From 12bf2514c17843aab17c9e3fa5ce8933cfefd7f6 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期二, 26 十一月 2024 00:56:47 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 src/views/projectEngineering/projectLibrary/index.vue |   82 ++++++++++++++++++++++++++++++++++-------
 1 files changed, 68 insertions(+), 14 deletions(-)

diff --git a/src/views/projectEngineering/projectLibrary/index.vue b/src/views/projectEngineering/projectLibrary/index.vue
index 96a5ae0..c1ff4cc 100644
--- a/src/views/projectEngineering/projectLibrary/index.vue
+++ b/src/views/projectEngineering/projectLibrary/index.vue
@@ -166,44 +166,46 @@
               <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
+      :key="tableKey"
+      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"
-          v-bind="item"
           :min-width="item.minWidth"
         >
           <template slot-scope="scope">
@@ -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,
       // 閬僵灞�
@@ -318,6 +324,7 @@
       // 寮瑰嚭灞傛爣棰�
       title: "",
       // 鏄惁鏄剧ず寮瑰嚭灞�
+      tableKey: 0,
       open: false,
       timeRange: [],
       // 鏌ヨ鍙傛暟
@@ -347,21 +354,69 @@
           {required: true, message: "椤圭洰鍚嶇О涓嶈兘涓虹┖", trigger: "blur"}
         ],
         projectStatus: [
-          {required: true, message: "椤圭洰鐘舵��  (0鏈紑宸ワ紝1宸插紑宸ワ紝2宸茬宸ワ紝3鏆傚仠)涓嶈兘涓虹┖", trigger: "change"}
+          {required: true, message: "椤圭洰鐘舵�佷笉鑳戒负绌�", trigger: "change"}
         ],
       }
     };
   },
   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(row) {
+      console.log( this.columns, '鎺掑簭鍓嶇殑鍒�');
+      this.columns = this.columns.map(item => {
+        if (item.key === row.key) {
+          return row;
+        }
+        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);
+      //寮哄埗table娓叉煋
+      this.tableKey = this.tableKey +1;
+      console.log( this.columns, '鎺掑簭鍚庣殑鍒�');
+    },
     // 鍏抽棴鏂囦欢澶勭悊寮规鐨勬柟娉�
     fileDialogCancel() {
       this.tableLoading = true;
@@ -379,7 +434,6 @@
     /** 鏌ヨ椤圭洰绠$悊鍩虹淇℃伅鍒楄〃 */
     getList() {
       this.loading = true;
-      console.log("鏌ヨ")
       listInfo(this.queryParams).then(response => {
         this.projectInfoList = response.data;
         this.total = response.total;

--
Gitblit v1.8.0