zhaoke 2 年之前
父節點
當前提交
a5d83dda84
共有 1 個文件被更改,包括 25 次插入75 次删除
  1. 25 75
      src/views/newTable/index.vue

+ 25 - 75
src/views/newTable/index.vue

@@ -325,6 +325,7 @@ export default {
               this.rowTitle = titleColumn.columnName;
             }
             this.tableCols = returnData;
+            this.setTableCols();
             this.getQuery(id);
           }
         } else {
@@ -514,88 +515,37 @@ export default {
       const datas = _.cloneDeep(this.tableColsCopy);
       // const reqUts = [];
       datas.forEach(async (item) => {
-        this.tableDataFilters[item.columnName] = [];
         if (item.needGroup) {
           this.tableGroups.push(item.columnName);
         }
-        if (item.listqueryTemplateID || item.listqueryTemplateID == 0) {
-          this.tableArrs.push(item.columnName);
-          // const reqUt = this.getSelectData(item.listqueryTemplateID)
-          // reqUts.push(reqUt)
-          // if (!this.tableOptions[item.columnName]) {
-          //   if (
-          //     item.columnName !== "beginPosition" &&
-          //     item.columnName !== "endPosition"
-          //   ) {
-          //     this.tableOptions[item.columnName] = await this.getSelectData(
-          //       item.listqueryTemplateID
-          //     );
-          //   } else {
-          //     this.tableOptions[item.columnName] = await this.getSelectData(
-          //       item.listqueryTemplateID,
-          //       null
-          //     );
-          //     this.tabledatacopy[item.columnName] = _.cloneDeep(
-          //       this.tableOptions[item.columnName]
-          //     );
-          //   }
-          // } else {
-          //   if (
-          //     item.columnName === "beginPosition" ||
-          //     item.columnName === "endPosition"
-          //   ) {
-          //     this.tableOptions[item.columnName] = await this.getSelectData(
-          //       item.listqueryTemplateID,
-          //       null
-          //     );
-          //   }
-          // }
-          //
-        }
-        // this.filterValues[item.columnName] = ''
       });
-      setTableFilters(this.tableData, this.tableDataFilters);
-      this.tableGroup(this.tableData);
-      this.setTableCols();
+      const dats = this.setTableFilters(this.tableData, this.tableDataFilters)
+      this.tableDataFilters = _.cloneDeep(dats)
       // this.selectTableRows(this.tableData, "DeployID");
-      this.tableOptionscp = _.cloneDeep(this.tableOptions);
-      const arrbegin = _.cloneDeep(this.tableOptions);
-      if (arrbegin) {
-        setTimeout(() => {
-          this.tableData.forEach((element) => {
-            if (this.tableOptions.beginNode) {
-              arrbegin.beginNode.forEach((res) => {
-                if (res.v === element.beginNode) {
-                  element.beginNode = res.k;
-                }
-              });
-              arrbegin.endNode.forEach((res) => {
-                if (res.v == element.endNode) {
-                  element.endNode = res.k;
-                }
-              });
-              arrbegin.calculationBasis.forEach((res) => {
-                if (res.v == element.calculationBasis) {
-                  element.calculationBasis = res.k;
-                }
-              });
-              //位置
-              this.tabledatacopy.beginPosition.forEach((res) => {
-                if (res.v == element.beginPosition) {
-                  element.beginPosition = res.k;
-                }
-              });
-              this.tabledatacopy.endPosition.forEach((res) => {
-                if (res.v == element.endPosition) {
-                  element.endPosition = res.k;
-                }
-              });
-            }
-          });
-        }, 100);
-      }
+      this.tableGroup(this.tableData)
       // this.getSelectDataAll(reqUts)
     },
+    setTableFilters (tableData, filters) {
+      const tempSets = {}
+      Object.keys(filters).forEach(key => {
+        tempSets[key] = new Set()
+      })
+      tableData.forEach(item => {
+        Object.keys(tempSets).forEach(key => {
+          ; (item[key] ?? '') !== '' && tempSets[key].add(String(item[key]))
+        })
+      })
+      Object.keys(tempSets).forEach(key => {
+        filters[key] = _.orderBy(
+          [...tempSets[key]].map(value => ({
+            text: value,
+            value,
+          })),
+          o => o.value
+        )
+      })
+      return filters
+    },
     //获取所有获取弹框-下拉数据-请求状态
     getSelectDataAll (reqUts) {
       Promise.all(reqUts)