Commit d724210a authored by Facius's avatar Facius

fixed: 材料工艺不可以小数

parent 4743fa60
......@@ -37,7 +37,7 @@
:border="true"
border-color="#2979FF"
@focus="handleFocus(item)"
type="digit"
type="number"
placeholder="请输入"
v-model="item[key]"
placeholder-style="color: #999999;font-size:26rpx"
......@@ -124,116 +124,116 @@
export default {
data() {
return {
orderId: "",
fieldName: "materialList",
orderId: '',
fieldName: 'materialList',
list: [], // 材料列表
other: [], // 其他列表
};
}
},
computed: {
buttonStyle() {
return {
width: "600rpx",
height: "104rpx",
"font-size": "32rpx",
"font-weight": "bold",
};
width: '600rpx',
height: '104rpx',
'font-size': '32rpx',
'font-weight': 'bold',
}
},
titles() {
return {
matName: this.isMaterial ? "材料名称" : "工艺名称",
matUnit: "单位",
freeLength: "免费量",
unitAmt: "单价/元",
useLength: "用量",
};
matName: this.isMaterial ? '材料名称' : '工艺名称',
matUnit: '单位',
freeLength: '免费量',
unitAmt: '单价/元',
useLength: '用量',
}
},
widths() {
return {
matName: 200,
matUnit: "auto",
freeLength: "auto",
unitAmt: "auto",
useLength: "auto",
};
matUnit: 'auto',
freeLength: 'auto',
unitAmt: 'auto',
useLength: 'auto',
}
},
thStyle() {
return {
"font-weight": "bold",
};
'font-weight': 'bold',
}
},
firstKey() {
return Object.keys(this.titles)[0];
return Object.keys(this.titles)[0]
},
subtractImage() {
return process.uniEnv.qn_base_url + "qxiao.png";
return process.uniEnv.qn_base_url + 'qxiao.png'
},
addImage() {
return process.uniEnv.qn_base_url + "tianjia.png";
return process.uniEnv.qn_base_url + 'tianjia.png'
},
money() {
// 总额
var amount = 0;
var amount = 0
for (var item of this.list) {
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;
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)) {
amount += Number(item.extraAmt);
amount += Number(item.extraAmt)
}
}
return amount;
return amount
},
isMaterial() {
return this.fieldName === "materialList";
return this.fieldName === 'materialList'
},
isCraft() {
return this.fieldName === "craftList";
return this.fieldName === 'craftList'
},
priceType() {
return this.isMaterial ? "01" : "02";
return this.isMaterial ? '01' : '02'
},
},
onLoad(option) {
getApp().trackPage("订单材料列表页");
this.orderId = option.orderId;
this.fieldName = option.fieldName;
const eventChannel = this.getOpenerEventChannel();
let self = this;
eventChannel.on("showMaterialData", function (data) {
getApp().trackPage('订单材料列表页')
this.orderId = option.orderId
this.fieldName = option.fieldName
const eventChannel = this.getOpenerEventChannel()
let self = this
eventChannel.on('showMaterialData', function(data) {
if (!data || data.length === 0) {
self.getMaterialData();
self.getMaterialData()
} else {
self.formatServiceMoreList(data);
self.formatServiceMoreList(data)
}
});
})
if (this.$u.test.isEmpty(this.other)) {
this.handleAdd();
this.handleAdd()
}
},
created() {},
mounted() {},
methods: {
getMaterialData() {
let self = this;
let self = this
self.$u.api.getOrderMaterial(self.orderId).then((res) => {
if (res.code !== 200) {
console.log(res.data.message);
return;
console.log(res.data.message)
return
}
self.formatServiceMoreList(res.data);
});
self.formatServiceMoreList(res.data)
})
},
formatServiceMoreList(materialCraftsData) {
let self = this;
let self = this
materialCraftsData.map((item) => {
if (item.priceType === self.priceType) {
item.matType === "04" ? self.other.push(item) : self.list.push(item);
item.matType === '04' ? self.other.push(item) : self.list.push(item)
}
});
})
},
handleBlur(item) {
// 失去焦点如果没输入用原先的值
......@@ -241,69 +241,69 @@ export default {
this.$u.test.isEmpty(item.useLength) ||
!this.$u.test.number(item.useLength)
) {
item.useLength = 0;
item.useLength = 0
}
},
handleFocus(item) {
// 点击清空
if (this.$u.test.isEmpty(item.useLength)) {
item.useLength = null;
item.useLength = null
}
},
/* 其他添加新的 */
handleAdd() {
this.other.push({
//orderNo:this.formInfo.orderNo,
isDel: "N",
isDel: 'N',
isWebAdd: true,
matName: "其他",
matName: '其他',
extraAmt: null,
priceType: this.priceType,
matType: "04",
otherExplain: "",
});
matType: '04',
otherExplain: '',
})
},
/* 其他删除某个 */
handleSubtract(index) {
this.other.splice(index, 1);
this.other.splice(index, 1)
},
validateForm() {
if (this.isMaterial) {
let row = this.list.find((item) => {
return !this.$u.test.isEmpty(item.useLength) && item.useLength != '0';
});
return !this.$u.test.isEmpty(item.useLength) && item.useLength != '0'
})
if (!this.$u.test.isEmpty(this.list) && this.$u.test.isEmpty(row)) {
this.$refs.uToast.show({
title: "请填写电缆、漏保、空开等用量",
type: "error",
title: '请填写电缆、漏保、空开等用量',
type: 'error',
icon: false,
position: "bottom",
});
return false;
position: 'bottom',
})
return false
}
}
return true;
return true
},
handleSure() {
if (!this.validateForm()) {
return false;
return false
}
let pages = getCurrentPages();
let prevPage = pages[pages.length - 2]; //上一个页面
let data = {};
let tmps = [];
let pages = getCurrentPages()
let prevPage = pages[pages.length - 2] //上一个页面
let data = {}
let tmps = []
this.other.map((item) => {
if (!this.$u.test.isEmpty(item.otherExplain)) {
item.extraAmt = item.extraAmt || 0;
tmps.push(item);
item.extraAmt = item.extraAmt || 0
tmps.push(item)
}
});
data[this.fieldName] = this.list.concat(tmps); // 将list合并给上以页面
prevPage.$vm.setData(data); //直接调用上一个页面的setData()方法,把数据存到上一个页面中去
uni.navigateBack();
})
data[this.fieldName] = this.list.concat(tmps) // 将list合并给上以页面
prevPage.$vm.setData(data) //直接调用上一个页面的setData()方法,把数据存到上一个页面中去
uni.navigateBack()
},
},
};
}
</script>
<style lang="scss" scoped>
......
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