| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293 |
- <template>
- <!-- 搜索 -->
- <ContentWrap>
- <el-form
- class="-mb-15px"
- :model="queryParams"
- ref="queryFormRef"
- :inline="true"
- label-width="80px"
- >
- <TenantSelect v-model="queryParams.tenantIds" placeholder="请选择机构名称" prop="tenantIds" />
- <el-form-item label="长者姓名" prop="elderName">
- <el-input
- @keyup.enter="handleQuery"
- v-model="queryParams.elderName"
- placeholder="请输入长者姓名"
- class="!w-240px"
- clearable
- />
- </el-form-item>
- <el-form-item label="出院日期" prop="dischargeDate">
- <el-date-picker
- style="width: 240px"
- v-model="queryParams.dischargeDate"
- type="daterange"
- :clearable="true"
- placeholder="选择出院日期范围"
- value-format="YYYY-MM-DD"
- format="YYYY-MM-DD"
- date-format="YYYY-MM-DD"
- />
- </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-form-item>
- </el-form>
- </ContentWrap>
- <!-- 列表 -->
- <ContentWrap>
- <TabBarBtn @add="openForm()" />
- <Table2
- v-loading="loading"
- :data="list"
- :columns="DischargeSummaryColumns"
- :queryParams="queryParams"
- :op-width="280"
- :show-edit-condition="() => false"
- :show-delete-condition="() => false"
- :show-detail-condition="() => false"
- @del="handleDelete"
- >
- <template #next="{ scope }">
- <el-button link type="primary" @click="openForm(scope)">编辑</el-button>
- <el-button link type="primary" @click="openDetail(scope)">详情</el-button>
- <el-button link type="danger" @click="handleDelete(scope.id)">删除</el-button>
- <el-button link type="primary" @click="openPrint(scope)">打印</el-button>
- <el-button link type="warning" @click="openCheckOut(scope)">退住申请</el-button>
- </template>
- </Table2>
- <!-- 分页 -->
- <Pagination
- :total="total"
- v-model:page="queryParams.pageNo"
- v-model:limit="queryParams.pageSize"
- @pagination="getList"
- />
- </ContentWrap>
- <!-- 新增 / 编辑弹窗 -->
- <Form ref="formRef" @success="getList" />
- <!-- 打印预览 -->
- <Print ref="printRef" />
- <!-- 退住申请弹窗(从出院小结带入长者 id,无需权限) -->
- <CheckOutForm ref="checkOutRef" @success="getList" />
- </template>
- <script lang="ts" setup>
- import {
- getDischargeSummaryPage,
- deleteDischargeSummary,
- getDischargeReasonText,
- DISCHARGE_REASON
- } from '@/api/elderly/elder/discharge-summary'
- import { DischargeSummaryColumns } from './columns'
- import Form from './Form.vue'
- import Print from './Print.vue'
- import CheckOutForm from '@/views/elderly/bak/check-out/Form.vue'
- import { useUserStore } from '@/store/modules/user'
- defineOptions({ name: 'DischargeSummary' })
- const userStore = useUserStore()
- const message = useMessage()
- const { t } = useI18n()
- const loading = ref(true)
- const total = ref(0)
- const list = ref<any[]>([])
- const queryParams = reactive({
- pageNo: 1,
- pageSize: 10,
- elderName: undefined as string | undefined,
- dischargeDate: [] as string[] | undefined,
- tenantIds: userStore.orgTenantId as any
- })
- const queryFormRef = ref()
- /** 测试假数据:列表请求失败时填充,方便前端联调 */
- const buildMockDischargeSummary = () => {
- const base = [
- {
- id: 3001,
- elderId: 801,
- elderName: '张建国',
- gender: 1,
- bedName: '1号楼-3区-301-01',
- elderAge: 78,
- checkInDate: '2024-03-15',
- dischargeDate: '2026-08-20',
- dischargeReason: DISCHARGE_REASON.HOME_CARE,
- doctorSign: '李医生',
- createTime: '2026-08-20 10:30:00'
- },
- {
- id: 3002,
- elderId: 802,
- elderName: '刘秀英',
- gender: 2,
- bedName: '2号楼-2区-205-03',
- elderAge: 82,
- checkInDate: '2023-11-02',
- dischargeDate: '2026-08-25',
- dischargeReason: DISCHARGE_REASON.HOSPITAL,
- doctorSign: '陈医生',
- createTime: '2026-08-25 15:10:00'
- },
- {
- id: 3003,
- elderId: 803,
- elderName: '王德海',
- gender: 1,
- bedName: '1号楼-4区-402-02',
- elderAge: 75,
- checkInDate: '2025-01-08',
- dischargeDate: '2026-09-01',
- dischargeReason: DISCHARGE_REASON.OTHER,
- dischargeReasonOther: '家属迁居外地',
- doctorSign: '周医生',
- createTime: '2026-09-01 09:00:00'
- }
- ]
- return base.map((item: any) => ({ ...item, tenantId: queryParams.tenantIds }))
- }
- /**
- * 查询列表
- * 说明:出院原因 / 年龄 的展示文本在此统一映射,
- * 因为它们是模块自定义枚举,Table2 的 dictArr 字典翻译用不上。
- */
- const getList = async () => {
- loading.value = true
- try {
- const params: Recordable = {
- pageNo: queryParams.pageNo,
- pageSize: queryParams.pageSize,
- elderName: queryParams.elderName || undefined,
- tenantIds: queryParams.tenantIds
- }
- // 出院日期范围
- if (Array.isArray(queryParams.dischargeDate) && queryParams.dischargeDate.length === 2) {
- params.dischargeDate = [...queryParams.dischargeDate]
- }
- // 返回的 list 已由 API 层转换并预计算 dischargeReasonText / elderAgeText
- const data = await getDischargeSummaryPage(params)
- list.value = data.list || []
- total.value = data.total || 0
- } catch (e) {
- // 列表请求失败时填充测试假数据,便于前端联调(控制台有提示,不影响页面渲染)
- console.warn('[出院小结] 列表请求失败,已使用测试假数据。', e)
- list.value = buildMockDischargeSummary().map((item: any) => ({
- ...item,
- dischargeReasonText: getDischargeReasonText(item.dischargeReason),
- elderAgeText: `${item.elderAge} 岁`
- }))
- total.value = list.value.length
- } finally {
- loading.value = false
- }
- }
- /** 搜索 */
- const handleQuery = async () => {
- await queryFormRef.value?.validate().catch(() => {})
- queryParams.pageNo = 1
- getList()
- }
- /** 重置 */
- const resetQuery = () => {
- queryFormRef.value?.resetFields()
- queryParams.dischargeDate = []
- handleQuery()
- }
- /** 新增 / 编辑 */
- const formRef = ref()
- const printRef = ref()
- const checkOutRef = ref()
- const openForm = (row: any = {}) => {
- if (
- !queryParams.tenantIds ||
- (Array.isArray(queryParams.tenantIds) && queryParams.tenantIds.length === 0) ||
- (Array.isArray(queryParams.tenantIds) && queryParams.tenantIds.length > 1 && !row.tenantId)
- ) {
- message.error('新增只能选择一个机构')
- return
- }
- formRef.value.open(row)
- }
- /** 打开详情(只读) */
- const openDetail = (row: any = {}) => {
- formRef.value.open(row, true)
- }
- /** 打印 */
- const openPrint = (row: any = {}) => {
- printRef.value.open(row)
- }
- /** 退住申请:复用退住申请页面新增功能,带入当前长者 id 并预选该长者(无需权限) */
- const openCheckOut = (row: any = {}) => {
- // 解析租户 id:优先用行内 tenantId,否则取当前查询选中的机构(只能单选)
- let tId = row.tenantId
- if (!tId) {
- const qt = queryParams.tenantIds
- if (Array.isArray(qt)) {
- tId = qt.length === 1 ? qt[0] : undefined
- } else {
- tId = qt
- }
- }
- if (!tId) {
- message.error('请先选择一个机构')
- return
- }
- // elderId 带入当前长者,open 内部会调用 setElderById 默认选中该长者
- // dischargeDate 带入退住日期,预填退住申请表单里的「退住日期」
- // reason 带入出院原因作为退住原因;出院原因=其他时,退住描述取「其他」输入值
- const reason = row.dischargeReason
- const description =
- Number(reason) === DISCHARGE_REASON.OTHER ? row.dischargeReasonOther || '' : ''
- checkOutRef.value.open(
- tId,
- undefined,
- false,
- undefined,
- row.elderId,
- row.dischargeDate,
- reason,
- description
- )
- }
- /** 删除 */
- const handleDelete = async (id: number) => {
- try {
- await message.confirm('确定删除该出院小结吗?删除后不可恢复。', '提示')
- await deleteDischargeSummary(id)
- message.success(t('common.delSuccess'))
- await getList()
- } catch {}
- }
- /** 路由携带 elderName 时自动带入 */
- const route = useRoute()
- onMounted(() => {
- if (route.query && route.query.elderName) {
- queryParams.elderName = route.query.elderName as string
- }
- getList()
- })
- </script>
|