From 3f386968d4b5cbb002ad93483f86a5443159e18a Mon Sep 17 00:00:00 2001
From: 小小儁爺 <1694218219@qq.com>
Date: 星期六, 08 二月 2025 09:54:32 +0800
Subject: [PATCH] 1.递交

---
 src/views/basicSettings/powerDivider.vue |  162 +++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 111 insertions(+), 51 deletions(-)

diff --git a/src/views/basicSettings/powerDivider.vue b/src/views/basicSettings/powerDivider.vue
index 4a55af6..f1aab8c 100644
--- a/src/views/basicSettings/powerDivider.vue
+++ b/src/views/basicSettings/powerDivider.vue
@@ -52,12 +52,12 @@
           >淇� 瀛�
           </el-button>
 
-          <el-tabs v-model="activeName" type="border-card">
+          <el-tabs v-model="activeName" type="border-card" @tab-click="tabClick">
             <el-tab-pane label="PC绔�" name="PC">
               <div style="display: flex;">
                 <div
                   ref="scrollLeft"
-                  style="border-right: 1px solid rgba(0,0,0,0.2);width:260px;
+                  style="border-right: 1px solid rgba(0,0,0,0.2);width:100%;
                   overflow-y: auto;overflow-x:hidden;"
                   :style="{height:(tableHeight-40)+'px'}"
                   @scroll="scrollLeftScroll()"
@@ -68,8 +68,8 @@
                   </div>
 
                   <el-tree
-                    ref="treeCenterRef"
-                    style="padding-top: 10px;width: 199px;"
+                    ref="treeCenterPCRef"
+                    style="padding-top: 10px;"
                     :data="treeCenter"
                     highlight-current
                     :props="defaultPropsCenter"
@@ -81,58 +81,87 @@
                     @node-click="getLeftTreeNode"
                   />
                 </div>
+                <!--                <div-->
+                <!--                  ref="scrollCenter"-->
+                <!--                  style="width: calc(100% - 260px );padding-left: 10px;overflow-y: auto;"-->
+                <!--                  :style="{height:(tableHeight-40)+'px'}"-->
+                <!--                  @scroll="scrollCenterScroll()"-->
+                <!--                  @mouseover="isScroll='center'"-->
+                <!--                >-->
+                <!--                  <div style=" ">-->
+                <!--                    <i class="el-icon-s-operation" :style="{color:$store.state.settings.theme}" /> 鎸夐挳鏉冮檺-->
+                <!--                  </div>-->
+
+                <!--                  <el-checkbox-->
+                <!--                    v-model="buttonIsChecked"-->
+                <!--                    style="height: 26px;display:flex;align-items: center;margin-top:10px;width:200px"-->
+                <!--                    @change=" handleCheckAllChange "-->
+                <!--                  >鍏ㄩ��-->
+                <!--                  </el-checkbox>-->
+
+                <!--                  <div v-if="treeCenter.length>0">-->
+                <!--                    <div v-for="(item,index) in treeCenter[0].children" :key="item.menucode">-->
+
+                <!--                      <div-->
+                <!--                        v-if="!item.buttoncodelist"-->
+                <!--                        style="margin-left: 40px;height:26px;display: flex;"-->
+                <!--                      />-->
+
+                <!--                      <el-checkbox-group-->
+                <!--                        v-for="it in item.children"-->
+                <!--                        v-if="item.expanded"-->
+                <!--                        :key="it.menucode"-->
+                <!--                        v-model="it.buttonChecked"-->
+                <!--                        style="margin-left: 40px;height:26px;display: flex;"-->
+                <!--                        @change="val=>handleCheckedButtonChange(val,it.menucode,it.buttonChecked)"-->
+                <!--                      >-->
+
+                <!--                        <el-checkbox-->
+                <!--                          v-for="i in it.buttoncodelist"-->
+                <!--                          :key="i"-->
+                <!--                          :label="i"-->
+                <!--                          style="display:flex;align-items: center;"-->
+                <!--                        />-->
+                <!--                      </el-checkbox-group>-->
+
+                <!--                    </div>-->
+
+                <!--                  </div>-->
+
+                <!--                </div>-->
+              </div>
+            </el-tab-pane>
+            <el-tab-pane label="APP绔�" name="APP">
+              <div style="display: flex;">
                 <div
