Parcourir la source

移动端性能优化

张保健 il y a 4 ans
Parent
révision
c861dcd24a
4 fichiers modifiés avec 407 ajouts et 386 suppressions
  1. 172 167
      src/pages/main/DialysisArea.vue
  2. 30 31
      src/pages/main/RecordPage.vue
  3. 62 61
      src/pages/main/WaitingArea.vue
  4. 143 127
      src/pages/main/index.vue

+ 172 - 167
src/pages/main/DialysisArea.vue Voir le fichier

@@ -116,23 +116,23 @@
116 116
 </template>
117 117
 
118 118
 <script>
119
-import PatientBox from "./PatientBox";
120
-import { Popover } from "vux";
121
-import { Datetime } from "vux";
122
-import { parseTime } from "@/utils/index";
123
-import { getDialysisScheduals } from "@/api/dialysis";
124
-import { Toast } from "vant";
125
-import $ from "jquery";
119
+import PatientBox from './PatientBox'
120
+import { Popover } from 'vux'
121
+import { Datetime } from 'vux'
122
+import { parseTime } from '@/utils/index'
123
+import { getDialysisScheduals } from '@/api/dialysis'
124
+import { Toast } from 'vant'
125
+import $ from 'jquery'
126 126
 
127 127
 export default {
128
-  name: "DialysisArea",
128
+  name: 'DialysisArea',
129 129
   components: {
130 130
     PatientBox,
131 131
     Popover,
132 132
     Datetime
133 133
   },
134
-  inject: ["reload"],
135
-  data() {
134
+  inject: ['reload'],
135
+  data () {
136 136
     return {
137 137
       loading: false,
138 138
       user_id: 0,
@@ -141,83 +141,83 @@ export default {
141 141
       ismypatient: this.$store.getters.app.dialysis_area.ismypatient,
142 142
       selected_date: this.$store.getters.app.dialysis_area.schedule_date, // new Date(),
143 143
       schedual_types: [
144
-        { value: 0, text: "全部班", select: true },
145
-        { value: 1, text: "上午", select: false },
146
-        { value: 2, text: "下午", select: false },
147
-        { value: 3, text: "晚上", select: false }
144
+        { value: 0, text: '全部班', select: true },
145
+        { value: 1, text: '上午', select: false },
146
+        { value: 2, text: '下午', select: false },
147
+        { value: 3, text: '晚上', select: false }
148 148
       ],
149 149
       schedual_type_selected: this.$store.getters.app.dialysis_area
150 150
         .schedule_type_select_index,
151 151
 
152 152
       zone_selected: this.$store.getters.app.dialysis_area.zone_select_index,
153
-      zones: [{ value: 0, text: "全部分区", select: true }],
153
+      zones: [{ value: 0, text: '全部分区', select: true }],
154 154
       dialysis_scheduals: [],
155 155
 
156 156
       zone_options_visible: false,
157 157
       sch_type_options_visible: false,
158 158
       newMypatient: 0
159
-    };
159
+    }
160 160
   },
161 161
   props: {
162 162
     search_keyword: {
163 163
       type: String,
164
-      default: ""
164
+      default: ''
165 165
     }
166 166
   },
167 167
   computed: {
168
-    selected_date_str: function() {
169
-      return parseTime(this.selected_date, "{y}-{m}-{d}");
168
+    selected_date_str: function () {
169
+      return parseTime(this.selected_date, '{y}-{m}-{d}')
170 170
     },
171 171
 
172
-    filtedScheduals: function() {
172
+    filtedScheduals: function () {
173 173
       if (this.dialysis_scheduals.length == 0) {
174
-        return [];
174
+        return []
175 175
       }
176 176
 
177
-      var search_keyword = this.search_keyword;
177
+      var search_keyword = this.search_keyword
178 178
       if (search_keyword.length > 0) {
179
-        var schedules = [];
179
+        var schedules = []
180 180
         for (let o_i = 0; o_i < this.dialysis_scheduals.length; o_i++) {
181
-          const scheduleInfo = this.dialysis_scheduals[o_i];
182
-          var originSchedules = scheduleInfo.scheduals;
181
+          const scheduleInfo = this.dialysis_scheduals[o_i]
182
+          var originSchedules = scheduleInfo.scheduals
183 183
           if (originSchedules.length == 0) {
184
-            continue;
184
+            continue
185 185
           }
186
-          var filtedSchedules = [];
186
+          var filtedSchedules = []
187 187
           for (let s_i = 0; s_i < originSchedules.length; s_i++) {
188
-            const schedule = originSchedules[s_i];
188
+            const schedule = originSchedules[s_i]
189 189
             if (
190 190
               schedule.patient.name.indexOf(search_keyword) != -1 ||
191 191
               schedule.patient.dialysis_no.indexOf(search_keyword) != -1
192 192
             ) {
193
-              filtedSchedules.push(schedule);
194
-              break;
193
+              filtedSchedules.push(schedule)
194
+              break
195 195
             }
196 196
           }
197 197
           if (filtedSchedules.length > 0) {
198 198
             schedules.push({
199 199
               zone_name: scheduleInfo.zone_name,
200 200
               scheduals: filtedSchedules
201
-            });
201
+            })
202 202
           }
203 203
         }
204
-        return schedules;
204
+        return schedules
205 205
       }
206 206
       if (this.ismypatient) {
207
-        var zone_selected = this.zone_selected;
208
-        var timetype_selected = this.schedual_type_selected;
207
+        var zone_selected = this.zone_selected
208
+        var timetype_selected = this.schedual_type_selected
209 209
         var zone_name =
210
-          zone_selected == 0 ? "" : this.zones[zone_selected].text;
211
-        var schedules = [];
210
+          zone_selected == 0 ? '' : this.zones[zone_selected].text
211
+        var schedules = []
212 212
         for (let o_i = 0; o_i < this.dialysis_scheduals.length; o_i++) {
213
-          const scheduleInfo = this.dialysis_scheduals[o_i];
214
-          var originSchedules = scheduleInfo.scheduals;
213
+          const scheduleInfo = this.dialysis_scheduals[o_i]
214
+          var originSchedules = scheduleInfo.scheduals
215 215
           if (originSchedules.length == 0) {
216
-            continue;
216
+            continue
217 217
           }
218
-          var filtedSchedules = [];
218
+          var filtedSchedules = []
219 219
           for (let s_i = 0; s_i < originSchedules.length; s_i++) {
220
-            const schedule = originSchedules[s_i];
220
+            const schedule = originSchedules[s_i]
221 221
             if (schedule.dialysis_order.start_nurse == this.user_id) {
222 222
               if (
223 223
                 zone_name.length == 0 ||
@@ -228,7 +228,7 @@ export default {
228 228
                   timetype_selected == 0 ||
229 229
                   schedule.schedule_type == timetype_selected
230 230
                 ) {
231
-                  filtedSchedules.push(schedule);
231
+                  filtedSchedules.push(schedule)
232 232
                 }
233 233
               }
234 234
               // break;
@@ -238,32 +238,32 @@ export default {
238 238
             schedules.push({
239 239
               zone_name: scheduleInfo.zone_name,
240 240
               scheduals: filtedSchedules
241
-            });
241
+            })
242 242
           }
243 243
         }
244
-        return schedules;
244
+        return schedules
245 245
       }
246 246
 
247
-      var zone_selected = this.zone_selected;
248
-      var timetype_selected = this.schedual_type_selected;
247
+      var zone_selected = this.zone_selected
248
+      var timetype_selected = this.schedual_type_selected
249 249
       if (
250 250
         (zone_selected == 0 && timetype_selected == 0) ||
251 251
         this.zones.length <= 1
252 252
       ) {
253
-        return this.dialysis_scheduals;
253
+        return this.dialysis_scheduals
254 254
       }
255 255
 
256
-      var zone_name = zone_selected == 0 ? "" : this.zones[zone_selected].text;
257
-      var schedules = [];
256
+      var zone_name = zone_selected == 0 ? '' : this.zones[zone_selected].text
257
+      var schedules = []
258 258
       for (let o_i = 0; o_i < this.dialysis_scheduals.length; o_i++) {
259
-        const scheduleInfo = this.dialysis_scheduals[o_i];
260
-        var originSchedules = scheduleInfo.scheduals;
261
-        var filtedSchedules = [];
259
+        const scheduleInfo = this.dialysis_scheduals[o_i]
260
+        var originSchedules = scheduleInfo.scheduals
261
+        var filtedSchedules = []
262 262
         for (let s_i = 0; s_i < originSchedules.length; s_i++) {
263
-          const schedule = originSchedules[s_i];
263
+          const schedule = originSchedules[s_i]
264 264
           if (this.ismypatient) {
265 265
             if (schedule.dialysis_order.creator == this.user_id) {
266
-              filtedSchedules.push(schedule);
266
+              filtedSchedules.push(schedule)
267 267
             }
268 268
           } else {
269 269
             if (
@@ -275,7 +275,7 @@ export default {
275 275
                 timetype_selected == 0 ||
276 276
                 schedule.schedule_type == timetype_selected
277 277
               ) {
278
-                filtedSchedules.push(schedule);
278
+                filtedSchedules.push(schedule)
279 279
               }
280 280
             }
281 281
           }
@@ -284,238 +284,243 @@ export default {
284 284
           schedules.push({
285 285
             zone_name: scheduleInfo.zone_name,
286 286
             scheduals: filtedSchedules
287
-          });
287
+          })
288 288
         }
289 289
       }
290
-      this.ismypatient = false;
291
-      return schedules;
290
+      this.ismypatient = false
291
+      return schedules
292 292
     }
293 293
   },
294 294
 
295
-  created() {
296
-    this.user_id = this.$store.getters.user.user.id;
295
+  created () {
296
+    this.user_id = this.$store.getters.user.user.id
297 297
 
298
-    var storedata = this.$store.getters.scheduals;
299
-    var scheduals = storedata.scheduals;
298
+    var storedata = this.$store.getters.scheduals
299
+    var scheduals = storedata.scheduals
300 300
     if (Object.keys(storedata).length > 0) {
301
-      var zoneMap = {};
302
-      var schedualMap = {};
301
+      var zoneMap = {}
302
+      var schedualMap = {}
303 303
       for (let index = 0; index < scheduals.length; index++) {
304
-        const schedual = scheduals[index];
304
+        const schedual = scheduals[index]
305 305
         if (schedual.dialysis_order == null) {
306
-          continue;
306
+          continue
307 307
         }
308 308
         if (schedualMap[schedual.device_number.zone.name] == null) {
309
-          schedualMap[schedual.device_number.zone.name] = [];
309
+          schedualMap[schedual.device_number.zone.name] = []
310 310
         }
311
-        schedualMap[schedual.device_number.zone.name].push(schedual);
311
+        schedualMap[schedual.device_number.zone.name].push(schedual)
312 312
         if (zoneMap[schedual.device_number.zone.name] == null) {
313 313
           zoneMap[schedual.device_number.zone.name] =
314
-            schedual.device_number.zone;
314
+            schedual.device_number.zone
315 315
         }
316 316
       }
317 317
 
318
-      var zones = [];
319
-      zones.push({ value: 0, text: "全部分区" });
318
+      var zones = []
319
+      zones.push({ value: 0, text: '全部分区' })
320 320
       for (var zoneName in zoneMap) {
321
-        zones.push({ value: zoneMap[zoneName].id, text: zoneName });
321
+        zones.push({ value: zoneMap[zoneName].id, text: zoneName })
322 322
       }
323 323
 
324
-      zones = zones.sort(function(a, b) {
325
-        return a.value > b.value;
326
-      });
327
-      this.zones = zones;
324
+      zones = zones.sort(function (a, b) {
325
+        return a.value > b.value
326
+      })
327
+      this.zones = zones
328 328
 
329
-      var dialysis_scheduals = [];
329
+      var dialysis_scheduals = []
330 330
       for (let index = 0; index < zones.length; index++) {
331
-        const zone = zones[index];
332
-        var scheduals = schedualMap[zone.text];
331
+        const zone = zones[index]
332
+        var scheduals = schedualMap[zone.text]
333 333
         if (scheduals == null) {
334
-          continue;
334
+          continue
335 335
         }
336 336
         dialysis_scheduals.push({
337 337
           zone_name: zone.text,
338 338
           scheduals: scheduals
339
-        });
339
+        })
340 340
       }
341
-      this.dialysis_scheduals = dialysis_scheduals;
341
+      this.dialysis_scheduals = dialysis_scheduals
342 342
     } else {
343
-      this.requestDialysisScheduals();
343
+      this.requestDialysisScheduals()
344 344
     }
345 345
   },
