From 562282b2ad6c608abf257bd7d3ada3e22dc1abed Mon Sep 17 00:00:00 2001 From: xingyu4j Date: Tue, 22 Nov 2022 16:41:43 +0800 Subject: [PATCH] refactor: file vxe --- .../src/api/infra/fileConfig/types.ts | 2 +- .../src/api/infra/fileList/index.ts | 16 +- .../src/api/infra/fileList/types.ts | 8 - .../src/plugins/vxeTable/renderer/img.tsx | 5 +- .../views/infra/fileConfig/fileConfig.data.ts | 126 ++++----- .../src/views/infra/fileConfig/index.vue | 248 +++++++--------- .../src/views/infra/fileList/fileList.data.ts | 90 +++--- .../src/views/infra/fileList/index.vue | 267 ++++++++---------- 8 files changed, 339 insertions(+), 423 deletions(-) delete mode 100644 yudao-ui-admin-vue3/src/api/infra/fileList/types.ts diff --git a/yudao-ui-admin-vue3/src/api/infra/fileConfig/types.ts b/yudao-ui-admin-vue3/src/api/infra/fileConfig/types.ts index ce21b49e0..c212d7b4d 100644 --- a/yudao-ui-admin-vue3/src/api/infra/fileConfig/types.ts +++ b/yudao-ui-admin-vue3/src/api/infra/fileConfig/types.ts @@ -15,7 +15,7 @@ export type FileConfigVO = { id: number name: string storage: string - primary: number + master: boolean visible: boolean config: ConfigType remark: string diff --git a/yudao-ui-admin-vue3/src/api/infra/fileList/index.ts b/yudao-ui-admin-vue3/src/api/infra/fileList/index.ts index 5c9c324fa..bbf61d35f 100644 --- a/yudao-ui-admin-vue3/src/api/infra/fileList/index.ts +++ b/yudao-ui-admin-vue3/src/api/infra/fileList/index.ts @@ -1,7 +1,21 @@ import request from '@/config/axios' +export type FileVO = { + id: number + path: string + url: string + size: string + type: string + createTime: string +} + +export interface FilePageReqVO extends PageParam { + name?: string + createTime?: string[] +} + // 查询文件列表 -export const getFilePageApi = (params) => { +export const getFilePageApi = (params: FilePageReqVO) => { return request.get({ url: '/infra/file/page', params }) } diff --git a/yudao-ui-admin-vue3/src/api/infra/fileList/types.ts b/yudao-ui-admin-vue3/src/api/infra/fileList/types.ts deleted file mode 100644 index 0d32314c4..000000000 --- a/yudao-ui-admin-vue3/src/api/infra/fileList/types.ts +++ /dev/null @@ -1,8 +0,0 @@ -export type FileVO = { - id: number - path: string - url: string - size: string - type: string - createTime: string -} diff --git a/yudao-ui-admin-vue3/src/plugins/vxeTable/renderer/img.tsx b/yudao-ui-admin-vue3/src/plugins/vxeTable/renderer/img.tsx index 8b67e0ea7..7703dcb00 100644 --- a/yudao-ui-admin-vue3/src/plugins/vxeTable/renderer/img.tsx +++ b/yudao-ui-admin-vue3/src/plugins/vxeTable/renderer/img.tsx @@ -1,4 +1,5 @@ import { VXETable } from 'vxe-table' +import { ElImage } from 'element-plus' // 图片渲染 VXETable.renderer.add('XImg', { @@ -6,13 +7,13 @@ VXETable.renderer.add('XImg', { renderDefault(_renderOpts, params) { const { row, column } = params return ( - + > ) } }) diff --git a/yudao-ui-admin-vue3/src/views/infra/fileConfig/fileConfig.data.ts b/yudao-ui-admin-vue3/src/views/infra/fileConfig/fileConfig.data.ts index 11cf0bdb4..74ff91fff 100644 --- a/yudao-ui-admin-vue3/src/views/infra/fileConfig/fileConfig.data.ts +++ b/yudao-ui-admin-vue3/src/views/infra/fileConfig/fileConfig.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() // 国际化 // 表单校验 @@ -25,80 +25,56 @@ 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, + actionWidth: '400px', + columns: [ + { + title: '配置名', + field: 'name', + isSearch: true }, - detail: { - show: false - } - }, - { - label: '配置名', - field: 'name', - search: { - show: true - } - }, - { - label: '存储器', - field: 'storage', - dictType: DICT_TYPE.INFRA_FILE_STORAGE, - dictClass: 'number', - search: { - show: true - } - }, - { - label: '主配置', - field: 'primary', - dictType: DICT_TYPE.INFRA_BOOLEAN_STRING, - dictClass: 'number' - }, - { - label: t('form.remark'), - field: 'remark', - form: { - component: 'Input', - componentProps: { - type: 'textarea', - rows: 4 - }, - colProps: { - span: 24 + { + title: '存储器', + field: 'storage', + dictType: DICT_TYPE.INFRA_FILE_STORAGE, + dictClass: 'number', + isSearch: true + }, + { + title: '主配置', + field: 'master', + dictType: DICT_TYPE.INFRA_BOOLEAN_STRING, + dictClass: 'boolean' + }, + { + title: t('form.remark'), + field: 'remark', + form: { + component: 'Input', + componentProps: { + type: 'textarea', + rows: 4 + }, + colProps: { + span: 24 + } + } + }, + { + title: t('common.createTime'), + field: 'createTime', + formatter: 'formatDate', + isForm: false, + search: { + show: true, + itemRender: { + name: 'XDataTimePicker' + } } } - }, - { - label: t('common.createTime'), - field: 'createTime', - form: { - show: false - }, - 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)] - } - } - }, - { - label: t('table.action'), - field: 'action', - width: '400px', - 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/fileConfig/index.vue b/yudao-ui-admin-vue3/src/views/infra/fileConfig/index.vue index dd72c2c4d..b8fae8120 100644 --- a/yudao-ui-admin-vue3/src/views/infra/fileConfig/index.vue +++ b/yudao-ui-admin-vue3/src/views/infra/fileConfig/index.vue @@ -1,23 +1,103 @@ + - - diff --git a/yudao-ui-admin-vue3/src/views/infra/fileList/fileList.data.ts b/yudao-ui-admin-vue3/src/views/infra/fileList/fileList.data.ts index e203fd4cf..ee56c4ccb 100644 --- a/yudao-ui-admin-vue3/src/views/infra/fileList/fileList.data.ts +++ b/yudao-ui-admin-vue3/src/views/infra/fileList/fileList.data.ts @@ -1,62 +1,46 @@ import { reactive } from 'vue' import { useI18n } from '@/hooks/web/useI18n' -import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas' +import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas' const { t } = useI18n() // 国际化 // 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: 'path', + search: { + show: true + } }, - detail: { - show: false - } - }, - { - label: '文件名', - field: 'path', - search: { - show: true - } - }, - { - label: 'URL', - field: 'url' - }, - { - label: '文件类型', - field: 'type' - }, - { - label: t('common.createTime'), - field: 'createTime', - form: { - show: false + { + title: 'URL', + field: 'url', + table: { + cellRender: { + name: 'XImg' + } + } }, - 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: '文件类型', + field: 'type' + }, + { + title: t('common.createTime'), + field: 'createTime', + formatter: 'formatDate', + isForm: false, + search: { + show: true, + itemRender: { + name: 'XDataTimePicker' + } } } - }, - { - label: t('table.action'), - field: 'action', - width: '300px', - 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/fileList/index.vue b/yudao-ui-admin-vue3/src/views/infra/fileList/index.vue index d20551814..e46770198 100644 --- a/yudao-ui-admin-vue3/src/views/infra/fileList/index.vue +++ b/yudao-ui-admin-vue3/src/views/infra/fileList/index.vue @@ -1,156 +1,35 @@ - -