From 0cbca7090b7b18d86c3f363f5670e6899330c4b9 Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期一, 25 十一月 2024 19:12:56 +0800
Subject: [PATCH] 路由参数

---
 src/views/projectEngineering/projectLibrary/index.vue |   76 ++++++++++++++++++++++++++++++++------
 1 files changed, 64 insertions(+), 12 deletions(-)

diff --git a/src/views/projectEngineering/projectLibrary/index.vue b/src/views/projectEngineering/projectLibrary/index.vue
index 96a5ae0..bdbfa4c 100644
--- a/src/views/projectEngineering/projectLibrary/index.vue
+++ b/src/views/projectEngineering/projectLibrary/index.vue
@@ -166,40 +166,42 @@
               <svg-icon icon-class="exportIcon" style="margin-right: 8px"/>
               瀵煎嚭鏁版嵁
             </el-button>
-            <el-button :disabled="isReserve" @click="handleImport" size="small">
+            <el-button :disabled="!isReserve" @click="handleImport" size="small">
               <svg-icon icon-class="importIcon" style="margin-right: 8px"/>
               瀵煎叆鏁版嵁
             </el-button>
           </div>
           <div class="add-btn">
             <el-tooltip content="鏂板" effect="dark" placement="top">
-              <el-button :disabled="isReserve" circle icon="el-icon-plus" @click="add()" size="small"/>
+              <el-button :disabled="!isReserve" circle icon="el-icon-plus" @click="add()" size="small"/>
             </el-tooltip>
           </div>
           <VisibilityToolbar
             v-model:showSearch="showSearch"
-            :columns="columns"
+            :columns="defaultColumns"
             @queryTable="handleQuery"
+            @update:sort="handleUpdateSort"
+            @update:columns="handleUpdateColumns"
+            @update:resetSort="handleResetSort"
           ></VisibilityToolbar>
-          <!--            @update:columns="handleUpdateColumns"-->
-          <!--            @update:sort="handleUpdateSort"-->
-          <!--            @update:resetSort="handleResetSort"-->
         </div>
       </div>
     </el-form>
 
     <el-table
+      ref="elTable"
       style="margin-top: 20px"
       v-loading="loading"
       :data="projectInfoList"
       @selection-change="handleSelectionChange"
       height="60vh"
+      sortable="custom"
       :show-overflow-tooltip="true">
       <el-table-column type="selection" width="55" align="center"/>
-
       <!-- 鍔ㄦ�佸垪 -->
-      <template v-for="item in columns">
         <el-table-column
+          v-for="item in columns"
+          :key="item.id"
           v-if="item.visible"
           :prop="item.id"
           :label="item.label"
@@ -234,7 +236,6 @@
             <span v-else>{{ scope.row[item.id] }}</span>
           </template>
         </el-table-column>
-      </template>
 
       <!-- 鎿嶄綔鍒� -->
       <el-table-column label="鎿嶄綔" width="140" align="center" >
@@ -247,6 +248,7 @@
           >
           </el-button>
           <el-button
+            v-if="isReserve"
             size="medium"
             type="text"
             icon="el-icon-edit"
@@ -254,6 +256,7 @@
           >
           </el-button>
           <el-button
+            v-if="isReserve"
             size="medium"
             type="text"
             icon="el-icon-delete"
@@ -283,7 +286,7 @@
 
 <script>
 import {listInfo, getInfo, delInfo, addInfo, updateInfo} from "@/api/projectInfo";
-import {current} from './list';
+import {current, currentRest} from './list';
 import FileDialog from '../component/FileDialog';
 
 export default {
@@ -297,8 +300,11 @@
       fileDialogVisible: false,
       //鏄惁闇�瑕佹柊澧炴寜閽�(鍌ㄨ搫椤圭洰闇�瑕�)
       isReserve: false,
+      //椤圭洰鐘舵�佺瓫閫夋潯浠�
+      isProjectCategory: false,
       //琛ㄥご
       columns: [],
+      defaultColumns: [],
       //鎺у埗鏇村绛涢�夋樉闅�
       popoverValue: false,
       // 閬僵灞�
@@ -353,15 +359,62 @@
     };
   },
   created() {
-    this.columns = current.map((item, index) => {
+    const projectCategory = this.$route.query.projectCategory;
+    if(!projectCategory || projectCategory === '1'){
+      this.isReserve = true;
+    }
+    if(projectCategory){
+      this.isProjectCategory = true;
+    }
+    const columns = current.map((item, index) => {
       item.index = index + 1;
       item.key = index;
       item.serialNumber = index + 1;
       return item;
     });
+    this.columns = columns;
+    this.defaultColumns = JSON.parse(JSON.stringify(columns));
     this.getList();
   },
   methods: {
+    // 閲嶇疆鎺掑簭鐨勬柟娉�
+    handleResetSort() {
+      this.defaultColumns = currentRest.map((item, index) => {
+        item.index = index + 1;
+        item.key = index;
+        item.serialNumber = index + 1
+        return item;
+      });
+      this.columns = currentRest.map((item, index) => {
+        item.index = index + 1;
+        item.key = index;
+        item.serialNumber = index + 1
+        return item;
+      });
+    },
+    // 鏇存柊鍒楃殑鏂规硶
+    handleUpdateColumns(row) {
+      // this.currentColumns = row;
+      this.columns = this.columns.map(item => {
+        if (item.key === row.key) {
+          return row;
+        }
+        return item;
+      });
+    },
+    handleUpdateSort(data) {
+      console.log( this.columns, '鎺掑簭鍓嶇殑鍒�');
+      this.columns = this.columns.map(item => {
+        if (item.key === data.key) {
+          item.serialNumber = data.serialNumber;
+        }
+        return item;
+      });
+      this.defaultColumns = JSON.parse(JSON.stringify(this.columns)).sort((a, b) => a.index - b.index);
+      this.columns.sort((a, b) => a.serialNumber - b.serialNumber);
+
+      console.log( this.columns, '鎺掑簭鍚庣殑鍒�');
+    },
     // 鍏抽棴鏂囦欢澶勭悊寮规鐨勬柟娉�
     fileDialogCancel() {
       this.tableLoading = true;
@@ -379,7 +432,6 @@
     /** 鏌ヨ椤圭洰绠$悊鍩虹淇℃伅鍒楄〃 */
     getList() {
       this.loading = true;
-      console.log("鏌ヨ")
       listInfo(this.queryParams).then(response => {
         this.projectInfoList = response.data;
         this.total = response.total;

--
Gitblit v1.8.0