dingxin 6 år sedan
förälder
incheckning
f6bb93d85c

+ 14
- 1
src/config/api.js Visa fil

@@ -345,6 +345,19 @@ const apis = {
345 345
       method: 'delete',
346 346
       url: `${commPrefix}/role`
347 347
     }
348
-  }
348
+  },
349
+  menu:{
350
+    list: {
351
+      method: 'get',
352
+      url: `${commPrefix}/sysmenu`
353
+    },
354
+    add: {
355
+      method: 'post',
356
+      url: `${commPrefix}/sysmenuAdd`
357
+    },
358
+    
359
+  },
360
+  
361
+
349 362
 }
350 363
 export default apis

+ 3
- 1
src/store/index.js Visa fil

@@ -18,6 +18,7 @@ import visitor from './modules/visitor'
18 18
 import lobby from './modules/lobby'
19 19
 import followup from './modules/followup'
20 20
 import sysyrole from './modules/role'
21
+import sysmenu from './modules/sysmenu'
21 22
 
22 23
 Vue.use(Vuex)
23 24
 
@@ -40,7 +41,8 @@ const store = new Vuex.Store({
40 41
     visitor,
41 42
     lobby,
42 43
     followup,
43
-    sysyrole
44
+    sysyrole,
45
+    sysmenu
44 46
   }
45 47
 })
46 48
 

+ 11
- 0
src/store/modules/role.js Visa fil

@@ -83,5 +83,16 @@ export default {
83 83
 
84 84
             })
85 85
         },
86
+        aAddNode({ commit }) {
87
+            return new Promise((resolve, reject) => {
88
+                const api = lodash.get(apis, 'menu.add')
89
+                interact(api).then((data) => {
90
+                    resolve(data)
91
+                    commit('setMenus', data)
92
+                }).catch(() => {
93
+                    reject()
94
+                })
95
+            })
96
+        },
86 97
     }
87 98
 }

+ 2
- 2
src/store/modules/sysuser.js Visa fil

@@ -107,11 +107,11 @@ export default {
107 107
         })
108 108
       })
109 109
     },
