XMLWAN 3 years ago
parent
commit
200da42881

+ 147 - 0
src/xt_pages/components/DrugExcel/index.vue View File

@@ -0,0 +1,147 @@
1
+<template>
2
+  <div>
3
+    <input id="excel-drug-input" ref="excel-drug-input" type="file" accept=".xlsx, .xls, .xltx" @change="handleClick">
4
+    <el-button :loading="loading" style="margin-left:16px;" size="mini" type="primary" @click="handleUpload">导入模板
5
+    </el-button>
6
+  </div>
7
+</template>
8
+
9
+<script>
10
+  import XLSX from 'xlsx'
11
+
12
+  export default {
13
+    props: {
14
+      beforeUpload: Function,
15
+      onSuccess: Function
16
+    },
17
+    data() {
18
+      return {
19
+        loading: false,
20
+        excelData: {
21
+          header: null,
22
+          results: null
23
+        }
24
+      }
25
+    },
26
+    methods: {
27
+      generateDate({ header, results }) {
28
+        this.excelData.header = header
29
+        this.excelData.results = results
30
+        this.onSuccess && this.onSuccess(this.excelData)
31
+      },
32
+      handleDrop(e) {
33
+        e.stopPropagation()
34
+        e.preventDefault()
35
+        if (this.loading) return
36
+        const files = e.dataTransfer.files
37
+        if (files.length !== 1) {
38
+          this.$message.error('Only support uploading one file!')
39
+          return
40
+        }
41
+        const rawFile = files[0] // only use files[0]
42
+
43
+        if (!this.isExcel(rawFile)) {
44
+          this.$message.error('Only supports upload .xlsx, .xls, .csv suffix files')
45
+          return false
46
+        }
47
+        this.upload(rawFile)
48
+        e.stopPropagation()
49
+        e.preventDefault()
50
+      },
51
+      handleDragover(e) {
52
+        e.stopPropagation()
53
+        e.preventDefault()
54
+        e.dataTransfer.dropEffect = 'copy'
55
+      },
56
+      handleUpload() {
57
+        document.getElementById('excel-drug-input').click()
58
+      },
59
+      handleClick(e) {
60
+        const files = e.target.files
61
+        const rawFile = files[0] // only use files[0]
62
+        if (!rawFile) return
63
+        this.upload(rawFile)
64
+      },
65
+      upload(rawFile) {
66
+        this.$refs['excel-drug-input'].value = null // fix can't select the same excel
67
+
68
+        if (!this.beforeUpload) {
69
+          this.readerData(rawFile)
70
+          return
71
+        }
72
+        const before = this.beforeUpload(rawFile)
73
+        if (before) {
74
+          this.readerData(rawFile)
75
+        }
76
+      },
77
+      readerData(rawFile) {
78
+        this.loading = true
79
+        return new Promise((resolve, reject) => {
80
+          const reader = new FileReader()
81
+          reader.onload = e => {
82
+            const data = e.target.result
83
+            const fixedData = this.fixdata(data)
84
+            const workbook = XLSX.read(btoa(fixedData), { type: 'base64' })
85
+            const firstSheetName = workbook.SheetNames[0]
86
+            const worksheet = workbook.Sheets[firstSheetName]
87
+            const header = this.get_header_row(worksheet)
88
+            const results = XLSX.utils.sheet_to_json(worksheet)
89
+            this.generateDate({ header, results })
90
+            this.loading = false
91
+            resolve()
92
+          }
93
+          reader.readAsArrayBuffer(rawFile)
94
+        })
95
+      },
96
+      fixdata(data) {
97
+        let o = ''
98
+        let l = 0
99
+        const w = 10240
100
+        for (; l < data.byteLength / w; ++l) o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w, l * w + w)))
101
+        o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w)))
102
+        return o
103
+      },
104
+      get_header_row(sheet) {
105
+        if(sheet['!ref'] == undefined){
106
+          this.loading = false
107
+          return
108
+        }
109
+
110
+        const headers = []
111
+        const range = XLSX.utils.decode_range(sheet['!ref'])
112
+        let C
113
+        const R = range.s.r /* start in the first row */
114
+        for (C = range.s.c; C <= range.e.c; ++C) { /* walk every column in the range */
115
+          var cell = sheet[XLSX.utils.encode_cell({ c: C, r: R })] /* find the cell in the first row */
116
+          var hdr = 'UNKNOWN ' + C // <-- replace with your desired default
117
+          if (cell && cell.t) hdr = XLSX.utils.format_cell(cell)
118
+          headers.push(hdr)
119
+        }
120
+        return headers
121
+      },
122
+      isExcel(file) {
123
+        return /\.(xlsx|xls|csv)$/.test(file.name)
124
+      }
125
+    }
126
+  }
127
+</script>
128
+
129
+<style scoped>
130
+  #excel-project-input {
131
+    display: none;
132
+    z-index: -9999;
133
+  }
134
+
135
+  #drop {
136
+    border: 2px dashed #bbb;
137
+    width: 600px;
138
+    height: 160px;
139
+    line-height: 160px;
140
+    margin: 0 auto;
141
+    font-size: 24px;
142
+    border-radius: 5px;
143
+    text-align: center;
144
+    color: #bbb;
145
+    position: relative;
146
+  }
147
+</style>

+ 147 - 0
src/xt_pages/components/ProjectExcel/index.vue View File

@@ -0,0 +1,147 @@
1
+<template>
2
+  <div>
3
+    <input id="excel-project-input" ref="excel-project-input" type="file" accept=".xlsx, .xls, .xltx" @change="handleClick">
4
+    <el-button :loading="loading" style="margin-left:16px;" size="mini" type="primary" @click="handleUpload">导入模板
5
+    </el-button>
6
+  </div>
7
+</template>
8
+
9
+<script>
10
+  import XLSX from 'xlsx'
11
+
12
+  export default {
13
+    props: {
14
+      beforeUpload: Function,
15
+      onSuccess: Function
16
+    },
17
+    data() {
18
+      return {
19
+        loading: false,
20
+        excelData: {
21
+          header: null,
22
+          results: null
23
+        }
24
+      }
25
+    },
26
+    methods: {
27
+      generateDate({ header, results }) {
28
+        this.excelData.header = header
29
+        this.excelData.results = results
30
+        this.onSuccess && this.onSuccess(this.excelData)
31
+      },
32
+      handleDrop(e) {
33
+        e.stopPropagation()
34
+        e.preventDefault()
35
+        if (this.loading) return
36
+        const files = e.dataTransfer.files
37
+        if (files.length !== 1) {
38
+          this.$message.error('Only support uploading one file!')
39
+          return
40
+        }
41
+        const rawFile = files[0] // only use files[0]
42
+
43
+        if (!this.isExcel(rawFile)) {
44
+          this.$message.error('Only supports upload .xlsx, .xls, .csv suffix files')
45
+          return false
46
+        }
47
+        this.upload(rawFile)
48
+        e.stopPropagation()
49
+        e.preventDefault()
50
+      },
51
+      handleDragover(e) {
52
+        e.stopPropagation()
53
+        e.preventDefault()
54
+        e.dataTransfer.dropEffect = 'copy'
55
+      },
56
+      handleUpload() {
57
+        document.getElementById('excel-project-input').click()
58
+      },
59
+      handleClick(e) {
60
+        const files = e.target.files
61
+        const rawFile = files[0] // only use files[0]
62
+        if (!rawFile) return
63
+        this.upload(rawFile)
64
+      },
65
+      upload(rawFile) {
66
+        this.$refs['excel-project-input'].value = null // fix can't select the same excel
67
+
68
+        if (!this.beforeUpload) {
69
+          this.readerData(rawFile)
70
+          return
71
+        }
72
+        const before = this.beforeUpload(rawFile)
73
+        if (before) {
74
+          this.readerData(rawFile)
75
+        }
76
+      },
77
+      readerData(rawFile) {
78
+        this.loading = true
79
+        return new Promise((resolve, reject) => {
80
+          const reader = new FileReader()
81
+          reader.onload = e => {
82
+            const data = e.target.result
83
+            const fixedData = this.fixdata(data)
84
+            const workbook = XLSX.read(btoa(fixedData), { type: 'base64' })
85
+            const firstSheetName = workbook.SheetNames[0]
86
+            const worksheet = workbook.Sheets[firstSheetName]
87
+            const header = this.get_header_row(worksheet)
88
+            const results = XLSX.utils.sheet_to_json(worksheet)
89
+            this.generateDate({ header, results })
90
+            this.loading = false
91
+            resolve()
92
+          }
93
+          reader.readAsArrayBuffer(rawFile)
94
+        })
95
+      },
96
+      fixdata(data) {
97
+        let o = ''
98
+        let l = 0
99
+        const w = 10240
100
+        for (; l < data.byteLength / w; ++l) o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w, l * w + w)))
101
+        o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w)))
102
+        return o
103
+      },
104
+      get_header_row(sheet) {
105
+        if(sheet['!ref'] == undefined){
106
+          this.loading = false
107
+          return
108
+        }
109
+
110
+        const headers = []
111
+        const range = XLSX.utils.decode_range(sheet['!ref'])
112
+        let C
113
+        const R = range.s.r /* start in the first row */
114
+        for (C = range.s.c; C <= range.e.c; ++C) { /* walk every column in the range */
115
+          var cell = sheet[XLSX.utils.encode_cell({ c: C, r: R })] /* find the cell in the first row */
116
+          var hdr = 'UNKNOWN ' + C // <-- replace with your desired default
117
+          if (cell && cell.t) hdr = XLSX.utils.format_cell(cell)
118
+          headers.push(hdr)
119
+        }
120
+        return headers
121
+      },
122
+      isExcel(file) {
123
+        return /\.(xlsx|xls|csv)$/.test(file.name)
124
+      }
125
+    }
126
+  }
127
+</script>
128
+
129
+<style scoped>
130
+  #excel-project-input {
131
+    display: none;
132
+    z-index: -9999;
133
+  }
134
+
135
+  #drop {
136
+    border: 2px dashed #bbb;
137
+    width: 600px;
138
+    height: 160px;
139
+    line-height: 160px;
140
+    margin: 0 auto;
141
+    font-size: 24px;
142
+    border-radius: 5px;
143
+    text-align: center;
144
+    color: #bbb;
145
+    position: relative;
146
+  }
147
+</style>

+ 2 - 2
src/xt_pages/dialysis/details/dialog/DoctorAdviceDialog.vue View File

@@ -295,7 +295,7 @@
295 295
         >
296 296
           <template slot-scope="scope">
297 297
             <span v-if="scope.row.execution_time != 0">
298
-              {{scope.row.start_time | parseTime('{m}-{d} {h}:{i}')}}
298
+              {{scope.row.execution_time | parseTime('{m}-{d} {h}:{i}')}}
299 299
             </span>
300 300
             <span v-else></span>
301 301
           </template>
@@ -385,7 +385,7 @@
385 385
         >
386 386
           <template slot-scope="scope">
387 387
             <span v-if="scope.row.execution_time != 0">
388
-              {{scope.row.start_time | parseTime('{m}-{d} {h}:{i}')}}
388
+              {{scope.row.execution_time | parseTime('{m}-{d} {h}:{i}')}}
389 389
             </span>
390 390
             <span v-else></span>
391 391
           </template>

+ 1 - 1
src/xt_pages/dialysis/dialysisDoctorAdvice.vue View File

@@ -149,7 +149,7 @@
149 149
         >
150 150
           <template slot-scope="scope">
151 151
             <span v-if="scope.row.execution_time != 0">
152
-              {{scope.row.start_time | parseTime('{m}-{d} {h}:{i}')}}
152
+              {{scope.row.execution_time | parseTime('{m}-{d} {h}:{i}')}}
153 153
             </span>
154 154
             <span v-else></span>
155 155
           </template>

+ 11 - 1
src/xt_pages/stock/drugs/drugStockInOrderEdit.vue View File

@@ -586,11 +586,21 @@ export default {
586 586
               return;
587 587
             }
588 588
           }
589
+          for(let i=0;i<this.recordInfo.recordData.length;i++){
590
+             if(this.recordInfo.recordData[i].dealer == ""){
591
+                this.recordInfo.recordData[i].dealer = 0
592
+             }
593
+             
594
+             if(this.recordInfo.recordData[i].manufacturer == ""){
595
+               this.recordInfo.recordData[i].manufacturer = 0
596
+             }
597
+            
598
+          }
589 599
           const params = {
590 600
             stockIn: this.recordInfo.recordData
591 601
           };
592 602
           console.log("params",params)
593
-    
603
+         
594 604
           EditDrugWarehouse(
595 605
             params,
596 606
             this.warehousing_time,