From 301b66d30ea3811a0abe07c5bcd5c5f102fd1223 Mon Sep 17 00:00:00 2001 From: xingyu Date: Sat, 12 Nov 2022 23:33:29 +0800 Subject: [PATCH] refactor: notice --- .../src/hooks/web/useVxeCrudSchemas.ts | 28 +- .../src/views/system/notice/index.vue | 244 ++++++++---------- .../src/views/system/notice/notice.data.ts | 107 +++----- .../src/views/system/post/index.vue | 12 +- 4 files changed, 175 insertions(+), 216 deletions(-) diff --git a/yudao-ui-admin-vue3/src/hooks/web/useVxeCrudSchemas.ts b/yudao-ui-admin-vue3/src/hooks/web/useVxeCrudSchemas.ts index 677dc10f6..96bfad64e 100644 --- a/yudao-ui-admin-vue3/src/hooks/web/useVxeCrudSchemas.ts +++ b/yudao-ui-admin-vue3/src/hooks/web/useVxeCrudSchemas.ts @@ -27,18 +27,38 @@ type VxeCrudColumns = Omit & { title?: string formatter?: VxeColumnPropTypes.Formatter isSearch?: boolean - search?: VxeFormItemProps + search?: CrudSearchParams isTable?: boolean - table?: VxeTableDefines.ColumnOptions + table?: CrudTableParams isForm?: boolean - form?: FormSchema + form?: CrudFormParams isDetail?: boolean - detail?: DescriptionsSchema + detail?: CrudDescriptionsParams print?: CrudPrintParams children?: VxeCrudColumns[] dictType?: string } +type CrudSearchParams = { + // 是否显示在查询项 + show?: boolean +} & Omit + +type CrudTableParams = { + // 是否显示表头 + show?: boolean +} & Omit + +type CrudFormParams = { + // 是否显示表单项 + show?: boolean +} & Omit + +type CrudDescriptionsParams = { + // 是否显示表单项 + show?: boolean +} & Omit + type CrudPrintParams = { // 是否显示表单项 show?: boolean diff --git a/yudao-ui-admin-vue3/src/views/system/notice/index.vue b/yudao-ui-admin-vue3/src/views/system/notice/index.vue index 738a3f060..0d10503f7 100644 --- a/yudao-ui-admin-vue3/src/views/system/notice/index.vue +++ b/yudao-ui-admin-vue3/src/views/system/notice/index.vue @@ -1,28 +1,91 @@ + - - diff --git a/yudao-ui-admin-vue3/src/views/system/notice/notice.data.ts b/yudao-ui-admin-vue3/src/views/system/notice/notice.data.ts index bdf2f3ecb..1b72e746a 100644 --- a/yudao-ui-admin-vue3/src/views/system/notice/notice.data.ts +++ b/yudao-ui-admin-vue3/src/views/system/notice/notice.data.ts @@ -2,7 +2,7 @@ import { reactive } from 'vue' import { useI18n } from '@/hooks/web/useI18n' import { required } from '@/utils/formRules' import { DICT_TYPE } from '@/utils/dict' -import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas' +import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas' const { t } = useI18n() // 国际化 // 表单校验 @@ -12,74 +12,47 @@ export const rules = reactive({ }) // CrudSchema -const crudSchemas = reactive([ - { - label: t('common.index'), - field: 'id', - type: 'index', - form: { - show: false +const crudSchemas = reactive({ + primaryKey: 'id', + primaryType: 'seq', + action: true, + columns: [ + { + title: '公告标题', + field: 'title', + isSearch: true }, - detail: { - show: false - } - }, - { - label: '公告标题', - field: 'title', - search: { - show: true - } - }, - { - label: '公告类型', - field: 'type', - dictType: DICT_TYPE.SYSTEM_NOTICE_TYPE, - search: { - show: true - } - }, - { - label: t('common.status'), - field: 'status', - dictType: DICT_TYPE.COMMON_STATUS, - search: { - show: true + { + title: '公告类型', + field: 'type', + dictType: DICT_TYPE.SYSTEM_NOTICE_TYPE, + isSearch: true }, - form: { - component: 'RadioButton' - } - }, - { - label: '公告内容', - field: 'content', - form: { - component: 'Editor', - colProps: { - span: 24 - }, - componentProps: { - valueHtml: '' + { + title: t('common.status'), + field: 'status', + dictType: DICT_TYPE.COMMON_STATUS, + isSearch: true + }, + { + title: '公告内容', + field: 'content', + form: { + component: 'Editor', + colProps: { + span: 24 + }, + componentProps: { + valueHtml: '' + } } - } - }, - { - label: t('common.createTime'), - field: 'createTime', - form: { - show: false - } - }, - { - label: t('table.action'), - field: 'action', - width: '240px', - form: { - show: false }, - detail: { - show: false + { + title: t('common.createTime'), + field: 'createTime', + formatter: 'formatDate', + isForm: false } - } -]) -export const { allSchemas } = useCrudSchemas(crudSchemas) + ] +}) +export const { allSchemas } = useVxeCrudSchemas(crudSchemas) diff --git a/yudao-ui-admin-vue3/src/views/system/post/index.vue b/yudao-ui-admin-vue3/src/views/system/post/index.vue index 9017152b8..27f57d730 100644 --- a/yudao-ui-admin-vue3/src/views/system/post/index.vue +++ b/yudao-ui-admin-vue3/src/views/system/post/index.vue @@ -99,12 +99,6 @@ const handleCreate = () => { unref(formRef)?.getElFormRef()?.resetFields() } -// 详情操作 -const handleDetail = (row: PostVO) => { - setDialogTile('detail') - detailRef.value = row -} - // 修改操作 const handleUpdate = async (rowId: number) => { setDialogTile('update') @@ -113,6 +107,12 @@ const handleUpdate = async (rowId: number) => { unref(formRef)?.setValues(res) } +// 详情操作 +const handleDetail = (row: PostVO) => { + setDialogTile('detail') + detailRef.value = row +} + // 删除操作 const handleDelete = async (rowId: number) => { message