Browse Source

Merge branch 'develop_yh21' of http://git.chelingzhu.com/jianguan-web/qpls-md-html into develop_yh21

chenrui 2 years ago
parent
commit
e1eb1ce8c1
3 changed files with 68 additions and 63 deletions
  1. 1 1
      public/version.json
  2. 59 45
      src/views/power/role/menuModal.vue
  3. 8 17
      src/views/power/role/roleList.vue

+ 1 - 1
public/version.json

@@ -1,5 +1,5 @@
 {
   "message": "发现有新版本发布,确定更新系统?",
   "vendorJsVersion": "",
-  "version": 1688458776700
+  "version": 1688460571930
 }

+ 59 - 45
src/views/power/role/menuModal.vue

@@ -1,40 +1,40 @@
 <template>
-  <div>
-    <a-spin :spinning="spinning" tip="Loading...">
-      <a-modal
+  <a-modal
         centered
         class="modalBox"
         :title="roleName"
         v-model="isshow"
         @cancel="cancel"
         :maskClosable="false">
-        <a-form class="form-box" style="max-height: 600px;" :form="form" @submit="handleSubmit">
-          <a-tree
-            checkable
-            @check="onCheck"
-            @expand="onExpand"
-            :expandedKeys="expandedKeys"
-            :autoExpandParent="autoExpandParent"
-            v-model="checkedKeys"
-            :treeData="treeData"
-          />
-        </a-form>
-        <a-form-item :wrapper-col="{ offset: 15 }">
-          <a-button type="primary" @click="handleSubmit()" id="menuModal-handleSubmit">
-            保存
-          </a-button>
-          <a-button :style="{ marginLeft: '8px' }" @click="cancel" id="menuModal-handleCancel">
-            取消
-          </a-button>
-        </a-form-item>
+        <div style="min-height: 100px;">
+          <a-spin :spinning="spinning" tip="Loading...">
+            <a-form class="form-box" style="max-height: 600px;" :form="form" @submit="handleSubmit">
+            <a-tree
+              checkable
+              @check="onCheck"
+              @expand="onExpand"
+              :expandedKeys="expandedKeys"
+              :autoExpandParent="autoExpandParent"
+              v-model="checkedKeys"
+              :treeData="treeData"
+            />
+          </a-form>
+          <a-form-item :wrapper-col="{ offset: 15 }">
+            <a-button type="primary" @click="handleSubmit()" id="menuModal-handleSubmit">
+              保存
+            </a-button>
+            <a-button :style="{ marginLeft: '8px' }" @click="cancel" id="menuModal-handleCancel">
+              取消
+            </a-button>
+          </a-form-item>
+          </a-spin>
+        </div>
       </a-modal>
-    </a-spin>
-  </div>
 </template>
 
 <script>
 import { STable, VSelect } from '@/components'
-import { addMenuPower } from '@/api/powerRole-md.js'
+import { addMenuPower, getMenuList } from '@/api/powerRole-md.js'
 export default {
   name: 'RoleModal',
   components: {
@@ -45,17 +45,12 @@ export default {
       type: Boolean,
       default: false
     },
-    data: {
-      type: Object,
-      default: function () {
-        return {}
-      }
-    }
   },
   data () {
     return {
       spinning: false,
       treeData: [],
+      menuData: null,
       roleName: '',
       expandedKeys: [],
       autoExpandParent: true,
@@ -130,7 +125,38 @@ export default {
           }
         }
       }
-    }
+    },
+    getmenuData(id){
+      this.spinning = true
+      getMenuList({
+        id: id
+      }).then(res => {
+        if (res.status == 200) {
+          if(res.data.role){
+            this.setmenuData(res.data)
+          }else{
+            this.$message.error("获取数据失败,请重试!")
+            this.isshow = false
+          }
+        }
+        this.spinning = false
+      })
+    },
+    setmenuData(newValue){
+      this.menuData = newValue
+      console.log(this.menuData)
+      if (newValue) { // 编辑
+        this.treeData = this.menuData.allMenuList
+        this.id = this.menuData.role.id
+        this.roleName = '分配权限' + '(' + this.menuData.role.name + ')'
+        if (this.menuData.role.menuIds) {
+          const arr = this.menuData.role.menuIds.split(',')
+          this.checkedData = arr
+          // 找出叶子节点
+          this.findLeaf(this.treeData, arr)
+        }
+      }
+    },
   },
   beforeCreate () {
     this.form = this.$form.createForm(this, { name: 'menuModal' })
@@ -140,19 +166,7 @@ export default {
       this.isshow = newValue
     },
     isshow (newValue, oldValue) {
-      if (newValue) {
-        if (this.data) { // 编辑
-          this.treeData = this.data.allMenuList
-          this.id = this.data.role.id
-          this.roleName = '分配权限' + '(' + this.data.role.name + ')'
-          if (this.data.role.menuIds) {
-            const arr = this.data.role.menuIds.split(',')
-            this.checkedData = arr
-            // 找出叶子节点
-            this.findLeaf(this.treeData, arr)
-          }
-        }
-      } else {
+      if (!newValue) {
         this.cancel()
       }
     }

+ 8 - 17
src/views/power/role/roleList.vue

@@ -70,7 +70,7 @@
       </s-table>
     </a-spin>
     <roleModal :visible="showModal" :data="itemData" @refresh="refreshTable" @close="showModal = false"></roleModal>
-    <menuModal :visible="showMenuModal" :data="menuData" @close="showMenuModal = false"></menuModal>
+    <menuModal ref="menuData" :visible="showMenuModal" @close="closeMenu"></menuModal>
   </a-card>
 </template>
 
@@ -84,8 +84,7 @@ import menuModal from './menuModal.vue'
 import {
   getPowerRoleList,
   updateEnableStatus,
-  delectRolePower,
-  getMenuList
+  delectRolePower
 } from '@/api/powerRole-md.js'
 export default {
   name: 'RoleList',
@@ -107,7 +106,6 @@ export default {
       showModal: false,
       showMenuModal: false,
       itemData: {}, // 编辑行数据
-      menuData: {},
       // 表头
       columns: [
         { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
@@ -161,21 +159,14 @@ export default {
     },
     // 打开分配权限弹窗
     openMenuModal (row) {
-      this.getMenuList(row.id)
-    },
-    // 获取菜单树列表
-    getMenuList (id) {
-      const _this = this
-      getMenuList({
-        id: id
-      }).then(res => {
-        if (res.status == 200) {
-          _this.menuData = res.data
-          this.showMenuModal = true
-        }
+      this.showMenuModal = true
+      this.$nextTick(()=>{
+        this.$refs.menuData.getmenuData(row.id)
       })
     },
-
+    closeMenu(){
+      this.showMenuModal = false
+    },
     // 删除
     delect (row) {
       const _this = this