<template>
|
<ContentWrap>
|
<!-- 搜索工作栏 -->
|
<el-form
|
class="-mb-15px"
|
:model="queryParams"
|
ref="queryFormRef"
|
:inline="true"
|
label-width="68px"
|
>
|
<el-form-item label="诊室编号" prop="roomId">
|
<el-input
|
v-model="queryParams.roomId"
|
placeholder="请输入诊室编号"
|
clearable
|
@keyup.enter="handleQuery"
|
class="!w-240px"
|
/>
|
</el-form-item>
|
<el-form-item label="诊室工位" prop="bedNo">
|
<el-input
|
v-model="queryParams.bedNo"
|
placeholder="请输入诊室工位编号"
|
clearable
|
@keyup.enter="handleQuery"
|
class="!w-240px"
|
/>
|
</el-form-item>
|
<el-form-item label="创建时间" prop="createTime">
|
<el-date-picker
|
v-model="queryParams.createTime"
|
value-format="YYYY-MM-DD HH:mm:ss"
|
type="daterange"
|
start-placeholder="开始日期"
|
end-placeholder="结束日期"
|
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
|
class="!w-220px"
|
/>
|
</el-form-item>
|
<el-form-item>
|
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
<el-button
|
type="primary"
|
plain
|
@click="openForm('create')"
|
v-hasPermi="['ecg:room:create']"
|
>
|
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
</el-button>
|
<el-button
|
type="success"
|
plain
|
@click="handleExport"
|
:loading="exportLoading"
|
v-hasPermi="['ecg:room:export']"
|
>
|
<Icon icon="ep:download" class="mr-5px" /> 导出
|
</el-button>
|
</el-form-item>
|
</el-form>
|
</ContentWrap>
|
|
<!-- 列表 -->
|
<ContentWrap>
|
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
<el-table-column label="诊室编号" align="center" prop="roomId" />
|
<el-table-column label="诊室名称" align="center" prop="roomName" />
|
<el-table-column label="诊室工位" align="center" prop="bedNo" />
|
<el-table-column label="工位绑定IP" align="center" prop="ip" />
|
<el-table-column label="操作类型" align="center" prop="opType">
|
<template #default="scope">
|
{{ opTypeText(scope.row.opType) }}
|
</template>
|
</el-table-column>
|
<el-table-column label="检查项目" align="center" prop="checkTypes" width="180px">
|
<template #default="scope">
|
<div v-for="(checkType, subIndex) in scope.row.checkTypes" :key="subIndex">
|
{{getCheckTypeName(checkType)}}
|
</div>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="创建时间"
|
align="center"
|
prop="createTime"
|
:formatter="dateFormatter2"
|
/>
|
<el-table-column label="操作" align="center" min-width="120px">
|
<template #default="scope">
|
<el-button
|
link
|
type="primary"
|
@click="openForm('update', scope.row.id)"
|
v-hasPermi="['ecg:room:update']"
|
>
|
编辑
|
</el-button>
|
<el-button
|
link
|
type="danger"
|
@click="handleDelete(scope.row.id)"
|
v-hasPermi="['ecg:room:delete']"
|
>
|
删除
|
</el-button>
|
<!--
|
【本次需求】管理员强制清空工位:医生下班忘离座 / 换人使用同一工位时用。
|
|
· 权限:`v-hasPermi` 是"任一命中即显示",这里同时接受 `clinic:room:update`(后端接口要求的)
|
与 `ecg:room:update`(本页其它按钮用的那套),避免角色只配了其中一套时按钮被隐藏。
|
后端仍严格校验 `clinic:room:update`。
|
· 只有"已被占用"(docId 有值)的工位才可点;空闲工位置灰并提示,避免点了才报"状态不允许"。
|
-->
|
<el-tooltip
|
:disabled="!!scope.row.docId"
|
content="该工位当前空闲,无需清空"
|
placement="top"
|
>
|
<span style="margin-left: 12px">
|
<el-button
|
link
|
type="warning"
|
:disabled="!scope.row.docId"
|
@click="handleForceClearBed(scope.row)"
|
v-hasPermi="['clinic:room:update', 'ecg:room:update']"
|
>
|
清空工位
|
</el-button>
|
</span>
|
</el-tooltip>
|
</template>
|
</el-table-column>
|
</el-table>
|
<!-- 分页 -->
|
<Pagination
|
:total="total"
|
v-model:page="queryParams.pageNo"
|
v-model:limit="queryParams.pageSize"
|
@pagination="getList"
|
/>
|
</ContentWrap>
|
|
<!-- 表单弹窗:添加/修改 -->
|
<RoomForm ref="formRef" @success="getList" />
|
</template>
|
|
<script setup lang="ts">
|
import {dateFormatter2} from '@/utils/formatTime'
|
import download from '@/utils/download'
|
import { RoomApi, RoomVO } from '@/api/ecg/room'
|
import RoomForm from './RoomForm.vue'
|
import {useCheckTypeStore} from "@/store/modules/checkType";
|
import {getCheckTypeName} from "../../../utils/checkTypeFormatter";
|
|
/** 诊室和诊疗床 列表 */
|
defineOptions({ name: 'Room' })
|
|
const message = useMessage() // 消息弹窗
|
const { t } = useI18n() // 国际化
|
|
const checkTypeStore = useCheckTypeStore();
|
|
const loading = ref(true) // 列表的加载中
|
const list = ref<RoomVO[]>([]) // 列表的数据
|
const total = ref(0) // 列表的总页数
|
const queryParams = reactive({
|
pageNo: 1,
|
pageSize: 10,
|
roomId: undefined,
|
bedNo: undefined,
|
createTime: []
|
})
|
const queryFormRef = ref() // 搜索的表单
|
const exportLoading = ref(false) // 导出的加载中
|
|
/**
|
* 操作类型中文(本需求:列表不再显示数字)。
|
*
|
* 取值与后端 `BedOpTypeEnum`、以及本模块 RoomForm 的「作业类型」单选项保持一致:
|
* 0=检查 1=领用 2=装机
|
* 历史脏数据(null / 其它值)显示 '-',不猜。
|
*/
|
const opTypeText = (opType?: number | null) => {
|
if (opType === 0) return '检查'
|
if (opType === 1) return '领用'
|
if (opType === 2) return '装机'
|
if (opType === 3) return '分诊'
|
return '-'
|
}
|
|
/** 查询列表 */
|
const getList = async () => {
|
loading.value = true
|
try {
|
const data = await RoomApi.getRoomPage(queryParams)
|
list.value = data.list
|
total.value = data.total
|
} finally {
|
loading.value = false
|
}
|
}
|
|
/** 搜索按钮操作 */
|
const handleQuery = () => {
|
queryParams.pageNo = 1
|
getList()
|
}
|
|
/** 重置按钮操作 */
|
const resetQuery = () => {
|
queryFormRef.value.resetFields()
|
handleQuery()
|
}
|
|
/** 添加/修改操作 */
|
const formRef = ref()
|
const openForm = (type: string, id?: number) => {
|
formRef.value.open(type, id)
|
}
|
|
/** 删除按钮操作 */
|
const handleDelete = async (id: number) => {
|
try {
|
// 删除的二次确认
|
await message.delConfirm()
|
// 发起删除
|
await RoomApi.deleteRoom(id)
|
message.success(t('common.delSuccess'))
|
// 刷新列表
|
await getList()
|
} catch {}
|
}
|
|
/**
|
* 【本次需求】管理员强制清空工位。
|
*
|
* 用途:医生下班忘记「离座」→ 工位一直被占用,别的医生坐不上;
|
* 或换人使用同一工位时需要把上一位清掉。
|
*
|
* 服务端只在该工位处于「医生在岗 / 暂停」且已被占用时才允许清空,
|
* 空闲工位会返回「当前工位状态不允许该操作」——这是预期行为,无需特殊处理。
|
*/
|
const handleForceClearBed = async (row: RoomVO) => {
|
const who = row.docName ? `「${row.docName}」` : '当前医生'
|
try {
|
await message.confirm(
|
`确认清空工位「${row.roomName ?? ''} · ${row.bedNo ?? ''}」吗?\n` +
|
`该工位当前由${who}占用,清空后对方将变成"仅围观",需要重新入座才能操作。`
|
)
|
await RoomApi.forceClearBed({ roomId: row.roomId, bedNo: row.bedNo })
|
message.success('已清空该工位')
|
await getList()
|
} catch {}
|
}
|
|
/** 导出按钮操作 */const handleExport = async () => {
|
try {
|
// 导出的二次确认
|
await message.exportConfirm()
|
// 发起导出
|
exportLoading.value = true
|
const data = await RoomApi.exportRoom(queryParams)
|
download.excel(data, '诊室和诊疗床.xls')
|
} catch {
|
} finally {
|
exportLoading.value = false
|
}
|
}
|
|
/** 初始化 **/
|
onMounted(() => {
|
getList()
|
})
|
</script>
|