Просмотр исходного кода

Merge branch 'master' of http://git.shengws.com/csx/Vue_New

csx 4 лет назад
Родитель
Сommit
70bdb82af1

+ 2 - 2
config/dev.env.js Просмотреть файл

@@ -6,8 +6,8 @@
6 6
 module.exports = {
7 7
   NODE_ENV: '"development"',
8 8
   ENV_CONFIG: '"dev"',
9
-  BASE_API:  '"http://api.xt.test.sgjyun.com"',// //http://api.xt.test.sgjyun.com http://112.74.16.180:9527,////'"http://localhost:9529"',
10
-  //BASE_API:'"http://localhost:9529"',
9
+  BASE_API:  '"http://new_mobile.xt.api.sgjyun.com"',// //http://api.xt.test.sgjyun.com http://112.74.16.180:9527,////'"http://localhost:9529"',
10
+  // BASE_API:'"http://localhost:9531"',
11 11
   SSO_HOST: '"http://testsso.sgjyun.com"',
12 12
   SRCM_HOST: '"http://test1.sgjyun.com"',
13 13
   XT_HOST: '"http://xt.test.sgjyun.com"',

+ 1 - 1
config/index.js Просмотреть файл

@@ -20,7 +20,7 @@ module.exports = {
20 20
     // host: 'xt.test.sgjyun.com',
21 21
     // host: 'xt.kuyicloud.com',
22 22
     host: 'xt.test.sgjyun.com',
23
-    //host:'localhost',
23
+    // host:'localhost',
24 24
     port: 9528, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
25 25
     autoOpenBrowser: true,
26 26
     errorOverlay: true,

+ 1 - 1
config/sit.env.js Просмотреть файл

@@ -1,7 +1,7 @@
1 1
 module.exports = {
2 2
   NODE_ENV: '"production"',
3 3
   ENV_CONFIG: '"sit"',
4
-  BASE_API: '"http://api.xt.test.sgjyun.com"',
4
+  BASE_API: '"http://new_mobile.xt.api.sgjyun.com"',
5 5
 
6 6
   SSO_HOST: '"https://testsso.sgjyun.com"',
7 7
   SRCM_HOST: '"https://test1.sgjyun.com"',

+ 20 - 0
src/api/config.js Просмотреть файл

@@ -90,5 +90,25 @@ export function updateSystemPrescription(id,params) {
90 90
 }
91 91
 
92 92
 
93
+export function getOrgs() {
94
+  return request({
95
+    url: '/api/public/orgs',
96
+    method: 'get',
97
+  })
98
+}
99
+
100
+
101
+
102
+export function changeOrg(params) {
103
+  return request({
104
+    url: '/api/org/change',
105
+    method: 'post',
106
+    params:params,
107
+  })
108
+}
109
+
110
+
111
+
112
+
93 113
 
94 114
 

+ 62 - 65
src/api/role/role.js Просмотреть файл

@@ -1,106 +1,103 @@
1 1
 import request from '@/utils/request'
2 2
 
3 3
 export function getRoles(page) {
4
-    const params = {
5
-        page: page,
6
-    }
7
-    return request({
8
-        url: '/api/roles',
9
-        method: 'get',
10
-        params: params,
11
-    })
4
+  const params = {
5
+    page: page
6
+  }
7
+  return request({
8
+    url: '/api/roles',
9
+    method: 'get',
10
+    params: params
11
+  })
12 12
 }
13 13
 
14 14
 export function addRole(name, intro) {
15
-    const params = {
16
-        name: name,
17
-        intro: intro
18
-    }
19
-    return request({
20
-        url: '/api/role/create',
21
-        method: 'post',
22
-        params: params,
23
-    })
15
+  const params = {
16
+    name: name,
17
+    intro: intro
18
+  }
19
+  return request({
20
+    url: '/api/role/create',
21
+    method: 'post',
22
+    params: params
23
+  })
24 24
 }
25 25
 
26 26
 export function modifyRole(role_id, name, intro) {
27
-    const params = {
28
-        role_id: role_id,
29
-        name: name,
30
-        intro: intro
31
-    }
32
-    return request({
33
-        url: '/api/role/modify',
34
-        method: 'post',
35
-        params: params,
36
-    })
27
+  const params = {
28
+    role_id: role_id,
29
+    name: name,
30
+    intro: intro
31
+  }
32
+  return request({
33
+    url: '/api/role/modify',
34
+    method: 'post',
35
+    params: params
36
+  })
37 37
 }
38 38
 
39 39
 export function setRoleStatus(role_id, enable) {
40
-    const params = {
41
-        role_id: role_id,
42
-        enable: enable,
43
-    }
44
-    return request({
45
-        url: '/api/role/setstatus',
46
-        method: 'post',
47
-        params: params,
48
-    })
40
+  const params = {
41
+    role_id: role_id,
42
+    enable: enable
43
+  }
44
+  return request({
45
+    url: '/api/role/setstatus',
46
+    method: 'post',
47
+    params: params
48
+  })
49 49
 }
50 50
 
51 51
 export function getEditPurviewInitData(role_id) {
52
-    const params = {
53
-        role_id: role_id,
54
-    }
55
-    return request({
56
-        url: '/role/purview/editinit',
57
-        method: 'get',
58
-        params: params,
59
-    })
52
+  const params = {
53
+    role_id: role_id
54
+  }
55
+  return request({
56
+    url: '/role/purview/editinit',
57
+    method: 'get',
58
+    params: params
59
+  })
60 60
 }
61 61
 
62
-export function editPurview(role_id, purview_ids) {
63
-    const params = {
64
-        role_id: role_id,
65
-        purview_ids: purview_ids,
66
-    }
67
-    return request({
68
-        url: '/role/purview/edit',
69
-        method: 'post',
70
-        params: params,
71
-    })
62
+export function editPurview(role_id, purview_ids, func_purview_ids) {
63
+  const params = {
64
+    role_id: role_id,
65
+    purview_ids: purview_ids,
66
+    func_purview_ids: func_purview_ids
67
+  }
68
+  return request({
69
+    url: '/role/purview/edit',
70
+    method: 'post',
71
+    params: params
72
+  })
72 73
 }
73 74
 
74
-
75 75
 export function getRolesList() {
76 76
   return request({
77 77
     url: '/api/roles/list',
78
-    method: 'get',
78
+    method: 'get'
79 79
   })
80 80
 }
81 81
 
82 82
 export function getStaffsList() {
83 83
   return request({
84 84
     url: '/api/staff',
85
-    method: 'get',
85
+    method: 'get'
86 86
   })
87 87
 }
88 88
 
89
-
90
-export function AddUserRole(params){
89
+export function AddUserRole(params) {
91 90
   return request({
92
-    url:'/api/role/addStaff',
93
-    method:'post',
94
-    params:params,
91
+    url: '/api/role/addStaff',
92
+    method: 'post',
93
+    params: params
95 94
   })
96 95
 }
97 96
 
98
-
99
-
100 97
 export function getRoleStaff() {
101 98
   return request({
102 99
     url: '/api/role/staff',
103
-    method: 'get',
100
+    method: 'get'
104 101
   })
105 102
 }
106 103
 

+ 8 - 8
src/router/modules/systems.js Просмотреть файл

@@ -59,14 +59,14 @@ export default {
59 59
     hidden: true,
60 60
     is_menu: false
61 61
   },
62
-  {
63
-    path: '/role/admin/specialpermission',
64
-    component: () => import('@/xt_pages/role/special_permission'),
65
-    name: 'special_permission_manage',
66
-    meta: {
67
-      title: 'special_permission_manage'
68
-    }
69
-  },
62
+  // {
63
+  //   path: '/role/admin/specialpermission',
64
+  //   component: () => import('@/xt_pages/role/special_permission'),
65
+  //   name: 'special_permission_manage',
66
+  //   meta: {
67
+  //     title: 'special_permission_manage'
68
+  //   }
69
+  // },
70 70
   {
71 71
     path: '/data/dictionary',
72 72
     component: () => import('@/xt_pages/data/index'),

+ 96 - 24
src/views/layout/components/Navbar.vue Просмотреть файл

@@ -53,7 +53,7 @@
53 53
             </el-dropdown-item>
54 54
             <el-dropdown-item divided command="logout">
55 55
               {{$t('navbar.logOut')}}
56
-              
56
+
57 57
             </el-dropdown-item>
58 58
           </el-dropdown-menu>
59 59
         </el-dropdown>
@@ -64,23 +64,19 @@
64 64
       </div>
65 65
     </el-menu>-->
66 66
     <div class="dropdownBox">
67
-      <el-dropdown trigger="click">
67
+      <el-dropdown trigger="click" @command="handleOrgCommand">
68 68
         <span class="el-dropdown-link">
69
-          {{this.$store.getters.xt_user.org.org_name}}
69
+          {{ org_name }}
70 70
           <i class="el-icon-arrow-down el-icon--right"></i>
71 71
         </span>
72 72
         <el-dropdown-menu slot="dropdown">
73
-          <el-dropdown-item icon="el-icon-plus">黄金糕</el-dropdown-item>
74
-          <el-dropdown-item icon="el-icon-circle-plus">狮子头</el-dropdown-item>
75
-          <el-dropdown-item icon="el-icon-circle-plus-outline">螺蛳粉</el-dropdown-item>
76
-          <el-dropdown-item icon="el-icon-check">双皮奶</el-dropdown-item>
77
-          <el-dropdown-item icon="el-icon-circle-check">蚵仔煎</el-dropdown-item>
73
+          <el-dropdown-item   icon="el-icon-plus" v-for="(item,index) in orgs" :key="index"  :command="item.id">{{item.org_name}}</el-dropdown-item>
78 74
         </el-dropdown-menu>
79 75
       </el-dropdown>
80 76
     </div>
81 77
     <div class="navRight">
82
-      <el-input placeholder="搜索患者透析号/姓名/首拼" prefix-icon="el-icon-search" v-model="input2"></el-input>
83
-      <div style="color: #b2b2b3;">通知中心</div>
78
+      <!-- <el-input placeholder="搜索患者透析号/姓名/首拼" prefix-icon="el-icon-search" v-model="input2"></el-input>
79
+      <div style="color: #b2b2b3;">通知中心</div> -->
84 80
       <div class="right-menu">
85 81
         <el-dropdown
86 82
           class="avatar-container right-menu-item"
@@ -89,18 +85,30 @@
89 85
         >
90 86
           <div class="avatar-wrapper">
91 87
             <img class="user-avatar" :src="avater" />
92
-            <span class="user-title">{{ this.$store.getters.xt_user.user.user_name }}</span>
88
+            <span class="user-title">{{
89
+              this.$store.getters.xt_user.user.user_name
90
+            }}</span>
93 91
             <i class="el-icon-caret-bottom"></i>
94 92
           </div>
95 93
           <el-dropdown-menu slot="dropdown">
96
-            <el-dropdown-item command="modifyUserInfoAction">修改个人信息</el-dropdown-item>
97
-            <el-dropdown-item command="modifyOrgInfoAction">机构信息</el-dropdown-item>
98
-            <el-dropdown-item divided command="logout">{{$t('navbar.logOut')}}</el-dropdown-item>
94
+            <el-dropdown-item command="modifyUserInfoAction"
95
+              >修改个人信息</el-dropdown-item
96
+            >
97
+            <el-dropdown-item command="modifyOrgInfoAction"
98
+              >机构信息</el-dropdown-item
99
+            >
100
+            <el-dropdown-item divided command="logout">{{
101
+              $t("navbar.logOut")
102
+            }}</el-dropdown-item>
99 103
           </el-dropdown-menu>
100 104
         </el-dropdown>
101 105
 
102
-        <modify-user-info-dialog ref="modify_user_info_dialog"></modify-user-info-dialog>
103
-        <modify-org-info-dialog ref="modify_org_info_dialog"></modify-org-info-dialog>
106
+        <modify-user-info-dialog
107
+          ref="modify_user_info_dialog"
108
+        ></modify-user-info-dialog>
109
+        <modify-org-info-dialog
110
+          ref="modify_org_info_dialog"
111
+        ></modify-org-info-dialog>
104 112
       </div>
105 113
       <div>
106 114
         <i class="el-icon-question"></i>
@@ -117,16 +125,26 @@ import { mapGetters } from "vuex";
117 125
 import Screenfull from "@/components/Screenfull";
118 126
 import ModifyUserInfoDialog from "@/xt_pages/home/modify_user_info_dialog";
119 127
 import ModifyOrgInfoDialog from "@/xt_pages/home/modifyOrgInfoDialog";
120
-
128
+import { getFiledConfigList, setFiledConfigList } from '@/utils/data_config' // getConfigList from sessionStorage
129
+import {
130
+  getAdminUserInfoCache,
131
+  cacheAdminUserInfo,
132
+  removeAdminUserInfoCache
133
+} from '@/utils/admin_info_cache'
134
+import {
135
+  getOrgs,changeOrg
136
+} from '@/api/config'
121 137
 export default {
122 138
   data() {
123 139
     return {
140
+      orgs:[],
141
+      org_id:this.$store.getters.xt_user.org.id,
142
+      org_name:this.$store.getters.xt_user.org.org_name,
143
+
124 144
       // scrm_role_exist: $store.getters.xt_user.scrm_role_exist
125 145
     };
126 146
   },
127 147
   components: {
128
-    // Breadcrumb,
129
-    // Hamburger,
130 148
     Screenfull,
131 149
     ModifyUserInfoDialog,
132 150
     ModifyOrgInfoDialog
@@ -141,9 +159,47 @@ export default {
141 159
     }
142 160
   },
143 161
   methods: {
144
-    // toggleSideBar() {
145
-    //   this.$store.dispatch("toggleSideBar");
146
-    // },
162
+    handleOrgCommand(org_id){
163
+      let params = {
164
+        org_id: org_id
165
+      }
166
+      changeOrg(params).then(response => {
167
+        if (response.data.state === 1) {
168
+          window.location.reload()
169
+
170
+          this.$message.success('切换成功')
171
+          let data = response.data.data
172
+          this.org_id = data.org.id
173
+          this.org_name = data.org.org_name
174
+
175
+          this.commit('SET_CURRENT_INFO', {
176
+            user: data.user,
177
+            cur_org_id: data.current_org_id,
178
+            cur_app_id: data.current_app_id,
179
+            org: data.org,
180
+            subscibe: data.subscibe,
181
+            template_info:data.template_info,
182
+          })
183
+
184
+          this.commit('SET_URLFORS', {
185
+            urlfors: data.urlfors
186
+          })
187
+
188
+          this.commit('SET_FILEDS', {
189
+            fileds: data.fileds
190
+          })
191
+          setFiledConfigList(JSON.stringify(data.fileds))
192
+          cacheAdminUserInfo(JSON.stringify(data))
193
+
194
+
195
+        }else{
196
+          this.$message.success(response.data.msg)
197
+        }
198
+      }).catch(e => {
199
+        // this.$message.success("网络异常")
200
+      });
201
+    },
202
+
147 203
     handleCommand(command) {
148 204
       switch (command) {
149 205
         case "modifyUserInfoAction":
@@ -190,7 +246,23 @@ export default {
190 246
       );
191 247
     }
192 248
   },
193
-  created() {}
249
+  created() {
250
+    this.org_id = 12
251
+
252
+    getOrgs().then(response => {
253
+      if (response.data.state === 1) {
254
+          this.orgs = response.data.data.orgs;
255
+          for (let i =0; i < this.orgs.length; i++){
256
+            if (this.orgs[i].id == this.org_id){
257
+              this.org_name = this.orgs[i].org_name
258
+            }
259
+          }
260
+      }
261
+    });
262
+
263
+
264
+
265
+  }
194 266
 };
195 267
 </script>
196 268
 
@@ -213,7 +285,7 @@ export default {
213 285
     display: flex;
214 286
     align-items: center;
215 287
     justify-content: space-between;
216
-    width: 540px;
288
+    width: 200px;
217 289
     margin-right: 10px;
218 290
     .right-menu {
219 291
       float: right;

+ 17 - 4
src/xt_pages/role/components/AdminInfoForm.vue Просмотреть файл

@@ -138,7 +138,6 @@
138 138
         }
139 139
          // let localthis.$store.getters.xt_user.user.id
140 140
         let local_user_id = this.$store.getters.xt_user.user.id
141
-        local_user_id = 597
142 141
         this.form.id = this.admin_id
143 142
         if (this.admin_id === 0) {
144 143
           let tempForm = {
@@ -171,7 +170,7 @@
171 170
                 //如果当前用户是子管理员则,则需要将子管理员角色去除,因为子管理员不能添加子管理员
172 171
                 if(this.isSubSuperAdmin){
173 172
                   for (let i =0 ; i < this.roles.length; i++){
174
-                    if(this.roles[i].is_system == 1 && this.roles[i].role_name != "子管理员"){
173
+                    if(this.roles[i].is_system == 1 && this.roles[i].role_name == "子管理员"){
175 174
                       this.roles.splice(i, 1)
176 175
                       i--
177 176
                     }
@@ -181,6 +180,9 @@
181 180
 
182 181
 
183 182
 
183
+
184
+
185
+
184 186
                 // if (this.roles.length > 0) {
185 187
                 //   this.form.role = this.roles[0].id;
186 188
                 //   console.log("国庆快乐",this.form.role)
@@ -203,11 +205,17 @@
203 205
                 this.roles = []
204 206
                 this.roles.push(...resp.data.roles)
205 207
                 this.qntoken = resp.data.qntoken
208
+                var org = resp.data.org
209
+
206 210
 
207 211
                 var admin = resp.data.admin
208 212
                 this.form.name = admin.user_name
209 213
                 this.form.mobile = admin.admin.mobile
210 214
                 this.form.user_type = admin.user_type
215
+                if(admin.user_type == 1){
216
+
217
+                  this.form.user_type = ""
218
+                }
211 219
                 this.form.user_title = admin.user_title
212 220
                 this.form.role = admin.role_ids
213 221
                 this.form.role_ids = []
@@ -223,9 +231,9 @@
223 231
 
224 232
 
225 233
                 //如果当前用户是超级管理员而且编辑自己的信息
226
-                if(!this.isSubSuperAdmin && local_user_id == this.form.id){
234
+                if(this.isSubSuperAdmin || this.admin_id == org.creator){
227 235
                   for (let i =0 ; i < this.roles.length; i++){
228
-                    if(this.roles[i].is_system == 1 && this.roles[i].role_name != "子管理员"){
236
+                    if(this.roles[i].is_system == 1 && this.roles[i].role_name == "子管理员"){
229 237
                       this.roles.splice(i, 1)
230 238
                       i--
231 239
                     }
@@ -253,6 +261,11 @@
253 261
         }
254 262
         this.$refs.form.validate(valid => {
255 263
           if (valid) {
264
+            if(this.form.user_type == "" || this.form.user_type == 0 ){
265
+              this.$message.error("职称不能为空")
266
+              return
267
+            }
268
+
256 269
             this.loading = true
257 270
             if (this.form.id === 0) {
258 271
               this.form.role = this.form.role_ids.join(',')

+ 27 - 8
src/xt_pages/role/components/EditRole.vue Просмотреть файл

@@ -18,7 +18,7 @@
18 18
       <el-radio v-model="checked" label="1">从已有员工中选择</el-radio>
19 19
       <el-radio v-model="checked" label="2">新增员工</el-radio>
20 20
     </div>
21
-    <div v-if="checked == '1'" class="roleContent">
21
+    <div v-if="checked == '1'"   v-loading="loading" class="roleContent">
22 22
       <div class="roleContentLeft">
23 23
         <p style="color:#303133">选择:</p>
24 24
         <div class="chooseBox">
@@ -49,7 +49,7 @@
49 49
         </div>
50 50
       </div>
51 51
 
52
-      <div class="roleContentRight">
52
+      <div class="roleContentRight" v-loading="loading">
53 53
         <p style="color:#303133">已选:</p>
54 54
         <div class="chooseBox">
55 55
           <div class="hasChoosedOne" v-for="(item,index) in is_check_admin_user" :key="index">
@@ -115,7 +115,7 @@
115 115
     </div>
116 116
     <div slot="footer" class="dialog-footer">
117 117
       <el-button @click="hide">取 消</el-button>
118
-      <el-button type="primary" @click="submitAction()">保 存</el-button>
118
+      <el-button type="primary" :loading="submitLoading" @click="submitAction()">保 存</el-button>
119 119
     </div>
120 120
   </el-dialog>
121 121
 </template>
@@ -146,6 +146,8 @@
146 146
       }
147 147
 
148 148
       return {
149
+        submitLoading:false,
150
+        loading:true,
149 151
         form: {
150 152
           id: 0,
151 153
           name: '',
@@ -268,9 +270,7 @@
268 270
           .then(rs => {
269 271
             var resp = rs.data
270 272
             if (resp.state === 1) {
271
-
272 273
               this.admin_user = resp.data.admins
273
-
274 274
               for (let i = 0; i < this.admin_user.length; i++) {
275 275
                 if (this.admin_user[i].role_ids.length > 0) {
276 276
                   let isExist = -1
@@ -279,12 +279,10 @@
279 279
                   if (isExist >= 0) {
280 280
                     this.is_check_admin_user.push(this.admin_user[i])
281 281
                     this.admin_user.splice(i, 1)
282
-
283 282
                     i = i - 1
284 283
                   }
285 284
                 }
286 285
               }
287
-
288 286
               for (let i = 0; i < this.admin_user.length; i++) {
289 287
                 if (this.admin_user[i].user_id == resp.data.org.creator) {
290 288
 
@@ -292,8 +290,12 @@
292 290
                   i = i - 1
293 291
                 }
294 292
               }
293
+              this.loading = false
294
+
295 295
             } else {
296 296
               this.$message.error(resp.msg)
297
+              this.loading = false
298
+
297 299
             }
298 300
           })
299 301
           .catch(err => {
@@ -312,6 +314,7 @@
312 314
       },
313 315
       show(role_id) {
314 316
         this.clear()
317
+        this.loading = true
315 318
         this.checked = '1'
316 319
         this.visible = true
317 320
         this.role_id = role_id
@@ -340,20 +343,30 @@
340 343
             id: this.role_id,
341 344
             ids: this.checkedCities.join(',')
342 345
           }
346
+          this.submitLoading = true
347
+
343 348
           AddUserRole(params).then(response => {
344 349
             if (response.data.state === 1) {
345 350
               this.$message.success('添加成功')
346 351
               this.$emit('did-edit-role')
347 352
               this.hide()
353
+              this.submitLoading = false
348 354
 
349 355
             } else {
356
+              this.submitLoading = false
357
+
350 358
               this.$message.error(response.data.msg)
351 359
 
352 360
             }
353
-          })
361
+          }).catch(e => {
362
+            this.submitLoading = false
363
+
364
+
365
+          });
354 366
         } else {
355 367
           this.$refs.form.validate(valid => {
356 368
             if (valid) {
369
+              this.submitLoading = true
357 370
               if (this.form.id === 0) {
358 371
                 this.ruleForm.role = this.role_id
359 372
                 addAdmin(
@@ -366,8 +379,11 @@
366 379
                   this.ruleForm.position
367 380
                 )
368 381
                   .then(rs => {
382
+                    this.submitLoading = false
383
+
369 384
                     var resp = rs.data
370 385
                     if (resp.state === 1) {
386
+
371 387
                       this.$store.dispatch('DidChangeAdmins')
372 388
                       var _this = this
373 389
                       setTimeout(() => {
@@ -387,11 +403,14 @@
387 403
                     }
388 404
                   })
389 405
                   .catch(err => {
406
+                    this.submitLoading = false
407
+
390 408
                     this.loading = false
391 409
                     this.$message.error(err)
392 410
                   })
393 411
               }
394 412
             } else {
413
+              this.submitLoading = false
395 414
               return false
396 415
             }
397 416
           })

+ 286 - 146
src/xt_pages/role/components/PermissionSettings.vue Просмотреть файл

@@ -4,203 +4,343 @@
4 4
       <div class="roleName">
5 5
         <div class="roleNameLeft">
6 6
           <p>角色名称</p>
7
-          <el-input placeholder="请输入内容" v-model="input" :disabled="true"></el-input>
7
+          <el-input placeholder="请输入内容" v-model="role.name" :disabled="true"></el-input>
8 8
         </div>
9
-        <p style="color:#338AFB">删除该角色</p>
9
+        <p style="color:#338AFB" v-if="role.is_system == 0" @click="disableRoleAction(role.id)">删除该角色</p>
10 10
       </div>
11
-      <div class="roleMain">
12
-        <div class="roleMainLeft">
11
+      <div class="roleMain" >
12
+        <div class="roleMainLeft" >
13 13
           <p class="roletitle">选择权限</p>
14 14
           <div class="roleMainLeftBox">
15 15
             <!--<el-tree-->
16
-              <!--:props="defaultProps"-->
17
-              <!--:data="data"-->
18
-              <!--:default-checked-keys="data"-->
19
-              <!--node-key="id"-->
20
-              <!--ref="tree"-->
21
-              <!--default-expand-all-->
22
-              <!--show-checkbox-->
16
+            <!--:props="defaultProps"-->
17
+            <!--:data="data"-->
18
+            <!--:default-checked-keys="data"-->
19
+            <!--node-key="id"-->
20
+            <!--ref="tree"-->
21
+            <!--default-expand-all-->
22
+            <!--show-checkbox-->
23 23
             <!--&gt;-->
24
-              <!--&lt;!&ndash; <span class="custom-tree-node" slot-scope="{ node, data }">-->
25
-                                <!--<span>{{ data.name }}</span>-->
26
-              <!--</span>&ndash;&gt;-->
24
+            <!--&lt;!&ndash; <span class="custom-tree-node" slot-scope="{ node, data }">-->
25
+            <!--<span>{{ data.name }}</span>-->
26
+            <!--</span>&ndash;&gt;-->
27 27
             <!--</el-tree>-->
28
-            <el-tree :props="treeProps" :data="purviews" :default-checked-keys="default_checkeds" node-key="id" ref="tree" default-expand-all show-checkbox>
28
+            <el-tree  v-loading="loading" :props="treeProps" :data="purviews" :default-checked-keys="default_checkeds" node-key="id"
29
+                     ref="tree" default-expand-all show-checkbox>
29 30
                             <span class="custom-tree-node" slot-scope="{ node, data }">
30 31
                                 <span>{{ data.name }}</span>
31 32
                             </span>
32 33
             </el-tree>
33 34
           </div>
34 35
         </div>
35
-        <div class="roleMainRight">
36
-          <div class="hasChoose">已选择权限</div>
37
-          <el-tree :data="data" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
38
-        </div>
36
+        <!--<div class="roleMainRight">-->
37
+        <!--<div class="hasChoose">已选择权限</div>-->
38
+        <!--<el-tree-->
39
+        <!--:props="treeProps" :data="check_purviews"   node-key="id" ref="tree" default-expand-all-->
40
+
41
+        <!--&gt;</el-tree>-->
42
+        <!--</div>-->
39 43
       </div>
40 44
     </div>
45
+    <div slot="footer" class="dialog-footer">
46
+      <el-button @click="hide">取 消</el-button>
47
+      <el-button type="primary" @click="submitAction" :loading="submitLoading">保 存</el-button>
48
+    </div>
41 49
   </el-dialog>
42 50
 </template>
43 51
 
44
-
45 52
 <script>
46
-  import {getEditPurviewInitData, editPurview} from '@/api/role/role'
53
+  import { editPurview, getEditPurviewInitData, setRoleStatus } from '@/api/role/role'
47 54
 
48 55
   export default {
49
-  data() {
50
-    return {
51
-      visible: false,
52
-      role_id: 0,
53
-      purviews: [], // [{id, pid, name, childs}]
54
-      treeProps: {
55
-        label: "name",
56
-        children: "childs"
57
-      },
58
-      // role_purview_ids: '',
59
-      default_checkeds: [],
60
-      data: [
61
-        {
62
-          id: 1,
63
-          label: "一级 2",
64
-          children: [
65
-            {
66
-              id: 3,
67
-              label: "二级 2-1",
68
-              children: [
69
-                {
70
-                  id: 4,
71
-                  label: "三级 3-1-1"
72
-                },
73
-                {
74
-                  id: 5,
75
-                  label: "三级 3-1-2"
76
-                }
77
-              ]
78
-            },
79
-            {
80
-              id: 2,
81
-              label: "二级 2-2",
82
-              children: [
83
-                {
84
-                  id: 6,
85
-                  label: "三级 3-2-1"
86
-                },
87
-                {
88
-                  id: 7,
89
-                  label: "三级 3-2-2"
90
-                }
91
-              ]
92
-            }
93
-          ]
56
+    data() {
57
+      return {
58
+        visible: false,
59
+        loading: true,
60
+        submitLoading:false,
61
+        role_id: 0,
62
+        name: '',
63
+        role: {
64
+          name:"",
65
+        },
66
+        purviews: [],
67
+        treeProps: {
68
+          label: 'name',
69
+          children: 'childs'
70
+        },
71
+        default_checkeds: [],
72
+        check_purviews: [],
73
+        defaultProps: {
74
+          children: 'children',
75
+          label: 'label'
94 76
         }
95
-      ],
96
-      defaultProps: {
97
-        children: "children",
98
-        label: "label"
99
-      }
100
-    };
101
-  },
102
-  methods: {
103
-    show(role_id) {
104
-      this.visible = true;
105
-
106
-      var id = parseInt(role_id)
107
-      if (id <= 0) {
108
-        this.$message.error("参数错误")
109
-        return
110 77
       }
111
-      this.role_id = role_id
112
-      getEditPurviewInitData(this.role_id).then(rs => {
113
-        var resp = rs.data
114
-        if (resp.state === 1) {
115
-          this.purviews.push(...resp.data.purviews)
116
-          // 初始化默认选中项
117
-          var role_purview_ids = resp.data.role_purview_ids
118
-          var checkeds = []
119
-          if (role_purview_ids.length > 0) {
120
-            var ids = role_purview_ids.split(",")
121
-            this.purviews.forEach(purview => {
122
-              if (purview.childs != null && purview.childs.length > 0) {
123
-                purview.childs.forEach(child => {
124
-                  if (ids.indexOf(child.id+"") != -1) {
125
-                    checkeds.push(child.id)
78
+    },
79
+    methods: {
80
+      disableRoleAction: function(id) {
81
+        this.$msgbox({
82
+          title: '提示',
83
+          message: '是否确定要移除该角色',
84
+          showCancelButton: true,
85
+          confirmButtonText: '确定',
86
+          cancelButtonText: '取消',
87
+          type: 'warning',
88
+          beforeClose: (action, instance, done) => {
89
+            if (action === "confirm") {
90
+
91
+              instance.confirmButtonLoading = true;
92
+              instance.confirmButtonText = "移除中...";
93
+              setRoleStatus(id, false)
94
+                .then(rs => {
95
+                  done();
96
+                  instance.confirmButtonLoading = false;
97
+                  const resp = rs.data
98
+                  if (resp.state === 1) {
99
+                    this.$emit('delete')
100
+                  } else {
101
+                    this.$message.error(resp.msg)
102
+                  }
103
+                })
104
+                .catch(err => {
105
+                  done();
106
+                  this.$message.error(err);
107
+                  instance.confirmButtonLoading = false;
108
+                })
109
+            }else{
110
+
111
+              done();
112
+            }
113
+          }
114
+        })
115
+      },
116
+
117
+      submitAction: function() {
118
+
119
+        if (this.role_id <= 0) {
120
+          return
121
+        }
122
+
123
+        var checkeds = this.$refs.tree.getCheckedKeys(true)
124
+
125
+        var ids = []
126
+        var func_ids = []
127
+
128
+        if (checkeds.length > 0) {
129
+          this.purviews.forEach(purview => {
130
+            if (purview.childs != null && purview.childs.length > 0) {
131
+              purview.childs.forEach(childs => {
132
+                if (childs.childs == null) {
133
+                  if (checkeds.indexOf(childs.id) != -1) {
134
+                    if (ids.indexOf(purview.id) == -1) {
135
+                      ids.push(purview.id)
136
+                    }
137
+                    ids.push(childs.id)
138
+
126 139
                   }
127
-                });
128
-              } else {
129
-                if (ids.indexOf(purview.id+"") != -1) {
130
-                  checkeds.push(purview.id)
140
+                } else {
141
+                  console.log(childs.name)
142
+                  if (childs.name == '透析记录') {
143
+
144
+                    childs.childs.forEach(child => {
145
+                      if (checkeds.indexOf(child.id) != -1) {
146
+                        if (func_ids.indexOf(childs.id) == -1) {
147
+                          func_ids.push(childs.id)
148
+                        }
149
+                        func_ids.push(child.id)
150
+                      }
151
+                    })
152
+                  } else {
153
+                    childs.childs.forEach(child => {
154
+                      if (checkeds.indexOf(child.id) != -1) {
155
+                        if (ids.indexOf(childs.id) == -1) {
156
+                          ids.push(childs.id)
157
+                        }
158
+                        ids.push(child.id)
159
+                      }
160
+                    })
161
+
162
+                  }
163
+
131 164
                 }
165
+              })
166
+
167
+            } else {
168
+              if (checkeds.indexOf(purview.id) != -1) {
169
+                ids.push(purview.id)
132 170
               }
133
-            });
171
+            }
172
+          })
173
+        }
174
+        var idsStr = ''
175
+        if (ids.length > 0) {
176
+          idsStr = ids.join(',')
177
+        }
178
+
179
+        var funcIdsStr = ''
180
+        if (func_ids.length > 0) {
181
+          funcIdsStr = func_ids.join(',')
182
+        }
183
+        this.submitLoading = true
184
+        editPurview(this.role_id, idsStr, funcIdsStr).then(rs => {
185
+          var resp = rs.data
186
+          this.submitLoading = false
187
+
188
+          if (resp.state === 1) {
189
+            this.hide()
190
+          } else {
191
+            this.$message.error(resp.msg)
134 192
           }
135
-          this.default_checkeds = checkeds
136
-        } else {
137
-          this.$message.error(resp.msg)
193
+        }).catch(err => {
194
+          this.submitLoading = false
195
+          this.$message.error(err)
196
+        })
197
+      },
198
+
199
+      show(role_id) {
200
+        this.loading = true
201
+        this.visible = true
202
+        this.default_checkeds = []
203
+        this.purviews = []
204
+
205
+
206
+
207
+        var id = parseInt(role_id)
208
+        if (id <= 0) {
209
+          this.$message.error('参数错误')
210
+          return
138 211
         }
139
-      }).catch(err => {
140
-        this.$message.error(err)
141
-      })
142
-    }
143
-  },created(){
212
+        this.role_id = role_id
213
+        getEditPurviewInitData(this.role_id).then(rs => {
214
+          var resp = rs.data
215
+          if (resp.state === 1) {
216
+            this.role = resp.data.role
217
+            this.purviews.push(...resp.data.purviews)
218
+            // 初始化默认选中项
219
+            var role_purview_ids = resp.data.role_purview_ids
220
+            var checkeds = []
221
+            if (role_purview_ids.length > 0) {
222
+              var ids = role_purview_ids.split(',')
223
+              this.purviews.forEach(purview => {
224
+                if (purview.childs != null && purview.childs.length > 0) {
225
+                  purview.childs.forEach(childs => {
226
+
227
+                    if (childs.childs != null && childs.childs.length > 0) {
228
+                      childs.childs.forEach(child => {
229
+                        if (ids.indexOf(child.id + '') != -1) {
230
+                          checkeds.push(child.id)
231
+                        }
232
+                      })
233
+
234
+                      }else{
235
+                      if (ids.indexOf(childs.id + '') != -1) {
236
+                        checkeds.push(childs.id)
237
+                      }
238
+                    }
239
+                  })
240
+
241
+                } else {
242
+                  if (ids.indexOf(purview.id + '') != -1) {
243
+                    checkeds.push(purview.id)
244
+                  }
245
+                }
246
+              })
247
+            }
248
+
249
+
250
+
251
+            this.$nextTick(() => {
252
+              this.default_checkeds = checkeds
253
+            })
254
+
255
+            this.loading = false
256
+
257
+          } else {
258
+            this.loading = false
259
+
260
+            this.$message.error(resp.msg)
261
+          }
262
+        }).catch(err => {
263
+          this.loading = false
264
+
265
+          this.$message.error(err)
266
+        })
267
+      },
268
+      hide() {
269
+        this.visible =false
144 270
 
271
+      }
272
+
273
+    }, created() {
145 274
 
146
-  },
147
-};
275
+    }
276
+  }
148 277
 </script>
149 278
 
150 279
 <style lang="scss" scoped>
151
-.roleSettings {
280
+  .roleSettings {
281
+
152 282
   .roleName {
153 283
     display: flex;
154 284
     align-items: center;
155 285
     justify-content: space-between;
156 286
   }
287
+
157 288
   .roleNameLeft {
158 289
     display: flex;
159 290
     align-items: center;
160
-    p {
161
-      width: 100px;
162
-    }
291
+
292
+  p {
293
+    width: 100px;
294
+  }
295
+
163 296
   }
164 297
   .roleMain {
165 298
     display: flex;
166 299
     justify-content: space-between;
167 300
     margin-top: 18px;
168
-    .roleMainLeft {
169
-      display: flex;
170
-      .roletitle {
171
-        width: 74px;
172
-      }
173
-      .roleMainLeftBox {
174
-        width: 300px;
175
-        height: 706px;
176
-        overflow-y: auto;
177
-        border: 1px solid rgba(234, 238, 240, 1);
178
-        border-radius: 4px;
179
-        padding: 20px 0 0 10px;
180
-      }
181
-    }
182
-    .roleMainRight {
183
-      width: 280px;
184
-      height: 706px;
185
-      overflow-y: auto;
186
-      border: 1px solid rgba(235, 238, 240, 1);
187
-      color: #303133;
188
-      .hasChoose {
189
-        height: 42px;
190
-        line-height: 42px;
191
-        padding-left: 20px;
192
-        background: #f6f8f9;
193
-      }
194
-    }
301
+
302
+  .roleMainLeft {
303
+    display: flex;
304
+
305
+  .roletitle {
306
+    width: 74px;
195 307
   }
196
-}
197
-</style>
198 308
 
309
+  .roleMainLeftBox {
310
+    width: 500px;
311
+    height: 706px;
312
+    overflow-y: auto;
313
+    border: 1px solid rgba(234, 238, 240, 1);
314
+    border-radius: 4px;
315
+    padding: 20px 0 0 10px;
316
+  }
317
+
318
+  }
319
+  .roleMainRight {
320
+    width: 280px;
321
+    height: 706px;
322
+    overflow-y: auto;
323
+    border: 1px solid rgba(235, 238, 240, 1);
324
+    color: #303133;
325
+
326
+  .hasChoose {
327
+    height: 42px;
328
+    line-height: 42px;
329
+    padding-left: 20px;
330
+    background: #f6f8f9;
331
+  }
332
+
333
+  }
334
+  }
335
+  }
336
+</style>
199 337
 
200 338
 <style lang="scss">
201
-.settingDialog {
339
+  .settingDialog {
340
+
202 341
   .el-dialog__body {
203 342
     max-height: 600px !important;
204 343
   }
205
-}
344
+
345
+  }
206 346
 </style>

+ 10 - 1
src/xt_pages/role/components/UserManagement.vue Просмотреть файл

@@ -3,6 +3,7 @@
3 3
   <el-dialog class="userDialog" title="用户管理" width="660px" :visible.sync="visible">
4 4
     <div class="userManagement">
5 5
       <el-table
6
+        v-loading="loading"
6 7
         :row-style="{ color: '#303133' }"
7 8
         :header-cell-style="{
8 9
           backgroundColor: 'rgb(245, 247, 250)',
@@ -98,7 +99,7 @@
98 99
         admin_user: [],
99 100
         local_user_id: 0,
100 101
         org:null,
101
-
102
+        loading:false,
102 103
 
103 104
       }
104 105
     },
@@ -175,7 +176,11 @@
175 176
         return parseTime(time, format);
176 177
       },
177 178
       GetAllStaff: function() {
179
+        this.loading = true
180
+
178 181
         getRoleStaff().then(response => {
182
+          this.loading = false
183
+
179 184
           if (response.data.state === 1) {
180 185
             this.admin_user = response.data.data.admins
181 186
             this.org = response.data.data.org
@@ -192,10 +197,14 @@
192 197
               }
193 198
             }
194 199
           } else {
200
+
195 201
             this.$toast({
196 202
               message: response.data.msg
197 203
             })
198 204
           }
205
+        }).catch(err => {
206
+          this.loading = false
207
+          this.$message.error(err)
199 208
         })
200 209
       },
201 210
 

+ 5 - 2
src/xt_pages/role/role.vue Просмотреть файл

@@ -11,7 +11,7 @@
11 11
         >新增</el-button
12 12
       >
13 13
     </div>
14
-    <div class="app-container">
14
+    <div class="app-container" v-loading="loading_roles">
15 15
       <!-- <el-table
16 16
         :data="roles"
17 17
         v-loading="loading_roles"
@@ -95,7 +95,7 @@
95 95
         @did-add-role="didAddRole"
96 96
       ></add-role>
97 97
 
98
-      <permission-settings ref="permission_settings"></permission-settings>
98
+      <permission-settings ref="permission_settings" @delete="deleteRole()"></permission-settings>
99 99
       <user-management ref="user_management"></user-management>
100 100
 
101 101
       <div class="roleTitle">
@@ -286,6 +286,9 @@ export default {
286 286
     },
287 287
     onClickManagement(role_id) {
288 288
       this.$refs.user_management.show(role_id);
289
+    },deleteRole(){
290
+      this.$refs.permission_settings.hide();
291
+      this.requestRoleWithPage(1);
289 292
     }
290 293
   }
291 294
 };

+ 13 - 13
src/xt_permission.js Просмотреть файл

@@ -10,19 +10,19 @@ const permissionWhiteList = loginWhiteList.concat(["/"]); // 权限验证白名
10 10
 
11 11
 router.beforeEach((to, from, next) => {
12 12
   // 线上注释
13
-  if (!store.getters.configlist || store.getters.configlist === undefined || store.getters.configlist.length <= 0) {
14
-    store.dispatch('VerifyConfigList', []).then(() => {
15
-      next()
16
-    })
17
-  }
18
-  if (store.getters.permission_routers === undefined) {
19
-    store.dispatch('xt_GenerateRoutes', []).then(() => {
20
-      next()
21
-    })
22
-  } else {
23
-    next()
24
-  }
25
-  return
13
+  // if (!store.getters.configlist || store.getters.configlist === undefined || store.getters.configlist.length <= 0) {
14
+  //   store.dispatch('VerifyConfigList', []).then(() => {
15
+  //     next()
16
+  //   })
17
+  // }
18
+  // if (store.getters.permission_routers === undefined) {
19
+  //   store.dispatch('xt_GenerateRoutes', []).then(() => {
20
+  //     next()
21
+  //   })
22
+  // } else {
23
+  //   next()
24
+  // }
25
+  // return
26 26
   // 线上注释
27 27
 
28 28
   NProgress.start();