From 68338b19f9dc2ad9725326b7e699a3e191030cb8 Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期四, 24 八月 2023 17:27:59 +0800
Subject: [PATCH] 1.角色分配

---
 src/views/basicSettings/roleList.vue |  972 ++++++++++++++++++++++----------------------------------
 1 files changed, 378 insertions(+), 594 deletions(-)

diff --git a/src/views/basicSettings/roleList.vue b/src/views/basicSettings/roleList.vue
index 89635a6..0d211da 100644
--- a/src/views/basicSettings/roleList.vue
+++ b/src/views/basicSettings/roleList.vue
@@ -2,8 +2,7 @@
   <div>
     <div class="body" :style="{height:mainHeight+'px'}">
       <div class="bodyTopButtonGroup" style="justify-content: space-between">
-        <el-button v-waves type="primary" icon="el-icon-circle-plus-outline">鏂板</el-button>
-        <el-button v-waves icon="el-icon-download">瀵煎叆</el-button>
+        <el-button v-waves type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">鏂板</el-button>
       </div>
 
       <div class="bodyTopFormGroup">
@@ -15,681 +14,466 @@
           style="display: flex;"
         >
           <div class="elForm">
-            <el-form-item label="姣嶄欢缂栫爜" style=" display: flex;">
-              <el-input v-model="form.OrgCode" placeholder="璇疯緭鍏�" style="width: 200px" />
+            <el-form-item label="瑙掕壊缂栫爜" style=" display: flex;">
+              <el-input v-model="form.storg_code" placeholder="璇疯緭鍏�" style="width: 200px" />
             </el-form-item>
-            <el-form-item label="姣嶄欢鍚嶇О" style=" display: flex;">
-              <el-input v-model="form.OrgName" placeholder="璇疯緭鍏�" style="width: 200px" />
-            </el-form-item>
-            <el-form-item label="姣嶄欢瑙勬牸" style=" display: flex;">
-              <el-input v-model="form.OrgName" placeholder="璇疯緭鍏�" style="width: 200px" />
-            </el-form-item>
-
-            <el-form-item label="鐗堟湰缂栧彿" style=" display: flex;">
-              <el-input v-model="form.OrgName" placeholder="璇疯緭鍏�" style="width: 200px" />
-            </el-form-item>
-            <el-form-item v-show="isExpandForm" label="鍒涘缓浜哄憳" style=" display: flex;">
-              <el-input v-model="form.UserName" style="width: 200px" placeholder="璇疯緭鍏�" />
-            </el-form-item>
-            <el-form-item v-show="isExpandForm" label="鍒涘缓鏃ユ湡" style=" display: flex;">
-              <el-date-picker
-                v-model="form.createdate"
-                style="width: 200px"
-                type="date"
-                placeholder="閫夋嫨鏃ユ湡"
-              />
+            <el-form-item label="瑙掕壊鍚嶇О" style=" display: flex;">
+              <el-input v-model="form.storg_name" placeholder="璇疯緭鍏�" style="width: 200px" />
             </el-form-item>
           </div>
           <div
             class="bodySearchReset"
             :style="{marginLeft:$store.state.app.sidebar.opened? $store.state.settings.menuIsHorizontal?'15%':'3%':'10%'}"
           >
-            <el-button v-waves type="primary" icon="el-icon-search">鏌ヨ</el-button>
-            <el-button v-waves type="info" icon="el-icon-refresh">閲嶇疆</el-button>
+            <el-button v-waves type="primary" icon="el-icon-search" @click="getRoleData">鏌ヨ</el-button>
+            <el-button v-waves type="info" icon="el-icon-refresh" @click="reset">閲嶇疆</el-button>
           </div>
         </el-form>
         <div
           class="bodyTopFormExpand"
+          style="height:5px"
         >
-          <svg-icon
-            v-show="mouseHoverType==='mouseout'"
-            style="cursor: pointer"
-            :icon-class="!isExpandForm?'doubleDown3':'doubleUp3'"
-            @mouseenter="mouseHoverType=$event.type"
-          />
-          <svg-icon
-            v-show="mouseHoverType==='mouseenter'"
-            style="cursor: pointer"
-            :icon-class="!isExpandForm?'doubleDown':'doubleUp'"
-            @click="isExpandForm=!isExpandForm"
-            @mouseout="mouseHoverType=$event.type"
-          />
+          <!--          <svg-icon-->
+          <!--            v-show="mouseHoverType==='mouseout'"-->
+          <!--            style="cursor: pointer"-->
+          <!--            :icon-class="!isExpandForm?'doubleDown3':'doubleUp3'"-->
+          <!--            @mouseenter="mouseHoverType=$event.type"-->
+          <!--          />-->
+          <!--          <svg-icon-->
+          <!--            v-show="mouseHoverType==='mouseenter'"-->
+          <!--            style="cursor: pointer"-->
+          <!--            :icon-class="!isExpandForm?'doubleDown':'doubleUp'"-->
+          <!--            @click="isExpandForm=!isExpandForm"-->
+          <!--            @mouseout="mouseHoverType=$event.type"-->
+          <!--          />-->
         </div>
       </div>
 
