|
@ -5,24 +5,43 @@ |
|
|
<view>填写信息</view> |
|
|
<view>填写信息</view> |
|
|
<view>请您填写相关问题</view> |
|
|
<view>请您填写相关问题</view> |
|
|
</view> |
|
|
</view> |
|
|
<image class="bg-img" src="/static/img/bsorbxBac.png" mode="aspectFill"></image> |
|
|
<image |
|
|
|
|
|
class="bg-img" |
|
|
|
|
|
src="/static/img/bsorbxBac.png" |
|
|
|
|
|
mode="aspectFill" |
|
|
|
|
|
></image> |
|
|
</view> |
|
|
</view> |
|
|
<view class="info-card"> |
|
|
<view class="info-card"> |
|
|
<view class="meter-row"> |
|
|
<view class="meter-row"> |
|
|
<view class="meter-label"> |
|
|
<view class="meter-label"> |
|
|
<view style="color: #f93838;margin-right: 4rpx;font-size: 24rpx;">*</view> |
|
|
<view style="color: #f93838; margin-right: 4rpx; font-size: 24rpx" |
|
|
|
|
|
>*</view |
|
|
|
|
|
> |
|
|
<text>乐业社区</text> |
|
|
<text>乐业社区</text> |
|
|
</view> |
|
|
</view> |
|
|
<view class="picker-label"> |
|
|
<view class="picker-label"> |
|
|
<picker mode="selector" :range="deptNames" @change="onPickerChange($event,'乐业社区')"> |
|
|
<picker |
|
|
<view :style="{'color':!form.apartmentName?'#cbcbcb':''}">{{form.apartmentName || pickerPlaceholder}}</view> |
|
|
mode="selector" |
|
|
|
|
|
:range="deptNames" |
|
|
|
|
|
@change="onPickerChange($event, '乐业社区')" |
|
|
|
|
|
> |
|
|
|
|
|
<view |
|
|
|
|
|
:style="{ color: !blockForm.apartmentName ? '#cbcbcb' : '' }" |
|
|
|
|
|
>{{ blockForm.apartmentName || pickerPlaceholder }}</view |
|
|
|
|
|
> |
|
|
</picker> |
|
|
</picker> |
|
|
<image class="arrow-r" src="/static/img/arrow-right.png" mode="aspectFill"></image> |
|
|
<image |
|
|
|
|
|
class="arrow-r" |
|
|
|
|
|
src="/static/img/arrow-right.png" |
|
|
|
|
|
mode="aspectFill" |
|
|
|
|
|
></image> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
<view class="meter-row"> |
|
|
<view class="meter-row"> |
|
|
<view class="meter-label"> |
|
|
<view class="meter-label"> |
|
|
<view style="color: #f93838;margin-right: 4rpx;font-size: 24rpx;">*</view> |
|
|
<view style="color: #f93838; margin-right: 4rpx; font-size: 24rpx" |
|
|
|
|
|
>*</view |
|
|
|
|
|
> |
|
|
<text>房屋</text> |
|
|
<text>房屋</text> |
|
|
</view> |
|
|
</view> |
|
|
<view class="picker-label"> |
|
|
<view class="picker-label"> |
|
@ -42,53 +61,84 @@ |
|
|
}}</view> |
|
|
}}</view> |
|
|
</picker> |
|
|
</picker> |
|
|
</view> |
|
|
</view> |
|
|
<view v-else @click="handleShowToast" style="color:#cbcbcb">请选择社区</view> |
|
|
<view v-else @click="handleShowToast" style="color: #cbcbcb" |
|
|
<image class="arrow-r" src="/static/img/arrow-right.png" mode="aspectFill"></image> |
|
|
>请选择社区</view |
|
|
|
|
|
> |
|
|
|
|
|
<image |
|
|
|
|
|
class="arrow-r" |
|
|
|
|
|
src="/static/img/arrow-right.png" |
|
|
|
|
|
mode="aspectFill" |
|
|
|
|
|
></image> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
<scroll-view class="house-view" scroll-y="true"> |
|
|
<scroll-view class="house-view" scroll-y="true"> |
|
|
<view class="section-card" v-for="(item,index) in form.waterMeters" :key="item.id"> |
|
|
<view class="section-card" v-for="(item, index) in form" :key="index"> |
|
|
<view class="meter-row"> |
|
|
<view class="meter-row"> |
|
|
<text class="meter-label">水表号</text> |
|
|
<view class="meter-label"> |
|
|
|
|
|
<view style="color: #f93838; margin-right: 4rpx; font-size: 24rpx" |
|
|
|
|
|
>*</view |
|
|
|
|
|
> |
|
|
|
|
|
<text>水表号</text> |
|
|
|
|
|
</view> |
|
|
<u-input |
|
|
<u-input |
|
|
v-model="item.meterNumber" |
|
|
v-model="item.waterMeterNumber" |
|
|
type="digit" |
|
|
type="digit" |
|
|
placeholder="请输入水表号" |
|
|
placeholder="请输入水表号" |
|
|
border="none" |
|
|
border="none" |
|
|
:disabled="!!item.meterNumber" |
|
|
:disabled="!!item.waterMeterNumber" |
|
|
:custom-style="item.meterNumber ? 'background:#fff;color:#bbb;' : ''" |
|
|
:custom-style=" |
|
|
|
|
|
item.waterMeterNumber ? 'background:#fff;color:#bbb;' : '' |
|
|
|
|
|
" |
|
|
/> |
|
|
/> |
|
|
</view> |
|
|
</view> |
|
|
<view class="meter-row"> |
|
|
<view class="meter-row"> |
|
|
<text class="meter-label">上次表数</text> |
|
|
<view class="meter-label"> |
|
|
|
|
|
<view style="color: #f93838; margin-right: 4rpx; font-size: 24rpx" |
|
|
|
|
|
>*</view |
|
|
|
|
|
> |
|
|
|
|
|
<text>上次表数</text> |
|
|
|
|
|
</view> |
|
|
<u-input |
|
|
<u-input |
|
|
v-model="item.lastMeterReading" |
|
|
v-model="form[index].lastMeterReading" |
|
|
type="digit" |
|
|
type="digit" |
|
|
placeholder="请输入上次表数" |
|
|
placeholder="请输入上次表数" |
|
|
border="none" |
|
|
border="none" |
|
|
:disabled="!!item.lastMeterReading" |
|
|
:custom-style=" |
|
|
:custom-style="item.lastMeterReading ? 'background:#fff;color:#bbb;' : ''" |
|
|
form[index].electricMeterNumber |
|
|
|
|
|
? 'background:#fff;color:#bbb;' |
|
|
|
|
|
: '' |
|
|
|
|
|
" |
|
|
/> |
|
|
/> |
|
|
</view> |
|
|
</view> |
|
|
<view class="meter-row"> |
|
|
<view class="meter-row"> |
|
|
<text class="meter-label">本次表数</text> |
|
|
<view class="meter-label"> |
|
|
|
|
|
<view style="color: #f93838; margin-right: 4rpx; font-size: 24rpx" |
|
|
|
|
|
>*</view |
|
|
|
|
|
> |
|
|
|
|
|
<text>本次表数</text> |
|
|
|
|
|
</view> |
|
|
<u-input |
|
|
<u-input |
|
|
v-model="item.thisMeterReading" |
|
|
v-model="form[index].thisMeterReading" |
|
|
type="digit" |
|
|
type="digit" |
|
|
placeholder="请输入本次表数" |
|
|
placeholder="请输入本次表数" |
|
|
border="none" |
|
|
border="none" |
|
|
/> |
|
|
/> |
|
|
</view> |
|
|
</view> |
|
|
<view class="imeter-row"> |
|
|
<view class="imeter-row"> |
|
|
<text class="meter-label">上传图片/视频</text> |
|
|
<view class="meter-label"> |
|
|
|
|
|
<view style="color: #f93838; margin-right: 4rpx; font-size: 24rpx" |
|
|
|
|
|
>*</view |
|
|
|
|
|
> |
|
|
|
|
|
<text>图片/视频</text> |
|
|
|
|
|
</view> |
|
|
<u-upload |
|
|
<u-upload |
|
|
:max-count="10" |
|
|
:max-count="10" |
|
|
:multiple="true" |
|
|
:multiple="true" |
|
|
:preview-full-image="true" |
|
|
:preview-full-image="true" |
|
|
:deletable="true" |
|
|
:deletable="true" |
|
|
:show-upload-list="true" |
|
|
:show-upload-list="true" |
|
|
:fileList="item.fileList || []" |
|
|
:fileList="form[index].fileList || []" |
|
|
:auto-upload="false" |
|
|
:auto-upload="false" |
|
|
accept="all" |
|
|
accept="all" |
|
|
:maxSize="10 * 1024 * 1024" |
|
|
:maxSize="10 * 1024 * 1024" |
|
@ -100,7 +150,11 @@ |
|
|
@click.stop="() => chooseMedia(index)" |
|
|
@click.stop="() => chooseMedia(index)" |
|
|
> |
|
|
> |
|
|
<view class="icon-box"> |
|
|
<view class="icon-box"> |
|
|
<image class="camera-icon" src="/static/img/camera-icon.png" mode="aspectFill"></image> |
|
|
<image |
|
|
|
|
|
class="camera-icon" |
|
|
|
|
|
src="/static/img/camera-icon.png" |
|
|
|
|
|
mode="aspectFill" |
|
|
|
|
|
></image> |
|
|
</view> |
|
|
</view> |
|
|
<view class="upload-tips">点击上传</view> |
|
|
<view class="upload-tips">点击上传</view> |
|
|
</view> |
|
|
</view> |
|
@ -114,52 +168,55 @@ |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script> |
|
|
<script> |
|
|
|
|
|
import { queryDeptDropdownList } from "@/common/rec"; |
|
|
import { |
|
|
import { getdeptList } from "@/common/api"; |
|
|
queryDeptDropdownList, |
|
|
|
|
|
} from "@/common/rec"; |
|
|
|
|
|
import { getdeptList } from '@/common/api'; |
|
|
|
|
|
import { |
|
|
import { |
|
|
uploadImage, |
|
|
uploadImage, |
|
|
queryLastMeterReading, |
|
|
queryLastMeterReading, |
|
|
submitWaterAndElectricity |
|
|
submitWaterAndElectricity, |
|
|
} from '@/pages/api'; |
|
|
getRoomByHouseId, |
|
|
|
|
|
getHouseInfo, |
|
|
|
|
|
} from "@/pages/api"; |
|
|
|
|
|
|
|
|
export default { |
|
|
export default { |
|
|
data() { |
|
|
data() { |
|
|
return { |
|
|
return { |
|
|
pickerPlaceholder: '请选择', // 初始显示的文字 |
|
|
pickerPlaceholder: "请选择", // 初始显示的文字 |
|
|
waterMeter: 3245.1, |
|
|
waterMeter: 3245.1, |
|
|
electricMeter: 2672.6, |
|
|
electricMeter: 2672.6, |
|
|
remark: '', |
|
|
remark: "", |
|
|
fileList: [], |
|
|
fileList: [], |
|
|
deptNames: [], |
|
|
deptNames: [], |
|
|
deptOptions: [], |
|
|
deptOptions: [], |
|
|
|
|
|
blockForm: {}, |
|
|
buildingOptions: [], |
|
|
buildingOptions: [], |
|
|
unitOptions: [], |
|
|
unitOptions: [], |
|
|
houseOptions: [], |
|
|
houseOptions: [], |
|
|
multiArray: [[], [], []], |
|
|
multiArray: [[], [], []], |
|
|
multiIndex: [-1, -1, -1], |
|
|
multiIndex: [-1, -1, -1], |
|
|
form:{ |
|
|
form: [ |
|
|
apartmentId: '', |
|
|
{ |
|
|
apartmentName:'', |
|
|
meterNumber: "", |
|
|
buildingId: '', |
|
|
meterType: 2, // 1:电表 2:水表 |
|
|
unitId: '', |
|
|
houseId: "", // 初始化时可为空,选择房屋后赋值 |
|
|
houseId: '', |
|
|
roomId: "", |
|
|
roomId: '', |
|
|
lastMeterReading: "", |
|
|
waterMeters: [], |
|
|
thisMeterReading: "", |
|
|
remark: '' |
|
|
fileList: [], |
|
|
|
|
|
remark: "", |
|
|
|
|
|
waterMeterNumber: "", |
|
|
}, |
|
|
}, |
|
|
} |
|
|
], // |
|
|
|
|
|
waterMeterConfig: "", |
|
|
|
|
|
}; |
|
|
}, |
|
|
}, |
|
|
watch: { |
|
|
watch: { |
|
|
"form.apartmentId": { |
|
|
"blockForm.apartmentId": { |
|
|
handler(newVal, oldVal) { |
|
|
handler(newVal, oldVal) { |
|
|
console.log("newVal", newVal); |
|
|
console.log("newVal", newVal); |
|
|
this.form.buildingId = null; |
|
|
this.blockForm.buildingId = null; |
|
|
this.form.unitId = null; |
|
|
this.blockForm.unitId = null; |
|
|
this.form.houseId = null; |
|
|
this.blockForm.houseId = null; |
|
|
this.buildingOptions = []; |
|
|
this.buildingOptions = []; |
|
|
this.unitOptions = []; |
|
|
this.unitOptions = []; |
|
|
this.houseOptions = []; |
|
|
this.houseOptions = []; |
|
@ -169,7 +226,7 @@ export default { |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
onLoad() { |
|
|
onLoad() { |
|
|
this.getTree() |
|
|
this.getTree(); |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
getTree() { |
|
|
getTree() { |
|
@ -209,8 +266,8 @@ export default { |
|
|
console.log("社区信息", apartmentInfo); |
|
|
console.log("社区信息", apartmentInfo); |
|
|
console.log("社区信息11", this.deptOptions); |
|
|
console.log("社区信息11", this.deptOptions); |
|
|
|
|
|
|
|
|
this.form.apartmentName = apartmentInfo.deptName; |
|
|
this.blockForm.apartmentName = apartmentInfo.deptName; |
|
|
this.form.apartmentId = apartmentInfo.deptId; |
|
|
this.blockForm.apartmentId = apartmentInfo.deptId; |
|
|
// 楼 |
|
|
// 楼 |
|
|
const buildingArray = await this.getListByParentId( |
|
|
const buildingArray = await this.getListByParentId( |
|
|
"2", |
|
|
"2", |
|
@ -221,7 +278,7 @@ export default { |
|
|
const buildingNames = buildingArray.map((item) => item.name); |
|
|
const buildingNames = buildingArray.map((item) => item.name); |
|
|
console.log("buildingNames:", buildingNames); |
|
|
console.log("buildingNames:", buildingNames); |
|
|
|
|
|
|
|
|
this.form.buildingId = buildingArray[0].id; |
|
|
this.blockForm.buildingId = buildingArray[0].id; |
|
|
// 单元 |
|
|
// 单元 |
|
|
const unitArray = await this.getListByParentId( |
|
|
const unitArray = await this.getListByParentId( |
|
|
"3", |
|
|
"3", |
|
@ -231,13 +288,21 @@ export default { |
|
|
console.log("unitArray:", unitArray); |
|
|
console.log("unitArray:", unitArray); |
|
|
|
|
|
|
|
|
const unitNames = unitArray.map((item) => item.name); |
|
|
const unitNames = unitArray.map((item) => item.name); |
|
|
this.form.unitId = unitArray[0].id; |
|
|
this.blockForm.unitId = unitArray[0].id; |
|
|
// 户 |
|
|
// 户 |
|
|
const houseArray = await this.getListByParentId("4", unitArray[0].id); |
|
|
const houseArray = await this.getListByParentId("4", unitArray[0].id); |
|
|
this.houseOptions = houseArray; |
|
|
this.houseOptions = houseArray; |
|
|
const houseNames = houseArray.map((item) => item.name); |
|
|
const houseNames = houseArray.map((item) => item.name); |
|
|
this.form.houseId = houseArray[0].id; |
|
|
this.blockForm.houseId = houseArray[0].id; |
|
|
this.form.roomId = houseArray[0].roomId; |
|
|
this.energyMeterConfig = houseArray[0].energyMeterConfig; |
|
|
|
|
|
this.waterMeterConfig = houseArray[0].waterMeterConfig; |
|
|
|
|
|
if (this.energyMeterConfig == 1) { |
|
|
|
|
|
this.getHouseInfoBy(this.blockForm.houseId); |
|
|
|
|
|
} else if (this.energyMeterConfig == 2) { |
|
|
|
|
|
this.getRoomByHouseId(this.blockForm.houseId); |
|
|
|
|
|
} |
|
|
|
|
|
this.getLastMeter(); |
|
|
|
|
|
this.blockForm.roomId = houseArray[0].roomId; |
|
|
let house = houseArray[0]; |
|
|
let house = houseArray[0]; |
|
|
// for (let index = 0; index < house.type; index++) { |
|
|
// for (let index = 0; index < house.type; index++) { |
|
|
// this.form.waterMeters.push({ |
|
|
// this.form.waterMeters.push({ |
|
@ -252,51 +317,63 @@ export default { |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
handleShowToast() { |
|
|
handleShowToast() { |
|
|
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; |
|
|
console.log('修改的列为:' + e.detail.column + ',值为:' + e.detail.value) |
|
|
this.multiIndex[e.detail.column] = e.detail.value; |
|
|
this.multiIndex[e.detail.column] = e.detail.value |
|
|
|
|
|
switch (e.detail.column) { |
|
|
switch (e.detail.column) { |
|
|
case 0: { |
|
|
case 0: |
|
|
const unitArray = await this.getListByParentId("3", this.buildingOptions[e.detail.value].id); |
|
|
{ |
|
|
this.unitOptions = unitArray |
|
|
const unitArray = await this.getListByParentId( |
|
|
const unitNames = unitArray.map(item=> item.name) |
|
|
"3", |
|
|
this.form.unitId = unitArray[0].id |
|
|
this.buildingOptions[e.detail.value].id |
|
|
|
|
|
); |
|
|
const houseArray = await this.getListByParentId("4", unitArray[0].id); |
|
|
this.unitOptions = unitArray; |
|
|
this.houseOptions = houseArray |
|
|
const unitNames = unitArray.map((item) => item.name); |
|
|
const houseNames = houseArray.map(item=> item.name) |
|
|
this.blockForm.unitId = unitArray[0].id; |
|
|
this.form.houseId = houseArray[0].id |
|
|
|
|
|
this.form.roomId = houseArray[0].roomId |
|
|
|
|
|
|
|
|
|
|
|
this.multiArray[1] = unitNames |
|
|
|
|
|
this.multiArray[2] = houseNames |
|
|
|
|
|
|
|
|
|
|
|
}//拖动第1列 |
|
|
|
|
|
this.multiIndex.splice(1, 1, 0) |
|
|
|
|
|
this.multiIndex.splice(2, 1, 0) |
|
|
|
|
|
break |
|
|
|
|
|
case 1:{ |
|
|
|
|
|
const houseArray = await this.getListByParentId("4", this.unitOptions[e.detail.value].id); |
|
|
|
|
|
this.houseOptions = houseArray |
|
|
|
|
|
const houseNames = houseArray.map(item=> item.name) |
|
|
|
|
|
this.form.houseId = houseArray[0].id |
|
|
|
|
|
this.form.roomId = houseArray[0].roomId |
|
|
|
|
|
|
|
|
|
|
|
this.multiArray[2] = houseNames |
|
|
const houseArray = await this.getListByParentId( |
|
|
} //拖动第2列 |
|
|
"4", |
|
|
this.multiIndex.splice(2, 1, 0) |
|
|
unitArray[0].id |
|
|
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[1] = unitNames; |
|
|
|
|
|
this.multiArray[2] = houseNames; |
|
|
|
|
|
} |
|
|
|
|
|
this.multiIndex.splice(1, 1, 0); |
|
|
|
|
|
this.multiIndex.splice(2, 1, 0); |
|
|
|
|
|
break; |
|
|
|
|
|
case 1: |
|
|
|
|
|
{ |
|
|
|
|
|
const houseArray = await this.getListByParentId( |
|
|
|
|
|
"4", |
|
|
|
|
|
this.unitOptions[e.detail.value].id |
|
|
|
|
|
); |
|
|
|
|
|
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; |
|
|
|
|
|
} |
|
|
|
|
|
this.multiIndex.splice(2, 1, 0); |
|
|
|
|
|
break; |
|
|
case 2: { |
|
|
case 2: { |
|
|
this.form.houseId = this.houseOptions[e.detail.value].id |
|
|
this.blockForm.houseId = this.houseOptions[e.detail.value].id; |
|
|
this.form.roomId = this.houseOptions[e.detail.value].roomId |
|
|
this.blockForm.roomId = this.houseOptions[e.detail.value].roomId; |
|
|
console.log(this.houseOptions[e.detail.value]); |
|
|
this.waterMeterConfig = |
|
|
|
|
|
this.houseOptions[e.detail.value].waterMeterConfig; |
|
|
|
|
|
if (this.waterMeterConfig == 1) { |
|
|
|
|
|
this.getHouseInfoBy(this.blockForm.houseId); |
|
|
|
|
|
} else if (this.waterMeterConfig == 2) { |
|
|
|
|
|
this.getRoomByHouseId(this.blockForm.houseId); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
this.getLastMeter() |
|
|
this.$forceUpdate(); |
|
|
this.$forceUpdate() |
|
|
|
|
|
}, |
|
|
}, |
|
|
//图片超过大小时取消上传 |
|
|
//图片超过大小时取消上传 |
|
|
oversize(e) { |
|
|
oversize(e) { |
|
@ -304,11 +381,11 @@ export default { |
|
|
return false; |
|
|
return false; |
|
|
}, |
|
|
}, |
|
|
chooseMedia(index) { |
|
|
chooseMedia(index) { |
|
|
if (!this.form.waterMeters[index].fileList) { |
|
|
if (!this.form[index].fileList) { |
|
|
this.$set(this.form.waterMeters[index], "fileList", []); |
|
|
this.$set(this.form[index], "fileList", []); |
|
|
} |
|
|
} |
|
|
uni.chooseMedia({ |
|
|
uni.chooseMedia({ |
|
|
count: 10 - this.form.waterMeters[index].fileList.length, |
|
|
count: 10 - this.form[index].fileList.length, |
|
|
mediaType: ["image", "video"], |
|
|
mediaType: ["image", "video"], |
|
|
sourceType: ["album", "camera"], |
|
|
sourceType: ["album", "camera"], |
|
|
maxDuration: 60, |
|
|
maxDuration: 60, |
|
@ -327,7 +404,7 @@ export default { |
|
|
: "image"); |
|
|
: "image"); |
|
|
// 上传 |
|
|
// 上传 |
|
|
const uploadRes = await uploadImage(filePath); |
|
|
const uploadRes = await uploadImage(filePath); |
|
|
this.form.waterMeters[index].fileList.push({ |
|
|
this.form[index].fileList.push({ |
|
|
url: uploadRes.data?.url || uploadRes.url || uploadRes.path, |
|
|
url: uploadRes.data?.url || uploadRes.url || uploadRes.path, |
|
|
name: uploadRes.data?.name || uploadRes.name || "", |
|
|
name: uploadRes.data?.name || uploadRes.name || "", |
|
|
type: type, |
|
|
type: type, |
|
@ -335,7 +412,9 @@ export default { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
// 更新 imageList |
|
|
// 更新 imageList |
|
|
this.form.waterMeters[index].imageList = this.form.waterMeters[index].fileList.map((v) => v.url); |
|
|
this.form[index].imageList = this.form[index].fileList.map( |
|
|
|
|
|
(v) => v.url |
|
|
|
|
|
); |
|
|
} catch (e) { |
|
|
} catch (e) { |
|
|
uni.showToast({ title: "上传失败", icon: "none" }); |
|
|
uni.showToast({ title: "上传失败", icon: "none" }); |
|
|
} finally { |
|
|
} finally { |
|
@ -347,72 +426,147 @@ export default { |
|
|
}, |
|
|
}, |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
|
// 获取上次抄表 |
|
|
async getHouseInfoBy(id) { |
|
|
|
|
|
const res = await getHouseInfo(id); |
|
|
|
|
|
if (res.code == 200) { |
|
|
|
|
|
this.form = this.form.map((item) => ({ |
|
|
|
|
|
...item, |
|
|
|
|
|
waterMeterNumber: res.data.waterMeterNumber, |
|
|
|
|
|
})); |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
async getLastMeter() { |
|
|
async getLastMeter() { |
|
|
const params = { |
|
|
const params = { |
|
|
houseId: this.form.houseId, |
|
|
houseId: this.blockForm.houseId, |
|
|
roomId: this.form.roomId, |
|
|
roomId: this.blockForm.roomId, |
|
|
meterType: 1, // 1是水表,2是电表 |
|
|
meterType: 2, // 2水表 |
|
|
meterNumber: "", |
|
|
meterNumber: "", |
|
|
}; |
|
|
}; |
|
|
const res = await queryLastMeterReading(params); |
|
|
const res = await queryLastMeterReading(params); |
|
|
if (Array.isArray(res.data) && res.data.length > 0) { |
|
|
this.form = this.form.map((item) => { |
|
|
this.form.waterMeters = res.data.map((item, idx) => ({ |
|
|
const meter = res.data.find( |
|
|
lastMeterReading: item.thisMeterReading, |
|
|
(m) => String(m.roomId) === String(item.id) |
|
|
meterNumber: item.meterNumber, |
|
|
); |
|
|
thisMeterReading: "", |
|
|
if (meter) { |
|
|
fileList: [], |
|
|
return { |
|
|
})); |
|
|
...item, |
|
|
} else { |
|
|
lastMeterReading: meter.thisMeterReading, |
|
|
// res.data 为空时,显示一个空表单 |
|
|
waterMeterNumber: meter.meterNumber, |
|
|
this.form.waterMeters = [ |
|
|
}; |
|
|
{ |
|
|
} |
|
|
lastMeterReading: "", |
|
|
return item; |
|
|
meterNumber: "", |
|
|
}); |
|
|
thisMeterReading: "", |
|
|
|
|
|
fileList: [], |
|
|
|
|
|
}, |
|
|
}, |
|
|
]; |
|
|
async getRoomByHouseId(id) { |
|
|
|
|
|
const res = await getRoomByHouseId({ houseId: id }); |
|
|
|
|
|
if (res.code == 200) { |
|
|
|
|
|
if (this.waterMeterConfig == 1) { |
|
|
|
|
|
this.form = [{}]; |
|
|
|
|
|
} else if (this.waterMeterConfig == 2) { |
|
|
|
|
|
this.form = res.data; |
|
|
|
|
|
} |
|
|
|
|
|
this.getLastMeter(); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
onDelete(event, index) { |
|
|
onDelete(event, index) { |
|
|
if ( |
|
|
if (this.form[index] && Array.isArray(this.form[index].fileList)) { |
|
|
this.form.waterMeters[index] && |
|
|
this.form[index].fileList.splice(event.index, 1); |
|
|
Array.isArray(this.form.waterMeters[index].fileList) |
|
|
// this.form.waterMeters[index].imageList = this.form.waterMeters[ |
|
|
) { |
|
|
// index |
|
|
this.form.waterMeters[index].fileList.splice(event.index, 1); |
|
|
// ].fileList.map((v) => v.url); |
|
|
// 更新 imageList |
|
|
|
|
|
this.form.waterMeters[index].imageList = this.form.waterMeters[index].fileList.map((v) => v.url); |
|
|
|
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
onSubmit() { |
|
|
onSubmit() { |
|
|
let {buildingId, unitId, houseId} = this.form |
|
|
let { buildingId, unitId, houseId } = this.blockForm; |
|
|
if(!this.form.apartmentName){ |
|
|
if (!this.blockForm.apartmentName) { |
|
|
uni.showToast({ title: '请选择乐业社区', icon: 'none' }); |
|
|
uni.showToast({ title: "请选择乐业社区", icon: "none" }); |
|
|
return |
|
|
return; |
|
|
} else if (!buildingId && !unitId && !houseId) { |
|
|
} else if (!buildingId && !unitId && !houseId) { |
|
|
uni.showToast({ title: '请选择房屋', icon: 'none' }); |
|
|
uni.showToast({ title: "请选择房屋", icon: "none" }); |
|
|
return |
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
// 必填校验:水表号、上次表数、本次表数、图片/视频 |
|
|
|
|
|
for (let i = 0; i < this.form.length; i++) { |
|
|
|
|
|
const item = this.form[i]; |
|
|
|
|
|
if (this.waterMeterConfig == 2) { |
|
|
|
|
|
if (!item.electricMeterNumber) { |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: `第${i + 1}个房间请填写水表号`, |
|
|
|
|
|
icon: "none", |
|
|
|
|
|
}); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
// if (!item.lastMeterReading && item.lastMeterReading !== 0) { |
|
|
|
|
|
// uni.showToast({ |
|
|
|
|
|
// title: `第${i + 1}个房间请填写上次表数`, |
|
|
|
|
|
// icon: "none", |
|
|
|
|
|
// }); |
|
|
|
|
|
// return; |
|
|
|
|
|
// } |
|
|
|
|
|
if (!item.thisMeterReading && item.thisMeterReading !== 0) { |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: `第${i + 1}个房间请填写本次表数`, |
|
|
|
|
|
icon: "none", |
|
|
|
|
|
}); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
if (!item.fileList || item.fileList.length === 0) { |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: `第${i + 1}个房间请上传图片/视频`, |
|
|
|
|
|
icon: "none", |
|
|
|
|
|
}); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
// if (!item.electricMeterNumber) { |
|
|
|
|
|
// 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: `请填写本次表数`, |
|
|
|
|
|
icon: "none", |
|
|
|
|
|
}); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
if (!item.fileList || item.fileList.length === 0) { |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: `请上传图片/视频`, |
|
|
|
|
|
icon: "none", |
|
|
|
|
|
}); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
this.submitAdd(); |
|
|
this.submitAdd(); |
|
|
console.log('onSubmit',this.form); |
|
|
console.log("onSubmit", this.form); |
|
|
}, |
|
|
}, |
|
|
async submitAdd() { |
|
|
async submitAdd() { |
|
|
let params = []; |
|
|
let params = this.form.map((item) => ({ |
|
|
this.form.waterMeters.forEach((item) => { |
|
|
meterNumber: item.waterMeterNumber, |
|
|
params.push({ |
|
|
meterType: 2, |
|
|
meterNumber: item.meterNumber, |
|
|
houseId: this.blockForm.houseId, |
|
|
meterType: 1, // 1是水表,2是电表 |
|
|
roomId: item.id || "", |
|
|
houseId: this.form.houseId, |
|
|
lastMeterReading: parseFloat(item.lastMeterReading).toFixed(4), |
|
|
roomId: this.form.roomId, |
|
|
thisMeterReading: parseFloat(item.thisMeterReading).toFixed(4), |
|
|
lastMeterReading: item.lastMeterReading, |
|
|
images: (item.fileList || []).map((f) => ({ |
|
|
thisMeterReading: item.thisMeterReading, |
|
|
url: f.url, |
|
|
images: item.fileList, |
|
|
name: f.name, |
|
|
remark: this.form.remark, |
|
|
type: f.type, |
|
|
}); |
|
|
format: f.format || (f.url ? f.url.split(".").pop() : ""), |
|
|
}); |
|
|
})), |
|
|
console.log(params, "params"); |
|
|
remark: item.remark || "", |
|
|
|
|
|
})); |
|
|
const res = await submitWaterAndElectricity(params); |
|
|
const res = await submitWaterAndElectricity(params); |
|
|
if (res.code == 200) { |
|
|
if (res.code == 200) { |
|
|
uni.showToast({ |
|
|
uni.showToast({ |
|
@ -435,10 +589,9 @@ export default { |
|
|
icon: "none", |
|
|
icon: "none", |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
console.log(res, "reeees"); |
|
|
}, |
|
|
} |
|
|
}, |
|
|
} |
|
|
}; |
|
|
} |
|
|
|
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
<style scoped> |
|
|
<style scoped> |
|
|