|
|
|
|
@ -79,7 +79,11 @@ |
|
|
|
|
<el-table-column prop="unit" label="单位"> </el-table-column> |
|
|
|
|
<el-table-column prop="num" label="数量"> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<el-input-number size="mini" v-model="scope.row.num" :min="0" style="width: 100%" |
|
|
|
|
<el-input-number size="mini" v-model="scope.row.num" |
|
|
|
|
:min="0" |
|
|
|
|
:max="getMaxQuantity(scope.row)" |
|
|
|
|
|
|
|
|
|
style="width: 100%" |
|
|
|
|
:disabled="outDialogType != 'add' || scope.row.type === 'NY'" @change=" |
|
|
|
|
(newValue) => handleQuantityChange(newValue, scope.$index) |
|
|
|
|
"></el-input-number> |
|
|
|
|
@ -105,7 +109,17 @@ |
|
|
|
|
<el-table-column prop="materialName" label="名称"> |
|
|
|
|
</el-table-column> |
|
|
|
|
<el-table-column prop="model" label="规格"> </el-table-column> |
|
|
|
|
<el-table-column prop="type" label="类别"> </el-table-column> |
|
|
|
|
<el-table-column prop="type" label="类别"> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
{{ |
|
|
|
|
scope.row.type === "NY" |
|
|
|
|
? "耐用品" |
|
|
|
|
: scope.row.type === "YH" |
|
|
|
|
? "易耗品" |
|
|
|
|
: "" |
|
|
|
|
}} |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
<el-table-column prop="unit" label="单位"> </el-table-column> |
|
|
|
|
<el-table-column prop="num" label="数量"> </el-table-column> |
|
|
|
|
</el-table-column> |
|
|
|
|
@ -303,9 +317,16 @@ export default { |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
// 最大数量 |
|
|
|
|
getMaxQuantity(row) { |
|
|
|
|
const stockInfo = this.statisticsList.find(stat => stat.materialCode === row.materialCode) |
|
|
|
|
if (row.type === 'NY') { |
|
|
|
|
return 1 |
|
|
|
|
} else { |
|
|
|
|
return stockInfo ? stockInfo.num : 999999; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
categoryHandle() { |
|
|
|
|
|
|
|
|
|
if ((!this.sizeForm.ldTwoOutStorage.proposerInfo) || (!this.sizeForm.ldTwoOutStorage.departmentInfo)) { |
|
|
|
|
this.$message.error('请先选择部门和领用人'); |
|
|
|
|
return false |
|
|
|
|
@ -313,9 +334,25 @@ export default { |
|
|
|
|
this.categoryVisible = true; |
|
|
|
|
}, |
|
|
|
|
confirm(allSelectedList) { |
|
|
|
|
this.selectionData = allSelectedList |
|
|
|
|
// 保存已选数量 |
|
|
|
|
const existingQuantities = {}; |
|
|
|
|
this.sizeForm.ldTwoOutStorageDetailList.forEach(item => { |
|
|
|
|
existingQuantities[item.id] = item.num |
|
|
|
|
}) |
|
|
|
|
const updatedList = allSelectedList.map(item => { |
|
|
|
|
const existingNum = existingQuantities[item.id]; |
|
|
|
|
if (existingNum !== undefined) { |
|
|
|
|
return { |
|
|
|
|
...item, |
|
|
|
|
num: existingNum |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
return item; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
this.selectionData = updatedList; |
|
|
|
|
this.categoryVisible = false; |
|
|
|
|
this.sizeForm.ldTwoOutStorageDetailList = allSelectedList; |
|
|
|
|
this.sizeForm.ldTwoOutStorageDetailList = updatedList; |
|
|
|
|
this.getStatistics(); |
|
|
|
|
}, |
|
|
|
|
// 删除表格行数据 |
|
|
|
|
@ -329,43 +366,17 @@ export default { |
|
|
|
|
JSON.stringify(this.sizeForm.ldTwoOutStorageDetailList) |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
handleQuantityChange(newValue, index) { |
|
|
|
|
console.log(newValue,'点击数量变化数量的值') |
|
|
|
|
const currentRow = this.sizeForm.ldTwoOutStorageDetailList[index]; |
|
|
|
|
// 核心:获取selectionData中对应行的库存数据(你的代码中已有的selectionData数组) |
|
|
|
|
const selectionItem = this.selectionData[index]; // 这里定义selectionItem,指向对应行的库存数据 |
|
|
|
|
|
|
|
|
|
if (!currentRow) return; |
|
|
|
|
|
|
|
|
|
// 耐用品逻辑保持不变 |
|
|
|
|
if (currentRow.type === "NY") { |
|
|
|
|
currentRow.num = 1; |
|
|
|
|
this.$set(this.sizeForm.ldTwoOutStorageDetailList, index, currentRow); |
|
|
|
|
this.$set(this.sizeForm.inAccountsTableData, index, { ...currentRow }); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 新增:校验输入数量不能超过库存数量 |
|
|
|
|
if (selectionItem && newValue > selectionItem.num) { |
|
|
|
|
this.$message.warning(`出库数量不能超过库存数量【${selectionItem.num}】!`); |
|
|
|
|
// 超出则重置为最大库存数 |
|
|
|
|
currentRow.num = selectionItem.num; |
|
|
|
|
this.$set(this.sizeForm.ldTwoOutStorageDetailList, index, currentRow); |
|
|
|
|
this.$set(this.sizeForm.inAccountsTableData, index, { ...currentRow }); |
|
|
|
|
this.getStatistics(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 原有库存计算逻辑(调整为基于selectionData的库存数) |
|
|
|
|
const stockNum = selectionItem ? selectionItem.num : currentRow.oldNum || currentRow.num; |
|
|
|
|
currentRow.oldNum = stockNum; // 出库前库存 |
|
|
|
|
currentRow.num = newValue; // 出库数量 |
|
|
|
|
currentRow.newNum = stockNum - newValue; // 出库后库存 |
|
|
|
|
|
|
|
|
|
this.$set(this.sizeForm.ldTwoOutStorageDetailList, index, currentRow); |
|
|
|
|
this.$set(this.sizeForm.inAccountsTableData, index, { ...currentRow }); |
|
|
|
|
this.getStatistics(); |
|
|
|
|
}, |
|
|
|
|
handleQuantityChange(newValue, index) { |
|
|
|
|
console.log(newValue, '点击数量变化数量的值') |
|
|
|
|
const currentRow = this.sizeForm.ldTwoOutStorageDetailList[index]; |
|
|
|
|
if (!currentRow) return; |
|
|
|
|
|
|
|
|
|
// 易耗品的有效数量 |
|
|
|
|
currentRow.num = newValue; |
|
|
|
|
this.$set(this.sizeForm.ldTwoOutStorageDetailList, index, currentRow); |
|
|
|
|
this.$set(this.sizeForm.inAccountsTableData, index, { ...currentRow }); |
|
|
|
|
this.getStatistics() |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
// 更新全局总计 |
|
|
|
|
updateGlobalTotal() { |
|
|
|
|
@ -499,4 +510,4 @@ export default { |
|
|
|
|
padding-right: 10px; |
|
|
|
|
/* 预留滚动条空间 */ |
|
|
|
|
} |
|
|
|
|
</style> |
|
|
|
|
</style> |