From fef5fd8385c26d39262938b7b7c36c9e47c44602 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期五, 28 二月 2025 10:56:15 +0800
Subject: [PATCH] Merge branch 'dev'

---
 src/components/VisibilityToolbar/index.vue |  108 +++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 99 insertions(+), 9 deletions(-)

diff --git a/src/components/VisibilityToolbar/index.vue b/src/components/VisibilityToolbar/index.vue
index d58270f..c1b45cf 100644
--- a/src/components/VisibilityToolbar/index.vue
+++ b/src/components/VisibilityToolbar/index.vue
@@ -23,7 +23,7 @@
         <span>淇℃伅鏄鹃殣绛涢��</span>
       </div>
       <div slot="default" style="margin-left: 20px;margin-top: 20px">
-        <el-table :data="pagedColumns" style="width: 95%; height: 80%;;margin-bottom: 40px;">
+        <el-table :data="getPage" style="width: 95%; height: 80%;;margin-bottom: 40px;">
           <el-table-column prop="index" label="搴忓彿" width="80"></el-table-column>
           <el-table-column prop="label" label="鏁版嵁鍚嶇О"></el-table-column>
           <el-table-column prop="visible" label="鏄惁鏄剧ず">
@@ -53,6 +53,7 @@
         ></el-pagination>
       </div>
       <div style="position: absolute; bottom: 0; left: 0; right: 0; padding: 20px; text-align: right;">
+        <el-button type="primary" @click="save" v-if="isAdmin()">淇� 瀛�</el-button>
         <el-button @click="table = false">鍙� 娑�</el-button>
         <el-button type="primary" @click="resetSort">閲� 缃�</el-button>
       </div>
@@ -61,6 +62,9 @@
 </template>
 
 <script>
+import {saveHiddenList} from "@/api/projectEngineering/projectInfo";
+
+import CircularJSON from 'circular-json'
 
 export default {
   data() {
@@ -68,7 +72,8 @@
       table: false,
       currentPage: 1,
       columnRef: null,
-      cpList: []
+      cpList: [],
+      saveList:[],
     };
   },
   props: {
@@ -79,6 +84,10 @@
     columns: {
       type: Array,
       default: () => [],
+    },
+    hiddenTotal:{
+      type: Number,
+      default: 0,
     },
     search: {
       type: Boolean,
@@ -99,15 +108,17 @@
       return 10;
     },
     total() {
-      return this.columns.length;
+      return this.hiddenTotal;
     },
-    pagedColumns() {
-      const start = (this.currentPage - 1) * this.pageSize;
-      const end = start + this.pageSize;
-      return this.columns.slice(start, end);
-    },
+    getPage(){
+      return this.columns;
+    }
   },
+
   methods: {
+    isAdmin(){
+      return this.$auth.hasRole("admin")
+    },
     toggleSearch() {
       this.$emit('update:showSearch', !this.showSearch);
     },
@@ -118,12 +129,87 @@
       this.table = true;
     },
     switchChange(row) {
+      row.sort = row.serialNumber;
+      if (row.visible === true){
+        row.display = "1"
+      }else {
+        row.display = "0"
+      }
+      if(this.saveList.length === 0){
+        this.saveList.push(row)
+      }else {
+        let have = true;
+        this.saveList.forEach((item ,index)=>{
+          if (item.id === row.id){
+              item[index] =item;
+            have =false;
+          }
+        })
+        if (have){
+          this.saveList.push(row)
+        }
+      }
+      console.log(this.saveList)
       this.$emit('update:columns', row);
     },
     handlePageChange(page) {
-      this.currentPage = page;
+      this.$emit('update:page', page);
+      // this.currentPage = page;
+      // this.queryParams.currentPage = page;
+      // getHiddenList(this.queryParams).then(res =>{
+      //   //杞崲
+      //   res.data.forEach((item,index)=>{
+      //     item.index = index + 1;
+      //     item.key = index;
+      //     item.serialNumber = index + 1;
+      //     item.label = item.name;
+      //     if(item.display === '0'){
+      //       item.visible = false
+      //     }else {
+      //       item.visible = true;
+      //     }
+      //     if(item.columns ==='usedStatus' ){
+      //       if(projectPhase !== '6') {
+      //         item.visible = false
+      //       }  else {
+      //         item.visible = true
+      //       }
+      //     }
+      //   });
+      //   this.columns = res.data;
+      // })
+
+    },
+    save(){
+      //淇濆瓨閫昏緫
+
+      if (this.saveList.length !== 0){
+        saveHiddenList(CircularJSON.stringify(this.saveList)).then(res =>{
+          this.$modal.msgSuccess(res.msg);
+        });
+      }
     },
     sortChange(row, val) {
+      row.sort = row.serialNumber;
+      if (row.visible === true){
+        row.display = "1"
+      }else {
+        row.display = "0"
+      }
+      if(this.saveList.length === 0){
+        this.saveList.push(row)
+      }else {
+        let have = true;
+        this.saveList.forEach((item ,index)=>{
+          if (item.id === row.id){
+            item[index] =item;
+            have =false;
+          }
+        })
+        if (have){
+          this.saveList.push(row)
+        }
+      }
       // // 鍒涘缓涓�涓柊鐨刢olumns鏁扮粍锛屼互閬垮厤鐩存帴淇敼鍘熷鏁扮粍
       // this.cpList = this.columns.map(item => ({ ...item })); // 浣跨敤瑙f瀯鏉ュ垱寤哄璞$殑娴呮嫹璐�
       //
@@ -142,10 +228,14 @@
       this.$emit('update:sort', row);
     },
     resetSort() {
+      //閲嶇疆淇濆瓨闆嗗悎
+      this.currentPage = 1;
+      this.saveList = [];
       this.$emit('update:resetSort');
     },
   },
   mounted() {
+
     this.columns.forEach((item, index) => {
       if (item.visible) {
 

--
Gitblit v1.8.0