Przeglądaj źródła

修改检验检查显示

张保健 4 lat temu
rodzic
commit
75d4138c9d
1 zmienionych plików z 308 dodań i 371 usunięć
  1. 308 371
      src/xt_pages/user/inspection.vue

+ 308 - 371
src/xt_pages/user/inspection.vue Wyświetl plik

@@ -4,30 +4,10 @@
4 4
     <div class="patient-app-container app-container" v-loading="pageLoading" element-loading-text="拼命加载中">
5 5
       <el-row :gutter="20">
6 6
         <el-col :span="7">
7
-          <el-table
8
-            :header-cell-style="{
9
-              backgroundColor: 'rgb(245, 247, 250)',
10
-              color: '#606266'
11
-            }"
12
-            :row-style="{ color: '#303133' }"
13
-            :data="projects"
14
-            border
15
-            style="width: 100%"
16
-            highlight-current-row
17
-            @current-change="handleCurrentChange"
18
-            ref="singleTable"
19
-          >
7
+          <el-table :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)', color: '#606266' }" :row-style="{ color: '#303133' }" :data="projects"  border style="width: 100%" highlight-current-row  @current-change="handleCurrentChange" ref="singleTable"  >
20 8
             <el-table-column label="检验检查项目" align="center">
21
-              <el-table-column
22
-                prop="project_name"
23
-                label="检验项目"
24
-                align="center">
25
-              </el-table-column>
26
-              <el-table-column
27
-                prop="count"
28
-                label="次数"
29
-                width="80"
30
-                align="center">
9
+              <el-table-column prop="project_name" label="检验项目" align="center"> </el-table-column>
10
+              <el-table-column prop="count" label="次数"  width="80"  align="center">
31 11
               </el-table-column>
32 12
             </el-table-column>
33 13
           </el-table>
@@ -41,71 +21,35 @@
41 21
           <div class="filter-container" >
42 22
             <el-button class="filter-item" type="text" style="color:#000">{{itemName}} <span v-if="itemDate">(检查日期:{{itemDate}})</span></el-button>
43 23
           </div>
44
-          <el-table
45
-            :header-cell-style="{
46
-              backgroundColor: 'rgb(245, 247, 250)',
47
-              color: '#606266'
48
-            }"
49
-            :row-style="{ color: '#303133' }"
50
-            :data="items"
51
-            border
52
-            style="width: 100%"
53
-            id="user-inspection-order"
54
-          >
55
-            <el-table-column
56
-              prop="item_name"
57
-              label="检验项目"
58
-              align="center"
59
-              min-width="180">
24
+          <el-table :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)', color: '#606266'  }"  :row-style="{ color: '#303133' }" :data="items"  border  style="width: 100%"  id="user-inspection-order" >
25
+            <el-table-column prop="item_name" label="检验项目" align="center" min-width="180">
60 26
               <template slot-scope="scope">
61 27
                 {{scope.row.item_name}} {{scope.row.item_name_addition}}
62 28
               </template>
63 29
             </el-table-column>
64
-            <el-table-column
65
-              prop="name"
66
-              label="结果"
67
-              align="center"
68
-              min-width="80">
30
+            <el-table-column prop="name" label="结果" align="center" min-width="80">
69 31
               <template slot-scope="scope">
70 32
                 <span>{{scope.row.value}}</span>
71 33
                 <span v-if="scope.row.range_type==1">{{scope.row.value_direction}}</span>
72 34
               </template>
73 35
             </el-table-column>
74
-            <el-table-column
75
-              prop="address"
76
-              label="参考值"
77
-              align="center"
78
-              min-width="120">
36
+            <el-table-column prop="address" label="参考值" align="center" min-width="120">
79 37
               <template slot-scope="scope">
80 38
                 <span v-if="scope.row.range_type==1">{{scope.row.range_min}}~{{scope.row.range_max}}</span>
81 39
                 <span v-else>{{scope.row.range_value}}</span>
82 40
               </template>
83 41
             </el-table-column>
84
-            <el-table-column
85
-              prop="unit"
86
-              label="单位"
87
-              align="center"
88
-              min-width="80">
42
+            <el-table-column prop="unit" label="单位"  align="center"  min-width="80">
89 43
             </el-table-column>
90 44
           </el-table>
