瀏覽代碼

代码优化验证

seimin 3 年之前
父節點
當前提交
053294d7ac

+ 8 - 6
components/seiminModel/seiminModel.vue

@@ -2,7 +2,7 @@
2
  * @Author: 廖明明
2
  * @Author: 廖明明
3
  * @Date: 2022-04-01 17:11:19
3
  * @Date: 2022-04-01 17:11:19
4
  * @LastEditors: 廖明明
4
  * @LastEditors: 廖明明
5
- * @LastEditTime: 2022-04-21 12:27:12
5
+ * @LastEditTime: 2022-04-21 13:16:48
6
  * @Description: 自定义弹窗组件
6
  * @Description: 自定义弹窗组件
7
 -->
7
 -->
8
 <template>
8
 <template>
@@ -142,8 +142,10 @@
142
         let deptId = this.loginInfo.user && this.loginInfo.user.dept.id;
142
         let deptId = this.loginInfo.user && this.loginInfo.user.dept.id;
143
         reqDeptCodes([deptId]).then((res) => {
143
         reqDeptCodes([deptId]).then((res) => {
144
           if (res.status == 200) {
144
           if (res.status == 200) {
145
-            this.nurseCodeImg = res["data"][0].base64;
146
-            this.refreshQRCodeTime = res["data"][0].refreshQRCodeTime;
145
+            res["data"] = res["data"] || [];
146
+            res["data"][0] = res["data"][0] || {};
147
+            this.nurseCodeImg = res["data"][0].base64 || "";
148
+            this.refreshQRCodeTime = res["data"][0].refreshQRCodeTime || 30;
147
             clearInterval(this.timer);
149
             clearInterval(this.timer);
148
             this.timer = setInterval(() => {
150
             this.timer = setInterval(() => {
149
               this.refreshQRCodeTime = Math.max(--this.refreshQRCodeTime, 0);
151
               this.refreshQRCodeTime = Math.max(--this.refreshQRCodeTime, 0);
@@ -155,9 +157,9 @@
155
           } else {
157
           } else {
156
             clearInterval(this.timer);
158
             clearInterval(this.timer);
157
             uni.showToast({
159
             uni.showToast({
158
-              icon: 'none',
159
-              title: '获取数据失败'
160
-            })
160
+              icon: "none",
161
+              title: "获取数据失败",
162
+            });
161
           }
163
           }
162
         });
164
         });
163
       },
165
       },

+ 6 - 4
pages/login/login.vue

@@ -46,7 +46,7 @@
46
     },
46
     },
47
     methods: {
47
     methods: {
48
       ...mapActions("user", ["vxLogin"]),
48
       ...mapActions("user", ["vxLogin"]),
49
-      ...mapMutations(['changeSeiminModel']),
49
+      ...mapMutations(["changeSeiminModel"]),
50
       // 登录
50
       // 登录
51
       login(e) {
51
       login(e) {
52
         let {
52
         let {
@@ -84,7 +84,9 @@
84
 
84
 
85
           if (res.status == 200) {
85
           if (res.status == 200) {
86
             //获取角色信息
86
             //获取角色信息
87
-            let role = res.user.user.role;
87
+            res.user = res.user || {};
88
+            res.user.user = res.user.user || {};
89
+            let role = res.user.user.role || [];
88
             // 护士角色才能登录
90
             // 护士角色才能登录
89
             let nurseRole = role.some((item) => item.rolecode === "nurse");
91
             let nurseRole = role.some((item) => item.rolecode === "nurse");
90
             if (!nurseRole) {
92
             if (!nurseRole) {
@@ -107,7 +109,7 @@
107
             }
109
             }
108
             // 跳转到首页(isShowSeiminModel,是否显示切换科室弹窗)
110
             // 跳转到首页(isShowSeiminModel,是否显示切换科室弹窗)
109
             uni.navigateTo({
111
             uni.navigateTo({
110
-              url: "/pages/index/index"
112
+              url: "/pages/index/index",
111
             });
113
             });
112
             this.changeSeiminModel(true);
114
             this.changeSeiminModel(true);
113
           } else {
115
           } else {
@@ -116,7 +118,7 @@
116
               icon: "error",
118
               icon: "error",
117
               content: res.remarks || "登录失败",
119
               content: res.remarks || "登录失败",
118
             });
120
             });
119
-            throw new Error(res.remarks || '登录失败');
121
+            throw new Error(res.remarks || "登录失败");
120
           }
122
           }
121
         });
