修改物业端切换小区的逻辑

This commit is contained in:
赵毅 2025-10-17 09:50:01 +08:00
parent e4a21804b0
commit 295872ccf1

View File

@ -76,7 +76,6 @@ export default {
}
},
async onLoad() {
uni.removeStorageSync('changeWorkOrderData');
const workOrderPermission = uni.getStorageSync('work_order_permission');
const orderDispatchPermission = uni.getStorageSync('order_dispatch_permission');
this.showWorkOrderSection = !(workOrderPermission === false && orderDispatchPermission === false);
@ -90,8 +89,21 @@ export default {
});
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 });
this.communityVal = res.rows[0].name;
}