110
-    userRoledetails ({ commit }, payload) {
110
+    userRoledetails (_, payload) {
111 111
       return new Promise((resolve, reject) => {
112 112
         const api = lodash.get(apis, 'sysuser.userRoledetails')
113 113
         interact(api,payload).then((data) => {
114
-          commit('updateList', data)
114
+          //commit('updateList', data)
115 115
           resolve(data)
116 116
         }).catch(() => {
117 117
           reject()

+ 22
- 4
src/views/index.js Visa fil

@@ -40,13 +40,31 @@ const pages = [
40 40
           },
41 41
         ],
42 42
       },
43
+      // {
44
+      //   path: 'sysuser/userRole',
45
+      //   name: 'userRole',
46
+      //   component: () => import('./sysuser/userRole/list.vue'),
47
+      //   meta: {
48
+      //     menuShow: true,
49
+      //     title: '人员角色',
50
+      //   },
51
+      // },
43 52
       {
44
-        path: 'sysuser/userRole',
45
-        name: 'userRole',
46
-        component: () => import('./sysuser/userRole/list.vue'),
53
+        path: 'sysmenu/list',
54
+        name: 'sysmenu',
55
+        component: () => import('./sysmenu/list.vue'),
47 56
         meta: {
48 57
           menuShow: true,
49
-          title: '人员角色',
58
+          title: '菜单管理',
59
+        },
60
+      },
61
+      {
62
+        path: 'sysmenu/add',
63
+        name: 'sysmenuAdd',
64
+        component: () => import('./sysmenu/add.vue'),
65
+        meta: {
66
+          menuShow: false,
67
+          title: '添加菜单',
50 68
         },
51 69
       },
52 70
       {

+ 36
- 1
src/views/sysuser/edit.vue Visa fil

@@ -23,6 +23,17 @@
23 23
           <el-option label="启用" :value="1"></el-option>
24 24
         </el-select>
25 25
       </el-form-item>
26
+
27
+      <el-form-item label="角色权限"  required>
28
+      <el-select v-model="roleId" multiple placeholder="请选择">
29
+      <el-option
30
+      v-for="(item, index) in sysRole"
31
+      :key="index"
32
+      :label="item.roleName"
33
+      :value="item.roleId">
34
+      </el-option>
35
+      </el-select>
36
+      </el-form-item>
26 37
       <el-form-item>
27 38
         <el-button type="primary" @click="onSubmit">保存</el-button>
28 39
         <el-button @click="onCancel">取消</el-button>
@@ -39,6 +50,15 @@ const {mapState: mapUserState, mapActions: mapUserActions, mapMutations: mapUser
39 50
 export default {
40 51
   data () {
41 52
     return {
53
+      formInline: {
54
+        userId: '',
55
+        label: [],
56
+        value: [],
57
+        menuArray: []
58
+        
59
+      },
60
+      roleId: [],
61
+      sysRole:[],
42 62
       rules: {
43 63
         nickname: [
44 64
           { required: true, message: '请输入用户名', trigger: 'blur' }
@@ -49,7 +69,10 @@ export default {
49 69
         status: [
50 70
           { required: true, message: '请选择状态', trigger: 'change' }
51 71
         ],
52
-      }
72
+      },
73
+    
74
+        value1: [],
75
+        value2: []
53 76
     }
54 77
   },
55 78
   methods: {
@@ -57,9 +80,12 @@ export default {
57 80
       'getDetail',
58 81
       'addSysUser',
59 82
       'editSysUser',
83
+      'userRoledetails',
84
+      'updateUserRolede',
60 85
     ]),
61 86
     ...mapUserMutations([
62 87
       'updateDetail',
88
+      
63 89
     ]),
64 90
     onCancel () {
65 91
       this.$router.back()
@@ -81,6 +107,10 @@ export default {
81 107
           this.editSysUser({...this.detail, isSales: 1}).then(() => {
82 108
             this.$notify.success('编辑信息成功')
83 109
           })
110
+          // 保存角色
111
+          console.log('this.formInline.menuArray',this.formInline.menuArray)
112
+          this.formInline.menuArray = this.roleId
113
+          this.updateUserRolede(this.formInline)
84 114
         }
85 115
 
86 116
       })
@@ -102,6 +132,11 @@ export default {
102 132
     }),
103 133
   },
104 134
   created () {
135
+    this.formInline.userId = this.$route.query.id
136
+    this.userRoledetails(this.formInline).then((data)=>{
137
+        this.sysRole = data.sysRole
138
+        this.roleId = data.arrayList
139
+    })
105 140
     this.init()
106 141
   },
107 142
 }

+ 62
- 6
src/views/sysuser/list.vue Visa fil

@@ -2,13 +2,13 @@
2 2
 <r-layout>
3 3
   <xm-search @submit="search">
4 4
     <el-form-item>
5
-      <el-input v-model="filterData.name" placeholder="用户名" clearable></el-input>
5
+      <el-input v-model="listQuery.name" placeholder="用户名" clearable></el-input>
6 6
     </el-form-item>
7 7
     <el-form-item>
8
-      <el-input v-model="filterData.phone" placeholder="手机号" clearable></el-input>
8
+      <el-input v-model="listQuery.phone" placeholder="手机号" clearable></el-input>
9 9
     </el-form-item>
10 10
     <el-form-item>
11
-        <el-select v-model="filterData.identity" placeholder="请选择">
11
+        <el-select v-model="listQuery.identity" placeholder="请选择">
12 12
           <el-option label="全部"></el-option>
13 13
           <el-option
14 14
             v-for="item in identityDict"
@@ -55,10 +55,10 @@
55 55
       </el-table-column>
56 56
       <el-table-column
57 57
         fixed="right"
58
-        label="操作"
59
-        width="120">
58
+        label="操作">
60 59
         <template slot-scope="scope">
61 60
           <el-button type="text" @click="handleEdit(scope.row)" size="small">编辑</el-button>
61
+           <el-button type="text" @click="addUserRole(scope.row)" size="small">添加权限</el-button>       
62 62
         </template>
63 63
       </el-table-column>
64 64
     </el-table>
@@ -73,6 +73,28 @@
73 73
     @current-change="getList"
74 74
   >
75 75
   </el-pagination>
76
+
77
+    <el-dialog title="添加权限" :visible.sync="filterData.dialogFormVisible" :show-close="filterData.close">
78
+      <el-form :model="filterData">  
79
+      <el-form-item label="角色权限"  required>
80
+      <el-select v-model="userRoleId" multiple placeholder="请选择">
81
+      <el-option
82
+      v-for="(item, index) in sysRole"
83
+      :key="index"
84
+      :label="item.roleName"
85
+      :value="item.roleId">
86
+      </el-option>
87
+      </el-select>
88
+      </el-form-item>
89
+
90
+      </el-form>
91
+      <div slot="footer" class="dialog-footer">
92
+        <el-button @click="TransactionReplyOff">取 消</el-button>
93
+        <el-button type="primary" @click="TransactionReplyAdd()">确 定</el-button>
94
+      </div>
95
+    </el-dialog>
96
+
97
+
76 98
 </r-layout>
77 99
 </template>
78 100
 
@@ -89,7 +111,17 @@ export default {
89 111
         name: '',
90 112
         phone: '',
91 113
         identity: undefined,
114
+        dialogFormVisible: false,
115
+        close: false,
116
+        menuArray:[]
92 117
       },
118
+      listQuery: {
119
+        name: '',
120
+        phone: '',
121
+        identity: undefined,
122
+      },
123
+      sysRole:[],
124
+      userRoleId:[],
93 125
       pageNavi: {
94 126
         page: 1,
95 127
         size: 10,
@@ -106,10 +138,20 @@ export default {
106 138
   methods: {
107 139
     ...mapUserActions([
108 140
       'getSysUserList',
141
+      'userRoledetails',
142
+      'updateUserRolede',
109 143
     ]),
110 144
     handleEdit (row) {
111 145
       this.$router.push({ name: 'sysuseredit', query: {id: row.userId} })
112 146
     },
147
+    addUserRole (row) {
148
+      this.filterData.userId = row.userId;
149
+          this.userRoledetails(this.filterData).then((data)=>{
150
+          this.sysRole = data.sysRole
151
+          this.userRoleId = data.arrayList
152
+      })
153
+      this.filterData.dialogFormVisible = true
154
+    },
113 155
     addUser () {
114 156
       this.$router.push({ name: 'sysuseredit' })
115 157
     },
@@ -117,7 +159,7 @@ export default {
117 159
       this.getSysUserList({
118 160
         pageNum: this.pageNavi.page || 1,
119 161
         pageSize: this.pageNavi.size,
120
-        ...this.filterData,
162
+        ...this.listQuery,
121 163
       }).then((data) => {
122 164
         const { current: page, size, total } = data
123 165
         this.pageNavi = { page, size, total }
@@ -139,7 +181,21 @@ export default {
139 181
     getIdentityName (val) {
140 182
       const identity = (this.identityDict || []).filter(x => x.value == val)[0] || {}
141 183
       return identity.label || '-'
184
+    },
185
+    TransactionReplyOff(){
186
+      this.filterData.dialogFormVisible = false
187
+      this.getList()
188
+    },
189
+    TransactionReplyAdd(){
190
+          this.filterData.menuArray = this.userRoleId
191
+          this.updateUserRolede(this.filterData).then((res)=>{
192
+            console.log('测试返回值:', res)
193
+            this.getList()
194
+          })
195
+          this.filterData.dialogFormVisible = false 
196
+          
142 197
     }
198
+    
143 199
   },
144 200
   created () {
145 201
     this.init()

+ 7
- 9
src/views/sysuser/userRole/addUserRole.vue Visa fil

@@ -1,9 +1,6 @@
1 1
 <template>
2 2
   <div id="root">
3 3
     <el-form ref="formInline" :model="formInline" :rules="rules" label-width="100px" class="demo-formInline">
4
-      <el-form-item class="filter-item" label="手机号" prop="phone" >
5
-        <el-input v-model.trim="formInline.phone" placeholder="手机号" />
6
-      </el-form-item>
7 4
       <el-form-item label="角色" prop="menuArray">
8 5
         <!-- default-expanded-keys 展示选中的
9 6
              default-checked-keys 勾上选中的-->
@@ -14,11 +11,10 @@
14 11
           :default-checked-keys="formInline.menuArray"
15 12
           :props="defaultProps"
16 13
           show-checkbox
17
-          node-key="id"
18
-          @check-change="handleCheckChange"/>
14
+          node-key="id"/>
19 15
       </el-form-item>
20 16
       <el-form-item>
21
-        <el-button type="primary" @click="submitForm('formInline')">立即创建</el-button>
17
+        <el-button type="primary" @click="submitForm('formInline')">添加权限</el-button>
22 18
       </el-form-item>
23 19
     </el-form>
24 20
   </div>
@@ -40,7 +36,8 @@ export default {
40 36
         pageSize: 10,
41 37
         menuArray:[],
42 38
         roleId:[],
43
-         empty:[]
39
+         empty:[],
40
+         userId:'',
44 41
 
45 42
       },
46 43
       defaultProps: {
@@ -67,6 +64,7 @@ export default {
67 64
     })
68 65
   },
69 66
   created() {
67
+    this.formInline.userId = this.$route.query.id
70 68
     this.dateQuery()
71 69
   },
72 70
   methods: {
@@ -116,8 +114,8 @@ export default {
116 114
        this.formInline.roleId.push(item.roleId)
117 115
        })
118 116
        this.addUserRole(this.formInline).then((data)=>{ 
119
-         if(data.phone === this.formInline.phone){
120
-             this.$router.push({ name: 'userRole' })
117
+         if(data.userId === this.formInline.userId){
118
+             this.$router.push({ name: 'sysuserlist' })
121 119
              return
122 120
              }
123 121
        })}