-      <div
-        class="elTableDiv"
-      >
-
-        <div style="width: 300px;">
-          <el-tree
-            ref="treeLeftRef"
-            style="padding: 10px;"
-            :style="{height:isExpandForm?tableHeight:(tableHeight+105)+'px'}"
-            :data="treeLeft"
-            node-key="code"
-            highlight-current
-            :props="defaultPropsLeft"
-            :default-expand-all="true"
-            @node-click="treeLeftNodeClick"
-          />
-        </div>
-
-        <div
-          style="margin-left: 15px;width:100%;"
+      <div class="elTableDiv">
+        <el-table
+          ref="tableDataRef"
+          class="tableFixed"
+          :data="tableData"
+          :height="tableHeight+'px'"
+          border
+          row-class-name="custom-row"
+          :style="{width: 100+'%',height:tableHeight+'px',}"
+          highlight-current-row
+          :header-cell-style="this.$headerCellStyle"
+          :cell-style="this.$cellStyle"
+          @sort-change="sortChange"
         >
-          <el-tabs v-model="activeName" type="border-card">
-            <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: 200px;
-                  overflow-y: auto;overflow-x:hidden;"
-                  :style="{height:isExpandForm?tableHeight:(tableHeight+35)+'px',}"
-                  @scroll="scrollLeftScroll()"
-                  @mouseover="changeScrollLeftFlag('left')"
-                >
-                  <div style=" ">
-                    <i class="el-icon-s-operation" :style="{color:$store.state.settings.theme}" /> 鑿滃崟鏉冮檺
-                  </div>
-                  <!--                  :style="{height:isExpandForm?tableHeight:(tableHeight+15)+'px',}"-->
-                  <el-tree
-                    ref="treeCenterRef"
-                    style="padding-top: 10px;width: 199px;"
-                    :data="treeCenter"
-                    highlight-current
-                    :props="defaultPropsCenter"
-                    show-checkbox
-                    node-key="code"
-                    :default-expand-all="true"
-                    @check-change="handleTreeCenterCheckChange"
-                    @check="handleTreeCenterCheck"
-                    @node-click="getLeftTreeNode"
+          <el-table-column
+            prop="rowNum"
+            width="120"
+            fixed
+            label="搴忓彿"
+          />
+          <el-table-column
+            prop="rolecode"
+            label="瑙掕壊缂栫爜"
+            sortable="custom"
+          />
+          <el-table-column
+            prop="rolename"
+            label="瑙掕壊鍚嶇О"
+            sortable="custom"
+          />
+          <el-table-column
+            prop="status"
+            label="鐘舵��"
+            sortable="custom"
+          >
+            <template slot-scope="{row}">
+              <el-tag v-if="row.status==='Y'" size="small" type="success">姝e父</el-tag>
+              <el-tag v-if="row.status==='N'" size="small" type="danger">鍋滅敤</el-tag>
+            </template>
+          </el-table-column>
+          <el-table-column
+            prop="dataname"
+            label="鏉冮檺鑼冨洿"
+            sortable="custom"
+          />
+          <el-table-column
+            prop="description"
+            label="澶囨敞"
+            sortable="custom"
+          >
+            <template slot-scope="{row}">
+              {{ row.description?row.description:'/' }}
+            </template>
+          </el-table-column>
+          <el-table-column
+            prop="username"
+            label="鍒涘缓浜哄憳"
+            sortable="custom"
+          />
+          <el-table-column
+            prop="lm_date"
+            label="鍒涘缓鏃堕棿"
+            width="160"
+            sortable="custom"
+          />
+          <el-table-column
+            label="鎿嶄綔"
+            width="160"
+            fixed="right"
+          >
+            <template slot-scope="{row}">
+              <div class="operationClass">
+                <el-tooltip class="item" effect="dark" content="缂栬緫" placement="top">
+                  <i
+                    class="el-icon-edit-outline"
+                    :style="{color:$store.state.settings.theme}"
+                    @click="edit('edit',row)"
                   />
-                </div>
+                </el-tooltip>
+                <el-tooltip v-del-tab-index class="item" effect="dark" content="鍒犻櫎" placement="top">
+                  <i
+                    class="el-icon-delete"
+                    :style="{color:$store.state.settings.theme}"
+                    @click="del(row)"
+                  />
+                </el-tooltip>
 
