魏熙美 6 jaren geleden
bovenliggende
commit
7c96220d3a

+ 26
- 0
src/config/api.js Bestand weergeven

@@ -300,5 +300,31 @@ const apis = {
300 300
       url: `${commPrefix}/customerList`
301 301
     }
302 302
   },
303
+  sysRole: {
304
+    list: {
305
+      method: 'get',
306
+      url: `${commPrefix}/role`
307
+    },
308
+    getById: {
309
+      method: 'get',
310
+      url: `${commPrefix}/roleById`
311
+    },
312
+    save: {
313
+      method: 'post',
314
+      url: `${commPrefix}/role`
315
+    },
316
+    update: {
317
+      method: 'put',
318
+      url: `${commPrefix}/role`
319
+    },
320
+    menu: {
321
+      method: 'get',
322
+      url: `${commPrefix}/menus`
323
+    },
324
+    deleteMenu: {
325
+      method: 'delete',
326
+      url: `${commPrefix}/role`
327
+    }
328
+  }
303 329
 }
304 330
 export default apis

+ 3
- 1
src/store/index.js Bestand weergeven

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

+ 1
- 1
src/store/modules/content.js Bestand weergeven

@@ -25,7 +25,7 @@ export default {
25 25
     },
26 26
     addContent ({ commit }, payload) {
27 27
       const { onSuccess } = payload
28
-      const api = lodash.get(apis, 'content.add')
28
+      const api = lodash.get(apis, 'content.edi.vue')
29 29
       interact(api, payload.detail).then((data) => {
30 30
         commit('appendList', data)
31 31
         if (onSuccess) {

+ 1
- 1
src/store/modules/firstpage.js Bestand weergeven

@@ -39,7 +39,7 @@ export default {
39 39
     },
40 40
     addFirstPage ( _, payload) {
41 41
       const { onSuccess } = payload
42
-      const api = lodash.get(apis, 'firstpage.add')
42
+      const api = lodash.get(apis, 'firstpage.edi.vue')
43 43
       interact(api, payload.detail).then((data) => {
44 44
         onSuccess(data)
45 45
       })

+ 1
- 1
src/store/modules/management.js Bestand weergeven

@@ -20,7 +20,7 @@ export default {
20 20
       })
21 21
     },
22 22
     addManagement ({ commit }, payload) {
23
-      const api = replaceApiParams(lodash.get(apis, 'management.add'), payload)
23
+      const api = replaceApiParams(lodash.get(apis, 'management.edi.vue'), payload)
24 24
       interact(api).then((data) => {
25 25
         commit('updateManagement', data)
26 26
       })

+ 1
- 1
src/store/modules/notice.js Bestand weergeven

@@ -34,7 +34,7 @@ export default {
34 34
     },
35 35
     addNotice ( _, payload) {
36 36
       const { onSuccess } = payload
37
-      const api = lodash.get(apis, 'notice.add')
37
+      const api = lodash.get(apis, 'notice.edi.vue')
38 38
       interact(api, payload.detail).then((data) => {
39 39
         onSuccess(data)
40 40
       })

+ 1
- 1
src/store/modules/person.js Bestand weergeven

@@ -98,7 +98,7 @@ export default {
98 98
     },
99 99
     addPerson ( _, payload) {
100 100
       const { onSuccess } = payload
101
-      const api = lodash.get(apis, 'person.add')
101
+      const api = lodash.get(apis, 'person.edi.vue')
102 102
       interact(api, payload.detail).then((data) => {
103 103
         onSuccess(data)
104 104
       })

+ 87
- 0
src/store/modules/role.js Bestand weergeven

@@ -0,0 +1,87 @@
1
+import lodash from 'lodash'
2
+import { interact, replaceApiParams } from '../../utils'
3
+import apis from '../../config/api'
4
+
5
+export default {
6
+    namespaced: true,
7
+    state: {
8
+        data: [],
9
+        menus: [],
10
+    },
11
+    mutations: {
12
+        setList(state, payload) {
13
+            state.data = payload
14
+        },
15
+        setMenus(state, payload) {
16
+            state.menus = payload
17
+        }
18
+    },
19
+    actions: {
20
+        GetList({ commit }, payload) {
21
+            return new Promise((resolve, reject) => {
22
+                const api = lodash.get(apis,'sysRole.list')
23
+                interact(api, payload).then((data) => {
24
+                    commit('setList', data)
25
+                    resolve(data)
26
+                }).catch(()=>{
27
+                    reject()
28
+                })
29
+
30
+            })
31
+        },
32
+        AddRole( _, payload) {
33
+            return new Promise((resolve, reject) => {
34
+                const api = lodash.get(apis,'sysRole.save')
35
+                interact(api, payload).then((data)=> {
36
+                    resolve(data)
37
+                }).catch(()=>{
38
+                    reject()
39
+                })
40
+            })
41
+        },
42
+        GetMenus({ commit }) {
43
+            return new Promise((resolve, reject) => {
44
+                const api = lodash.get(apis, 'sysRole.menu')
45
+                interact(api).then((data) => {
46
+                    resolve(data)
47
+                    commit('setMenus', data)
48
+                }).catch(() => {
49
+                    reject()
50
+                })
51
+            })
52
+        },
53
+        GetById(_, payload) {
54
+            return new Promise((resolve, reject) => {
55
+                const api = lodash.get(apis,'sysRole.getById')
56
+                interact(api, payload).then((data) => {
57
+                    resolve(data)
58
+                }).catch(()=>{
59
+                    reject()
60
+                })
61
+
62
+            })
63
+        },
64
+        UpdateRole(_, payload) {
65
+            return new Promise((resolve, reject) => {
66
+                const api = lodash.get(apis,'sysRole.update')
67
+                interact(api, payload).then((data) => {
68
+                    resolve(data)
69
+                }).catch(()=>{
70
+                    reject()
71
+                })
72
+
73
+            })
74
+        },
75
+        DeleteMenu(_, payload) {
76
+            return new Promise((resolve, reject) => {
77
+                const api = lodash.get(apis,'sysRole.deleteMenu')
78
+                interact(api, payload).then((data) => {
79
+                    resolve(data)
80
+                }).catch(()=>{
81
+                    reject()
82
+                })
83
+
84
+            })
85
+        },
86
+    }
87
+}

+ 1
- 1
src/store/modules/sysuser.js Bestand weergeven

@@ -60,7 +60,7 @@ export default {
60 60
     },
61 61
     addSysUser ( _, payload) {
62 62
       const dtStr = window.JSON.stringify(payload)
63
-      const api = lodash.get(apis, 'sysuser.add')
63
+      const api = lodash.get(apis, 'sysuser.edi.vue')
64 64
       return interact(api, dtStr)
65 65
     },
66 66
     editSysUser ( _, payload) {

+ 1
- 1
src/store/modules/type.js Bestand weergeven

@@ -41,7 +41,7 @@ export default {
41 41
     },
42 42
     addType (_, payload) {
43 43
       const { onSuccess } = payload
44
-      const api = lodash.get(apis, 'type.add')
44
+      const api = lodash.get(apis, 'type.edi.vue')
45 45
       interact(api, payload.detail).then((data) => {
46 46
         onSuccess(data)
47 47
       })

+ 1
- 1
src/store/modules/words.js Bestand weergeven

@@ -42,7 +42,7 @@ export default {
42 42
     },
43 43
     addWords ( _, payload) {
44 44
       const { onSuccess } = payload
45
-      const api = lodash.get(apis, 'words.add')
45
+      const api = lodash.get(apis, 'words.edi.vue')
46 46
       interact(api, payload.detail).then((data) => {
47 47
         onSuccess(data)
48 48
       })

+ 18
- 0
src/views/index.js Bestand weergeven

@@ -45,6 +45,24 @@ const pages = [
45 45
           title: '角色管理',
46 46
         },
47 47
       },
48
+      {
49
+        path: 'sysuser/role/add',
50
+        name: 'role-add',
51
+        component: () => import('./sysuser/role/add/add.vue'),
52
+        meta: {
53
+          menuShow: false,
54
+          title: '角色添加',
55
+        },
56
+      },
57
+      {
58
+        path: 'sysuser/role/edi',
59
+        name: 'role-edi',
60
+        component: () => import('./sysuser/role/edi/edi.vue'),
61
+        meta: {
62
+          menuShow: false,
63
+          title: '角色修改',
64
+        },
65
+      },
48 66
       {
49 67
         path: 'device',
50 68
         name: 'devicelist',

+ 76
- 0
src/views/sysuser/role/add/add.vue Bestand weergeven

@@ -0,0 +1,76 @@
1
+<template>
2
+    <div id="root">
3
+        <el-form ref="form" :model="form" label-width="80px">
4
+            <el-form-item label="角色名称">
5
+                <el-input v-model="form.roleName"></el-input>
6
+            </el-form-item>
7
+            <el-form-item label="菜单权限">
8
+                <el-tree
9
+                        :data="menus"
10
+                        show-checkbox
11
+                        node-key="menuId"
12
+                        ref="tree"
13
+                        :props="defaultProps">
14
+                </el-tree>
15
+            </el-form-item>
16
+            <el-form-item>
17
+                <el-button type="success" @click="onSubmit">提交</el-button>
18
+            </el-form-item>
19
+        </el-form>
20
+    </div>
21
+</template>
22
+
23
+<script>
24
+import { createNamespacedHelpers } from 'vuex'
25
+const {mapState: mapSysRoleState, mapActions: mapSysRoleActions } = createNamespacedHelpers('sysyrole')
26
+
27
+export default {
28
+  name: "addRole",
29
+  data() {
30
+      return {
31
+          form: {
32
+              roleName: '',
33
+              menuIds: []
34
+          },
35
+          defaultProps: {
36
+              label: 'menuName',
37
+              children: 'children'
38
+          }
39
+      }
40
+  },
41
+  computed: {
42
+      ...mapSysRoleState({
43
+          menus: x => x.menus
44
+      })
45
+  },
46
+  methods: {
47
+    ...mapSysRoleActions([
48
+        'GetMenus',
49
+        'AddRole'
50
+    ]),
51
+    getCheckedNodes() {
52
+      let idSet = new Set();
53
+      const checkedNodes = this.$refs.tree.getCheckedNodes();
54
+      checkedNodes.map((item,index) => {
55
+          idSet.add(item.menuId)
56
+          idSet.add(item.menuPid)
57
+      })
58
+
59
+        for (let [value] of idSet.entries()) this.form.menuIds.push(value);
60
+
61
+    },
62
+    onSubmit() {
63
+        this.getCheckedNodes()
64
+        this.AddRole(this.form)
65
+        this.$router.go(-1)
66
+    }
67
+  },
68
+  created() {
69
+      this.GetMenus()
70
+  }
71
+}
72
+</script>
73
+
74
+<style scoped>
75
+
76
+</style>

+ 98
- 0
src/views/sysuser/role/edi/edi.vue Bestand weergeven

@@ -0,0 +1,98 @@
1
+<template>
2
+    <div id="root">
3
+        <el-form ref="form" :model="form" label-width="80px">
4
+            <el-form-item label="角色名称">
5
+                <el-input v-model="form.roleName"></el-input>
6
+            </el-form-item>
7
+            <el-form-item label="菜单权限">
8
+                <el-tree
9
+                        :data="menus"
10
+                        show-checkbox
11
+                        node-key="menuId"
12
+                        ref="tree"
13
+                        :default-checked-keys="checkedMenuKeys"
14
+                        :props="defaultProps">
15
+                </el-tree>
16
+            </el-form-item>
17
+            <el-form-item>
18
+                <el-button type="success" @click="onSubmit">提交</el-button>
19
+            </el-form-item>
20
+        </el-form>
21
+    </div>
22
+</template>
23
+
24
+<script>
25
+import { createNamespacedHelpers } from 'vuex'
26
+const {mapState: mapSysRoleState, mapActions: mapSysRoleActions } = createNamespacedHelpers('sysyrole')
27
+
28
+export default {
29
+  name: "ediRole",
30
+  data() {
31
+      return {
32
+          form: {
33
+              roleName: '',
34
+              roleId: '',
35
+              menuIds: []
36
+          },
37
+          defaultProps: {
38
+              label: 'menuName',
39
+              children: 'children'
40
+          },
41
+          checkedMenuKeys: [] // 默认勾选
42
+      }
43
+  },
44
+  computed: {
45
+      ...mapSysRoleState({
46
+          menus: x => x.menus
47
+      })
48
+  },
49
+  methods: {
50
+    ...mapSysRoleActions([
51
+        'GetMenus',
52
+        'AddRole',
53
+        'GetById',
54
+        'UpdateRole'
55
+    ]),
56
+    getCheckedNodes() {
57
+      let idSet = new Set();
58
+      const checkedNodes = this.$refs.tree.getCheckedNodes();
59
+      checkedNodes.map((item,index) => {
60
+          idSet.add(item.menuId)
61
+      })
62
+
63
+        for (let [value] of idSet.entries()) this.form.menuIds.push(value);
64
+
65
+    },
66
+    onSubmit() {
67
+        this.getCheckedNodes()
68
+        this.UpdateRole(this.form)
69
+        this.$router.go(-1)
70
+    },
71
+    getByRoleId() {
72
+        this.GetById({ roleId: this.form.roleId }).then((res) => {
73
+            this.form.roleId = res.roleId
74
+            this.form.roleName = res.roleName
75
+
76
+            this.menusParsing(res.menuList)
77
+        })
78
+    },
79
+    menusParsing(array) {
80
+        array.map((item,index) => {
81
+            this.checkedMenuKeys.push(item.menuId)
82
+            if (item.children !== null) {
83
+                this.menusParsing(item.children)
84
+            }
85
+        })
86
+    }
87
+  },
88
+  created() {
89
+      this.GetMenus()
90
+      this.form.roleId = this.$route.query.id
91
+      this.getByRoleId()
92
+  }
93
+}
94
+</script>
95
+
96
+<style scoped>
97
+
98
+</style>

+ 66
- 45
src/views/sysuser/role/list.vue Bestand weergeven

@@ -2,31 +2,45 @@
2 2
   <div id="root">
3 3
     <el-form :inline="true" :model="formInline" class="demo-form-inline">
4 4
       <el-form-item label="角色名称">
5
-        <el-input v-model="formInline.customerName" placeholder="角色名称"></el-input>
5
+        <el-input v-model="formInline.roleName" placeholder="角色名称"></el-input>
6 6
       </el-form-item> 
7 7
       <el-form-item>
8 8
         <el-button type="primary" @click="onSubmit">查询</el-button>
9 9
         <el-button type="info" @click="clear">重置</el-button>
10 10
       </el-form-item>
11 11
     </el-form>
12
+    <div style="margin-bottom: 20px;">
13
+<!--      <router-link :to="{name: 'role-add'}" tag="el-button">添加</router-link>-->
14
+
15
+      <el-button type="success" @click="addRole">添加</el-button>
16
+      <el-button type="warning" @click="updateRole">修改</el-button>
17
+      <el-button type="danger" @click="deleteRole">删除</el-button>
18
+    </div>
12 19
     <el-table
13
-    :data="FollowupList"
20
+    :data="roleDataList.records"
21
+    @selection-change="handleSelectionChange"
14 22
     border>
23
+      <el-table-column
24
+              type="selection"
25
+              width="55"/>
15 26
     <el-table-column
16
-      prop="customerId"
27
+      prop="roleId"
17 28
       align='center'
18
-      label="角色名称">
19
-    </el-table-column>
29
+      label="编号"/>
20 30
     <el-table-column
21
-      prop="customerName"
31
+      prop="roleName"
22 32
       align='center'
23
-      label="角色状态">
24
-    </el-table-column>
33
+      label="角色名称"/>
25 34
     <el-table-column
26
-      prop="phone"
35
+      prop="roleStatus"
27 36
       align='center'
28
-      label="创建时间">
37
+      label="角色状态">
38
+      <template slot-scope="scope">{{ scope.row.status === 1 ? '有效' : '无效' }}</template>
29 39
     </el-table-column>
40
+    <el-table-column
41
+       prop="createDate"
42
+       align='center'
43
+       label="创建时间"/>
30 44
   </el-table>
31 45
     <el-pagination
32 46
             style="margin-top:50px;float:right"
@@ -35,6 +49,7 @@
35 49
             :current-page="formInline.pageNum"
36 50
             :page-sizes="[1,10, 20, 30, 40]"
37 51
             :page-size="formInline.pageSize"
52
+            :total="roleDataList.total"
38 53
             layout="total, sizes, prev, pager, next, jumper"
39 54
             >
40 55
             <!-- :total="FollowupList.total || 0" -->
@@ -43,39 +58,38 @@
43 58
 </template>
44 59
 <script>
45 60
 import { createNamespacedHelpers } from 'vuex'
46
-const {mapState: mapUserManagementState, mapActions: mapUserManagementActions } = createNamespacedHelpers('sysuser')
61
+const {mapState: mapSysRoleState, mapActions: mapSysRoleActions } = createNamespacedHelpers('sysyrole')
47 62
 
48 63
 export default {
49 64
   name: 'followup-index',
50 65
   data() {
51 66
     return {
52 67
       formInline: {
53
-        customerName:'',
54
-        personName: '',
55
-        phone: '',
56
-        platNumber: '',
68
+        roleName: '',
57 69
         pageNum: 1,
58 70
         pageSize: 10
59
-      }
71
+      },
72
+      ids: []
60 73
     }
61 74
   },
62 75
   computed: {
63
-    ...mapUserManagementState({
64
-    FollowupList: x => x.followup
76
+    ...mapSysRoleState({
77
+    roleDataList: x => x.data
65 78
     })
66 79
   },
67 80
   created() {
68 81
     this.getPage()
69 82
   },
70 83
   methods: {
71
-    ...mapUserManagementActions([
72
-      'roleManagementList',
84
+    ...mapSysRoleActions([
85
+      'GetList',
86
+      'DeleteMenu'
73 87
     ]),
74 88
     onSubmit() {
75 89
       this.getPage()
76 90
     },
77 91
     getPage() {
78
-       this.roleManagementList(this.formInline)
92
+       this.GetList(this.formInline)
79 93
       // window.console.log(this.$store)
80 94
       // this.$store.commit('security/foo')
81 95
       // this.$store.dispatch('security/getSecurity')
@@ -90,35 +104,42 @@ export default {
90 104
       this.formInline.pageNum = val
91 105
       this.getPage()
92 106
     },
93
-    favorHouse (msg) {
94
-      if (msg == '1') {
95
-        return "三房"
96
-      } else if(msg == '2'){
97
-        return "四房"
98
-      }else if(msg == '3'){
99
-        return "四房以上"
100
-      }
101
-    },
102
-    favorLevel (msg) {
103
-      if (msg == 'A') {
104
-        return "买房"
105
-      } else if(msg == 'B'){
106
-        return "有意向金"
107
-      }else if(msg == 'C'){
108
-        return "考虑中"
109
-      }else if(msg == 'D'){
110
-        return "不买"
111
-      }
112
-    },
113 107
     clear(){
114
-      this.formInline.customerName = ''
115
-      this.formInline.phone = ''
116
-      this.formInline.platNumber = ''
108
+      this.formInline.roleName = ''
117 109
       this.formInline.pageNum = 1
118 110
       this.formInline.pageSize = 10
119 111
       this.getPage()
112
+    },
113
+    addRole() {
114
+      this.$router.push({name: 'role-add'})
115
+    },
116
+    deleteRole() {
117
+      if (this.ids.length <= 0) {
118
+        this.$message.error("请至少选择一行")
119
+        return
120
+      }
121
+
122
+      this.DeleteMenu({ menuIds: this.ids })
123
+      this.getPage()
124
+    },
125
+    updateRole() {
126
+      if (this.ids.length > 1) {
127
+        this.$message.error("只能针对一行操作")
128
+        return
129
+      }
130
+      if (this.ids.length <= 0) {
131
+        this.$message.error("请至少选择一行")
132
+        return
133
+      }
134
+
135
+      this.$router.push({name: 'role-edi', query: { id: this.ids[0] }})
136
+    },
137
+    handleSelectionChange(val) {
138
+      this.ids = []
139
+      val.map((item,index)=> {
140
+        this.ids.push(item.roleId);
141
+      })
120 142
     }
121
-   
122 143
   }
123 144
 }
124 145
 </script>