123
         });
122
       },
124
       },

+ 1 - 0
pages/quickCreateOrder/quickCreateOrder.vue

@@ -198,6 +198,7 @@
198
             res.customRemarks = [];
198
             res.customRemarks = [];
199
           }
199
           }
200
           // 处理msg
200
           // 处理msg
201
+          res.msg = res.msg || '';
201
           if (res.msg.includes("<b>")) {
202
           if (res.msg.includes("<b>")) {
202
             res.msg = res.msg.replace(/<b>/g, '<text class="green">');
203
             res.msg = res.msg.replace(/<b>/g, '<text class="green">');
203
             res.msg = res.msg.replace(/<\/b>/g, "</text>");
204
             res.msg = res.msg.replace(/<\/b>/g, "</text>");

+ 28 - 16
pages/searchDept/searchDept.vue

@@ -62,7 +62,12 @@
62
     },
62
     },
63
     computed: {
63
     computed: {
64
       ...mapState("user", ["loginInfo"]),
64
       ...mapState("user", ["loginInfo"]),
65
-      ...mapState(["deptDisplay", "searchDeptParams", "searchDeptResult", 'searchDeptResultList']),
65
+      ...mapState([
66
+        "deptDisplay",
67
+        "searchDeptParams",
68
+        "searchDeptResult",
69
+        "searchDeptResultList",
70
+      ]),
66
     },
71
     },
67
     onUnload() {
72
     onUnload() {
68
       if (this.timer) {
73
       if (this.timer) {
@@ -74,7 +79,11 @@
74
       this.init();
79
       this.init();
75
     },
80
     },
76
     methods: {
81
     methods: {
77
-      ...mapMutations(["changeSearchDeptResult", 'changeSeiminModel', 'changeSearchDeptResultList']),
82
+      ...mapMutations([
83
+        "changeSearchDeptResult",
84
+        "changeSeiminModel",
85
+        "changeSearchDeptResultList",
86
+      ]),
78
       ...mapMutations("user", ["changeLoginInfo"]),
87
       ...mapMutations("user", ["changeLoginInfo"]),
79
       init() {
88
       init() {
80
         this.loadOldKeyword();
89
         this.loadOldKeyword();
@@ -126,7 +135,8 @@
126
           postData.department.nurseSign = 1;
135
           postData.department.nurseSign = 1;
127
         } else if (
136
         } else if (
128
           this.searchDeptParams.type === "selectDept_start_qucikCreateOrder" ||
137
           this.searchDeptParams.type === "selectDept_start_qucikCreateOrder" ||
129
-          this.searchDeptParams.type === "selectDept_end_qucikCreateOrder") {
138
+          this.searchDeptParams.type === "selectDept_end_qucikCreateOrder"
139
+        ) {
130
           //快捷建单选择起点科室或选择终点科室
140
           //快捷建单选择起点科室或选择终点科室
131
           postData.department.hospital = {
141
           postData.department.hospital = {
132
             id: this.loginInfo.user.currentHospital.id,
142
             id: this.loginInfo.user.currentHospital.id,
@@ -138,7 +148,7 @@
138
           if (this.searchDeptParams.departmentStrategy == 205) {
148
           if (this.searchDeptParams.departmentStrategy == 205) {
139
             // 固定科室类型
149
             // 固定科室类型
140
             postData.department.type = {
150
             postData.department.type = {
141
-              id: this.searchDeptParams.deptType
151
+              id: this.searchDeptParams.deptType,
142
             };
152
             };
143
           }
153
           }
144
         } else {
154
         } else {
@@ -165,7 +175,7 @@
165
           if (res.status == 200) {
175
           if (res.status == 200) {
166
             this.searchData.push({
176
             this.searchData.push({
167
               name: keyword,
177
               name: keyword,
168
-              list: res.list,
178
+              list: res.list || [],
169
             });
179
             });
170
             let searchText = this.searchText.detail ?
180
             let searchText = this.searchText.detail ?
171
               this.searchText.detail.value :
181
               this.searchText.detail.value :
@@ -184,7 +194,7 @@
184
               icon: "error",
194
               icon: "error",
185
               content: res.msg || "获取数据失败",
195
               content: res.msg || "获取数据失败",
186
             });
196
             });
187
-            throw new Error(res.msg || '获取数据失败');
197
+            throw new Error(res.msg || "获取数据失败");
188
           }
198
           }
189
         });
199
         });