-                  ref="scrollCenter"
-                  style="width: calc(100% - 260px );padding-left: 10px;overflow-y: auto"
+                  ref="scrollLeft"
+                  style="border-right: 1px solid rgba(0,0,0,0.2);width:100%;
+                                overflow-y: auto;overflow-x:hidden;"
                   :style="{height:(tableHeight-40)+'px'}"
-                  @scroll="scrollCenterScroll()"
-                  @mouseover="isScroll='center'"
+                  @scroll="scrollLeftScroll()"
+                  @mouseover="isScroll='left'"
                 >
                   <div style=" ">
-                    <i class="el-icon-s-operation" :style="{color:$store.state.settings.theme}" /> 鎸夐挳鏉冮檺
+                    <i class="el-icon-s-operation" :style="{color:$store.state.settings.theme}" /> 鑿滃崟鏉冮檺
                   </div>
 
-                  <el-checkbox
-                    v-model="buttonIsChecked"
-                    style="height: 26px;display:flex;align-items: center;margin-top:10px;width:200px"
-                    @change=" handleCheckAllChange "
-                  >鍏ㄩ��
-                  </el-checkbox>
-
-                  <div v-if="treeCenter.length>0">
-                    <div v-for="(item,index) in treeCenter[0].children" :key="item.menucode">
-
-                      <div
-                        v-if="!item.buttoncodelist"
-                        style="margin-left: 40px;height:26px;display: flex;"
-                      />
-
-                      <el-checkbox-group
-                        v-for="it in item.children"
-                        v-if="item.expanded"
-                        :key="it.menucode"
-                        v-model="it.buttonChecked"
-                        style="margin-left: 40px;height:26px;display: flex;"
-                        @change="val=>handleCheckedButtonChange(val,it.menucode,it.buttonChecked)"
-                      >
-
-                        <el-checkbox
-                          v-for="i in it.buttoncodelist"
-                          :key="i"
-                          :label="i"
-                          style="display:flex;align-items: center;"
-                        />
-                      </el-checkbox-group>
-
-                    </div>
-
-                  </div>
-
+                  <el-tree
+                    ref="treeCenterAPPRef"
+                    style="padding-top: 10px;"
+                    :data="treeCenter"
+                    highlight-current
+                    :props="defaultPropsCenter"
+                    show-checkbox
+                    node-key="menucode"
+                    :default-expand-all="true"
+                    @check-change="handleTreeCenterCheckChange"
+                    @check="handleTreeCenterCheck"
+                    @node-click="getLeftTreeNode"
+                  />
                 </div>
               </div>
             </el-tab-pane>
-            <el-tab-pane label="APP绔�" name="APP">APP绔�</el-tab-pane>
-            <el-tab-pane label="宸ユ帶绔�" name="宸ユ帶绔�">宸ユ帶绔�</el-tab-pane>
+            <!--            <el-tab-pane label="宸ユ帶绔�" name="宸ユ帶绔�">宸ユ帶绔�</el-tab-pane>-->
           </el-tabs>
 
         </div>
@@ -220,6 +249,11 @@
         this.$notify.error('璇峰厛寤虹浉瀵瑰簲鐨勮鑹诧紒')
       }
     },
