feat: 字典功能

This commit is contained in:
dap
2024-08-08 14:05:08 +08:00
parent 7f38933e37
commit 66100d44b2
12 changed files with 707 additions and 2 deletions

View File

@@ -0,0 +1,75 @@
import type { DictData } from './dict-data-model';
import type { ID, IDS, PageQuery } from '#/api/base';
import { commonExport } from '#/api/base';
import { requestClient } from '#/api/request';
enum Api {
dictDataExport = '/system/dict/data/export',
dictDataList = '/system/dict/data/list',
root = '/system/dict/data',
}
/**
* 主要是DictTag组件使用
* @param dictType 字典类型
* @returns 字典数据
*/
export function dictDataInfo(dictType: string) {
return requestClient.get<DictData[]>(`${Api.root}/type/${dictType}`);
}
/**
* 字典数据
* @param params 查询参数
* @returns 字典数据列表
*/
export function dictDataList(params?: PageQuery) {
return requestClient.get<DictData[]>(Api.dictDataList, { params });
}
/**
* 导出字典数据
* @param data 表单参数
* @returns blob
*/
export function dictDataExport(data: any) {
return commonExport(Api.dictDataExport, data);
}
/**
* 删除
* @param dictIds 字典ID Array
* @returns void
*/
export function dictDataRemove(dictIds: IDS) {
return requestClient.deleteWithMsg<void>(`${Api.root}/${dictIds.join(',')}`);
}
/**
* 新增
* @param data 表单参数
* @returns void
*/
export function dictDataAdd(data: any) {
return requestClient.postWithMsg<void>(Api.root, data);
}
/**
* 修改
* @param data 表单参数
* @returns void
*/
export function dictDataUpdate(data: any) {
return requestClient.putWithMsg<void>(Api.root, data);
}
/**
* 查询字典数据详细
* @param dictCode 字典编码
* @returns 字典数据
*/
export function dictDetailInfo(dictCode: ID) {
return requestClient.get<DictData>(`${Api.root}/${dictCode}`);
}