Commit 9264a81d authored by 高铭波's avatar 高铭波

perf(order):勘查材料金额计算逻辑修改

parent 2023fc1c
......@@ -673,16 +673,19 @@ export default {
if (value && !Array.isArray(value)) {
panelResult.submitted++;
} else if (value && Array.isArray(value) && value.length > 0) {
if(ele.fieldsName === 'materialList') {
let materRow = value.find((val)=>{
return val.useLength > 0
})
if(!this.$u.test.isEmpty(materRow)) {
panelResult.submitted++;
}
} else {
if (ele.fieldsName === "materialList") {
let materRow = value.find((val) => {
return (
val.hasOwnProperty("useLength") &&
!this.$u.test.isEmpty(val.useLength)
);
});
if (!this.$u.test.isEmpty(materRow)) {
panelResult.submitted++;
}
} else {
panelResult.submitted++;
}
} else if (first) {
// 记录第一个 为空 并且需要必填的项 用于定位
first = false;
......@@ -861,16 +864,14 @@ export default {
let amount = 0;
if (arr) {
arr.forEach((item) => {
if (
Number(item.useLength) &&
Number(item.freeLength) &&
Number(item.unitAmt)
) {
amount +=
Math.max(Number(item.useLength) - Number(item.freeLength), 0) *
Number(item.unitAmt);
}
if (Number(item.extraAmt)) {
let useLength =
(item.hasOwnProperty("useLength") && Number(item.useLength)) || 0;
let freeLength =
(item.hasOwnProperty("freeLength") && Number(item.freeLength)) || 0;
let unitAmt =
(item.hasOwnProperty("unitAmt") && Number(item.unitAmt)) || 0;
amount += Math.max(useLength - freeLength, 0) * unitAmt;
if (item.hasOwnProperty("extraAmt") && Number(item.extraAmt)) {
amount += Number(item.extraAmt);
}
});
......
......@@ -175,15 +175,10 @@ export default {
// 总额
var amount = 0;
for (var item of this.list) {
if (
this.$u.test.number(item.useLength) &&
this.$u.test.number(item.freeLength) &&
this.$u.test.number(item.unitAmt)
) {
amount +=
Math.max(Number(item.useLength) - Number(item.freeLength), 0) *
Number(item.unitAmt);
}
let useLength = Number(item.useLength) || 0;
let freeLength = Number(item.freeLength) || 0;
let unitAmt = Number(item.unitAmt) || 0;
amount += Math.max(useLength - freeLength, 0) * unitAmt;
}
for (var item of this.other) {
if (item.extraAmt && Number(item.extraAmt)) {
......@@ -218,80 +213,6 @@ export default {
self.formatServiceMoreList(data);
}
});
this.list = [
{
matType: "02",
priceType: "01",
matName: "开孔厚40cm以上,直径11cm以下",
matUnit: "个",
freeLength: 0,
unitAmt: 10,
useLength: 0,
},
{
matType: "02",
priceType: "01",
matName: "验收完成后移动安装地点",
matUnit: "次",
freeLength: 0,
unitAmt: 20,
useLength: 0,
},
{
matType: "02",
priceType: "01",
matName: "北京地区报装",
matUnit: "次",
freeLength: 0,
unitAmt: 30,
useLength: 0,
},
{
matType: "02",
priceType: "01",
matName: "墙面开墙及恢复",
matUnit: "米",
freeLength: 0,
unitAmt: 40,
useLength: 0,
},
{
matType: "02",
priceType: "01",
matName: "安装位置单次往返经销商距离",
matUnit: "千米",
freeLength: 0,
unitAmt: 50,
useLength: 0,
},
{
matType: "02",
priceType: "01",
matName: "开孔厚40cm以上,直径11cm以下",
matUnit: "个",
freeLength: 1,
unitAmt: 60,
useLength: 0,
},
{
matType: "02",
priceType: "01",
matName: "桥架50mm*50mm",
matUnit: "米",
freeLength: 2,
unitAmt: 70,
useLength: 0,
},
{
matType: "02",
priceType: "01",
matName: "铺装庭院开挖(复合材料)",
matUnit: "米",
freeLength: 3,
unitAmt: 220,
useLength: 0,
},
];
},
created() {},
mounted() {},
......@@ -348,8 +269,8 @@ export default {
},
validateForm() {
if (this.isMaterial) {
let row = this.list.find((item, index) => {
return item.useLength != 0;
let row = this.list.find((item) => {
return !this.$u.test.isEmpty(item.useLength);
});
if (this.$u.test.isEmpty(row)) {
this.$refs.uToast.show({
......@@ -367,19 +288,17 @@ export default {
if (!this.validateForm()) {
return false;
}
for (let item of this.other) {
if (this.other.length > 1 && !item.otherExplain) {
this.$refs.uToast.show({
title: "请输入其他项说明",
type: "warning",
});
return;
}
}
let pages = getCurrentPages();
let prevPage = pages[pages.length - 2]; //上一个页面
let data = {};
data[this.fieldName] = this.list.concat(this.other); // 将list合并给上以页面
let tmps = [];
this.other.map((item) => {
if (!this.$u.test.isEmpty(item.otherExplain)) {
item.extraAmt = item.extraAmt || 0;
tmps.push(item);
}
});
data[this.fieldName] = this.list.concat(tmps); // 将list合并给上以页面
prevPage.$vm.setData(data); //直接调用上一个页面的setData()方法,把数据存到上一个页面中去
uni.navigateBack();
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment