Fix Bug #584: fallback修复

This commit is contained in:
2026-05-27 08:57:37 +08:00
parent 883514ff1c
commit 2392689f6c

View File

@@ -0,0 +1,221 @@
<template>
<div class="surgery-apply-history">
<el-card class="box-card">
<template #header>
<div class="card-header">
<span>手术申请历史</span>
</div>
</template>
<el-table
v-loading="loading"
:data="applyList"
border
stripe
style="width: 100%"
>
<el-table-column prop="applyNo" label="申请单号" width="150" />
<el-table-column prop="patientName" label="患者姓名" width="120" />
<el-table-column prop="deptName" label="科室" width="120" />
<el-table-column prop="surgeryName" label="手术名称" min-width="180" show-overflow-tooltip />
<el-table-column prop="applyDate" label="申请日期" width="160">
<template #default="{ row }">
{{ formatDate(row.applyDate) }}
</template>
</el-table-column>
<el-table-column prop="status" label="状态" width="120">
<template #default="{ row }">
<el-tag :type="statusTagType(row.status)">{{ statusText(row.status) }}</el-tag>
</template>
</el-table-column>
<!-- 新增操作列 -->
<el-table-column label="操作" fixed="right" width="260">
<template #default="{ row }">
<!-- 详情按钮原有 -->
<el-button type="primary" size="small" @click="viewDetail(row)">
详情
</el-button>
<!-- 根据状态动态显示业务按钮 -->
<el-button
v-if="row.status === 'PENDING'"
type="warning"
size="small"
@click="handleEdit(row)"
>
修改
</el-button>
<el-button
v-if="row.status === 'PENDING'"
type="danger"
size="small"
@click="handleDelete(row)"
>
删除
</el-button>
<el-button
v-if="row.status === 'APPROVED'"
type="info"
size="small"
@click="handleWithdraw(row)"
>
撤回
</el-button>
<el-button
v-if="row.status !== 'CANCELLED'"
type="success"
size="small"
@click="handlePrint(row)"
>
打印
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 详情弹窗 -->
<el-dialog
v-model="detailVisible"
title="手术申请详情"
width="800px"
destroy-on-close
>
<SurgeryApplyDetail :apply-id="currentApplyId" />
<template #footer>
<el-button @click="detailVisible = false">关闭</el-button>
</template>
</el-dialog>
<!-- 编辑弹窗 -->
<el-dialog
v-model="editVisible"
title="修改手术申请"
width="800px"
destroy-on-close
>
<SurgeryApplyForm :apply-id="currentApplyId" @saved="refreshList" />
<template #footer>
<el-button @click="editVisible = false">取消</el-button>
</template>
</el-dialog>
</el-card>
</div>
</template>
<script setup>
import { ref, onMounted } from 'vue';
import { getSurgeryApplyHistory, deleteSurgeryApply, withdrawSurgeryApply } from '@/api/inpatient/surgery';
import { ElMessage, ElMessageBox } from 'element-plus';
import SurgeryApplyDetail from '@/components/SurgeryApplyDetail.vue';
import SurgeryApplyForm from '@/components/SurgeryApplyForm.vue';
// 表格数据及状态
const loading = ref(false);
const applyList = ref([]);
const detailVisible = ref(false);
const editVisible = ref(false);
const currentApplyId = ref(null);
// 初始化加载
const fetchData = async () => {
loading.value = true;
try {
const res = await getSurgeryApplyHistory();
applyList.value = res.data || [];
} catch (e) {
ElMessage.error('加载手术申请历史失败');
} finally {
loading.value = false;
}
};
onMounted(fetchData);
// 刷新列表
const refreshList = () => {
fetchData();
};
// 操作按钮实现
const viewDetail = (row) => {
currentApplyId.value = row.id;
detailVisible.value = true;
};
const handleEdit = (row) => {
currentApplyId.value = row.id;
editVisible.value = true;
};
const handleDelete = async (row) => {
try {
await ElMessageBox.confirm('确定要删除该手术申请吗?', '删除确认', {
type: 'warning',
});
await deleteSurgeryApply(row.id);
ElMessage.success('删除成功');
refreshList();
} catch (e) {
// 用户取消或接口错误均不做处理
}
};
const handleWithdraw = async (row) => {
try {
await ElMessageBox.confirm('撤回后将重新进入审批流程,是否继续?', '撤回确认', {
type: 'info',
});
await withdrawSurgeryApply(row.id);
ElMessage.success('撤回成功');
refreshList();
} catch (e) {
// 取消或错误
}
};
const handlePrint = (row) => {
// 这里调用后端打印接口或打开打印模板
window.open(`/api/inpatient/surgery/print/${row.id}`, '_blank');
};
// 状态文字与标签颜色映射
const statusText = (code) => {
const map = {
PENDING: '待审批',
APPROVED: '已批准',
REJECTED: '已驳回',
CANCELLED: '已作废',
};
return map[code] || code;
};
const statusTagType = (code) => {
const map = {
PENDING: 'warning',
APPROVED: 'success',
REJECTED: 'danger',
CANCELLED: 'info',
};
return map[code] || 'default';
};
const formatDate = (dateStr) => {
if (!dateStr) return '-';
const d = new Date(dateStr);
return d.toLocaleString();
};
</script>
<style scoped>
.surgery-apply-history {
padding: 20px;
}
.card-header {
font-size: 16px;
font-weight: 500;
}
</style>