|
@@ -202,54 +202,90 @@
|
|
|
</el-row>
|
|
|
<!--待出库明细表单-->
|
|
|
<el-dialog :title="$t('oldOutStock.dialog.title')" :visible.sync="dckOpen" append-to-body width="1200px" >
|
|
|
-
|
|
|
+ <el-form :inline="true" :model="formInline" class="demo-form-inline">
|
|
|
+ <el-form-item label="批号">
|
|
|
+ <el-input v-model="formInline.lotNum" placeholder="批号"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" @click="onSubmit">查询</el-button>
|
|
|
+ <el-button @click="onSubmitcz">查询</el-button>
|
|
|
+ <el-button type="primary" @click="batchOutStock">批量出库</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
<div>
|
|
|
<p style="font-size: 20px;color: red;margin-left: 815px">{{ $t('oldOutStock.dialog.demandBoxCount') }}:<span style="margin-right: 30px">{{xqxs}}</span>{{ $t('oldOutStock.dialog.demandWeight') }}:<span>{{ xqzl }}</span></p>
|
|
|
</div>
|
|
|
<el-table
|
|
|
:data="tableData"
|
|
|
border
|
|
|
- style="width: 100%">
|
|
|
+ style="width: 100%"
|
|
|
+ @selection-change="handleSelectionChange">
|
|
|
+ <el-table-column type="selection" width="55"></el-table-column>
|
|
|
<el-table-column prop="productName" :label="$t('oldOutStock.dialog.name')" align="center" ></el-table-column>
|
|
|
<el-table-column prop="lotNum" :label="$t('oldOutStock.dialog.batchNumber')" align="center" ></el-table-column>
|
|
|
<el-table-column prop="levels" :label="$t('oldOutStock.dialog.level')" align="center" ></el-table-column>
|
|
|
<el-table-column prop="productColour" :label="$t('oldOutStock.dialog.color')" align="center" ></el-table-column>
|
|
|
<el-table-column prop="totalBoxNum" :label="$t('oldOutStock.dialog.inventoryBoxCount')" align="center" ></el-table-column>
|
|
|
<el-table-column prop="totalGrossWeight" :label="$t('oldOutStock.dialog.inventoryWeight')" align="center" ></el-table-column>
|
|
|
- <el-table-column align="center" :label="$t('normal.operation')" width="600px">
|
|
|
-
|
|
|
- <el-table-column align="center" :label="$t('oldOutStock.dialog.actualBoxCount')" prop="oldActualBoxNum">
|
|
|
- <template slot-scope="{ row, $index }">
|
|
|
- <el-form :model="row" :rules="getRules2($index)" :ref="`boxFormRef${$index}`" :inline="true" style="margin-top: 20px;">
|
|
|
- <el-form-item prop="oldActualBoxNum">
|
|
|
- <el-input :disabled="row.deleted === 1" v-model="row.oldActualBoxNum" v-allow-decimal size="mini" @input="iptChange"></el-input>
|
|
|
- </el-form-item>
|
|
|
- </el-form>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column align="center" :label="$t('oldOutStock.dialog.actualWeight')" prop="oldActualWeight">
|
|
|
- <template slot-scope="{ row, $index }">
|
|
|
- <el-form :model="row" :rules="getRules1($index)" :ref="`weightFormRef${$index}`" :inline="true" style="margin-top: 20px;">
|
|
|
- <el-form-item prop="oldActualWeight">
|
|
|
- <el-input :disabled="row.deleted === 1" v-model="row.oldActualWeight" v-allow-decimal size="mini" @input="iptChange"></el-input>
|
|
|
- </el-form-item>
|
|
|
- </el-form>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
+ <el-table-column align="center" :label="$t('oldOutStock.dialog.actualBoxCount')" prop="oldActualBoxNum">
|
|
|
+ <template slot-scope="{ row, $index }">
|
|
|
+ <el-form :model="row" :rules="getRules2($index)" :ref="`boxFormRef${$index}`" :inline="true" style="margin-top: 20px;" :validate-on-rule-change="false">
|
|
|
+ <el-form-item prop="oldActualBoxNum">
|
|
|
+ <el-input
|
|
|
+ :disabled="row.deleted === 1"
|
|
|
+ v-model="row.oldActualBoxNum"
|
|
|
+ v-allow-decimal
|
|
|
+ size="mini"
|
|
|
+ @input="iptChange"
|
|
|
+ auto-complete="off"
|
|
|
+ :validate-event="false">
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column align="center" :label="$t('oldOutStock.dialog.actualWeight')" prop="oldActualWeight">
|
|
|
+ <template slot-scope="{ row, $index }">
|
|
|
+ <el-form :model="row" :rules="getRules1($index)" :ref="`weightFormRef${$index}`" :inline="true" style="margin-top: 20px;" :validate-on-rule-change="false">
|
|
|
+ <el-form-item prop="oldActualWeight">
|
|
|
+ <el-input
|
|
|
+ :disabled="row.deleted === 1"
|
|
|
+ v-model="row.oldActualWeight"
|
|
|
+ v-allow-decimal
|
|
|
+ size="mini"
|
|
|
+ @input="iptChange"
|
|
|
+ auto-complete="off"
|
|
|
+ :validate-event="false">
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </template>
|
|
|
</el-table-column>
|
|
|
<el-table-column align="center" :label="$t('oldOutStock.dialog.operation')">
|
|
|
<template slot-scope="scope">
|
|
|
- <el-button v-if="scope.row.deleted === 0" type="primary" @click="ckDo(scope.$index, scope.row)">{{ $t('oldOutStock.button.outStock') }}</el-button>
|
|
|
+ <el-button
|
|
|
+ v-if="!isRowSelected(scope.row) && scope.row.deleted === 0"
|
|
|
+ type="primary"
|
|
|
+ @click="ckDo(scope.$index, scope.row)">
|
|
|
+ {{ $t('oldOutStock.button.outStock') }}
|
|
|
+ </el-button>
|
|
|
+ <span
|
|
|
+ v-else-if="isRowSelected(scope.row)"
|
|
|
+ style="color: #67C23A; font-weight: bold">
|
|
|
+ 全部出库
|
|
|
+ </span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
+
|
|
|
<pagination
|
|
|
v-show="cktotal > 0"
|
|
|
:total="cktotal"
|
|
|
:page.sync="queryParams.ckpageNum"
|
|
|
:limit.sync="queryParams.ckpageSize"
|
|
|
- @pagination="handleEditCkDo"
|
|
|
+ @pagination="handlePaginationChange"
|
|
|
/>
|
|
|
+
|
|
|
</el-dialog>
|
|
|
</div>
|
|
|
</el-card>
|
|
@@ -263,7 +299,8 @@ import {
|
|
|
noticeOutStorage,
|
|
|
oldNoticeOutStorage, checkOldInventory,
|
|
|
queryTheOldInventoryDeliveryList,
|
|
|
- oldInventoryGoOut
|
|
|
+ oldInventoryGoOut,
|
|
|
+ oldInventoryGoOutBatch
|
|
|
} from "@/api/tablelist/commonTable";
|
|
|
import { mapState } from "vuex";
|
|
|
import FormList from "@/components/FormGroup/formList.vue";
|
|
@@ -332,6 +369,7 @@ export default {
|
|
|
// { validator: validateOldActualBoxNum, trigger: 'blur' } // 自定义校验规则
|
|
|
// ]
|
|
|
// },
|
|
|
+ formInline:{},
|
|
|
cktotal:0,
|
|
|
tableData: [],
|
|
|
queryParams:{
|
|
@@ -388,24 +426,47 @@ export default {
|
|
|
// 表单引用数组
|
|
|
formRefs: [],
|
|
|
clickHook:false,
|
|
|
+ selectedRows: [], // 添加选中行数据存储
|
|
|
};
|
|
|
},
|
|
|
methods: {
|
|
|
+ async onSubmit(){
|
|
|
+ let rowtj={...this.currentRowData,"lotNum":this.formInline.lotNum,"pageSize":this.queryParams.ckpageSize,"pageNum":this.queryParams.ckpageNum}
|
|
|
+ let res1 = await queryTheOldInventoryDeliveryList(rowtj);
|
|
|
+ console.log(res1,"数组集合")
|
|
|
+ res1.rows = res1.rows.map(item=>{return{...item,deleted:0}});//增加出库按钮是否显示标识,点击过出库后则不显示出库按钮
|
|
|
+ // //打开老库存列表弹窗
|
|
|
+ this.cktotal=res1.total;
|
|
|
+ this.tableData=res1.rows;
|
|
|
+ },
|
|
|
+ async onSubmitcz(){
|
|
|
+ this.formInline.lotNum=null
|
|
|
+ let rowtj={...this.currentRowData,"pageSize":this.queryParams.ckpageSize,"pageNum":this.queryParams.ckpageNum}
|
|
|
+ let res1 = await queryTheOldInventoryDeliveryList(rowtj);
|
|
|
+ console.log(res1,"数组集合")
|
|
|
+ res1.rows = res1.rows.map(item=>{return{...item,deleted:0}});//增加出库按钮是否显示标识,点击过出库后则不显示出库按钮
|
|
|
+ // //打开老库存列表弹窗
|
|
|
+ this.cktotal=res1.total;
|
|
|
+ this.tableData=res1.rows;
|
|
|
+ },
|
|
|
+ plck(){
|
|
|
+ //批量出库
|
|
|
+ },
|
|
|
// 动态生成校验规则
|
|
|
getRules1(index) {
|
|
|
return {
|
|
|
oldActualWeight: [
|
|
|
- { required: true, message: this.$t('oldOutStock.validation.weight.required'), trigger: 'blur' },
|
|
|
- // { required: true, message: this.$t('oldOutStock.validation.weight.required'), trigger: 'blur' },
|
|
|
+ { required: true, message: this.$t('oldOutStock.validation.weight.required'), trigger: ['blur', 'change'] },
|
|
|
{
|
|
|
validator: (rule, value, callback) => {
|
|
|
if(value==0){
|
|
|
callback(new Error(this.$t('oldOutStock.validation.weight.zero')));
|
|
|
+ return;
|
|
|
}
|
|
|
const currentRow = this.tableData[index];
|
|
|
if (!value) {
|
|
|
callback(new Error(this.$t('oldOutStock.validation.weight.required')));
|
|
|
- } else if (currentRow.oldActualWeight>currentRow.totalGrossWeight) {
|
|
|
+ } else if (Number(value) > Number(currentRow.totalGrossWeight)) {
|
|
|
//标识为已出完就不提示
|
|
|
if(currentRow.deleted === 0){
|
|
|
callback(new Error(this.$t('oldOutStock.validation.weight.exceed')));
|
|
@@ -414,7 +475,7 @@ export default {
|
|
|
callback();
|
|
|
}
|
|
|
},
|
|
|
- trigger: 'blur'
|
|
|
+ trigger: ['blur', 'change']
|
|
|
}
|
|
|
]
|
|
|
};
|
|
@@ -423,17 +484,17 @@ export default {
|
|
|
getRules2(index) {
|
|
|
return {
|
|
|
oldActualBoxNum: [
|
|
|
- { required: true, message: this.$t('oldOutStock.validation.boxCount.required'), trigger: 'blur' },
|
|
|
- // { type: 'number', message: this.$t('oldOutStock.validation.boxCount.number'), trigger: 'blur' },
|
|
|
+ { required: true, message: this.$t('oldOutStock.validation.boxCount.required'), trigger: ['blur', 'change'] },
|
|
|
{
|
|
|
validator: (rule, value, callback) => {
|
|
|
if(value==0){
|
|
|
callback(new Error(this.$t('oldOutStock.validation.boxCount.zero')));
|
|
|
+ return;
|
|
|
}
|
|
|
const currentRow = this.tableData[index];
|
|
|
if (!value) {
|
|
|
callback(new Error(this.$t('oldOutStock.validation.boxCount.required')));
|
|
|
- } else if (currentRow.oldActualBoxNum>currentRow.totalBoxNum) {
|
|
|
+ } else if (Number(value) > Number(currentRow.totalBoxNum)) {
|
|
|
//标识为已出完就不提示
|
|
|
if(currentRow.deleted === 0){
|
|
|
callback(new Error(this.$t('oldOutStock.validation.boxCount.exceed')));
|
|
@@ -442,11 +503,28 @@ export default {
|
|
|
callback();
|
|
|
}
|
|
|
},
|
|
|
- trigger: 'blur'
|
|
|
+ trigger: ['blur', 'change']
|
|
|
}
|
|
|
]
|
|
|
};
|
|
|
},
|
|
|
+ // 添加分页切换处理方法
|
|
|
+ async handlePaginationChange() {
|
|
|
+ // 先调用分页加载方法
|
|
|
+ await this.handleEditCkDo();
|
|
|
+
|
|
|
+ // 等待DOM更新后再清除校验
|
|
|
+ this.$nextTick(() => {
|
|
|
+ // 直接遍历0-9的范围
|
|
|
+ for(let i = 0; i < 10; i++) {
|
|
|
+ const boxForm = this.$refs[`boxFormRef${i}`];
|
|
|
+ const weightForm = this.$refs[`weightFormRef${i}`];
|
|
|
+ weightForm.resetFields();
|
|
|
+ boxForm.resetFields();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 修改handleEditCkDo方法,移除重复的校验清除逻辑
|
|
|
async handleEditCkDo(index,row){
|
|
|
console.log(this.clickHook,"点击标识")
|
|
|
if(this.clickHook==false){
|
|
@@ -457,12 +535,11 @@ export default {
|
|
|
this.$message.warning(this.$t('oldOutStock.message.selectWarehouse'));
|
|
|
return;
|
|
|
}
|
|
|
- console.log(row,"当前行数据........")
|
|
|
- // return;
|
|
|
- //判断条件取值 当前行数据点击||保留的当前行数据
|
|
|
+
|
|
|
+ // 判断条件取值 当前行数据点击||保留的当前行数据
|
|
|
if(row==null||row==undefined){
|
|
|
- //如果行数据为空证明点击的是分页,那就取当前行数据
|
|
|
- row=this.currentRowData;
|
|
|
+ //如果行数据为空证明点击的是分页,那就取当前行数据
|
|
|
+ row=this.currentRowData;
|
|
|
}else {
|
|
|
//如果行数据不为空就赋值当前数据
|
|
|
this.currentRowData=row;
|
|
@@ -472,18 +549,22 @@ export default {
|
|
|
this.sh=row.productColor;
|
|
|
this.productCode=row.productCode;
|
|
|
this.productSpecifications=row.productSpecifications;
|
|
|
- //产品编码,产品名称,规格,颜色.
|
|
|
- //查询老库存列表信息 pageNum: 1, // 第几页
|
|
|
|
|
|
let rowtj={...row,"pageSize":this.queryParams.ckpageSize,"pageNum":this.queryParams.ckpageNum}
|
|
|
let res1 = await queryTheOldInventoryDeliveryList(rowtj);
|
|
|
- res1.rows = res1.rows.map(item=>{return{...item,deleted:0}});//增加出库按钮是否显示标识,点击过出库后则不显示出库按钮
|
|
|
+ res1.rows = res1.rows.map(item=>{
|
|
|
+ return {
|
|
|
+ ...item,
|
|
|
+ deleted: 0,
|
|
|
+ oldActualBoxNum: '',
|
|
|
+ oldActualWeight: ''
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
//打开老库存列表弹窗
|
|
|
this.cktotal=res1.total;
|
|
|
this.tableData=res1.rows;
|
|
|
- console.log("---------------------------",this.tableData)
|
|
|
this.dckOpen=true;
|
|
|
- // 初始化表单引用数组
|
|
|
},
|
|
|
async ckDo(index,row){
|
|
|
//出库逻辑........
|
|
@@ -561,9 +642,20 @@ export default {
|
|
|
// this.dckOpen=false;
|
|
|
}
|
|
|
},
|
|
|
+ // 修改输入事件处理,输入时才进行校验
|
|
|
iptChange(value) {
|
|
|
- console.log(value);
|
|
|
- this.$forceUpdate(); //强制刷新
|
|
|
+ const currentIndex = this.tableData.findIndex(item => item.oldActualBoxNum === value || item.oldActualWeight === value);
|
|
|
+ if (currentIndex > -1) {
|
|
|
+ const boxFormRef = this.$refs[`boxFormRef${currentIndex}`];
|
|
|
+ const weightFormRef = this.$refs[`weightFormRef${currentIndex}`];
|
|
|
+ if (boxFormRef && boxFormRef[0]) {
|
|
|
+ boxFormRef[0].validateField('oldActualBoxNum');
|
|
|
+ }
|
|
|
+ if (weightFormRef && weightFormRef[0]) {
|
|
|
+ weightFormRef[0].validateField('oldActualWeight');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.$forceUpdate();
|
|
|
},
|
|
|
tableRowClassName({ row, rowIndex }) {
|
|
|
if (!row.actualWeight && row.actualWeight != 0) {
|
|
@@ -691,7 +783,46 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- handleSelectionChange() {},
|
|
|
+ handleSelectionChange(selection) {
|
|
|
+ // 找出取消勾选的行
|
|
|
+ const previousSelected = this.selectedRows || [];
|
|
|
+ const unselectedRows = previousSelected.filter(row => !selection.includes(row));
|
|
|
+
|
|
|
+ // 更新选中状态
|
|
|
+ this.selectedRows = selection;
|
|
|
+
|
|
|
+ // 处理取消勾选的行
|
|
|
+ unselectedRows.forEach(row => {
|
|
|
+ if (row.deleted !== 1) {
|
|
|
+ // 清空取消勾选行的数据
|
|
|
+ this.$set(row, 'oldActualBoxNum', '');
|
|
|
+ this.$set(row, 'oldActualWeight', '');
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 处理新选中的行
|
|
|
+ selection.forEach(row => {
|
|
|
+ if (row.deleted !== 1) {
|
|
|
+ // 设置实发箱数和重量
|
|
|
+ this.$set(row, 'oldActualBoxNum', row.totalBoxNum);
|
|
|
+ this.$set(row, 'oldActualWeight', row.totalGrossWeight);
|
|
|
+
|
|
|
+ // 触发表单验证
|
|
|
+ this.$nextTick(() => {
|
|
|
+ const index = this.tableData.findIndex(item => item === row);
|
|
|
+ const boxFormRef = this.$refs[`boxFormRef${index}`];
|
|
|
+ const weightFormRef = this.$refs[`weightFormRef${index}`];
|
|
|
+
|
|
|
+ if (boxFormRef && boxFormRef[0]) {
|
|
|
+ boxFormRef[0].validateField('oldActualBoxNum');
|
|
|
+ }
|
|
|
+ if (weightFormRef && weightFormRef[0]) {
|
|
|
+ weightFormRef[0].validateField('oldActualWeight');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
// 初始化仓库选项数据
|
|
|
async initWarehouse() {
|
|
|
try {
|
|
@@ -854,6 +985,78 @@ export default {
|
|
|
console.log(error);
|
|
|
}
|
|
|
},
|
|
|
+ // 批量出库方法
|
|
|
+ async batchOutStock() {
|
|
|
+ // 验证所有选中行的表单
|
|
|
+ let isValid = true;
|
|
|
+ for (let row of this.selectedRows) {
|
|
|
+ const index = this.tableData.findIndex(item => item === row);
|
|
|
+ const boxFormRef = this.$refs[`boxFormRef${index}`];
|
|
|
+ const weightFormRef = this.$refs[`weightFormRef${index}`];
|
|
|
+
|
|
|
+ if (boxFormRef && boxFormRef[0]) {
|
|
|
+ await boxFormRef[0].validate().catch(() => {
|
|
|
+ isValid = false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (weightFormRef && weightFormRef[0]) {
|
|
|
+ await weightFormRef[0].validate().catch(() => {
|
|
|
+ isValid = false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!isValid) {
|
|
|
+ this.$message.warning('请检查表单填写是否正确');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 构建批量出库的请求数据
|
|
|
+ const batchData = this.selectedRows.map(row => ({
|
|
|
+ noticeNumber: this.form.noticeNumber,
|
|
|
+ saleOrderNo: this.form.saleOrderNo,
|
|
|
+ productCode: this.productCode,
|
|
|
+ oldActualBoxNum: row.oldActualBoxNum,
|
|
|
+ oldActualWeight: row.oldActualWeight,
|
|
|
+ productColour: this.sh,
|
|
|
+ productSpecifications: this.productSpecifications,
|
|
|
+ inventoryId: row.id,
|
|
|
+ productName: row.productName,
|
|
|
+ ...this.form
|
|
|
+ }));
|
|
|
+
|
|
|
+ // 调用批量出库接口
|
|
|
+ const res = await oldInventoryGoOutBatch(batchData);
|
|
|
+
|
|
|
+ if (res.code === 200) {
|
|
|
+ // 更新表格数据
|
|
|
+ this.selectedRows.forEach(row => {
|
|
|
+ const index = this.tableData.findIndex(item => item === row);
|
|
|
+ if (index > -1) {
|
|
|
+ this.tableData[index].totalBoxNum = this.tableData[index].totalBoxNum - row.oldActualBoxNum;
|
|
|
+ this.tableData[index].totalGrossWeight = (this.tableData[index].totalGrossWeight - row.oldActualWeight).toFixed(2);
|
|
|
+ if (this.tableData[index].totalBoxNum <= 0 && this.tableData[index].totalGrossWeight <= 0) {
|
|
|
+ this.tableData[index].deleted = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ this.$message.success('批量出库成功');
|
|
|
+ // 清空选择
|
|
|
+ this.selectedRows = [];
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.msg || '批量出库失败');
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('批量出库错误:', error);
|
|
|
+ this.$message.error('批量出库失败');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 判断行是否被选中
|
|
|
+ isRowSelected(row) {
|
|
|
+ return this.selectedRows.includes(row);
|
|
|
+ },
|
|
|
},
|
|
|
computed: {
|
|
|
...mapState({
|