91
-          <el-pagination
92
-          align="right"
93
-            @current-change="handleCurrentChangePage"
94
-            :current-page="queryParams.page"
95
-            :page-size="1"
96
-            background
97
-            style="margin-top:20px;"
98
-            layout="total, prev, pager, next, jumper"
99
-            :total="total">
45
+          <el-pagination align="right"  @current-change="handleCurrentChangePage" :current-page="queryParams.page" :page-size="1"  background style="margin-top:20px;" layout="total, prev, pager, next, jumper" :total="total">
100 46
           </el-pagination>
101 47
         </el-col>
102 48
       </el-row>
103 49
     </div>
104 50
 
105 51
     <el-dialog :title="formTitle" :visible.sync="dialogFormVisible" width="1000px" id="user-inspection-form" v-loading="formLoading">
106
-
107 52
       <el-form :model="form"  ref="form" label-position="top">
108
-
109 53
         <el-row >
110 54
           <el-col :span="24" v-if="form.formItem[0].project_id == 14">
111 55
             <el-form-item label="传染病周期提醒: " >
@@ -173,447 +117,440 @@
173 117
 </template>
174 118
 
175 119
 <script>
176
-import PatientSidebar from "./components/PatientSidebar";
177
-import {fetchInspectionReference,CreatePatientInspection,fetchPatientInspections,EditPatientInspection,DeletePatientInspection} from "@/api/inspection";
178
-import {uParseTime,isPositiveNumber} from "@/utils/tools";
120
+import PatientSidebar from './components/PatientSidebar'
121
+import { fetchInspectionReference, CreatePatientInspection, fetchPatientInspections, EditPatientInspection, DeletePatientInspection } from '@/api/inspection'
122
+import { uParseTime, isPositiveNumber } from '@/utils/tools'
179 123
 
