|
|
@@ -12,6 +12,7 @@
|
|
|
full-height="calc(100vh - 76px)"
|
|
|
:show-summary="clientEnvironmentId == 4"
|
|
|
:summary-method="getSummaries"
|
|
|
+ :row-class-name="tableRowClassName"
|
|
|
>
|
|
|
<!-- 表头工具栏 -->
|
|
|
<template v-slot:toolbar>
|
|
|
@@ -180,7 +181,7 @@
|
|
|
<el-select
|
|
|
v-model="scope.row.warehouseId"
|
|
|
placeholder="请选择"
|
|
|
- @change="warehouseChange(scope.$index, scope.row)"
|
|
|
+ @change="warehouseChange(scope.$index, scope.row, true)"
|
|
|
>
|
|
|
<el-option
|
|
|
v-for="item in scope.row.warehouseList"
|
|
|
@@ -289,6 +290,21 @@
|
|
|
</el-input>
|
|
|
</el-form-item>
|
|
|
</template>
|
|
|
+ <template v-slot:warehouseNum="scope">
|
|
|
+ <el-form-item
|
|
|
+ :prop="'datasource.' + scope.$index + '.warehouseNum'"
|
|
|
+ >
|
|
|
+ <el-link
|
|
|
+ v-if="scope.row.isSuspend === 1"
|
|
|
+ :underline="false"
|
|
|
+ type="primary"
|
|
|
+ @click="pendingReplaceTable(scope.row, scope.$index)"
|
|
|
+ >
|
|
|
+ {{ scope.row.warehouseNum }}
|
|
|
+ </el-link>
|
|
|
+ <span v-else>{{ scope.row.warehouseNum }}</span>
|
|
|
+ </el-form-item>
|
|
|
+ </template>
|
|
|
<!-- <template v-slot:saleUnit="scope">
|
|
|
<el-form-item
|
|
|
style="margin-bottom: 20px"
|
|
|
@@ -361,6 +377,27 @@
|
|
|
>
|
|
|
替代料
|
|
|
</el-link>
|
|
|
+
|
|
|
+ <template v-if="scope.row.batchNo">
|
|
|
+ <el-popconfirm
|
|
|
+ v-if="scope.row.isSuspend === 1"
|
|
|
+ class="ele-action"
|
|
|
+ title="确定要挂起吗?"
|
|
|
+ @confirm="pending(scope.row, 0)"
|
|
|
+ >
|
|
|
+ <template v-slot:reference>
|
|
|
+ <el-link
|
|
|
+ type="primary"
|
|
|
+ :underline="false"
|
|
|
+ >
|
|
|
+ 取消挂起
|
|
|
+ </el-link>
|
|
|
+ </template>
|
|
|
+ </el-popconfirm>
|
|
|
+ <el-link v-else type="primary" :underline="false" @click="pendingReplaceTable(scope.row, scope.$index)">
|
|
|
+ 挂起
|
|
|
+ </el-link>
|
|
|
+ </template>
|
|
|
</template>
|
|
|
</ele-pro-table>
|
|
|
<productListNew
|
|
|
@@ -385,6 +422,10 @@
|
|
|
ref="selectStockLedgerDialogRef"
|
|
|
@changeParent="replaceTable"
|
|
|
></selectStockLedgerDialog>
|
|
|
+ <selectStockLedgerDialogPending
|
|
|
+ ref="selectStockLedgerDialogPendingRef"
|
|
|
+ @changeParent="pendingReplaceTableConfirm"
|
|
|
+ ></selectStockLedgerDialogPending>
|
|
|
<BIZproductList
|
|
|
ref="BIZproductListRef"
|
|
|
classType="1"
|
|
|
@@ -420,6 +461,7 @@
|
|
|
import { parameterGetByCode } from '@/api/main/index.js';
|
|
|
import { getSummaries } from '@/utils/util.js';
|
|
|
import { getBatchList } from '@/api/wms';
|
|
|
+ import selectStockLedgerDialogPending from './selectStockLedger/selectStockLedgerDialog.vue';
|
|
|
|
|
|
export default {
|
|
|
mixins: [dictMixins, getDynamicsColumns, tabMixins],
|
|
|
@@ -455,7 +497,8 @@
|
|
|
productListNew,
|
|
|
stockLedgerDialog,
|
|
|
selectStockLedgerDialog,
|
|
|
- BIZproductList
|
|
|
+ BIZproductList,
|
|
|
+ selectStockLedgerDialogPending
|
|
|
},
|
|
|
data() {
|
|
|
const defaultForm = {
|
|
|
@@ -931,7 +974,7 @@
|
|
|
{
|
|
|
columnKey: 'action',
|
|
|
label: '操作',
|
|
|
- width: 180,
|
|
|
+ width: 200,
|
|
|
align: 'center',
|
|
|
resizable: false,
|
|
|
slot: 'action',
|
|
|
@@ -945,6 +988,52 @@
|
|
|
// this.clientEnvironmentId =
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 挂起/取消挂起功能
|
|
|
+ async pending(row) {
|
|
|
+ console.log('pending~~~', row)
|
|
|
+ // 取消挂起不需要二次确认
|
|
|
+ this.$set(row, 'isSuspend', 0);
|
|
|
+ this.$forceUpdate();
|
|
|
+ this.current['offsetDetail'] = [];
|
|
|
+ this.current['isSuspend'] = 0;
|
|
|
+ this.$set(this.current, 'warehouseList', await getIdWarehouseList({
|
|
|
+ categoryId: this.current.id
|
|
|
+ }))
|
|
|
+ this.$set(this.current, 'warehouseId', '')
|
|
|
+ },
|
|
|
+ // 通过挂起状态设置行样式
|
|
|
+ tableRowClassName({row}) {
|
|
|
+ // console.log('tableRowClassName', row)
|
|
|
+ if (row.isSuspend == 1) {
|
|
|
+ return 'warning-row';
|
|
|
+ }
|
|
|
+ return '';
|
|
|
+ },
|
|
|
+ // 挂起选择库存
|
|
|
+ pendingReplaceTable(row, index) {
|
|
|
+ // console.log('handleWarehouseClick', row, index)
|
|
|
+ this.current = row;
|
|
|
+ this.$refs.selectStockLedgerDialogPendingRef.open(row, index)
|
|
|
+ },
|
|
|
+ pendingReplaceTableConfirm(list) {
|
|
|
+ console.log('confirm', list)
|
|
|
+ list.forEach((item) => {
|
|
|
+ item.warehouseList =[{
|
|
|
+ warehouseName: item.warehouseName,
|
|
|
+ warehouseId: item.warehouseId,
|
|
|
+ }]
|
|
|
+ });
|
|
|
+
|
|
|
+ this.$set(this.current, 'warehouseList', list[0].warehouseList)
|
|
|
+ this.$set(this.current, 'warehouseId', list[0].warehouseId)
|
|
|
+ this.$set(this.current, 'warehouseNum', list[0].measureQuantity)
|
|
|
+ this.current['offsetDetail'] = list
|
|
|
+ this.$set(this.current, 'isSuspend', 1)
|
|
|
+ console.log('current', this.current)
|
|
|
+ // this.$emit('pendingReplaceTableConfirm', list);
|
|
|
+ // this.$emit('replaceTableChange', list);
|
|
|
+ // console.log('pendingReplaceTableConfirm', list)
|
|
|
+ },
|
|
|
getSummaries(param) {
|
|
|
if (this.clientEnvironmentId != 4) {
|
|
|
return;
|
|
|
@@ -1029,7 +1118,7 @@
|
|
|
this.selection = [];
|
|
|
},
|
|
|
|
|
|
- async warehouseChange(index, row) {
|
|
|
+ async warehouseChange(index, row, isReset = false) {
|
|
|
const data = row.warehouseList.find(
|
|
|
(item) => item.warehouseId == row.warehouseId
|
|
|
);
|
|
|
@@ -1054,13 +1143,32 @@
|
|
|
warehouseOutStock || 0
|
|
|
);
|
|
|
|
|
|
- // this.$set(this.form.datasource[index], 'batchStockId', '');
|
|
|
-
|
|
|
- // this.$set(this.form.datasource[index], 'batchNo', '');
|
|
|
+ if(isReset) {
|
|
|
+ this.$set(this.form.datasource[index], 'batchStockId', '');
|
|
|
+ this.$set(this.form.datasource[index], 'batchNo', '');
|
|
|
+ }
|
|
|
+
|
|
|
},
|
|
|
|
|
|
//批次号选择
|
|
|
async batchNoChange(index, row) {
|
|
|
+ if(!row.batchStockId) {
|
|
|
+ this.$set(this.form.datasource[index], 'batchNo', '');
|
|
|
+ this.$set(this.form.datasource[index], 'warehouseNum', '');
|
|
|
+ const tempWarehouse = await getIdWarehouseList({
|
|
|
+ categoryId: this.form.datasource[index].productId,
|
|
|
+ })
|
|
|
+ // 有仓库列表
|
|
|
+ if (tempWarehouse?.length) {
|
|
|
+ console.log('666~~~~!!', index, tempWarehouse);
|
|
|
+ this.$set(
|
|
|
+ this.form.datasource[index],
|
|
|
+ 'warehouseList',
|
|
|
+ tempWarehouse
|
|
|
+ );
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
const data = row.batchNoList.find(
|
|
|
(item) => item.id == row.batchStockId
|
|
|
);
|
|
|
@@ -1403,72 +1511,369 @@
|
|
|
});
|
|
|
this.form.datasource.forEach(async (item, index) => {
|
|
|
if (indexS.includes(index)) {
|
|
|
+ if(!item.batchNo) {
|
|
|
+ console.log('111~~~~', index);
|
|
|
+ this.$set(
|
|
|
+ this.form.datasource[index],
|
|
|
+ 'warehouseList',
|
|
|
+ await getIdWarehouseList({
|
|
|
+ categoryId: item.productId
|
|
|
+ })
|
|
|
+ );
|
|
|
+ if (item.warehouseId) {
|
|
|
+ this.$set(
|
|
|
+ this.form.datasource[index],
|
|
|
+ 'warehouseNum',
|
|
|
+ item.stockNum ? item.stockNum : await getWarehouseOutStock({
|
|
|
+ warehouseId: item.warehouseId,
|
|
|
+ code: item.productCode
|
|
|
+ })
|
|
|
+ );
|
|
|
+ } else if (this.form.datasource[index]?.warehouseList?.length) {
|
|
|
+ this.$set(
|
|
|
+ this.form.datasource[index],
|
|
|
+ 'warehouseId',
|
|
|
+ this.form.datasource[index]?.warehouseList[0].warehouseId
|
|
|
+ );
|
|
|
+ await this.warehouseChange(index, this.form.datasource[index]);
|
|
|
+ }
|
|
|
+
|
|
|
+ const templist = await getBatchList({
|
|
|
+ categoryCode: item.productCode,
|
|
|
+ warehouseId: item.warehouseId,
|
|
|
+ size: -1
|
|
|
+ });
|
|
|
+
|
|
|
+ console.log('templist~~~~', index, templist.list);
|
|
|
+
|
|
|
+ // 批次号
|
|
|
+ this.$set(
|
|
|
+ this.form.datasource[index],
|
|
|
+ 'batchNoList',
|
|
|
+ templist?.list || []
|
|
|
+ );
|
|
|
+ // console.log(this.form.datasource[index]);
|
|
|
+ } else {
|
|
|
+ this.setBatchAndWarehouse(item, index);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ async setBatchAndWarehouse(item, index) {
|
|
|
+ console.log('333~~~~', index);
|
|
|
+ // 通过产品编码查仓库
|
|
|
+ const tempWarehouse = await getIdWarehouseList({
|
|
|
+ categoryId: item.productId,
|
|
|
+ })
|
|
|
+ // 有仓库列表
|
|
|
+ if (tempWarehouse?.length) {
|
|
|
+ console.log('666~~~~', index, tempWarehouse);
|
|
|
this.$set(
|
|
|
this.form.datasource[index],
|
|
|
'warehouseList',
|
|
|
- await getIdWarehouseList({
|
|
|
- categoryId: item.productId
|
|
|
- })
|
|
|
+ tempWarehouse
|
|
|
);
|
|
|
if (item.warehouseId) {
|
|
|
this.$set(
|
|
|
this.form.datasource[index],
|
|
|
'warehouseNum',
|
|
|
- await getWarehouseOutStock({
|
|
|
+ item.stockNum ? item.stockNum : await getWarehouseOutStock({
|
|
|
warehouseId: item.warehouseId,
|
|
|
code: item.productCode
|
|
|
})
|
|
|
);
|
|
|
- } else if (this.form.datasource[index]?.warehouseList?.length) {
|
|
|
- this.$set(
|
|
|
- this.form.datasource[index],
|
|
|
- 'warehouseId',
|
|
|
- this.form.datasource[index]?.warehouseList[0].warehouseId
|
|
|
- );
|
|
|
- await this.warehouseChange(index, this.form.datasource[index]);
|
|
|
+ } else {
|
|
|
+ if (this.form.datasource[index]?.warehouseList?.length) {
|
|
|
+ this.$set(
|
|
|
+ this.form.datasource[index],
|
|
|
+ 'warehouseId',
|
|
|
+ this.form.datasource[index]?.warehouseList[0].warehouseId
|
|
|
+ );
|
|
|
+ await this.warehouseChange(index, this.form.datasource[index]);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- const templist = await getBatchList({
|
|
|
+ const templist1 = await getBatchList({
|
|
|
categoryCode: item.productCode,
|
|
|
warehouseId: item.warehouseId,
|
|
|
size: -1
|
|
|
});
|
|
|
|
|
|
- console.log('templist~~~~', templist.list);
|
|
|
+ let tempBatchNoList = templist1?.list || [];
|
|
|
+ console.log('888~~~~', index, item.batchNo);
|
|
|
|
|
|
- // 批次号
|
|
|
+ const batchNoObj = tempBatchNoList.find(i => i.batchNo == item.batchNo);
|
|
|
+
|
|
|
+ if(batchNoObj) {
|
|
|
+ this.$set(
|
|
|
+ this.form.datasource[index],
|
|
|
+ 'batchStockId',
|
|
|
+ batchNoObj.id
|
|
|
+ );
|
|
|
+ this.$set(
|
|
|
+ this.form.datasource[index],
|
|
|
+ 'warehouseNum',
|
|
|
+ item.stockNum ? item.stockNum : batchNoObj.measureQuantity || 0
|
|
|
+ );
|
|
|
+ } else { //不存在
|
|
|
+ // 批次列表添加不存在的批次号对象
|
|
|
+ tempBatchNoList.push({
|
|
|
+ batchNo: item.batchNo,
|
|
|
+ id: 999,
|
|
|
+ measureQuantity: 0
|
|
|
+ })
|
|
|
+ // 设置为不存在的批次ID
|
|
|
+ this.$set(
|
|
|
+ this.form.datasource[index],
|
|
|
+ 'batchStockId',
|
|
|
+ 999
|
|
|
+ );
|
|
|
+ this.$set(
|
|
|
+ this.form.datasource[index],
|
|
|
+ 'warehouseNum',
|
|
|
+ item.stockNum ? item.stockNum : ''
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ // // 批次号
|
|
|
this.$set(
|
|
|
this.form.datasource[index],
|
|
|
'batchNoList',
|
|
|
- templist?.list || []
|
|
|
+ tempBatchNoList
|
|
|
);
|
|
|
- console.log(this.form.datasource[index]);
|
|
|
+ } else {
|
|
|
if(item.batchNo) {
|
|
|
- const batchStockId = templist?.list?.find((n) => n.batchNo == item.batchNo)?.id
|
|
|
- if(batchStockId) {
|
|
|
+ const tempBatchNoList = [{
|
|
|
+ batchNo: item.batchNo,
|
|
|
+ id: 999,
|
|
|
+ measureQuantity: 0
|
|
|
+ }]
|
|
|
+ this.$set(
|
|
|
+ this.form.datasource[index],
|
|
|
+ 'batchNoList',
|
|
|
+ tempBatchNoList
|
|
|
+ );
|
|
|
+ this.$set(
|
|
|
+ this.form.datasource[index],
|
|
|
+ 'batchStockId',
|
|
|
+ 999
|
|
|
+ );
|
|
|
+ this.$set(
|
|
|
+ this.form.datasource[index],
|
|
|
+ 'warehouseNum',
|
|
|
+ item.stockNum ? item.stockNum : ''
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async setBatchAndWarehouse1(item, index) {
|
|
|
+ // 通过产品编号和批次号获取仓库列表
|
|
|
+ const warehouse = await getIdWarehouseList({
|
|
|
+ categoryId: item.productId,
|
|
|
+ // batchNo: item.batchNo
|
|
|
+ })
|
|
|
+ // 如果有仓库列表
|
|
|
+ if (warehouse?.length) {
|
|
|
+ console.log('222~~~~', index, item.batchNo);
|
|
|
+ // 设置仓库列表
|
|
|
+ this.$set(
|
|
|
+ this.form.datasource[index],
|
|
|
+ 'warehouseList',
|
|
|
+ warehouse
|
|
|
+ );
|
|
|
+ // 如果有仓库ID
|
|
|
+ if (item.warehouseId) {
|
|
|
+ // console.log('444~~~~');
|
|
|
+ // const templist = await getBatchList({
|
|
|
+ // categoryCode: item.productCode,
|
|
|
+ // warehouseId: item.warehouseId,
|
|
|
+ // size: -1
|
|
|
+ // });
|
|
|
+ // const batchNoList = templist?.list || [];
|
|
|
+ // // 批次号
|
|
|
+ // this.$set(
|
|
|
+ // this.form.datasource[index],
|
|
|
+ // 'batchNoList',
|
|
|
+ // batchNoList
|
|
|
+ // );
|
|
|
+ // const batchNo = batchNoList.find(i => i.batchNo === item.batchNo);
|
|
|
+ // if (batchNo) {
|
|
|
+ // this.$set(
|
|
|
+ // this.form.datasource[index],
|
|
|
+ // 'batchStockId',
|
|
|
+ // batchNo.id
|
|
|
+ // );
|
|
|
+ // this.$set(
|
|
|
+ // this.form.datasource[index],
|
|
|
+ // 'warehouseNum',
|
|
|
+ // data.measureQuantity || 0
|
|
|
+ // );
|
|
|
+ // }
|
|
|
+
|
|
|
+ }
|
|
|
+ // 没有仓库ID,设置第一个仓库ID
|
|
|
+ else {
|
|
|
+ if (this.form.datasource[index]?.warehouseList?.length){
|
|
|
+ console.log('555~~~~', index);
|
|
|
+ this.$set(
|
|
|
+ this.form.datasource[index],
|
|
|
+ 'warehouseId',
|
|
|
+ this.form.datasource[index]?.warehouseList[0].warehouseId
|
|
|
+ );
|
|
|
+
|
|
|
+ // await this.warehouseChange(index, this.form.datasource[index]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // const wdata = warehouse.find(
|
|
|
+ // (i) => i.warehouseId == row.warehouseId
|
|
|
+ // );
|
|
|
+
|
|
|
+ // this.$set(
|
|
|
+ // this.form.datasource[index],
|
|
|
+ // 'warehouseName',
|
|
|
+ // wdata.warehouseName
|
|
|
+ // );
|
|
|
+ // this.$set(
|
|
|
+ // this.form.datasource[index],
|
|
|
+ // 'warehouseCode',
|
|
|
+ // wdata.warehouseCode
|
|
|
+ // );
|
|
|
+ // const warehouseOutStock = await getWarehouseOutStock({
|
|
|
+ // warehouseId: wdata.warehouseId,
|
|
|
+ // code: row.productCode
|
|
|
+ // });
|
|
|
+ // this.$set(
|
|
|
+ // this.form.datasource[index],
|
|
|
+ // 'warehouseNum',
|
|
|
+ // warehouseOutStock || 0
|
|
|
+ // );
|
|
|
+
|
|
|
+ console.log('444~~~~');
|
|
|
+ // 通过仓库ID获取批次号列表
|
|
|
+ const templist = await getBatchList({
|
|
|
+ categoryCode: item.productCode,
|
|
|
+ warehouseId: item.warehouseId,
|
|
|
+ size: -1
|
|
|
+ });
|
|
|
+ let batchNoList = templist?.list || [];
|
|
|
+ console.log('batchNoList~~~~', index, batchNoList);
|
|
|
+ // 设置批次列表
|
|
|
+ this.$set(
|
|
|
+ this.form.datasource[index],
|
|
|
+ 'batchNoList',
|
|
|
+ batchNoList
|
|
|
+ );
|
|
|
+ // 查找批次号是否存在批次列表
|
|
|
+ const batchNo = batchNoList.find(i => i.batchNo == item.batchNo);
|
|
|
+ console.log('batchNo~~~~', index, batchNo);
|
|
|
+ // 存在
|
|
|
+ if (batchNo) {
|
|
|
+ // 设置批次ID
|
|
|
+ this.$set(
|
|
|
+ this.form.datasource[index],
|
|
|
+ 'batchStockId',
|
|
|
+ batchNo.id
|
|
|
+ );
|
|
|
+ // 设置批次库存
|
|
|
+ this.$set(
|
|
|
+ this.form.datasource[index],
|
|
|
+ 'warehouseNum',
|
|
|
+ batchNo.measureQuantity || 0
|
|
|
+ );
|
|
|
+
|
|
|
+ } else { //不存在
|
|
|
+ // 批次列表添加不存在的批次号对象
|
|
|
+ batchNoList = batchNoList.push({
|
|
|
+ batchNo: item.batchNo,
|
|
|
+ id: 999,
|
|
|
+ measureQuantity: 0
|
|
|
+ })
|
|
|
+ // 设置为不存在的批次ID
|
|
|
+ this.$set(
|
|
|
+ this.form.datasource[index],
|
|
|
+ 'batchStockId',
|
|
|
+ 999
|
|
|
+ );
|
|
|
+ this.$set(
|
|
|
+ this.form.datasource[index],
|
|
|
+ 'warehouseNum',
|
|
|
+ ''
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 如果没有仓库列表
|
|
|
+ else {
|
|
|
+ console.log('333~~~~', index);
|
|
|
+ // 通过产品编码查仓库
|
|
|
+ const tempWarehouse = await getIdWarehouseList({
|
|
|
+ categoryId: item.productId,
|
|
|
+ })
|
|
|
+ // 有仓库列表
|
|
|
+ if (tempWarehouse?.length) {
|
|
|
+ console.log('666~~~~', index, tempWarehouse);
|
|
|
+ this.$set(
|
|
|
+ this.form.datasource[index],
|
|
|
+ 'warehouseList',
|
|
|
+ tempWarehouse
|
|
|
+ );
|
|
|
+ if (item.warehouseId) {
|
|
|
+ this.$set(
|
|
|
+ this.form.datasource[index],
|
|
|
+ 'warehouseNum',
|
|
|
+ await getWarehouseOutStock({
|
|
|
+ warehouseId: item.warehouseId,
|
|
|
+ code: item.productCode
|
|
|
+ })
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ if (this.form.datasource[index]?.warehouseList?.length) {
|
|
|
this.$set(
|
|
|
this.form.datasource[index],
|
|
|
- 'batchStockId',
|
|
|
- batchStockId
|
|
|
+ 'warehouseId',
|
|
|
+ this.form.datasource[index]?.warehouseList[0].warehouseId
|
|
|
);
|
|
|
+ await this.warehouseChange(index, this.form.datasource[index]);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
- // if (item.batchStockId) {
|
|
|
- // // this.$set(
|
|
|
- // // this.form.datasource[index],
|
|
|
- // // 'warehouseNum',
|
|
|
- // // await getWarehouseOutStock({
|
|
|
- // // warehouseId: item.warehouseId,
|
|
|
- // // code: item.productCode
|
|
|
- // // })
|
|
|
- // // );
|
|
|
-
|
|
|
- // await this.batchNoChange(index, this.form.datasource[index]);
|
|
|
- // }
|
|
|
+
|
|
|
+ const templist1 = await getBatchList({
|
|
|
+ categoryCode: item.productCode,
|
|
|
+ warehouseId: item.warehouseId,
|
|
|
+ size: -1
|
|
|
+ });
|
|
|
+
|
|
|
+ let tempBatchNoList = templist1?.list || [];
|
|
|
+ console.log('888~~~~', index, item.batchNo);
|
|
|
+ tempBatchNoList.push({
|
|
|
+ batchNo: item.batchNo,
|
|
|
+ id: 999,
|
|
|
+ measureQuantity: 0
|
|
|
+ })
|
|
|
+ console.log('tempBatchNoList~~~~', index, tempBatchNoList);
|
|
|
+ // 批次号
|
|
|
+ this.$set(
|
|
|
+ this.form.datasource[index],
|
|
|
+ 'batchNoList',
|
|
|
+ tempBatchNoList
|
|
|
+ );
|
|
|
+ this.$set(
|
|
|
+ this.form.datasource[index],
|
|
|
+ 'batchStockId',
|
|
|
+ 999
|
|
|
+ );
|
|
|
+ this.$set(
|
|
|
+ this.form.datasource[index],
|
|
|
+ 'warehouseNum',
|
|
|
+ ''
|
|
|
+ );
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
+
|
|
|
},
|
|
|
-
|
|
|
remove(i) {
|
|
|
this.form.datasource.splice(i, 1);
|
|
|
this.setSort();
|
|
|
@@ -1501,10 +1906,18 @@
|
|
|
//开始表单校验
|
|
|
this.$refs.form.validate((valid, obj) => {
|
|
|
let is = false;
|
|
|
+ let isBatchNo = false;
|
|
|
+ let isSuspend = false;
|
|
|
this.form.datasource.forEach((item) => {
|
|
|
if (Number(item.totalCount) > item.orderTotalCount) {
|
|
|
is = true;
|
|
|
}
|
|
|
+ if (item.batchStockId == 999) {
|
|
|
+ isBatchNo = true;
|
|
|
+ }
|
|
|
+ if(item.isSuspend == 1 && (Number(item.totalCount) > item.warehouseNum)) {
|
|
|
+ isSuspend = true;
|
|
|
+ }
|
|
|
});
|
|
|
// 退货单退货不校验数量,实物赔偿无法计算
|
|
|
if (is && this.sourceType != 3) {
|
|
|
@@ -1513,6 +1926,15 @@
|
|
|
callback(false);
|
|
|
}
|
|
|
}
|
|
|
+ if (isBatchNo) {
|
|
|
+ this.$message.warning('你填的批次号与库存批次号不相符,请重新选择批次号出库或删除批次号');
|
|
|
+ callback(false);
|
|
|
+ }
|
|
|
+ if (isSuspend) {
|
|
|
+ this.$message.warning('挂起产品发货数量不能大于库存');
|
|
|
+ callback(false);
|
|
|
+ }
|
|
|
+
|
|
|
if (obj) {
|
|
|
let messages = Object.keys(obj).map((key) => obj[key][0]);
|
|
|
if (messages.length > 0) {
|
|
|
@@ -1522,11 +1944,147 @@
|
|
|
|
|
|
callback(valid);
|
|
|
});
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 优化后的表单校验方法 - 重构版本
|
|
|
+ * 添加了详细的注释、错误消息常量和更清晰的结构
|
|
|
+ */
|
|
|
+ validateFormOptimized(callback) {
|
|
|
+ // 使用常量存储错误消息
|
|
|
+ const ERROR_MESSAGES = {
|
|
|
+ QUANTITY_EXCEEDS_ORDER: '发货数量大于订单总数量',
|
|
|
+ BATCH_NUMBER_INVALID: '你填的批次号与库存批次号不相符,请重新选择批次号出库或删除批次号',
|
|
|
+ SUSPENDED_PRODUCT_OVERSTOCK: '挂起产品发货数量不能大于库存'
|
|
|
+ };
|
|
|
+
|
|
|
+ // 开始表单校验
|
|
|
+ this.$refs.form.validate((valid, obj) => {
|
|
|
+ // 收集所有校验错误
|
|
|
+ const errors = [];
|
|
|
+
|
|
|
+ // 遍历数据源进行业务规则校验
|
|
|
+ this.form.datasource.forEach((item, index) => {
|
|
|
+ const productInfo = this.getProductDisplayInfo(item);
|
|
|
+
|
|
|
+ // 检查数量是否超过订单数量(退货单除外)
|
|
|
+ if (this.isQuantityExceedsOrder(item)) {
|
|
|
+ if (this.sourceType != 3) { // 非退货单
|
|
|
+ errors.push({
|
|
|
+ type: 'quantity',
|
|
|
+ message: `产品[${productInfo.name}]的发货数量${item.totalCount}大于订单总数量${item.orderTotalCount}`,
|
|
|
+ stopValidation: this.isTotalCount == 1,
|
|
|
+ item: item
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查批次号是否正确
|
|
|
+ // if (this.isBatchNumberInvalid(item)) {
|
|
|
+ // errors.push({
|
|
|
+ // type: 'batch',
|
|
|
+ // message: `产品[${productInfo.name}]填写的批次号与库存批次号不相符,请重新选择批次号出库或删除批次号`,
|
|
|
+ // stopValidation: true,
|
|
|
+ // item: item
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+
|
|
|
+ if (this.isBatchNumberInvalid(item) && item.isSuspend != 1) {
|
|
|
+ // 获取当前批次号和正确的库存批次号信息
|
|
|
+ const currentBatchNumber = item.batchNo || '未填写';
|
|
|
+ // const availableBatches = item.availableBatchNumbers || item.validBatchNumbers || [];
|
|
|
+ // const batchInfo = availableBatches.length > 0
|
|
|
+ // ? `当前可选择批次号:${availableBatches.join('、')}`
|
|
|
+ // : '当前无有效批次';
|
|
|
+
|
|
|
+ errors.push({
|
|
|
+ type: 'batch',
|
|
|
+ message: `第${index + 1}条产品[${productInfo.name}]填写的批次号"${currentBatchNumber}"与库存批次号不相符,请重新选择批次号出库或删除批次号`,
|
|
|
+ stopValidation: true,
|
|
|
+ item: item
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查挂起产品库存
|
|
|
+ if (this.isSuspendedProductOverstock(item)) {
|
|
|
+ errors.push({
|
|
|
+ type: 'suspend',
|
|
|
+ message: `挂起产品[${productInfo.name}]的发货数量${item.totalCount}不能大于库存${item.warehouseNum}`,
|
|
|
+ stopValidation: true,
|
|
|
+ item: item
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 如果存在错误,显示第一个错误并根据情况终止校验
|
|
|
+ if (errors.length > 0) {
|
|
|
+ this.$message.warning(errors[0].message);
|
|
|
+ if (errors[0].stopValidation) {
|
|
|
+ callback(false);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 显示表单字段错误(如果存在)
|
|
|
+ if (obj) {
|
|
|
+ let messages = Object.keys(obj).map((key) => obj[key][0]);
|
|
|
+ if (messages.length > 0) {
|
|
|
+ this.$message.warning(messages[0].message);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ callback(valid);
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 检查数量是否超过订单数量
|
|
|
+ * @param {Object} item 数据项
|
|
|
+ * @returns {boolean} 是否超过
|
|
|
+ */
|
|
|
+ isQuantityExceedsOrder(item) {
|
|
|
+ return Number(item.totalCount) > item.orderTotalCount;
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 检查批次号是否无效
|
|
|
+ * @param {Object} item 数据项
|
|
|
+ * @returns {boolean} 是否无效
|
|
|
+ */
|
|
|
+ isBatchNumberInvalid(item) {
|
|
|
+ return item.batchStockId == 999;
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 检查挂起产品是否超过库存
|
|
|
+ * @param {Object} item 数据项
|
|
|
+ * @returns {boolean} 是否超过
|
|
|
+ */
|
|
|
+ isSuspendedProductOverstock(item) {
|
|
|
+ return item.isSuspend == 1 && Number(item.totalCount) > item.warehouseNum;
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取产品显示信息
|
|
|
+ * @param {Object} item 数据项
|
|
|
+ * @returns {Object} 包含产品名称和编码的对象
|
|
|
+ */
|
|
|
+ getProductDisplayInfo(item) {
|
|
|
+ return {
|
|
|
+ name: item.productName || item.name || '未知产品',
|
|
|
+ code: item.productCode || item.code || '',
|
|
|
+ info: item.productName && item.productCode
|
|
|
+ ? `${item.productName}(${item.productCode})`
|
|
|
+ : (item.productName || item.name || '未知产品')
|
|
|
+ };
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
</script>
|
|
|
<style lang="scss" scoped>
|
|
|
+ ::v-deep .el-table .warning-row {
|
|
|
+ background: #d9ecff;
|
|
|
+ }
|
|
|
.headbox {
|
|
|
display: flex;
|
|
|
justify-content: flex-start;
|
|
|
@@ -1565,9 +2123,9 @@
|
|
|
background-color: transparent !important;
|
|
|
}
|
|
|
|
|
|
- ::v-deep .time-form .el-table tr {
|
|
|
- background-color: #ffffff;
|
|
|
- }
|
|
|
+ // ::v-deep .time-form .el-table tr {
|
|
|
+ // background-color: #ffffff;
|
|
|
+ // }
|
|
|
|
|
|
.pricebox {
|
|
|
display: flex;
|