190
       },
200
       },
@@ -251,13 +261,15 @@
251
             //首页切换科室
261
             //首页切换科室
252
             this.changeDept_index_handler();
262
             this.changeDept_index_handler();
253
           } else if (
263
           } else if (
254
-            this.searchDeptParams.type === "selectDept_start_qucikCreateOrder") {
264
+            this.searchDeptParams.type === "selectDept_start_qucikCreateOrder"
265
+          ) {
255
             //快捷建单选择起点科室
266
             //快捷建单选择起点科室
256
             this.searchDeptResultList.start = arr[0];
267
             this.searchDeptResultList.start = arr[0];
257
             this.changeSearchDeptResultList(this.searchDeptResultList);
268
             this.changeSearchDeptResultList(this.searchDeptResultList);
258
             this.selectDept_startOrEnd_qucikCreateOrder();
269
             this.selectDept_startOrEnd_qucikCreateOrder();
259
           } else if (
270
           } else if (
260
-            this.searchDeptParams.type === "selectDept_end_qucikCreateOrder") {
271
+            this.searchDeptParams.type === "selectDept_end_qucikCreateOrder"
272
+          ) {
261
             //快捷建单选择终点科室
273
             //快捷建单选择终点科室
262
             this.searchDeptResultList.end = arr[0];
274
             this.searchDeptResultList.end = arr[0];
263
             this.changeSearchDeptResultList(this.searchDeptResultList);
275
             this.changeSearchDeptResultList(this.searchDeptResultList);
@@ -301,9 +313,9 @@
301
         if (this.searchDeptParams.type === "changeDept_index") {
313
         if (this.searchDeptParams.type === "changeDept_index") {
302
           // 首页切换科室
314
           // 首页切换科室
303
           uni.showLoading({
315
           uni.showLoading({
304
-            title: '加载中',
316
+            title: "加载中",
305
             mask: true,
317
             mask: true,
306
-          })
318
+          });
307
           if (
319
           if (
308
             this.loginInfo.user.currentHospital.id ==
320
             this.loginInfo.user.currentHospital.id ==
309
             this.searchDeptParams.hospital.value
321
             this.searchDeptParams.hospital.value
@@ -325,7 +337,7 @@
325
                   icon: "error",
337
                   icon: "error",
326
                   content: res.msg || "操作失败",
338
                   content: res.msg || "操作失败",
327
                 });
339
                 });
328
-                throw new Error(res.msg || '操作失败');
340
+                throw new Error(res.msg || "操作失败");
329
               }
341
               }
330
             });
342
             });
331
           }
343
           }
@@ -358,8 +370,8 @@
358
                       uni.navigateTo({
370
                       uni.navigateTo({
359
                         url: this.searchDeptParams.backUrl,
371
                         url: this.searchDeptParams.backUrl,
360
                       });
372
                       });
361
-                    }
362
-                  }]
373
+                    },
374
+                  }, ],
363
                 });
375
                 });
364
               } else {
376
               } else {
365
                 this.$refs.seiminModel.showChangeDept({
377
                 this.$refs.seiminModel.showChangeDept({
@@ -367,7 +379,7 @@
367
                   icon: "error",
379
                   icon: "error",
368
                   content: res.msg || "操作失败",
380
                   content: res.msg || "操作失败",
369
                 });
381
                 });
370
-                throw new Error(res.msg || '操作失败');
382
+                throw new Error(res.msg || "操作失败");
371
               }
