修改物业端切换小区的逻辑
This commit is contained in:
parent
e4a21804b0
commit
295872ccf1
@ -76,7 +76,6 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
async onLoad() {
|
async onLoad() {
|
||||||
uni.removeStorageSync('changeWorkOrderData');
|
|
||||||
const workOrderPermission = uni.getStorageSync('work_order_permission');
|
const workOrderPermission = uni.getStorageSync('work_order_permission');
|
||||||
const orderDispatchPermission = uni.getStorageSync('order_dispatch_permission');
|
const orderDispatchPermission = uni.getStorageSync('order_dispatch_permission');
|
||||||
this.showWorkOrderSection = !(workOrderPermission === false && orderDispatchPermission === false);
|
this.showWorkOrderSection = !(workOrderPermission === false && orderDispatchPermission === false);
|
||||||
@ -90,8 +89,21 @@ export default {
|
|||||||
});
|
});
|
||||||
this.communityList = res.rows;
|
this.communityList = res.rows;
|
||||||
|
|
||||||
|
const changeCommData = uni.getStorageSync('changeWorkOrderData');
|
||||||
|
// 检查本地存储的小区是否存在于返回的列表中
|
||||||
|
if (changeCommData) {
|
||||||
|
const exists = res.rows.some(item => item.community_id === changeCommData.id);
|
||||||
|
// 如果不存在,则清除数据并设置为第一个
|
||||||
|
if (!exists && res.rows.length > 0) {
|
||||||
|
uni.setStorageSync('changeWorkOrderData', { id: res.rows[0].community_id, name: res.rows[0].name });
|
||||||
|
this.communityVal = res.rows[0].name;
|
||||||
|
} else if (!exists) {
|
||||||
|
// 如果列表为空,则清除数据
|
||||||
|
uni.removeStorageSync('changeWorkOrderData');
|
||||||
|
this.communityVal = "切换小区";
|
||||||
|
}
|
||||||
|
} else if (res.rows.length > 0) {
|
||||||
// 如果没有选中的小区且有小区列表,则默认选中第一个
|
// 如果没有选中的小区且有小区列表,则默认选中第一个
|
||||||
if (!uni.getStorageSync('changeWorkOrderData') && res.rows.length > 0) {
|
|
||||||
uni.setStorageSync('changeWorkOrderData', { id: res.rows[0].community_id, name: res.rows[0].name });
|
uni.setStorageSync('changeWorkOrderData', { id: res.rows[0].community_id, name: res.rows[0].name });
|
||||||
this.communityVal = res.rows[0].name;
|
this.communityVal = res.rows[0].name;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user