فهرست منبع

fix(显示列):显示列组件添加列排序

wanglj 1 سال پیش
والد
کامیت
46b87899a4
1فایلهای تغییر یافته به همراه9 افزوده شده و 2 حذف شده
  1. 9 2
      src/components/table/TableTool.vue

+ 9 - 2
src/components/table/TableTool.vue

@@ -109,7 +109,7 @@
           const { data: id } = await tableColsConfigApi.save({
             id: this.id,
             table: this.tableType,
-            columns: JSON.stringify(newValue),
+            columns: JSON.stringify(list.map((item) => item.label)),
           })
           this.id = id
         }
@@ -128,7 +128,14 @@
         if (data) {
           this.id = data.id
           if (data.columns !== '' && data.columns !== '[]') {
-            list = this.columns.filter((item) => JSON.parse(data.columns).includes(item.label))
+            const arr = JSON.parse(data.columns)
+            for (const item of list) {
+              const idx = arr.findIndex((it) => item.label == it)
+              item.sort = idx > -1 ? idx : 0
+            }
+            list.sort((pre, cur) => {
+              return pre.sort - cur.sort
+            })
           }
         }
         this.checkColumns = list.map((item) => item.label)