Browse Source

Merge branch '20230223_pc_vue_new_branch' of http://git.shengws.com/csx/Vue_New into 20230223_pc_vue_new_branch

28169 1 year ago
parent
commit
186cd760b5
2 changed files with 193 additions and 15 deletions
  1. 79 2
      src/vendor/Export2Excel.js
  2. 114 13
      src/xt_pages/qcd/workAnalysis/nurse.vue

+ 79 - 2
src/vendor/Export2Excel.js View File

@@ -70,6 +70,7 @@ function sheet_from_array_of_arrays(data, opts) {
70 70
       r: 0
71 71
     }
72 72
   };
73
+  console.log('rrrrr',data);
73 74
   for (var R = 0; R != data.length; ++R) {
74 75
     for (var C = 0; C != data[R].length; ++C) {
75 76
       if (range.s.r > R) range.s.r = R;
@@ -157,11 +158,11 @@ export function export_json_to_excel({
157 158
   filename = filename || 'excel-list'
158 159
   data = [...data]
159 160
   data.unshift(header);
160
-
161
+  console.log('wwwww',data);
161 162
   for (let i = multiHeader.length - 1; i > -1; i--) {
162 163
     data.unshift(multiHeader[i])
163 164
   }
164
-
165
+  console.log('qqqqq',data);
165 166
   var ws_name = "SheetJS";
166 167
   var wb = new Workbook(),
167 168
     ws = sheet_from_array_of_arrays(data);
@@ -310,3 +311,79 @@ export function export_json_to_excel1({
310 311
   }
311 312
   
312 313
 }
314
+
315
+export function export_json_to_excel2({
316
+  multiHeader = [],
317
+  header,
318
+  data,
319
+  filename,
320
+  merges = [],
321
+  autoWidth = true,
322
+  bookType = 'xlsx'
323
+} = {}) {
324
+  /* original data */
325
+  filename = filename || 'excel-list'
326
+  data = [...data]
327
+  // data.unshift(header);
328
+  console.log('wwwww',data);
329
+  for (let i = multiHeader.length - 1; i > -1; i--) {
330
+    data.unshift(multiHeader[i])
331
+  }
332
+  console.log('qqqqq',data);
333
+  var ws_name = "SheetJS";
334
+  var wb = new Workbook(),
335
+    ws = sheet_from_array_of_arrays(data);
336
+
337
+  if (merges.length > 0) {
338
+    if (!ws['!merges']) ws['!merges'] = [];
339
+    merges.forEach(item => {
340
+      console.log(XLSX.utils.decode_range(item))
341
+      ws['!merges'].push(XLSX.utils.decode_range(item))
342
+    })
343
+  }
344
+
345
+  if (autoWidth) {
346
+    /*设置worksheet每列的最大宽度*/
347
+    const colWidth = data.map(row => row.map(val => {
348
+      /*先判断是否为null/undefined*/
349
+      if (val == null) {
350
+        return {
351
+          'wch': 10
352
+        };
353
+      }
354
+      /*再判断是否为中文*/
355
+      else if (val.toString().charCodeAt(0) > 255) {
356
+        return {
357
+          'wch': val.toString().length * 2
358
+        };
359
+      } else {
360
+        return {
361
+          'wch': val.toString().length
362
+        };
363
+      }
364
+    }))
365
+    /*以第一行为初始值*/
366
+    let result = colWidth[0];
367
+    for (let i = 1; i < colWidth.length; i++) {
368
+      for (let j = 0; j < colWidth[i].length; j++) {
369
+        if (result[j]['wch'] < colWidth[i][j]['wch']) {
370
+          result[j]['wch'] = colWidth[i][j]['wch'];
371
+        }
372
+      }
373
+    }
374
+    ws['!cols'] = result;
375
+  }
376
+
377
+  /* add worksheet to workbook */
378
+  wb.SheetNames.push(ws_name);
379
+  wb.Sheets[ws_name] = ws;
380
+
381
+  var wbout = XLSX.write(wb, {
382
+    bookType: bookType,
383
+    bookSST: false,
384
+    type: 'binary'
385
+  });
386
+  saveAs(new Blob([s2ab(wbout)], {
387
+    type: "application/octet-stream"
388
+  }), `${filename}.${bookType}`);
389
+}

+ 114 - 13
src/xt_pages/qcd/workAnalysis/nurse.vue View File

@@ -60,6 +60,7 @@
60 60
             format="yyyy-MM-dd"
61 61
             value-format="yyyy-MM-dd"
62 62
           ></el-date-picker>
63
+          <el-button type="primary" @click="export_file()" :loading="downloadLoading">导出</el-button>
63 64
         </div>
64 65
         <div class="tableTitle">统计图</div>
65 66
         <div>
@@ -178,7 +179,12 @@
178 179
                 start_nurse_count:total_start_nurse, -->
179 180
             <el-table-column label="合计" align="center">
180 181
               <template slot-scope="scope">
181
-                {{scope.row.finish_nuser_count + scope.row.washpipe_nuser_count + scope.row.puncture_count + scope.row.cure_count + scope.row.mission_count + scope.row.change_nuser_count+scope.row.difficult_nuser_count+scope.row.new_nuser_count +scope.row.start_nuser_count ?scope.row.puncture_count  + scope.row.cure_count + scope.row.mission_count+scope.row.change_nuser_count+scope.row.difficult_nuser_count+scope.row.new_nuser_count+scope.row.start_nuser_count:''}}
182
+                {{scope.row.finish_nuser_count + scope.row.washpipe_nuser_count + scope.row.puncture_count + 
183
+                scope.row.cure_count + scope.row.mission_count + scope.row.change_nuser_count+
184
+                scope.row.difficult_nuser_count+scope.row.new_nuser_count +scope.row.start_nuser_count ?
185
+                scope.row.puncture_count  + scope.row.cure_count + scope.row.change_nuser_count+scope.row.difficult_nuser_count+
186
+                scope.row.difficult_nuser_count+scope.row.finish_nuser_count+scope.row.start_nuser_count +
187
+                scope.row.washpipe_nuser_count+scope.row.mission_count:''}}
182 188
               </template>
183 189
             </el-table-column>
184 190
           </el-table>
@@ -348,6 +354,8 @@
348 354
           ]
349 355
         },
350 356
         modeList:[],
357
+        downloadLoading: false,
358
+        list:[]
351 359
       };
352 360
     },
353 361
     methods: {
@@ -400,7 +408,6 @@
400 408
             var resp = rs.data
401 409
             console.log("列表2323323232323233232332323223233223233223",resp)
402 410
             if (resp.state == 1) {
403
-
404 411
               let total_cure = 0
405 412
               let total_puncture = 0
406 413
               let total_mission = 0
@@ -411,7 +418,7 @@
411 418
               let total_finish_nurse = 0
412 419
               let total_washpipe_nurse = 0
413 420
               this.loading = false
414
-
421
+              var list=[]
415 422
               for (let i = 0; i < resp.data.data.length; i++) {
416 423
                 total_cure = total_cure + resp.data.data[i].cure_count
417 424
                 total_puncture = total_puncture + resp.data.data[i].puncture_count
@@ -421,15 +428,15 @@
421 428
                 total_diffcult_nurse = total_diffcult_nurse + resp.data.data[i].difficult_nuser_count
422 429
                 total_new_fistula_nurse = total_new_fistula_nurse + resp.data.data[i].new_nuser_count
423 430
                 total_start_nurse = total_start_nurse + resp.data.data[i].start_nuser_count
424
-                console.log( resp.data.data[i].start_nuser_count)
431
+                // console.log( resp.data.data[i].start_nuser_count)
425 432
 
426
-                console.log(total_start_nurse)
433
+                // console.log(total_start_nurse)
427 434
                 total_finish_nurse = total_finish_nurse + resp.data.data[i].finish_nuser_count
428 435
                 total_washpipe_nurse = total_washpipe_nurse + resp.data.data[i].washpipe_nuser_count
429 436
                 this.tableData.push(resp.data.data[i])
430
-             }
431
-              console.log(total_start_nurse)
432
-
437
+                
438
+             }        
439
+            //  this.list.push(obj)
433 440
               this.tableData.push( {
434 441
                 user_name:"合计",
435 442
                 cure_count:total_cure,
@@ -442,10 +449,13 @@
442 449
                 finish_nuser_count:total_finish_nurse,
443 450
                 washpipe_nuser_count:total_washpipe_nurse,
444 451
               })
445
-              console.log("hhhhhhh23232233223",this.tableData)
452
+              console.log('33333',this.tableData)
453
+              
446 454
               var dialysisCount = resp.data.dialysisCount
447 455
                 console.log("dialysisCount",dialysisCount)
448 456
               for(let i=0;i<dialysisCount.length;i++){
457
+                // for()
458
+                // var obj={}
449 459
                 if(dialysisCount[i].mode_id == 1){
450 460
                   dialysisCount[i].mode_id = "HD"
451 461
                 }
@@ -510,6 +520,28 @@
510 520
              })
511 521
              console.log("listq23333",list)
512 522
              this.modeList.push(...list)
523
+
524
+             for(let i=0;i<this.tableData.length;i++){
525
+              
526
+                var obj={}
527
+                  obj['name'] = this.tableData[i].user_name
528
+                  obj['chuanci'] = this.tableData[i].puncture_count
529
+                  obj['zhiliao'] = this.tableData[i].cure_count
530
+                  obj['huanyao'] = this.tableData[i].change_nuser_count
531
+                  obj['yncc'] = this.tableData[i].difficult_nuser_count
532
+                  obj['shangji'] = this.tableData[i].start_nuser_count+'('+this.getTotalCount(this.tableData[i].admin_user_id)+')'
533
+                  obj['xiaji'] = this.tableData[i].finish_nuser_count
534
+                  obj['chongguan'] = this.tableData[i].washpipe_nuser_count
535
+                  obj['xuanjiao'] = this.tableData[i].mission_count
536
+                  obj['heji'] = this.tableData[i].puncture_count*1 +this.tableData[i].cure_count*1 +this.tableData[i].change_nuser_count*1+
537
+                                this.tableData[i].difficult_nuser_count*1 +this.tableData[i].finish_nuser_count*1+
538
+                                this.tableData[i].washpipe_nuser_count*1 +this.tableData[i].mission_count*1+
539
+                                this.tableData[i].start_nuser_count*1
540
+                  this.list.push(obj)
541
+              }
542
+
543
+              console.log("hhhhhhh23232233223",this.list)
544
+
513 545
             } else {
514 546
               this.loading = false
515 547
             }
