+
+
+
+
+
+
+ {{ scope.row.startTime || '-' }}
+
+
+
@@ -792,12 +799,15 @@ function handleAddPrescription() {
}
isAdding.value = true;
// 在数组最前方添加一行,让新增行显示在最上边
+ // 获取当前时间作为默认开始时间
+ const defaultStartTime = defaultStartTimeFn();
prescriptionList.value.unshift({
uniqueKey: nextId.value++,
showPopover: false,
isEdit: true,
statusEnum: 1,
therapyEnum: '1', // 默认为长期医嘱
+ startTime: defaultStartTime,
});
getGroupMarkers();
nextTick(() => {
@@ -822,6 +832,34 @@ function checkUnit(item, row) {
}
}
+/**
+ * 校验医嘱开始时间不能早于患者入院时间
+ * @param {string} startTime 医嘱开始时间字符串
+ * @returns {boolean} true=通过, false=不通过
+ */
+function validateStartTime(startTime) {
+ if (!startTime || !patientInfo.value?.inHospitalTime) return true;
+ const startDate = new Date(startTime);
+ const inHospitalDate = new Date(patientInfo.value.inHospitalTime);
+ if (startDate < inHospitalDate) {
+ const pad = (n) => String(n).padStart(2, '0');
+ const d = inHospitalDate;
+ const timeStr = d.getFullYear() + '-' + pad(d.getMonth() + 1) + '-' + pad(d.getDate()) + ' ' + pad(d.getHours()) + ':' + pad(d.getMinutes());
+ proxy.$modal.msgWarning('医嘱开始时间不能早于患者入院时间(' + timeStr + ')!');
+ return false;
+ }
+ return true;
+}
+
+/**
+ * 获取当前时间的格式化字符串作为默认开始时间
+ */
+function defaultStartTimeFn() {
+ const now = new Date();
+ const pad = (n) => String(n).padStart(2, '0');
+ return now.getFullYear() + '-' + pad(now.getMonth() + 1) + '-' + pad(now.getDate()) + ' ' + pad(now.getHours()) + ':' + pad(now.getMinutes()) + ':' + pad(now.getSeconds());
+}
+
// 行双击打开编辑块:待保存、待签发医嘱均可编辑;已签发/已完成/停止不允许编辑
function clickRowDb(row, column, event) {
// 检查点击的是否是复选框
@@ -1146,6 +1184,12 @@ function handleSave() {
proxy.$modal.msgWarning('请先保存当前医嘱');
return;
}
+ // 校验所有待签发医嘱的开始时间
+ for (const item of filterPrescriptionList.value) {
+ if (item.statusEnum == 1 && item.requestId && !validateStartTime(item.startTime)) {
+ return;
+ }
+ }
// 如果可以编辑状态并且医嘱类型不存在删除掉
if (filterPrescriptionList.value[0].isEdit && !filterPrescriptionList.value[0].adviceType) {
prescriptionList.value.shift();
@@ -1339,6 +1383,10 @@ function handleCancelEdit(row, index) {
}
function handleSaveSign(row, index) {
+ // 校验医嘱开始时间
+ if (!validateStartTime(row.startTime)) {
+ return;
+ }
if (row.adviceType != 2) {
let itemNo = row.adviceType == 1 ? row.methodCode : row.adviceDefinitionId;
if (!itemNo) {
@@ -1423,6 +1471,13 @@ function handleSaveBatch() {
proxy.$modal.msgWarning('请先点击确定确认当前医嘱');
return;
}
+ // 校验开始时间(批量保存前验证所有待保存项)
+ const pendingItems = filterPrescriptionList.value.filter(item => item.statusEnum == 1 && !item.requestId);
+ for (const item of pendingItems) {
+ if (!validateStartTime(item.startTime)) {
+ return;
+ }
+ }
console.log('filterPrescriptionList=====>', JSON.stringify(filterPrescriptionList.value));
// 如果可以编辑状态并且医嘱类型不存在删除掉
@@ -1656,6 +1711,7 @@ function handleSaveGroup(orderGroupList) {
orgId: resolveOrgId(mergedDetail.orgId || patientInfo.value?.inHospitalOrgId) || '',
// 🔧 修复:同时存储 orgName,确保树匹配不到时仍有中文名称可显示
orgName: findOrgName(mergedDetail.orgId || patientInfo.value?.inHospitalOrgId) || mergedDetail.orgName || patientInfo.value?.inHospitalOrgName || '',
+ startTime: mergedDetail.startTime || defaultStartTimeFn(),
dbOpType: prescriptionList.value[tempIndex].requestId ? '2' : '1',
conditionId: conditionId.value,
conditionDefinitionId: conditionDefinitionId.value,
@@ -1700,6 +1756,7 @@ function handleSaveHistory(value) {
encounterId: patientInfo.value.encounterId,
accountId: accountId.value,
uniqueKey: undefined,
+ startTime: defaultStartTimeFn(),
dbOpType: value.requestId ? '2' : '1',
minUnitQuantity: value.quantity * value.partPercent,
conditionId: conditionId.value,