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