From 42eb550858f0e932aa40f567b1020f4874c589ef Mon Sep 17 00:00:00 2001 From: xingyu4j Date: Tue, 22 Nov 2022 14:34:21 +0800 Subject: [PATCH] feat: dict vxe --- .../src/views/system/dict/dict.data.ts | 195 +++++++--------- .../src/views/system/dict/dict.type.ts | 129 ++++------- .../src/views/system/dict/index.vue | 209 ++++++++---------- 3 files changed, 217 insertions(+), 316 deletions(-) diff --git a/yudao-ui-admin-vue3/src/views/system/dict/dict.data.ts b/yudao-ui-admin-vue3/src/views/system/dict/dict.data.ts index d07683f15..06defb795 100644 --- a/yudao-ui-admin-vue3/src/views/system/dict/dict.data.ts +++ b/yudao-ui-admin-vue3/src/views/system/dict/dict.data.ts @@ -2,131 +2,100 @@ import { reactive } from 'vue' import { DICT_TYPE } from '@/utils/dict' import { required } from '@/utils/formRules' import { useI18n } from '@/hooks/web/useI18n' -import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas' +import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas' // 国际化 const { t } = useI18n() // 表单校验 export const dictDataRules = reactive({ - label: [required], + title: [required], value: [required], sort: [required] }) // crudSchemas -export const crudSchemas = reactive([ - { - label: t('common.index'), - field: 'id', - type: 'index', - form: { - show: false +export const crudSchemas = reactive({ + primaryKey: 'id', + primaryType: 'seq', + action: true, + actionWidth: '140px', + columns: [ + { + title: '字典类型', + field: 'dictType', + isTable: false, + isForm: false }, - detail: { - show: false - } - }, - { - label: '字典类型', - field: 'dictType', - table: { - show: false + { + title: '数据标签', + field: 'label', + isSearch: true }, - form: { - show: false - } - }, - { - label: '数据标签', - field: 'label', - search: { - show: true - } - }, - { - label: '数据键值', - field: 'value' - }, - { - label: '颜色类型', - field: 'colorType', - form: { - component: 'Select', - componentProps: { - options: [ - { - label: 'default', - value: '' - }, - { - label: 'success', - value: 'success' - }, - { - label: 'info', - value: 'info' - }, - { - label: 'warning', - value: 'warning' - }, - { - label: 'danger', - value: 'danger' - } - ] - } + { + title: '数据键值', + field: 'value' }, - table: { - show: false - } - }, - { - label: 'CSS Class', - field: 'cssClass', - table: { - show: false - } - }, - { - label: '显示排序', - field: 'sort', - table: { - show: false - } - }, - { - label: t('common.status'), - field: 'status', - dictType: DICT_TYPE.COMMON_STATUS, - dictClass: 'number' - }, - { - label: t('form.remark'), - field: 'remark', - form: { - component: 'Input', - componentProps: { - type: 'textarea', - rows: 4 + { + title: '颜色类型', + field: 'colorType', + form: { + component: 'Select', + componentProps: { + options: [ + { + title: 'default', + value: '' + }, + { + title: 'success', + value: 'success' + }, + { + title: 'info', + value: 'info' + }, + { + title: 'warning', + value: 'warning' + }, + { + title: 'danger', + value: 'danger' + } + ] + } }, - colProps: { - span: 24 - } + isTable: false }, - table: { - show: false - } - }, - { - label: t('table.action'), - field: 'action', - width: '180px', - form: { - show: false + { + title: 'CSS Class', + field: 'cssClass', + isTable: false }, - detail: { - show: false + { + title: '显示排序', + field: 'sort', + isTable: false + }, + { + title: t('common.status'), + field: 'status', + dictType: DICT_TYPE.COMMON_STATUS, + dictClass: 'number' + }, + { + title: t('form.remark'), + field: 'remark', + form: { + component: 'Input', + componentProps: { + type: 'textarea', + rows: 4 + }, + colProps: { + span: 24 + } + }, + isTable: false } - } -]) - -export const { allSchemas } = useCrudSchemas(crudSchemas) + ] +}) +export const { allSchemas } = useVxeCrudSchemas(crudSchemas) diff --git a/yudao-ui-admin-vue3/src/views/system/dict/dict.type.ts b/yudao-ui-admin-vue3/src/views/system/dict/dict.type.ts index 08dd41397..5f41bb043 100644 --- a/yudao-ui-admin-vue3/src/views/system/dict/dict.type.ts +++ b/yudao-ui-admin-vue3/src/views/system/dict/dict.type.ts @@ -2,96 +2,63 @@ import { reactive } from 'vue' import { DICT_TYPE } from '@/utils/dict' import { required } from '@/utils/formRules' import { useI18n } from '@/hooks/web/useI18n' -import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas' -// 国际化 -const { t } = useI18n() +import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas' +const { t } = useI18n() // 国际化 + // 表单校验 export const dictTypeRules = reactive({ name: [required], type: [required] }) // 新增 + 修改 -const crudSchemas = reactive([ - { - label: t('common.index'), - field: 'id', - type: 'index', - form: { - show: false +const crudSchemas = reactive({ + primaryKey: 'id', + primaryType: 'seq', + action: true, + actionWidth: '140px', + columns: [ + { + title: '字典名称', + field: 'name', + isSearch: true }, - detail: { - show: false - } - }, - { - label: '字典名称', - field: 'name', - search: { - show: true - } - }, - { - label: '字典类型', - field: 'type', - search: { - show: true - } - }, - { - label: t('common.status'), - field: 'status', - dictType: DICT_TYPE.COMMON_STATUS, - dictClass: 'number' - }, - { - label: t('common.createTime'), - field: 'createTime', - table: { - show: false + { + title: '字典类型', + field: 'type', + isSearch: true }, - form: { - show: false + { + title: t('common.status'), + field: 'status', + dictType: DICT_TYPE.COMMON_STATUS, + dictClass: 'number', + table: { + width: 70 + } }, - detail: { - show: false + { + title: t('common.createTime'), + field: 'createTime', + formatter: 'formatDate', + isForm: false, + table: { + width: 150 + } }, - search: { - show: true, - component: 'DatePicker', - componentProps: { - type: 'datetimerange', - valueFormat: 'YYYY-MM-DD HH:mm:ss', - defaultTime: [new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)] + { + title: t('form.remark'), + field: 'remark', + isTable: false, + form: { + componentProps: { + type: 'textarea', + rows: 4 + }, + colProps: { + span: 24 + } } } - }, - { - label: t('form.remark'), - field: 'remark', - table: { - show: false - }, - form: { - componentProps: { - type: 'textarea', - rows: 4 - }, - colProps: { - span: 24 - } - } - }, - { - field: 'action', - width: '180px', - label: t('table.action'), - form: { - show: false - }, - detail: { - show: false - } - } -]) - -export const { allSchemas } = useCrudSchemas(crudSchemas) + ] +}) +export const { allSchemas } = useVxeCrudSchemas(crudSchemas) diff --git a/yudao-ui-admin-vue3/src/views/system/dict/index.vue b/yudao-ui-admin-vue3/src/views/system/dict/index.vue index 998ca581e..be492458e 100644 --- a/yudao-ui-admin-vue3/src/views/system/dict/index.vue +++ b/yudao-ui-admin-vue3/src/views/system/dict/index.vue @@ -6,54 +6,36 @@ 字典分类 - - -
- -
- - -