180 124
 export default {
181
-  name: "Inspection",
125
+  name: 'Inspection',
182 126
   components: { PatientSidebar },
183 127
   data() {
184 128
     return {
185
-      total:0,
186
-      pageLoading:true,
187
-      itemLoading:false,
188
-      formLoading:false,
189
-      itemDate:'',
129
+      total: 0,
130
+      pageLoading: true,
131
+      itemLoading: false,
132
+      formLoading: false,
133
+      itemDate: '',
190 134
       patientID: 0,
191
-      panelClass: "patient-app-container",
135
+      panelClass: 'patient-app-container',
192 136
       patientInfo: {
193 137
         id: 0
194 138
       },
195
-      itemName:'请选择项目',
196
-      formTitle:'',
197
-      dialogFormVisible:false,
198
-      patient_info:null,
199
-      form:{
200
-        remind_cycle:'',
201
-        method:'add',
202
-        project_id:0,
203
-        inspect_date:'',
204
-        formItem:[
205
-          {id:0, value:''},
139
+      itemName: '请选择项目',
140
+      formTitle: '',
141
+      dialogFormVisible: false,
142
+      patient_info: null,
143
+      form: {
144
+        remind_cycle: '',
145
+        method: 'add',
146
+        project_id: 0,
147
+        inspect_date: '',
148
+        formItem: [
149
+          { id: 0, value: '' }
206 150
         ]
207 151
       },
208
-      formItem:[],
209
-      items:[],
210
-      inspections:[],
211
-      inspectionsMap:{},
212
-      projects:[],
213
-      project:null,
214
-      queryParams:{
215
-        patient:0,
216
-        project_id:0,
217
-        page:1
218
-      },
219
-    };
152
+      formItem: [],
153
+      items: [],
154
+      inspections: [],
155
+      inspectionsMap: {},
156
+      projects: [],
157
+      project: null,
158
+      queryParams: {
159
+        patient: 0,
160
+        project_id: 0,
161
+        page: 1
162
+      }
163
+    }
220 164
   },
221
-  methods:{
222
-    deleteInspection(){
223
-
224
-      if(this.project == null || this.itemDate == "") {
225
-        this.$message.error("请先选择删除删除的记录");
226
-        return false;
165
+  methods: {
166
+    deleteInspection() {
167
+      if (this.project == null || this.itemDate == '') {
168
+        this.$message.error('请先选择删除删除的记录')
169
+        return false
227 170
       }
228 171
 
229 172
       this.$confirm('确认删除此记录?', '删除', {
230
-          confirmButtonText: '确定',
231
-          cancelButtonText: '取消',
232
-          type: 'warning'
173
+        confirmButtonText: '确定',
174
+        cancelButtonText: '取消',
175
+        type: 'warning'
233 176
       }).then(() => {
234
-        var params = {patient: this.patientID, date: this.itemDate, project_id: this.project.project_id};
235
-          DeletePatientInspection(params).then(response=>{
236
-              if(response.data.state==0) {
237
-                  this.$message.error(response.data.msg);
238
-                  return false;
239
-              }else {
240
-                this.$notify({
241
-                    title: "成功",
242
-                    message: "删除成功",
243
-                    type: "success",
244
-                    duration: 2000
245
-                });
246
-
247
-                for( var index in this.projects) {
248
-                  if (this.projects[index].project_id == params.project_id) {
249
-                    this.projects[index].count --;
250
-                    break;
251
-                  }
252
-                }
253
-                this.total -=1;
254
-                this.itemDate = "";
255
-                this.items = [];
256
-                if(this.total > 0) {
257
-                  this.queryParams.page = 1;
258
-                  this.fetchPatientInspections(this.queryParams);
259
-                }
177
+        var params = { patient: this.patientID, date: this.itemDate, project_id: this.project.project_id }
178
+        DeletePatientInspection(params).then(response => {
179
+          if (response.data.state == 0) {
180
+            this.$message.error(response.data.msg)
181
+            return false
182
+          } else {
183
+            this.$notify({
184
+              title: '成功',
185
+              message: '删除成功',
186
+              type: 'success',
187
+              duration: 2000
188
+            })
189
+
190
+            for (var index in this.projects) {
191
+              if (this.projects[index].project_id == params.project_id) {
192
+                this.projects[index].count--
193
+                break
260 194
               }
261
-          });
262
-      }).catch(() => { });
195
+            }
196
+            this.total -= 1
197
+            this.itemDate = ''
198
+            this.items = []
199
+            if (this.total > 0) {
200
+              this.queryParams.page = 1
201
+              this.fetchPatientInspections(this.queryParams)
202
+            }
203
+          }
204
+        })
205
+      }).catch(() => { })
263 206
     },
264
-    openEdit(){
265
-      if(this.project == null) {
266
-        this.$message.error("请先选择项目");
267
-        return false;
207
+    openEdit() {
208
+      if (this.project == null) {
209
+        this.$message.error('请先选择项目')
210
+        return false
268 211
       }
269 212
 
270
-      this.form.method = "edit";
271
-      this.formTitle = "修改" + this.project.project_name;
272
-      this.form.project_id = this.project.project_id;
273
-      this.form.inspect_date = this.itemDate;
213
+      this.form.method = 'edit'
214
+      this.formTitle = '修改' + this.project.project_name
215
+      this.form.project_id = this.project.project_id
216
+      this.form.inspect_date = this.itemDate
274 217
       this.form.remind_cycle = this.patient_info.remind_cycle
275 218
       console.log(this.form.remind_cycle)
276 219
 
277
-      this.form.formItem = [];
278
-      for(var index in this.project.inspection_reference){
220
+      this.form.formItem = []
221
+      for (var index in this.project.inspection_reference) {
279 222
         this.form.formItem.push({
280
-          id:  (this.project.inspection_reference[index].id in this.inspectionsMap)? this.inspectionsMap[this.project.inspection_reference[index].id].id:0,
223
+          id: (this.project.inspection_reference[index].id in this.inspectionsMap) ? this.inspectionsMap[this.project.inspection_reference[index].id].id : 0,
281 224
           project_id: this.project.inspection_reference[index].project_id,
282 225
           project_name: this.project.inspection_reference[index].project_name,
283 226
           item_id: this.project.inspection_reference[index].id,
284 227
           item: this.project.inspection_reference[index].item,
285 228
           item_name: this.project.inspection_reference[index].item_name,
286 229
           range_type: this.project.inspection_reference[index].range_type,
287
-          value:(this.project.inspection_reference[index].id in this.inspectionsMap)? this.inspectionsMap[this.project.inspection_reference[index].id].inspect_value:"",
288
-          select_options: this.project.inspection_reference[index].range_options.split(","),
289
-          unit: this.project.inspection_reference[index].unit,
290
-        });
230
+          value: (this.project.inspection_reference[index].id in this.inspectionsMap) ? this.inspectionsMap[this.project.inspection_reference[index].id].inspect_value : '',
231
+          select_options: this.project.inspection_reference[index].range_options.split(','),
232
+          unit: this.project.inspection_reference[index].unit
233
+        })
291 234
       }
292 235
 
293
-      console.log( this.form.formItem)
294
-
295
-      this.dialogFormVisible = true;
236
+      console.log(this.form.formItem)
296 237
 
238
+      this.dialogFormVisible = true
297 239
     },
298
-    openNew(){
299
-      if(this.project == null) {
300
-        this.$message.error("请先选择项目");
301
-        return false;
240
+    openNew() {
241
+      if (this.project == null) {
242
+        this.$message.error('请先选择项目')
243
+        return false
302 244
       }
303
-      this.form.method = "add";
304
-      this.formTitle = "新增" + this.project.project_name;
305
-      this.form.project_id = this.project.project_id;
245
+      this.form.method = 'add'
246
+      this.formTitle = '新增' + this.project.project_name
247
+      this.form.project_id = this.project.project_id
306 248
       this.form.remind_cycle = this.patient_info.remind_cycle
307 249
 
308
-      var today = new Date();
309
-      this.form.inspect_date = uParseTime(today, '{y}-{m}-{d}');
310
-      this.form.formItem = [];
311
-      for(var index in this.project.inspection_reference){
250
+      var today = new Date()
251
+      this.form.inspect_date = uParseTime(today, '{y}-{m}-{d}')
252
+      this.form.formItem = []
253
+      for (var index in this.project.inspection_reference) {
312 254
         // var formItem = this.project.inspection_reference[index];
313 255
         // formItem["value"] = '';
314 256
         // if (formItem.range_type==2) {
315 257
         //   formItem["select_options"] = formItem.range_options.split(",");
316 258
         // }
317 259
         this.form.formItem.push({
318
-          id:    0,
260
+          id: 0,
319 261
           project_id: this.project.inspection_reference[index].project_id,
320 262
           project_name: this.project.inspection_reference[index].project_name,
321 263
           item_id: this.project.inspection_reference[index].id,
322 264
           item: this.project.inspection_reference[index].item,
323 265
           item_name: this.project.inspection_reference[index].item_name,
324 266
           range_type: this.project.inspection_reference[index].range_type,
325
-          value:'',
326
-          select_options: this.project.inspection_reference[index].range_options.split(","),
327
-          unit: this.project.inspection_reference[index].unit,
328
-        });
267
+          value: '',
268
+          select_options: this.project.inspection_reference[index].range_options.split(','),
269
+          unit: this.project.inspection_reference[index].unit
270
+        })
329 271
       }
330 272
 
331
-      this.dialogFormVisible = true;
273
+      this.dialogFormVisible = true
332 274
     },
333
-    submitEdit(formName){
275
+    submitEdit(formName) {
334 276
       this.$refs[formName].validate((valid) => {
335 277
         if (valid) {
336
-          this.formLoading = true;
337
-          if (this.form.formItem.length==0) {
338
-            this.$message.error("未填写项目");
339
-            return false;
278
+          this.formLoading = true
279
+          if (this.form.formItem.length == 0) {
280
+            this.$message.error('未填写项目')
281
+            return false
340 282
           }
341
-          for( var index in this.form.formItem) {
342
-            this.form.formItem[index].value = '' + this.form.formItem[index].value;
283
+          for (var index in this.form.formItem) {
284
+            this.form.formItem[index].value = '' + this.form.formItem[index].value
343 285
           }
344 286
 
345
-
346
-
347
-
348
-          EditPatientInspection(this.patientID, this.form,this.form.remind_cycle).then(response=>{
349
-            if (response.data.state==1) {
287
+          EditPatientInspection(this.patientID, this.form, this.form.remind_cycle).then(response => {
288
+            if (response.data.state == 1) {
350 289
               this.$notify({
351
-                title: "成功",
352
-                message: "修改成功",
353
-                type: "success",
290
+                title: '成功',
291
+                message: '修改成功',
292
+                type: 'success',
354 293
                 duration: 2000
355
-              });
294
+              })
356 295
               this.patient_info.remind_cycle = response.data.data.remind_cycle
357
-              this.itemDate = this.form.inspect_date;
358
-              this.items=[];
359
-              var inspections = response.data.data.inspections;
360
-              this.inspections = response.data.data.inspections;
361
-              if (inspections==null) {
362
-                this.inspections = [];
363
-                return false;
296
+              this.itemDate = this.form.inspect_date
297
+              this.items = []
298
+              var inspections = response.data.data.inspections
299
+              this.inspections = response.data.data.inspections
300
+              if (inspections == null) {
301
+                this.inspections = []
302
+                return false
364 303
               }
365
-              var inspectionsMap = {};
366
-              this.inspectionsMap = {};
304
+              var inspectionsMap = {}
305
+              this.inspectionsMap = {}
367 306
               for (var index in inspections) {
368
-                inspectionsMap[inspections[index].item_id] = inspections[index];
369
-                this.inspectionsMap[inspections[index].item_id] = inspections[index];
307
+                inspectionsMap[inspections[index].item_id] = inspections[index]
308
+                this.inspectionsMap[inspections[index].item_id] = inspections[index]
370 309
               }
371
-              var items = this.project.inspection_reference;
372
-              for(var index in items) {
310
+              var items = this.project.inspection_reference
311
+              for (var index in items) {
373 312
                 if (items[index].id in inspectionsMap) {
374
-                  var item = {};
375
-                  for(var key in items[index]) {
376
-                    item[key] = items[index][key];
313
+                  var item = {}
314
+                  for (var key in items[index]) {
315
+                    item[key] = items[index][key]
377 316
                   }
378
-                  item.value = inspectionsMap[items[index].id].inspect_value;
379
-                  item.value_direction = "";
380
-                  if (item.range_type==1) {
381
-                    var value = parseFloat(item.value);
382
-                    var range_min = parseFloat(item.range_min);
383
-                    var range_max = parseFloat(item.range_max);
317
+                  item.value = inspectionsMap[items[index].id].inspect_value
318
+                  item.value_direction = ''
319
+                  if (item.range_type == 1) {
320
+                    var value = parseFloat(item.value)
321
+                    var range_min = parseFloat(item.range_min)
322
+                    var range_max = parseFloat(item.range_max)
384 323
                     if (value < range_min) {
385
-                      item.value_direction = "↓";
386
-                    }else if (value > range_max) {
387
-                      item.value_direction = "↑";
324
+                      item.value_direction = '↓'
325
+                    } else if (value > range_max) {
326
+                      item.value_direction = '↑'
388 327
                     }
389 328
                   }
390
-                  this.items.push(item);
329
+                  this.items.push(item)
391 330
                 }
392 331
               }
393 332
 
394
-              this.resetForm(formName);
395
-              this.dialogFormVisible = false;
396
-
397
-            }else {
398
-              this.$message.error(response.data.msg);
399
-              return false;
333
+              this.resetForm(formName)
334
+              this.dialogFormVisible = false
335
+            } else {
336
+              this.$message.error(response.data.msg)
337
+              return false
400 338
             }
401
-          }).catch(v=>{
402
-            this.$message.error(v);
403
-            return false;
404
-          });
405
-          this.formLoading = false;
406
-          return false;
339
+          }).catch(v => {
340
+            this.$message.error(v)
341
+            return false
342
+          })
343
+          this.formLoading = false
344
+          return false
407 345
         } else {
408
-          return false;
346
+          return false
409 347
         }
410
-      });
348
+      })
411 349
     },
412
-    submitNew(formName){
350
+    submitNew(formName) {
413 351
       this.$refs[formName].validate((valid) => {
414 352
         if (valid) {
415
-          this.formLoading = true;
416
-          if (this.form.formItem.length==0) {
417
-            this.$message.error("未填写项目");
418
-            return false;
353
+          this.formLoading = true
354
+          if (this.form.formItem.length == 0) {
355
+            this.$message.error('未填写项目')
356
+            return false
419 357
           }
420
-          for( var index in this.form.formItem) {
421
-            this.form.formItem[index].value = '' + this.form.formItem[index].value;
358
+          for (var index in this.form.formItem) {
359
+            this.form.formItem[index].value = '' + this.form.formItem[index].value
422 360
           }
423
-          CreatePatientInspection(this.patientID, this.form, this.form.remind_cycle).then(response=>{
424
-            if (response.data.state==1) {
361
+          CreatePatientInspection(this.patientID, this.form, this.form.remind_cycle).then(response => {
362
+            if (response.data.state == 1) {
425 363
               this.$notify({
426
-                title: "成功",
427
-                message: "新增成功",
428
-                type: "success",
364
+                title: '成功',
365
+                message: '新增成功',
366
+                type: 'success',
429 367
                 duration: 2000
430
-              });
368
+              })
431 369
               // this.form.remind_reycle = response.data.data.remind_reycc
432 370
               this.patient_info.remind_cycle = response.data.data.remind_cycle
433
-              console.log( this.patient_info.remind_cycle)
371
+              console.log(this.patient_info.remind_cycle)
434 372
 
435
-              this.itemDate = this.form.inspect_date;
436
-              this.items=[];
437
-              for( var index in this.projects) {
373
+              this.itemDate = this.form.inspect_date
374
+              this.items = []
375
+              for (var index in this.projects) {
438 376
                 if (this.projects[index].project_id == this.form.project_id) {
439
-                  this.projects[index].count ++;
440
-                  break;
377
+                  this.projects[index].count++
378
+                  break
441 379
                 }
442 380
               }
443
-              this.total +=1;
444
-              var inspections = response.data.data.inspections;
445
-              this.inspections = response.data.data.inspections;
446
-              if (inspections==null) {
447
-                this.inspections = [];
448
-                return false;
381
+              this.total += 1
382
+              var inspections = response.data.data.inspections
383
+              this.inspections = response.data.data.inspections
384
+              if (inspections == null) {
385
+                this.inspections = []
386
+                return false
449 387
               }
450
-              var inspectionsMap = {};
451
-              this.inspectionsMap = {};
388
+              var inspectionsMap = {}
389
+              this.inspectionsMap = {}
452 390
               for (var index in inspections) {
453
-                inspectionsMap[inspections[index].item_id] = inspections[index];
454
-                this.inspectionsMap[inspections[index].item_id] = inspections[index];
391
+                inspectionsMap[inspections[index].item_id] = inspections[index]
392
+                this.inspectionsMap[inspections[index].item_id] = inspections[index]
455 393
               }
456
-              var items = this.project.inspection_reference;
457
-              for(var index in items) {
394
+              var items = this.project.inspection_reference
395
+              for (var index in items) {
458 396
                 if (items[index].id in inspectionsMap) {
459
-                  var item = {};
460
-                  for(var key in items[index]) {
461
-                    item[key] = items[index][key];
397
+                  var item = {}
398
+                  for (var key in items[index]) {
399
+                    item[key] = items[index][key]
462 400
                   }
463
-                  item.value = inspectionsMap[items[index].id].inspect_value;
464
-                  item.value_direction = "";
465
-                  if (item.range_type==1) {
466
-                    var value = parseFloat(item.value);
467
-                    var range_min = parseFloat(item.range_min);
468
-                    var range_max = parseFloat(item.range_max);
401
+                  item.value = inspectionsMap[items[index].id].inspect_value
402
+                  item.value_direction = ''
403
+                  if (item.range_type == 1) {
404
+                    var value = parseFloat(item.value)
405
+                    var range_min = parseFloat(item.range_min)
406
+                    var range_max = parseFloat(item.range_max)
469 407
                     if (value < range_min) {
470
-                      item.value_direction = "↓";
471
-                    }else if (value > range_max) {
472
-                      item.value_direction = "↑";
408
+                      item.value_direction = '↓'
409
+                    } else if (value > range_max) {
410
+                      item.value_direction = '↑'
473 411
                     }
474 412
                   }
475
-                  this.items.push(item);
413
+                  this.items.push(item)
476 414
                 }
477 415
               }
478 416
 
479
-              this.resetForm(formName);
480
-              this.dialogFormVisible = false;
481
-
482
-
483
-              this.queryParams.patient = this.patientID;
484
-              this.queryParams.project_id = this.project.project_id;
485
-              this.queryParams.page = 1;
486
-              this.total = 0;
487
-              this.fetchPatientInspections(this.queryParams);
488
-
489
-
490
-            }else {
491
-              this.$message.error(response.data.msg);
492
-              return false;
417
+              this.resetForm(formName)
418
+              this.dialogFormVisible = false
419
+
420
+              this.queryParams.patient = this.patientID
421
+              this.queryParams.project_id = this.project.project_id
422
+              this.queryParams.page = 1
423
+              this.total = 0
424
+              this.fetchPatientInspections(this.queryParams)
425
+            } else {
426
+              this.$message.error(response.data.msg)
427
+              return false
493 428
             }
494
-          }).catch(v=>{
495
-            this.$message.error(v);
496
-            return false;
497
-          });
498
-          this.formLoading = false;
499
-          return false;
429
+          }).catch(v => {
430
+            this.$message.error(v)
431
+            return false
432
+          })
433
+          this.formLoading = false
434
+          return false
500 435
         } else {
501
-          return false;
436
+          return false
502 437
         }
503
-      });
504
-
438
+      })
505 439
     },
506
-    fetchInspectionReference(){
507
-      fetchInspectionReference(this.patientID).then(response=>{
508
-        if(response.data.state==1) {
509
-          var reference = response.data.data.reference;
510
-          var patient_info = response.data.data.patient_info;
511
-          this.projects = reference;
512
-          this.patient_info = patient_info;
513
-          this.pageLoading = false;
440
+    fetchInspectionReference() {
441
+      fetchInspectionReference(this.patientID).then(response => {
442
+        if (response.data.state == 1) {
443
+          var reference = response.data.data.reference
444
+          var patient_info = response.data.data.patient_info
445
+          this.projects = reference
446
+          this.patient_info = patient_info
447
+          this.pageLoading = false
514 448
           this.form.remind_cycle = this.patient_info.remind_cycle
515
-        }else {
516
-          this.$message.error(response.data.msg);
517
-          return false;
449
+        } else {
450
+          this.$message.error(response.data.msg)
451
+          return false
518 452
         }
519
-      }).catch(v=>{
520
-      });
453
+      }).catch(v => {
454
+      })
521 455
     },
522 456
     setCurrent(row) {
523
-      this.$refs.singleTable.setCurrentRow(row);
457
+      this.$refs.singleTable.setCurrentRow(row)
524 458
     },
525 459
     resetForm(formName) {
526
-      this.$refs[formName].resetFields();
460
+      this.$refs[formName].resetFields()
527 461
     },
528 462
     handleCurrentChange(row) {
529
-      this.itemDate = '';
530
-      this.form.method = 'add';
531
-      if(typeof(row)=="undefined" || row==null) {
532
-        this.project = null;
533
-        this.items = [];
534
-        this.itemName='请选择项目';
535
-      }else {
536
-        this.itemLoading = true;
537
-        this.project = row;
538
-        this.items = row.inspection_reference;
539
-        this.itemName=row.project_name;
540
-
541
-        this.queryParams.patient = this.patientID;
542
-        this.queryParams.project_id = this.project.project_id;
543
-        this.queryParams.page = 1;
544
-        this.total = 0;
545
-        this.fetchPatientInspections(this.queryParams);
463
+      this.itemDate = ''
464
+      this.form.method = 'add'
465
+      if (typeof (row) === 'undefined' || row == null) {
466
+        this.project = null
467
+        this.items = []
468
+        this.itemName = '请选择项目'
469
+      } else {
470
+        this.itemLoading = true
471
+        this.project = row
472
+        this.items = row.inspection_reference
473
+        this.itemName = row.project_name
474
+
475
+        this.queryParams.patient = this.patientID
476
+        this.queryParams.project_id = this.project.project_id
477
+        this.queryParams.page = 1
478
+        this.total = 0
479
+        this.fetchPatientInspections(this.queryParams)
546 480
       }
547 481
     },
548 482
 
549 483
     handleCurrentChangePage(val) {
550
-        this.itemLoading = true;
551
-      this.queryParams.page = val;
552
-      this.fetchPatientInspections(this.queryParams);
484
+      this.itemLoading = true
485
+      this.queryParams.page = val
486
+      this.fetchPatientInspections(this.queryParams)
553 487
     },
554
-    fetchPatientInspections(params){
555
-      this.items = [];
556
-      fetchPatientInspections(params).then(response=>{
557
-        if(response.data.state==1) {
558
-          var inspections = response.data.data.inspections;
559
-          this.total = response.data.data.total;
560
-          this.itemDate = response.data.data.date;
561
-          this.inspections = response.data.data.inspections;
562
-          if (inspections==null) {
563
-            this.inspections = [];
564
-            return false;
488
+    fetchPatientInspections(params) {
489
+      this.items = []
490
+      fetchPatientInspections(params).then(response => {
491
+        if (response.data.state == 1) {
492
+          var inspections = response.data.data.inspections
493
+          this.total = response.data.data.total
494
+          this.itemDate = response.data.data.date
495
+          this.inspections = response.data.data.inspections
496
+          if (inspections == null) {
497
+            this.inspections = []
498
+            return false
565 499
           }
566
-          var inspectionsMap = {};
567
-          this.inspectionsMap = {};
500
+          var inspectionsMap = {}
501
+          this.inspectionsMap = {}
568 502
           for (var index in inspections) {
569
-            inspectionsMap[inspections[index].item_id] = inspections[index];
570
-            this.inspectionsMap[inspections[index].item_id] = inspections[index];
503
+            inspectionsMap[inspections[index].item_id] = inspections[index]
504
+            this.inspectionsMap[inspections[index].item_id] = inspections[index]
571 505
           }
572
-          var items = this.project.inspection_reference;
573
-          for(var index in items) {
574
-            if (items[index].id in inspectionsMap) {
575
-              var item = {};
576
-              for(var key in items[index]) {
577
-                item[key] = items[index][key];
506
+          var items = this.project.inspection_reference
507
+          for (var index in items) {
508
+            if (items[index].id in inspectionsMap || items[index].item_id in inspectionsMap) {
509
+              var item = {}
510
+              for (var key in items[index]) {
511
+                item[key] = items[index][key]
578 512
               }
579
-              item.value = inspectionsMap[items[index].id].inspect_value;
580
-              item.value_direction = "";
581
-              if (item.range_type==1) {
582
-                var value = parseFloat(item.value);
583
-                var range_min = parseFloat(item.range_min);
584
-                var range_max = parseFloat(item.range_max);
513
+              if (item.item_id > 0) {
514
+                item.value = inspectionsMap[items[index].item_id].inspect_value
515
+              } else {
516
+                item.value = inspectionsMap[items[index].id].inspect_value
517
+              }
518
+              item.value_direction = ''
519
+              if (item.range_type == 1) {
520
+                var value = parseFloat(item.value)
521
+                var range_min = parseFloat(item.range_min)
522
+                var range_max = parseFloat(item.range_max)
585 523
                 if (value < range_min) {
586
-                  item.value_direction = "↓";
524
+                  item.value_direction = '↓'
587 525
                 } else if (value > range_max) {
588
-                  item.value_direction = "↑";
526
+                  item.value_direction = '↑'
589 527
                 }
590 528
               }
591
-              this.items.push(item);
529
+              this.items.push(item)
592 530
             }
593 531
           }
594 532
           console.log(this.items)
595
-
596 533
         }
597
-      }).catch(v=>{});
534
+      }).catch(v => {})
598 535
       setTimeout(() => {
599
-        this.itemLoading = false;
600
-      }, 1000);
601
-    },
536
+        this.itemLoading = false
537
+      }, 1000)
538
+    }
602 539
   },
603 540
   created() {
604
-    const id = this.$route.query && this.$route.query.id;
605
-    this.patientID = parseInt(id);
541
+    const id = this.$route.query && this.$route.query.id
542
+    this.patientID = parseInt(id)
606 543
     if (isNaN(this.patientID) || this.patientID <= 0) {
607 544
       this.$notify.error({
608
-        title: "错误",
609
-        message: "无效的id"
610
-      });
611
-      this.$router.push("/patients/patients");
545
+        title: '错误',
546
+        message: '无效的id'
547
+      })
548
+      this.$router.push('/patients/patients')
612 549
     }
613 550
 
614
-    this.fetchInspectionReference();
551
+    this.fetchInspectionReference()
615 552
   }
616
-};
553
+}
617 554
 </script>
618 555
 
619 556
 <style>