+    async tabClick() {
+      this.treeCenter = []
+      await this.getRolePermissionSearchRoleMenuButton(this.$refs.treeLeftRef.getCurrentKey())// 鐢ㄤ簬鏁版嵁鍥炴樉
+      await this.getRolePermissionSearchRoleMenu(this.$refs.treeLeftRef.getCurrentKey())// 鐢ㄤ簬娓叉煋椤甸潰
+    },
 
     // 鑾峰彇鑿滃崟鏉冮檺瀵瑰簲鐨勬寜閽�
     async getRolePermissionSearchRoleMenuButton(rolecode) {
@@ -241,6 +275,7 @@
         { menucode: '-1', menuname: '鍏ㄩ儴', children: result }
       ]
 
+      this.treeCenter[0].children.sort((a, b) => a.menu_seq - b.menu_seq)
       this.treeCenter[0].children.forEach(item => {
         if (item.children && item.children.length) {
           item.children.forEach(it => {
@@ -254,6 +289,8 @@
             }
           })
 
+          item.children.sort((a, b) => a.menu_seq - b.menu_seq)
+
           item.expanded = true
         }
       })
@@ -264,7 +301,12 @@
     handleData() {
       this.menuCheckedCodeArr = this.allButtonData.map(i => i.menucode)
       this.$nextTick(() => {
-        this.$refs.treeCenterRef.setCheckedKeys(this.menuCheckedCodeArr)
+        if (this.activeName === 'PC') {
+          this.$refs.treeCenterPCRef.setCheckedKeys(this.menuCheckedCodeArr)
+        }
+        if (this.activeName === 'APP') {
+          this.$refs.treeCenterAPPRef.setCheckedKeys(this.menuCheckedCodeArr)
+        }
       })
 
       this.treeCenter[0].children.forEach(item => {
@@ -301,7 +343,13 @@
 
     // 鍏ㄩ�夋敼鍙�
     handleCheckAllChange(val) {
-      const checkedKeys = this.$refs.treeCenterRef.getCheckedKeys()
+      let checkedKeys
+      if (this.activeName === 'PC') {
+        checkedKeys = this.$refs.treeCenterPCRef.getCheckedKeys()
+      }
+      if (this.activeName === 'APP') {
+        checkedKeys = this.$refs.treeCenterAPPRef.getCheckedKeys()
+      }
 
       if (val) {
         this.treeCenter[0].children.forEach(item => {
@@ -335,7 +383,12 @@
         } else if (this.menuCheckedCodeArr.includes(code) && oldValue.length === 1 && newValue.length === 0) { // 鏄�
           this.menuCheckedCodeArr = this.menuCheckedCodeArr.filter(i => i !== code)
         }
-        this.$refs.treeCenterRef.setCheckedKeys(this.menuCheckedCodeArr)
+        if (this.activeName === 'PC') {
+          this.$refs.treeCenterPCRef.setCheckedKeys(this.menuCheckedCodeArr)
+        }
+        if (this.activeName === 'APP') {
+          this.$refs.treeCenterAPPRef.setCheckedKeys(this.menuCheckedCodeArr)
+        }
       }
 
       // 杩欓噷鏄垽鏂叏閫塩heckbox 鏄惁閫変腑
@@ -420,7 +473,14 @@
     async saveClick() {
       const rolecode = this.$refs.treeLeftRef.getCurrentKey()
       const datacode = this.treeLeft.find(i => i.code === rolecode).datarange !== 'CUSTOM' ? this.treeLeft.find(i => i.code === rolecode).datarange : this.treeLeft.find(i => i.code === rolecode).datapermissions
-      const menuKeyArr = this.$refs.treeCenterRef.getCheckedKeys()
+      let menuKeyArr
+      if (this.activeName === 'PC') {
+        menuKeyArr = this.$refs.treeCenterPCRef.getCheckedKeys()
+      }
+      if (this.activeName === 'APP') {
+        menuKeyArr = this.$refs.treeCenterAPPRef.getCheckedKeys()
+      }
+
       const arr = []
       this.treeCenter[0].children.forEach(item => {
         if (item.children && item.children.length) {

--
Gitblit v1.9.3