采购合同清单明细 验证提示到行级别

master
Harry Yang 2023-01-03 15:59:50 +08:00
parent a6b6d05879
commit 54fa818666
2 changed files with 65 additions and 27 deletions

View File

@ -480,7 +480,6 @@
const procurementDetailProperties = [
"spec",
"amount",
"purchaseList",
"amountCurrent",
"supplierName",
@ -574,16 +573,32 @@
* @returns {boolean} 校验通过否
*/
checkProcurementDetails() {
const emptyRows = this.procurementDetails.filter(detail => {
let row = 1;
const emptyRowIndex = []
const containsEmpty = detail => {
return isNotEmpty(procurementDetailProperties.filter(property => isBlank(detail[property])))
}
this.procurementDetails.forEach(detail => {
if (containsEmpty(detail)) {
emptyRowIndex.push(row)
}
row++;
const { children } = detail
if (children) {
children.forEach(childDetail => {
if (containsEmpty(childDetail)) {
emptyRowIndex.push(row)
}
// 每个children都加1
row++;
})
}
})
if (isNotEmpty(emptyRows)) {
this.procurementDetails.forEach(detail => {
const properties = procurementDetailProperties.filter(property => isBlank(detail[property]))
console.log(properties)
})
const row = emptyRows[0]
this.$message.error("合同清单明细 费用项目为:'" + row.feeType + "' 采购类别为:'" + row.category + "' 的数据未填写")
if (isNotEmpty(emptyRowIndex)) {
const indexString = emptyRowIndex.join(",")
this.$message.error("在合同清单明细中第 '" + indexString + "' 行中的数据未填写完整")
return false
}
return true
@ -871,6 +886,9 @@
}
if (!validStatus) {
if (isEmpty(document.getElementsByClassName('el-message'))) {
this.$message.error("表单填写不完整,不能提交");
}
return false
}
@ -883,7 +901,9 @@
const detail = budgetCostIdMap.get(budgetCostId)
const ret = []
const map = detail => {
const ret = { id: detail.id }
const ret = {
id: detail.id, amount: detail.amount
}
procurementDetailProperties.forEach(property => {
ret[property] = detail[property]
})

View File

@ -506,7 +506,7 @@
<el-table-column prop="amountAlready" label="已采购数量" width="100"></el-table-column>
<el-table-column prop="amountCurrent" label="本次采购数量" width="180">
<template slot-scope="scope">
<span v-if="scope.row.newRow">{{scope.row.parent.amountCurrent}}</span>
<span v-if="scope.row.newRow"></span>
<el-input-number v-else :precision="2" :step="0.1" :min="0" v-model="scope.row.amountCurrent"
:disabled="scope.row.amount - scope.row.amountAlready===0" size="mini"
:max="scope.row.amount - scope.row.amountAlready" controls-position="right">
@ -516,7 +516,7 @@
<el-table-column prop="amountLeft" label="未采购数量" width="100">
<template slot-scope="scope">
<span>{{scope.row.amount - scope.row.amountAlready}}</span>
<span v-if="!scope.row.newRow">{{scope.row.amount - scope.row.amountAlready}}</span>
</template>
</el-table-column>
@ -600,7 +600,6 @@
const procurementDetailProperties = [
"spec",
"amount",
"purchaseList",
"amountCurrent",
"supplierName",
@ -754,18 +753,32 @@
* @returns {boolean} 校验通过否
*/
checkProcurementDetails() {
// TODO FIXME 修改为提示第几行数据有问题
const emptyRows = this.procurementDetails.filter(detail => {
let row = 1;
const emptyRowIndex = []
const containsEmpty = detail => {
return isNotEmpty(procurementDetailProperties.filter(property => isBlank(detail[property])))
}
this.procurementDetails.forEach(detail => {
if (containsEmpty(detail)) {
emptyRowIndex.push(row)
}
row++;
const { children } = detail
if (children) {
children.forEach(childDetail => {
if (containsEmpty(childDetail)) {
emptyRowIndex.push(row)
}
// 每个children都加1
row++;
})
}
})
console.log(emptyRows)
if (isNotEmpty(emptyRows)) {
this.procurementDetails.forEach(detail => {
const properties = procurementDetailProperties.filter(property => isBlank(detail[property]))
console.log(properties)
})
const row = emptyRows[0]
this.$message.error("合同清单明细 费用项目为:'" + row.feeType + "' 采购类别为:'" + row.category + "' 的数据未填写")
if (isNotEmpty(emptyRowIndex)) {
const indexString = emptyRowIndex.join(",")
this.$message.error("在合同清单明细中第 '" + indexString + "' 行中的数据未填写完整")
return false
}
return true
@ -1042,6 +1055,9 @@
}
if (!validStatus) {
if (isEmpty(document.getElementsByClassName('el-message'))) {
this.$message.error("表单填写不完整,不能提交");
}
return false
}
@ -1055,7 +1071,9 @@
const detail = budgetCostIdMap.get(budgetCostId)
const ret = []
const map = detail => {
const ret = {}
const ret = {
amount: detail.amount // 需要 amount
}
procurementDetailProperties.forEach(property => {
ret[property] = detail[property]
})
@ -1232,7 +1250,7 @@
const { row } = scope
const { children } = row
const newRow = {
...row,
// ...row, // 不显示数据相同的部分
rowKey: this.rowKeyCounter++,
newRow: true,
parent: row // 记录上一级元素,在删除的时候使用
@ -1250,8 +1268,8 @@
},
removeProcurementDetailRow(scope) {
const { rowKey } = scope.row
.filter(child => child.rowKey !== rowKey)
const { rowKey, parent } = scope.row
parent.children = parent.children.filter(child => child.rowKey !== rowKey)
},
// 区别子项