Commit 807dcfb4 authored by Facius's avatar Facius

Merge branch 'dev-1.4.5' into test

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