WXL
19 小时以前 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
"use strict";
const common_vendor = require("../../common/vendor.js");
const common_assets = require("../../common/assets.js");
const utils_dict = require("../../utils/dict.js");
if (!Array) {
  const _easycom_u_loading_icon2 = common_vendor.resolveComponent("u-loading-icon");
  const _easycom_u_loading_page2 = common_vendor.resolveComponent("u-loading-page");
  (_easycom_u_loading_icon2 + _easycom_u_loading_page2)();
}
const _easycom_u_loading_icon = () => "../../uni_modules/uview-plus/components/u-loading-icon/u-loading-icon.js";
const _easycom_u_loading_page = () => "../../uni_modules/uview-plus/components/u-loading-page/u-loading-page.js";
if (!Math) {
  (_easycom_u_loading_icon + _easycom_u_loading_page)();
}
const _sfc_main = {
  __name: "transfer",
  setup(__props) {
    const dict = common_vendor.ref({});
    const stats = common_vendor.ref({
      totalTransports: 0,
      pendingTransports: 0,
      completedTransports: 0
    });
    const transports = common_vendor.ref([]);
    const loading = common_vendor.ref(false);
    const initLoading = common_vendor.ref(false);
    const loadingMore = common_vendor.ref(false);
    const refreshing = common_vendor.ref(false);
    const hasMore = common_vendor.ref(true);
    const pageNum = common_vendor.ref(1);
    const pageSize = common_vendor.ref(10);
    const showActionModal = common_vendor.ref(false);
    const currentTransport = common_vendor.ref({});
    const modalTitle = common_vendor.ref("");
    const modalAction = common_vendor.ref("");
    const transportTypes = [
      { label: "全部", value: "" },
      { label: "待转运", value: 1 },
      { label: "转运中", value: 2 },
      { label: "已完成", value: 3 },
      { label: "已取消", value: 4 },
      { label: "暂存", value: 5 }
    ];
    const currentType = common_vendor.ref("");
    const startDate = common_vendor.ref("");
    const endDate = common_vendor.ref("");
    common_vendor.onLoad(async (options) => {
      dict.value = await utils_dict.useDict("sys_user_sex");
      await loadInitialData();
    });
    common_vendor.onReachBottom(() => {
      if (hasMore.value && !loading.value && !loadingMore.value) {
        onLoadMore();
      }
    });
    common_vendor.onShow(() => {
      const update = common_vendor.index.getStorageSync("transportStatusUpdate");
      if (update) {
        handleStatusUpdate(update);
        common_vendor.index.removeStorageSync("transportStatusUpdate");
      }
    });
    const mapApiDataToTransportItem = (apiData) => {
      return {
        id: apiData.id,
        reportId: apiData.reportId,
        caseNo: apiData.caseNo,
        patName: apiData.patName,
        sex: apiData.sex,
        age: apiData.age,
        diagnosisname: apiData.diagnosisname,
        treatmentHospitalName: apiData.treatmentHospitalName,
        transportStartTime: apiData.transportStartTime,
        contactPerson: apiData.contactPerson,
        createTime: apiData.createTime,
        transitStatus: apiData.transitStatus,
        // 医护人员信息
        doctor: apiData.doctor,
        nurse: apiData.nurse,
        driver: apiData.driver,
        // 其他字段
        transportStartPlace: apiData.transportStartPlace,
        remark: apiData.remark
      };
    };
    const filteredTransports = common_vendor.computed(() => {
      let result = transports.value;
      if (currentType.value !== "") {
        result = result.filter((item) => item.transitStatus === currentType.value);
      }
      return result;
    });
    const getStatusClass = (status) => {
      const map = {
        1: "pending",
        // 待转运
        2: "transporting",
        // 转运中
        3: "completed",
        // 已完成
        4: "cancelled",
        // 已取消
        5: "cancelled"
        // 暂存
      };
      return map[status] || "pending";
    };
    const getStatusText = (status) => {
      const map = {
        1: "待出发",
        2: "转运中",
        3: "已完成",
        4: "已取消",
        5: "暂存"
      };
      return map[status] || "待转运";
    };
    const getGenderText = (gender) => {
      if (!gender)
        return "待转运";
      if (!dict.value.sys_user_sex)
        return gender;
      const genderItem = dict.value.sys_user_sex.find(
        (item) => item.dictValue === gender
      );
      return genderItem ? genderItem.dictLabel : gender;
    };
    const formatTime = (timeStr) => {
      if (!timeStr)
        return "未设置";
      return timeStr.replace("T", " ").substring(0, 16);
    };
    const selectType = (type) => {
      currentType.value = type;
      pageNum.value = 1;
      loadTransports(true);
    };
    const onStartDateChange = (e) => {
      startDate.value = e.detail.value;
      if (endDate.value) {
        pageNum.value = 1;
        loadTransports(true);
      }
    };
    const onEndDateChange = (e) => {
      endDate.value = e.detail.value;
      if (startDate.value) {
        pageNum.value = 1;
        loadTransports(true);
      }
    };
    const viewDetail = (item) => {
      viewDetails(item);
    };
    const viewDetails = (item) => {
      common_vendor.index.navigateTo({
        url: `/pages/case/transferinfo?id=${item.id}`
      });
    };
    const editTransport = (item) => {
      common_vendor.index.navigateTo({
        url: `/pages/case/transferinfo?id=${item.id}&edit=true`
      });
    };
    const startTransport = (item) => {
      currentTransport.value = item;
      modalTitle.value = "开始转运";
      modalAction.value = "开始";
      showActionModal.value = true;
    };
    const completeTransport = (item) => {
      currentTransport.value = item;
      modalTitle.value = "完成转运";
      modalAction.value = "完成";
      showActionModal.value = true;
    };
    const confirmAction = async () => {
      try {
        if (modalAction.value === "开始") {
          await updateTransportStatus(2, "开始转运");
        } else if (modalAction.value === "完成") {
          await updateTransportStatus(3, "完成转运");
        }
        common_vendor.index.showToast({
          title: `${modalAction.value}成功`,
          icon: "success"
        });
      } catch (error) {
        common_vendor.index.__f__("error", "at pages/case/transfer.vue:421", `${modalAction.value}失败:`, error);
        common_vendor.index.showToast({
          title: `${modalAction.value}失败,请重试`,
          icon: "none"
        });
      } finally {
        showActionModal.value = false;
      }
    };
    const cancelAction = () => {
      showActionModal.value = false;
    };
    const loadInitialData = async () => {
      initLoading.value = true;
      try {
        await Promise.all([loadTransports(true), loadStats()]);
      } catch (error) {
        common_vendor.index.__f__("error", "at pages/case/transfer.vue:442", "初始化数据失败:", error);
      } finally {
        initLoading.value = false;
      }
    };
    const onRefresh = async () => {
      refreshing.value = true;
      pageNum.value = 1;
      await loadTransports(true);
      await loadStats();
      setTimeout(() => {
        refreshing.value = false;
      }, 1e3);
    };
    const onLoadMore = async () => {
      if (!hasMore.value || loading.value || loadingMore.value)
        return;
      await loadTransports();
    };
    const loadTransports = async (reset = false) => {
      if (reset) {
        pageNum.value = 1;
        hasMore.value = true;
      }
      if (loading.value || loadingMore.value || !hasMore.value)
        return;
      if (reset) {
        loading.value = true;
      } else {
        loadingMore.value = true;
      }
      try {
        const params = {
          pageNum: pageNum.value,
          pageSize: pageSize.value
        };
        if (currentType.value !== "") {
          params.transitStatus = currentType.value;
        }
        if (startDate.value && endDate.value) {
          params.startDate = startDate.value;
          params.endDate = endDate.value;
        }
        common_vendor.index.__f__("log", "at pages/case/transfer.vue:497", "请求参数:", params);
        const res = await common_vendor.index.$uapi.post("/project/transport/list", params);
        common_vendor.index.__f__("log", "at pages/case/transfer.vue:501", "接口返回数据:", res);
        if (res && res.code === 200) {
          let data = [];
          if (res.rows && Array.isArray(res.rows)) {
            data = res.rows;
          } else if (res.data && Array.isArray(res.data)) {
            data = res.data;
          } else if (Array.isArray(res)) {
            data = res;
          } else {
            common_vendor.index.__f__("error", "at pages/case/transfer.vue:514", "接口返回格式不正确:", res);
            throw new Error("接口返回格式不正确");
          }
          const mappedData = data.map((item) => mapApiDataToTransportItem(item));
          if (reset || pageNum.value === 1) {
            transports.value = mappedData;
          } else {
            transports.value = [...transports.value, ...mappedData];
          }
          hasMore.value = data.length >= pageSize.value;
          if (data.length > 0) {
            pageNum.value++;
          }
        } else {
          throw new Error((res == null ? void 0 : res.msg) || "加载失败");
        }
      } catch (error) {
        common_vendor.index.__f__("error", "at pages/case/transfer.vue:537", "加载转运单列表失败:", error);
        common_vendor.index.showToast({
          title: "网络请求失败",
          icon: "none"
        });
      } finally {
        loading.value = false;
        loadingMore.value = false;
      }
    };
    const loadStats = async () => {
      try {
        const res = await common_vendor.index.$uapi.post("/api/totalServiceTransportState");
        if (res.data) {
          stats.value = {
            totalTransports: res.data.reduce((sum, item) => sum + item.count, 0) || 0,
            pendingTransports: res.data[0].count || 0,
            completedTransports: res.data[3].count || 0
          };
        }
      } catch (error) {
        common_vendor.index.__f__("error", "at pages/case/transfer.vue:561", "加载统计失败:", error);
      }
    };
    const updateTransportStatus = async (newStatus, actionName) => {
      try {
        const updateData = {
          id: currentTransport.value.id,
          transitStatus: newStatus
        };
        const res = await common_vendor.index.$uapi.post("/project/transport/edit", updateData);
        if (res && res.code === 200) {
          const index = transports.value.findIndex(
            (item) => item.id === currentTransport.value.id
          );
          if (index !== -1) {
            transports.value[index].transitStatus = newStatus;
          }
          await loadStats();
          common_vendor.index.setStorageSync("transportStatusUpdate", {
            orderId: currentTransport.value.id,
            status: newStatus
          });
          return true;
        } else {
          throw new Error((res == null ? void 0 : res.msg) || `${actionName}失败`);
        }
      } catch (error) {
        common_vendor.index.__f__("error", "at pages/case/transfer.vue:598", `${actionName}失败:`, error);
        throw error;
      }
    };
    const handleStatusUpdate = (update) => {
      const index = transports.value.findIndex(
        (item) => item.id === update.orderId
      );
      if (index !== -1) {
        transports.value[index].transitStatus = update.status;
      }
    };
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.t(stats.value.totalTransports),
        b: common_vendor.t(stats.value.pendingTransports),
        c: common_vendor.t(stats.value.completedTransports),
        d: common_vendor.f(transportTypes, (type, index, i0) => {
          return {
            a: common_vendor.t(type.label),
            b: index,
            c: currentType.value == type.value ? 1 : "",
            d: common_vendor.o(($event) => selectType(type.value), index)
          };
        }),
        e: common_vendor.t(startDate.value || "开始日期"),
        f: startDate.value,
        g: endDate.value,
        h: common_vendor.o(onStartDateChange),
        i: common_vendor.t(endDate.value || "结束日期"),
        j: endDate.value,
        k: startDate.value,
        l: common_vendor.o(onEndDateChange),
        m: common_vendor.f(filteredTransports.value, (item, index, i0) => {
          return common_vendor.e({
            a: common_vendor.t(item.caseNo || item.reportId),
            b: common_vendor.t(item.patName),
            c: common_vendor.t(getGenderText(item.sex)),
            d: common_vendor.t(item.age),
            e: common_vendor.t(getStatusText(item.transitStatus)),
            f: common_vendor.n(getStatusClass(item.transitStatus)),
            g: common_vendor.t(item.diagnosisname || "未填写"),
            h: common_vendor.t(item.treatmentHospitalName || "未填写"),
            i: common_vendor.t(formatTime(item.transportStartTime)),
            j: common_vendor.t(item.contactPerson || "未指定"),
            k: common_vendor.t(formatTime(item.createTime)),
            l: common_vendor.t(getStatusText(item.transitStatus)),
            m: item.transitStatus === 1
          }, item.transitStatus === 1 ? {
            n: common_vendor.o(($event) => startTransport(item), index)
          } : {}, {
            o: item.transitStatus === 2
          }, item.transitStatus === 2 ? {
            p: common_vendor.o(($event) => completeTransport(item), index)
          } : {}, {
            q: item.transitStatus != 3
          }, item.transitStatus != 3 ? {
            r: common_vendor.o(($event) => editTransport(item), index)
          } : {}, {
            s: common_vendor.o(($event) => viewDetails(item), index),
            t: index,
            v: common_vendor.o(($event) => viewDetail(item), index)
          });
        }),
        n: loadingMore.value
      }, loadingMore.value ? {
        o: common_vendor.p({
          text: "加载中..."
        })
      } : {}, {
        p: !hasMore.value && filteredTransports.value.length > 0
      }, !hasMore.value && filteredTransports.value.length > 0 ? {} : {}, {
        q: !loading.value && filteredTransports.value.length === 0
      }, !loading.value && filteredTransports.value.length === 0 ? {
        r: common_assets._imports_0$8
      } : {}, {
        s: refreshing.value,
        t: common_vendor.o(onRefresh),
        v: common_vendor.o(onLoadMore),
        w: showActionModal.value
      }, showActionModal.value ? {
        x: common_vendor.t(modalTitle.value),
        y: common_vendor.t(modalAction.value),
        z: common_vendor.t(currentTransport.value.caseNo),
        A: common_vendor.o(cancelAction),
        B: common_vendor.o(confirmAction)
      } : {}, {
        C: initLoading.value
      }, initLoading.value ? {
        D: common_vendor.p({
          loading: true,
          text: "数据加载中..."
        })
      } : {}, {
        E: common_vendor.gei(_ctx, "")
      });
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-86a576d6"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/case/transfer.js.map