28169 il y a 6 mois
Parent
révision
6158eefde7
2 fichiers modifiés avec 431 ajouts et 13 suppressions
  1. 418 0
      src/xt_pages/outpatientTool/drugCodeQuery.vue
  2. 13 13
      src/xt_permission.js

+ 418 - 0
src/xt_pages/outpatientTool/drugCodeQuery.vue Voir le fichier

@@ -0,0 +1,418 @@
1
+<template>
2
+    <div>
3
+      <div style="display: flex;justify-content: space-between;margin-bottom:10px;">
4
+        <div class="cell clearfix">
5
+          <span>发药时间:</span>
6
+          <el-date-picker
7
+            size="small"
8
+            v-model="start_time"
9
+            prefix-icon="el-icon-date"
10
+            :editable="false"
11
+            style="width: 196px;"
12
+            type="date"
13
+            placeholder="选择日期时间"
14
+            align="right"
15
+            format="yyyy-MM-dd"
16
+            value-format="yyyy-MM-dd"
17
+            @change="changeStartTime"
18
+          ></el-date-picker>-
19
+          <el-date-picker
20
+           @change="changeEndTime"
21
+            size="small"
22
+            v-model="end_time"
23
+            prefix-icon="el-icon-date"
24
+            :editable="false"
25
+            style="width: 196px;margin-right:10px;"
26
+            type="date"
27
+            placeholder="选择日期时间"
28
+            align="right"
29
+            format="yyyy-MM-dd"
30
+            value-format="yyyy-MM-dd"
31
+          ></el-date-picker>
32
+        </div>
33
+  
34
+  
35
+        <div>
36
+          <div>上传状态:
37
+            <el-select size="small" v-model="is_sale" placeholder="请选择" style="width:100px;" @change="changeStock">
38
+                <el-option
39
+                  v-for="item,index in items"
40
+                  :key="index"
41
+                  :label="item.name"
42
+                  :value="item.id">
43
+                </el-option>
44
+            </el-select>
45
+         </div>
46
+        </div>
47
+  
48
+        <div>
49
+          <el-button type="primary" @click="query()">查询</el-button>
50
+          <el-button type="primary" @click="exportdata()">导出</el-button>
51
+        </div>
52
+      </div>
53
+      <el-table :data="tableData" border :row-style="{ color: '#303133' }" ref="table2"
54
+                :header-cell-style="{backgroundColor: 'rgb(245, 247, 250)',color: '#606266'}"
55
+                max-height="800"
56
+                @select="selectCostInfo"
57
+                @selection-change="changeCostInfoTableData"
58
+                @select-all="changeAllCostInfoTableData"
59
+                highlight-current-row>
60
+        <el-table-column align="center" prop="name" label="患者姓名">
61
+          <template slot-scope="scope">{{getPatientName(scope.row.patient_id) }}</template>
62
+        </el-table-column>
63
+        <el-table-column align="center" prop="name" label="处方日期">
64
+          <template slot-scope="scope">{{getTime(scope.row.advice_date)}}</template>
65
+        </el-table-column>
66
+        <el-table-column align="center" prop="name" label="药品名称">
67
+          <template slot-scope="scope">{{ scope.row.advice_name }}</template>
68
+        </el-table-column>
69
+        <el-table-column align="center" prop="name" label="规格">
70
+          <template slot-scope="scope">{{getDrugSpec(scope.row.drug_id)}}</template>
71
+        </el-table-column>
72
+        <el-table-column align="center" prop="name" label="开药总量">
73
+          <template slot-scope="scope">{{scope.row.prescribing_number}}{{ scope.row.prescribing_number_unit }}</template>
74
+        </el-table-column>
75
+        <el-table-column align="center" prop="name" label="药品追溯码">
76
+          <template slot-scope="scope">
77
+            <div @click="getDrugCode(scope.row.id,scope.row.DataSources,scope.row.drug_code,scope.$index)"><el-input style="width: 100;" v-model="scope.row.drug_code"></el-input></div> 
78
+          </template>
79
+        </el-table-column>
80
+        <el-table-column align="center" prop="name" label="上传状态">
81
+          <template slot-scope="scope">
82
+            <div v-if="scope.row.is_upload == 1">已上传</div>
83
+            <div v-if="scope.row.is_upload == 2 || scope.row.is_upload == 0">未上传</div>
84
+          </template>
85
+        </el-table-column>
86
+
87
+        <el-table-column align="center" prop="name" label="发药状态">
88
+          <template slot-scope="scope">
89
+            <div v-if="scope.row.is_medicine == 1">已发药</div>
90
+            <div v-if="scope.row.is_medicine == 2 || scope.row.is_medicine == 0">未发药</div>
91
+          </template>
92
+        </el-table-column>
93
+
94
+        <el-table-column align="center" prop="name" label="操作" width="200">
95
+          <template slot-scope="scope">
96
+            <div>
97
+             <el-button v-if="scope.row.is_upload == 1" type="primary" @click="sigle_stock(scope.row)">未上传</el-button>   
98
+            <el-button type="primary" v-if="scope.row.is_upload == 0 || scope.row.is_upload == 2" @click="toUpload(scope.row)">上传</el-button>
99
+            <el-button v-if="faShow == true" type="primary" @click="toFaYao(scope.row)">发药</el-button>   
100
+            </div>
101
+          </template>
102
+        </el-table-column>
103
+  
104
+       
105
+      </el-table>
106
+      <el-pagination
107
+        @size-change="handleSizeChange"
108
+        @current-change="handleCurrentChange"
109
+        :page-size="5"
110
+        :page-sizes="[10, 20, 50, 100,500,1000,2000]"
111
+        background
112
+        style="margin-top:20px;float: right"
113
+        :total="value"
114
+      ></el-pagination>
115
+  
116
+    
117
+ 
118
+  
119
+
120
+      <el-dialog
121
+        title="药品追溯码"
122
+        :visible.sync="dialogVisibleOne"
123
+         width="40%">
124
+       <span>
125
+        <el-input
126
+          @keyup.native="changeText"
127
+          type="textarea"
128
+          placeholder="请输入内容"
129
+          v-model="textarea"
130
+          :rows="10"
131
+        >
132
+        </el-input>
133
+      </span>
134
+      <span slot="footer" class="dialog-footer">
135
+        <el-button @click="dialogVisibleOne = false">取 消</el-button>
136
+        <el-button type="primary" @click="saveTextArea()">确 定</el-button>
137
+      </span>
138
+      </el-dialog>
139
+    </div>
140
+  
141
+   
142
+  </template>
143
+  
144
+  
145
+  <script>
146
+  import BreadCrumb from '@/xt_pages/components/bread-crumb'
147
+  import { getHisDrugCodeQueryList,createUploadDrugCode,getPatientDrugCode } from '../../api/new_stock/stock'
148
+  import { getDictionaryDataConfig } from "@/utils/data";
149
+  import { uParseTime } from '@/utils/tools'
150
+  import { changeDrugCode } from "@/api/pharmacy";
151
+  import axios from 'axios'
152
+  const moment = require('moment')
153
+  export default {
154
+    components: {
155
+      BreadCrumb
156
+    },
157
+    data() {
158
+      return {
159
+        drugTypeList: [{ id: 0, name: "全部" }],
160
+        start_time: new Date(new Date().getFullYear(), new Date().getMonth(), 1).toLocaleDateString('en-CA'),
161
+        end_time: new Date(new Date().getFullYear(), new Date().getMonth() + 1, 0).toLocaleDateString('en-CA'),
162
+  
163
+        tableData: [],
164
+        change_type:"3",
165
+        selection:[],
166
+        page:1,
167
+        limit:10,
168
+        value:0,
169
+        is_sale:"0",
170
+        items: [
171
+          { id: "0", name: '全部' },
172
+          { id: "1", name: '已上传' },
173
+          { id: "2", name: '未上传' },
174
+        ],
175
+        patientList:[],
176
+        drugList:[],
177
+        dialogVisibleOne:false,
178
+        id:0,
179
+        is_source:0,
180
+        drug_code:0,
181
+        currentRow:{},
182
+        currentIndex:0,
183
+        is_drug_open:"2",
184
+        textarea:'',
185
+        total:0,
186
+        faShow:false,
187
+        is_open:false,
188
+      }
189
+    },
190
+    methods: {
191
+        changeText(event){
192
+        // 检查是否为特定的按键,例如回车键,来确认扫码枪输入完成
193
+        if (event.key === 'Enter') {
194
+            var textarea = ""
195
+            textarea += this.textarea + ","
196
+            this.textarea = textarea
197
+        }
198
+       },
199
+       getDrugCode(id,DataSources,DrugCode,index){
200
+            this.id = id 
201
+            this.textarea = DrugCode
202
+            this.currentIndex = index
203
+            this.dialogVisibleOne = true
204
+      },
205
+      saveTextArea(){
206
+       var params = {
207
+        id:this.id,
208
+        data_source:1,
209
+        drug_code:this.textarea,
210
+       }
211
+       console.log("paramss",params)
212
+      changeDrugCode(params).then(response=>{
213
+         if(response.data.state == 1){
214
+            this.$message.success("保存成功!")
215
+            for(let i=0;i<this.tableData.length;i++){
216
+             if(this.currentIndex == i){
217
+                this.tableData[i].drug_code = this.textarea
218
+             }
219
+            }
220
+            this.dialogVisibleOne = false
221
+         }
222
+      })
223
+    },
224
+    getPatientName(id){
225
+       var name = ""
226
+       for(let i=0;i<this.patientList.length;i++){
227
+          if(id == this.patientList[i].id){
228
+             name = this.patientList[i].name
229
+          }
230
+       }
231
+       return name
232
+      },
233
+      getTime(val) {
234
+         if(val < 0){
235
+           return ""
236
+         }
237
+         if(val == ""){
238
+          return ""
239
+         }else {
240
+          return uParseTime(val, '{y}-{m}-{d}')
241
+         }
242
+      },
243
+      getDrugName(drug_id){
244
+        var drug_name = ""
245
+        for(let i=0;i<this.drugList.length;i++){
246
+           if(drug_id == this.drugList[i].id){
247
+              drug_name = this.drugList[i].drug_name
248
+           }
249
+        }
250
+        return drug_name
251
+      },
252
+      getDrugSpec(drug_id){
253
+        var specification_name = ""
254
+        for(let i=0;i<this.drugList.length;i++){
255
+          if(drug_id == this.drugList[i].id){
256
+            specification_name = this.drugList[i].specification_name
257
+          }
258
+        }
259
+        return specification_name
260
+      },
261
+      handleSizeChange(val) {
262
+        this.limit = val
263
+        this.getlist()
264
+      },
265
+      handleCurrentChange(val) {
266
+        this.page = val
267
+        this.getlist()
268
+      },
269
+      selectCostInfo(selection, row) {
270
+        this.selection = selection
271
+      },
272
+       changeCostInfoTableData(val) {
273
+        this.selection = val
274
+      }, changeAllCostInfoTableData(selection) {
275
+        this.selection = selection
276
+      },
277
+      delete(){
278
+  
279
+  
280
+      },
281
+      exportdata(){
282
+        console.log("hahahahh",this.tableData)
283
+        if(this.tableData!=null && this.tableData.length>0){
284
+           for(let i=0;i<this.tableData.length;i++){
285
+             this.tableData[i].patient_name = this.getPatientName(this.tableData[i].patient_id)
286
+             this.tableData[i].advice_date_str = this.getTime(this.tableData[i].advice_date)
287
+             if(this.tableData[i].is_upload == 1){
288
+                this.tableData[i].is_upload_name = "已上传"
289
+             }
290
+             if(this.tableData[i].is_upload == 2 || this.tableData[i].is_upload == 0){
291
+                this.tableData[i].is_upload_name = "未上传"
292
+             }
293
+
294
+             if(this.tableData[i].is_medicine == 1){
295
+                this.tableData[i].is_medicine_name = "已发药"
296
+             }
297
+             if(this.tableData[i].is_medicine == 2 || this.tableData[i].is_medicine == 0){
298
+                this.tableData[i].is_medicine_name = "未发药"
299
+             }
300
+             this.tableData[i].specification_name = this.getDrugSpec(this.tableData[i].drug_id)
301
+           }
302
+        }
303
+       
304
+        import('@/vendor/Export2Excel').then(excel => {
305
+          const tHeader = ['患者姓名', '处方日期', '药品名称', '规格', '开药总量', '药品追溯码','上传状态','发药状态']
306
+          const filterVal = ['patient_name', 'advice_date_str', 'advice_name', 'specification_name', 'prescribing_numbers', 'drug_code','is_upload_name','is_medicine_name']
307
+
308
+          const data = this.formatJson(filterVal, this.tableData)
309
+           excel.export_json_to_excel({
310
+           header: tHeader,
311
+           data,
312
+           filename: '药品追溯'
313
+         })
314
+        })
315
+  
316
+      },formatJson(filterVal, jsonData) {
317
+        return jsonData.map(v => filterVal.map(j => v[j]))
318
+      },
319
+    
320
+      query(){
321
+        this.getlist()
322
+      },
323
+      getDrugType(id) {
324
+        var name = "";
325
+        for (let i = 0; i < this.drugTypeList.length; i++) {
326
+          if (this.drugTypeList[i].id == id) {
327
+            name = this.drugTypeList[i].name;
328
+          }
329
+        }
330
+  
331
+        return name;
332
+      },  
333
+      getTime(val) {
334
+        if(val == "" || val == undefined){
335
+          return ""
336
+        }else {
337
+          return uParseTime(val, '{y}-{m}-{d}')
338
+        }
339
+      },
340
+      getlist(){
341
+        this.tableData = []
342
+        let params = {
343
+          start_time: this.start_time,
344
+          end_time: this.end_time,
345
+          page:this.page,
346
+          limit:this.limit,
347
+          is_sale:this.is_sale,
348
+        
349
+        }
350
+        getHisDrugCodeQueryList(params).then(response => {
351
+          if (response.data.state == 0) {
352
+            this.$message.error(response.data.msg)
353
+            return false
354
+          } else {
355
+             this.tableData = response.data.data.list
356
+             this.total = response.data.data.total
357
+             this.drugList = response.data.data.drug
358
+             this.patientList = response.data.data.patients
359
+             this.is_open = response.data.data.codeConfig.is_open
360
+          }
361
+        })
362
+      },
363
+      changeStock(val){
364
+        this.is_sale = val
365
+        this.getlist()
366
+      },
367
+      changeStartTime(val){
368
+        this.start_time = val
369
+      },
370
+      changeEndTime(val){
371
+        this.end_time = val
372
+      },
373
+      toUpload(row){
374
+        if(row.is_medicine == 0 || row.is_is_medicine == 2){
375
+          this.$message.error("该药品未发药,请先发药")
376
+          this.faShow = true
377
+          return
378
+        }
379
+        var params = {
380
+          drug_id:row.drug_id,
381
+          patient_id:row.patient_id,
382
+         advice_date:row.advice_date,
383
+        }
384
+        createUploadDrugCode(params).then(response=>{
385
+          if(response.data.state == 1){
386
+            this.$message.success("上传成功!")
387
+          }
388
+        })
389
+      },
390
+      toFaYao(row){
391
+        if(this.is_open == 1){
392
+          if(row.drug_code==''){
393
+             this.$message.error("药品追溯码不能为空!")
394
+             return
395
+          }
396
+        }
397
+          var params= {
398
+            drug_id:row.drug_id,
399
+            patient_id:row.patient_id,
400
+            advice_date:row.advice_date,
401
+          }
402
+        getPatientDrugCode(params).then(response=>{
403
+          if(response.data.state == 1){
404
+             this.$message.success("发药成功!")
405
+             this.getlist()
406
+          } 
407
+        })
408
+      }
409
+    },
410
+    created() {
411
+      var drugTypeList = getDictionaryDataConfig("system", "drug_type");
412
+      this.drugTypeList.push(...drugTypeList);
413
+      this.getlist()
414
+    }
415
+  }
416
+  </script>
417
+  
418
+  

+ 13 - 13
src/xt_permission.js Voir le fichier

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