-                <div
-                  ref="scrollCenter"
-                  style="border-right: 1px solid rgba(0,0,0,0.2);width: 600px;padding-left: 10px;overflow-y: auto"
-                  :style="{height:isExpandForm?tableHeight:(tableHeight+35)+'px',}"
-                  @scroll="scrollCenterScroll()"
-                  @mouseover="changeScrollLeftFlag('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="val=>handleCheckAllChange(val,'button')"
-                  >鍏ㄩ��
-                  </el-checkbox>
-
-                  <div v-if="treeCenter.length>0">
-                    <div v-for="item in treeCenter[0].children" :key="item.code">
-                      <div
-                        v-if="item.display"
-                        style="margin-left: 40px;height:26px;display: flex;"
-                      />
-
-                      <el-checkbox-group
-                        v-for="it in item.children"
-                        v-if="item.expanded"
-                        :key="it.code"
-                        v-model="it.checkedButton"
-                        style="margin-left: 40px;height:26px;display: flex"
-                        @change="val=>handleCheckedButtonChange(val,it.code)"
-                      >
-
-                        <el-checkbox
-                          v-for="i in it.itemButton"
-                          :key="i"
-                          :label="i"
-                          style="display:flex;align-items: center"
-                        />
-                      </el-checkbox-group>
+                <el-dropdown placement="bottom" @command="command=>handleCommand(command,row)">
+                  <div
+                    class="el-dropdown-link"
+                    style="display: flex;align-content: center;
+                    justify-content: center;
+                    cursor: pointer;"
+                    :style="{color:$store.state.settings.theme}"
+                  >
+                    <div>鏇村</div>
+                    <div>
+                      <i class="el-icon-arrow-down el-icon--right" />
                     </div>
-
                   </div>
-
-                </div>
-
-                <div
-                  ref="scrollRight"
-                  style="width: 360px;padding-left: 10px;overflow-y: auto"
-                  :style="{height:isExpandForm?tableHeight:(tableHeight+35)+'px',}"
-                  @scroll="scrollRightScroll()"
-                  @mouseover="changeScrollLeftFlag('right')"
-                >
-                  <div style=" ">
-                    <i class="el-icon-s-operation" :style="{color:$store.state.settings.theme}" /> 鏁版嵁鏉冮檺
-                  </div>
-
-                  <el-checkbox
-                    v-model="dataIsChecked"
-                    style="height: 26px;display:flex;align-items: center;margin-top:10px;width:200px"
-                    @change="val=>handleCheckAllChange(val,'data')"
-                  >鍏ㄩ��
-                  </el-checkbox>
-
-                  <div v-if="treeCenter.length>0">
-                    <div v-for="item in treeCenter[0].children" :key="item.code">
-                      <div
-                        v-if="item.display"
-                        style="margin-left: 40px;height:26px;display: flex;"
-                      />
-
-                      <el-radio-group
-                        v-for="it in item.children"
-                        v-if="item.expanded"
-                        :key="it.code"
-                        v-model="it.checkedData"
-                        style="margin-left: 40px;height:26px;display: flex"
-                        @change="val=>handleCheckedDataChange(val,it.code)"
-                      >
-                        <el-radio
-                          v-for="i in it.itemData"
-                          :key="i"
-                          style="display:flex;align-items: center"
-                          :label="i"
-                        />
-                      </el-radio-group>
-                    </div>
-
-                  </div>
-
-                </div>
-
+                  <el-dropdown-menu slot="dropdown">
+                    <el-dropdown-item icon="el-icon-circle-check" command="menuPower">鑿滃崟鏉冮檺</el-dropdown-item>
+                    <el-dropdown-item icon="el-icon-user" command="divideUser">鍒嗛厤鐢ㄦ埛</el-dropdown-item>
+                    <!--                    <el-dropdown-item icon="el-icon-download" command="downloadMenu">瀵煎嚭鑿滃崟</el-dropdown-item>-->
+                  </el-dropdown-menu>
+                </el-dropdown>
               </div>
-            </el-tab-pane>
-            <el-tab-pane label="APP绔�" name="APP绔�">澶уぇ</el-tab-pane>
-            <el-tab-pane label="宸ユ帶绔�" name="宸ユ帶绔�">宸ユ帶绔�</el-tab-pane>
-          </el-tabs>
-
-        </div>
-
+            </template>
+          </el-table-column>
+        </el-table>
       </div>
-
+      <!--鍒嗛〉-->
+      <pagination
+        :total="total"
+        :page.sync="form.page"
+        :limit.sync="form.rows"
+        align="right"
+        layout="total,prev, pager, next,sizes,jumper"
+        popper-class="select_bottom"
+        @pagination="getRoleData"
+      />
     </div>
