Browse Source

fix 设备筛选bug

wangqin
qingzhengli 8 months ago
parent
commit
4f39738a32
  1. 18
      ruoyi-ui/src/views/JiHeExpressway/pages/Home/components/HomeFilter/index.vue
  2. 27
      ruoyi-ui/src/views/JiHeExpressway/pages/Home/components/RoadAndEvents/index.vue

18
ruoyi-ui/src/views/JiHeExpressway/pages/Home/components/HomeFilter/index.vue

@ -13,7 +13,7 @@
<div class="body"> <div class="body">
<div class="title">设备筛选</div> <div class="title">设备筛选</div>
<Form labelWidth="90px" column="1" class="form" ref="FormConfigRef" :formList="formList" /> <Form v-model="data" labelWidth="90px" column="1" class="form" ref="FormConfigRef" :formList="formList" />
<div class="footer"> <div class="footer">
<Button style="background-color: rgba(0, 179, 204, 0.3)" @click.native="handleResetForm"> <Button style="background-color: rgba(0, 179, 204, 0.3)" @click.native="handleResetForm">
重置 重置
@ -82,12 +82,14 @@ export default {
return true; return true;
}, },
}, },
] ],
data: {}
} }
}, },
watch: { watch: {
activeDeviceTypes: { activeDeviceTypes: {
handler(val) { handler(val) {
console.log(val, this.activeDeviceTypes, 'xxx')
const options = [] const options = []
for (let id of DeviceTypeIds) { for (let id of DeviceTypeIds) {
if (this.activeDeviceTypes.indexOf(`路测设备_${id}`) >= 0) { if (this.activeDeviceTypes.indexOf(`路测设备_${id}`) >= 0) {
@ -96,6 +98,15 @@ export default {
} }
// if (this.activeDeviceTypes.indexOf("_2") >= 0) options.push(...Object.keys(BoardChildTypes).map(key => { return { label: BoardChildTypes[key], value: key } })); // if (this.activeDeviceTypes.indexOf("_2") >= 0) options.push(...Object.keys(BoardChildTypes).map(key => { return { label: BoardChildTypes[key], value: key } }));
} }
const isChildTypeClear = !options.length;
if (isChildTypeClear)
this.$set(this.data, 'childType', undefined);
const isDeviceStateClear = !find(this.activeDeviceTypes, (type => type.match("路测设备_")));
if (isDeviceStateClear)
this.$set(this.data, 'deviceState', undefined);
if (isChildTypeClear || isDeviceStateClear) {
this.setFilterDataNoAction(this.data);
}
this.formList[2].options.options = options; this.formList[2].options.options = options;
}, },
immediate: true, immediate: true,
@ -111,6 +122,9 @@ export default {
filterEnd(data) { filterEnd(data) {
this.$parent.$refs.RoadAndEventsRef?.setFilterData?.(data); this.$parent.$refs.RoadAndEventsRef?.setFilterData?.(data);
}, },
setFilterDataNoAction(data) {
this.$parent.$refs.RoadAndEventsRef?.setFilterDataNoAction?.(data);
},
async handleResetForm() { async handleResetForm() {
this.$refs.FormConfigRef?.reset(); this.$refs.FormConfigRef?.reset();
this.activeIcon = "filter"; this.activeIcon = "filter";

27
ruoyi-ui/src/views/JiHeExpressway/pages/Home/components/RoadAndEvents/index.vue

@ -177,7 +177,10 @@ export default {
getMinMapLayers(); getMinMapLayers();
}, },
methods: { methods: {
async setFilterData(data) { setFilterDataNoAction(data) { //data
this.filterData = data;
},
async setFilterData(data) {//
this.filterData = data; this.filterData = data;
const tabContentData = []; const tabContentData = [];
this.layerData.forEach((layerDataItem => { this.layerData.forEach((layerDataItem => {
@ -193,20 +196,24 @@ export default {
const status = item.status; const status = item.status;
// if (!eventMap[`${key}${status ? "_close" : ""}`]) return this.$emit("onClickItem", item); // if (!eventMap[`${key}${status ? "_close" : ""}`]) return this.$emit("onClickItem", item);
// console.log(`${key}${status ? "" : "_close"}`, this.filterData, 'xxx'); // console.log(`${key}${status ? "" : "_close"}`, this.filterData, 'xxx');
await eventMap[`${key}${status ? "" : "_close"}`]?.call(this, item, this.filterData, isDefault); await eventMap[`${key}${status ? "" : "_close"}`]?.call(this, item, this.filterData, isDefault, this.cb);
} }
await Promise.allSettled(tabContentData.map(item => eventMapCall(item, true))) await Promise.allSettled(tabContentData.map(item => eventMapCall(item, true)))
Object.keys(lngLatMap).forEach(key => { Object.keys(lngLatMap).forEach(key => {
addInGraphHandle(lngLatMap[key]); addInGraphHandle(lngLatMap[key]);
}); });
}, },
handleClick(item) { handleClick(item) {
this.active = item.title; this.active = item.title;
this.tabContentData = item.children; this.tabContentData = item.children;
}, },
cb(item, config) {
const deviceType = config.deviceType;
const activeDeviceTypes = this.activeDeviceTypes;
const findIndex = activeDeviceTypes.indexOf(deviceType);
if (item.status) findIndex === -1 && activeDeviceTypes.push(deviceType);
else findIndex !== -1 && activeDeviceTypes.splice(findIndex, 1);
},
async handleDeviceImmediate(item, isDefault) { async handleDeviceImmediate(item, isDefault) {
const key = getHandleDeviceType(item) || `${this.active}/${item.title}`; const key = getHandleDeviceType(item) || `${this.active}/${item.title}`;
@ -218,14 +225,8 @@ export default {
if (!eventMap[`${key}${status ? "_close" : ""}`]) return this.$emit("onClickItem", item); if (!eventMap[`${key}${status ? "_close" : ""}`]) return this.$emit("onClickItem", item);
console.log(`${key}${status ? "_close" : ""}`, this.filterData, isDefault) console.log(`${key}${status ? "_close" : ""}`, this.filterData, isDefault)
const cb = (item, config) => {
const deviceType = config.deviceType; await eventMap[`${key}${status ? "_close" : ""}`]?.call(this, item, this.filterData, isDefault, this.cb);
const activeDeviceTypes = this.activeDeviceTypes;
const findIndex = activeDeviceTypes.indexOf(deviceType);
if (item.status) findIndex === -1 && activeDeviceTypes.push(deviceType);
else findIndex !== -1 && activeDeviceTypes.splice(findIndex, 1);
}
await eventMap[`${key}${status ? "_close" : ""}`]?.call(this, item, this.filterData, isDefault, cb);
}, },
handleDevice: debounce(function (item) { handleDevice: debounce(function (item) {
this.handleDeviceImmediate(item); this.handleDeviceImmediate(item);

Loading…
Cancel
Save