|
|
|
@ -27,8 +27,19 @@ |
|
|
|
</view> |
|
|
|
<view class="picker-label"> |
|
|
|
<view class="uni-list-cell-db" v-if="multiArray[0].length"> |
|
|
|
<picker mode="multiSelector" @columnchange="bindMultiPickerColumnChange" :value="multiIndex" :range="multiArray"> |
|
|
|
<view class="uni-input">{{multiArray[0][multiIndex[0]] + multiArray[1][multiIndex[1]] + multiArray[2][multiIndex[2]]}}</view> |
|
|
|
<picker |
|
|
|
mode="multiSelector" |
|
|
|
@columnchange="bindMultiPickerColumnChange" |
|
|
|
:value="multiIndex" |
|
|
|
:range="multiArray" |
|
|
|
> |
|
|
|
<view class="uni-input">{{ |
|
|
|
multiIndex[0] === -1 |
|
|
|
? "请选择" |
|
|
|
: multiArray[0][multiIndex[0]] + |
|
|
|
multiArray[1][multiIndex[1]] + |
|
|
|
multiArray[2][multiIndex[2]] |
|
|
|
}}</view> |
|
|
|
</picker> |
|
|
|
</view> |
|
|
|
<view v-else @click="handleShowToast" style="color:#cbcbcb">请选择社区</view> |
|
|
|
@ -40,32 +51,54 @@ |
|
|
|
<view class="section-card" v-for="(item,index) in form.waterMeters" :key="item.id"> |
|
|
|
<view class="meter-row"> |
|
|
|
<text class="meter-label">水表号</text> |
|
|
|
<!-- <text>20072620</text> --> |
|
|
|
<u-input v-model="item.waterMeter" type="digit" placeholder="请输入水表号" border="none" /> |
|
|
|
<u-input |
|
|
|
v-model="item.meterNumber" |
|
|
|
type="digit" |
|
|
|
placeholder="请输入水表号" |
|
|
|
border="none" |
|
|
|
:disabled="!!item.meterNumber" |
|
|
|
:custom-style="item.meterNumber ? 'background:#fff;color:#bbb;' : ''" |
|
|
|
/> |
|
|
|
</view> |
|
|
|
<view class="meter-row"> |
|
|
|
<text class="meter-label">上次表数</text> |
|
|
|
<u-input v-model="item.waterMeter" type="digit" :placeholder="`3823.1`" border="none" /> |
|
|
|
<u-input |
|
|
|
v-model="item.lastMeterReading" |
|
|
|
type="digit" |
|
|
|
placeholder="请输入上次表数" |
|
|
|
border="none" |
|
|
|
:disabled="!!item.lastMeterReading" |
|
|
|
:custom-style="item.lastMeterReading ? 'background:#fff;color:#bbb;' : ''" |
|
|
|
/> |
|
|
|
</view> |
|
|
|
<view class="meter-row"> |
|
|
|
<text class="meter-label">本次表数</text> |
|
|
|
<u-input v-model="item.waterMeter" type="digit" placeholder="请输入本次表数" border="none" /> |
|
|
|
<u-input |
|
|
|
v-model="item.thisMeterReading" |
|
|
|
type="digit" |
|
|
|
placeholder="请输入本次表数" |
|
|
|
border="none" |
|
|
|
/> |
|
|
|
</view> |
|
|
|
<view class="imeter-row"> |
|
|
|
<text class="meter-label">上传图片</text> |
|
|
|
<text class="meter-label">上传图片/视频</text> |
|
|
|
<u-upload |
|
|
|
v-model="item.fileList" |
|
|
|
:max-count="10" |
|
|
|
:multiple="true" |
|
|
|
:preview-full-image="true" |
|
|
|
:deletable="true" |
|
|
|
:show-upload-list="true" |
|
|
|
:fileList="item.fileList" |
|
|
|
:fileList="item.fileList || []" |
|
|
|
:auto-upload="false" |
|
|
|
accept="all" |
|
|
|
@afterRead="afterRead($event,index)" |
|
|
|
@delete="onDelete($event,index)" |
|
|
|
:maxSize="10 * 1024 * 1024" |
|
|
|
@oversize="oversize" |
|
|
|
@delete="(e) => onDelete(e, index)" |
|
|
|
> |
|
|
|
<view class="custom-upload-btn"> |
|
|
|
<view |
|
|
|
class="custom-upload-btn" |
|
|
|
@click.stop="() => chooseMedia(index)" |
|
|
|
> |
|
|
|
<view class="icon-box"> |
|
|
|
<image class="camera-icon" src="/static/img/camera-icon.png" mode="aspectFill"></image> |
|
|
|
</view> |
|
|
|
@ -86,7 +119,11 @@ import { |
|
|
|
queryDeptDropdownList, |
|
|
|
} from "@/common/rec"; |
|
|
|
import { getdeptList } from '@/common/api'; |
|
|
|
import { uploadImage } from '@/pages/api'; |
|
|
|
import { |
|
|
|
uploadImage, |
|
|
|
queryLastMeterReading, |
|
|
|
submitWaterAndElectricity |
|
|
|
} from '@/pages/api'; |
|
|
|
|
|
|
|
export default { |
|
|
|
data() { |
|
|
|
@ -102,15 +139,17 @@ export default { |
|
|
|
buildingOptions: [], |
|
|
|
unitOptions: [], |
|
|
|
houseOptions: [], |
|
|
|
multiArray: [[],[],[]], |
|
|
|
multiIndex: [0, 0, 0], |
|
|
|
multiArray: [[], [], []], |
|
|
|
multiIndex: [-1, -1, -1], |
|
|
|
form:{ |
|
|
|
apartmentId: '', |
|
|
|
apartmentName:'', |
|
|
|
buildingId: '', |
|
|
|
unitId: '', |
|
|
|
houseId: '', |
|
|
|
waterMeters: [] |
|
|
|
roomId: '', |
|
|
|
waterMeters: [], |
|
|
|
remark: '' |
|
|
|
}, |
|
|
|
} |
|
|
|
}, |
|
|
|
@ -142,10 +181,16 @@ export default { |
|
|
|
"children", |
|
|
|
2 |
|
|
|
); |
|
|
|
const deptInfo = this.deptOptions[0].children.filter(item=>item.deptName == '城阳区')[0] |
|
|
|
this.deptOptions = await this.getListByParentId('1', deptInfo.deptId); |
|
|
|
const array = JSON.parse(JSON.stringify(this.deptOptions)) |
|
|
|
this.deptNames = array.map(item=>item.name) |
|
|
|
// const deptInfo = this.deptOptions[0].children.filter( |
|
|
|
// (item) => item.deptName == "城阳区" |
|
|
|
// )[0]; |
|
|
|
const newArr = this.deptOptions.map((item) => ({ |
|
|
|
name: item.deptName, |
|
|
|
})); |
|
|
|
// this.deptOptions = newArr |
|
|
|
// this.deptOptions = await this.getListByParentId("1", deptInfo.deptId); |
|
|
|
// const array = JSON.parse(JSON.stringify(this.deptOptions)); |
|
|
|
this.deptNames = newArr.map((item) => item.name); |
|
|
|
}); |
|
|
|
}, |
|
|
|
// 三级联动通用接口 |
|
|
|
@ -156,35 +201,54 @@ export default { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
async onPickerChange(e,type){ |
|
|
|
if(type == '乐业社区'){ |
|
|
|
const apartmentInfo = this.deptOptions[e.detail.value] |
|
|
|
this.form.apartmentName = apartmentInfo.name |
|
|
|
this.form.apartmentId = apartmentInfo.id |
|
|
|
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.form.apartmentName = apartmentInfo.deptName; |
|
|
|
this.form.apartmentId = apartmentInfo.deptId; |
|
|
|
// 楼 |
|
|
|
const buildingArray = await this.getListByParentId("2", apartmentInfo.id); |
|
|
|
this.buildingOptions = buildingArray |
|
|
|
const buildingNames = buildingArray.map(item=> item.name) |
|
|
|
this.form.buildingId = buildingArray[0].id |
|
|
|
const buildingArray = await this.getListByParentId( |
|
|
|
"2", |
|
|
|
apartmentInfo.deptId |
|
|
|
); |
|
|
|
this.buildingOptions = buildingArray; |
|
|
|
console.log("楼信息", buildingArray); |
|
|
|
const buildingNames = buildingArray.map((item) => item.name); |
|
|
|
console.log("buildingNames:", buildingNames); |
|
|
|
|
|
|
|
this.form.buildingId = buildingArray[0].id; |
|
|
|
// 单元 |
|
|
|
const unitArray = await this.getListByParentId("3", buildingArray[0].id); |
|
|
|
this.unitOptions = unitArray |
|
|
|
const unitNames = unitArray.map(item=> item.name) |
|
|
|
this.form.unitId = unitArray[0].id |
|
|
|
const unitArray = await this.getListByParentId( |
|
|
|
"3", |
|
|
|
buildingArray[0].id |
|
|
|
); |
|
|
|
this.unitOptions = unitArray; |
|
|
|
console.log("unitArray:", unitArray); |
|
|
|
|
|
|
|
const unitNames = unitArray.map((item) => item.name); |
|
|
|
this.form.unitId = unitArray[0].id; |
|
|
|
// 户 |
|
|
|
const houseArray = await this.getListByParentId("4", unitArray[0].id); |
|
|
|
this.houseOptions = houseArray |
|
|
|
const houseNames = houseArray.map(item=> item.name) |
|
|
|
this.form.houseId = houseArray[0].id |
|
|
|
let house = houseArray[0] |
|
|
|
for (let index = 0; index < house.type; index++) { |
|
|
|
this.form.waterMeters.push({ |
|
|
|
waterMeter: '', |
|
|
|
imageList: [], |
|
|
|
fileList: [] |
|
|
|
}) |
|
|
|
} |
|
|
|
this.multiArray = [buildingNames, unitNames, houseNames] |
|
|
|
this.houseOptions = houseArray; |
|
|
|
const houseNames = houseArray.map((item) => item.name); |
|
|
|
this.form.houseId = houseArray[0].id; |
|
|
|
this.form.roomId = houseArray[0].roomId; |
|
|
|
let house = houseArray[0]; |
|
|
|
// for (let index = 0; index < house.type; index++) { |
|
|
|
// this.form.waterMeters.push({ |
|
|
|
// meterNumber: "", |
|
|
|
// lastMeterReading: "", |
|
|
|
// thisMeterReading: "", |
|
|
|
// imageList: [], |
|
|
|
// fileList: [], |
|
|
|
// }); |
|
|
|
// } |
|
|
|
this.multiArray = [buildingNames, unitNames, houseNames]; |
|
|
|
} |
|
|
|
}, |
|
|
|
handleShowToast(){ |
|
|
|
@ -205,6 +269,7 @@ export default { |
|
|
|
this.houseOptions = houseArray |
|
|
|
const houseNames = houseArray.map(item=> item.name) |
|
|
|
this.form.houseId = houseArray[0].id |
|
|
|
this.form.roomId = houseArray[0].roomId |
|
|
|
|
|
|
|
this.multiArray[1] = unitNames |
|
|
|
this.multiArray[2] = houseNames |
|
|
|
@ -218,6 +283,7 @@ export default { |
|
|
|
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 |
|
|
|
} //拖动第2列 |
|
|
|
@ -225,45 +291,99 @@ export default { |
|
|
|
break |
|
|
|
case 2:{ |
|
|
|
this.form.houseId = this.houseOptions[e.detail.value].id |
|
|
|
this.form.roomId = this.houseOptions[e.detail.value].roomId |
|
|
|
console.log(this.houseOptions[e.detail.value]); |
|
|
|
} |
|
|
|
} |
|
|
|
this.getLastMeter() |
|
|
|
this.$forceUpdate() |
|
|
|
}, |
|
|
|
async afterRead(event,index) { |
|
|
|
let lists = [].concat(event.file); |
|
|
|
let fileListLen = this.form.waterMeters[index][`fileList${event.name}`].length; |
|
|
|
lists.map((item) => { |
|
|
|
this.form.waterMeters[index][`fileList${event.name}`].push({ |
|
|
|
...item, |
|
|
|
status: "uploading", |
|
|
|
message: "上传中", |
|
|
|
}); |
|
|
|
}); |
|
|
|
for (let i = 0; i < lists.length; i++) { |
|
|
|
const result = await uploadImage(lists[i].url); |
|
|
|
let item = this.form.waterMeters[index][`fileList${event.name}`][fileListLen]; |
|
|
|
|
|
|
|
this.form.waterMeters[index][`fileList${event.name}`].splice( |
|
|
|
fileListLen, |
|
|
|
1, |
|
|
|
Object.assign(item, { |
|
|
|
status: "success", |
|
|
|
message: "", |
|
|
|
url: result.url, |
|
|
|
}) |
|
|
|
); |
|
|
|
fileListLen++; |
|
|
|
//图片超过大小时取消上传 |
|
|
|
oversize(e) { |
|
|
|
this.$u.toast("请传10MB以内大小的图片/视频!"); |
|
|
|
return false; |
|
|
|
}, |
|
|
|
chooseMedia(index) { |
|
|
|
if (!this.form.waterMeters[index].fileList) { |
|
|
|
this.$set(this.form.waterMeters[index], "fileList", []); |
|
|
|
} |
|
|
|
var arry = []; |
|
|
|
this.form.waterMeters[index].fileList.filter((v, i) => { |
|
|
|
arry.push(v.url); |
|
|
|
uni.chooseMedia({ |
|
|
|
count: 10 - this.form.waterMeters[index].fileList.length, |
|
|
|
mediaType: ["image", "video"], |
|
|
|
sourceType: ["album", "camera"], |
|
|
|
maxDuration: 60, |
|
|
|
camera: "back", |
|
|
|
success: async (res) => { |
|
|
|
uni.showLoading({ title: "上传中...", mask: true }); |
|
|
|
try { |
|
|
|
const files = res.tempFiles; |
|
|
|
for (let i = 0; i < files.length; i++) { |
|
|
|
const file = files[i]; |
|
|
|
const filePath = file.tempFilePath; |
|
|
|
const type = |
|
|
|
file.fileType || |
|
|
|
(filePath.match(/\.(mp4|mov|avi|wmv|flv|mkv)$/i) |
|
|
|
? "video" |
|
|
|
: "image"); |
|
|
|
// 上传 |
|
|
|
const uploadRes = await uploadImage(filePath); |
|
|
|
this.form.waterMeters[index].fileList.push({ |
|
|
|
url: uploadRes.data?.url || uploadRes.url || uploadRes.path, |
|
|
|
name: uploadRes.data?.name || uploadRes.name || "", |
|
|
|
type: type, |
|
|
|
status: "success", |
|
|
|
}); |
|
|
|
} |
|
|
|
// 更新 imageList |
|
|
|
this.form.waterMeters[index].imageList = this.form.waterMeters[index].fileList.map((v) => v.url); |
|
|
|
} catch (e) { |
|
|
|
uni.showToast({ title: "上传失败", icon: "none" }); |
|
|
|
} finally { |
|
|
|
uni.hideLoading(); |
|
|
|
} |
|
|
|
}, |
|
|
|
fail: () => { |
|
|
|
uni.hideLoading(); |
|
|
|
}, |
|
|
|
}); |
|
|
|
this.form.waterMeters[index].imageList = arry |
|
|
|
}, |
|
|
|
onDelete(event,index) { |
|
|
|
this.form.waterMeters[index].fileList.splice(event.index, 1) |
|
|
|
this.form.waterMeters[index].imageList.splice(event.index, 1) |
|
|
|
// 获取上次抄表 |
|
|
|
async getLastMeter() { |
|
|
|
const params = { |
|
|
|
houseId: this.form.houseId, |
|
|
|
roomId: this.form.roomId, |
|
|
|
meterType: 1, // 1是水表,2是电表 |
|
|
|
meterNumber: "", |
|
|
|
}; |
|
|
|
const res = await queryLastMeterReading(params); |
|
|
|
if (Array.isArray(res.data) && res.data.length > 0) { |
|
|
|
this.form.waterMeters = res.data.map((item, idx) => ({ |
|
|
|
lastMeterReading: item.thisMeterReading, |
|
|
|
meterNumber: item.meterNumber, |
|
|
|
thisMeterReading: "", |
|
|
|
fileList: [], |
|
|
|
})); |
|
|
|
} else { |
|
|
|
// res.data 为空时,显示一个空表单 |
|
|
|
this.form.waterMeters = [ |
|
|
|
{ |
|
|
|
lastMeterReading: "", |
|
|
|
meterNumber: "", |
|
|
|
thisMeterReading: "", |
|
|
|
fileList: [], |
|
|
|
}, |
|
|
|
]; |
|
|
|
} |
|
|
|
}, |
|
|
|
onDelete(event, index) { |
|
|
|
if ( |
|
|
|
this.form.waterMeters[index] && |
|
|
|
Array.isArray(this.form.waterMeters[index].fileList) |
|
|
|
) { |
|
|
|
this.form.waterMeters[index].fileList.splice(event.index, 1); |
|
|
|
// 更新 imageList |
|
|
|
this.form.waterMeters[index].imageList = this.form.waterMeters[index].fileList.map((v) => v.url); |
|
|
|
} |
|
|
|
}, |
|
|
|
onSubmit() { |
|
|
|
let {buildingId, unitId, houseId} = this.form |
|
|
|
@ -274,7 +394,48 @@ export default { |
|
|
|
uni.showToast({ title: '请选择房屋', icon: 'none' }); |
|
|
|
return |
|
|
|
} |
|
|
|
this.submitAdd(); |
|
|
|
console.log('onSubmit',this.form); |
|
|
|
}, |
|
|
|
async submitAdd() { |
|
|
|
let params = []; |
|
|
|
this.form.waterMeters.forEach((item) => { |
|
|
|
params.push({ |
|
|
|
meterNumber: item.meterNumber, |
|
|
|
meterType: 1, // 1是水表,2是电表 |
|
|
|
houseId: this.form.houseId, |
|
|
|
roomId: this.form.roomId, |
|
|
|
lastMeterReading: item.lastMeterReading, |
|
|
|
thisMeterReading: item.thisMeterReading, |
|
|
|
images: item.fileList, |
|
|
|
remark: this.form.remark, |
|
|
|
}); |
|
|
|
}); |
|
|
|
console.log(params, "params"); |
|
|
|
|
|
|
|
const res = await submitWaterAndElectricity(params); |
|
|
|
if (res.code == 200) { |
|
|
|
uni.showToast({ |
|
|
|
icon: "success", |
|
|
|
title: "提交成功!", |
|
|
|
success: () => { |
|
|
|
setTimeout(() => { |
|
|
|
uni.switchTab({ |
|
|
|
url: "/pages/tabBar/work/index", |
|
|
|
success: () => { |
|
|
|
this.fileList = []; |
|
|
|
}, |
|
|
|
}); |
|
|
|
}, 1500); |
|
|
|
}, |
|
|
|
}); |
|
|
|
} else { |
|
|
|
uni.showToast({ |
|
|
|
title: res.msg || "提交失败", |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
} |
|
|
|
console.log(res, "reeees"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|