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
"use strict";
const common_vendor = require("../../common/vendor.js");
const _sfc_main = {
  __name: "edit",
  setup(__props) {
    const relations = [
      { value: "self", label: "本人" },
      { value: "parent", label: "父母" },
      { value: "child", label: "子女" },
      { value: "spouse", label: "配偶" },
      { value: "other", label: "其他" }
    ];
    const selectedRelation = common_vendor.ref(null);
    const form = common_vendor.ref({
      id: "",
      name: "",
      idType: "",
      idNumber: "",
      relation: "",
      cardNo: "",
      phone: "",
      isDefault: false
    });
    const getIdTypeLabel = (type) => {
      const types = {
        id: "身份证",
        passport: "护照",
        hkm: "港澳居民来往内地通行证"
      };
      return types[type] || type;
    };
    const maskIdNumber = (number) => {
      if (!number)
        return "";
      if (number.length <= 8)
        return number;
      return number.replace(new RegExp("(?<=.{4}).(?=.{4})", "g"), "*");
    };
    const onRelationChange = (e) => {
      selectedRelation.value = relations[e.detail.value];
      form.value.relation = selectedRelation.value.value;
    };
    const canSubmit = common_vendor.computed(() => {
      const { name, relation, phone } = form.value;
      return name && relation && phone;
    });
    const submitForm = () => {
      if (!canSubmit.value)
        return;
      common_vendor.index.showLoading({
        title: "保存中..."
      });
      common_vendor.index.__f__("log", "at pages/patient/edit.vue:147", "提交表单:", form.value);
      setTimeout(() => {
        common_vendor.index.hideLoading();
        common_vendor.index.showToast({
          title: "保存成功",
          icon: "success"
        });
        setTimeout(() => {
          common_vendor.index.navigateBack();
        }, 1500);
      }, 1e3);
    };
    common_vendor.onMounted(() => {
      var _a, _b;
      const pages = getCurrentPages();
      const page = pages[pages.length - 1];
      const id = (_b = (_a = page.$page) == null ? void 0 : _a.options) == null ? void 0 : _b.id;
      loadPatient(id);
    });
    const loadPatient = (id) => {
      form.value = {
        id,
        name: "张三",
        idType: "id",
        idNumber: "440123199001011234",
        relation: "self",
        cardNo: "1234567890",
        phone: "13800138000",
        isDefault: true
      };
      selectedRelation.value = relations.find((r) => r.value === form.value.relation);
    };
    return (_ctx, _cache) => {
      var _a;
      return {
        a: form.value.name,
        b: common_vendor.o(($event) => form.value.name = $event.detail.value),
        c: common_vendor.t(getIdTypeLabel(form.value.idType)),
        d: common_vendor.t(maskIdNumber(form.value.idNumber)),
        e: common_vendor.t(((_a = selectedRelation.value) == null ? void 0 : _a.label) || "请选择关系"),
        f: relations,
        g: common_vendor.o(onRelationChange),
        h: common_vendor.t(form.value.cardNo || "暂未绑定就诊卡"),
        i: form.value.phone,
        j: common_vendor.o(($event) => form.value.phone = $event.detail.value),
        k: form.value.isDefault,
        l: common_vendor.o((e) => form.value.isDefault = e.detail.value),
        m: form.value.isDefault,
        n: !canSubmit.value,
        o: common_vendor.o(submitForm),
        p: common_vendor.gei(_ctx, "")
      };
    };
  }
};
wx.createPage(_sfc_main);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/patient/edit.js.map