WXL
昨天 c80bc467a41daa6cbae4e5515a300a8ca98cfeaa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
"use strict";
const common_vendor = require("../../common/vendor.js");
const stores_user = require("../../stores/user.js");
const utils_useDictMapper = require("../../utils/useDictMapper.js");
if (!Array) {
  const _easycom_u_input2 = common_vendor.resolveComponent("u-input");
  const _easycom_u_textarea2 = common_vendor.resolveComponent("u-textarea");
  const _easycom_u_datetime_picker2 = common_vendor.resolveComponent("u-datetime-picker");
  const _easycom_u_button2 = common_vendor.resolveComponent("u-button");
  (_easycom_u_input2 + _easycom_u_textarea2 + _easycom_u_datetime_picker2 + _easycom_u_button2)();
}
const _easycom_u_input = () => "../../uni_modules/uview-plus/components/u-input/u-input.js";
const _easycom_u_textarea = () => "../../uni_modules/uview-plus/components/u-textarea/u-textarea.js";
const _easycom_u_datetime_picker = () => "../../uni_modules/uview-plus/components/u-datetime-picker/u-datetime-picker.js";
const _easycom_u_button = () => "../../uni_modules/uview-plus/components/u-button/u-button.js";
if (!Math) {
  (_easycom_u_input + common_vendor.unref(AreaSelect) + _easycom_u_textarea + _easycom_u_datetime_picker + common_vendor.unref(attachmentUpload) + _easycom_u_button)();
}
const attachmentUpload = () => "../../components/attachment/index.js";
const AreaSelect = () => "../../components/AreaSelect/index.js";
const _sfc_main = {
  __name: "CaseDetails",
  setup(__props) {
    const requiredDictTypes = [
      "sys_IDType",
      "sys_user_sex",
      "sys_Nation",
      "sys_BloodType",
      "sys_Infectious",
      "sys_AgeUnit",
      // 年龄单位(已存在)
      "sys_education",
      "sys_occupation"
    ];
    const { dictData, loading: dictLoading } = utils_useDictMapper.useDictMapper(requiredDictTypes);
    const getDictList = (dictType) => dictData.value[dictType] || [];
    const nationList = common_vendor.computed(
      () => getDictList("sys_Nation").map((item) => item.label)
    );
    const idCardTypeList = common_vendor.computed(
      () => getDictList("sys_IDType").map((item) => item.label)
    );
    const infectiousList = common_vendor.computed(() => getDictList("sys_Infectious"));
    const educationList = common_vendor.computed(
      () => getDictList("sys_education").map((item) => item.label)
    );
    const occupationList = common_vendor.computed(
      () => getDictList("sys_occupation").map((item) => item.label)
    );
    const ageUnitList = common_vendor.computed(
      () => getDictList("sys_AgeUnit").map((item) => item.label)
    );
    const userStore = stores_user.useUserStore();
    const isEditMode = common_vendor.ref(false);
    const currentId = common_vendor.ref(null);
    const selectedInfectious = common_vendor.ref([]);
    const loading = common_vendor.ref(false);
    const currentTime = common_vendor.ref("");
    const disabledColor = common_vendor.ref("#f5f5f7");
    const isReadonly = common_vendor.ref(false);
    common_vendor.ref(false);
    common_vendor.ref(0);
    const nationIndex = common_vendor.ref(-1);
    const idCardTypeIndex = common_vendor.ref(-1);
    const educationIndex = common_vendor.ref(-1);
    const occupationIndex = common_vendor.ref(-1);
    const idCardError = common_vendor.ref("");
    const attachments = common_vendor.ref([]);
    const ageUnitIndex = common_vendor.ref(-1);
    const showReportTimePicker = common_vendor.ref(false);
    const reportTimeValue = common_vendor.ref(Date.now());
    const residenceAddress = common_vendor.ref({ sheng: "", shi: "", qu: "" });
    const registerAddress = common_vendor.ref({ sheng: "", shi: "", qu: "" });
    const form = common_vendor.ref({
      caseNo: "",
      treatmenthospitalname: "",
      toHospital: "",
      coordinatorName: "",
      coordinatorNo: "",
      treatmentdeptname: "",
      deptName: "",
      name: "",
      nation: "",
      nationality: "中国",
      idcardtype: "",
      idcardno: "",
      sex: "",
      birthday: "",
      age: "",
      ageunit: "",
      inpatientno: "",
      gcsScore: "",
      diagnosisname: "",
      bloodType: "",
      rhYin: "",
      infoName: "",
      phone: "",
      icuDoctor: "",
      icuDoctorPhone: "",
      reportername: "",
      reporterno: "",
      reporterphone: "",
      reporttime: "",
      contactperson: "",
      education: "",
      illnessoverview: "",
      infectious: "",
      infectiousOther: "",
      isTransport: "",
      nativeplace: "",
      occupation: "",
      patientstate: "",
      registeraddress: "",
      registerprovince: "",
      registerprovincename: "",
      registercityname: "",
      registertownname: "",
      registercommunityname: "",
      residenceaddress: "",
      residenceprovince: "",
      residenceprovincename: "",
      residencecountycode: "",
      residencecountyname: "",
      residencetownname: "",
      residencecommunity: "",
      residencecommunityname: "",
      remark: "",
      reportStatus: "1",
      terminationCase: 0,
      annexfilesList: []
    });
    const genderOptions = common_vendor.computed(() => {
      const sexDict = getDictList("sys_user_sex");
      if (sexDict.length)
        return sexDict.map((item) => ({ label: item.label, value: item.value }));
      return [
        { label: "男", value: "1" },
        { label: "女", value: "2" }
      ];
    });
    const bloodTypeOptions = [
      { label: "A型", value: "A型" },
      { label: "B型", value: "B型" },
      { label: "O型", value: "O型" },
      { label: "AB型", value: "AB型" }
    ];
    const rhOptions = [
      { label: "阳性", value: "1" },
      { label: "阴性", value: "0" }
    ];
    const isFormValid = common_vendor.computed(
      () => form.value.name && form.value.diagnosisname && form.value.toHospital
    );
    const currentAgeUnitText = common_vendor.computed(() => {
      if (ageUnitIndex.value >= 0 && ageUnitList.value[ageUnitIndex.value]) {
        return ageUnitList.value[ageUnitIndex.value];
      }
      if (form.value.ageunit) {
        const found = getDictList("sys_AgeUnit").find(
          (item) => item.value === form.value.ageunit
        );
        return found ? found.label : form.value.ageunit;
      }
      return "";
    });
    const currentNationText = common_vendor.computed(() => {
      if (nationIndex.value >= 0 && nationList.value[nationIndex.value])
        return nationList.value[nationIndex.value];
      return form.value.nation || "";
    });
    const currentIdCardTypeText = common_vendor.computed(() => {
      if (idCardTypeIndex.value >= 0 && idCardTypeList.value[idCardTypeIndex.value])
        return idCardTypeList.value[idCardTypeIndex.value];
      if (form.value.idcardtype) {
        const found = getDictList("sys_IDType").find(
          (item) => item.value == form.value.idcardtype
        );
        return found ? found.label : form.value.idcardtype;
      }
      return "";
    });
    const currentEducationText = common_vendor.computed(() => {
      if (educationIndex.value >= 0 && educationList.value[educationIndex.value])
        return educationList.value[educationIndex.value];
      if (form.value.education) {
        const found = getDictList("sys_education").find(
          (item) => item.value == form.value.education
        );
        return found ? found.label : form.value.education;
      }
      return "";
    });
    const currentOccupationText = common_vendor.computed(() => {
      if (occupationIndex.value >= 0 && occupationList.value[occupationIndex.value])
        return occupationList.value[occupationIndex.value];
      if (form.value.occupation) {
        const found = getDictList("sys_occupation").find(
          (item) => item.value == form.value.occupation
        );
        return found ? found.label : form.value.occupation;
      }
      return "";
    });
    const updateCurrentTime = () => {
      const now = /* @__PURE__ */ new Date();
      const year = now.getFullYear();
      const month = String(now.getMonth() + 1).padStart(2, "0");
      const day = String(now.getDate()).padStart(2, "0");
      const hours = String(now.getHours()).padStart(2, "0");
      const minutes = String(now.getMinutes()).padStart(2, "0");
      const seconds = String(now.getSeconds()).padStart(2, "0");
      const timeStr = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
      currentTime.value = timeStr;
      if (!form.value.reporttime) {
        form.value.reporttime = timeStr;
      }
    };
    const generateCaseNo = () => {
      const now = /* @__PURE__ */ new Date();
      const year = now.getFullYear();
      const month = String(now.getMonth() + 1).padStart(2, "0");
      const day = String(now.getDate()).padStart(2, "0");
      const hours = String(now.getHours()).padStart(2, "0");
      const minutes = String(now.getMinutes()).padStart(2, "0");
      form.value.caseNo = `opo${year}${month}${day}${hours}${minutes}`;
    };
    const onNationChange = (e) => {
      const index = parseInt(e.detail.value);
      nationIndex.value = index;
      form.value.nation = nationList.value[index];
    };
    const onIdCardTypeChange = (e) => {
      const index = parseInt(e.detail.value);
      idCardTypeIndex.value = index;
      const selectedLabel = idCardTypeList.value[index];
      const dictItem = getDictList("sys_IDType").find(
        (item) => item.label == selectedLabel
      );
      form.value.idcardtype = dictItem ? dictItem.value : selectedLabel;
    };
    const onEducationChange = (e) => {
      const index = parseInt(e.detail.value);
      educationIndex.value = index;
      const selectedLabel = educationList.value[index];
      const dictItem = getDictList("sys_education").find(
        (item) => item.label == selectedLabel
      );
      form.value.education = dictItem ? dictItem.value : selectedLabel;
    };
    const onOccupationChange = (e) => {
      const index = parseInt(e.detail.value);
      occupationIndex.value = index;
      const selectedLabel = occupationList.value[index];
      const dictItem = getDictList("sys_occupation").find(
        (item) => item.label == selectedLabel
      );
      form.value.occupation = dictItem ? dictItem.value : selectedLabel;
    };
    const onAgeUnitChange = (e) => {
      const index = parseInt(e.detail.value);
      ageUnitIndex.value = index;
      const selectedLabel = ageUnitList.value[index];
      const dictItem = getDictList("sys_AgeUnit").find(
        (item) => item.label === selectedLabel
      );
      form.value.ageunit = dictItem ? dictItem.value : selectedLabel;
    };
    const onBirthdayChange = (e) => {
      form.value.birthday = e.detail.value;
      calculateAge();
    };
    const calculateAge = () => {
      if (!form.value.birthday) {
        form.value.age = "";
        form.value.ageunit = "";
        ageUnitIndex.value = -1;
        return;
      }
      const birthDate = new Date(form.value.birthday);
      const today = /* @__PURE__ */ new Date();
      if (isNaN(birthDate.getTime()))
        return;
      if (birthDate > today) {
        common_vendor.index.showToast({ title: "出生日期不能是未来日期", icon: "none" });
        form.value.age = "";
        form.value.ageunit = "";
        ageUnitIndex.value = -1;
        return;
      }
      const daysDiff = Math.floor((today - birthDate) / (1e3 * 60 * 60 * 24));
      if (daysDiff < 0)
        return;
      let years = today.getFullYear() - birthDate.getFullYear();
      let months = today.getMonth() - birthDate.getMonth();
      let days = today.getDate() - birthDate.getDate();
      let ageValue, ageUnit;
      if (years >= 1) {
        if (months < 0 || months === 0 && days < 0)
          years--;
        ageValue = years.toString();
        ageUnit = "岁";
      } else if (daysDiff >= 30) {
        let totalMonths = years * 12 + months;
        if (days < 0)
          totalMonths--;
        ageValue = Math.max(1, totalMonths).toString();
        ageUnit = "个月";
      } else {
        ageValue = Math.max(1, daysDiff).toString();
        ageUnit = "天";
      }
      form.value.age = ageValue;
      form.value.ageunit = ageUnit;
      const unitList = ageUnitList.value;
      const idx = unitList.findIndex((item) => item === ageUnit);
      ageUnitIndex.value = idx >= 0 ? idx : -1;
    };
    const validateIdCard = () => {
      const idCard = form.value.idcardno;
      if (!idCard) {
        idCardError.value = "";
        return true;
      }
      if (idCard.length !== 18) {
        idCardError.value = "身份证号码必须是18位";
        return false;
      }
      const reg = /^\d{17}(\d|X|x)$/;
      if (!reg.test(idCard)) {
        idCardError.value = "身份证号码格式不正确";
        return false;
      }
      const coefficientArray = [
        7,
        9,
        10,
        5,
        8,
        4,
        2,
        1,
        6,
        3,
        7,
        9,
        10,
        5,
        8,
        4,
        2
      ];
      const checkCodeMap = ["1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2"];
      let sum = 0;
      for (let i = 0; i < 17; i++)
        sum += parseInt(idCard.charAt(i), 10) * coefficientArray[i];
      const checkCode = checkCodeMap[sum % 11];
      if (checkCode != idCard.charAt(17).toUpperCase()) {
        idCardError.value = "身份证号码校验失败";
        return false;
      }
      idCardError.value = "";
      return true;
    };
    const onIdCardChange = () => {
      if (validateIdCard())
        extractBirthdayFromIdCard();
    };
    const extractBirthdayFromIdCard = () => {
      const idCard = form.value.idcardno;
      if (!idCard || idCard.length !== 18)
        return;
      const year = idCard.substring(6, 10);
      const month = idCard.substring(10, 12);
      const day = idCard.substring(12, 14);
      const birthDate = /* @__PURE__ */ new Date(`${year}-${month}-${day}`);
      if (isNaN(birthDate.getTime()))
        return;
      form.value.birthday = `${year}-${month}-${day}`;
      calculateAge();
      const genderCode = parseInt(idCard.charAt(16), 10);
      if (!isNaN(genderCode))
        form.value.sex = genderCode % 2 === 1 ? "1" : "2";
      common_vendor.index.showToast({
        title: "已自动提取出生日期和性别",
        icon: "success",
        duration: 1500
      });
    };
    const handleGcsBlur = () => {
      const val = Number(form.value.gcsScore);
      if (!val && val !== 0)
        return;
      if (val > 7) {
        common_vendor.index.showToast({ title: "GCS评分不能大于7", icon: "none" });
        form.value.gcsScore = "";
      }
      if (val < 3) {
        common_vendor.index.showToast({ title: "GCS评分不能小于3", icon: "none" });
        form.value.gcsScore = "";
      }
    };
    const toggleInfectious = (value) => {
      const index = selectedInfectious.value.indexOf(value);
      if (index === -1)
        selectedInfectious.value.push(value);
      else
        selectedInfectious.value.splice(index, 1);
      form.value.infectious = selectedInfectious.value.join(",");
    };
    const isInfectiousSelected = (value) => selectedInfectious.value.includes(value);
    const onReportTimeConfirm = (e) => {
      const date = new Date(e.value);
      const year = date.getFullYear();
      const month = String(date.getMonth() + 1).padStart(2, "0");
      const day = String(date.getDate()).padStart(2, "0");
      const hours = String(date.getHours()).padStart(2, "0");
      const minutes = String(date.getMinutes()).padStart(2, "0");
      const seconds = String(date.getSeconds()).padStart(2, "0");
      form.value.reporttime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
      showReportTimePicker.value = false;
    };
    const handleBaseUpload = (file) => attachments.value.push(file);
    const handleFilesUpdate = (files) => {
      attachments.value = files.map((file) => ({ ...file }));
    };
    const handlePreview = (file) => {
      const fullUrl = file.url.startsWith("http") ? file.url : (file.url.startsWith("/") ? "" : "/") + file.url;
      if (file.type.includes("image")) {
        common_vendor.index.previewImage({
          urls: attachments.value.filter((f) => f.type.includes("image")).map(
            (f) => f.url.startsWith("http") ? f.url : (f.url.startsWith("/") ? "" : "/") + f.url
          ),
          current: fullUrl
        });
      } else if (file.type.includes("pdf")) {
        common_vendor.index.downloadFile({
          url: fullUrl,
          success: (res) => common_vendor.index.openDocument({
            filePath: res.tempFilePath,
            fileType: "pdf",
            showMenu: true
          })
        });
      } else {
        common_vendor.index.showToast({ title: "暂不支持此文件类型预览", icon: "none" });
      }
    };
    const onResidenceChange = (val) => {
      form.value.residenceprovincename = val.sheng;
      form.value.residenceprovince = val.provinceCode || "";
      form.value.residencecountyname = val.shi;
      form.value.residencetownname = val.qu;
    };
    const onRegisterChange = (val) => {
      form.value.registerprovincename = val.sheng;
      form.value.registerprovince = val.provinceCode || "";
      form.value.registercityname = val.shi;
      form.value.registertownname = val.qu;
    };
    const handleCancel = () => common_vendor.index.navigateBack();
    const resetForm = () => {
      common_vendor.index.showModal({
        title: "确认重置",
        content: "确定要清空所有已填写的内容吗?",
        success: (res) => {
          if (res.confirm) {
            Object.keys(form.value).forEach((key) => {
              if (!["id", "caseNo"].includes(key))
                form.value[key] = "";
            });
            form.value.nationality = "中国";
            form.value.reportStatus = "1";
            form.value.terminationCase = 0;
            nationIndex.value = -1;
            idCardTypeIndex.value = -1;
            educationIndex.value = -1;
            occupationIndex.value = -1;
            ageUnitIndex.value = -1;
            selectedInfectious.value = [];
            attachments.value = [];
            residenceAddress.value = { sheng: "", shi: "", qu: "" };
            registerAddress.value = { sheng: "", shi: "", qu: "" };
            if (!isEditMode.value)
              generateCaseNo();
            updateCurrentTime();
            common_vendor.index.showToast({ title: "表单已重置", icon: "success" });
          }
        }
      });
    };
    const handleSubmit = async () => {
      if (!isFormValid.value) {
        common_vendor.index.showToast({ title: "请填写姓名、疾病诊断和上报医院", icon: "none" });
        return;
      }
      try {
        loading.value = true;
        common_vendor.index.showLoading({ title: isEditMode.value ? "修改中..." : "提交中..." });
        const submitData = {
          ...form.value,
          treatmenthospitalname: form.value.toHospital,
          age: parseInt(form.value.age) || 0,
          annexfilesList: attachments.value.map((file) => ({
            path: file.url,
            fileName: file.name,
            type: file.type
          })),
          isTransport: form.value.isTransport,
          terminationCase: form.value.terminationCase || 0,
          reportStatus: form.value.reportStatus || "1"
        };
        let res;
        if (isEditMode.value) {
          res = await common_vendor.index.$uapi.post(
            "/project/donatebaseinforeport/edit",
            submitData
          );
        } else {
          res = await common_vendor.index.$uapi.post(
            "/project/donatebaseinforeport/add",
            submitData
          );
        }
        common_vendor.index.hideLoading();
        if (res.code == 200) {
          common_vendor.index.showToast({
            title: isEditMode.value ? "修改成功" : "上报成功",
            icon: "success"
          });
          setTimeout(() => common_vendor.index.navigateBack(), 1500);
        } else {
          throw new Error(res.msg || "操作失败");
        }
      } catch (error) {
        common_vendor.index.showToast({
          title: error.message || (isEditMode.value ? "修改失败" : "上报失败"),
          icon: "none"
        });
      } finally {
        loading.value = false;
      }
    };
    const loadCaseData = async (id) => {
      try {
        loading.value = true;
        const res = await common_vendor.index.$uapi.get(
          `/project/donatebaseinforeport/getInfo/${id}`
        );
        if (res.code) {
          form.value = res.data;
          if (res.data.infectious)
            selectedInfectious.value = res.data.infectious.split(",").filter((item) => item.trim() !== "");
          if (form.value.nation) {
            const idx = nationList.value.findIndex(
              (item) => item == form.value.nation
            );
            nationIndex.value = idx >= 0 ? idx : -1;
          }
          if (form.value.idcardtype) {
            const dictList = getDictList("sys_IDType");
            const idx = dictList.findIndex(
              (item) => item.value == form.value.idcardtype
            );
            idCardTypeIndex.value = idx >= 0 ? idx : -1;
          }
          if (form.value.education) {
            const dictList = getDictList("sys_education");
            const idx = dictList.findIndex(
              (item) => item.value == form.value.education
            );
            educationIndex.value = idx >= 0 ? idx : -1;
          }
          if (form.value.occupation) {
            const dictList = getDictList("sys_occupation");
            const idx = dictList.findIndex(
              (item) => item.value == form.value.occupation
            );
            occupationIndex.value = idx >= 0 ? idx : -1;
          }
          if (form.value.ageunit) {
            const unitList = ageUnitList.value;
            const idx = unitList.findIndex((item) => item === form.value.ageunit);
            ageUnitIndex.value = idx >= 0 ? idx : -1;
          }
          if (res.data.residenceprovincename) {
            residenceAddress.value = {
              sheng: res.data.residenceprovincename,
              shi: res.data.residencecountyname,
              qu: res.data.residencetownname
            };
          }
          if (res.data.registerprovincename) {
            registerAddress.value = {
              sheng: res.data.registerprovincename,
              shi: res.data.registercityname,
              qu: res.data.registertownname
            };
          }
          if (res.data.annexfilesList) {
            attachments.value = res.data.annexfilesList.map((item) => ({
              url: item.path,
              name: item.fileName,
              type: item.type || ""
            }));
          }
        } else {
          throw new Error(res.msg || "数据加载失败");
        }
      } catch (error) {
        common_vendor.index.showToast({ title: "数据加载失败,请重试", icon: "none" });
      } finally {
        loading.value = false;
      }
    };
    common_vendor.onMounted(() => {
      updateCurrentTime();
      setInterval(updateCurrentTime, 1e3);
    });
    common_vendor.onLoad(async (options) => {
      if (options.id) {
        currentId.value = options.id;
        isEditMode.value = true;
        await new Promise((resolve) => {
          if (!dictLoading.value)
            resolve();
          else {
            const stopWatch = common_vendor.watch(dictLoading, (val) => {
              if (!val) {
                stopWatch();
                resolve();
              }
            });
          }
        });
        await loadCaseData(options.id);
      } else {
        isEditMode.value = false;
        generateCaseNo();
        updateCurrentTime();
      }
      if (!userStore.userInfo)
        await userStore.refreshUserInfo();
      const user = userStore.userInfo;
      if (user) {
        if (!form.value.treatmenthospitalname)
          form.value.treatmenthospitalname = user.orgName;
        if (!form.value.toHospital)
          form.value.toHospital = user.orgName;
        if (!form.value.coordinatorName)
          form.value.coordinatorName = user.coordinatorName;
        if (!form.value.coordinatorNo)
          form.value.coordinatorNo = user.coordinatorNo;
        if (!form.value.infoName)
          form.value.infoName = user.nickName;
        if (!form.value.phone)
          form.value.phone = user.phonenumber;
        if (!form.value.reportername)
          form.value.reportername = user.name;
        if (!form.value.reporterno)
          form.value.reporterno = user.userId;
      }
      updateCurrentTime();
    });
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.t(isEditMode.value ? "修改案例" : "上报案例"),
        b: common_vendor.o(($event) => form.value.caseNo = $event),
        c: common_vendor.p({
          placeholder: "系统自动生成",
          disabled: true,
          disabledColor: disabledColor.value,
          modelValue: form.value.caseNo
        }),
        d: common_vendor.o(($event) => form.value.toHospital = $event),
        e: common_vendor.p({
          placeholder: "请输入上报医院",
          maxlength: "100",
          modelValue: form.value.toHospital
        }),
        f: common_vendor.o(($event) => form.value.deptName = $event),
        g: common_vendor.p({
          placeholder: "请输入上报科室",
          maxlength: "50",
          modelValue: form.value.deptName
        }),
        h: common_vendor.o(($event) => form.value.name = $event),
        i: common_vendor.p({
          type: "text",
          placeholder: "请输入姓名",
          maxlength: "20",
          modelValue: form.value.name
        }),
        j: common_vendor.t(currentNationText.value || "请选择民族"),
        k: nationList.value,
        l: nationIndex.value,
        m: common_vendor.o(onNationChange),
        n: common_vendor.o(($event) => form.value.nationality = $event),
        o: common_vendor.p({
          type: "text",
          placeholder: "请输入国籍",
          modelValue: form.value.nationality
        }),
        p: common_vendor.t(currentIdCardTypeText.value || "请选择证件类型"),
        q: idCardTypeList.value,
        r: idCardTypeIndex.value,
        s: common_vendor.o(onIdCardTypeChange),
        t: common_vendor.o(onIdCardChange),
        v: common_vendor.o(($event) => form.value.idcardno = $event),
        w: common_vendor.p({
          type: "idcard",
          placeholder: "请输入证件号码",
          maxlength: "18",
          modelValue: form.value.idcardno
        }),
        x: idCardError.value
      }, idCardError.value ? {
        y: common_vendor.t(idCardError.value)
      } : {}, {
        z: common_vendor.f(genderOptions.value, (gender, k0, i0) => {
          return {
            a: common_vendor.t(gender.label),
            b: gender.value,
            c: form.value.sex == gender.value ? 1 : "",
            d: common_vendor.o(($event) => form.value.sex = gender.value, gender.value)
          };
        }),
        A: common_vendor.t(form.value.birthday || "选择出生日期"),
        B: form.value.birthday,
        C: common_vendor.o(onBirthdayChange),
        D: common_vendor.o(($event) => form.value.age = $event),
        E: common_vendor.p({
          placeholder: "输入或自动计算",
          type: "number",
          modelValue: form.value.age
        }),
        F: common_vendor.t(currentAgeUnitText.value || "单位"),
        G: ageUnitList.value,
        H: ageUnitIndex.value,
        I: common_vendor.o(onAgeUnitChange),
        J: common_vendor.o(($event) => form.value.phone = $event),
        K: common_vendor.p({
          placeholder: "请输入联系电话",
          type: "number",
          modelValue: form.value.phone
        }),
        L: common_vendor.t(currentEducationText.value || "请选择学历"),
        M: educationList.value,
        N: educationIndex.value,
        O: common_vendor.o(onEducationChange),
        P: common_vendor.t(currentOccupationText.value || "请选择职业"),
        Q: occupationList.value,
        R: occupationIndex.value,
        S: common_vendor.o(onOccupationChange),
        T: common_vendor.o(($event) => form.value.nativeplace = $event),
        U: common_vendor.p({
          placeholder: "请输入籍贯",
          modelValue: form.value.nativeplace
        }),
        V: common_vendor.o(onResidenceChange),
        W: common_vendor.o(($event) => residenceAddress.value = $event),
        X: common_vendor.p({
          modelValue: residenceAddress.value
        }),
        Y: common_vendor.o(($event) => form.value.residenceaddress = $event),
        Z: common_vendor.p({
          placeholder: "请输入详细地址",
          border: "none",
          modelValue: form.value.residenceaddress
        }),
        aa: common_vendor.o(onRegisterChange),
        ab: common_vendor.o(($event) => registerAddress.value = $event),
        ac: common_vendor.p({
          modelValue: registerAddress.value
        }),
        ad: common_vendor.o(($event) => form.value.registeraddress = $event),
        ae: common_vendor.p({
          placeholder: "请输入详细地址",
          border: "none",
          modelValue: form.value.registeraddress
        }),
        af: common_vendor.o(($event) => form.value.inpatientno = $event),
        ag: common_vendor.p({
          placeholder: "请输入住院号",
          modelValue: form.value.inpatientno
        }),
        ah: common_vendor.o(handleGcsBlur),
        ai: common_vendor.o(($event) => form.value.gcsScore = $event),
        aj: common_vendor.p({
          type: "number",
          maxlength: "1",
          placeholder: "≤7",
          modelValue: form.value.gcsScore
        }),
        ak: common_vendor.o(($event) => form.value.diagnosisname = $event),
        al: common_vendor.p({
          placeholder: "请输入疾病诊断名称",
          count: true,
          maxlength: "200",
          modelValue: form.value.diagnosisname
        }),
        am: common_vendor.f(bloodTypeOptions, (bloodType, k0, i0) => {
          return {
            a: form.value.bloodType == bloodType.value ? 1 : "",
            b: common_vendor.t(bloodType.label),
            c: bloodType.value,
            d: common_vendor.o(($event) => form.value.bloodType = bloodType.value, bloodType.value)
          };
        }),
        an: common_vendor.f(rhOptions, (rh, k0, i0) => {
          return {
            a: form.value.rhYin == rh.value ? 1 : "",
            b: common_vendor.t(rh.label),
            c: rh.value,
            d: common_vendor.o(($event) => form.value.rhYin = rh.value, rh.value)
          };
        }),
        ao: common_vendor.f(infectiousList.value, (disease, k0, i0) => {
          return common_vendor.e({
            a: isInfectiousSelected(disease.value)
          }, isInfectiousSelected(disease.value) ? {} : {}, {
            b: isInfectiousSelected(disease.value) ? 1 : "",
            c: common_vendor.t(disease.label),
            d: disease.value,
            e: isInfectiousSelected(disease.value) ? 1 : "",
            f: common_vendor.o(($event) => toggleInfectious(disease.value), disease.value)
          });
        }),
        ap: common_vendor.o(($event) => form.value.infectiousOther = $event),
        aq: common_vendor.p({
          placeholder: "请输入其他传染病",
          modelValue: form.value.infectiousOther
        }),
        ar: common_vendor.o(($event) => form.value.infoName = $event),
        as: common_vendor.p({
          placeholder: "请输入信息员",
          modelValue: form.value.infoName
        }),
        at: common_vendor.t(form.value.reporttime || "选择报告时间"),
        av: common_vendor.o(($event) => showReportTimePicker.value = true),
        aw: common_vendor.o(onReportTimeConfirm),
        ax: common_vendor.o(($event) => showReportTimePicker.value = false),
        ay: common_vendor.o(($event) => reportTimeValue.value = $event),
        az: common_vendor.p({
          show: showReportTimePicker.value,
          mode: "datetime",
          title: "选择报告时间",
          modelValue: reportTimeValue.value
        }),
        aA: common_vendor.sr("attachment", "2006fde2-19"),
        aB: common_vendor.o(handleFilesUpdate),
        aC: common_vendor.o(handleBaseUpload),
        aD: common_vendor.o(handlePreview),
        aE: common_vendor.p({
          files: attachments.value,
          readonly: isReadonly.value,
          maxCount: 5
        }),
        aF: common_vendor.o(handleCancel),
        aG: common_vendor.o(resetForm),
        aH: common_vendor.t(loading.value ? "提交中..." : isEditMode.value ? "保存修改" : "提交上报"),
        aI: common_vendor.o(handleSubmit),
        aJ: common_vendor.p({
          disabled: !isFormValid.value || loading.value
        }),
        aK: common_vendor.gei(_ctx, "")
      });
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-2006fde2"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pagesSub/case/CaseDetails.js.map