From fc157671eea10157eaa5afcf8c7db9eb84b98ce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9D=99=E5=80=99=E7=A7=8B=E5=86=AC?= Date: Sat, 30 Apr 2022 16:54:22 +0800 Subject: [PATCH] =?UTF-8?q?-=E5=89=8D=E7=AB=AF=E6=8F=90=E4=BA=A4=EF=BC=9A?= =?UTF-8?q?=E5=AD=97=E5=85=B8=E7=AE=A1=E7=90=86=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kicc-ui/src/api/system/dict.ts | 60 +++-- kicc-ui/src/api/system/dictdata.ts | 61 +++++ kicc-ui/src/api/system/model/dictDataModel.ts | 24 ++ kicc-ui/src/api/system/model/dictModel.ts | 31 +-- .../src/views/system/dict/DictDataModal.vue | 55 +++++ .../{DictSubTable.vue => DictDataTable.vue} | 40 ++-- .../dict/{DictDrawer.vue => DictModal.vue} | 28 +-- .../src/views/system/dict/DictSubDrawer.vue | 53 ----- kicc-ui/src/views/system/dict/dict.data.ts | 218 +++++++++--------- .../src/views/system/dict/dictdata.data.ts | 82 +++++++ kicc-ui/src/views/system/dict/index.vue | 32 +-- 11 files changed, 442 insertions(+), 242 deletions(-) create mode 100644 kicc-ui/src/api/system/dictdata.ts create mode 100644 kicc-ui/src/api/system/model/dictDataModel.ts create mode 100644 kicc-ui/src/views/system/dict/DictDataModal.vue rename kicc-ui/src/views/system/dict/{DictSubTable.vue => DictDataTable.vue} (74%) rename kicc-ui/src/views/system/dict/{DictDrawer.vue => DictModal.vue} (60%) delete mode 100644 kicc-ui/src/views/system/dict/DictSubDrawer.vue create mode 100644 kicc-ui/src/views/system/dict/dictdata.data.ts diff --git a/kicc-ui/src/api/system/dict.ts b/kicc-ui/src/api/system/dict.ts index 31286d0a..1e7e4de1 100644 --- a/kicc-ui/src/api/system/dict.ts +++ b/kicc-ui/src/api/system/dict.ts @@ -1,22 +1,54 @@ -import { DictVO, DictDTO, Dict } from './model/dictModel'; +import { DictParams, DictResult, Dict } from './model/dictModel'; import { defHttp } from '/@/utils/http/axios'; +import {isDef} from "/@/utils/is"; enum Api { - Page = '/mate-system/dict/page', - Set = '/mate-system/dict/set', - Del = '/mate-system/dict/del', - SubPage = '/mate-system/dict/list-value', + List = '/system_proxy/system/dict/list', + GetById = '/system_proxy/system/dict', + Save = '/system_proxy/system/dict/save', + Update = '/system_proxy/system/dict/update', + Remove = '/system_proxy/system/dict/remove', + ChangeStatus = '/system_proxy/system/dict/changeStatus' } -// 分页查询 -export const page = (params: DictVO) => defHttp.get({ url: Api.Page, params }); -// 字典项分页查询 -export const subPage = (params: DictVO) => defHttp.get({ url: Api.SubPage, params }); -// 保存 -export const set = (params: Dict) => defHttp.post({ url: Api.Set, params }); +/** + * 条件查询字典数据列表 + * @param params + */ +export const list = (params: DictParams) => + defHttp.get({url: Api.List, params}); -// 删除 -export const del = (params: { ids: String }) => - defHttp.post({ url: Api.Del + `?ids=${params.ids}` }); +/** + * 修改或新增 + * @param params + */ +export const set = (params: Dict) => { + if (isDef(params.id)) { + return defHttp.put({url: Api.Update, params}); + } else { + return defHttp.post({url: Api.Save, params}); + } +} + +/** + * 通过id获取 + * @param params + */ +export const getById = (params: { id: string }) => + defHttp.get({url: Api.GetById + `/${params.id}`}); + +/** + * 删除字典数据 + * @param params + */ +export const remove = (params: {id: string}) => + defHttp.delete({url: Api.Remove + `/${params.id}` }); + +/** + * 修改状态 + * @param params + */ +export const changeStatus = (params: Dict) => + defHttp.get({url: Api.ChangeStatus, params}); \ No newline at end of file diff --git a/kicc-ui/src/api/system/dictdata.ts b/kicc-ui/src/api/system/dictdata.ts new file mode 100644 index 00000000..c0c615b1 --- /dev/null +++ b/kicc-ui/src/api/system/dictdata.ts @@ -0,0 +1,61 @@ +import {DictDataParams, DictDataResult, DictData} from './model/dictDataModel'; +import {defHttp} from '/@/utils/http/axios'; +import {isDef} from "/@/utils/is"; + +enum Api { + List = '/system_proxy/system/dictData/list', + GetById = '/system_proxy/system/dictData', + GetByData = '/system_proxy/system/dictData/getDictData', + GetByDictType = '/system_proxy/system/dictData/dictType', + Save = '/system_proxy/system/dictData/save', + Update = '/system_proxy/system/dictData/update', + Remove = '/system_proxy/system/dictData/remove' + +} + +/** + * 条件查询字典数据列表 + * @param params + */ +export const list = (params: DictDataParams) => + defHttp.get({url: Api.List, params}); + +/** + * 修改或新增 + * @param params + */ +export const set = (params: DictData) => { + if (isDef(params.id)) { + return defHttp.put({url: Api.Update, params}); + } else { + return defHttp.post({url: Api.Save, params}); + } +} + +/** + * 通过id获取 + * @param params + */ +export const getById = (params: { id: string }) => + defHttp.get({url: Api.GetById + `/${params.id}`}); + +/** + * 通过type和value查询 + * @param params + */ +export const getByData = (params: {dataType: string, value: string}) => + defHttp.get({url: Api.GetByData, params}); + +/** + * 获取字典数据通过字典类型 + * @param params + */ +export const getByDictType = (params: {dictType: string}) => + defHttp.get({url: Api.GetByDictType + `/${params.dictType}`}) + +/** + * 删除字典数据 + * @param params + */ +export const remove = (params: {id: string}) => + defHttp.delete({url: Api.Remove + `/${params.id}` }); diff --git a/kicc-ui/src/api/system/model/dictDataModel.ts b/kicc-ui/src/api/system/model/dictDataModel.ts new file mode 100644 index 00000000..65fa7b86 --- /dev/null +++ b/kicc-ui/src/api/system/model/dictDataModel.ts @@ -0,0 +1,24 @@ +// 引入基础包 +import {CommonEntity, Page, R} from '/@/api/model'; + +// 定义查询参数 +export type DictDataParams = Page & { + id?: string; + dictType?: string; + label?: string; + value?: string; + sort?: string; + +} + +export interface DictData extends CommonEntity { + id: string; + dictType: string; + label: string; + value: string; + sort: number; + +} + +// 根据字典对象生成响应模型 +export type DictDataResult = R; \ No newline at end of file diff --git a/kicc-ui/src/api/system/model/dictModel.ts b/kicc-ui/src/api/system/model/dictModel.ts index 7241e4d0..2891bdfa 100644 --- a/kicc-ui/src/api/system/model/dictModel.ts +++ b/kicc-ui/src/api/system/model/dictModel.ts @@ -1,23 +1,26 @@ // 引入基础包 -import { Page, R } from '/@/api/model'; +import {CommonEntity, Page, R} from '/@/api/model'; // 定义查询参数 -export type DictVO = Page & { - code?: string; - dictValue?: string; +export type DictParams = Page & { + id?:string; + name?:string; + type?:string; + isSys?:string; + status?:string; + }; + // 定义字典对象 -export interface Dict { - id: string; - parentId: string; - code: string; - dictKey: string; - dictValue: string; - sort: string; - remark: string; - createTime: string; +export interface Dict extends CommonEntity{ + id:string; + name:string; + type:string; + isSys:string; + status:string; } + // 根据字典对象生成响应模型 -export type DictDTO = R; +export type DictResult = R; diff --git a/kicc-ui/src/views/system/dict/DictDataModal.vue b/kicc-ui/src/views/system/dict/DictDataModal.vue new file mode 100644 index 00000000..d3b1ab3e --- /dev/null +++ b/kicc-ui/src/views/system/dict/DictDataModal.vue @@ -0,0 +1,55 @@ + + diff --git a/kicc-ui/src/views/system/dict/DictSubTable.vue b/kicc-ui/src/views/system/dict/DictDataTable.vue similarity index 74% rename from kicc-ui/src/views/system/dict/DictSubTable.vue rename to kicc-ui/src/views/system/dict/DictDataTable.vue index 419e3da6..6b3453d2 100644 --- a/kicc-ui/src/views/system/dict/DictSubTable.vue +++ b/kicc-ui/src/views/system/dict/DictDataTable.vue @@ -23,7 +23,7 @@ /> - + diff --git a/kicc-ui/src/views/system/dict/DictSubDrawer.vue b/kicc-ui/src/views/system/dict/DictSubDrawer.vue deleted file mode 100644 index b3db07ef..00000000 --- a/kicc-ui/src/views/system/dict/DictSubDrawer.vue +++ /dev/null @@ -1,53 +0,0 @@ - - diff --git a/kicc-ui/src/views/system/dict/dict.data.ts b/kicc-ui/src/views/system/dict/dict.data.ts index f7714c3d..21733432 100644 --- a/kicc-ui/src/views/system/dict/dict.data.ts +++ b/kicc-ui/src/views/system/dict/dict.data.ts @@ -1,119 +1,119 @@ -import { BasicColumn } from '/@/components/Table'; -import { FormSchema } from '/@/components/Table'; +import {BasicColumn} from '/@/components/Table'; +import {FormSchema} from '/@/components/Table'; +import {h} from "vue"; +import {Tag} from "ant-design-vue"; export const columns: BasicColumn[] = [ - { - title: '字典ID', - dataIndex: 'id', - width: 100, - }, - { - title: '字典编号', - dataIndex: 'code', - width: 100, - }, - { - title: '字典名称', - dataIndex: 'dictValue', - width: 130, - }, - { - title: '排序', - dataIndex: 'sort', - width: 90, - }, -]; - -export const searchFormSchema: FormSchema[] = [ - { - field: 'keyword', - label: '关键词', - component: 'Input', - componentProps: { - placeholder: '请输入字典名称/编码', + { + title: '字典ID', + dataIndex: 'id', + width: 100, + }, + { + title: '字典名称', + dataIndex: 'name', + width: 100, }, - colProps: { span: 16 }, - }, + { + title: '字典类型', + dataIndex: 'type', + width: 130, + }, + { + title: '系统内置', + dataIndex: 'isSys', + width: 90, + customRender: ({ record }) => { + const status = record.status; + const enable = status === '0'; + const color = 'gray'; + const text = enable ? '是' : '否'; + return h(Tag, { color: color }, () => text); + } + }, + { + title: '状态', + dataIndex: 'status', + width: 90, + customRender: ({ record }) => { + const status = record.status; + const enable = status === '0'; + const color = enable ? 'green' : 'red'; + const text = enable ? '启用' : '禁用'; + return h(Tag, { color: color }, () => text); + } + } ]; -export const subSearchFormSchema: FormSchema[] = [ - { - field: 'keyword', - label: '关键词', - component: 'Input', - componentProps: { - placeholder: '请输入字典名称/编码', - }, - colProps: { span: 16 }, - }, +export const searchFormSchema: FormSchema[] = [ + { + field: 'type', + label: '字典类型', + component: 'Input', + componentProps: { + placeholder: '请输入字典类型', + }, + colProps: {span: 16}, + } ]; export const formSchema: FormSchema[] = [ - { - field: 'id', - label: 'ID', - component: 'Input', - show: false, - }, - { - field: 'code', - label: '字典编号', - component: 'Input', - }, - { - field: 'dictValue', - label: '字典名称', - component: 'Input', - }, - { - field: 'sort', - label: '排序', - component: 'InputNumber', - }, - { - field: 'remark', - label: '备注', - component: 'InputTextArea', - }, -]; + { + field: 'id', + label: 'ID', + component: 'Input', + show: false, + }, + { + field: 'name', + label: '字典名称', + component: 'Input', + colProps:{ + span: 12 + } -export const subFormSchema: FormSchema[] = [ - { - field: 'id', - label: 'ID', - component: 'Input', - show: false, - }, - { - field: 'parentId', - label: '上级ID', - component: 'Input', - show: false, - }, - { - field: 'code', - label: '字典编号', - component: 'Input', - componentProps: { disabled: true }, - }, - { - field: 'dictKey', - label: '字典值', - component: 'Input', - }, - { - field: 'dictValue', - label: '字典名称', - component: 'Input', - }, - { - field: 'sort', - label: '排序', - component: 'InputNumber', - }, - { - field: 'remark', - label: '备注', - component: 'InputTextArea', - }, + }, + { + field: 'type', + label: '字典类型', + component: 'Input', + colProps:{ + span: 12 + } + }, + { + field: 'isSys', + label: '系统内置', + component: 'Select', + defaultValue: '0', + componentProps: { + options: [ + { label: '是', value: '0' }, + { label: '否', value: '1' } + ] + }, + colProps:{ + span: 12 + } + }, + { + field: 'status', + label: '状态', + component: 'Select', + defaultValue: '0', + componentProps: { + options: [ + { label: '启用', value: '0' }, + { label: '禁用', value: '1' } + ] + }, + colProps:{ + span: 12 + } + }, + { + field: 'remarks', + label: '备注', + component: 'InputTextArea', + }, ]; diff --git a/kicc-ui/src/views/system/dict/dictdata.data.ts b/kicc-ui/src/views/system/dict/dictdata.data.ts new file mode 100644 index 00000000..c51f7d58 --- /dev/null +++ b/kicc-ui/src/views/system/dict/dictdata.data.ts @@ -0,0 +1,82 @@ +import {BasicColumn} from '/@/components/Table'; +import {FormSchema} from '/@/components/Table'; + +export const columns: BasicColumn[] = [ + { + title: '字典ID', + dataIndex: 'id', + width: 100, + }, + { + title: '字典类型', + dataIndex: 'dictType', + width: 100, + }, + { + title: '字典标签', + dataIndex: 'label', + width: 130, + }, + { + title: '字典键值', + dataIndex: 'value', + width: 90, + }, + { + title: '字典排序', + dataIndex: 'sort', + width: 90, + } + +]; + + +export const searchFormSchema: FormSchema[] = [ + { + field: 'dataType', + label: '字典参数类型', + component: 'Input', + componentProps: { + placeholder: '请输入字典参数类型', + }, + colProps: {span: 16}, + } +]; + +export const formSchema: FormSchema[] = [ + { + field: 'id', + label: 'ID', + component: 'Input', + show: false, + }, + { + field: 'dictType', + label: '字典类型', + component: 'Input', + required: true, + componentProps: {disabled: true} + }, + { + field: 'label', + label: '字典标签', + component: 'Input', + required: true + }, + { + field: 'value', + label: '字典键值', + component: 'Input', + required: true + }, + { + field: 'sort', + label: '排序', + component: 'InputNumber', + }, + { + field: 'remark', + label: '备注', + component: 'InputTextArea', + } +]; \ No newline at end of file diff --git a/kicc-ui/src/views/system/dict/index.vue b/kicc-ui/src/views/system/dict/index.vue index 7f87bf0f..d9458e05 100644 --- a/kicc-ui/src/views/system/dict/index.vue +++ b/kicc-ui/src/views/system/dict/index.vue @@ -23,8 +23,8 @@ /> - - + +