11 changed files with 442 additions and 242 deletions
@ -1,22 +1,54 @@
@@ -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<DictDTO>({ url: Api.Page, params }); |
||||
|
||||
// 字典项分页查询
|
||||
export const subPage = (params: DictVO) => defHttp.get<DictDTO>({ url: Api.SubPage, params }); |
||||
|
||||
// 保存
|
||||
export const set = (params: Dict) => defHttp.post<Dict>({ 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<boolean>({ 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}); |
@ -0,0 +1,61 @@
@@ -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}` }); |
@ -0,0 +1,24 @@
@@ -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<DictData>; |
@ -1,23 +1,26 @@
@@ -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<DictVO>; |
||||
export type DictResult = R<Dict>; |
||||
|
@ -0,0 +1,55 @@
@@ -0,0 +1,55 @@
|
||||
<template> |
||||
<BasicModal |
||||
v-bind="$attrs" |
||||
@register="registerModal" |
||||
showFooter |
||||
:title="getTitle" |
||||
width="500px" |
||||
@ok="handleSubmit" |
||||
> |
||||
<BasicForm @register="registerForm"/> |
||||
</BasicModal> |
||||
</template> |
||||
<script lang="ts" setup> |
||||
import {ref, computed, unref} from 'vue'; |
||||
import {BasicForm, useForm} from '/@/components/Form/index'; |
||||
import {formSchema} from './dictdata.data'; |
||||
import {set} from '/@/api/system/dictdata'; |
||||
import {BasicModal, useModalInner} from "/@/components/Modal"; |
||||
|
||||
const emit = defineEmits(['success', 'register']); |
||||
const isUpdate = ref(true); |
||||
const [registerForm, {resetFields, setFieldsValue, validate}] = useForm({ |
||||
labelWidth: 100, |
||||
schemas: formSchema, |
||||
showActionButtonGroup: false, |
||||
}); |
||||
|
||||
const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => { |
||||
await resetFields(); |
||||
setModalProps({confirmLoading: false}); |
||||
isUpdate.value = !!data?.isUpdate; |
||||
|
||||
if (unref(isUpdate)) { |
||||
await setFieldsValue({ |
||||
...data.record, |
||||
}); |
||||
} |
||||
}); |
||||
|
||||
const getTitle = computed(() => (!unref(isUpdate) ? '新增字典项' : '编辑字典项')); |
||||
|
||||
async function handleSubmit() { |
||||
try { |
||||
const values = await validate(); |
||||
setModalProps({confirmLoading: true}); |
||||
await set(values); |
||||
closeModal(); |
||||
emit('success'); |
||||
} finally { |
||||
setModalProps({confirmLoading: false}); |
||||
} |
||||
} |
||||
|
||||
|
||||
</script> |
@ -1,53 +0,0 @@
@@ -1,53 +0,0 @@
|
||||
<template> |
||||
<BasicDrawer |
||||
v-bind="$attrs" |
||||
@register="registerDrawer" |
||||
showFooter |
||||
:title="getTitle" |
||||
width="500px" |
||||
@ok="handleSubmit" |
||||
> |
||||
<BasicForm @register="registerForm" /> |
||||
</BasicDrawer> |
||||
</template> |
||||
<script lang="ts" setup> |
||||
import { ref, computed, unref } from 'vue'; |
||||
import { BasicForm, useForm } from '/@/components/Form/index'; |
||||
import { subFormSchema } from './dict.data'; |
||||
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; |
||||
import { set } from '/@/api/system/dict'; |
||||
|
||||
const emit = defineEmits(['success', 'register']); |
||||
const isUpdate = ref(true); |
||||
const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({ |
||||
labelWidth: 100, |
||||
schemas: subFormSchema, |
||||
showActionButtonGroup: false, |
||||
}); |
||||
|
||||
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { |
||||
resetFields(); |
||||
setDrawerProps({ confirmLoading: false }); |
||||
isUpdate.value = !!data?.isUpdate; |
||||
|
||||
if (unref(isUpdate)) { |
||||
setFieldsValue({ |
||||
...data.record, |
||||
}); |
||||
} |
||||
}); |
||||
|
||||
const getTitle = computed(() => (!unref(isUpdate) ? '新增字典项' : '编辑字典项')); |
||||
|
||||
async function handleSubmit() { |
||||
try { |
||||
const values = await validate(); |
||||
setDrawerProps({ confirmLoading: true }); |
||||
await set(values); |
||||
closeDrawer(); |
||||
emit('success'); |
||||
} finally { |
||||
setDrawerProps({ confirmLoading: false }); |
||||
} |
||||
} |
||||
</script> |
@ -0,0 +1,82 @@
@@ -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', |
||||
} |
||||
]; |
Loading…
Reference in new issue