项目初始化
This commit is contained in:
429
ruoyi-ui/src/views/out/addOutStockout.vue
Normal file
429
ruoyi-ui/src/views/out/addOutStockout.vue
Normal file
@@ -0,0 +1,429 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<!-- 主表信息录入 -->
|
||||
<el-form :model="formData" ref="formRef" size="small" :inline="true" label-width="68px" :rules="rules">
|
||||
<el-form-item :label="'仓库'" prop="warehouseId" required><!--仓库-->
|
||||
<el-select v-model="formData.warehouseId" :placeholder="'请选择仓库'" clearable>
|
||||
<el-option
|
||||
v-for="dict in warehouseOptions"
|
||||
:key="dict.warehouseId"
|
||||
:label="dict.warehouseName"
|
||||
:value="dict.warehouseId"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'客户'" prop="customerNo" required><!--客户-->
|
||||
<el-input
|
||||
v-model="formData.customerName"
|
||||
:placeholder="'请输入客户编号'"
|
||||
clearable
|
||||
@click.native="openCustomerSelector"
|
||||
readonly
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'单据类型'" prop="outType" required><!--单据类型-->
|
||||
<el-select v-model="formData.outType" :placeholder="'请选择单据类型'" clearable>
|
||||
<el-option
|
||||
v-for="dict in dict.type.out_bill_type"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="warning" icon="el-icon-refresh" size="mini" @click="reset">{{'重置'}}<!--重置--></el-button>
|
||||
<el-button type="success" icon="el-icon-check" size="mini" @click="handleSave" v-hasPermi="['out:outStockout:saveBill']">{{'保存单据'}}<!--保存单据--></el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<div class="mb8">
|
||||
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleSelectMaterials" v-hasPermi="['out:productAndStock:list']">{{'选择物资'}}<!--选择物资--></el-button>
|
||||
<el-button type="info" icon="el-icon-refresh-right" size="mini" @click="handleReload">{{'重新建单'}}<!--重新建单--></el-button>
|
||||
</div>
|
||||
|
||||
<!-- 物资明细表格 -->
|
||||
<el-table v-loading="loading" :data="materialList">
|
||||
<el-table-column :label="'物资编号'" align="left" prop="productId" /><!--物资编号-->
|
||||
<el-table-column :label="'物资名称'" align="left" prop="productName" /><!--物资名称-->
|
||||
<!-- <el-table-column :label="$t('addOutStockout.batchNo')" align="left" prop="lotNo" /><!–批号–>-->
|
||||
<el-table-column :label="'数量'" align="right" prop="quantity"><!--数量-->
|
||||
<template slot-scope="scope">
|
||||
<el-input-number v-model="scope.row.quantity" :min="1" size="mini" @change="handleQuantityChange(scope.row)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="'操作'" align="center" class-name="small-padding fixed-width"><!--操作-->
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.$index)">{{'删除'}}<!--删除--></el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- 选择物资弹窗 -->
|
||||
<el-dialog :title="'选择物资'" :visible.sync="materialDialog" width="800px" append-to-body><!--选择物资-->
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
|
||||
<el-form-item :label="'物资编码'" prop="productId"><!--物资编码-->
|
||||
<el-input
|
||||
v-model="queryParams.productId"
|
||||
:placeholder="'请输入物资编码'"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'物资名称'" prop="productName"><!--物资名称-->
|
||||
<el-input
|
||||
v-model="queryParams.productName"
|
||||
:placeholder="'请输入物资名称'"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">{{'搜索'}}<!--搜索--></el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置<!--重置--></el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-table v-loading="materialLoading" :data="materialOptions" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column :label="'物资编码'" align="left" prop="productId" /><!--物资编码-->
|
||||
<el-table-column :label="'物资名称'" align="left" prop="productName" /><!--物资名称-->
|
||||
<el-table-column :label="'数量'" align="right" prop="quantity" /><!--数量-->
|
||||
<el-table-column :label="'仓库'" align="left" prop="warehouseId" /><!--仓库-->
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getMaterialList"
|
||||
/>
|
||||
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="confirmSelectMaterials">{{'确定'}}<!--确 定--></el-button>
|
||||
<el-button @click="cancelSelectMaterials">{{'取消'}}<!--取 消--></el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 选择客户弹窗 -->
|
||||
<el-dialog :title="'客户管理'" :visible.sync="customerDialog" width="800px" append-to-body>
|
||||
<el-form :model="customerQueryParams" ref="customerQueryForm" size="small" :inline="true" label-width="100px">
|
||||
<el-form-item :label="'客户编号'" prop="customerNo"><!--客户编号-->
|
||||
<el-input
|
||||
v-model="customerQueryParams.customerNo"
|
||||
:placeholder="'请输入客户编号'"
|
||||
clearable
|
||||
@keyup.enter.native="handleCustomerQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'客户名称'" prop="customerName"><!--客户名称-->
|
||||
<el-input
|
||||
v-model="customerQueryParams.customerName"
|
||||
:placeholder="'请输入客户名称'"
|
||||
clearable
|
||||
@keyup.enter.native="handleCustomerQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleCustomerQuery">搜索<!--搜索--></el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetCustomerQuery">重置<!--重置--></el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-table ref="customerTable" v-loading="customerLoading" :data="customerList" @row-click="handleCustomerRowClick" highlight-current-row>
|
||||
<el-table-column :label="'客户编号'" align="left" prop="customerNo" /><!--客户编号-->
|
||||
<el-table-column :label="'客户名称'" align="left" prop="customerName" /><!--客户名称-->
|
||||
<!-- <el-table-column :label="$t('basCustomer.simpleName')" align="left" prop="simpleName" />客户简称 -->
|
||||
<el-table-column :label="'是否可用'" align="left" prop="useable">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.is_available" :value="scope.row.useable"/>
|
||||
</template>
|
||||
</el-table-column><!--是否可用-->
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="customerTotal > 0"
|
||||
:total="customerTotal"
|
||||
:page.sync="customerQueryParams.pageNum"
|
||||
:limit.sync="customerQueryParams.pageSize"
|
||||
@pagination="getCustomerList"
|
||||
/>
|
||||
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="confirmSelectCustomer">确定<!--确 定--></el-button>
|
||||
<el-button @click="cancelSelectCustomer">取消<!--取 消--></el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listProductAndStock,saveOutStock } from "@/api/out/outStockout";
|
||||
import {listWarehouse} from "@/api/bas/warehouse";
|
||||
import { listBasCustomer } from "@/api/bas/BasCustomer";
|
||||
import Pagination from "@/components/Pagination";
|
||||
|
||||
export default {
|
||||
name: "AddOutStock",
|
||||
dicts: ['out_bill_type', 'bill_status', 'is_available'],
|
||||
components: {
|
||||
Pagination
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: false,
|
||||
materialLoading: false,
|
||||
customerLoading: false,
|
||||
// 总条数
|
||||
total: 0,
|
||||
customerTotal: 0,
|
||||
// 表单验证规则
|
||||
rules: {
|
||||
warehouseId: [
|
||||
{ required: true, message: '请选择仓库', trigger: "change" }
|
||||
],
|
||||
customerNo: [
|
||||
{ required: true, message: '请输入客户编号', trigger: "blur" }
|
||||
],
|
||||
outType: [
|
||||
{ required: true, message: '请选择单据类型', trigger: "change" }
|
||||
]
|
||||
},
|
||||
// 主表数据
|
||||
formData: {
|
||||
warehouseId: null,
|
||||
customerNo: null,
|
||||
customerName: null, // 添加客户名称字段,用于显示
|
||||
outType: null
|
||||
},
|
||||
// 仓库选项
|
||||
warehouseOptions: [],
|
||||
// 物资明细列表
|
||||
materialList: [],
|
||||
// 选择物资弹窗
|
||||
materialDialog: false,
|
||||
// 物资选项数据
|
||||
materialOptions: [],
|
||||
// 已选择的物资
|
||||
selectedMaterials: [],
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
onlyIdentity: null,
|
||||
productId: null,
|
||||
lotNo: null,
|
||||
productName: null,
|
||||
quantity: null,
|
||||
warehouseId: null
|
||||
},
|
||||
// 客户选择弹窗
|
||||
customerDialog: false,
|
||||
// 客户列表数据
|
||||
customerList: [],
|
||||
// 当前选中的客户
|
||||
selectedCustomer: null,
|
||||
// 客户查询参数
|
||||
customerQueryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
customerNo: null,
|
||||
customerName: null,
|
||||
useable: '1' // 默认只查询可用的客户
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getWarehouseOptions();
|
||||
},
|
||||
methods: {
|
||||
/** 获取仓库选项 */
|
||||
getWarehouseOptions() {
|
||||
|
||||
listWarehouse({
|
||||
pageNum: 1,
|
||||
pageSize: 100
|
||||
}).then(response => {
|
||||
this.warehouseOptions = response.rows;
|
||||
});
|
||||
},
|
||||
/** 打开客户选择弹窗 */
|
||||
openCustomerSelector() {
|
||||
this.customerDialog = true;
|
||||
this.getCustomerList();
|
||||
},
|
||||
/** 获取客户列表 */
|
||||
getCustomerList() {
|
||||
this.customerLoading = true;
|
||||
listBasCustomer(this.customerQueryParams).then(response => {
|
||||
this.customerList = response.rows;
|
||||
this.customerTotal = response.total;
|
||||
this.customerLoading = false;
|
||||
});
|
||||
},
|
||||
/** 客户搜索按钮操作 */
|
||||
handleCustomerQuery() {
|
||||
this.customerQueryParams.pageNum = 1;
|
||||
this.getCustomerList();
|
||||
},
|
||||
/** 客户重置按钮操作 */
|
||||
resetCustomerQuery() {
|
||||
this.resetForm("customerQueryForm");
|
||||
this.customerQueryParams.useable = '1'; // 保持默认只查询可用的客户
|
||||
this.handleCustomerQuery();
|
||||
},
|
||||
/** 客户行点击事件 */
|
||||
handleCustomerRowClick(row) {
|
||||
this.selectedCustomer = row;
|
||||
this.$refs['customerTable']?.setCurrentRow(row);
|
||||
},
|
||||
/** 确认选择客户 */
|
||||
confirmSelectCustomer() {
|
||||
if (!this.selectedCustomer) {
|
||||
this.$modal.msgError('请选择客户');
|
||||
return;
|
||||
}
|
||||
this.formData.customerNo = this.selectedCustomer.customerNo;
|
||||
this.formData.customerName = this.selectedCustomer.customerName;
|
||||
this.customerDialog = false;
|
||||
},
|
||||
/** 取消选择客户 */
|
||||
cancelSelectCustomer() {
|
||||
this.selectedCustomer = null;
|
||||
this.customerDialog = false;
|
||||
},
|
||||
/** 打开选择物资弹窗 */
|
||||
handleSelectMaterials() {
|
||||
if (!this.formData.warehouseId) {
|
||||
this.$modal.msgError('请选择仓库');
|
||||
return;
|
||||
}
|
||||
this.materialDialog = true;
|
||||
this.queryParams.warehouseId = this.formData.warehouseId;
|
||||
this.getMaterialList();
|
||||
},
|
||||
/** 获取物资列表 */
|
||||
getMaterialList() {
|
||||
this.materialLoading = true;
|
||||
listProductAndStock(this.queryParams).then(response => {
|
||||
this.materialOptions = response.rows;
|
||||
this.total = response.total;
|
||||
this.materialLoading = false;
|
||||
});
|
||||
},
|
||||
/** 物资选择变更 */
|
||||
handleSelectionChange(selection) {
|
||||
this.selectedMaterials = selection;
|
||||
},
|
||||
/** 确认选择物资 */
|
||||
confirmSelectMaterials() {
|
||||
if (this.selectedMaterials.length === 0) {
|
||||
this.$modal.msgError('请选择物资');
|
||||
return;
|
||||
}
|
||||
// 过滤掉已经存在的物资
|
||||
const newMaterials = this.selectedMaterials.filter(item => {
|
||||
return !this.materialList.some(existing => existing.onlyIdentity === item.onlyIdentity);
|
||||
});
|
||||
|
||||
if (newMaterials.length === 0) {
|
||||
this.$modal.msgWarning('选择的物资已存在');
|
||||
return;
|
||||
}
|
||||
|
||||
this.materialList = this.materialList.concat(
|
||||
newMaterials.map(item => ({
|
||||
productId: item.productId,
|
||||
productName: item.productName,
|
||||
quantity: item.quantity,
|
||||
quantityOrignal: item.quantity,
|
||||
lotNo: item.lotNo,
|
||||
onlyIdentity: item.onlyIdentity
|
||||
}))
|
||||
);
|
||||
this.materialDialog = false;
|
||||
this.selectedMaterials = [];
|
||||
},
|
||||
/** 取消选择物资 */
|
||||
cancelSelectMaterials() {
|
||||
this.selectedMaterials = [];
|
||||
this.materialDialog = false;
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getMaterialList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
/** 删除物资 */
|
||||
handleDelete(index) {
|
||||
this.materialList.splice(index, 1);
|
||||
},
|
||||
/** 数量变更 */
|
||||
handleQuantityChange(row) {
|
||||
// 如果没有初始数量,则设置初始数量
|
||||
|
||||
// 如果修改后的数量大于初始数量,给出提示并重置为当前值
|
||||
if (row.quantity > row.quantityOrignal) {
|
||||
this.$modal.msgError('修改后的数量不能大于初始数量');
|
||||
row.quantity = row.quantityOrignal;
|
||||
}
|
||||
},
|
||||
/** 保存单据 */
|
||||
handleSave() {
|
||||
this.$refs.formRef.validate(valid => {
|
||||
if (valid) {
|
||||
if (this.materialList.length === 0) {
|
||||
this.$modal.msgError('请选择物资');
|
||||
return;
|
||||
}
|
||||
const data = {
|
||||
outStockout: this.formData,
|
||||
detailList: this.materialList
|
||||
};
|
||||
// 这里需要调用保存接口
|
||||
saveOutStock(data).then(response => {
|
||||
console.log(response)
|
||||
this.$modal.msgSuccess('操作成功'+":"+response.msg);
|
||||
this.$tab.refreshPage(this.$route);
|
||||
// this.reset();
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 重置数据 */
|
||||
reset() {
|
||||
this.formData = {
|
||||
warehouseId: null,
|
||||
customerNo: null,
|
||||
customerName: null,
|
||||
outType: null
|
||||
};
|
||||
this.materialList = [];
|
||||
this.selectedCustomer = null;
|
||||
},
|
||||
/** 重新建单 */
|
||||
handleReload() {
|
||||
this.$tab.refreshPage(this.$route);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
.el-table >>> .current-row {
|
||||
background-color: #f0f9eb;
|
||||
}
|
||||
.el-form-item >>> .el-form-item__label {
|
||||
white-space: nowrap;
|
||||
width: auto;
|
||||
min-width: fit-content;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user