346
-  mounted() {
346
+  mounted () {
347 347
     this.timer = window.setInterval(() => {
348
-      setTimeout(this.requestDialysisScheduals(), 0);
349
-    }, 120000);
348
+      setTimeout(this.requestDialysisScheduals(), 0)
349
+    }, 120000)
350 350
   },
351
-  beforeDestroy() {
352
-    clearInterval(this.timer);
353
-    this.timer = null;
351
+  beforeDestroy () {
352
+    clearInterval(this.timer)
353
+    this.timer = null
354 354
   },
355 355
   methods: {
356
-    clearPatient() {
357
-      this.search_keyword = "";
358
-      this.ismypatient = false;
359
-      this.$emit("clear_search_keyword");
360
-      this.$store.dispatch("SaveDialysisAreaSelectIndexs", {
356
+    clearPatient () {
357
+      this.search_keyword = ''
358
+      this.ismypatient = false
359
+      this.$emit('clear_search_keyword')
360
+      this.$store.dispatch('SaveDialysisAreaSelectIndexs', {
361 361
         zone: this.zone_selected,
362 362
         schedule_type: this.schedual_type_selected,
363 363
         schedule_date: this.selected_date,
364 364
         ismypatient: this.ismypatient
365
-      });
365
+      })
366 366
     },
367
-    mypatient() {
368
-      this.search_keyword = "";
369
-      this.ismypatient = true;
370
-      this.$emit("clear_search_keyword");
371
-      this.$store.dispatch("SaveDialysisAreaSelectIndexs", {
367
+    mypatient () {
368
+      this.search_keyword = ''
369
+      this.ismypatient = true
370
+      this.$emit('clear_search_keyword')
371
+      this.$store.dispatch('SaveDialysisAreaSelectIndexs', {
372 372
         zone: this.zone_selected,
373 373
         schedule_type: this.schedual_type_selected,
374 374
         schedule_date: this.selected_date,
375 375
         ismypatient: this.ismypatient
376
-      });
377
-      this.newMypatient = 1;
376
+      })
377
+      this.newMypatient = 1
378 378
     },
379
-    reloads: function() {
380
-      this.reload();
379
+    reloads: function () {
380
+      this.reload()
381 381
     },
382
-    handletimeType: function(index) {
382
+    handletimeType: function (index) {
383 383
       if (!this.ismypatient) {
384
-        this.ismypatient = false;
384
+        this.ismypatient = false
385 385
       }
386
-      this.sch_type_options_visible = false;
387
-      this.schedual_type_selected = index;
388
-      this.$emit("clear_search_keyword");
389
-      this.$store.dispatch("SaveDialysisAreaSelectIndexs", {
386
+      this.sch_type_options_visible = false
387
+      this.schedual_type_selected = index
388
+      this.$emit('clear_search_keyword')
389
+      this.$store.dispatch('SaveDialysisAreaSelectIndexs', {
390 390
         zone: this.zone_selected,
391 391
         schedule_type: this.schedual_type_selected,
392 392
         schedule_date: this.selected_date,
393 393
         ismypatient: this.ismypatient
394
-      });
394
+      })
395 395
     },
396
-    handleZoneChange: function(index) {
397
-      this.ismypatient = false;
398
-      this.zone_options_visible = false;
399
-      this.zone_selected = index;
400
-      this.$emit("clear_search_keyword");
401
-      this.$store.dispatch("SaveDialysisAreaSelectIndexs", {
396
+    handleZoneChange: function (index) {
397
+      this.ismypatient = false
398
+      this.zone_options_visible = false
399
+      this.zone_selected = index
400
+      this.$emit('clear_search_keyword')
401
+      this.$store.dispatch('SaveDialysisAreaSelectIndexs', {
402 402
         zone: this.zone_selected,
403 403
         schedule_type: this.schedual_type_selected,
404 404
         schedule_date: this.selected_date,
405 405
         ismypatient: this.ismypatient
406
-      });
407
-      this.newMypatient = 0;
406
+      })
407
+      this.newMypatient = 0
408 408
     },
409
-    handleScheduleDateChange: function(date) {
409
+    handleScheduleDateChange: function (date) {
410 410
       if (!this.ismypatient) {
411
-        this.ismypatient = false;
411
+        this.ismypatient = false
412 412
       }
413
-      this.zone_selected = 0;
414
-      this.schedual_type_selected = 0;
415
-      this.$emit("clear_search_keyword");
416
-      this.$store.dispatch("SaveDialysisAreaSelectIndexs", {
413
+      this.zone_selected = 0
414
+      this.schedual_type_selected = 0
415
+      this.$emit('clear_search_keyword')
416
+      this.$store.dispatch('SaveDialysisAreaSelectIndexs', {
417 417
         zone: this.zone_selected,
418 418
         schedule_type: this.schedual_type_selected,
419 419
         schedule_date: this.selected_date,
420 420
         ismypatient: this.ismypatient
421
-      });
422
-      this.requestDialysisScheduals();
421
+      })
422
+      this.requestDialysisScheduals()
423 423
     },
424 424
 
425
-    requestDialysisScheduals() {
425
+    requestDialysisScheduals () {
426 426
       // this.$toast.loading({forbidClick: true, duration: 0})
427 427
       // this.loading = true;
428
-      var type = 0;
428
+      var type = 0
429 429
       getDialysisScheduals({ type: type, date: this.selected_date_str })
430 430
         .then(rs => {
431
-          this.networkStates = true;
432
-          var resp = rs.data;
431
+          this.networkStates = true
432
+          var resp = rs.data
433 433
           if (resp.state == 1) {
434
-            this.loading = false;
434
+            this.loading = false
435 435
 
436 436
             // console.log(resp.data)
437
-            var scheduals = resp.data.scheduals;
438
-            this.$store.dispatch("SetScheduals", { scheduals: scheduals });
439
-            var zoneMap = {};
440
-            var schedualMap = {};
437
+            var scheduals = resp.data.scheduals
438
+            this.$store.dispatch('SetScheduals', { scheduals: scheduals })
439
+            this.$store.dispatch('SetWaitScheduals', { waitscheduals: scheduals })
440
+            this.$emit('refWaitingArea')
441
+            var zoneMap = {}
442
+            var schedualMap = {}
441 443
             for (let index = 0; index < scheduals.length; index++) {
442
-              const schedual = scheduals[index];
444
+              const schedual = scheduals[index]
443 445
               if (schedual.dialysis_order == null) {
444
-                continue;
446
+                continue
445 447
               }
446 448
               if (schedualMap[schedual.device_number.zone.name] == null) {
447
-                schedualMap[schedual.device_number.zone.name] = [];
449
+                schedualMap[schedual.device_number.zone.name] = []
448 450
               }
449
-              schedualMap[schedual.device_number.zone.name].push(schedual);
451
+              schedualMap[schedual.device_number.zone.name].push(schedual)
450 452
               if (zoneMap[schedual.device_number.zone.name] == null) {
451 453
                 zoneMap[schedual.device_number.zone.name] =
452
-                  schedual.device_number.zone;
454
+                  schedual.device_number.zone
453 455
               }
454 456
             }
455 457
 
456
-            var zones = [];
457
-            zones.push({ value: 0, text: "全部分区" });
458
+            var zones = []
459
+            zones.push({ value: 0, text: '全部分区' })
458 460
             for (var zoneName in zoneMap) {
459
-              zones.push({ value: zoneMap[zoneName].id, text: zoneName });
461
+              zones.push({ value: zoneMap[zoneName].id, text: zoneName })
460 462
             }
461 463
 
462
-            zones = zones.sort(function(a, b) {
463
-              return a.value > b.value;
464
-            });
465
-            this.zones = zones;
464
+            zones = zones.sort(function (a, b) {
465
+              return a.value > b.value
466
+            })
467
+            this.zones = zones
466 468
 
467
-            var dialysis_scheduals = [];
469
+            // eslint-disable-next-line camelcase
470
+            var dialysis_scheduals = []
468 471
             for (let index = 0; index < zones.length; index++) {
469
-              const zone = zones[index];
470
-              var scheduals = schedualMap[zone.text];
472
+              const zone = zones[index]
473
+              // eslint-disable-next-line no-redeclare
474
+              var scheduals = schedualMap[zone.text]
471 475
               if (scheduals == null) {
472
-                continue;
476
+                continue
473 477
               }
474 478
               dialysis_scheduals.push({
475 479
                 zone_name: zone.text,
476 480
                 scheduals: scheduals
477
-              });
481
+              })
478 482
             }
479
-            this.dialysis_scheduals = dialysis_scheduals;
483
+            // eslint-disable-next-line camelcase
484
+            this.dialysis_scheduals = dialysis_scheduals
480 485
           } else {
481
-            this.loading = false;
486
+            this.loading = false
482 487
 
483 488
             this.$toast({
484 489
               message: resp.msg
485
-            });
490
+            })
486 491
           }
487 492
         })
488 493
         .catch(error => {
489
-          this.loading = false;
494
+          this.loading = false
490 495
 
491 496
           // 超时之后在这里捕抓错误信息.
492 497
           if (error.response) {
493
-            this.networkStates = false;
498
+            this.networkStates = false
494 499
 
495
-            console.log("error.response");
496
-            console.log(error.response);
500
+            console.log('error.response')
501
+            console.log(error.response)
497 502
           } else if (error.request) {
498
-            this.networkStates = false;
503
+            this.networkStates = false
499 504
 
500 505
             // if(error.request.readyState == 4 && error.request.status == 0){
501 506
             //   //我在这里重新请求
502 507
             //   this.networkStates = false
503 508
             // }
504 509
           } else {
505
-            this.networkStates = false;
510
+            this.networkStates = false
506 511
           }
507
-        });
512
+        })
508 513
     },
509
-    openPicker() {
510
-      this.$refs.picker.open();
511
-      this.newMypatient = 0;
514
+    openPicker () {
515
+      this.$refs.picker.open()
516
+      this.newMypatient = 0
512 517
     }
513 518
     // getMyPatient () {
514 519
     //   console.log('这是啥', this.zone_options_visible)
515 520
     //   console.log('日期', this.selected_date)
516 521
     // }
517 522
   }
518
-};
523
+}
519 524
 </script>
520 525
 
521 526
 <style style="stylesheet/scss" lang="scss" scoped>

+ 30 - 31
src/pages/main/RecordPage.vue Voir le fichier

@@ -118,27 +118,22 @@
118 118
         <van-button size="small" type="info">临时排班</van-button>
119 119
     </div>-->
120 120
     <div class="area">
121
-      <waiting-area v-show="index == 0" title="候诊区" :search_keyword="search_keyword"></waiting-area>
122
-      <dialysis-area
123
-        v-show="index == 1"
124
-        title="透析区"
125
-        :search_keyword="search_keyword"
126
-        @clear_search_keyword="clearKeyword"
127
-      ></dialysis-area>
121
+      <waiting-area ref="waitingArea" v-show="index == 0" title="候诊区" :search_keyword="search_keyword"></waiting-area>
122
+      <dialysis-area @refWaitingArea="refWaitingArea" v-show="index == 1" title="透析区" :search_keyword="search_keyword"  @clear_search_keyword="clearKeyword" ></dialysis-area>
128 123
     </div>
129 124
   </div>
130 125
 </template>
131 126
 
132 127
 <script>
133
-import DialysisArea from "./DialysisArea";
134
-import WaitingArea from "./WaitingArea";
135
-import { Popover } from "vux";
136
-import { getDialysisScheduals, getWaitingScheduals } from "@/api/dialysis";
137
-import { parseTime } from "@/utils/index";
138
-import { getDialysisOrWaitSelectedConfig } from "@/utils/data_config";
128
+import DialysisArea from './DialysisArea'
129
+import WaitingArea from './WaitingArea'
130
+import { Popover } from 'vux'
131
+import { getDialysisScheduals, getWaitingScheduals } from '@/api/dialysis'
132
+import { parseTime } from '@/utils/index'
133
+import { getDialysisOrWaitSelectedConfig } from '@/utils/data_config'
139 134
 
140 135
 export default {
141
-  name: "RecordPage",
136
+  name: 'RecordPage',
142 137
   props: {
143 138
     un_read_wait_num: {
144 139
       type: Number
@@ -147,16 +142,16 @@ export default {
147 142
       type: Number
148 143
     }
149 144
   },
150
-  data() {
145
+  data () {
151 146
     return {
152 147
       index: 1,
153
-      search_input: "",
154
-      search_keyword: "",
148
+      search_input: '',
149
+      search_keyword: '',
155 150
       scheduals: [],
156 151
       advice_groups: [],
157 152
       unReadWaitNum: 0,
158 153
       unReadDialysisNum: 0
159
-    };
154
+    }
160 155
   },
161 156
   components: {
162 157
     DialysisArea,
@@ -167,26 +162,30 @@ export default {
167 162
   },
168 163
 
169 164
   methods: {
170
-    ClickTab: function(tabIndex) {
171
-      this.index = tabIndex;
165
+    refWaitingArea: function () {
166
+      this.$refs.waitingArea.requestScheduals()
167
+      this.$emit('refAdvice')
168
+    },
169
+    ClickTab: function (tabIndex) {
170
+      this.index = tabIndex
172 171
     },
173
-    searchWithKeyword: function() {
174
-      this.$refs.search_field.blur();
175
-      this.search_keyword = this.search_input;
172
+    searchWithKeyword: function () {
173
+      this.$refs.search_field.blur()
174
+      this.search_keyword = this.search_input
176 175
     },
177
-    clearKeyword: function() {
178
-      this.search_input = "";
179
-      this.search_keyword = "";
176
+    clearKeyword: function () {
177
+      this.search_input = ''
178
+      this.search_keyword = ''
180 179
     }
181 180
   },
182
-  created() {
183
-    var index = getDialysisOrWaitSelectedConfig();
184
-    console.log(index);
181
+  created () {
182
+    var index = getDialysisOrWaitSelectedConfig()
183
+    console.log(index)
185 184
     if (index != null) {
186
-      this.index = index;
185
+      this.index = index
187 186
     }
188 187
   }
189
-};
188
+}
190 189
 </script>
191 190
 
192 191
 <style lang="scss" scoped>

+ 62 - 61
src/pages/main/WaitingArea.vue Voir le fichier

@@ -304,7 +304,7 @@ export default {
304 304
 
305 305
         console.log(filtedSchedules)
306 306
         return this.processScheduals(filtedSchedules)
307
-
307
+        // eslint-disable-next-line no-unreachable
308 308
         if (this.select_index == 2) {
309 309
           var scheduals = []
310 310
           for (let index = 0; index < this.scheduals.length; index++) {
@@ -462,14 +462,15 @@ export default {
462 462
 
463 463
       this.zone_options = this.makeZones(scheduals)
464 464
       this.zone_scheduals = this.processScheduals(scheduals)
465
-    } else {
466
-      this.requestScheduals()
467
-    }
465
+    } 
466
+    // else {
467
+    //   this.requestScheduals()
468
+    // }
468 469
   },
469 470
   mounted () {
470
-    this.timer = window.setInterval(() => {
471
-      setTimeout(this.requestScheduals(), 0)
472
-    }, 120000)
471
+    // this.timer = window.setInterval(() => {
472
+    //   setTimeout(this.requestScheduals(), 0)
473
+    // }, 120000)
473 474
   },
474 475
   beforeDestroy () {
475 476
     clearInterval(this.timer)
@@ -577,61 +578,61 @@ export default {
577 578
       setSelectedTimesDataConfigList(index.toString())
578 579
     },
579 580
 
580
-    requestScheduals () {
581
+    requestScheduals: function () {
581 582
       // this.loading = true;
582
-      var date = parseTime(Date.parse(new Date()), '{y}-{m}-{d}')
583
-      getWaitingScheduals({ date: date })
584
-        .then(rs => {
585
-          var resp = rs.data
586
-          if (resp.state == 1) {
587
-            this.loading = false
588
-
589
-            var scheduals = resp.data.scheduals
590
-            this.$store.dispatch('SetWaitScheduals', {
591
-              waitscheduals: scheduals
592
-            })
593
-            var totalCount = scheduals.length
594
-            var prescription_count = 0
595
-            var assessment_before_dislysis_count = 0
596
-            for (let index = 0; index < scheduals.length; index++) {
597
-              const schedual = scheduals[index]
598
-              if (schedual.assessment_before_dislysis == null) {
599
-                assessment_before_dislysis_count += 1
600
-              }
601
-              if (schedual.prescription == null) {
602
-                prescription_count += 1
603
-              }
604
-            }
605
-            this.menuList[2].count = assessment_before_dislysis_count
606
-            this.menuList[1].count = prescription_count
607
-            this.scheduals = scheduals
608
-
609
-            this.zone_options = this.makeZones(scheduals)
610
-            this.zone_scheduals = this.processScheduals(scheduals)
611
-          } else {
612
-            this.loading = false
613
-
614
-            this.$toast({
615
-              message: resp.msg
616
-            })
617
-          }
618
-        })
619
-        .catch(error => {
620
-          this.loading = false
621
-
622
-          // 超时之后在这里捕抓错误信息.
623
-          if (error.response) {
624
-            this.networkStates = false
625
-          } else if (error.request) {
626
-            this.networkStates = false
627
-            // if(error.request.readyState == 4 && error.request.status == 0){
628
-            //   //我在这里重新请求
629
-            //   this.networkStates = false
630
-            // }
631
-          } else {
632
-            this.networkStates = false
633
-          }
634
-        })
583
+      // var date = parseTime(Date.parse(new Date()), '{y}-{m}-{d}')
584
+      // getWaitingScheduals({ date: date }).then(rs => {
585
+      // var resp = rs.data
586
+      // if (resp.state == 1) {
587
+      this.loading = false
588
+      var storedata = this.$store.getters.waitscheduals
589
+      var scheduals = storedata.waitscheduals
590
+
591
+      // var scheduals = resp.data.scheduals
592
+      // this.$store.dispatch('SetWaitScheduals', {
593
+      //   waitscheduals: scheduals
594
+      // })
595
+      var totalCount = scheduals.length
596
+      var prescription_count = 0
597
+      var assessment_before_dislysis_count = 0
598
+      for (let index = 0; index < scheduals.length; index++) {
599
+        const schedual = scheduals[index]
600
+        if (schedual.assessment_before_dislysis == null) {
601
+          assessment_before_dislysis_count += 1
602
+        }
603
+        if (schedual.prescription == null) {
604
+          prescription_count += 1
605
+        }
606
+      }
607
+      this.menuList[2].count = assessment_before_dislysis_count
608
+      this.menuList[1].count = prescription_count
609
+      this.scheduals = scheduals
610
+
611
+      this.zone_options = this.makeZones(scheduals)
612
+      this.zone_scheduals = this.processScheduals(scheduals)
613
+      // } else {
614
+      //   this.loading = false
615
+
616
+      //   this.$toast({
617
+      //     message: resp.msg
618
+      //   })
619
+      // }
620
+      // }).catch(error => {
621
+      //     this.loading = false
622
+
623
+      //     // 超时之后在这里捕抓错误信息.
624
+      //     if (error.response) {
625
+      //       this.networkStates = false
626
+      //     } else if (error.request) {
627
+      //       this.networkStates = false
628
+      //       // if(error.request.readyState == 4 && error.request.status == 0){
629
+      //       //   //我在这里重新请求
630
+      //       //   this.networkStates = false
631
+      //       // }
632
+      //     } else {
633
+      //       this.networkStates = false
634
+      //     }
635
+      //   })
635 636
     },
636 637
     makeZones: function (scheduals) {
637 638
       var zoneMap = {}

+ 143 - 127
src/pages/main/index.vue Voir le fichier

@@ -2,10 +2,7 @@
2 2
   <div class="mainBox">
3 3
     <div class="newBox">
4 4
       <div class="mainContent">
5
-        <record-page
6
-          :un_read_wait_num="unReadWaitNum"
7
-          :un_read_dialysis_num="unReadDialysisNum"
8
-        ></record-page>
5
+        <record-page @refAdvice="refAdvice" :un_read_wait_num="unReadWaitNum" :un_read_dialysis_num="unReadDialysisNum" ></record-page>
9 6
       </div>
10 7
       <side-bar :active_index="0" :total_read_dot="readNum"></side-bar>
11 8
     </div>
@@ -13,179 +10,198 @@
13 10
 </template>
14 11
 
15 12
 <script>
16
-import RecordPage from "./RecordPage";
17
-import SideBar from "@/pages/layout/SideBar";
18
-import { getDialysisScheduals, getWaitingScheduals } from "@/api/dialysis";
19
-import { parseTime } from "@/utils/index";
13
+import RecordPage from './RecordPage'
14
+import SideBar from '@/pages/layout/SideBar'
15
+import { getDialysisScheduals, getWaitingScheduals } from '@/api/dialysis'
16
+import { parseTime } from '@/utils/index'
20 17
 
21 18
 export default {
22
-  name: "Main",
23
-  data() {
19
+  name: 'Main',
20
+  data () {
24 21
     return {
25 22
       timer: null,
26 23
       scheduals: [],
27 24
       advice_groups: [],
28 25
       unReadWaitNum: 0,
29 26
       unReadDialysisNum: 0
30
-    };
27
+    }
31 28
   },
32 29
   components: {
33 30
     RecordPage,
34 31
     SideBar
35 32
   },
36
-  created() {
37
-    this.requestScheduals();
38
-    this.requestDialysisScheduals();
33
+  created () {
34
+    // this.requestScheduals()
35
+    // this.requestDialysisScheduals()
39 36
   },
37
+  mounted () {
38
+    // this.timer = window.setInterval(() => {
39
+    //   setTimeout(this.requestScheduals(), 0)
40
+    // }, 10000)
41
+
42
+    // this.timerDia = window.setInterval(() => {
43
+    //   setTimeout(this.requestDialysisScheduals(), 0)
44
+    // }, 10000)
45
+  },
46
+  // beforeDestroy () {
47
+  //   clearInterval(this.timer)
48
+  //   this.timer = null
49
+  //   this.$once('hook:beforeDestroy', () => {
50
+  //     clearInterval(this.timer)
51
+  //   })
52
+
53
+  //   clearInterval(this.timerDia)
54
+  //   this.timerDia = null
55
+  //   this.$once('hook:beforeDestroy', () => {
56
+  //     clearInterval(this.timerDia)
57
+  //   })
58
+  // },
40 59
   methods: {
41
-    requestScheduals() {
42
-      var storedata = this.$store.getters.waitscheduals;
43
-      var scheduals = storedata.waitscheduals;
60
+    refAdvice () {
61
+      this.requestScheduals()
62
+      this.requestDialysisScheduals()
63
+    },
64
+    requestScheduals () {
65
+      var storedata = this.$store.getters.waitscheduals
66
+      var scheduals = storedata.waitscheduals
44 67
       if (Object.keys(storedata).length > 0) {
45
-        this.scheduals = scheduals;
46
-        console.log(this.scheduals);
47
-        let doctorAdvice = [];
68
+        this.scheduals = scheduals
69
+        console.log(this.scheduals)
70
+        let doctorAdvice = []
48 71
         for (let i = 0; i < this.scheduals.length; i++) {
49 72
           for (let y = 0; y < this.scheduals[i].doctor_advice.length; y++) {
50 73
             if (this.scheduals[i].dialysis_order == null) {
51 74
               if (this.scheduals[i].doctor_advice[y].execution_state == 2) {
52
-                doctorAdvice.push(this.scheduals[i].doctor_advice[y]);
75
+                doctorAdvice.push(this.scheduals[i].doctor_advice[y])
53 76
               }
54 77
             }
55 78
           }
56 79
         }
57 80
 
58
-        const sorted = this.groupBy(doctorAdvice, function(item) {
59
-          return [item.groupno];
60
-        });
61
-        this.unReadWaitNum = sorted.length;
62
-      } else {
63
-        var date = parseTime(Date.parse(new Date()), "{y}-{m}-{d}");
64
-        getWaitingScheduals({ date: date }).then(rs => {
65
-          var resp = rs.data;
66
-          this.$store.dispatch("SetRequestScheduals", { resp });
67
-          // console.log(resp);
68
-          if (resp.state == 1) {
69
-            var scheduals = resp.data.scheduals;
70
-            this.scheduals = scheduals;
71
-            console.log(this.scheduals);
72
-            let doctorAdvice = [];
73
-            for (let i = 0; i < this.scheduals.length; i++) {
74
-              for (let y = 0; y < this.scheduals[i].doctor_advice.length; y++) {
75
-                if (this.scheduals[i].dialysis_order == null) {
76
-                  if (this.scheduals[i].doctor_advice[y].execution_state == 2) {
77
-                    doctorAdvice.push(this.scheduals[i].doctor_advice[y]);
78
-                  }
79
-                }
80
-              }
81
-            }
81
+        const sorted = this.groupBy(doctorAdvice, function (item) {
82
+          return [item.groupno]
83
+        })
84
+        this.unReadWaitNum = sorted.length
85
+      } 
86
+      // else {
87
+      //   var date = parseTime(Date.parse(new Date()), '{y}-{m}-{d}')
88
+      //   getWaitingScheduals({ date: date }).then(rs => {
89
+      //     var resp = rs.data
90
+      //     this.$store.dispatch('SetRequestScheduals', { resp })
91
+      //     // console.log(resp);
92
+      //     if (resp.state == 1) {
93
+      //       var scheduals = resp.data.scheduals
94
+      //       this.scheduals = scheduals
95
+      //       console.log(this.scheduals)
96
+      //       let doctorAdvice = []
97
+      //       for (let i = 0; i < this.scheduals.length; i++) {
98
+      //         for (let y = 0; y < this.scheduals[i].doctor_advice.length; y++) {
99
+      //           if (this.scheduals[i].dialysis_order == null) {
100
+      //             if (this.scheduals[i].doctor_advice[y].execution_state == 2) {
101
+      //               doctorAdvice.push(this.scheduals[i].doctor_advice[y])
102
+      //             }
103
+      //           }
104
+      //         }
105
+      //       }
82 106
 
83
-            const sorted = this.groupBy(doctorAdvice, function(item) {
84
-              return [item.groupno];
85
-            });
107
+      //       const sorted = this.groupBy(doctorAdvice, function (item) {
108
+      //         return [item.groupno]
109
+      //       })
86 110
 
87
-            this.unReadWaitNum = sorted.length;
88
-          } else {
89
-            this.$toast({
90
-              message: resp.msg
91
-            });
92
-          }
93
-        });
94
-      }
111
+      //       this.unReadWaitNum = sorted.length
112
+      //     } else {
113
+      //       this.$toast({
114
+      //         message: resp.msg
115
+      //       })
116
+      //     }
117
+      //   })
118
+      // }
95 119
     },
96
-    requestDialysisScheduals() {
97
-      var storedata = this.$store.getters.scheduals;
98
-      var scheduals = storedata.scheduals;
120
+    requestDialysisScheduals () {
121
+      var storedata = this.$store.getters.scheduals
122
+      var scheduals = storedata.scheduals
99 123
       if (Object.keys(storedata).length > 0) {
100
-        let doctorAdvice = [];
124
+        let doctorAdvice = []
101 125
         for (let index = 0; index < scheduals.length; index++) {
102
-          const schedual = scheduals[index];
126
+          const schedual = scheduals[index]
103 127
           if (schedual.dialysis_order == null) {
104
-            continue;
128
+            continue
105 129
           }
106 130
           for (let y = 0; y < schedual.doctor_advice.length; y++) {
107 131
             if (schedual.doctor_advice[y].execution_state == 2) {
108
-              doctorAdvice.push(schedual.doctor_advice[y]);
132
+              doctorAdvice.push(schedual.doctor_advice[y])
109 133
             }
110 134
           }
111 135
         }
112 136
 
113
-        const sorted = this.groupBy(doctorAdvice, function(item) {
114
-          return [item.groupno];
115
-        });
116
-
117
-        this.unReadDialysisNum = sorted.length;
118
-      } else {
119
-        var date = this.$store.getters.app.dialysis_area.schedule_date;
120
-        var type = 0;
121
-        getDialysisScheduals({
122
-          type: type,
123
-          date: parseTime(date, "{y}-{m}-{d}")
137
+        const sorted = this.groupBy(doctorAdvice, function (item) {
138
+          return [item.groupno]
124 139
         })
125
-          .then(rs => {
126
-            var resp = rs.data;
127
-            this.$store.dispatch("SetRequestDialysisScheduals", { resp });
128
-            if (resp.state == 1) {
129
-              var scheduals = resp.data.scheduals;
130
-              let doctorAdvice = [];
131
-              for (let index = 0; index < scheduals.length; index++) {
132
-                const schedual = scheduals[index];
133
-                if (schedual.dialysis_order == null) {
134
-                  continue;
135
-                }
136
-                for (let y = 0; y < schedual.doctor_advice.length; y++) {
137
-                  if (schedual.doctor_advice[y].execution_state == 2) {
138
-                    doctorAdvice.push(schedual.doctor_advice[y]);
139
-                  }
140
-                }
141
-              }
142 140
 
143
-              const sorted = this.groupBy(doctorAdvice, function(item) {
144
-                return [item.groupno];
145
-              });
141
+        this.unReadDialysisNum = sorted.length
142
+      } 
143
+      // else {
144
+      //   var date = this.$store.getters.app.dialysis_area.schedule_date
145
+      //   var type = 0
146
+      //   getDialysisScheduals({
147
+      //     type: type,
148
+      //     date: parseTime(date, '{y}-{m}-{d}')
149
+      //   })
150
+      //     .then(rs => {
151
+      //       var resp = rs.data
152
+      //       this.$store.dispatch('SetRequestDialysisScheduals', { resp })
153
+      //       if (resp.state == 1) {
154
+      //         var scheduals = resp.data.scheduals
155
+      //         let doctorAdvice = []
156
+      //         for (let index = 0; index < scheduals.length; index++) {
157
+      //           const schedual = scheduals[index]
158
+      //           if (schedual.dialysis_order == null) {
159
+      //             continue
160
+      //           }
161
+      //           for (let y = 0; y < schedual.doctor_advice.length; y++) {
162
+      //             if (schedual.doctor_advice[y].execution_state == 2) {
163
+      //               doctorAdvice.push(schedual.doctor_advice[y])
164
+      //             }
165
+      //           }
166
+      //         }
146 167
 
147
-              this.unReadDialysisNum = sorted.length;
148
-            } else {
149
-              this.$toast({
150
-                message: resp.msg
151
-              });
152
-            }
153
-          })
154
-          .catch(v => {});
155
-      }
168
+      //         const sorted = this.groupBy(doctorAdvice, function (item) {
169
+      //           return [item.groupno]
170
+      //         })
171
+
172
+      //         this.unReadDialysisNum = sorted.length
173
+      //       } else {
174
+      //         this.$toast({
175
+      //           message: resp.msg
176
+      //         })
177
+      //       }
178
+      //     })
179
+      //     .catch(v => {})
180
+      // }
156 181
     },
157
-    groupBy(array, f) {
158
-      const groups = {};
159
-      array.forEach(function(o) {
160
-        const group = JSON.stringify(f(o));
161
-        groups[group] = groups[group] || [];
162
-        groups[group].push(o);
163
-      });
164
-      return Object.keys(groups).map(function(group) {
165
-        return groups[group];
166
-      });
182
+    groupBy (array, f) {
183
+      const groups = {}
184
+      array.forEach(function (o) {
185
+        const group = JSON.stringify(f(o))
186
+        groups[group] = groups[group] || []
187
+        groups[group].push(o)
188
+      })
189
+      return Object.keys(groups).map(function (group) {
190
+        return groups[group]
191
+      })
167 192
     },
168
-    getData() {
169
-      console.log("111111");
193
+    getData () {
194
+      console.log('111111')
170 195
       // this.requestScheduals()
171 196
       // this.requestDialysisScheduals()
172 197
     }
173 198
   },
174 199
   computed: {
175
-    readNum: function() {
176
-      return this.unReadWaitNum + this.unReadDialysisNum;
200
+    readNum: function () {
201
+      return this.unReadWaitNum + this.unReadDialysisNum
177 202
     }
178
-  },
179
-  mounted() {
180
-    // this.timer = window.setInterval(() => {
181
-    //   setTimeout(this.getData(), 0);
182
-    // }, 30000);
183
-  },
184
-  beforeDestroy() {
185
-    clearInterval(this.timer);
186
-    this.timer = null;
187 203
   }
188
-};
204
+}
189 205
 </script>
190 206
 
191 207
 <style style="stylesheet/scss" lang="scss" scoped>