|
@@ -17,19 +17,19 @@
|
|
|
<uni-section title="地址信息" type="line">
|
|
|
<uni-forms ref="addrForm" :modelValue="formData" :label-width="90">
|
|
|
<uni-forms-item label="小区选择">
|
|
|
- <uni-data-picker v-model="formData.estateId" :map="pickerMap" :localdata="items" placeholder="请选择地址" popup-title="请选择地址" @change="onchange" @nodeclick="onnodeclick"></uni-data-picker>
|
|
|
+ <uni-data-picker v-model="formData.estateId" :map="pickerMap" :localdata="items" placeholder="请选择地址" popup-title="请选择地址" @change="onchange"></uni-data-picker>
|
|
|
</uni-forms-item>
|
|
|
<uni-forms-item label="楼栋选择">
|
|
|
- <uni-data-select :localdata="range" @change="selectChange" v-model="formData.buildingId"></uni-data-select>
|
|
|
+ <uni-data-picker v-model="formData.buildingId" :localdata="range" placeholder="请选择小区" popup-title="请选择小区" @change="selectChange"></uni-data-picker>
|
|
|
</uni-forms-item>
|
|
|
- <uni-forms-item label="单元选择" v-if="house.unit && house.unit !== null">
|
|
|
- <uni-data-select :localdata="house.unit" @change="unitChange" v-model="formData.unit"></uni-data-select>
|
|
|
+ <uni-forms-item label="单元选择" v-if="house.unit && house.unit.length > 0">
|
|
|
+ <uni-data-picker v-model="formData.unit" :localdata="house.unit" placeholder="请选择单元" popup-title="请选择单元" @change="unitChange"></uni-data-picker>
|
|
|
</uni-forms-item>
|
|
|
- <uni-forms-item label="楼层选择" v-if="house.floor && house.floor !== null">
|
|
|
- <uni-data-select :localdata="house.floor" @change="floorChange" v-model="formData.floor"></uni-data-select>
|
|
|
+ <uni-forms-item label="楼层选择" v-if="house.floor && house.unit.length > 0">
|
|
|
+ <uni-data-picker v-model="formData.floor" :localdata="house.floor" placeholder="请选择楼层" popup-title="请选择楼层" @change="floorChange"></uni-data-picker>
|
|
|
</uni-forms-item>
|
|
|
- <uni-forms-item label="门牌选择" v-if="house.number && house.number !== null">
|
|
|
- <uni-data-select :localdata="house.number" v-model="formData.houseId" @change="houseChange"></uni-data-select>
|
|
|
+ <uni-forms-item label="门牌选择" v-if="house.number && house.number !== ''">
|
|
|
+ <uni-data-picker v-model="formData.houseId" :localdata="house.number" placeholder="请选择门牌" popup-title="请选择门牌" @change="houseChange"></uni-data-picker>
|
|
|
</uni-forms-item>
|
|
|
</uni-forms>
|
|
|
</uni-section>
|
|
@@ -84,7 +84,16 @@
|
|
|
},
|
|
|
async onLoad(option) {
|
|
|
this.residentId = option.residentId;
|
|
|
- if (option.residentId) this.queryInfo();
|
|
|
+ if (option.residentId) {
|
|
|
+ this.queryInfo();
|
|
|
+ } else {
|
|
|
+ // 设置默认地址信息
|
|
|
+ const userinfo = uni.getStorageSync('userinfo');
|
|
|
+ const { estateId, buildingId, unit, floor, houseId } = userinfo;
|
|
|
+ this.formData = { estateId, buildingId, unit, floor, houseId };
|
|
|
+ this.setAddr(userinfo);
|
|
|
+ }
|
|
|
+
|
|
|
},
|
|
|
async mounted() {
|
|
|
const res = await request.addrTreeSelect();
|
|
@@ -93,30 +102,31 @@
|
|
|
methods: {
|
|
|
async queryInfo() {
|
|
|
const userinfo = await requestFamily.getFamilyInfoDetails({ residentId: this.residentId });
|
|
|
- console.log(userinfo.data);
|
|
|
this.formData = userinfo.data;
|
|
|
- const { estateId, buildingId, unit, floor, houseId } = userinfo.data;
|
|
|
+ this.setAddr(userinfo.data);
|
|
|
+ },
|
|
|
+ // 设置地址
|
|
|
+ async setAddr(data) {
|
|
|
// 小区存在
|
|
|
- if (estateId) {
|
|
|
- const res = await request.buildingList({ estateId });
|
|
|
+ if (data.estateId) {
|
|
|
+ const res = await request.buildingList({ estateId: data.estateId });
|
|
|
this.range = res.rows.map(e => ({ ...e, text: `${e.number}栋`, value: e.buildingId }));
|
|
|
}
|
|
|
// 楼栋存在
|
|
|
- if(buildingId) {
|
|
|
- await this.selectChange(buildingId);
|
|
|
+ if(data.buildingId) {
|
|
|
+ await this.selectChange(data.buildingId);
|
|
|
}
|
|
|
// 单元存在
|
|
|
- if(unit) {
|
|
|
- await this.unitChange(unit);
|
|
|
+ if(data.unit) {
|
|
|
+ await this.unitChange(data.unit);
|
|
|
}
|
|
|
// 楼层存在
|
|
|
- if(floor) {
|
|
|
- await this.floorChange(floor);
|
|
|
+ if(data.floor) {
|
|
|
+ await this.floorChange(data.floor);
|
|
|
}
|
|
|
// 门牌存在
|
|
|
- if(houseId) {
|
|
|
- console.log(houseId)
|
|
|
- await this.houseChange(houseId);
|
|
|
+ if(data.houseId) {
|
|
|
+ await this.houseChange(data.houseId);
|
|
|
}
|
|
|
},
|
|
|
async onchange(e) {
|
|
@@ -127,35 +137,31 @@
|
|
|
onnodeclick(node) {},
|
|
|
// 楼栋选择
|
|
|
async selectChange(e) {
|
|
|
- if (!e || e == '') return;
|
|
|
- const res = await request.houseList({ buildingId: e });
|
|
|
+ if (!e || e == '' || e.detail.value.length <= 0) return;
|
|
|
+ const res = await request.houseList({ buildingId: e.detail.value[0].value });
|
|
|
this.building = res.rows;
|
|
|
const list = [];
|
|
|
+ const numList = [];
|
|
|
const unit = res.rows.filter(j => j.unit !== null).map(j => ({ ...j, text: `${j.unit}单元`, value: j.unit }));
|
|
|
const number = res.rows.filter(j => j.number !== null).map(j => ({ ...j, text: `${j.number}号`, value: j.houseId }));
|
|
|
- if (unit && unit.length > 0) {
|
|
|
- unit.forEach(k => {
|
|
|
- const isunit = list.find(j => j.unit == k.unit);
|
|
|
- if (!isunit) list.push(k);
|
|
|
- });
|
|
|
- this.$set(this.house, 'unit', list);
|
|
|
- return;
|
|
|
- }
|
|
|
- if (number && number.length > 0) {
|
|
|
- number.forEach(k => {
|
|
|
- const isunit = list.find(j => j.number == k.number);
|
|
|
- if (!isunit) list.push(k);
|
|
|
- });
|
|
|
- this.$set(this.house, 'number', list);
|
|
|
- return;
|
|
|
- }
|
|
|
+ unit.forEach(k => {
|
|
|
+ const isunit = list.find(j => j.unit == k.unit);
|
|
|
+ if (!isunit) list.push(k);
|
|
|
+ });
|
|
|
+ this.$set(this.house, 'unit', list);
|
|
|
+ number.forEach(k => {
|
|
|
+ const isunit = numList.find(j => j.number == k.number);
|
|
|
+ if (!isunit) numList.push(k);
|
|
|
+ });
|
|
|
+ this.$set(this.house, 'number', numList);
|
|
|
|
|
|
},
|
|
|
// 单元选择
|
|
|
unitChange(e) {
|
|
|
- this.unit = e;
|
|
|
+ if (!e || e == '' || e.detail.value.length <= 0) return;
|
|
|
+ this.unit = e.detail.value[0].value;
|
|
|
const list = [];
|
|
|
- const floor = this.building.filter(j => j.unit == e).map(j => ({ ...j, text: `${j.floor}层`, value: j.floor }));
|
|
|
+ const floor = this.building.filter(j => j.unit == e.detail.value[0].value).map(j => ({ ...j, text: `${j.floor}层`, value: j.floor }));
|
|
|
floor.forEach(k => {
|
|
|
const isunit = list.find(j => j.floor == k.floor);
|
|
|
if (!isunit) list.push(k);
|
|
@@ -164,8 +170,9 @@
|
|
|
},
|
|
|
// 楼层选择
|
|
|
floorChange(e) {
|
|
|
+ if (!e || e == '' || e.detail.value.length <= 0) return;
|
|
|
const list = [];
|
|
|
- const number = this.building.filter(j => j.floor == e && j.unit == this.unit).map(j => ({ ...j, text: `${j.number}号`, value: j.houseId }));
|
|
|
+ const number = this.building.filter(j => j.floor == e.detail.value[0].value && j.unit == this.unit).map(j => ({ ...j, text: `${j.number}号`, value: j.houseId }));
|
|
|
number.forEach(k => {
|
|
|
const isunit = list.find(j => j.number == k.number);
|
|
|
if (!isunit) list.push(k);
|
|
@@ -174,8 +181,8 @@
|
|
|
},
|
|
|
// 门牌选择
|
|
|
houseChange(e) {
|
|
|
- if (!e || e == '') return;
|
|
|
- const dept = this.house.number.find(j => j.houseId == e);
|
|
|
+ if (!e || e == '' || e.detail.value.length <= 0) return;
|
|
|
+ const dept = this.house.number.find(j => j.houseId == e.detail.value[0].value);
|
|
|
this.formData.deptId = dept.deptId;
|
|
|
},
|
|
|
// 提交
|