Compare commits

...

2 Commits

Author SHA1 Message Date
wangyx 6573f2ff59 优化 1 month ago
wangyx 121db33bf3 无房屋选不了 1 month ago
  1. 147
      pagesA/sdPage/dfReport.vue
  2. 150
      pagesA/sdPage/sfReport.vue

147
pagesA/sdPage/dfReport.vue

@ -52,11 +52,7 @@
:value="multiIndex" :value="multiIndex"
:range="multiArray" :range="multiArray"
> >
<view class="uni-input">{{ <view class="uni-input">{{pickerDisplay}}</view>
multiArray[0][multiIndex[0]] +
multiArray[1][multiIndex[1]] +
multiArray[2][multiIndex[2]]
}}</view>
</picker> </picker>
</view> </view>
<view v-else @click="handleShowToast" style="color: #cbcbcb" <view v-else @click="handleShowToast" style="color: #cbcbcb"
@ -85,9 +81,9 @@
> >
<text>电表号</text> <text>电表号</text>
</view> </view>
<u-input <u--input
v-model="item.electricMeterNumber" v-model="item.electricMeterNumber"
type="digit" type="text"
placeholder="请输入电表号" placeholder="请输入电表号"
border="none" border="none"
:disabled="item.isSystemElectricMeterNumber" :disabled="item.isSystemElectricMeterNumber"
@ -278,6 +274,14 @@ export default {
this.getTree(); this.getTree();
// this.initMeterReadingTime(); // this.initMeterReadingTime();
}, },
computed: {
pickerDisplay() {
const a = this.multiArray?.[0]?.[this.multiIndex?.[0]] || ''
const b = this.multiArray?.[1]?.[this.multiIndex?.[1]] || ''
const c = (this.multiArray?.[2]?.length > 0) ? (this.multiArray[2][this.multiIndex?.[2]] || '') : ''
return [a, b, c].filter(Boolean).join('')
}
},
methods: { methods: {
// //
initMeterReadingTime() { initMeterReadingTime() {
@ -388,10 +392,12 @@ export default {
const houseArray = await this.getListByParentId("4", unitArray[0].id); const houseArray = await this.getListByParentId("4", unitArray[0].id);
// //
if (!houseArray || houseArray.length === 0) { // if (!houseArray || houseArray.length === 0) {
console.warn("未获取到户信息"); // console.warn("");
return; // return;
} // }
if(houseArray.length > 0 && houseArray[0]){
this.houseOptions = houseArray; this.houseOptions = houseArray;
const houseNames = houseArray.map((item) => item.name); const houseNames = houseArray.map((item) => item.name);
this.blockForm.houseId = houseArray[0].id; this.blockForm.houseId = houseArray[0].id;
@ -408,6 +414,10 @@ export default {
// }); // });
// } // }
this.multiArray = [buildingNames, unitNames, houseNames]; this.multiArray = [buildingNames, unitNames, houseNames];
}else {
this.houseOptions = [];
this.multiArray = [buildingNames, unitNames, []];
}
if (this.energyMeterConfig == 1) { if (this.energyMeterConfig == 1) {
this.getHouseInfoBy(this.blockForm.houseId); this.getHouseInfoBy(this.blockForm.houseId);
} else if (this.energyMeterConfig == 2) { } else if (this.energyMeterConfig == 2) {
@ -436,91 +446,66 @@ export default {
uni.showToast({ title: "请选择乐业社区", icon: "none" }); uni.showToast({ title: "请选择乐业社区", icon: "none" });
}, },
async bindMultiPickerColumnChange(e) { async bindMultiPickerColumnChange(e) {
if (!this.multiArray[0].length) return; if (!this.multiArray[0].length) return
this.multiIndex[e.detail.column] = e.detail.value;
switch (e.detail.column) {
case 0:
{
const unitArray = await this.getListByParentId(
"3",
this.buildingOptions[e.detail.value].id
);
//
if (!unitArray || unitArray.length === 0) {
console.warn("未获取到单元信息");
return;
}
this.unitOptions = unitArray;
const unitNames = unitArray.map((item) => item.name);
this.blockForm.unitId = unitArray[0].id;
const houseArray = await this.getListByParentId( // 450 splice
"4", this.multiIndex.splice(e.detail.column, 1, e.detail.value)
unitArray[0].id
);
// switch (e.detail.column) {
if (!houseArray || houseArray.length === 0) { case 0: {
console.warn("未获取到户信息"); const unitArray = await this.getListByParentId('3', this.buildingOptions[e.detail.value].id)
return; if (!unitArray || unitArray.length === 0) return
} this.unitOptions = unitArray
const unitNames = unitArray.map(item => item.name)
this.blockForm.unitId = unitArray[0].id
this.houseOptions = houseArray; const houseArray = await this.getListByParentId('4', unitArray[0].id)
const houseNames = houseArray.map((item) => item.name); if (!houseArray || houseArray.length === 0) return
this.blockForm.houseId = houseArray[0].id; this.houseOptions = houseArray
this.blockForm.roomId = houseArray[0].roomId; const houseNames = houseArray.map(item => item.name)
this.blockForm.houseId = houseArray[0].id
this.blockForm.roomId = houseArray[0].roomId
this.multiArray[1] = unitNames; // 485/486 $set
this.multiArray[2] = houseNames; this.$set(this.multiArray, 1, unitNames)
} //1 this.$set(this.multiArray, 2, houseNames)
this.multiIndex.splice(1, 1, 0); //
this.multiIndex.splice(2, 1, 0); this.multiIndex.splice(1, 1, 0)
break; this.multiIndex.splice(2, 1, 0)
case 1: break
{ }
const houseArray = await this.getListByParentId( case 1: {
"4", const houseArray = await this.getListByParentId('4', this.unitOptions[e.detail.value].id)
this.unitOptions[e.detail.value].id if (!houseArray || houseArray.length === 0) return
); this.houseOptions = houseArray
const houseNames = houseArray.map(item => item.name)
this.blockForm.houseId = houseArray[0].id
this.blockForm.roomId = houseArray[0].roomId
// // 508 $set
if (!houseArray || houseArray.length === 0) { this.$set(this.multiArray, 2, houseNames)
console.warn("未获取到户信息"); //
return; this.multiIndex.splice(2, 1, 0)
break
} }
this.houseOptions = houseArray;
const houseNames = houseArray.map((item) => item.name);
this.blockForm.houseId = houseArray[0].id;
this.blockForm.roomId = houseArray[0].roomId;
this.multiArray[2] = houseNames;
} //2
this.multiIndex.splice(2, 1, 0);
break;
case 2: { case 2: {
this.blockForm.houseId = this.houseOptions[e.detail.value].id; // splice
this.blockForm.roomId = this.houseOptions[e.detail.value].roomId; this.multiIndex.splice(2, 1, e.detail.value)
this.waterMeterConfig = this.blockForm.houseId = this.houseOptions[e.detail.value].id
this.houseOptions[e.detail.value].waterMeterConfig; this.blockForm.roomId = this.houseOptions[e.detail.value].roomId
this.energyMeterConfig = this.waterMeterConfig = this.houseOptions[e.detail.value].waterMeterConfig
this.houseOptions[e.detail.value].energyMeterConfig; this.energyMeterConfig = this.houseOptions[e.detail.value].energyMeterConfig
break
} }
} }
//
if (this.energyMeterConfig && this.blockForm.houseId) { if (this.energyMeterConfig && this.blockForm.houseId) {
if (this.energyMeterConfig == 1) { if (this.energyMeterConfig == 1) {
this.getHouseInfoBy(this.blockForm.houseId); this.getHouseInfoBy(this.blockForm.houseId)
} else if (this.energyMeterConfig == 2) { } else if (this.energyMeterConfig == 2) {
this.getRoomByHouseId(this.blockForm.houseId); this.getRoomByHouseId(this.blockForm.houseId)
} }
} }
this.$forceUpdate();
}, },
onDelete(event, index) { onDelete(event, index) {
if (this.form[index] && Array.isArray(this.form[index].fileList)) { if (this.form[index] && Array.isArray(this.form[index].fileList)) {

150
pagesA/sdPage/sfReport.vue

@ -52,11 +52,7 @@
:value="multiIndex" :value="multiIndex"
:range="multiArray" :range="multiArray"
> >
<view class="uni-input">{{ <view class="uni-input">{{pickerDisplay}}</view>
multiArray[0][multiIndex[0]] +
multiArray[1][multiIndex[1]] +
multiArray[2][multiIndex[2]]
}}</view>
</picker> </picker>
</view> </view>
<view v-else @click="handleShowToast" style="color: #cbcbcb" <view v-else @click="handleShowToast" style="color: #cbcbcb"
@ -80,9 +76,9 @@
> >
<text>水表号</text> <text>水表号</text>
</view> </view>
<u-input <u--input
v-model="item.waterMeterNumber" v-model="item.waterMeterNumber"
type="digit" type="text"
placeholder="请输入水表号" placeholder="请输入水表号"
border="none" border="none"
:disabled="item.isSystemWaterMeterNumber" :disabled="item.isSystemWaterMeterNumber"
@ -259,6 +255,14 @@ export default {
deep: true, deep: true,
immediate: true, immediate: true,
}, },
},
computed: {
pickerDisplay() {
const a = this.multiArray?.[0]?.[this.multiIndex?.[0]] || ''
const b = this.multiArray?.[1]?.[this.multiIndex?.[1]] || ''
const c = (this.multiArray?.[2]?.length > 0) ? (this.multiArray[2][this.multiIndex?.[2]] || '') : ''
return [a, b, c].filter(Boolean).join('')
}
}, },
onLoad() { onLoad() {
this.getTree(); this.getTree();
@ -330,11 +334,11 @@ export default {
// //
const houseArray = await this.getListByParentId("4", unitArray[0].id); const houseArray = await this.getListByParentId("4", unitArray[0].id);
if (!houseArray || houseArray.length === 0) { // if (!houseArray || houseArray.length === 0) {
console.warn("未获取到户信息"); // console.warn("");
return; // return;
} // }
if(houseArray.length > 0 && houseArray[0]){
this.houseOptions = houseArray; this.houseOptions = houseArray;
const houseNames = houseArray.map((item) => item.name); const houseNames = houseArray.map((item) => item.name);
this.blockForm.houseId = houseArray[0].id; this.blockForm.houseId = houseArray[0].id;
@ -344,6 +348,13 @@ export default {
let house = houseArray[0]; let house = houseArray[0];
this.multiArray = [buildingNames, unitNames, houseNames]; this.multiArray = [buildingNames, unitNames, houseNames];
}else {
this.houseOptions = [];
this.multiArray = [buildingNames, unitNames, []];
}
console.log(this.multiArray,"this.multiArray11");
if (this.waterMeterConfig == 1) { if (this.waterMeterConfig == 1) {
this.getHouseInfoBy(this.blockForm.houseId); this.getHouseInfoBy(this.blockForm.houseId);
} else if (this.waterMeterConfig == 2) { } else if (this.waterMeterConfig == 2) {
@ -371,89 +382,71 @@ export default {
} }
}, },
handleShowToast() { handleShowToast() {
console.log(this.multiArray,"this.multiArray");
uni.showToast({ title: "请选择乐业社区", icon: "none" }); uni.showToast({ title: "请选择乐业社区", icon: "none" });
}, },
async bindMultiPickerColumnChange(e) { async bindMultiPickerColumnChange(e) {
if (!this.multiArray[0].length) return; if (!this.multiArray[0].length) return
this.multiIndex[e.detail.column] = e.detail.value;
switch (e.detail.column) {
case 0:
{
const unitArray = await this.getListByParentId(
"3",
this.buildingOptions[e.detail.value].id
);
// // splice this.multiIndex[e.detail.column] = e.detail.value
if (!unitArray || unitArray.length === 0) { this.multiIndex.splice(e.detail.column, 1, e.detail.value)
console.warn("未获取到单元信息");
return;
}
this.unitOptions = unitArray; switch (e.detail.column) {
const unitNames = unitArray.map((item) => item.name); case 0: {
this.blockForm.unitId = unitArray[0].id; const unitArray = await this.getListByParentId('3', this.buildingOptions[e.detail.value].id)
if (!unitArray || unitArray.length === 0) return
this.unitOptions = unitArray
const unitNames = unitArray.map(item => item.name)
this.blockForm.unitId = unitArray[0].id
const houseArray = await this.getListByParentId( const houseArray = await this.getListByParentId('4', unitArray[0].id)
"4", if (!houseArray || houseArray.length === 0) return
unitArray[0].id this.houseOptions = houseArray
); const houseNames = houseArray.map(item => item.name)
this.blockForm.houseId = houseArray[0].id
this.blockForm.roomId = houseArray[0].roomId
// //
if (!houseArray || houseArray.length === 0) { this.$set(this.multiArray, 1, unitNames)
console.warn("未获取到户信息"); this.$set(this.multiArray, 2, houseNames)
return;
}
this.houseOptions = houseArray; //
const houseNames = houseArray.map((item) => item.name); this.multiIndex.splice(1, 1, 0)
this.blockForm.houseId = houseArray[0].id; this.multiIndex.splice(2, 1, 0)
this.blockForm.roomId = houseArray[0].roomId; break
this.multiArray[1] = unitNames; }
this.multiArray[2] = houseNames; case 1: {
} const houseArray = await this.getListByParentId('4', this.unitOptions[e.detail.value].id)
this.multiIndex.splice(1, 1, 0); if (!houseArray || houseArray.length === 0) return
this.multiIndex.splice(2, 1, 0); this.houseOptions = houseArray
break; const houseNames = houseArray.map(item => item.name)
case 1: this.blockForm.houseId = houseArray[0].id
{ this.blockForm.roomId = houseArray[0].roomId
const houseArray = await this.getListByParentId(
"4",
this.unitOptions[e.detail.value].id
);
// this.$set(this.multiArray, 2, houseNames)
if (!houseArray || houseArray.length === 0) {
console.warn("未获取到户信息");
return;
}
this.houseOptions = houseArray; //
const houseNames = houseArray.map((item) => item.name); this.multiIndex.splice(2, 1, 0)
this.blockForm.houseId = houseArray[0].id; break
this.blockForm.roomId = houseArray[0].roomId;
this.multiArray[2] = houseNames;
} }
this.multiIndex.splice(2, 1, 0);
break;
case 2: { case 2: {
this.blockForm.houseId = this.houseOptions[e.detail.value].id; // splice
this.blockForm.roomId = this.houseOptions[e.detail.value].roomId; this.blockForm.houseId = this.houseOptions[e.detail.value].id
this.waterMeterConfig = this.blockForm.roomId = this.houseOptions[e.detail.value].roomId
this.houseOptions[e.detail.value].waterMeterConfig; this.waterMeterConfig = this.houseOptions[e.detail.value].waterMeterConfig
break
} }
} }
// //
if (this.waterMeterConfig && this.blockForm.houseId) { if (this.waterMeterConfig && this.blockForm.houseId) {
if (this.waterMeterConfig == 1) { if (this.waterMeterConfig == 1) {
this.getHouseInfoBy(this.blockForm.houseId); this.getHouseInfoBy(this.blockForm.houseId)
} else if (this.waterMeterConfig == 2) { } else if (this.waterMeterConfig == 2) {
this.getRoomByHouseId(this.blockForm.houseId); this.getRoomByHouseId(this.blockForm.houseId)
} }
} }
this.$forceUpdate();
}, },
// //
oversize(e) { oversize(e) {
@ -575,16 +568,19 @@ export default {
(m) => String(m.roomId) === String(item.id) (m) => String(m.roomId) === String(item.id)
); );
if (meter) { if (meter) {
const hasMeterNum = !!(meter.meterNumber && meter.meterNumber.trim() !== '');
return { return {
...item, ...item,
lastMeterReading: meter.thisMeterReading || 0, lastMeterReading: meter.thisMeterReading || 0,
waterMeterNumber: meter.meterNumber || "", waterMeterNumber: meter.meterNumber || '',
isSystemWaterMeterNumber: !!(meter.meterNumber && meter.meterNumber.trim() !== ''), isSystemWaterMeterNumber: hasMeterNum, //
meterReadingTime: item.meterReadingTime || this.formatDateTime(new Date()), // meterReadingTime: item.meterReadingTime || this.formatDateTime(new Date()), //
}; };
} }
return item; return item;
}); });
console.log(this.form,"this.form11");
} }
}, },
// //

Loading…
Cancel
Save