From 6ae0fcef149ddbe614746023a58a3885b3ac4bde Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期二, 25 三月 2025 11:31:04 +0800
Subject: [PATCH] Merge branch 'dev'

---
 src/components/VisibilityToolbar/index.vue |  161 ++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 139 insertions(+), 22 deletions(-)

diff --git a/src/components/VisibilityToolbar/index.vue b/src/components/VisibilityToolbar/index.vue
index 7b37a77..9f875e7 100644
--- a/src/components/VisibilityToolbar/index.vue
+++ b/src/components/VisibilityToolbar/index.vue
@@ -1,5 +1,5 @@
 <template>
-  <div class="top-right-btn" :style="style">
+  <div class="top-right-btn">
     <el-row>
       <el-tooltip v-if="search" class="item" effect="dark" :content="showSearch ? '闅愯棌鎼滅储' : '鏄剧ず鎼滅储'" placement="top">
         <el-button size="small" circle icon="el-icon-search" @click="toggleSearch"></el-button>
@@ -12,31 +12,38 @@
       </el-tooltip>
     </el-row>
 
-    <el-drawer v-model="table" title="淇℃伅鏄鹃殣绛涢��" size="30%" append-to-body>
+    <el-drawer
+      :visible.sync="table"
+      title="淇℃伅鏄鹃殣绛涢��"
+      size="30%"
+      append-to-body
+      :wrapperCLosable="false"
+      :with-header="true">
       <div slot="header">
         <span>淇℃伅鏄鹃殣绛涢��</span>
       </div>
-      <div slot="default">
-        <el-table :data="pagedColumns" style="width: 100%; height: 80%">
+      <div slot="default" style="margin-left: 20px;margin-top: 20px">
+        <el-table :row-key="row => { return row.id }" :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="鏄惁鏄剧ず">
+          <el-table-column prop="visible" label="鏄惁鏄剧ず" >
             <template slot-scope="scope">
               <el-switch
                 v-model="scope.row.visible"
                 class="ml-2"
-                style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"
+                active-color="#13ce66"
+                inactive-color="#ff4949"
                 @change="switchChange(scope.row)"
               ></el-switch>
             </template>
           </el-table-column>
-          <el-table-column prop="date" label="鎺掑簭">
+          <el-table-column prop="sort" label="鎺掑簭">
             <template slot-scope="scope">
-              <el-input-number v-model="scope.row.serialNumber" :min="0" style="width: 120px" @change="sortChange(scope.row, $event)"></el-input-number>
+              <el-input-number v-model="scope.row.sort" :min="0" style="width: 120px"
+                               @change="sortChange(scope.row, $event)"></el-input-number>
             </template>
           </el-table-column>
         </el-table>
-
         <el-pagination
           v-if="total > pageSize"
           :page-size="pageSize"
@@ -46,7 +53,8 @@
           @current-change="handlePageChange"
         ></el-pagination>
       </div>
-      <div slot="footer">
+      <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>
@@ -55,6 +63,9 @@
 </template>
 
 <script>
+import {saveHiddenList} from "@/api/projectEngineering/projectInfo";
+
+import CircularJSON from 'circular-json'
 
 export default {
   data() {
@@ -62,6 +73,8 @@
       table: false,
       currentPage: 1,
       columnRef: null,
+      cpList: [],
+      saveList:[],
     };
   },
   props: {
@@ -72,6 +85,10 @@
     columns: {
       type: Array,
       default: () => [],
+    },
+    hiddenTotal:{
+      type: Number,
+      default: 0,
     },
     search: {
       type: Boolean,
@@ -92,15 +109,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);
     },
@@ -111,25 +130,113 @@
       this.table = true;
     },
     switchChange(row) {
+      if (row.visible === true){
+        row.display = "1"
+      }else {
+        row.display = "0"
+      }
+      if(this.saveList.length === 0){
+        this.saveList.push(row)
+      }else {
+        let have = true;
+        let index = this.saveList.findIndex(item => item.id === row.id);
+        if (index !== -1){
+            this.saveList[index] = row;
+            have =false;
+        }
+
+        if (have){
+          this.saveList.push(row)
+        }
+      }
+      console
       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("淇濆瓨鎴愬姛");
+          //鍒锋柊椤甸潰
+          this.$emit('update:resetSort');
+        });
+      }
     },
     sortChange(row, val) {
-      this.$emit('update:sort', { key: row.key, serialNumber: val });
+      if (row.visible === true){
+        row.display = "1"
+      }else {
+        row.display = "0"
+      }
+      if(this.saveList.length === 0){
+        this.saveList.push(row)
+      }else {
+        let have = true;
+        let index = this.saveList.findIndex(item => item.id === row.id);
+        if (index !== -1){
+          this.saveList[index] = row;
+          have =false;
+        }
+        if (have){
+          this.saveList.push(row)
+        }
+      }
+      // // 鍒涘缓涓�涓柊鐨刢olumns鏁扮粍锛屼互閬垮厤鐩存帴淇敼鍘熷鏁扮粍
+      // this.cpList = this.columns.map(item => ({ ...item })); // 浣跨敤瑙f瀯鏉ュ垱寤哄璞$殑娴呮嫹璐�
+      //
+      // // 鏇存柊鎸囧畾椤圭殑serialNumber
+      // this.cpList.forEach(item => {
+      //   if (item.key ===  row.key) {
+      //     item.serialNumber =  row.serialNumber;
+      //   }
+      // });
+      //
+      // // 鏍规嵁serialNumber瀵筺ewColumns杩涜鎺掑簭
+      // this.cpList = this.cpList.sort((a, b) => a.serialNumber - b.serialNumber);
+      // // 瑙﹀彂浜嬩欢閫氱煡鐖剁粍浠禼olumns宸叉洿鏂帮紙濡傛灉鐖剁粍浠堕渶瑕佺煡閬撹繖涓彉鍖栵級
+      // this.$emit('update:sort', this.cpList);
+      this.$emit('update:sort', row);
     },
     resetSort() {
+      //閲嶇疆淇濆瓨闆嗗悎
+      this.currentPage = 1;
+      this.saveList = [];
       this.$emit('update:resetSort');
     },
   },
   mounted() {
+
     this.columns.forEach((item, index) => {
       if (item.visible) {
-        // 娉ㄦ剰锛氳繖閲屽亣璁綾olumnRef搴旇鏄竴涓猚heckbox缁勪欢鐨勫紩鐢紝
-        // 浣嗗湪Vue 2涓紝鎴戜滑鍙兘闇�瑕佸彟涓�绉嶆柟寮忔潵绠$悊checked鐘舵�侊紝
-        // 鍥犱负Vue 2娌℃湁ref鐨勮嚜鍔ㄥ疄渚嬬粦瀹氾紝涓旇繖閲岀殑columnRef閫昏緫浼间箮涓嶅畬鏁存垨閿欒銆�
-        // 鍙兘闇�瑕佺Щ闄ゆ垨閲嶅啓杩欓儴鍒嗛�昏緫銆�
+
       }
     });
   },
@@ -157,4 +264,14 @@
 .show-btn {
   margin-left: 12px;
 }
+.drawer-footer {
+  position: absolute;
+  bottom: 0;
+  left: 0;
+  right: 0;
+  padding: 20px;
+  background: #fff;
+  border-top: 1px solid #e8e8e8;
+  text-align: right;
+}
 </style>

--
Gitblit v1.8.0