|
|
@@ -319,8 +319,6 @@
|
|
|
if (form.realEndTime) {
|
|
|
this.$nextTick(() => {
|
|
|
this.form = { ...form };
|
|
|
- this.reportNum = form.reportQuantity ? form.reportQuantity : 0;
|
|
|
- this.lossNum = form.lossQuantity ? form.lossQuantity : 0;
|
|
|
});
|
|
|
if (type !== 'report') {
|
|
|
listUpdateRealTimeRecord(row.apsAssigneeId)
|
|
|
@@ -334,6 +332,8 @@
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
+ this.reportNum = Number(this.current.reportQuantityReported) || 0;
|
|
|
+ this.lossNum = Number(this.current.lossQuantityReported) || 0;
|
|
|
this.getData();
|
|
|
},
|
|
|
cancel() {
|
|
|
@@ -442,15 +442,17 @@
|
|
|
|
|
|
// 计算数量
|
|
|
calculateQuantity(type) {
|
|
|
+ const taskQuantity = Number(this.current.quantity) || 0;
|
|
|
const actualQuantity = this.add(this.reportNum, this.lossNum);
|
|
|
- const remainingQuantity = this.sub(
|
|
|
- this.current.formingNum,
|
|
|
- actualQuantity
|
|
|
- );
|
|
|
- let total = this.form.reportQuantity - 0 + (this.form.lossQuantity - 0);
|
|
|
+ const remainingQuantity = this.sub(taskQuantity, actualQuantity);
|
|
|
+ const reportQuantity = Number(this.form.reportQuantity) || 0;
|
|
|
+ const lossQuantity = Number(this.form.lossQuantity) || 0;
|
|
|
+ const total = this.add(reportQuantity, lossQuantity);
|
|
|
if (total > remainingQuantity) {
|
|
|
- this.form[type] = 0;
|
|
|
- this.$message.warning('报工数量加损耗数量不能大于要求完成数量');
|
|
|
+ this.form[type] = '';
|
|
|
+ this.$message.warning(
|
|
|
+ `本次报工数与损耗数之和不能超过任务剩余可报数量(剩余 ${remainingQuantity})`
|
|
|
+ );
|
|
|
}
|
|
|
},
|
|
|
// 数量正则 quantity
|
|
|
@@ -481,11 +483,21 @@
|
|
|
// 更新绑定值
|
|
|
this.form[type] = match ? match[0] : '';
|
|
|
this.calculateQuantity(type);
|
|
|
- this.calculateQuantity(type);
|
|
|
},
|
|
|
submitAdd() {
|
|
|
this.$refs.form.validate((valid) => {
|
|
|
if (!valid) return;
|
|
|
+ const taskQuantity = Number(this.current.quantity) || 0;
|
|
|
+ const actualQuantity = this.add(this.reportNum, this.lossNum);
|
|
|
+ const remainingQuantity = this.sub(taskQuantity, actualQuantity);
|
|
|
+ const reportQuantity = Number(this.form.reportQuantity) || 0;
|
|
|
+ const lossQuantity = Number(this.form.lossQuantity) || 0;
|
|
|
+ const total = this.add(reportQuantity, lossQuantity);
|
|
|
+ if (total > remainingQuantity) {
|
|
|
+ return this.$message.warning(
|
|
|
+ `本次报工数与损耗数之和不能超过任务剩余可报数量(剩余 ${remainingQuantity})`
|
|
|
+ );
|
|
|
+ }
|
|
|
|
|
|
let data = {
|
|
|
...this.form,
|