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
"use strict";
const common_vendor = require("../../common/vendor.js");
require("../../stores/user.js");
if (!Array) {
  const _easycom_u_input2 = common_vendor.resolveComponent("u-input");
  const _easycom_u_icon2 = common_vendor.resolveComponent("u-icon");
  const _easycom_u_textarea2 = common_vendor.resolveComponent("u-textarea");
  const _easycom_u_button2 = common_vendor.resolveComponent("u-button");
  const _easycom_u_datetime_picker2 = common_vendor.resolveComponent("u-datetime-picker");
  const _easycom_u_picker2 = common_vendor.resolveComponent("u-picker");
  const _easycom_u_loading_icon2 = common_vendor.resolveComponent("u-loading-icon");
  (_easycom_u_input2 + _easycom_u_icon2 + _easycom_u_textarea2 + _easycom_u_button2 + _easycom_u_datetime_picker2 + _easycom_u_picker2 + _easycom_u_loading_icon2)();
}
const _easycom_u_input = () => "../../uni_modules/uview-plus/components/u-input/u-input.js";
const _easycom_u_icon = () => "../../uni_modules/uview-plus/components/u-icon/u-icon.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_datetime_picker = () => "../../uni_modules/uview-plus/components/u-datetime-picker/u-datetime-picker.js";
const _easycom_u_picker = () => "../../uni_modules/uview-plus/components/u-picker/u-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_icon + _easycom_u_textarea + _easycom_u_button + common_vendor.unref(attachmentUpload) + _easycom_u_datetime_picker + _easycom_u_picker + _easycom_u_loading_icon)();
}
const attachmentUpload = () => "../../components/attachment/index.js";
const _sfc_main = {
  __name: "transferinfo",
  setup(__props) {
    common_vendor.ref({});
    const transportData = common_vendor.ref({
      annexfilesList: []
      // 附件文件地址集合
    });
    const loading = common_vendor.ref(false);
    const saving = common_vendor.ref(false);
    const isEdit = common_vendor.ref(false);
    const statusPickerVisible = common_vendor.ref(false);
    const statusCurrentIndex = common_vendor.ref(0);
    const transportId = common_vendor.ref(null);
    const showTimePicker = common_vendor.ref(false);
    const departureTimeValue = common_vendor.ref(0);
    common_vendor.ref(false);
    const isReadonly = common_vendor.ref(false);
    const attachments = common_vendor.ref([]);
    const statusOptions = common_vendor.ref([
      { label: "待转运", value: 1 },
      { label: "转运中", value: 2 },
      { label: "转运完成", value: 3 },
      { label: "转运取消", value: 4 },
      { label: "暂存", value: 5 }
    ]);
    const disabledColor = common_vendor.ref("#f5f5f7");
    const loadingText = common_vendor.computed(() => {
      return loading.value ? "加载中..." : saving.value ? "保存中..." : "";
    });
    const isFormValid = common_vendor.computed(() => {
      return transportData.value.transportStartPlace && transportData.value.transportStartTime && transportData.value.contactPerson;
    });
    const canEdit = common_vendor.computed(() => {
      if (loading.value)
        return false;
      return transportData.value.transitStatus === 1 || // 待转运
      transportData.value.transitStatus === 5;
    });
    const canStartTransport = common_vendor.computed(() => {
      if (loading.value)
        return false;
      return transportData.value.transitStatus === 1;
    });
    const canCompleteTransport = common_vendor.computed(() => {
      if (loading.value)
        return false;
      return transportData.value.transitStatus === 2;
    });
    common_vendor.computed(() => {
      if (loading.value)
        return false;
      return true;
    });
    const statusLabels = common_vendor.computed(() => {
      return statusOptions.value.map((item) => item.label);
    });
    common_vendor.computed(() => {
      if (!transportData.value.transitStatus)
        return 0;
      const index = statusOptions.value.findIndex(
        (item) => item.value == transportData.value.transitStatus
      );
      return index >= 0 ? index : 0;
    });
    common_vendor.watch(
      () => transportData.value.transitStatus,
      (newVal) => {
        if (newVal !== void 0 && newVal !== null) {
          const index = statusOptions.value.findIndex(
            (item) => item.value == newVal
          );
          if (index >= 0) {
            statusCurrentIndex.value = index;
          }
        }
      },
      { immediate: true }
    );
    common_vendor.onLoad(async (options) => {
      if (options.id) {
        transportId.value = options.id;
        await loadTransportData(options.id);
      } else if (options.caseId) {
        isEdit.value = true;
        await initNewTransport(options.caseId, options.caseNo);
      }
      if (transportData.value.transitStatus !== void 0) {
        const index = statusOptions.value.findIndex(
          (item) => item.value == transportData.value.transitStatus
        );
        statusCurrentIndex.value = index >= 0 ? index : 0;
      }
    });
    const loadTransportData = async (id) => {
      loading.value = true;
      try {
        const res = await common_vendor.index.$uapi.get(`/project/transport/getInfo/${id}`);
        if (res.data) {
          transportData.value = res.data;
          if (res.data.annexfilesList) {
            attachments.value = res.data.annexfilesList;
            attachments.value.forEach((item) => {
              item.url = item.opath, item.name = item.fileName;
            });
          }
          if (transportData.value.transitStatus !== void 0) {
            const index = statusOptions.value.findIndex(
              (item) => item.value == transportData.value.transitStatus
            );
            statusCurrentIndex.value = index >= 0 ? index : 0;
          }
        } else {
          throw new Error(res.msg || "数据加载失败");
        }
      } catch (error) {
        common_vendor.index.__f__("error", "at pages/case/transferinfo.vue:491", "加载转运单失败:", error);
        common_vendor.index.showToast({
          title: "数据加载失败,请重试",
          icon: "none"
        });
      } finally {
        loading.value = false;
      }
    };
    const initNewTransport = async (caseId, caseNo) => {
      try {
        if (caseId) {
          const res = await common_vendor.index.$uapi.get(
            `/project/donatebaseinforeport/getInfo/${caseId}`
          );
          if (res.data) {
            const caseData = res.data;
            common_vendor.index.__f__("log", "at pages/case/transferinfo.vue:511", caseData);
            transportData.value = {
              ...transportData.value,
              caseNo: caseData.caseNo || "",
              patName: caseData.name || "",
              sex: caseData.sex || "",
              age: caseData.age || "",
              reportId: caseData.id || null,
              diagnosisname: caseData.diagnosisname || "",
              treatmentHospitalName: caseData.treatmenthospitalname || "",
              treatmentDeptName: caseData.treatmentdeptname || "",
              // 可以设置一些默认值
              transportStartPlace: caseData.treatmenthospitalname || "",
              contactPerson: caseData.coordinatorName || ""
            };
            common_vendor.index.__f__("log", "at pages/case/transferinfo.vue:527", transportData.value, "transportData.value");
          }
        } else {
          transportData.value = {
            transitStatus: 1,
            createTime: (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").substring(0, 19)
          };
        }
      } catch (error) {
        common_vendor.index.__f__("error", "at pages/case/transferinfo.vue:536", "初始化转运单失败:", error);
      }
    };
    const getTransportStatusText = (status) => {
      const map = {
        1: "待转运",
        2: "转运中",
        3: "转运完成",
        4: "转运取消",
        5: "暂存"
      };
      return map[status] || "未知";
    };
    const getTransportStatusClass = (status) => {
      const map = {
        1: "pending",
        2: "transporting",
        3: "completed",
        4: "cancelled",
        5: "draft"
      };
      return map[status] || "draft";
    };
    const getGenderText = (gender) => {
      if (!gender)
        return "未知";
      return gender === "1" ? "男" : "女";
    };
    const inputStyle = (isError) => {
      return isError ? "border: 2rpx solid #f56c6c !important; border-radius: 12rpx !important;" : "border: 2rpx solid #e5e5e7 !important; border-radius: 12rpx !important;";
    };
    const onTimeConfirm = (e) => {
      const date = new Date(e.value);
      transportData.value.transportStartTime = `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, "0")}-${date.getDate().toString().padStart(2, "0")} ${date.getHours().toString().padStart(2, "0")}:${date.getMinutes().toString().padStart(2, "0")}:${date.getSeconds().toString().padStart(2, "0")}`;
      showTimePicker.value = false;
    };
    const handleStatusClick = () => {
      if (!isEdit.value)
        return;
      statusPickerVisible.value = true;
    };
    const onStatusPickerConfirm = (e) => {
      const index = e.indexs[0];
      if (statusOptions.value[index]) {
        transportData.value.transitStatus = statusOptions.value[index].value;
      }
      statusPickerVisible.value = false;
    };
    const goBack = () => {
      common_vendor.index.navigateBack();
    };
    const handleEdit = () => {
      isEdit.value = true;
    };
    const cancelEdit = () => {
      if (transportId.value) {
        isEdit.value = false;
        loadTransportData(transportId.value);
      } else {
        common_vendor.index.navigateBack();
      }
    };
    const handleSave = async () => {
      if (!validateForm())
        return;
      saving.value = true;
      try {
        const submitData = {
          ...transportData.value,
          annexfilesList: attachments.value.map((file) => ({
            path: file.url,
            fileName: file.name,
            type: file.type
          }))
        };
        let res;
        if (transportId.value) {
          res = await common_vendor.index.$uapi.post("/project/transport/edit", submitData);
        } else {
          submitData.createBy = "移动端用户";
          res = await common_vendor.index.$uapi.post("/project/transport/add", submitData);
        }
        if (res.code === 200) {
          common_vendor.index.showToast({
            title: transportId.value ? "修改成功" : "新增成功",
            icon: "success"
          });
          if (transportId.value) {
            isEdit.value = false;
            await loadTransportData(transportId.value);
          } else {
            setTimeout(() => {
              common_vendor.index.navigateBack();
            }, 1500);
          }
        } else {
          throw new Error(res.msg || "操作失败");
        }
      } catch (error) {
        common_vendor.index.__f__("error", "at pages/case/transferinfo.vue:720", "保存失败:", error);
        common_vendor.index.showToast({
          title: error.message || (transportId.value ? "修改失败" : "新增失败"),
          icon: "none"
        });
      } finally {
        saving.value = false;
      }
    };
    const validateForm = () => {
      if (!transportData.value.transportStartPlace) {
        common_vendor.index.showToast({ title: "请输入出发地点", icon: "none" });
        return false;
      }
      if (!transportData.value.transportStartTime) {
        common_vendor.index.showToast({ title: "请选择出发时间", icon: "none" });
        return false;
      }
      if (!transportData.value.contactPerson) {
        common_vendor.index.showToast({ title: "请输入负责协调员", icon: "none" });
        return false;
      }
      return true;
    };
    const handleStartTransport = () => {
      common_vendor.index.showModal({
        title: "开始转运",
        content: "确定要开始转运吗?",
        success: async (res) => {
          if (res.confirm) {
            await updateTransportStatus(2, "开始转运");
          }
        }
      });
    };
    const handleCompleteTransport = () => {
      common_vendor.index.showModal({
        title: "完成转运",
        content: "确定要完成转运吗?",
        success: async (res) => {
          if (res.confirm) {
            await updateTransportStatus(3, "完成转运");
          }
        }
      });
    };
    const updateTransportStatus = async (newStatus, actionName) => {
      try {
        const updateData = {
          id: transportId.value,
          transitStatus: newStatus,
          ...transportData.value,
          annexfilesList: attachments.value.map((file) => ({
            path: file.url,
            fileName: file.name,
            type: file.type
          }))
        };
        const res = await common_vendor.index.$uapi.post("/project/transport/edit", updateData);
        if (res.code === 200) {
          common_vendor.index.showToast({ title: `${actionName}成功`, icon: "success" });
          await loadTransportData(transportId.value);
        } else {
          throw new Error(res.msg || `${actionName}失败`);
        }
      } catch (error) {
        common_vendor.index.__f__("error", "at pages/case/transferinfo.vue:799", `${actionName}失败:`, error);
        common_vendor.index.showToast({ title: `${actionName}失败`, icon: "none" });
      }
    };
    const handleBaseUpload = (file) => {
      common_vendor.index.__f__("log", "at pages/case/transferinfo.vue:806", "基础附件上传成功:", file);
      attachments.value.push(file);
    };
    const handleFilesUpdate = (files) => {
      common_vendor.index.__f__("log", "at pages/case/transferinfo.vue:812", files, "files");
      attachments.value = files.map((file) => ({
        ...file
        // 确保只存储半路径
        // url: file.url.startsWith("http")
        //   ? file.url.replace(baseUrlHt, "")
        //   : file.url,
      }));
      common_vendor.index.__f__("log", "at pages/case/transferinfo.vue:821", attachments.value);
    };
    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/transferinfo.vue:852", "打开文档失败:", err);
            common_vendor.index.showToast({ title: "打开文件失败", icon: "none" });
          }
        });
      } else {
        common_vendor.index.showToast({ title: "暂不支持此文件类型预览", icon: "none" });
      }
    };
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: transportData.value.reportId
      }, transportData.value.reportId ? {
        b: common_vendor.t(transportData.value.caseNo),
        c: common_vendor.t(transportData.value.patName),
        d: common_vendor.t(getGenderText(transportData.value.sex)),
        e: common_vendor.t(transportData.value.age),
        f: common_vendor.t(transportData.value.diagnosisname),
        g: common_vendor.t(transportData.value.treatmentHospitalName)
      } : {}, {
        h: common_vendor.t(getTransportStatusText(transportData.value.transitStatus)),
        i: common_vendor.n(getTransportStatusClass(transportData.value.transitStatus)),
        j: common_vendor.o(($event) => transportData.value.transportStartPlace = $event),
        k: common_vendor.p({
          placeholder: "请输入出发地点",
          border: "none",
          readonly: !isEdit.value,
          customStyle: inputStyle(!transportData.value.transportStartPlace),
          modelValue: transportData.value.transportStartPlace
        }),
        l: isEdit.value
      }, isEdit.value ? {
        m: common_vendor.p({
          name: "arrow-down",
          color: "#86868b"
        })
      } : {}, {
        n: common_vendor.o(($event) => isEdit.value && (showTimePicker.value = true)),
        o: common_vendor.o(($event) => transportData.value.transportStartTime = $event),
        p: common_vendor.p({
          placeholder: "请选择出发时间",
          readonly: true,
          border: "none",
          disabled: !isEdit.value,
          customStyle: inputStyle(!transportData.value.transportStartTime),
          modelValue: transportData.value.transportStartTime
        }),
        q: common_vendor.t(getTransportStatusText(transportData.value.transitStatus)),
        r: isEdit.value
      }, isEdit.value ? {
        s: common_vendor.p({
          name: "arrow-down",
          size: "16",
          color: "#999"
        })
      } : {}, {
        t: common_vendor.o(($event) => isEdit.value && handleStatusClick()),
        v: !isEdit.value ? 1 : "",
        w: common_vendor.o(($event) => transportData.value.contactPerson = $event),
        x: common_vendor.p({
          placeholder: "请输入协调员姓名",
          border: "none",
          readonly: !isEdit.value,
          customStyle: inputStyle(!transportData.value.contactPerson),
          modelValue: transportData.value.contactPerson
        }),
        y: transportData.value.createTime
      }, transportData.value.createTime ? {
        z: common_vendor.o(($event) => transportData.value.createTime = $event),
        A: common_vendor.p({
          placeholder: "自动生成",
          disabled: true,
          disabledColor: disabledColor.value,
          border: "none",
          modelValue: transportData.value.createTime
        })
      } : {}, {
        B: transportData.value.createBy
      }, transportData.value.createBy ? {
        C: common_vendor.o(($event) => transportData.value.createBy = $event),
        D: common_vendor.p({
          placeholder: "自动获取",
          disabled: true,
          disabledColor: disabledColor.value,
          border: "none",
          modelValue: transportData.value.createBy
        })
      } : {}, {
        E: common_vendor.o(($event) => transportData.value.doctor = $event),
        F: common_vendor.p({
          placeholder: "请输入急诊科医生",
          border: "none",
          readonly: !isEdit.value,
          modelValue: transportData.value.doctor
        }),
        G: common_vendor.o(($event) => transportData.value.doctorPhone = $event),
        H: common_vendor.p({
          placeholder: "请输入医生手机号",
          type: "number",
          border: "none",
          readonly: !isEdit.value,
          modelValue: transportData.value.doctorPhone
        }),
        I: common_vendor.o(($event) => transportData.value.nurse = $event),
        J: common_vendor.p({
          placeholder: "请输入护士姓名",
          border: "none",
          readonly: !isEdit.value,
          modelValue: transportData.value.nurse
        }),
        K: common_vendor.o(($event) => transportData.value.nursePhone = $event),
        L: common_vendor.p({
          placeholder: "请输入护士手机号",
          type: "number",
          border: "none",
          readonly: !isEdit.value,
          modelValue: transportData.value.nursePhone
        }),
        M: common_vendor.o(($event) => transportData.value.driver = $event),
        N: common_vendor.p({
          placeholder: "请输入驾驶员姓名",
          border: "none",
          readonly: !isEdit.value,
          modelValue: transportData.value.driver
        }),
        O: common_vendor.o(($event) => transportData.value.driverPhone = $event),
        P: common_vendor.p({
          placeholder: "请输入驾驶员手机号",
          type: "number",
          border: "none",
          readonly: !isEdit.value,
          modelValue: transportData.value.driverPhone
        }),
        Q: common_vendor.o(($event) => transportData.value.icuDoctor = $event),
        R: common_vendor.p({
          placeholder: "请输入ICU评估医生",
          border: "none",
          readonly: !isEdit.value,
          modelValue: transportData.value.icuDoctor
        }),
        S: common_vendor.o(($event) => transportData.value.icuDoctorPhone = $event),
        T: common_vendor.p({
          placeholder: "请输入ICU医生手机号",
          type: "number",
          border: "none",
          readonly: !isEdit.value,
          modelValue: transportData.value.icuDoctorPhone
        }),
        U: common_vendor.o(($event) => transportData.value.remark = $event),
        V: common_vendor.p({
          placeholder: "请输入备注信息",
          border: "none",
          readonly: !isEdit.value,
          count: isEdit.value,
          maxlength: "500",
          height: "150",
          modelValue: transportData.value.remark
        }),
        W: !isEdit.value
      }, !isEdit.value ? common_vendor.e({
        X: common_vendor.o(goBack),
        Y: canEdit.value
      }, canEdit.value ? {
        Z: common_vendor.o(handleEdit)
      } : {}, {
        aa: canStartTransport.value
      }, canStartTransport.value ? {
        ab: common_vendor.o(handleStartTransport)
      } : {}, {
        ac: canCompleteTransport.value
      }, canCompleteTransport.value ? {
        ad: common_vendor.o(handleCompleteTransport)
      } : {}) : {
        ae: common_vendor.o(cancelEdit),
        af: common_vendor.o(handleSave),
        ag: common_vendor.p({
          disabled: !isFormValid.value,
          loading: saving.value
        })
      }, {
        ah: common_vendor.sr("attachment", "d1f38c9b-22"),
        ai: common_vendor.o(handleFilesUpdate),
        aj: common_vendor.o(handleBaseUpload),
        ak: common_vendor.o(handlePreview),
        al: common_vendor.p({
          files: attachments.value,
          readonly: isReadonly.value,
          maxCount: 5
        }),
        am: common_vendor.o(onTimeConfirm),
        an: common_vendor.o(($event) => showTimePicker.value = false),
        ao: common_vendor.o(($event) => departureTimeValue.value = $event),
        ap: common_vendor.p({
          show: showTimePicker.value,
          mode: "datetime",
          title: "选择出发时间",
          modelValue: departureTimeValue.value
        }),
        aq: common_vendor.o(onStatusPickerConfirm),
        ar: common_vendor.o(($event) => statusPickerVisible.value = false),
        as: common_vendor.p({
          show: statusPickerVisible.value,
          columns: [statusLabels.value],
          defaultIndex: [statusCurrentIndex.value],
          keyName: "label",
          title: "请选择转运状态"
        }),
        at: common_vendor.p({
          show: loading.value,
          text: loadingText.value
        }),
        av: common_vendor.gei(_ctx, "")
      });
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-d1f38c9b"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/case/transferinfo.js.map