+
+    <el-dialog
+      v-el-drag-dialog
+      :title="operation==='add'?'鏂板':'缂栬緫'"
+      :visible.sync="dialogVisible"
+      width="800px"
+      :close-on-click-modal="false"
+      top="15vh"
+      @closed="handleClose"
+      @close="handleClose"
+    >
+      <el-form ref="dialogForm" inline :rules="dialogFormRules" :model="dialogForm" label-width="80px">
+        <!--        <el-form-item label="瑙掕壊缂栫爜" prop="rolecode">-->
+        <!--          <el-input v-model="dialogForm.rolecode" :disabled="operation!=='add'" style="width: 200px" />-->
+        <!--        </el-form-item>-->
+        <el-form-item label="瑙掕壊鍚嶇О" prop="rolename">
+          <el-input v-model="dialogForm.rolename" style="width: 200px" />
+        </el-form-item>
+
+        <el-form-item required label="鏁版嵁鑼冨洿">
+          <el-select
+            v-model="dialogForm.datacode"
+            style="width:200px"
+            placeholder="璇烽�夋嫨"
+            :popper-append-to-body="false"
+          >
+            <el-option
+              v-for="item in datacodeArr"
+              :key="item.datacode"
+              :label="item.dataname"
+              :value="item.datacode"
+            />
+          </el-select>
+        </el-form-item>
+        <el-form-item required label="鐘舵��">
+          <el-radio-group v-model="dialogForm.status" style="width: 200px">
+            <el-radio label="Y">姝e父</el-radio>
+            <el-radio label="N">鍋滅敤</el-radio>
+          </el-radio-group>
+        </el-form-item>
+        <el-form-item v-if="dialogForm.datacode==='CUSTOM'" label="鏁版嵁鏉冮檺" style="margin: 0">
+          <el-checkbox-group v-model="checkboxGroupSelected" @change="checkboxGroupChange">
+            <el-checkbox v-for="item in checkboxGroup" :key="item" :label="item">
+              {{ item }}
+              <el-tooltip class="item" effect="dark" content="鍕鹃�夌埗鑺傜偣鏄惁鍚屾椂閫変腑瀛愯妭鐐�" placement="top">
+                <i v-if="item==='鐖跺瓙鑱斿姩'" class="el-icon-question" />
+              </el-tooltip>
+            </el-checkbox>
+          </el-checkbox-group>
+        </el-form-item>
+        <el-card
+          v-if="dialogForm.datacode==='CUSTOM'"
+          class="box-card"
+          shadow="never"
+          style="margin-bottom: 30px;width: 78%;margin-left: 12%;"
+        >
+
+          <el-tree
+            ref="tree"
+            :key="checkboxGroupSelected.toString()"
+            :data="treeData"
+            show-checkbox
+            :check-strictly="!checkboxGroupSelected.includes('鐖跺瓙鑱斿姩')"
+            :default-expand-all="checkboxGroupSelected.includes('灞曞紑/鎶樺彔')"
+            node-key="torg_code"
+            :props="defaultProps"
+          />
+        </el-card>
+
+        <el-form-item label="澶囨敞">
+          <el-input v-model="dialogForm.description" type="textarea" style="width:500px" />
+        </el-form-item>
+
+      </el-form>
+      <span slot="footer" class="dialog-footer">
+        <div class="footerButton">
+          <el-button v-waves @click="dialogVisibleCancel">鍙� 娑�</el-button>
+          <el-button
+            v-waves
+            type="primary"
+            :loading="$store.state.app.buttonIsDisabled"
+            :disabled="$store.state.app.buttonIsDisabled"
+            @click="dialogVisibleConfirm"
+          >纭� 瀹�</el-button>
+        </div>
+      </span>
+    </el-dialog>
 
   </div>
 </template>
 
 <script>
 import Pagination from '@/components/Pagination'
-import ImportPicker from '@/components/ImportPicker'
+import {
+  AddUpdateGroup,
+  DeleteGroup, RoleAddUpdateSava,
+  RoleData, RoleDeleteSava
+} from '@/api/basicSettings'
+import { validateCode } from '@/utils/global'
 import elDragDialog from '@/directive/el-drag-dialog'
 import waves from '@/directive/waves'
