.
This commit is contained in:
parent
4b918264ab
commit
417583afca
28
App.vue
28
App.vue
@ -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();
|
||||
|
@ -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)
|
||||
}
|
||||
},
|
||||
// 选中地块数据
|
||||
|
@ -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) {
|
||||
|
@ -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} ,未授权则弹出权限询问弹窗以及权限说明窗口
|
||||
|
@ -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)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user