瀏覽代碼

用地类型多全选需求实现

songxy 1 年之前
父節點
當前提交
976a82b319

+ 30 - 17
BJYSYBZ_C/src/views/KgView/components/FourContent.vue

@@ -117,6 +117,7 @@ export default {
       mj: 0,
       zs: 0,
       ydlx: [],
+      ydlx_n: [],
       ydlxDicts: ydlxDicts,
       query: {
         dkbh: '',
@@ -133,7 +134,6 @@ export default {
         },
         total: 0
       },
-      isAllSelected: false,
       isOther: false
     }
   },
@@ -153,8 +153,8 @@ export default {
       if (this.isOther) {
         p['dlbms'] = ydlxDicts.map((item) => item['value']);
       } else {
-        if (this.ydlx.length > 0) {
-          p['dlbms'] = this.isAllSelected ? [this.ydlx[0][0]] : this.ydlx.map(arr => arr[1])
+        if (this.ydlx_n.length > 0) {
+          p['dlbms'] = this.ydlx_n.map(item=> item)
         }
       }
       this.$ajax.post(urlApi, p, this, false).then((result) => {
@@ -181,8 +181,8 @@ export default {
       if (this.isOther) {
         p['dlbms'] = ydlxDicts.map((item) => item['value']);
       } else {
-        if (this.ydlx.length > 0) {
-          p['dlbms'] = this.isAllSelected ? [this.ydlx[0][0]] : this.ydlx.map(arr => arr[1])
+        if (this.ydlx_n.length > 0) {
+          p['dlbms'] = this.ydlx_n.map(item=> item)
         }
       }
       return new Promise((resolve, reject) => {
@@ -210,22 +210,35 @@ export default {
       this.$vm.$emit("getGdDetailData", item);
       this.$vm.$emit("location-feature-where", { layerId: 'bj-kg', where: `dkbh = '${item.dkbh}'`, setting: {outFields: 'dkbh,ssqx,ssjd,mj'} })
     },
+    computedYdlx () {
+      const list = this.ydlx
+      const map = {};
+      list.forEach((item) => {
+        if (map[item[0]]) {
+          map[item[0]].push(item[1])
+        } else {
+          map[item[0]] = [item[1]];
+        }
+      });
+      return map;
+    },
     async searchData () {
+      this.ydlx_n = [];
       this.isOther = false;
-      this.isAllSelected = false;
       if (this.ydlx.length > 0) {
-        const otherBms = this.ydlx.filter(arr => arr[0] === 'Q');
-        if (otherBms.length === 0) {
-          const pBm = this.ydlx[0][0]
-          const selected = ydlxDicts.filter(item => item.value === pBm);
-          if (selected && selected.length > 0) {
-            if (selected[0]['children'].length === this.ydlx.length) {
-              this.isAllSelected = true;
-            }
-          }
-        } else {
-          this.isAllSelected = true;
+        const ydlxMap = this.computedYdlx();
+        if (ydlxMap['Q']) {
           this.isOther = true;
+        } else {
+          ydlxDicts.forEach((item) => {
+            if (ydlxMap[item['value']]) {
+              if (ydlxMap[item['value']].length === item.children.length) {
+                this.ydlx_n.push(item['value'])
+              } else {
+                this.ydlx_n.push(...ydlxMap[item['value']])
+              }
+            }
+          })
         }
       }
       this.queryStatisticsAndListPage();

+ 34 - 21
BJYSYBZ_C/src/views/WlydtbView/components/FourContent.vue

@@ -232,6 +232,7 @@ export default {
       lx: [],
       lxArr: [],
       ydlx: [],
+      ydlx_n: [],
       ydlxDicts: ydlxDicts,
       query: {
         xzqmc: '',
@@ -272,7 +273,6 @@ export default {
         total: 100
       },
       nf: '2021',
-      isAllSelected: false,
       isOther: false
     }
   },
@@ -282,22 +282,35 @@ export default {
     this.getTsxzListData();
   },
   methods: {
+    computedYdlx () {
+      const list = this.ydlx
+      const map = {};
+      list.forEach((item) => {
+        if (map[item[0]]) {
+          map[item[0]].push(item[1])
+        } else {
+          map[item[0]] = [item[1]];
+        }
+      });
+      return map;
+    },
     async queryData() {
+      this.ydlx_n = [];
       this.isOther = false;
-      this.isAllSelected = false;
       if (this.ydlx.length > 0) {
-        const otherBms = this.ydlx.filter(arr => arr[0] === 'Q');
-        if (otherBms.length === 0) {
-          const pBm = this.ydlx[0][0]
-          const selected = ydlxDicts.filter(item => item.value === pBm);
-          if (selected && selected.length > 0) {
-            if (selected[0]['children'].length === this.ydlx.length) {
-              this.isAllSelected = true;
-            }
-          }
-        } else {
-          this.isAllSelected = true;
+        const ydlxMap = this.computedYdlx();
+        if (ydlxMap['Q']) {
           this.isOther = true;
+        } else {
+          ydlxDicts.forEach((item) => {
+            if (ydlxMap[item['value']]) {
+              if (ydlxMap[item['value']].length === item.children.length) {
+                this.ydlx_n.push(item['value'])
+              } else {
+                this.ydlx_n.push(...ydlxMap[item['value']])
+              }
+            }
+          })
         }
       }
       this.initHZ()
@@ -369,8 +382,8 @@ export default {
       if (this.isOther) {
         p['dlbms'] = ydlxDicts.map((item) => item['value']);
       } else {
-        if (this.ydlx.length > 0) {
-          p['dlbms'] = this.isAllSelected ? [this.ydlx[0][0]] : this.ydlx.map(arr => arr[1])
+        if (this.ydlx_n.length > 0) {
+          p['dlbms'] = this.ydlx_n.map(item=> item)
         }
       }
       return new Promise((resolve, reject) => {
@@ -392,8 +405,8 @@ export default {
       if (this.isOther) {
         p['dlbms'] = ydlxDicts.map((item) => item['value']);
       } else {
-        if (this.ydlx.length > 0) {
-          p['dlbms'] = this.isAllSelected ? [this.ydlx[0][0]] : this.ydlx.map(arr => arr[1])
+        if (this.ydlx_n.length > 0) {
+          p['dlbms'] = this.ydlx_n.map(item=> item)
         }
       }
       const urlApi = `/api/ybz-bj/wlydTJ`;
@@ -423,8 +436,8 @@ export default {
       if (this.isOther) {
         p['dlbms'] = ydlxDicts.map((item) => item['value']);
       } else {
-        if (this.ydlx.length > 0) {
-          p['dlbms'] = this.isAllSelected ? [this.ydlx[0][0]] : this.ydlx.map(arr => arr[1])
+        if (this.ydlx_n.length > 0) {
+          p['dlbms'] = this.ydlx_n.map(item=> item)
         }
       }
       this.$ajax.get(urlApi, p, this, false).then((result) => {
@@ -459,8 +472,8 @@ export default {
       if (this.isOther) {
         sendData['dlbms'] = ydlxDicts.map((item) => item['value']);
       } else {
-        if (this.ydlx.length > 0) {
-          sendData['dlbms'] = this.isAllSelected ? [this.ydlx[0][0]] : this.ydlx.map(arr => arr[1])
+        if (this.ydlx_n.length > 0) {
+          sendData['dlbms'] = this.ydlx_n.map(item=> item)
         }
       }
       this.$axios({

+ 33 - 20
BJYSYBZ_C/src/views/WlydxqView/components/FourContent.vue

@@ -264,9 +264,9 @@ export default {
       },
       nf: '2021',
       ydlx: [],
+      ydlx_n: [],
       crjhs: [ '2023年', '2024年', '2025年','2026年','远期' ],
       foldShow: false,
-      isAllSelected: false,
       isOther: false
     }
   },
@@ -290,8 +290,8 @@ export default {
       if (this.isOther) {
         p['dlbms'] = ydlxDicts.map((item) => item['value']);
       } else {
-        if (this.ydlx.length > 0) {
-          p['dlbms'] = this.isAllSelected ? [this.ydlx[0][0]] : this.ydlx.map(arr => arr[1])
+        if (this.ydlx_n.length > 0) {
+          p['dlbms'] = this.ydlx_n.map(item=> item)
         }
       }
       return new Promise((resolve, reject) => {
@@ -315,8 +315,8 @@ export default {
       if (this.isOther) {
         p['dlbms'] = ydlxDicts.map((item) => item['value']);
       } else {
-        if (this.ydlx.length > 0) {
-          p['dlbms'] = this.isAllSelected ? [this.ydlx[0][0]] : this.ydlx.map(arr => arr[1])
+        if (this.ydlx_n.length > 0) {
+          p['dlbms'] = this.ydlx_n.map(item=> item)
         }
       }
       this.$ajax.get(urlApi, p, this, false).then((result) => {
@@ -348,22 +348,35 @@ export default {
       });
       window.open(routeUrl.href, '_blank');
     },
-    async searchData() {
+    computedYdlx () {
+      const list = this.ydlx
+      const map = {};
+      list.forEach((item) => {
+        if (map[item[0]]) {
+          map[item[0]].push(item[1])
+        } else {
+          map[item[0]] = [item[1]];
+        }
+      });
+      return map;
+    },
+    async searchData () {
+      this.ydlx_n = [];
       this.isOther = false;
-      this.isAllSelected = false;
       if (this.ydlx.length > 0) {
-        const otherBms = this.ydlx.filter(arr => arr[0] === 'Q');
-        if (otherBms.length === 0) {
-          const pBm = this.ydlx[0][0]
-          const selected = ydlxDicts.filter(item => item.value === pBm);
-          if (selected && selected.length > 0) {
-            if (selected[0]['children'].length === this.ydlx.length) {
-              this.isAllSelected = true;
-            }
-          }
-        } else {
-          this.isAllSelected = true;
+        const ydlxMap = this.computedYdlx();
+        if (ydlxMap['Q']) {
           this.isOther = true;
+        } else {
+          ydlxDicts.forEach((item) => {
+            if (ydlxMap[item['value']]) {
+              if (ydlxMap[item['value']].length === item.children.length) {
+                this.ydlx_n.push(item['value'])
+              } else {
+                this.ydlx_n.push(...ydlxMap[item['value']])
+              }
+            }
+          })
         }
       }
       this.initHZ()
@@ -428,8 +441,8 @@ export default {
       if (this.isOther) {
         p['dlbms'] = ydlxDicts.map((item) => item['value']);
       } else {
-        if (this.ydlx.length > 0) {
-          p['dlbms'] = this.isAllSelected ? [this.ydlx[0][0]] : this.ydlx.map(arr => arr[1])
+        if (this.ydlx_n.length > 0) {
+          p['dlbms'] = this.ydlx_n.map(item=> item)
         }
       }
       const urlApi = `/api/ybz-bj/wlydTJ`;