fix(c1): 服务对象页评审修复
- 回退对脚手架文件(ty-crud/ty-dialog)的越界修改 - 列表页改用 ty-search-form + ty-table 组合,去掉对 ty-crud 的依赖 - 详情弹窗改用默认 footer + confirmText「关闭」,去掉自关逻辑 - 状态变更区块加 v-permission="elder:status-change" - 新增「下次服务」占位列(显示 —) - 目标状态下拉排除当前状态与不可逆终态(dead/terminated) - 失能等级去掉「(最高级)」后缀 - 建档/详情组件从 src/pages 迁至 src/components(对齐 change-password-form 约定,避免被 vue-router 注册为路由) - components.d.ts 由构建重新生成,不再手改 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
8975a7dd63
commit
49043881ba
8
components.d.ts
vendored
8
components.d.ts
vendored
@ -20,9 +20,12 @@ declare module 'vue' {
|
||||
ElCard: typeof import('element-plus/es')['ElCard']
|
||||
ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
|
||||
ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup']
|
||||
ElCol: typeof import('element-plus/es')['ElCol']
|
||||
ElColorPicker: typeof import('element-plus/es')['ElColorPicker']
|
||||
ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider']
|
||||
ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
|
||||
ElderDetail: typeof import('./src/components/elder-detail.vue')['default']
|
||||
ElderForm: typeof import('./src/components/elder-form.vue')['default']
|
||||
ElDescriptions: typeof import('element-plus/es')['ElDescriptions']
|
||||
ElDescriptionsItem: typeof import('element-plus/es')['ElDescriptionsItem']
|
||||
ElDialog: typeof import('element-plus/es')['ElDialog']
|
||||
@ -45,6 +48,7 @@ declare module 'vue' {
|
||||
ElRadioButton: typeof import('element-plus/es')['ElRadioButton']
|
||||
ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
|
||||
ElResult: typeof import('element-plus/es')['ElResult']
|
||||
ElRow: typeof import('element-plus/es')['ElRow']
|
||||
ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
|
||||
ElSelect: typeof import('element-plus/es')['ElSelect']
|
||||
ElSlider: typeof import('element-plus/es')['ElSlider']
|
||||
@ -93,9 +97,12 @@ declare global {
|
||||
const ElCard: typeof import('element-plus/es')['ElCard']
|
||||
const ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
|
||||
const ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup']
|
||||
const ElCol: typeof import('element-plus/es')['ElCol']
|
||||
const ElColorPicker: typeof import('element-plus/es')['ElColorPicker']
|
||||
const ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider']
|
||||
const ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
|
||||
const ElderDetail: typeof import('./src/components/elder-detail.vue')['default']
|
||||
const ElderForm: typeof import('./src/components/elder-form.vue')['default']
|
||||
const ElDescriptions: typeof import('element-plus/es')['ElDescriptions']
|
||||
const ElDescriptionsItem: typeof import('element-plus/es')['ElDescriptionsItem']
|
||||
const ElDialog: typeof import('element-plus/es')['ElDialog']
|
||||
@ -118,6 +125,7 @@ declare global {
|
||||
const ElRadioButton: typeof import('element-plus/es')['ElRadioButton']
|
||||
const ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
|
||||
const ElResult: typeof import('element-plus/es')['ElResult']
|
||||
const ElRow: typeof import('element-plus/es')['ElRow']
|
||||
const ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
|
||||
const ElSelect: typeof import('element-plus/es')['ElSelect']
|
||||
const ElSlider: typeof import('element-plus/es')['ElSlider']
|
||||
|
||||
@ -26,11 +26,12 @@
|
||||
<el-descriptions-item label="备注" :span="2">{{ elder.note ?? '-' }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<div v-permission="'elder:status-change'">
|
||||
<el-divider content-position="left">状态变更</el-divider>
|
||||
<el-form inline>
|
||||
<el-form-item label="目标状态">
|
||||
<el-select v-model="statusForm.toStatus" placeholder="请选择" style="width: 200px">
|
||||
<el-option v-for="o in TREAT_STATUS_OPTIONS" :key="o.value" :label="o.label" :value="o.value" />
|
||||
<el-option v-for="o in statusOptions" :key="o.value" :label="o.label" :value="o.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="变更原因">
|
||||
@ -40,6 +41,7 @@
|
||||
<el-button type="primary" :loading="changing" @click="submitStatusChange">变更</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<el-divider content-position="left">状态日志</el-divider>
|
||||
<el-timeline v-if="statusLog.length > 0">
|
||||
@ -50,18 +52,13 @@
|
||||
</el-timeline>
|
||||
<el-empty v-else description="暂无状态变更记录" :image-size="60" />
|
||||
</template>
|
||||
|
||||
<div class="mt-md flex justify-end">
|
||||
<el-button @click="close">关闭</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { changeElderStatus, getElder, getStatusLog, type Elder, type ElderStatusLog } from '@/api/elder'
|
||||
import { closeDialog } from '@/utils/dialog'
|
||||
import {
|
||||
ASSESS_LEVEL_OPTIONS,
|
||||
CARE_LEVEL_OPTIONS,
|
||||
@ -73,11 +70,11 @@ import {
|
||||
formatDate,
|
||||
formatDateTime,
|
||||
labelOf,
|
||||
} from '../constants'
|
||||
} from '@/pages/ltc/elder/constants'
|
||||
|
||||
defineOptions({ name: 'ElderDetail' })
|
||||
|
||||
const props = defineProps<{ elderId: string; dialogId?: number }>()
|
||||
const props = defineProps<{ elderId: string }>()
|
||||
|
||||
const elder = ref<Elder>()
|
||||
const statusLog = ref<ElderStatusLog[]>([])
|
||||
@ -86,6 +83,13 @@ const changing = ref(false)
|
||||
|
||||
const statusForm = reactive({ toStatus: '', changeReason: '' })
|
||||
|
||||
/** 目标状态下拉:排除当前状态 + 不可逆终态(dead/terminated)。 */
|
||||
const statusOptions = computed(() => {
|
||||
const exclude = new Set(['dead', 'terminated'])
|
||||
if (elder.value?.treatStatus) exclude.add(elder.value.treatStatus)
|
||||
return TREAT_STATUS_OPTIONS.filter((o) => !exclude.has(o.value))
|
||||
})
|
||||
|
||||
async function load(): Promise<void> {
|
||||
loading.value = true
|
||||
try {
|
||||
@ -118,9 +122,5 @@ async function submitStatusChange(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
function close(): void {
|
||||
if (props.dialogId != null) closeDialog(props.dialogId)
|
||||
}
|
||||
|
||||
onMounted(load)
|
||||
</script>
|
||||
@ -132,7 +132,7 @@ import {
|
||||
GENDER_OPTIONS,
|
||||
INSURE_TYPE_OPTIONS,
|
||||
INSURE_VERIFY_STATUS_OPTIONS,
|
||||
} from '../constants'
|
||||
} from '@/pages/ltc/elder/constants'
|
||||
|
||||
defineOptions({ name: 'ElderForm' })
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
<el-card class="ty-crud__table" shadow="never">
|
||||
<div class="ty-crud__toolbar">
|
||||
<div class="ty-crud__toolbar-left">
|
||||
<el-button v-if="showCreate && (!createPermission || permissionStore.has(createPermission))" type="primary" @click="openCreate">
|
||||
<el-button v-if="!createPermission || permissionStore.has(createPermission)" type="primary" @click="openCreate">
|
||||
新增{{ entityName }}
|
||||
</el-button>
|
||||
<slot name="toolbar" />
|
||||
@ -122,8 +122,6 @@ const props = withDefaults(
|
||||
selection?: boolean
|
||||
/** 新增按钮所需权限码(无该权限且非超管时隐藏新增按钮)。 */
|
||||
createPermission?: string
|
||||
/** 是否显示内置「新增」按钮(false 时可改用 #toolbar 插槽自定义建档入口)。 */
|
||||
showCreate?: boolean
|
||||
actionsWidth?: number | string
|
||||
}>(),
|
||||
{
|
||||
@ -134,7 +132,6 @@ const props = withDefaults(
|
||||
actions: () => ['edit', 'delete'],
|
||||
collapseCount: 2,
|
||||
selection: false,
|
||||
showCreate: true,
|
||||
actionsWidth: 140,
|
||||
},
|
||||
)
|
||||
|
||||
@ -12,7 +12,6 @@
|
||||
<component
|
||||
:is="dialog.options.component"
|
||||
v-bind="dialog.options.props ?? {}"
|
||||
:dialog-id="dialog.id"
|
||||
:ref="setRef(dialog.id)"
|
||||
/>
|
||||
<template v-if="dialog.options.showFooter !== false" #footer>
|
||||
|
||||
@ -21,7 +21,7 @@ export const INSURE_VERIFY_STATUS_OPTIONS: LabeledValue[] = [
|
||||
]
|
||||
|
||||
export const ASSESS_LEVEL_OPTIONS: LabeledValue[] = [
|
||||
{ label: '重度一级(最高级)', value: 'sev_1' },
|
||||
{ label: '重度一级', value: 'sev_1' },
|
||||
{ label: '重度二级', value: 'sev_2' },
|
||||
{ label: '重度三级', value: 'sev_3' },
|
||||
]
|
||||
|
||||
@ -1,34 +1,40 @@
|
||||
<template>
|
||||
<ty-crud
|
||||
ref="crudRef"
|
||||
entity-name="服务对象"
|
||||
:columns="columns"
|
||||
:search-schema="searchSchema"
|
||||
:form-schema="formSchema"
|
||||
:list="list"
|
||||
:create="create"
|
||||
:update="update"
|
||||
:remove="remove"
|
||||
:actions="actions"
|
||||
:show-create="false"
|
||||
id-key="id"
|
||||
name-key="name"
|
||||
>
|
||||
<template #toolbar>
|
||||
<div class="elder-page">
|
||||
<el-card class="mb-md" shadow="never">
|
||||
<ty-search-form :schema="searchSchema" :model-value="query" @search="handleSearch" @reset="handleReset" />
|
||||
</el-card>
|
||||
|
||||
<el-card class="elder-page__table" shadow="never">
|
||||
<div class="mb-md flex items-center">
|
||||
<el-button v-permission="'elder:create'" type="primary" @click="openCreate">建档</el-button>
|
||||
</div>
|
||||
<ty-table
|
||||
:columns="columns"
|
||||
:data="list"
|
||||
:loading="loading"
|
||||
:total="total"
|
||||
v-model:page="page"
|
||||
v-model:page-size="pageSize"
|
||||
:actions-width="120"
|
||||
>
|
||||
<template #actions="{ row }">
|
||||
<el-button link type="primary" @click="openDetail(row)">查看</el-button>
|
||||
</template>
|
||||
</ty-crud>
|
||||
</ty-table>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { onMounted, reactive, ref, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import type { CrudAction, JsonSchema, PageQuery, TableColumn } from '@/types/crud'
|
||||
import type { JsonSchema, TableColumn } from '@/types/crud'
|
||||
import { showDialog } from '@/utils/dialog'
|
||||
import { useRequest } from '@/composables/useRequest'
|
||||
import { createElder, listElders, type ElderCreateData, type ElderListQuery } from '@/api/elder'
|
||||
import { CARE_LEVEL_OPTIONS, GENDER_OPTIONS, TREAT_STATUS_OPTIONS, TREAT_STATUS_TAG_MAP, formatDate, labelOf } from './constants'
|
||||
import ElderForm from './components/elder-form.vue'
|
||||
import ElderDetail from './components/elder-detail.vue'
|
||||
import ElderForm from '@/components/elder-form.vue'
|
||||
import ElderDetail from '@/components/elder-detail.vue'
|
||||
|
||||
defineOptions({ name: 'elder' })
|
||||
|
||||
@ -38,6 +44,8 @@ const columns: TableColumn[] = [
|
||||
{ prop: 'careLevel', label: '护理等级', minWidth: 150, formatter: (v) => labelOf(CARE_LEVEL_OPTIONS, v) },
|
||||
{ prop: 'treatStatus', label: '待遇状态', width: 120, align: 'center', type: 'tag', tagMap: TREAT_STATUS_TAG_MAP },
|
||||
{ prop: 'birthDate', label: '出生日期', width: 120, formatter: (v) => formatDate(v) },
|
||||
// 下次服务为占位列,本期无数据,统一显示「—」
|
||||
{ prop: 'nextService', label: '下次服务', width: 120, formatter: () => '—' },
|
||||
]
|
||||
|
||||
const searchSchema: JsonSchema = {
|
||||
@ -54,27 +62,37 @@ const searchSchema: JsonSchema = {
|
||||
},
|
||||
}
|
||||
|
||||
// ty-crud 要求 formSchema,但建档走自定义表单(含日期/上传),此处仅为满足组件契约,不会被使用。
|
||||
const formSchema: JsonSchema = { type: 'object', properties: {} }
|
||||
const query = reactive<Record<string, any>>({ name: '', treatStatus: '' })
|
||||
const list = ref<Record<string, any>[]>([])
|
||||
const total = ref(0)
|
||||
const page = ref(1)
|
||||
const pageSize = ref(10)
|
||||
|
||||
function toListQuery(query: PageQuery): ElderListQuery {
|
||||
const str = (v: unknown): string | undefined => (typeof v === 'string' && v !== '' ? v : undefined)
|
||||
return { page: query.page, pageSize: query.pageSize, name: str(query.name), treatStatus: str(query.treatStatus) }
|
||||
const str = (v: unknown): string | undefined => (typeof v === 'string' && v !== '' ? v : undefined)
|
||||
|
||||
function toListQuery(): ElderListQuery {
|
||||
return { page: page.value, pageSize: pageSize.value, name: str(query.name), treatStatus: str(query.treatStatus) }
|
||||
}
|
||||
|
||||
const list = async (query: PageQuery, signal?: AbortSignal) => {
|
||||
const result = await listElders(toListQuery(query), signal)
|
||||
return { ...result, list: result.list.map((e) => ({ ...e })) }
|
||||
const { loading, run: fetchList } = useRequest((signal: AbortSignal) => listElders(toListQuery(), signal), {
|
||||
manual: true,
|
||||
onSuccess: (result) => {
|
||||
list.value = result.list.map((e) => ({ ...e }))
|
||||
total.value = result.total
|
||||
},
|
||||
})
|
||||
|
||||
watch([page, pageSize], () => fetchList())
|
||||
|
||||
function handleSearch(): void {
|
||||
if (page.value === 1) fetchList()
|
||||
else page.value = 1
|
||||
}
|
||||
|
||||
// 建档/编辑/删除均不走 ty-crud 内置流程(建档走工具栏「建档」自定义表单),此处仅为满足组件契约,不会被调用。
|
||||
const create = () => Promise.reject(new Error('建档请使用工具栏「建档」按钮'))
|
||||
const update = () => Promise.reject(new Error('服务对象不支持编辑'))
|
||||
const remove = () => Promise.reject(new Error('服务对象不支持删除'))
|
||||
|
||||
const actions: CrudAction[] = [{ label: '查看', type: 'primary', permission: 'elder:detail', onClick: (row) => openDetail(row) }]
|
||||
|
||||
const crudRef = ref()
|
||||
function handleReset(): void {
|
||||
if (page.value === 1) fetchList()
|
||||
else page.value = 1
|
||||
}
|
||||
|
||||
async function openCreate(): Promise<void> {
|
||||
const data = await showDialog({
|
||||
@ -85,7 +103,7 @@ async function openCreate(): Promise<void> {
|
||||
if (data == null) return
|
||||
await createElder(data as ElderCreateData)
|
||||
ElMessage.success('建档成功')
|
||||
crudRef.value?.reload()
|
||||
fetchList()
|
||||
}
|
||||
|
||||
async function openDetail(row: Record<string, any>): Promise<void> {
|
||||
@ -94,7 +112,23 @@ async function openDetail(row: Record<string, any>): Promise<void> {
|
||||
props: { elderId: String(row.id) },
|
||||
title: `服务对象详情(${row.name})`,
|
||||
width: '840px',
|
||||
showFooter: false,
|
||||
confirmText: '关闭',
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => fetchList())
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.elder-page {
|
||||
@apply flex h-full flex-col;
|
||||
}
|
||||
|
||||
.elder-page__table {
|
||||
@apply flex min-h-0 flex-1 flex-col;
|
||||
|
||||
:deep(.el-card__body) {
|
||||
@apply flex min-h-0 flex-1 flex-col;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user