@@ -663,19 +695,88 @@
663 695
         return y + '-' + m + '-' + d;
664 696
       },
665 697
       getTotalCount(adminuserid){
666
-        console.log("adminuserid",adminuserid)
667
-        console.log("333333",this.modeList)
698
+        // console.log("adminuserid",adminuserid)
699
+        // console.log("333333",this.modeList)
668 700
         var name = ""
669 701
         for(let i=0;i<this.modeList.length;i++){
670 702
           for(let j=0;j<this.modeList[i].child.length;j++){
671 703
             if(adminuserid == this.modeList[i].child[j].start_nurse){
672 704
                name += (this.modeList[i].child[j].mode_id+"-"+this.modeList[i].child[j].Count) + "次"+"、"
705
+              //  this.list[]
673 706
             }
674 707
           }
675 708
         }
676
-        console.log("name22222",name)
709
+        // console.log("name22222",name)
677 710
         return name.substr(0,name.length-1)
678
-      }
711
+      },
712
+      export_file:function(){
713
+        this.export_file_step_two()
714
+      },
715
+      export_file_step_two: function(){
716
+        this.downloadLoading = true
717
+        import('@/vendor/Export2Excel').then(excel => {
718
+          // const filterVal = [
719
+          //   '区号',
720
+          //   '机号'
721
+          // ]
722
+          // if (this.export_type == 0) {
723
+            const multiHeader = [['姓名', '穿刺', '治疗', '换药', '疑难穿刺', '上机', '下机', '冲管', '宣教小结', '合计']]
724
+          //  const header=['姓名', '穿刺', '治疗', '换药', '疑难穿刺', '上机', '下机', '冲管', '宣教小结', '合计']
725
+            // const header = ['', '', '上午', '下午', '晚上', '上午', '下午', '晚上', '上午', '下午', '晚上', '上午', '下午', '晚上', '上午', '下午', '晚上', '上午', '下午', '晚上', '上午', '下午', '晚上', '上午', '下午', '晚上', '上午', '下午', '晚上', '上午', '下午', '晚上', '上午', '下午', '晚上', '上午', '下午', '晚上', '上午', '下午', '晚上', '上午', '下午', '晚上', '上午', '下午', '晚上', '上午', '下午', '晚上', '上午', '下午', '晚上', '上午', '下午', '晚上', '上午', '下午', '晚上', '上午', '下午', '晚上', '上午', '下午', '晚上']
726
+            const merges = ['A1', 'B1', 'C1', 'D1', 'E1', 'F1', 'G1', 'H1', 'I1', 'J1']
727
+            // var list = []
728
+            // let i = 0
729
+            // var jihaos=[]
730
+            // for (let key in this.tableData) {
731
+            //   var tempValue
732
+            //   if(this.tableData[key].admin_user_id !=''){
733
+            //     jihaos.push(this.tableData[key].admin_user_id)
734
+            //     // console.log('2222222',jihaos);
735
+            //   }
736
+              
737
+            //   if (i == 0) {
738
+            //     let m = 'A2' + ':' + 'A' + (1 + jihaos.length)
739
+            //     tempValue = (2 + jihaos.length)
740
+            //     merges.push(m)
741
+            //   } 
742
+            //   else {
743
+            //     let m = 'A' + (tempValue + 1) + ':' + 'A' + ((tempValue + 1) + jihaos.length - 1)
744
+            //     tempValue = ((tempValue + 1) + jihaos.length - 1)
745
+            //     merges.push(m)
746
+            //   }
747
+            //   // for (let b = 0; b < jihaos.length; b++) {
748
+            //     let obj = {}
749
+            //     obj['name'] = this.tableData[key].user_name
750
+            //     // obj['区号'] = this.partitions[key].name
751
+            //     // obj['机号'] = jihaos[b].number.toString()
752
+            //     list.push(obj)
753
+            //   // }
754
+            //   // i++
755
+            // }
756
+            var data = []
757
+
758
+            this.list.map(item => {
759
+              // console.log('111111',item);
760
+              data.push(Object.values(item))
761
+            })
762
+
763
+            const filename = '护士工作量'
764
+            
765
+            console.log('333333333',data),
766
+            excel.export_json_to_excel2({
767
+              
768
+              multiHeader,
769
+              // header,
770
+              merges,
771
+              data,
772
+              filename
773
+            })
774
+            this.downloadLoading = false
775
+          // }
776
+
777
+        })
778
+      },
779
+
679 780
     },
680 781
     created(){
681 782
       var date = new Date()