WXL
11 小时以前 05c363fdd7ab04e3bd9a753e2c5d5bfff04d681c
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
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
"use strict";
const common_vendor = require("../../common/vendor.js");
const stores_user = require("../../stores/user.js");
const utils_dict = require("../../utils/dict.js");
if (!Array) {
  const _easycom_u_input2 = common_vendor.resolveComponent("u-input");
  const _easycom_u_textarea2 = common_vendor.resolveComponent("u-textarea");
  const _easycom_u_button2 = common_vendor.resolveComponent("u-button");
  const _easycom_u_picker2 = common_vendor.resolveComponent("u-picker");
  const _easycom_u_datetime_picker2 = common_vendor.resolveComponent("u-datetime-picker");
  const _easycom_u_loading_icon2 = common_vendor.resolveComponent("u-loading-icon");
  (_easycom_u_input2 + _easycom_u_textarea2 + _easycom_u_button2 + _easycom_u_picker2 + _easycom_u_datetime_picker2 + _easycom_u_loading_icon2)();
}
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_button = () => "../../uni_modules/uview-plus/components/u-button/u-button.js";
const _easycom_u_picker = () => "../../uni_modules/uview-plus/components/u-picker/u-picker.js";
const _easycom_u_datetime_picker = () => "../../uni_modules/uview-plus/components/u-datetime-picker/u-datetime-picker.js";
const _easycom_u_loading_icon = () => "../../uni_modules/uview-plus/components/u-loading-icon/u-loading-icon.js";
if (!Math) {
  (_easycom_u_input + _easycom_u_textarea + _easycom_u_button + common_vendor.unref(attachmentUpload) + _easycom_u_picker + _easycom_u_datetime_picker + _easycom_u_loading_icon)();
}
const attachmentUpload = () => "../../components/attachment/index.js";
const _sfc_main = {
  __name: "CaseDetails",
  setup(__props) {
    const dict = common_vendor.ref({});
    const userStore = stores_user.useUserStore();
    const isEditMode = common_vendor.ref(false);
    const currentId = common_vendor.ref(null);
    const selectedInfectious = common_vendor.ref([]);
    const form = common_vendor.ref({
      caseNo: "",
      treatmenthospitalname: "",
      toHospital: "",
      coordinatorName: "",
      coordinatorNo: "",
      treatmentdeptname: "",
      name: "",
      nation: "",
      nationality: "中国",
      idcardtype: "",
      idcardno: "",
      sex: "",
      birthday: "",
      age: "",
      ageunit: "",
      // 新增:年龄单位
      inpatientno: "",
      diagnosisname: "",
      bloodType: "",
      rhYin: "",
      infoName: "",
      phone: "",
      reportername: "",
      reporterno: "",
      reporterphone: "",
      // 报告者联系电话
      reporttime: "",
      contactperson: "",
      // 新增:联系人(协调员)
      education: "",
      // 新增:学历
      illnessoverview: "",
      // 新增:病情概况
      infectious: "",
      // 传染病情况
      infectiousOther: "",
      // 传染病其他
      isTransport: "",
      // 新增:是否需要转运,默认1不需要
      nativeplace: "",
      // 新增:籍贯
      occupation: "",
      // 新增:职业
      patientstate: "",
      // 新增:病人状况
      registeraddress: "",
      // 新增:户籍地址
      registerprovince: "",
      // 新增:户籍地址省编号
      registerprovincename: "",
      // 新增:户籍地址省名称
      registercityname: "",
      // 新增:市名称
      registertownname: "",
      // 新增:所属街道(镇)名称
      registercommunityname: "",
      // 新增:社区(村)名称
      residenceaddress: "",
      // 新增:现住地址
      residenceprovince: "",
      // 新增:现住地址省代码
      residenceprovincename: "",
      // 新增:现住地址省名称
      residencecountycode: "",
      // 新增:所属区域编号
      residencecountyname: "",
      // 新增:所属区域名称
      residencetownname: "",
      // 新增:所属街道(镇)名称
      residencecommunity: "",
      // 新增:社区(村)编号
      residencecommunityname: "",
      // 新增:社区(村)名称
      remark: "",
      // 新增:备注
      reportStatus: "1",
      // 新增:上报状态,默认1已上报
      terminationCase: 0,
      // 新增:是否终止案例,默认0开启
      annexfilesList: []
      // 附件文件地址集合
    });
    const attachments = common_vendor.ref([]);
    const infectiousDiseaselist = common_vendor.ref([]);
    const nationLabel = common_vendor.ref([]);
    const isReadonly = common_vendor.ref(false);
    const id = common_vendor.ref(null);
    const selectShow = common_vendor.ref(false);
    const showHospitalPicker = common_vendor.ref(false);
    const showNationPicker = common_vendor.ref(false);
    common_vendor.ref(false);
    const showDatePicker = common_vendor.ref(false);
    const showReporterPicker = common_vendor.ref(false);
    const birthdayValue = common_vendor.ref(0);
    const hospitalOptions = common_vendor.ref([
      { label: "青岛镜湖医院", value: "qdhospital1" },
      { label: "青岛科大医院", value: "qdhospital2" },
      { label: "青岛大学附属医院", value: "qdhospital3" },
      { label: "青岛市立医院", value: "qdhospital4" }
    ]);
    const pickerColumns = common_vendor.ref([
      [
        { label: "神经外科", value: "neurosurgery" },
        { label: "心血管内科", value: "cardiology" },
        { label: "重症医学科", value: "icu" },
        { label: "急诊科", value: "emergency" },
        { label: "神经内科", value: "neurology" },
        { label: "呼吸内科", value: "respiratory" },
        { label: "消化内科", value: "gastroenterology" },
        { label: "肾内科", value: "nephrology" }
      ]
    ]);
    const nationOptions = common_vendor.ref([
      { label: "汉族", value: "han" },
      { label: "回族", value: "hui" },
      { label: "满族", value: "man" },
      { label: "蒙古族", value: "menggu" }
    ]);
    const idCardTypeOptions = common_vendor.ref([
      { label: "居民身份证", value: "idcard" },
      { label: "护照", value: "passport" },
      { label: "军官证", value: "officer" }
    ]);
    const genderOptions = common_vendor.ref([
      { label: "男", value: "1" },
      { label: "女", value: "2" }
    ]);
    const bloodTypeOptions = common_vendor.ref([
      { label: "A型", value: "A型" },
      { label: "B型", value: "B型" },
      { label: "O型", value: "O型" },
      { label: "AB型", value: "AB型" }
    ]);
    common_vendor.ref([
      { label: "需要", value: "2" },
      { label: "不需要", value: "1" }
    ]);
    const rhOptions = common_vendor.ref([
      { label: "阳性", value: "1" },
      { label: "阴性", value: "0" }
    ]);
    const reporterOptions = common_vendor.ref([
      { label: "张医生", value: "doctor1" },
      { label: "李医生", value: "doctor2" }
    ]);
    const loading = common_vendor.ref(false);
    const currentTime = common_vendor.ref("");
    const disabledColor = common_vendor.ref("#f5f5f7");
    const isFormValid = common_vendor.computed(() => {
      return form.value.name && // form.value.idcardno &&
      form.value.diagnosisname && form.value.toHospital;
    });
    const hospitalIndex = common_vendor.ref(-1);
    const deptIndex = common_vendor.ref(-1);
    const nationIndex = common_vendor.ref(-1);
    const idCardTypeIndex = common_vendor.ref(-1);
    const hospitalLabels = common_vendor.computed(
      () => hospitalOptions.value.map((item) => item.label)
    );
    const ageDisplay = common_vendor.computed(() => {
      if (!form.value.age || !form.value.ageunit) {
        return "自动计算";
      }
      return `${form.value.age}${form.value.ageunit}`;
    });
    const deptLabels = common_vendor.computed(() => {
      return pickerColumns.value[0].map((item) => item.label);
    });
    const nationLabels = common_vendor.computed(
      () => nationLabel.value.map((item) => item.label)
    );
    const idCardTypeLabels = common_vendor.computed(
      () => idCardTypeOptions.value.map((item) => item.label)
    );
    common_vendor.computed(() => {
      return hospitalIndex.value >= 0 ? hospitalLabels.value[hospitalIndex.value] : "请选择医疗机构";
    });
    common_vendor.computed(() => {
      return deptIndex.value >= 0 ? deptLabels.value[deptIndex.value] : "请选择科室";
    });
    const currentNation = common_vendor.computed(() => {
      return nationIndex.value >= 0 ? nationLabels.value[nationIndex.value] : form.value.nation ? form.value.nation : "请选择民族";
    });
    const currentIdCardType = common_vendor.computed(() => {
      return idCardTypeIndex.value >= 0 ? idCardTypeLabels.value[idCardTypeIndex.value] : "请选择证件类型";
    });
    const onNationChange = (e) => {
      const index = parseInt(e.detail.value);
      nationIndex.value = index;
      form.value.nation = nationOptions.value[index].label;
      common_vendor.index.__f__("log", "at pages/case/CaseDetails.vue:673", form.value.nation, "form.value.nation");
    };
    const onIdCardTypeChange = (e) => {
      const index = parseInt(e.detail.value);
      idCardTypeIndex.value = index;
      form.value.idcardtype = idCardTypeOptions.value[index].value;
      common_vendor.index.__f__("log", "at pages/case/CaseDetails.vue:680", form.value.idcardtype, "form.value.idcardtype");
    };
    const onBirthdayChange = (e) => {
      form.value.birthday = e.detail.value;
      calculateAge();
    };
    const onDateConfirm = (e) => {
      const date = new Date(e.value);
      form.value.birthday = `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, "0")}-${date.getDate().toString().padStart(2, "0")}`;
      calculateAge();
      showDatePicker.value = false;
    };
    const idCardError = common_vendor.ref("");
    const validateIdCard = () => {
      const idCard = form.value.idcardno;
      common_vendor.index.__f__("log", "at pages/case/CaseDetails.vue:703", idCard, "当前输入");
      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 birthStr = idCard.substring(6, 14);
      const year = birthStr.substring(0, 4);
      const month = birthStr.substring(4, 6);
      const day = birthStr.substring(6, 8);
      const birthDate = /* @__PURE__ */ new Date(`${year}-${month}-${day}`);
      if (isNaN(birthDate.getTime())) {
        idCardError.value = "身份证号码中的出生日期无效";
        return false;
      }
      common_vendor.index.__f__("log", "at pages/case/CaseDetails.vue:732", 3);
      const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
      const birthYear = parseInt(year, 10);
      if (birthYear < 1900 || birthYear > currentYear) {
        idCardError.value = "出生年份不在有效范围内";
        return false;
      }
      common_vendor.index.__f__("log", "at pages/case/CaseDetails.vue:741", 4);
      if (!validateIdCardCheckCode(idCard)) {
        idCardError.value = "身份证号码校验失败";
        return false;
      }
      common_vendor.index.__f__("log", "at pages/case/CaseDetails.vue:748", 5);
      idCardError.value = "";
      return true;
    };
    const onIdCardChange = (value) => {
      if (validateIdCard()) {
        extractBirthdayFromIdCard();
      }
    };
    const handleGcsBlur = () => {
      const val = Number(form.value.gcsScore);
      if (!val && val !== 0)
        return;
      common_vendor.index.__f__("log", "at pages/case/CaseDetails.vue:765", val);
      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 validateIdCardCheckCode = (idCard) => {
      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];
      return checkCode === idCard.charAt(17).toUpperCase();
    };
    const extractBirthdayFromIdCard = () => {
      const idCard = form.value.idcardno;
      if (!idCard || idCard.length !== 18) {
        return;
      }
      try {
        const birthStr = idCard.substring(6, 14);
        const year = birthStr.substring(0, 4);
        const month = birthStr.substring(4, 6);
        const day = birthStr.substring(6, 8);
        const birthDate = /* @__PURE__ */ new Date(`${year}-${month}-${day}`);
        if (isNaN(birthDate.getTime())) {
          common_vendor.index.__f__("log", "at pages/case/CaseDetails.vue:819", "身份证号码中的出生日期无效");
          return;
        }
        const today = /* @__PURE__ */ new Date();
        if (birthDate > today) {
          common_vendor.index.__f__("log", "at pages/case/CaseDetails.vue:826", "出生日期不能是未来日期");
          return;
        }
        const monthNum = parseInt(month, 10);
        const dayNum = parseInt(day, 10);
        if (monthNum < 1 || monthNum > 12) {
          common_vendor.index.__f__("log", "at pages/case/CaseDetails.vue:835", "月份无效");
          return;
        }
        const daysInMonth = new Date(year, monthNum, 0).getDate();
        if (dayNum < 1 || dayNum > daysInMonth) {
          common_vendor.index.__f__("log", "at pages/case/CaseDetails.vue:842", "日期无效");
          return;
        }
        form.value.birthday = `${year}-${month.padStart(2, "0")}-${day.padStart(
          2,
          "0"
        )}`;
        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
        });
      } catch (error) {
        common_vendor.index.__f__("error", "at pages/case/CaseDetails.vue:867", "解析身份证出生日期失败:", error);
      }
    };
    const textareaStyle = (isError) => {
      return isError ? "border: 2rpx solid #ff4757; border-radius: 12rpx; min-height: 120rpx; padding: 20rpx 24rpx;" : "border: 2rpx solid #e5e5e7; border-radius: 12rpx; min-height: 120rpx; padding: 20rpx 24rpx;";
    };
    common_vendor.onMounted(() => {
      setInterval(updateCurrentTime, 1e3);
    });
    common_vendor.onLoad(async (options) => {
      id.value = options.id;
      if (options.id) {
        currentId.value = options.id;
        isEditMode.value = true;
        await loadCaseData(options.id);
      } else {
        isEditMode.value = false;
        generateDonorNo();
      }
      common_vendor.index.__f__("log", "at pages/case/CaseDetails.vue:894", userStore.userInfo, "userStoreuserInfo");
      if (!userStore.userInfo) {
        await userStore.refreshUserInfo();
      }
      form.value.treatmenthospitalname = userStore.userInfo.orgName;
      form.value.toHospital = userStore.userInfo.orgName;
      form.value.coordinatorName = userStore.userInfo.coordinatorName;
      form.value.coordinatorNo = userStore.userInfo.coordinatorNo;
      form.value.infoName = userStore.userInfo.nickName;
      form.value.phone = userStore.userInfo.phonenumber;
      form.value.reportername = userStore.userInfo.name;
      form.value.reporterno = userStore.userInfo.userId;
      dict.value = await utils_dict.useDict(
        "sys_IDType",
        "sys_user_sex",
        "sys_Nation",
        "sys_BloodType",
        "sys_Infectious",
        "sys_AgeUnit",
        // 新增年龄单位
        "sys_education",
        // 新增学历
        "sys_occupation"
        // 新增职业
      );
      initOptions();
      updateCurrentTime();
    });
    const initOptions = () => {
      infectiousDiseaselist.value = dict.value.sys_Infectious || [];
      idCardTypeOptions.value = dict.value.sys_IDType || [];
      nationLabel.value = dict.value.sys_Nation || [];
      if (form.value.infectious) {
        selectedInfectious.value = form.value.infectious.split(",").filter((item) => item.trim() !== "");
      }
    };
    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) => {
      return selectedInfectious.value.includes(value);
    };
    const updateCurrentTime = () => {
      const now = /* @__PURE__ */ new Date();
      const localString = now.toLocaleString("zh-CN", {
        year: "numeric",
        month: "2-digit",
        day: "2-digit",
        hour: "2-digit",
        minute: "2-digit",
        second: "2-digit",
        hour12: false
      });
      currentTime.value = localString.replace(/\//g, "-");
      form.value.reporttime = currentTime.value;
    };
    const generateDonorNo = () => {
      const date = /* @__PURE__ */ new Date();
      date.getTime().toString().slice(-6);
    };
    const calculateAge = () => {
      if (!form.value.birthday) {
        form.value.age = "";
        form.value.ageunit = "";
        return;
      }
      const birthDate = new Date(form.value.birthday);
      const today = /* @__PURE__ */ new Date();
      if (isNaN(birthDate.getTime())) {
        form.value.age = "";
        form.value.ageunit = "";
        return;
      }
      if (birthDate > today) {
        common_vendor.index.showToast({
          title: "出生日期不能是未来日期",
          icon: "none"
        });
        form.value.age = "";
        form.value.ageunit = "";
        return;
      }
      const timeDiff = today.getTime() - birthDate.getTime();
      const daysDiff = Math.floor(timeDiff / (1e3 * 60 * 60 * 24));
      if (daysDiff < 0) {
        form.value.age = "";
        form.value.ageunit = "";
        return;
      }
      const years = today.getFullYear() - birthDate.getFullYear();
      const months = today.getMonth() - birthDate.getMonth();
      const days = today.getDate() - birthDate.getDate();
      let ageValue, ageUnit;
      if (years >= 1) {
        let actualYears = years;
        if (months < 0 || months === 0 && days < 0) {
          actualYears = years - 1;
        }
        ageValue = actualYears.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 handleBaseUpload = (file) => {
      common_vendor.index.__f__("log", "at pages/case/CaseDetails.vue:1058", "基础附件上传成功:", file);
      attachments.value.push(file);
    };
    const handleFilesUpdate = (files) => {
      common_vendor.index.__f__("log", "at pages/case/CaseDetails.vue:1064", files, "files");
      attachments.value = files.map((file) => ({
        ...file
        // 确保只存储半路径
        // url: file.url.startsWith("http")
        //   ? file.url.replace(baseUrlHt, "")
        //   : file.url,
      }));
    };
    const handlePreview = (file) => {
      const fullUrl = file.url.startsWith("http") ? file.url : baseUrlHt + (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 : baseUrlHt + (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
            });
          },
          fail: (err) => {
            common_vendor.index.__f__("error", "at pages/case/CaseDetails.vue:1103", "打开文档失败:", err);
            common_vendor.index.showToast({ title: "打开文件失败", icon: "none" });
          }
        });
      } else {
        common_vendor.index.showToast({ title: "暂不支持此文件类型预览", icon: "none" });
      }
    };
    const onConfirm = (e) => {
      if (e.value && e.value[0]) {
        form.value.treatmentdeptname = e.value[0].label;
      }
      selectShow.value = false;
    };
    const onHospitalConfirm = (e) => {
      common_vendor.index.__f__("log", "at pages/case/CaseDetails.vue:1120", e, "民族");
      if (e.value && e.value[0]) {
        form.value.treatmenthospitalname = e.value[0].label;
      }
      showHospitalPicker.value = false;
    };
    const onNationConfirm = (e) => {
      if (e.value && e.value[0]) {
        form.value.nation = e.value[0].label;
      }
      showNationPicker.value = false;
    };
    const onReporterConfirm = (e) => {
      if (e.value && e.value[0]) {
        form.value.reporterno = e.value[0].label;
      }
      showReporterPicker.value = false;
    };
    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] = "";
              }
            });
            hospitalIndex.value = -1;
            deptIndex.value = -1;
            nationIndex.value = -1;
            idCardTypeIndex.value = -1;
            selectedInfectious.value = [];
            attachments.value = [];
            form.value.nationality = "中国";
            form.value.isTransport = "";
            form.value.terminationCase = 0;
            form.value.reportStatus = "1";
            if (!isEditMode.value) {
              generateDonorNo();
            }
            common_vendor.index.showToast({ title: "表单已重置", icon: "success" });
          }
        }
      });
    };
    const handleSubmit = async () => {
      if (!isFormValid.value) {
        common_vendor.index.showToast({
          title: "请填写姓名、证件号码和疾病诊断",
          icon: "none"
        });
        return;
      }
      try {
        common_vendor.index.showLoading({ title: isEditMode.value ? "修改中..." : "提交中..." });
        const submitData = {
          ...form.value,
          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"
          });
          removeDraft();
          setTimeout(() => {
            common_vendor.index.navigateBack();
          }, 1500);
        } else {
          throw new Error(res.msg || "操作失败");
        }
      } catch (error) {
        common_vendor.index.__f__("error", "at pages/case/CaseDetails.vue:1257", "操作失败:", error);
        common_vendor.index.showToast({
          title: error.message || (isEditMode.value ? "修改失败" : "上报失败"),
          icon: "none"
        });
      } finally {
        loading.value = false;
      }
    };
    const removeDraft = () => {
      localStorage.removeItem("caseReportDraft");
    };
    const handleCancel = () => {
      common_vendor.index.navigateBack();
    };
    const loadCaseData = async (id2) => {
      try {
        loading.value = true;
        const res = await common_vendor.index.$uapi.get(
          `/project/donatebaseinforeport/getInfo/${id2}`
        );
        if (res.code) {
          form.value = res.data;
          if (res.data.infectious) {
            selectedInfectious.value = res.data.infectious.split(",").filter((item) => item.trim() !== "");
          }
          currentNation.value = form.value.nation;
          idCardTypeIndex.value = form.value.idcardtype;
          if (res.data.annexfilesList) {
            attachments.value = res.data.annexfilesList;
            attachments.value.forEach((item) => {
              item.url = item.path;
              item.name = item.fileName;
            });
          }
          common_vendor.index.__f__("log", "at pages/case/CaseDetails.vue:1300", 3, "res");
          common_vendor.index.showToast({
            title: "数据加载成功",
            icon: "success"
          });
        } else {
          throw new Error(res.msg || "数据加载失败");
        }
      } catch (error) {
        common_vendor.index.__f__("error", "at pages/case/CaseDetails.vue:1310", "加载案例数据失败:", error);
        common_vendor.index.showToast({
          title: "数据加载失败,请重试",
          icon: "none"
        });
      } finally {
        loading.value = false;
      }
    };
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.t(isEditMode.value ? "修改案例" : "上报案例"),
        b: common_vendor.o(($event) => form.value.toHospital = $event),
        c: common_vendor.p({
          placeholder: "请输入上报医院",
          maxlength: "100",
          modelValue: form.value.toHospital
        }),
        d: common_vendor.o(($event) => form.value.deptName = $event),
        e: common_vendor.p({
          placeholder: "请输入上报科室",
          maxlength: "50",
          modelValue: form.value.deptName
        }),
        f: common_vendor.o(($event) => form.value.name = $event),
        g: common_vendor.p({
          type: "text",
          placeholder: "请输入姓名",
          maxlength: "20",
          modelValue: form.value.name
        }),
        h: common_vendor.t(currentNation.value),
        i: nationLabels.value,
        j: nationIndex.value,
        k: common_vendor.o(onNationChange),
        l: common_vendor.o(($event) => form.value.nationality = $event),
        m: common_vendor.p({
          type: "text",
          placeholder: "请输入国籍",
          modelValue: form.value.nationality
        }),
        n: common_vendor.t(currentIdCardType.value),
        o: idCardTypeLabels.value,
        p: idCardTypeIndex.value,
        q: common_vendor.o(onIdCardTypeChange),
        r: common_vendor.o(onIdCardChange),
        s: common_vendor.o(($event) => form.value.idcardno = $event),
        t: common_vendor.p({
          type: "idcard",
          placeholder: "请输入证件号码",
          maxlength: "18",
          modelValue: form.value.idcardno
        }),
        v: idCardError.value
      }, idCardError.value ? {
        w: common_vendor.t(idCardError.value)
      } : {}, {
        x: 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)
          };
        }),
        y: common_vendor.t(form.value.birthday || "选择出生日期"),
        z: form.value.birthday,
        A: common_vendor.o(onBirthdayChange),
        B: common_vendor.o(($event) => ageDisplay.value = $event),
        C: common_vendor.p({
          placeholder: "自动计算",
          disabled: true,
          disabledColor: disabledColor.value,
          border: "none",
          modelValue: ageDisplay.value
        }),
        D: common_vendor.o(($event) => form.value.inpatientno = $event),
        E: common_vendor.p({
          placeholder: "请输入住院号",
          border: "none",
          modelValue: form.value.inpatientno
        }),
        F: common_vendor.o(handleGcsBlur),
        G: common_vendor.o(($event) => form.value.gcsScore = $event),
        H: common_vendor.p({
          type: "number",
          maxlength: "1",
          placeholder: "≤7",
          border: "none",
          modelValue: form.value.gcsScore
        }),
        I: common_vendor.o(($event) => form.value.diagnosisname = $event),
        J: common_vendor.p({
          placeholder: "请输入疾病诊断名称",
          count: true,
          maxlength: "200",
          customStyle: textareaStyle(!form.value.diagnosisname),
          modelValue: form.value.diagnosisname
        }),
        K: common_vendor.f(bloodTypeOptions.value, (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)
          };
        }),
        L: common_vendor.f(rhOptions.value, (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)
          };
        }),
        M: common_vendor.f(infectiousDiseaselist.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: common_vendor.o(($event) => toggleInfectious(disease.value), disease.value)
          });
        }),
        N: common_vendor.o(($event) => form.value.infectiousOther = $event),
        O: common_vendor.p({
          placeholder: "请输入其他传染病",
          border: "none",
          modelValue: form.value.infectiousOther
        }),
        P: common_vendor.o(($event) => form.value.icuDoctor = $event),
        Q: common_vendor.p({
          placeholder: "请输入ICU评估医生",
          border: "none",
          modelValue: form.value.icuDoctor
        }),
        R: common_vendor.o(($event) => form.value.icuDoctorPhone = $event),
        S: common_vendor.p({
          placeholder: "请输入ICU医生电话",
          type: "number",
          border: "none",
          modelValue: form.value.icuDoctorPhone
        }),
        T: common_vendor.o(($event) => form.value.infoName = $event),
        U: common_vendor.p({
          placeholder: "请输入信息员",
          border: "none",
          modelValue: form.value.infoName
        }),
        V: common_vendor.o(($event) => form.value.phone = $event),
        W: common_vendor.p({
          placeholder: "请输入联系电话",
          type: "number",
          border: "none",
          modelValue: form.value.phone
        }),
        X: common_vendor.o(($event) => currentTime.value = $event),
        Y: common_vendor.p({
          disabled: true,
          disabledColor: disabledColor.value,
          border: "none",
          modelValue: currentTime.value
        }),
        Z: common_vendor.o(handleCancel),
        aa: common_vendor.o(resetForm),
        ab: common_vendor.t(loading.value ? "提交中..." : isEditMode.value ? "保存修改" : "提交上报"),
        ac: common_vendor.o(handleSubmit),
        ad: common_vendor.p({
          disabled: !isFormValid.value || loading.value
        }),
        ae: common_vendor.sr("attachment", "14b6ba50-18"),
        af: common_vendor.o(handleFilesUpdate),
        ag: common_vendor.o(handleBaseUpload),
        ah: common_vendor.o(handlePreview),
        ai: common_vendor.p({
          files: attachments.value,
          readonly: isReadonly.value,
          maxCount: 5
        }),
        aj: common_vendor.sr("uPicker", "14b6ba50-19"),
        ak: common_vendor.o(onConfirm),
        al: common_vendor.o(($event) => selectShow.value = false),
        am: common_vendor.p({
          show: selectShow.value,
          columns: pickerColumns.value,
          keyName: "label",
          title: "请选择科室"
        }),
        an: common_vendor.o(onHospitalConfirm),
        ao: common_vendor.o(($event) => showHospitalPicker.value = false),
        ap: common_vendor.p({
          show: showHospitalPicker.value,
          columns: [hospitalOptions.value],
          keyName: "label",
          title: "请选择医疗机构"
        }),
        aq: common_vendor.o(onNationConfirm),
        ar: common_vendor.o(($event) => showNationPicker.value = false),
        as: common_vendor.p({
          show: showNationPicker.value,
          columns: [nationOptions.value],
          keyName: "label",
          title: "请选择民族"
        }),
        at: common_vendor.o(onDateConfirm),
        av: common_vendor.o(($event) => showDatePicker.value = false),
        aw: common_vendor.o(($event) => birthdayValue.value = $event),
        ax: common_vendor.p({
          show: showDatePicker.value,
          mode: "date",
          title: "选择出生日期",
          modelValue: birthdayValue.value
        }),
        ay: common_vendor.o(onReporterConfirm),
        az: common_vendor.o(($event) => showReporterPicker.value = false),
        aA: common_vendor.p({
          show: showReporterPicker.value,
          columns: [reporterOptions.value],
          keyName: "label",
          title: "请选择报告人"
        }),
        aB: common_vendor.p({
          show: loading.value,
          text: "提交中..."
        }),
        aC: common_vendor.gei(_ctx, "")
      });
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-14b6ba50"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/case/CaseDetails.js.map