383
               }
372
             });
384
             });
373
           } else {
385
           } else {
@@ -377,7 +389,7 @@
377
               icon: "error",
389
               icon: "error",
378
               content: res.msg || "操作失败",
390
               content: res.msg || "操作失败",
379
             });
391
             });
380
-            throw new Error(res.msg || '操作失败');
392
+            throw new Error(res.msg || "操作失败");
381
           }
393
           }
382
         });
394
         });
383
       },
395
       },
@@ -386,7 +398,7 @@
386
         uni.navigateTo({
398
         uni.navigateTo({
387
           url: this.searchDeptParams.backUrl,
399
           url: this.searchDeptParams.backUrl,
388
         });
400
         });
389
-      }
401
+      },
390
     },
402
     },
391
   };
403
   };
392
 </script>
404
 </script>

+ 3 - 3
store/index.js

@@ -50,7 +50,7 @@ export default new Vuex.Store({
50
       state.isShowSeiminModel = args;
50
       state.isShowSeiminModel = args;
51
     },
51
     },
52
     //快捷建单类型
52
     //快捷建单类型
53
-    changeQucikCreateOrderType(state, args = {}) {
53
+    changeQucikCreateOrderType(state, args) {
54
       state.qucikCreateOrderType = args.type;
54
       state.qucikCreateOrderType = args.type;
55
       state.qucikCreateOrderTypeId = args.taskTypeId;
55
       state.qucikCreateOrderTypeId = args.taskTypeId;
56
     },
56
     },
@@ -72,11 +72,11 @@ export default new Vuex.Store({
72
     },
72
     },
73
     //搜索到的科室-searchDept
73
     //搜索到的科室-searchDept
74
     changeSearchDeptResult(state, args) {
74
     changeSearchDeptResult(state, args) {
75
-      state.searchDeptResult = args;
75
+      state.searchDeptResult = args || {};
76
     },
76
     },
77
     //搜索到的科室集合-searchDept-选起点科室并且需要选终点科室
77
     //搜索到的科室集合-searchDept-选起点科室并且需要选终点科室
78
     changeSearchDeptResultList(state, args) {
78
     changeSearchDeptResultList(state, args) {
79
-      state.searchDeptResultList = args;
79
+      state.searchDeptResultList = args || {};
80
     },
80
     },
81
     //搜索科室需要传递的参数
81
     //搜索科室需要传递的参数
82
     changeSearchDeptParams(state, args) {
82
     changeSearchDeptParams(state, args) {

+ 10 - 6
store/modules/user.js

@@ -1,4 +1,6 @@
1
-import { reqLogin } from "@/request/api.js";
1
+import {
2
+  reqLogin
3
+} from "@/request/api.js";
2
 const state = {
4
 const state = {
3
   loginInfo: {}, //当前登录用户信息
5
   loginInfo: {}, //当前登录用户信息
4
 };
6
 };
@@ -6,16 +8,18 @@ const getters = {};
6
 const mutations = {
8
 const mutations = {
7
   // 登录
9
   // 登录
8
   vxLogin(state, args) {
10
   vxLogin(state, args) {
9
-    state.loginInfo = args;
11
+    state.loginInfo = args || {};
10
   },
12
   },
11
   // 修改当前登录用户信息
13
   // 修改当前登录用户信息
12
-  changeLoginInfo(state, args){
13
-    state.loginInfo.user = args;
14
-  }
14
+  changeLoginInfo(state, args) {
15
+    state.loginInfo.user = args || {};
16
+  },
15
 };
17
 };
16
 const actions = {
18
 const actions = {
17
   // 登录
19
   // 登录
18
-  async vxLogin({ commit }, args) {
20
+  async vxLogin({
21
+    commit
22
+  }, args) {
19
     let result = await reqLogin(args);
23
     let result = await reqLogin(args);
20
     if (result.status == 200) {
24
     if (result.status == 200) {
21
       commit("vxLogin", result.user);
25
       commit("vxLogin", result.user);