"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
|