From 3dd2203803053d1f0f5117cb01c9dd15ebd96729 Mon Sep 17 00:00:00 2001 From: xingyu4j Date: Tue, 22 Nov 2022 15:10:00 +0800 Subject: [PATCH] refactor: config vxe --- .../src/api/infra/config/index.ts | 28 +- .../src/api/infra/config/types.ts | 11 - .../src/views/infra/config/config.data.ts | 168 +++++------- .../src/views/infra/config/index.vue | 254 +++++++++--------- 4 files changed, 219 insertions(+), 242 deletions(-) delete mode 100644 yudao-ui-admin-vue3/src/api/infra/config/types.ts diff --git a/yudao-ui-admin-vue3/src/api/infra/config/index.ts b/yudao-ui-admin-vue3/src/api/infra/config/index.ts index 38a8eeb6d3..b23b86da15 100644 --- a/yudao-ui-admin-vue3/src/api/infra/config/index.ts +++ b/yudao-ui-admin-vue3/src/api/infra/config/index.ts @@ -1,8 +1,30 @@ import request from '@/config/axios' -import type { ConfigVO } from './types' + +export type ConfigVO = { + id: number + group: string + name: string + key: string + value: string + type: string + visible: boolean + remark: string + createTime: string +} +export interface ConfigPageReqVO extends PageParam { + name?: string + type?: number + createTime?: string[] +} + +export interface ConfigExportReqVO { + name?: string + type?: number + createTime?: string[] +} // 查询参数列表 -export const getConfigPageApi = (params) => { +export const getConfigPageApi = (params: ConfigPageReqVO) => { return request.get({ url: '/infra/config/page', params }) } @@ -32,6 +54,6 @@ export const deleteConfigApi = (id: number) => { } // 导出参数 -export const exportConfigApi = (params) => { +export const exportConfigApi = (params: ConfigExportReqVO) => { return request.download({ url: '/infra/config/export', params }) } diff --git a/yudao-ui-admin-vue3/src/api/infra/config/types.ts b/yudao-ui-admin-vue3/src/api/infra/config/types.ts deleted file mode 100644 index 613a5e65c9..0000000000 --- a/yudao-ui-admin-vue3/src/api/infra/config/types.ts +++ /dev/null @@ -1,11 +0,0 @@ -export type ConfigVO = { - id: number - group: string - name: string - key: string - value: string - type: string - visible: boolean - remark: string - createTime: string -} diff --git a/yudao-ui-admin-vue3/src/views/infra/config/config.data.ts b/yudao-ui-admin-vue3/src/views/infra/config/config.data.ts index 3dfc441577..951a8898ea 100644 --- a/yudao-ui-admin-vue3/src/views/infra/config/config.data.ts +++ b/yudao-ui-admin-vue3/src/views/infra/config/config.data.ts @@ -1,8 +1,8 @@ import { reactive } from 'vue' import { useI18n } from '@/hooks/web/useI18n' import { required } from '@/utils/formRules' -import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas' import { DICT_TYPE } from '@/utils/dict' +import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas' const { t } = useI18n() // 国际化 // 表单校验 @@ -14,105 +14,81 @@ 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: 'category' }, - detail: { - show: false - } - }, - { - label: '参数分类', - field: 'category' - }, - { - label: '参数名称', - field: 'name', - search: { - show: true - } - }, - { - label: '参数键名', - field: 'key', - search: { - show: true - } - }, - { - label: '参数键值', - field: 'value' - }, - { - label: '系统内置', - field: 'type', - dictType: DICT_TYPE.INFRA_CONFIG_TYPE, - dictClass: 'number', - search: { - show: true - } - }, - { - label: '是否可见', - field: 'visible', - form: { - component: 'RadioButton', - componentProps: { - options: [ - { label: '是', value: true }, - { label: '否', value: false } - ] - } - } - }, - { - label: t('form.remark'), - field: 'remark', - form: { - component: 'Input', - componentProps: { - type: 'textarea', - rows: 4 + { + title: '参数名称', + field: 'name', + isSearch: true + }, + { + title: '参数键名', + field: 'key', + isSearch: true + }, + { + title: '参数键值', + field: 'value' + }, + { + title: '系统内置', + field: 'type', + dictType: DICT_TYPE.INFRA_CONFIG_TYPE, + dictClass: 'number', + isSearch: true + }, + { + title: '是否可见', + field: 'visible', + table: { + slots: { + default: 'visible_default' + } }, - colProps: { - span: 24 + form: { + component: 'RadioButton', + componentProps: { + options: [ + { label: '是', value: true }, + { label: '否', value: false } + ] + } } }, - table: { - show: false - } - }, - { - label: t('common.createTime'), - field: 'createTime', - form: { - show: false + { + title: t('form.remark'), + field: 'remark', + isTable: false, + form: { + component: 'Input', + componentProps: { + type: 'textarea', + rows: 4 + }, + colProps: { + span: 24 + } + } }, - 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('common.createTime'), + field: 'createTime', + formatter: 'formatDate', + isForm: false, + search: { + show: true, + itemRender: { + name: 'XDataTimePicker' + } } } - }, - { - label: t('table.action'), - field: 'action', - width: '240px', - 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/infra/config/index.vue b/yudao-ui-admin-vue3/src/views/infra/config/index.vue index 687448e1e3..8c9769ef18 100644 --- a/yudao-ui-admin-vue3/src/views/infra/config/index.vue +++ b/yudao-ui-admin-vue3/src/views/infra/config/index.vue @@ -1,140 +1,34 @@ - -