This commit is contained in:
Iruka 2025-01-17 11:31:15 +08:00
parent 4b918264ab
commit 417583afca
5 changed files with 89 additions and 43 deletions

28
App.vue
View File

@ -35,6 +35,12 @@
onShow: function() {
console.log('App Show')
const that = this;
//
uni.$off("notify-add-land");
uni.$on("notify-add-land", (data) => {
that.getLand(data);
});
//
uni.$off("notify-update-land");
uni.$on("notify-update-land", (data) => {
// console.error("index", data)
@ -88,17 +94,35 @@
}
}
},
getLand(e) {
this.ijs.getLand(e.node).then(data => {
// this.$refs.landRef.addLand(e, data);
this.sendMsgEvent("land", {
type: "add",
data: {
item: e,
lands: data
}
});
});
},
getWoList(land, wo) {
const that = this;
if (land && wo) {
that.dc.setData(land, wo);
that.mqttSubscribes();
that.sendMsgEvent("land", wo);
that.sendMsgEvent("land", {
type: "wo",
data: wo
});
}
that.ijs.getWoList(land).then(res => {
that.dc.setData(land, res.data);
that.mqttSubscribes();
that.sendMsgEvent("land", res.data);
that.sendMsgEvent("land", {
type: "wo",
data: res.data
});
uni.hideLoading();
}).catch(() => {
uni.hideLoading();

View File

@ -213,6 +213,7 @@
}
//
this.$emit('getLand', item);
uni.$emit('notify-add-land', item);
},
/**
* 添加地块
@ -241,8 +242,12 @@
});
}
if (index !== -1) {
const keys = that.datamap[item.key].keys;
let addLand = [];
lands.forEach(land => {
if (keys.includes(`l${land.id}`)) {
return;
}
land = {
id: land.id,
label: land.landName,
@ -260,8 +265,13 @@
newItem.show = that.datamap[item.key].show;
that.datamap[land.key] = newItem;
});
that.datalist.splice(index + 1, 0, ...addLand);
item.keys = that.datamap[item.key].keys;
if (addLand.length) {
that.datalist.splice(index + 1, 0, ...addLand);
item.keys = that.datamap[item.key].keys;
}
that.datamap[item.key].show = true;
that.datamap[item.key].expand = true;
that.checkExpandedChange(that.datamap[item.key], true)
}
},
//

View File

@ -449,7 +449,7 @@
</u-popup>
<!-- 地块选择 -->
<custom-select-land ref="landRef" :data="ijs.companys" :defaultSelect="ijs.land" @getLand="getLand" @select="" />
<custom-select-land ref="landRef" :data="ijs.companys" :defaultSelect="ijs.land" @getLand="" @select="" />
<!-- 角度 -->
<custom-angle-slider ref="refAngleSlider" mode="bottom" @close="openPopup" @confirm="swiperConfirm" />
<!-- ADC -->
@ -509,8 +509,12 @@
}
});
getApp().on("land", "land_map", function(e) {
that.title = that.ijs?.land?.landName || null;
that.mapOnload();
if (e.type == "wo") {
that.title = that.ijs?.land?.landName || null;
that.mapOnload();
} else if (e.type == "add") {
that.$refs.landRef.addLand(e.data.item, e.data.lands);
} else {}
});
},
onShow() {
@ -536,12 +540,6 @@
};
},
methods: {
//
getLand(e) {
this.ijs.getLand(e.node).then(res => {
this.$refs.landRef.addLand(e, res.data);
});
},
//
mapOnload(e) {
if (!this.ijs.wo) {

View File

@ -141,7 +141,6 @@
</u-col>
<u-col span="5">
<view class="fixed">
<u-button type="success" size="mini" text="手持基站" />
<u-button type="success" size="mini" text="刷新" icon="reload"
:loading="dc.dataObj[item.deviceCode]?.refresh"
@click="dc.refreshDeviceItem(item.deviceCode, item)" />
@ -539,7 +538,7 @@
</view>
<!-- 地块选择 -->
<custom-select-land ref="landRef" :data="ijs.companys" :defaultSelect="ijs.land" @getLand="getLand" @select="" />
<custom-select-land ref="landRef" :data="ijs.companys" :defaultSelect="ijs.land" @getLand="" @select="" />
<!-- 角度 -->
<custom-angle-slider ref="refAngleSlider" mode="bottom" @close="" @confirm="swiperConfirm" />
<!-- ADC -->
@ -589,13 +588,17 @@
} else if (e.type == "msg") {}
});
getApp().on("land", "land_index", function(e) {
that.title = that.ijs?.land?.landName || null;
that.$nextTick(() => {
setTimeout(() => {
that.$refs.collapseStationRef.resize();
that.$refs.collapseRef.resize();
}, 500)
})
if (e.type == "wo") {
that.title = that.ijs?.land?.landName || null;
that.$nextTick(() => {
setTimeout(() => {
that.$refs.collapseStationRef.resize();
that.$refs.collapseRef.resize();
}, 500)
})
} else if (e.type == "add") {
that.$refs.landRef.addLand(e.data.item, e.data.lands);
} else {}
});
},
onShow() {
@ -628,12 +631,6 @@
mqttSubscribes() {
getApp().mqttSubscribes();
},
//
getLand(e) {
this.ijs.getLand(e.node).then(res => {
this.$refs.landRef.addLand(e, res.rows);
});
},
//
async toQRCode() {
// // { isSuc : true} ,

View File

@ -22,6 +22,7 @@ import {
const cacheKey = "cacheData";
class indexUtil {
static companys = null; //公司选择的列表
static companyLands = {}; //地块的数据列表
static land = null; //选中的数据
static wo = null; //地块的数据列表
static cacheData = {
@ -34,6 +35,16 @@ class indexUtil {
//接收创建来的数据
constructor(eventHandler) {
this.eventHandler = eventHandler;
this.companys = null; //公司选择的列表
this.companyLands = {}; //地块的数据列表
this.land = null; //选中的数据
this.wo = null; //地块的数据列表
this.cacheData = {
userId: null,
companys: null,
land: null,
wo: null,
}
}
/**
@ -92,23 +103,29 @@ class indexUtil {
// 获取地块信息
getLand(company) {
const that = this;
const keyName = company.companyId;
return new Promise((resolve, reject) => {
const query = {
companyGroupId: company.companyId,
companyId: company.rootCompanyId,
status: 0,
delFlag: 0,
}
getLandAndDevice(query).then(res => {
if (res.rows && res.rows.length) {
let companys = that.cacheData.companys || [];
that.findObjectById(companys, company.companyId, res.rows);
that.setStorage(constant.companys, companys);
if (that.companyLands.hasOwnProperty(keyName)) {
resolve(that.companyLands[keyName])
} else {
const query = {
companyGroupId: company.companyId,
companyId: company.rootCompanyId,
status: 0,
delFlag: 0,
}
resolve(res)
}).catch(error => {
reject(error)
})
getLandAndDevice(query).then(res => {
if (res.rows && res.rows.length) {
let companys = that.cacheData.companys || [];
that.findObjectById(companys, company.companyId, res.rows);
that.setStorage(constant.companys, companys);
that.companyLands[keyName] = res.rows;
}
resolve(res.rows || [])
}).catch(error => {
reject(error)
})
}
})
}