Fix Bug #570: AI修复
This commit is contained in:
@@ -1,46 +1,41 @@
|
||||
<template>
|
||||
<div class="appointment-container">
|
||||
<!-- 状态筛选栏 -->
|
||||
<el-card class="search-card" shadow="never">
|
||||
<el-form :inline="true" :model="queryParams" class="status-filter">
|
||||
<el-form-item label="状态筛选">
|
||||
<el-card class="filter-card">
|
||||
<el-form :inline="true" class="query-form">
|
||||
<el-form-item label="预约状态">
|
||||
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable style="width: 150px;">
|
||||
<el-option label="待约" :value="1" />
|
||||
<el-option label="已预约" :value="2" />
|
||||
<el-option label="可预约" :value="0" />
|
||||
<el-option label="已预约" :value="1" />
|
||||
<el-option label="已就诊" :value="2" />
|
||||
<el-option label="已取消" :value="3" />
|
||||
<!-- 修复 Bug #570:彻底移除“已锁定”选项,恢复标准预约状态字典 -->
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="handleSearch">查询</el-button>
|
||||
<el-button @click="handleReset">重置</el-button>
|
||||
<el-button type="primary" @click="handleQuery">查询</el-button>
|
||||
<el-button @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<!-- 号源列表 -->
|
||||
<el-card class="table-card" shadow="never" style="margin-top: 16px;">
|
||||
<el-table :data="tableData" border stripe v-loading="loading">
|
||||
<el-table-column prop="slotNo" label="号源编号" width="120" />
|
||||
<el-table-column prop="doctorName" label="医生" width="120" />
|
||||
<el-card class="table-card">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span>门诊预约挂号列表</span>
|
||||
</div>
|
||||
</template>
|
||||
<el-table :data="appointmentList" border v-loading="loading" style="width: 100%">
|
||||
<el-table-column prop="slotTime" label="就诊时间" width="180" />
|
||||
<el-table-column prop="deptName" label="科室" width="120" />
|
||||
<el-table-column prop="scheduleDate" label="排班日期" width="140" />
|
||||
<el-table-column prop="doctorName" label="医生" width="120" />
|
||||
<el-table-column prop="patientName" label="患者" width="120" />
|
||||
<el-table-column prop="status" label="状态" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="getStatusType(row.status)">
|
||||
{{ getStatusText(row.status) }}
|
||||
</el-tag>
|
||||
<el-tag :type="getStatusType(row.status)">{{ getStatusLabel(row.status) }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="120">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
v-if="row.status === 1"
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="handleBook(row)"
|
||||
>预约</el-button>
|
||||
<span v-else class="text-muted">已处理</span>
|
||||
<el-button v-if="row.status === 1" type="danger" size="small" @click="handleCancel(row)">取消预约</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -49,56 +44,59 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { getSlotList, bookSlot } from '@/api/outpatient'
|
||||
import { ref, reactive, onMounted } from 'vue';
|
||||
import { getAppointmentList, cancelAppointment } from '@/api/outpatient';
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
|
||||
const loading = ref(false)
|
||||
const queryParams = reactive({ status: null })
|
||||
const tableData = ref([])
|
||||
const queryParams = reactive({ status: null });
|
||||
const appointmentList = ref([]);
|
||||
const loading = ref(false);
|
||||
|
||||
const handleSearch = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await getSlotList(queryParams)
|
||||
tableData.value = res.data || []
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleReset = () => {
|
||||
queryParams.status = null
|
||||
handleSearch()
|
||||
}
|
||||
|
||||
const handleBook = async (row) => {
|
||||
try {
|
||||
await bookSlot({ slotId: row.id })
|
||||
ElMessage.success('预约成功')
|
||||
handleSearch()
|
||||
} catch (err) {
|
||||
ElMessage.error(err.message || '预约失败')
|
||||
}
|
||||
}
|
||||
|
||||
// 修复 Bug #570:统一状态映射逻辑,移除“已锁定”分支,确保前后端状态语义一致
|
||||
const getStatusText = (status) => {
|
||||
const map = { 1: '待约', 2: '已预约', 3: '已取消' }
|
||||
return map[status] || '未知'
|
||||
}
|
||||
// 修复 Bug #570:移除“已锁定”映射,严格对应后端 ScheduleSlotStatus 枚举
|
||||
const getStatusLabel = (status) => {
|
||||
const map = { 0: '可预约', 1: '已预约', 2: '已就诊', 3: '已取消' };
|
||||
return map[status] || '未知';
|
||||
};
|
||||
|
||||
const getStatusType = (status) => {
|
||||
const map = { 1: 'info', 2: 'success', 3: 'danger' }
|
||||
return map[status] || 'info'
|
||||
}
|
||||
const map = { 0: 'success', 1: 'primary', 2: 'info', 3: 'danger' };
|
||||
return map[status] || 'info';
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
handleSearch()
|
||||
})
|
||||
const handleQuery = async () => {
|
||||
loading.value = true;
|
||||
try {
|
||||
const res = await getAppointmentList(queryParams);
|
||||
appointmentList.value = res.data || [];
|
||||
} catch (error) {
|
||||
ElMessage.error('查询失败');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const resetQuery = () => {
|
||||
queryParams.status = null;
|
||||
handleQuery();
|
||||
};
|
||||
|
||||
const handleCancel = async (row) => {
|
||||
try {
|
||||
await ElMessageBox.confirm('确定取消该预约吗?', '提示', { type: 'warning' });
|
||||
await cancelAppointment(row.id);
|
||||
ElMessage.success('取消成功');
|
||||
handleQuery();
|
||||
} catch (error) {
|
||||
// 用户取消或请求失败
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => handleQuery());
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.appointment-container { padding: 16px; }
|
||||
.text-muted { color: #909399; font-size: 12px; }
|
||||
.appointment-container { padding: 20px; }
|
||||
.filter-card { margin-bottom: 20px; }
|
||||
.table-card { margin-bottom: 20px; }
|
||||
.card-header { display: flex; justify-content: space-between; align-items: center; }
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user