-import {
-  RolePermissionSearchRole,
-  RolePermissionSearchRoleMenu,
-  RolePermissionSearchRoleMenuButton
-} from '@/api/basicSettings'
+import { DataPermissions, PrentOrganization } from '@/api/GeneralBasicData'
 import arrayToTree from 'array-to-tree'
 
 export default {
   name: 'Zzjg',
   components: {
-    Pagination, ImportPicker
+    Pagination
   },
   directives: { elDragDialog, waves },
   data() {
     return {
-      mouseHoverType: 'mouseout',
-      isExpandForm: false,
       mainHeight: 0,
       tableHeight: 0,
       form: {
-        OrgCode: '', // 缁勭粐鏋舵瀯浠g爜
-        OrgName: '', // 缁勭粐鏋舵瀯鍚嶇О
-        OrgType: '', // 缁勭粐绫诲瀷
-        UserName: '', // 鍒涘缓浜哄憳
-        createdate: '',
+        role_code: '',
+        role_name: '',
         prop: 'lm_date', // 鎺掑簭瀛楁
         order: 'desc', // 鎺掑簭瀛楁
         page: 1, // 绗嚑椤�
         rows: 20 // 姣忛〉澶氬皯鏉�
       },
-      treeLeft: [],
-      treeCenter: [],
-      defaultPropsLeft: {
-        children: 'roles',
-        label: 'name'
+      total: 10,
+      tableData: [],
+      dialogVisible: false,
+      dialogForm: {
+        rolecode: '', //
+        rolename: '', //
+        datacode: 'ALL',
+        description: '',
+        datapermissions: '', // 鏁版嵁鏉冮檺
+        status: 'Y'// 鐘舵��
       },
-      defaultPropsCenter: {
+      datacodeArr: [],
+      checkboxGroupSelected: ['灞曞紑/鎶樺彔', '鐖跺瓙鑱斿姩'],
+      checkboxGroup: ['灞曞紑/鎶樺彔', '鍏ㄩ��/鍏ㄤ笉閫�', '鐖跺瓙鑱斿姩'],
+      operation: '',
+      dialogFormRules: {
+        rolecode: [
+          { required: true, validator: validateCode, trigger: ['blur', 'change'] }
+        ],
+        rolename: [
+          { required: true, message: '璇疯緭鍏ョ粍缁囧悕绉�', trigger: ['blur', 'change'] }
+        ]
+      },
+      defaultProps: {
         children: 'children',
-        label: 'name'
+        label: 'torg_name'
       },
-      activeName: 'PC绔�',
-
-      buttonIsChecked: false,
-      dataIsChecked: false,
-
-      menuCheckedCodeArr: [], // 鑿滃崟鏉冮檺鏁扮粍閫変腑鐨�
-
-      allButtonData: [], // 鎵�鏈夌殑鎸夐挳鍔犳潈闄�
-
-      isScroll: 'left'
+      treeData: []
 
     }
   },
-
   created() {
-    this.getRolePermissionSearchRole()
+    this.getRoleData()
   },
   mounted() {
     window.addEventListener('resize', this.getHeight)
     this.getHeight()
+
+    this.getPrentOrganization()
+    this.getDataPermissions()
   },
   methods: {
-
-    // 鑾峰彇瑙掕壊鏉冮檺鏌ヨ瑙掕壊
-    async getRolePermissionSearchRole() {
-      const { data: res } = await RolePermissionSearchRole()
-      this.treeLeft = res
-      if (res.length > 0) {
-        this.$nextTick(() => { // 榛樿閫変腑绗竴涓�
-          this.$refs.treeLeftRef.setCurrentKey(res[0].roles[0].code) // 榛樿閫変腑鑺傜偣绗竴涓�
-        })
-        await this.getRolePermissionSearchRoleMenuButton(res[0].roles[0].code)
-        await this.getRolePermissionSearchRoleMenu(res[0].roles[0].code)
-      } else {
-        this.$notify.error('璇峰厛寤虹浉瀵瑰簲鐨勮鑹诧紒')
-      }
+    async getRoleData() {
+      const res = await RoleData(this.form)
+      this.tableData = res.data
+      this.total = res.count
     },
-    // 鑾峰彇鑿滃崟鏉冮檺瀵瑰簲鐨勬寜閽�
-    async getRolePermissionSearchRoleMenuButton(rolecode) {
-      const { data: res } = await RolePermissionSearchRoleMenuButton({ rolecode })
-      this.allButtonData = res
+    async getDataPermissions() {
+      const { data: res } = await DataPermissions()
+      this.datacodeArr = res
     },
-    // 鑾峰彇鑿滃崟鏉冮檺
-    async getRolePermissionSearchRoleMenu(rolecode) {
-      const { data: res } = await RolePermissionSearchRoleMenu({ rolecode, type: 'PC' })
-
-      // 鎷垮埌鏁扮粍list杞崲鎴愭爲褰ree
-      const result = arrayToTree(res, {
-        parentProperty: 'parentid',
-        customID: 'code',
+    // 缁勭粐鏋舵瀯绾ц仈閫夋嫨鍣�
+    async getPrentOrganization() {
+      const { data: res } = await PrentOrganization()
+      this.treeData = arrayToTree(res, {
+        parentProperty: 'parent_id',
+        customID: 'torg_code',
         childrenProperty: 'children'
       })
-
-      this.menuCheckedCodeArr = []
-
-      // console.log(this.allButtonData, 213)
-      result.forEach(item => {
-        if (item.children && item.children.length) {
-          item.children.forEach(it => {
-            // 鎸夐挳鏉冮檺鍥炴樉
-            const buttonAll = this.allButtonData.tButton.filter(j => j.menucode === it.code).map(j => j.name)
-            const buttonChecked = this.allButtonData.tButton.filter(j =>
-              j.menucode === it.code && j.flag === 'Y'
-            ).map(j => j.name)
-            it.itemButton = buttonAll
-            it.checkedButton = buttonChecked
-
-            // 鏁版嵁鏉冮檺鍥炴樉
-            const dataAll = this.allButtonData.tData.filter(j => j.menucode === it.code).map(j => j.name)
-            const dataChecked = this.allButtonData.tData.filter(j => j.menucode === it.code && j.flag === 'Y').name
-            // console.log(dataAll, dataChecked, 2)
-            it.itemData = dataAll
-            it.checkedData = dataChecked
-
-            // 鐢ㄤ綔鑿滃崟鍕鹃�夊洖鏄�
-            if (it.flag === 'Y') {
-              this.menuCheckedCodeArr.push(it.code)
-            }
-          })
-          item.display = true
-          item.expanded = true
-        }
-      })
-
-      console.log(JSON.parse(JSON.stringify(result)), 8)
-
-      this.treeCenter = [
-        { code: '-1', name: '鍏ㄩ儴', flag: result.every(i => i.flag === 'Y') ? 'Y' : 'N', children: result }
-      ]
-
-      // this.buttonIsChecked = result.every(i => i.flag === 'Y')
-      this.handleCheckedButtonChange('', '', true)
-      this.handleCheckedDataChange('', '', true)
-      // console.log(this.menuCheckedCodeArr, 2)
+    },
+    // 鎺掑簭鏀瑰彉鏃�
+    sortChange({ column, prop, order }) {
+      if (order === 'descending') {
+        order = 'desc'
+      } else if (order === 'ascending') {
+        order = 'asc'
+      } else {
+        order = 'desc'
+      }
+      this.form.order = order
+      this.form.prop = prop
+      this.getRoleData()
+    },
+    // 閲嶇疆
+    reset() {
+      this.form.storg_code = ''
+      this.form.storg_name = ''
+      this.getRoleData()
+    },
+    // 鏂板鎸夐挳
+    add(operation) {
+      this.operation = operation
+      this.dialogVisible = true
+      this.dialogForm.OperType = 'Add'
+    },
+    // 淇敼鎸夐挳
+    async edit(operation, row) {
+      this.operation = operation
+      this.dialogVisible = true
+      this.dialogForm.OperType = 'Update'
       this.$nextTick(() => {
-        this.$refs.treeCenterRef.setCheckedKeys(this.menuCheckedCodeArr)
+        this.dialogForm.rolecode = row.rolecode
+        this.dialogForm.rolename = row.rolename
+        this.dialogForm.datacode = row.datacode
+        this.dialogForm.status = row.status
+        this.dialogForm.description = row.description
+        if (this.dialogForm.datacode === 'CUSTOM') {
+          setTimeout(() => {
+            this.$refs.tree.setCheckedKeys(row.datapermissionscode.split(','))
+          })
+        }
       })
-
-      this.$forceUpdate()
-      // console.log(this.treeCenter[0].children)
     },
-
-    // 宸﹁竟婊氬姩鏉℃粦鍔ㄦ椂
-    scrollLeftScroll() {
-      if (this.isScroll === 'left') {
-        this.$refs.scrollCenter.scrollTop = this.$refs.scrollLeft.scrollTop
-        this.$refs.scrollRight.scrollTop = this.$refs.scrollLeft.scrollTop
-      }
-    },
-    // 涓棿杈规粴鍔ㄦ潯婊戝姩鏃�
-    scrollCenterScroll() {
-      if (this.isScroll === 'center') {
-        this.$refs.scrollLeft.scrollTop = this.$refs.scrollCenter.scrollTop
-        this.$refs.scrollRight.scrollTop = this.$refs.scrollCenter.scrollTop
-      }
-    },
-    // 鍙充晶婊氬姩鏉℃粦鍔ㄦ椂
-    scrollRightScroll() {
-      if (this.isScroll === 'right') {
-        this.$refs.scrollLeft.scrollTop = this.$refs.scrollRight.scrollTop
-        this.$refs.scrollCenter.scrollTop = this.$refs.scrollRight.scrollTop
-      }
-    },
-
-    resize() {
-
-    },
-
-    changeScrollLeftFlag(val) {
-      this.isScroll = val
-    },
-
-    // 鍏ㄩ�夋敼鍙�
-    handleCheckAllChange(val, belong) {
-      const checkedKeys = this.$refs.treeCenterRef.getCheckedKeys()
-
-      if (val) {
-        this.treeCenter[0].children.forEach(item => {
-          if (item.children && item.children.length) {
-            item.children.forEach(it => {
-              if (checkedKeys.includes(it.code)) {
-                if (belong === 'button') {
-                  it.checkedButton = it.itemButton
-                }
-                if (belong === 'data') {
-                  it.checkedData = '鍏ㄩ儴'
-                }
-              }
-            })
+    // 鍒犻櫎鎸夐挳
+    async del(row) {
+      this.$confirm('鏄惁纭鍒犻櫎?', '鎻愮ず', {
+        confirmButtonText: '纭畾',
+        cancelButtonText: '鍙栨秷',
+        type: 'warning'
+      }).then(() => {
+        RoleDeleteSava({ rolecode: row.rolecode }).then(res => {
+          if (res.code === '200') {
+            this.$notify.success('鍒犻櫎鎴愬姛!')
+            if (this.form.page > 1 && this.tableData.length === 1) {
+              this.form.page--
+            }
+            this.getRoleData()
           }
         })
-      } else {
-        this.treeCenter[0].children.forEach(item => {
-          if (item.children && item.children.length) {
-            item.children.forEach(it => {
-              if (checkedKeys.includes(it.code)) {
-                if (belong === 'button') {
-                  it.checkedButton = []
-                }
-                if (belong === 'data') {
-                  it.checkedData = undefined
-                }
-              }
-            })
+      }).catch(() => {
+        this.$notify.info('宸插彇娑堝垹闄�')
+      })
+    },
+    checkboxGroupChange(val) {
+      if (val.includes('鍏ㄩ��/鍏ㄤ笉閫�')) {
+        this.$refs.tree.setCheckedKeys([this.treeData[0].torg_code])
+      }
+    },
+    // 瀵硅瘽妗嗗叧闂簨浠�
+    handleClose() {
+      this.dialogForm.rolecode = ''
+      this.dialogForm.rolename = ''
+      this.dialogForm.description = ''
+      this.dialogForm.datapermissions = ''
+      this.dialogForm.datacode = 'ALL'
+      this.dialogForm.status = 'Y'
+      this.$refs.dialogForm.clearValidate()
+    },
+    // 瀵硅瘽妗嗗彇娑�
+    dialogVisibleCancel() {
+      this.dialogVisible = false
+    },
+    // 瀵硅瘽妗嗙‘璁�
+    dialogVisibleConfirm() {
+      this.$refs.dialogForm.validate(valid => {
+        if (valid) {
+          this.$store.state.app.buttonIsDisabled = true
+          if (this.$refs.tree) {
+            this.dialogForm.datapermissions = this.$refs.tree.getCheckedKeys().join(',')
           }
-        })
-      }
-
-      // console.log(this.treeCenter[0].children, 20)
-    },
-    // 鍗曚釜鎸夐挳鏀瑰彉
-    handleCheckedButtonChange(value, code, flag) {
-      // 鍒ゆ柇鏄惁鍖呭惈鍦ㄥ唴
-      if (!flag) {
-        if (!this.menuCheckedCodeArr.includes(code) && value.length === 1) { // 鍚�
-          this.menuCheckedCodeArr.push(code)
-        } else if (this.menuCheckedCodeArr.includes(code) && value.length === 0) { // 鏄�
-          this.menuCheckedCodeArr = this.menuCheckedCodeArr.filter(i => i !== code)
-        }
-        this.$refs.treeCenterRef.setCheckedKeys(this.menuCheckedCodeArr)
-      }
-
-      // 杩欓噷鏄垽鏂叏閫塩heckbox 鏄惁閫変腑
-      let count = 0
-      let childrenLength = 0
-      this.treeCenter[0].children.forEach(item => {
-        if (item.children && item.children.length) {
-          item.children.forEach(it => {
-            if (it.checkedButton.length === it.itemButton.length) {
-              count++
-            }
-            childrenLength++
-          })
-        }
-      })
-      this.buttonIsChecked = count === childrenLength
-      this.$forceUpdate()
-    },
-
-    // 鑾峰彇鏍戝舰鑺傜偣node
-    getLeftTreeNode(data, Node, VueComponent) {
-      // console.log(data, Node, VueComponent, 2221)
-      // console.log(Node.expanded)
-      this.treeCenter[0].children.forEach(item => {
-        if (item.name === data.name) {
-          item.expanded = Node.expanded
-        }
-      })
-      if (data.code === '-1') {
-        Node.expanded = true // 鏆傛椂鍏堝啓鎴愯繖涓�
-        // this.treeCenter[0].children.forEach(item => {
-        //   item.expanded = Node.expanded
-        // })
-      }
-      this.$forceUpdate()
-    },
-    // 澶勭悊鏍戝舰鍕鹃��
-    handleTreeCenterCheck(obj, { checkedNodes, checkedKeys, halfCheckedNodes, halfCheckedKeys }) {
-      // console.log(obj, checkedNodes, checkedKeys, halfCheckedNodes, halfCheckedKeys, '鍔犲瀹�')
-
-      if (checkedKeys.length === 0) { // 鏍戝舰鑿滃崟鍏ㄤ笉閫夌殑鎯呭喌涓�
-        this.buttonIsChecked = false
-        this.dataIsChecked = false
-        this.menuCheckedCodeArr = []
-      } else {
-        if (checkedKeys.includes(obj.code)) { // 鍒ゆ柇鏄惁鍖呭惈鍦ㄥ唴   //鏄�
-          this.menuCheckedCodeArr.push(obj.code)
-        } else { // 鍚�
-          this.menuCheckedCodeArr = this.menuCheckedCodeArr.filter(i => i !== obj.code)
-        }
-      }
-    },
-    // 澶勭悊鏍戝舰閫変腑鍊兼敼鍙�
-    handleTreeCenterCheckChange(obj, selfChecked, selfChildrenTreeCheck) {
-      // console.log(obj, selfChecked, selfChildrenTreeCheck, '鐜嬭�佸悏')
-      if (!selfChildrenTreeCheck) {
-        if (!selfChecked) {
-          this.treeCenter[0].children.forEach(item => {
-            if (item.children && item.children.length) {
-              item.children.forEach(it => {
-                if (it.code === obj.code) {
-                  it.checkedButton = []
-                  it.checkedData = undefined
-                }
-              })
-            }
-          })
-          this.$forceUpdate()
-        }
-      }
-    },
-
-    // 鍗曢�夋鎸夐挳鏀瑰彉
-    handleCheckedDataChange(value, code, flag) {
-      // console.log(value, code)
-      if (flag) {
-        this.menuCheckedCodeArr.push(code)
-        this.menuCheckedCodeArr = [...new Set(this.menuCheckedCodeArr)]
-
-        this.$refs.treeCenterRef.setCheckedKeys(this.menuCheckedCodeArr)
-      }
-
-      // 杩欓噷鏄垽鏂叏閫塺adio 鏄惁閫変腑
-      let count = 0
-      let childrenLength = 0
-      this.treeCenter[0].children.forEach(item => {
-        if (item.children && item.children.length) {
-          item.children.forEach(it => {
-            if (it.checkedData) {
-              count++
-            }
-            if (it.itemData.length > 0) {
-              childrenLength++
+          RoleAddUpdateSava(this.dialogForm).then(res => {
+            if (res.code === '200') {
+              this.$notify.success(this.operation === 'add' ? '娣诲姞鎴愬姛锛�' : '淇敼鎴愬姛锛�')
+              this.dialogVisible = false
+              this.$store.state.app.buttonIsDisabled = false
+              this.getRoleData()
+            } else {
+              this.$store.state.app.buttonIsDisabled = false
+              this.$notify.error(this.operation === 'add' ? '娣诲姞澶辫触锛�' : '淇敼澶辫触锛�')
             }
           })
         }
       })
-      // console.log(count, childrenLength, 9)
-      this.dataIsChecked = count === childrenLength
-      // console.log(JSON.parse(JSON.stringify(this.treeCenter[0].children)))
-
-      this.$forceUpdate()
     },
-
-    async  treeLeftNodeClick(obj, Node, VueComponent) {
-      // this.menuCheckedCodeArr = []
-
-      await this.getRolePermissionSearchRoleMenuButton(obj.code)
-      await this.getRolePermissionSearchRoleMenu(obj.code)
+    handleCommand(command, row) {
+      console.log(command, row)
+      if (command === 'menuPower') {
+        this.$router.push('./powerDivider?rolecode=' + row.rolecode)
+      }
+      if (command === 'divideUser') {
+        this.$router.push('./roleDivider?rolecode=' + row.rolecode)
+      }
     },
-
     // 鑾峰彇椤甸潰楂樺害
     getHeight() {
       this.$nextTick(() => {
         this.mainHeight = window.innerHeight - 85
-        this.tableHeight = this.mainHeight - 255
-        // this.$refs.tableDataRef.doLayout()
+        this.tableHeight = this.mainHeight - 200
+        this.$refs.tableDataRef.doLayout()
       })
     }
   }
 }
 </script>
-
-<!--鍏叡椤甸潰鏍峰紡-->
-<style lang="scss" scoped>
-$main_color: #42b983;
-::v-deep .el-button--text {
-  font-size: 14px;
-  cursor: pointer;
-}
-
-.el-icon-share, .el-icon-delete, .el-icon-edit-outline {
-  color: $main_color;
-  cursor: pointer;
-}
-
-.el-icon-edit-outline {
-  margin-right: 15px;
-}
-
-::v-deep .el-button--primary, .el-button--default, .el-button--info {
-  height: 34px;
-  display: flex;
-  align-items: center;
-  padding: 0 15px;
-}
-
-::v-deep .el-button--primary {
-  //background-color: $main_color !important;
-}
-
-::v-deep .el-button--default {
-  background-color: #f8f8fa;
-  border: none;
-}
-
-::v-deep .el-input__inner {
-  height: 34px;
-  line-height: 34px;
-  //color: #a7a7a7;
-}
-
-::v-deep .el-dialog__body {
-  padding: 20px 100px !important;
-}
-
-::v-deep .dialogVisibleRoles .el-dialog__body {
-  padding: 20px 20px !important;
-}
-
-::v-deep .importPickerClass .el-dialog__body {
-  padding: 20px 20px !important;
-}
-
-::v-deep .el-dialog__footer {
-  display: flex;
-  justify-content: flex-end;
-}
-
-::v-deep .el-table .caret-wrapper {
-  transform: scale(0.8);
-}
-
-::v-deep .cell {
-  display: flex;
-  align-items: center;
-  justify-content: space-between;
-}
-
-::v-deep .el-table::before {
-  height: 0;
-}
-
-::v-deep .el-table__body-wrapper {
-  background-color: #f8f8fa;
-}
-
-::v-deep .el-table__body .el-table__row.hover-row td {
-  background-color: #eaecef;
-}
-
-::v-deep .el-form--inline .el-form-item__label {
-  color: #a7a7a7;
-}
-
-.body ::v-deep .el-divider {
-  border: 1px solid #eee;
-  width: 99%;
-  margin: 10px auto;
-}
-
-.body ::v-deep .el-form-item {
-  margin-bottom: 0;
-}
-
-.userDialogVisible ::v-deep .el-form-item {
-  margin-bottom: 0;
-}
-
-::v-deep .el-select__caret {
-  display: flex;
-  align-items: center;
-  justify-content: center;
-}
-
-.tableFixed {
-  ::v-deep .el-table__fixed-right {
-    height: 100% !important;
-  }
-
-  ::v-deep .el-table__fixed {
-    height: 100% !important;
-  }
-}
-</style>
-<style>
-
-.el-table .custom-row {
-  background: #f8f8fa;
-}
-</style>

--
Gitblit v1.9.3