|
|
@ -100,9 +100,9 @@ |
|
|
|
|
|
|
|
<view class="meter-row"> |
|
|
|
<view class="meter-label"> |
|
|
|
<view style="color: #f93838; margin-right: 4rpx; font-size: 24rpx" |
|
|
|
<!-- <view style="color: #f93838; margin-right: 4rpx; font-size: 24rpx" |
|
|
|
>*</view |
|
|
|
> |
|
|
|
> --> |
|
|
|
<text>上次表数</text> |
|
|
|
</view> |
|
|
|
<u-input |
|
|
@ -270,18 +270,12 @@ export default { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
queryDeptDropdownList({ type, id }).then((res) => { |
|
|
|
resolve(res.data); |
|
|
|
console.log(res.data, "res.data"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
async onPickerChange(e, type) { |
|
|
|
if (type == "乐业社区") { |
|
|
|
console.log("e", e); |
|
|
|
|
|
|
|
const apartmentInfo = this.deptOptions[e.detail.value]; |
|
|
|
console.log("社区信息", apartmentInfo); |
|
|
|
console.log("社区信息11", this.deptOptions); |
|
|
|
|
|
|
|
this.blockForm.apartmentName = apartmentInfo.deptName; |
|
|
|
this.blockForm.apartmentId = apartmentInfo.deptId; |
|
|
|
// 楼 |
|
|
@ -290,9 +284,7 @@ export default { |
|
|
|
apartmentInfo.deptId |
|
|
|
); |
|
|
|
this.buildingOptions = buildingArray; |
|
|
|
console.log("楼信息", buildingArray); |
|
|
|
const buildingNames = buildingArray.map((item) => item.name); |
|
|
|
console.log("buildingNames:", buildingNames); |
|
|
|
|
|
|
|
this.blockForm.buildingId = buildingArray[0].id; |
|
|
|
// 单元 |
|
|
@ -301,7 +293,6 @@ export default { |
|
|
|
buildingArray[0].id |
|
|
|
); |
|
|
|
this.unitOptions = unitArray; |
|
|
|
console.log("unitArray:", unitArray); |
|
|
|
|
|
|
|
const unitNames = unitArray.map((item) => item.name); |
|
|
|
this.blockForm.unitId = unitArray[0].id; |
|
|
@ -313,6 +304,8 @@ export default { |
|
|
|
this.energyMeterConfig = houseArray[0].energyMeterConfig; |
|
|
|
this.waterMeterConfig = houseArray[0].waterMeterConfig; |
|
|
|
let house = houseArray[0]; |
|
|
|
this.blockForm.roomId = houseArray[0].roomId; |
|
|
|
|
|
|
|
// for (let index = 0; index < house.type; index++) { |
|
|
|
// this.form.waterMeters.push({ |
|
|
|
// waterMeter: "", |
|
|
@ -325,7 +318,6 @@ export default { |
|
|
|
this.getHouseInfoBy(this.blockForm.houseId); |
|
|
|
} else if (this.energyMeterConfig == 2) { |
|
|
|
this.getRoomByHouseId(this.blockForm.houseId); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
@ -334,9 +326,7 @@ export default { |
|
|
|
}, |
|
|
|
async bindMultiPickerColumnChange(e) { |
|
|
|
if (!this.multiArray[0].length) return; |
|
|
|
console.log( |
|
|
|
"修改的列为:" + e.detail.column + ",值为:" + e.detail.value |
|
|
|
); |
|
|
|
|
|
|
|
this.multiIndex[e.detail.column] = e.detail.value; |
|
|
|
switch (e.detail.column) { |
|
|
|
case 0: |
|
|
@ -392,17 +382,7 @@ export default { |
|
|
|
this.getHouseInfoBy(this.blockForm.houseId); |
|
|
|
} else if (this.energyMeterConfig == 2) { |
|
|
|
this.getRoomByHouseId(this.blockForm.houseId); |
|
|
|
this.getLastMeter(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
console.log( |
|
|
|
this.waterMeterConfig, |
|
|
|
this.energyMeterConfig, |
|
|
|
"this.waterMeterConfig, this.energyMeterConfig" |
|
|
|
); |
|
|
|
console.log(this.houseOptions[e.detail.value]); |
|
|
|
|
|
|
|
this.$forceUpdate(); |
|
|
|
}, |
|
|
|
onDelete(event, index) { |
|
|
@ -461,6 +441,8 @@ export default { |
|
|
|
const res = await getHouseInfo(id); |
|
|
|
if (res.code == 200) { |
|
|
|
if (this.energyMeterConfig == 1) { |
|
|
|
this.getRoomByHouseId(id); |
|
|
|
|
|
|
|
this.form = [ |
|
|
|
{ |
|
|
|
electricMeterNumber: res.data.electricMeterNumber, |
|
|
@ -477,11 +459,11 @@ export default { |
|
|
|
}, |
|
|
|
// 获取上次抄表 |
|
|
|
async getLastMeter(item) { |
|
|
|
let roomId = ''; |
|
|
|
if(this.energyMeterConfig == 1){ |
|
|
|
roomId = this.blockForm.houseId; |
|
|
|
} else if (this.energyMeterConfig == 2) { |
|
|
|
// roomId = this.form.map((item) => item.id).join(','); |
|
|
|
let roomId = ""; |
|
|
|
if (this.waterMeterConfig == 1) { |
|
|
|
roomId = this.form[0].id; |
|
|
|
} else { |
|
|
|
roomId = this.blockForm.roomId; |
|
|
|
} |
|
|
|
const params = { |
|
|
|
houseId: this.blockForm.houseId, |
|
|
@ -491,35 +473,17 @@ export default { |
|
|
|
}; |
|
|
|
const res = await queryLastMeterReading(params); |
|
|
|
if (this.energyMeterConfig == 1) { |
|
|
|
this.form = [ |
|
|
|
{ |
|
|
|
electricMeterNumber: res.data[0].meterNumber, |
|
|
|
lastMeterReading: res.data[0].thisMeterReading, |
|
|
|
}, |
|
|
|
]; |
|
|
|
this.form = this.form.map((item) => ({ |
|
|
|
...item, |
|
|
|
lastMeterReading: res.data[0].thisMeterReading, |
|
|
|
electricMeterNumber: res.data[0].meterNumber, |
|
|
|
})); |
|
|
|
} else if (this.energyMeterConfig == 2) { |
|
|
|
this.form = this.form.map((item) => { |
|
|
|
// 找到 getLastMeter 返回的对应项 |
|
|
|
const meter = res.data.find( |
|
|
|
(m) => String(m.roomId) === String(item.id) |
|
|
|
); |
|
|
|
console.log(meter, "meter"); |
|
|
|
|
|
|
|
if (meter) { |
|
|
|
return { |
|
|
|
...item, |
|
|
|
lastMeterReading: meter.thisMeterReading, |
|
|
|
electricMeterNumber: meter.meterNumber, |
|
|
|
}; |
|
|
|
} |
|
|
|
return item; |
|
|
|
}); |
|
|
|
this.form = this.form.map((item) => { |
|
|
|
// 找到 getLastMeter 返回的对应项 |
|
|
|
const meter = res.data.find( |
|
|
|
(m) => String(m.roomId) === String(item.id) |
|
|
|
); |
|
|
|
console.log(meter, "meter"); |
|
|
|
|
|
|
|
if (meter) { |
|
|
|
return { |
|
|
@ -531,42 +495,19 @@ export default { |
|
|
|
return item; |
|
|
|
}); |
|
|
|
} |
|
|
|
// if (Array.isArray(res.data) && res.data.length > 0) { |
|
|
|
|
|
|
|
// } else { |
|
|
|
// // res.data 为空时,显示一个空表单 |
|
|
|
// this.form = [ |
|
|
|
// { |
|
|
|
// lastMeterReading: "", |
|
|
|
// // meterNumber: "", |
|
|
|
// thisMeterReading: "", |
|
|
|
// }, |
|
|
|
// ]; |
|
|
|
// } |
|
|
|
}, |
|
|
|
async getRoomByHouseId(id) { |
|
|
|
const res = await getRoomByHouseId({ houseId: id }); |
|
|
|
if (res.code == 200) { |
|
|
|
console.log(res.data, "res.data"); |
|
|
|
const data = res.data; |
|
|
|
if (this.energyMeterConfig == 1) { |
|
|
|
this.form = [{}]; |
|
|
|
this.form = this.form.map((item) => ({ |
|
|
|
...item, |
|
|
|
id: res.data[0].id, |
|
|
|
})); |
|
|
|
} else if (this.energyMeterConfig == 2) { |
|
|
|
this.form = res.data; |
|
|
|
this.getLastMeter(); |
|
|
|
} |
|
|
|
|
|
|
|
console.log(this.form, "this.form"); |
|
|
|
// if (this.waterMeterConfig == 1 && this.energyMeterConfig == 1) { |
|
|
|
// this.sbList = []; |
|
|
|
// this.dbList = []; |
|
|
|
// } else if (this.waterMeterConfig == 1 && this.energyMeterConfig == 2) { |
|
|
|
// this.sbList = []; |
|
|
|
// this.dbList = data; |
|
|
|
// } else if (this.waterMeterConfig == 2 && this.energyMeterConfig == 1) { |
|
|
|
// this.sbList = data; |
|
|
|
// this.dbList = []; |
|
|
|
// } |
|
|
|
} |
|
|
|
}, |
|
|
|
onSubmit() { |
|
|
@ -621,13 +562,13 @@ export default { |
|
|
|
// }); |
|
|
|
// return; |
|
|
|
// } |
|
|
|
if (!item.lastMeterReading && item.lastMeterReading !== 0) { |
|
|
|
uni.showToast({ |
|
|
|
title: `请填写上次表数`, |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
return; |
|
|
|
} |
|
|
|
// if (!item.lastMeterReading && item.lastMeterReading !== 0) { |
|
|
|
// uni.showToast({ |
|
|
|
// title: `请填写上次表数`, |
|
|
|
// icon: "none", |
|
|
|
// }); |
|
|
|
// return; |
|
|
|
// } |
|
|
|
if (!item.thisMeterReading && item.thisMeterReading !== 0) { |
|
|
|
uni.showToast({ |
|
|
|
title: `请填写本次表数`, |
|
|
@ -645,7 +586,6 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
this.submitAdd(); |
|
|
|
console.log("onSubmit", this.form); |
|
|
|
}, |
|
|
|
async submitAdd() { |
|
|
|
let params = this.form.map((item) => ({ |
|
|
@ -653,7 +593,7 @@ export default { |
|
|
|
meterType: 1, |
|
|
|
houseId: this.blockForm.houseId, |
|
|
|
roomId: item.id || "", |
|
|
|
lastMeterReading: parseFloat(item.lastMeterReading).toFixed(4), |
|
|
|
lastMeterReading: isNaN(parseFloat(item.lastMeterReading)) ? '' : parseFloat(item.lastMeterReading).toFixed(4), |
|
|
|
thisMeterReading: parseFloat(item.thisMeterReading).toFixed(4), |
|
|
|
images: (item.fileList || []).map((f) => ({ |
|
|
|
url: f.url, |
|
|
@ -664,7 +604,6 @@ export default { |
|
|
|
remark: item.remark || "", |
|
|
|
})); |
|
|
|
console.log(params, "params"); |
|
|
|
|
|
|
|
const res = await submitWaterAndElectricity(params); |
|
|
|
if (res.code == 200) { |
|
|
|
uni.showToast({ |
|
|
@ -687,7 +626,6 @@ export default { |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
} |
|
|
|
console.log(res, "reeees"); |
|
|
|
}, |
|
|
|
}, |
|
|
|
}; |
|
|
|