bug 573 578 584

This commit is contained in:
Ranyunqiao
2026-06-04 17:36:48 +08:00
parent 0eaf133a8d
commit b8d719429d
12 changed files with 446 additions and 46 deletions

View File

@@ -1509,12 +1509,13 @@ function submitForm() {
if (!form.value.identifierNo) {
form.value.typeCode = undefined;
}
form.value.address = getAddress(form);
// 拼接完整地址用于提交,但不覆写表单字段(避免弹窗关闭前显示全地址)
const submitData = { ...form.value, address: getAddress(form) };
// 判断是修改还是新增
if (form.value.busNo != undefined) {
// 修改患者
updatePatient(form.value).then((response) => {
updatePatient(submitData).then((response) => {
proxy.$modal.msgSuccess('修改成功');
visible.value = false;
// 触发提交成功事件,让父组件刷新列表
@@ -1524,7 +1525,7 @@ function submitForm() {
// console.log('患者就诊卡号:', form.value.identifierNo)
// console.log('患者就诊信息:', form.value.patientIdInfoList)
// 新增患者
addPatient(form.value).then((response) => {
addPatient(submitData).then((response) => {
proxy.$modal.msgSuccess('新增成功');
getPatientInfo(response.data.idCard);
visible.value = false;

View File

@@ -137,8 +137,8 @@ function close() {
emit('close');
}
function clickRow(row) {
selectRow.value = row;
function clickRow(params) {
selectRow.value = params.row;
}
</script>

View File

@@ -124,8 +124,8 @@ function handlePageChange(page) {
}
// 点击行选择诊断
function clickRow(row) {
emit('selectDiagnosis', row);
function clickRow(params) {
emit('selectDiagnosis', params.row);
}
</script>

View File

@@ -166,19 +166,79 @@
</vxe-column>
<vxe-column
title="操作"
min-width="100"
min-width="220"
align="center"
fixed="right"
>
<template #default="scope">
<el-button
link
type="primary"
icon="View"
@click="handleViewDetail(scope.row)"
>
详情
</el-button>
<!-- 待签发编辑 + 详情 + 删除 -->
<template v-if="canManageRow(scope.row) && isPendingStatus(scope.row)">
<el-button
link
type="primary"
@click="handleEdit(scope.row)"
>
编辑
</el-button>
<el-button
link
type="primary"
@click="handleViewDetail(scope.row)"
>
详情
</el-button>
<el-button
link
type="danger"
@click="handleDelete(scope.row)"
>
删除
</el-button>
</template>
<!-- 已签发撤回 + 详情 -->
<template v-else-if="canManageRow(scope.row) && isWithdrawableStatus(scope.row)">
<el-button
link
type="warning"
@click="handleWithdraw(scope.row)"
>
撤回
</el-button>
<el-button
link
type="primary"
@click="handleViewDetail(scope.row)"
>
详情
</el-button>
</template>
<!-- 已校对/已执行/已安排/已完成详情 + 打印 -->
<template v-else-if="isPrintableStatus(scope.row)">
<el-button
link
type="primary"
@click="handleViewDetail(scope.row)"
>
详情
</el-button>
<el-button
link
type="success"
@click="handlePrint(scope.row)"
>
打印
</el-button>
</template>
<!-- 已作废/其他状态仅详情 -->
<template v-else>
<el-button
link
type="primary"
@click="handleViewDetail(scope.row)"
>
详情
</el-button>
</template>
</template>
</vxe-column>
</vxe-table>
@@ -256,7 +316,7 @@
v-if="isFieldMatched(key)"
:label="getFieldLabel(key)"
>
{{ value || '-' }}
{{ getFieldValue(key, value) }}
</el-descriptions-item>
</template>
</el-descriptions>
@@ -309,17 +369,45 @@
</el-button>
</template>
</el-dialog>
<!-- 编辑弹窗 -->
<el-dialog
v-model="editDialogVisible"
title="编辑手术申请单"
width="1200px"
destroy-on-close
:close-on-click-modal="false"
@closed="editRowData = null"
>
<SurgeryForm
ref="editFormRef"
:edit-data="editRowData"
@submit-ok="handleEditSubmitOk"
/>
<template #footer>
<el-button @click="editDialogVisible = false">取消</el-button>
<el-button
type="primary"
@click="submitEditForm"
>
确认修改
</el-button>
</template>
</el-dialog>
</div>
</template>
<script setup>
import {computed, getCurrentInstance, ref, watch} from 'vue';
import {computed, getCurrentInstance, nextTick, ref, watch} from 'vue';
import {Refresh, Search} from '@element-plus/icons-vue';
import {patientInfo} from '../../store/patient.js';
import {getSurgery} from './api';
import {getSurgery, deleteRequestForm, withdrawRequestForm} from './api';
import {getDepartmentList} from '@/api/public.js';
import SurgeryForm from '../order/applicationForm/surgery.vue';
import useUserStore from '@/store/modules/user';
import auth from '@/plugins/auth';
const { proxy } = getCurrentInstance();
const userStore = useUserStore();
const tableData = ref([]);
const loading = ref(false);
@@ -327,6 +415,9 @@ const detailDialogVisible = ref(false);
const currentDetail = ref(null);
const descJsonData = ref(null);
const orgOptions = ref([]);
const editDialogVisible = ref(false);
const editRowData = ref(null);
const editFormRef = ref(null);
// 获取默认日期范围近7天
const getDefaultDateRange = () => {
@@ -412,6 +503,101 @@ const handleRefresh = async () => {
await fetchData();
};
/** 待签发 */
const isPendingStatus = (row) => row.status === 1;
/** 已签发(可撤回) */
const isWithdrawableStatus = (row) => row.status === 2;
/** 已校对/已执行/已安排/已完成(可打印) */
const isPrintableStatus = (row) => [3, 4, 5, 6].includes(row.status);
/** 是否可管理该申请单:申请者本人或管理员 */
const canManageRow = (row) => {
if (auth.hasRole('admin')) return true;
const currentPractitionerId = userStore.practitionerId;
const requesterId = row?.requesterId;
if (!currentPractitionerId || !requesterId) return false;
return String(currentPractitionerId) === String(requesterId);
};
/**
* 编辑手术申请单(待签发状态)
*/
const handleEdit = async (row) => {
editRowData.value = row;
editDialogVisible.value = true;
await nextTick();
editFormRef.value?.getLocationInfo?.();
editFormRef.value?.getDiagnosisList?.();
editFormRef.value?.loadDoctorOptions?.();
if (row.requestFormDetailList?.length > 0) {
editFormRef.value?.fillForm?.(
JSON.parse(row.descJson || '{}'),
row.requestFormDetailList,
row.requestFormId
);
}
};
const handleEditSubmitOk = async () => {
editDialogVisible.value = false;
editRowData.value = null;
proxy.$modal?.msgSuccess?.('修改成功');
await fetchData();
};
const submitEditForm = () => {
if (editFormRef.value?.submit) {
editFormRef.value.submit();
}
};
/**
* 删除手术申请单(仅待签发状态可删除)
*/
const handleDelete = async (row) => {
try {
await proxy.$modal?.confirm?.('确认删除该笔手术申请单吗?删除后数据将无法恢复。');
} catch { return; }
try {
const res = await deleteRequestForm({ requestFormId: row.requestFormId });
if (res?.code === 200) {
proxy.$modal?.msgSuccess?.('删除成功');
await fetchData();
} else {
proxy.$modal?.msgError?.(res?.msg || '删除失败');
}
} catch { /* 响应拦截器已处理错误提示 */ }
};
/**
* 撤回手术申请单(已签发状态可撤回)
*/
const handleWithdraw = async (row) => {
try {
await proxy.$modal?.confirm?.(
'确认撤回该手术申请吗?撤回后将恢复为待签发状态,护士站医嘱校对将同步更新。'
);
} catch { return; }
try {
const res = await withdrawRequestForm({ requestFormId: row.requestFormId });
if (res?.code === 200) {
proxy.$modal?.msgSuccess?.('撤回成功');
await fetchData();
} else {
proxy.$modal?.msgError?.(res?.msg || '撤回失败');
}
} catch { /* 响应拦截器已处理错误提示 */ }
};
/**
* 打印手术申请单:打开详情弹窗后触发浏览器打印
*/
const handlePrint = async (row) => {
await handleViewDetail(row);
nextTick(() => {
window.print();
});
};
/** 手术申请单状态映射 (与后端 SurgeryAppStatusEnum 对齐) */
const statusMap = {
1: { text: '待签发', type: 'info' },
@@ -459,6 +645,20 @@ const getFieldLabel = (key) => {
return labelMap[key] || key;
};
const getFieldValue = (key, value) => {
// 主刀医生/助手优先显示姓名兜底显示ID
if (key === 'mainSurgeonId' && descJsonData.value?.mainSurgeonName) {
return descJsonData.value.mainSurgeonName;
}
if (key === 'assistant1Id' && descJsonData.value?.assistant1Name) {
return descJsonData.value.assistant1Name;
}
if (key === 'assistant2Id' && descJsonData.value?.assistant2Name) {
return descJsonData.value.assistant2Name;
}
return value || '-';
};
const hasMatchedFields = computed(() => {
if (!descJsonData.value) return false;
return Object.keys(descJsonData.value).some((key) => isFieldMatched(key));

View File

@@ -79,8 +79,8 @@ function getList() {
}
}
function clickRow(row) {
emit('selectDiagnosis', row);
function clickRow(params) {
emit('selectDiagnosis', params.row);
}
</script>

View File

@@ -343,6 +343,14 @@ import useUserStore from '@/store/modules/user';
const { proxy } = getCurrentInstance();
const emits = defineEmits(['submitOk']);
const userStore = useUserStore();
const props = defineProps({
editData: {
type: Object,
default: null,
},
});
// 当前编辑的申请单ID编辑模式时有值用于覆盖保存
const editingRequestFormId = ref('');
// 模块级缓存:避免每次打开弹窗都重新请求
let surgeryRecordsCache = null; // 原始 API 记录
let surgeryMappedCache = null; // 映射后的 el-transfer 数据
@@ -454,6 +462,27 @@ const mapToTransferItem = (item) => ({
disabled: false,
});
/**
* 填充编辑表单数据(父组件调用)
* @param {Object} descJson - row.descJson 解析后的对象
* @param {Array} details - row.requestFormDetailList
* @param {string} formId - row.requestFormId
*/
const fillForm = (descJson, details, formId) => {
editingRequestFormId.value = formId || '';
// 回填已选手术项目到穿梭框
const ids = (details || []).map((d) => String(d.adviceDefinitionId));
transferValue.value = ids;
// 回填表单字段
if (descJson) {
Object.keys(form).forEach((key) => {
if (descJson[key] !== undefined && key !== 'primaryDiagnosisList' && key !== 'otherDiagnosisList') {
form[key] = descJson[key];
}
});
}
};
const transferValue = ref([]);
const form = reactive({
// categoryType: '', // 项目类别
@@ -613,12 +642,21 @@ const submit = () => {
accountId: patientInfo.value.accountId,
};
});
// 解析主刀医生、助手姓名,确保 descJson 中存有名称而非纯ID
const surgeonDoc = doctorOptions.value.find(d => d.id === form.mainSurgeonId);
form.mainSurgeonName = surgeonDoc ? surgeonDoc.name : '';
const assistant1Doc = doctorOptions.value.find(d => d.id === form.assistant1Id);
form.assistant1Name = assistant1Doc ? assistant1Doc.name : '';
const assistant2Doc = doctorOptions.value.find(d => d.id === form.assistant2Id);
form.assistant2Name = assistant2Doc ? assistant2Doc.name : '';
saveSurgery({
activityList: applicationListAllFilter,
patientId: patientInfo.value.patientId, //患者ID
encounterId: patientInfo.value.encounterId, // 就诊ID
organizationId: patientInfo.value.inHospitalOrgId, // 医疗机构ID
requestFormId: '', // 申请单ID
requestFormId: editingRequestFormId.value || '', // 编辑时传已有ID新建时为空
name: '手术申请单',
descJson: JSON.stringify(form),
categoryEnum: '24', // 21 检验 22 检查 23 输血 24 手术(避开 adviceType 1-6 碰撞)
@@ -626,6 +664,7 @@ const submit = () => {
if (res.code === 200) {
proxy.$message.success(res.msg);
applicationList.value = [];
editingRequestFormId.value = '';
emits('submitOk');
} else {
proxy.$message.error(res.message);
@@ -681,7 +720,7 @@ function getDiagnosisList() {
}
});
}
defineExpose({ state, submit, getLocationInfo, getDiagnosisList, getList, loadDoctorOptions });
defineExpose({ state, submit, fillForm, getLocationInfo, getDiagnosisList, getList, loadDoctorOptions });
</script>
<style lang="scss" scoped>
.surgery-container {

View File

@@ -1467,7 +1467,7 @@
<vxe-column
title="手术名称"
align="center"
field="descJson.surgeryName"
field="surgeryName"
min-width="140"
show-overflow
/>
@@ -1823,6 +1823,9 @@ const rules = reactive({
anesMethod: [
{ required: true, message: '请选择麻醉方法', trigger: 'change' }
],
preoperativeDiagnosis: [
{ required: true, message: '请输入术前诊断', trigger: 'blur' }
],
surgeonCode: [
{ required: true, message: '请选择主刀医生', trigger: 'change' }
]
@@ -2915,7 +2918,9 @@ function submitForm() {
const submitData = {
...form,
orgId: userStore.orgId,
incisionLevel: form.incisionType
incisionLevel: form.incisionType,
preoperativeDiagnosis: form.preoperativeDiagnosis || '',
postoperativeDiagnosis: form.postoperativeDiagnosis || ''
}
delete submitData.incisionType
if (!form.scheduleId) {
@@ -3028,7 +3033,7 @@ function cancelApplyDialog() {
// 行点击事件处理
function handleApplyRowClick(row) {
const selectedRows = applyTableRef.value?.getSelectionRows ? applyTableRef.value.getSelectionRows() : []
const selectedRows = applyTableRef.value?.getCheckboxRecords ? applyTableRef.value.getCheckboxRecords() : []
// 如果已经有选中的行,先清除所有选择
if (selectedRows.length > 0) {
applyTableRef.value.clearCheckboxRow()
@@ -3040,14 +3045,14 @@ function handleApplyRowClick(row) {
// 表格行样式
function tableRowClassName({ row, rowIndex }) {
// 检查当前行是否被选中
const selectedRows = applyTableRef.value?.getSelectionRows ? applyTableRef.value.getSelectionRows() : []
const selectedRows = applyTableRef.value?.getCheckboxRecords ? applyTableRef.value.getCheckboxRecords() : []
const isSelected = selectedRows.some(selectedRow => selectedRow.surgeryNo === row.surgeryNo)
return isSelected ? 'selected-row' : ''
}
// 控制表格只能单选
function handleSelectable(row, rowIndex) {
const selectedRows = applyTableRef.value?.getSelectionRows ? applyTableRef.value.getSelectionRows() : []
const selectedRows = applyTableRef.value?.getCheckboxRecords ? applyTableRef.value.getCheckboxRecords() : []
// 如果还没有选中的行,或者当前行就是已经选中的行,则允许选择
return selectedRows.length === 0 || selectedRows.some(selectedRow => selectedRow.surgeryNo === row.surgeryNo)
}
@@ -3099,7 +3104,7 @@ const formattedApplyTime = computed(() => {
// 确认手术申请
function confirmApply() {
const selectedRows = applyTableRef.value?.getSelectionRows ? applyTableRef.value.getSelectionRows() : []
const selectedRows = applyTableRef.value?.getCheckboxRecords ? applyTableRef.value.getCheckboxRecords() : []
if (!selectedRows || selectedRows.length === 0) {
proxy.$modal.msgWarning('请先选择一条手术申请记录')
return
@@ -3112,8 +3117,8 @@ function confirmApply() {
form.visitId = selectedRow.encounterId // id对应填入就诊id
form.identifierNo = selectedRow.identifierNo || '' // 就诊卡号
form.operCode = selectedRow.surgeryNo // 手术单号作为手术编码
form.operName = selectedRow.descJson?.surgeryName//手术名称
form.preoperativeDiagnosis = selectedRow.preoperativeDiagnosis || selectedRow.descJson?.preoperativeDiagnosis
form.operName = selectedRow.surgeryName || selectedRow.descJson?.surgeryName//手术名称
form.preoperativeDiagnosis = selectedRow.preoperativeDiagnosis || selectedRow.descJson?.preoperativeDiagnosis || ''
form.patientName = selectedRow.name// 患者姓名对应填入患者姓名
form.gender = selectedRow.gender//患者性别
form.birthDay = selectedRow.birthDay//患者出生日期