Prechádzať zdrojové kódy

Merge branch 'master' of http://49.4.53.36:3000/hotel/hotel-saas-tenant-frontend

gqx 2 rokov pred
rodič
commit
4134e167a0

+ 4 - 0
src/api/api.js

@@ -7,6 +7,8 @@ const addRole = (params)=>postAction("/sys/role/add",params);
 const editRole = (params)=>putAction("/sys/role/edit",params);
 const checkRoleCode = (params)=>getAction("/sys/role/checkRoleCode",params);
 const queryall = (params)=>getAction("/sys/role/queryall",params);
+const saveRoleAndPermission = (params)=>postAction("/sys/role/saveRoleAndPermission",params);
+const editRoleAndPermission = (params)=>postAction("/sys/role/editRoleAndPermission",params);
 
 //用户管理
 const addUser = (params)=>postAction("/sys/user/add",params);
@@ -126,6 +128,8 @@ export const transitRESTful = {
 
 export {
   addRole,
+  saveRoleAndPermission,
+  editRoleAndPermission,
   editRole,
   checkRoleCode,
   addUser,

+ 3 - 2
src/views/hotel/newHotelForm.vue

@@ -60,7 +60,7 @@
             <a-input-number placeholder="1~9999" style="width: 180px;" :min="1" :max="9999"  v-decorator="['roomCount', { rules: [{ required: true, message: '1~9999' }], }]"/>
         </a-form-item>
 
-        
+
 
 
         <a-form-item label="集团品牌">
@@ -103,6 +103,7 @@ export default {
     },
     methods: {
         handleSubmit(e) {
+            this.$router.go(0);
             // e.preventDefault();
             this.form.validateFields((err, values) => {
                 if (!err) {
@@ -130,4 +131,4 @@ export default {
 .short-anl{
     width: 70%;
 }
-</style>
+</style>

+ 4 - 4
src/views/system/RoleUserList.vue

@@ -68,9 +68,9 @@
                 更多 <a-icon type="down"/>
               </a>
               <a-menu slot="overlay">
-                <a-menu-item>
-                  <a @click="handlePerssion(record.id)">授权</a>
-                </a-menu-item>
+<!--                <a-menu-item>-->
+<!--                  <a @click="handlePerssion(record.id)">授权</a>-->
+<!--                </a-menu-item>-->
                 <a-menu-item>
                   <a @click="handleEdit(record)">编辑</a>
                 </a-menu-item>
@@ -542,4 +542,4 @@
   .ant-btn {
     margin-left: 8px
   }
-</style>
+</style>

+ 76 - 6
src/views/system/modules/RoleModal.vue

@@ -21,13 +21,32 @@
         <a-form-model-item label="描述" prop="description">
           <a-textarea :rows="5" v-model="model.description" placeholder="请输入角色描述"/>
         </a-form-model-item>
+        <a-form-item label='授权'>
+          <a-card style="max-height: 400px;overflow: scroll;">
+            <a-tree
+                    checkable
+                    @check="onCheck"
+                    :checkedKeys="checkedKeys"
+                    :treeData="treeData"
+                    @expand="onExpand"
+                    @select="onTreeNodeSelect"
+                    :selectedKeys="selectedKeys"
+                    :expandedKeys="expandedKeysss"
+                    :checkStrictly="checkStrictly">
+          <span slot="hasDatarule" slot-scope="{slotTitle,ruleFlag}">
+            {{ slotTitle }}<a-icon v-if="ruleFlag" type="align-left" style="margin-left:5px;color: red;"></a-icon>
+          </span>
+            </a-tree>
+          </a-card>
+        </a-form-item>
       </a-form-model>
     </a-spin>
   </a-modal>
 </template>
 
 <script>
-  import {addRole,editRole,duplicateCheck } from '@/api/api'
+  import {addRole,editRole,duplicateCheck,queryTreeListForRole,queryRolePermission,
+    saveRolePermission,saveRoleAndPermission,editRoleAndPermission } from '@/api/api'
   export default {
     name: "RoleModal",
     data () {
@@ -55,6 +74,13 @@
             { min: 0, max: 126, message: '长度不超过 126 个字符', trigger: 'blur' }
           ]
         },
+        treeData: [],
+        checkedKeys:[],
+        expandedKeysss:[],
+        selectedKeys:[],
+        defaultCheckedKeys:[],
+        allTreeKeys:[],
+        checkStrictly: true,
       }
     },
     created () {
@@ -74,6 +100,7 @@
         }else{
           this.roleDisabled = false;
         }
+        this.loadData();
       },
       close () {
         this.$refs.form.clearValidate();
@@ -87,10 +114,19 @@
           if (valid) {
             that.confirmLoading = true;
             let obj;
+            var param = {
+              role: this.model,
+              permissionJson: {
+                permissionIds: that.checkedKeys.join(","),
+                lastpermissionIds: that.defaultCheckedKeys.join(","),
+              }
+            }
             if(!this.model.id){
-              obj=addRole(this.model);
-            }else{
-              obj=editRole(this.model);
+              // obj=addRole(this.model);
+              obj=saveRoleAndPermission(param);
+            }else {
+              // obj=editRole(this.model);
+              obj = editRoleAndPermission(param);
             }
             obj.then((res)=>{
               if(res.success){
@@ -129,11 +165,45 @@
             }
           });
         }
-      }
+      },
+      loadData(){
+        var _this = this;
+        var _roleId = "";
+        if (_this.model.id !== null &&_this.model.id !== undefined){
+          _roleId = _this.model.id;
+        }
+        queryTreeListForRole().then((res) => {
+          this.treeData = res.result.treeList
+          this.allTreeKeys = res.result.ids
+          queryRolePermission({roleId:_roleId}).then((res)=>{
+            this.checkedKeys = [...res.result];
+            this.defaultCheckedKeys = [...res.result];
+            this.expandedKeysss = this.allTreeKeys;
+            console.log(this.defaultCheckedKeys)
+          })
+        })
+      },
+      onCheck (o) {
+        if(this.checkStrictly){
+          this.checkedKeys = o.checked;
+        }else{
+          this.checkedKeys = o
+        }
+      },
+      onExpand(expandedKeys){
+        this.expandedKeysss = expandedKeys;
+        this.autoExpandParent = false
+      },
+      onTreeNodeSelect(id){
+        if(id && id.length>0){
+          this.selectedKeys = id
+        }
+        this.$refs.datarule.show(this.selectedKeys[0],this.roleId)
+      },
     }
   }
 </script>
 
 <style scoped>
 
-</style>
+</style>