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
"use strict";
const common_vendor = require("../../common/vendor.js");
const _sfc_main = {
  __name: "list",
  setup(__props) {
    const patients = common_vendor.ref([
      {
        id: 1,
        name: "张三",
        idType: "身份证",
        idNumber: "440************123",
        cardNo: "1234567890",
        relation: "self",
        relationText: "本人",
        isDefault: true
      },
      {
        id: 2,
        name: "张小明",
        idType: "身份证",
        idNumber: "440************456",
        cardNo: "0987654321",
        relation: "child",
        relationText: "子女",
        isDefault: false
      }
    ]);
    const selectPatient = (patient) => {
      var _a, _b;
      const pages = getCurrentPages();
      const prevPage = pages[pages.length - 2];
      if ((_b = (_a = prevPage == null ? void 0 : prevPage.$page) == null ? void 0 : _a.path) == null ? void 0 : _b.includes("/appointment/")) {
        common_vendor.index.$emit("selectPatient", patient);
        common_vendor.index.navigateBack();
      }
    };
    const addPatient = () => {
      if (patients.value.length >= 5) {
        common_vendor.index.showToast({
          title: "最多添加5个就诊人",
          icon: "none"
        });
        return;
      }
      common_vendor.index.navigateTo({
        url: "/pages/patient/add"
      });
    };
    const editPatient = (patient) => {
      common_vendor.index.navigateTo({
        url: `/pages/patient/edit?id=${patient.id}`
      });
    };
    const deletePatient = (patient) => {
      common_vendor.index.showModal({
        title: "提示",
        content: "确定要删除该就诊人吗?",
        success: (res) => {
          if (res.confirm) {
            const index = patients.value.findIndex((p) => p.id === patient.id);
            if (index > -1) {
              patients.value.splice(index, 1);
              common_vendor.index.showToast({
                title: "删除成功",
                icon: "success"
              });
            }
          }
        }
      });
    };
    const setDefault = (patient) => {
      patients.value.forEach((p) => {
        p.isDefault = p.id === patient.id;
      });
      common_vendor.index.showToast({
        title: "设置成功",
        icon: "success"
      });
    };
    return (_ctx, _cache) => {
      return {
        a: common_vendor.f(patients.value, (patient, index, i0) => {
          return common_vendor.e({
            a: common_vendor.t(patient.name),
            b: patient.isDefault
          }, patient.isDefault ? {} : {}, {
            c: common_vendor.t(patient.relationText),
            d: common_vendor.n(patient.relation),
            e: common_vendor.t(patient.idType),
            f: common_vendor.t(patient.idNumber),
            g: patient.cardNo
          }, patient.cardNo ? {
            h: common_vendor.t(patient.cardNo)
          } : {}, {
            i: common_vendor.o(($event) => editPatient(patient), index),
            j: !patient.isDefault
          }, !patient.isDefault ? {
            k: common_vendor.o(($event) => deletePatient(patient), index)
          } : {}, {
            l: !patient.isDefault
          }, !patient.isDefault ? {
            m: common_vendor.o(($event) => setDefault(patient), index)
          } : {}, {
            n: index,
            o: common_vendor.o(($event) => selectPatient(patient), index)
          });
        }),
        b: common_vendor.o(addPatient),
        c: common_vendor.gei(_ctx, "")
      };
    };
  }
};
wx.createPage(_sfc_main);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/patient/list.js.map