From 4a3d8adcce2a60981ba5dbc081c7b170e89eb05f Mon Sep 17 00:00:00 2001 From: xingyuv Date: Tue, 21 Mar 2023 17:55:06 +0800 Subject: [PATCH] feat: dict --- src/api/system/dict/{dict.data.ts => data.ts} | 0 src/api/system/dict/{dict.type.ts => type.ts} | 0 src/store/modules/dict.ts | 2 +- src/views/system/dict/DictData.vue | 98 +++++++++++ src/views/system/dict/DictDataModel.vue | 58 +++++++ src/views/system/dict/DictTypeModel.vue | 58 +++++++ src/views/system/dict/dict.data.ts | 159 ++++++++++++++++++ src/views/system/dict/dict.type.ts | 89 ++++++++++ src/views/system/dict/index.vue | 98 ++++++++++- 9 files changed, 560 insertions(+), 2 deletions(-) rename src/api/system/dict/{dict.data.ts => data.ts} (100%) rename src/api/system/dict/{dict.type.ts => type.ts} (100%) create mode 100644 src/views/system/dict/DictData.vue create mode 100644 src/views/system/dict/DictDataModel.vue create mode 100644 src/views/system/dict/DictTypeModel.vue create mode 100644 src/views/system/dict/dict.data.ts create mode 100644 src/views/system/dict/dict.type.ts diff --git a/src/api/system/dict/dict.data.ts b/src/api/system/dict/data.ts similarity index 100% rename from src/api/system/dict/dict.data.ts rename to src/api/system/dict/data.ts diff --git a/src/api/system/dict/dict.type.ts b/src/api/system/dict/type.ts similarity index 100% rename from src/api/system/dict/dict.type.ts rename to src/api/system/dict/type.ts diff --git a/src/store/modules/dict.ts b/src/store/modules/dict.ts index c84d1c2c..11a45a8b 100644 --- a/src/store/modules/dict.ts +++ b/src/store/modules/dict.ts @@ -5,7 +5,7 @@ import { store } from '@/store' import { DICT_KEY } from '@/enums/cacheEnum' import { createLocalStorage } from '@/utils/cache' -import { listSimpleDictDataApi } from '@/api/system/dict/dict.data' +import { listSimpleDictDataApi } from '@/api/system/dict/data' import { DictDataVO } from '@/api/system/dict/types' const ls = createLocalStorage() diff --git a/src/views/system/dict/DictData.vue b/src/views/system/dict/DictData.vue new file mode 100644 index 00000000..5d6c7e88 --- /dev/null +++ b/src/views/system/dict/DictData.vue @@ -0,0 +1,98 @@ + + diff --git a/src/views/system/dict/DictDataModel.vue b/src/views/system/dict/DictDataModel.vue new file mode 100644 index 00000000..9c1e7102 --- /dev/null +++ b/src/views/system/dict/DictDataModel.vue @@ -0,0 +1,58 @@ + + diff --git a/src/views/system/dict/DictTypeModel.vue b/src/views/system/dict/DictTypeModel.vue new file mode 100644 index 00000000..0d7c849e --- /dev/null +++ b/src/views/system/dict/DictTypeModel.vue @@ -0,0 +1,58 @@ + + diff --git a/src/views/system/dict/dict.data.ts b/src/views/system/dict/dict.data.ts new file mode 100644 index 00000000..45c3cbdb --- /dev/null +++ b/src/views/system/dict/dict.data.ts @@ -0,0 +1,159 @@ +import { BasicColumn, FormSchema, useRender } from '@/components/Table' +import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' + +export const dataColumns: BasicColumn[] = [ + { + title: '字典编码', + dataIndex: 'id', + width: 100 + }, + { + title: '字典标签', + dataIndex: 'label', + width: 180 + }, + { + title: '字典键值', + dataIndex: 'value', + width: 100 + }, + { + title: '字典排序', + dataIndex: 'sort', + width: 120 + }, + { + title: '状态', + dataIndex: 'status', + width: 180, + customRender: ({ text }) => { + return useRender.renderDict(text, DICT_TYPE.COMMON_STATUS) + } + }, + { + title: '颜色类型', + dataIndex: 'colorType', + width: 180 + }, + { + title: 'CSS Class', + dataIndex: 'cssClass', + width: 180 + }, + { + title: '备注', + dataIndex: 'remark', + width: 180 + }, + { + title: '创建时间', + dataIndex: 'createTime', + width: 180, + customRender: ({ text }) => { + return useRender.renderDate(text) + } + } +] + +export const dataSearchFormSchema: FormSchema[] = [ + { + label: '字典标签', + field: 'label', + component: 'Input', + colProps: { span: 8 } + }, + { + label: '状态', + field: 'status', + component: 'Select', + componentProps: { + options: getIntDictOptions(DICT_TYPE.COMMON_STATUS) + }, + colProps: { span: 8 } + } +] + +export const dataFormSchema: FormSchema[] = [ + { + label: '编号', + field: 'id', + show: false, + component: 'Input' + }, + { + label: '字典类型', + field: 'dictType', + required: true, + component: 'Input' + }, + { + label: '数据标签', + field: 'label', + required: true, + component: 'Input' + }, + { + label: '数据键值', + field: 'value', + required: true, + component: 'Input' + }, + { + label: '显示排序', + field: 'sort', + required: true, + component: 'InputNumber' + }, + { + label: '状态', + field: 'status', + component: 'Select', + defaultValue: 0, + componentProps: { + options: getIntDictOptions(DICT_TYPE.COMMON_STATUS) + } + }, + { + label: '颜色类型', + field: 'colorType', + component: 'Select', + componentProps: { + options: [ + { + value: 'default', + label: '默认' + }, + { + value: 'primary', + label: '主要' + }, + { + value: 'success', + label: '成功' + }, + { + value: 'info', + label: '信息' + }, + { + value: 'warning', + label: '警告' + }, + { + value: 'danger', + label: '危险' + } + ] + } + }, + { + label: 'CSS Class', + field: 'cssClass', + component: 'Input' + }, + { + label: '备注', + field: 'remark', + component: 'InputTextArea' + } +] diff --git a/src/views/system/dict/dict.type.ts b/src/views/system/dict/dict.type.ts new file mode 100644 index 00000000..87439d30 --- /dev/null +++ b/src/views/system/dict/dict.type.ts @@ -0,0 +1,89 @@ +import { BasicColumn, FormSchema, useRender } from '@/components/Table' +import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' + +export const typeColumns: BasicColumn[] = [ + { + title: '字典编号', + dataIndex: 'id', + width: 100 + }, + { + title: '字典名称', + dataIndex: 'name', + width: 180 + }, + { + title: '状态', + dataIndex: 'status', + width: 180, + customRender: ({ text }) => { + return useRender.renderDict(text, DICT_TYPE.COMMON_STATUS) + } + }, + { + title: '备注', + dataIndex: 'remark', + width: 180 + }, + { + title: '创建时间', + dataIndex: 'createTime', + width: 180, + customRender: ({ text }) => { + return useRender.renderDate(text) + } + } +] + +export const typeSearchFormSchema: FormSchema[] = [ + { + label: '字典名称', + field: 'name', + component: 'Input', + colProps: { span: 8 } + }, + { + label: '状态', + field: 'status', + component: 'Select', + componentProps: { + options: getIntDictOptions(DICT_TYPE.COMMON_STATUS) + }, + colProps: { span: 8 } + } +] + +export const typeFormSchema: FormSchema[] = [ + { + label: '编号', + field: 'id', + show: false, + component: 'Input' + }, + { + label: '字典名称', + field: 'name', + required: true, + component: 'Input' + }, + { + label: '字典类型', + field: 'type', + required: true, + component: 'Input' + }, + { + label: '状态', + field: 'status', + component: 'Select', + defaultValue: 0, + componentProps: { + options: getIntDictOptions(DICT_TYPE.COMMON_STATUS) + } + }, + { + label: '备注', + field: 'remark', + component: 'InputTextArea' + } +] diff --git a/src/views/system/dict/index.vue b/src/views/system/dict/index.vue index 3b64cfc4..e095cf94 100644 --- a/src/views/system/dict/index.vue +++ b/src/views/system/dict/index.vue @@ -1,3 +1,99 @@ +