字典类型 CRUD
This commit is contained in:
139
frontend/src/api/system/dictionary/dictExample.ts
Normal file
139
frontend/src/api/system/dictionary/dictExample.ts
Normal file
@@ -0,0 +1,139 @@
|
||||
import { type Dict } from "@/api/system/dictionary/interface";
|
||||
|
||||
export const dictTypeList: Dict.ResDictType[] = [
|
||||
{
|
||||
id: "1",
|
||||
name: "用户性别",
|
||||
code: "EXAMPLE_CODE1",
|
||||
sort: 100,
|
||||
openLevel: 1,
|
||||
openDescribe: 1,
|
||||
remark: "示例描述示例描述示例描述12231",
|
||||
state: 1,
|
||||
createBy: "admin",
|
||||
createTime: "2023-10-01 12:00:00",
|
||||
updateBy: "admin",
|
||||
updateTime: "2023-10-12 14:40:00",
|
||||
},
|
||||
{
|
||||
id: "231",
|
||||
name: "菜单状态",
|
||||
code: "EXAMPLE_CODE2",
|
||||
sort: 100,
|
||||
openLevel: 1,
|
||||
openDescribe: 1,
|
||||
remark: "示例描述示例描述示例描述11133",
|
||||
state: 0,
|
||||
createBy: "admin",
|
||||
createTime: "2023-10-01 12:00:00",
|
||||
updateBy: "admin",
|
||||
updateTime: "2023-10-10 12:00:00",
|
||||
},
|
||||
{
|
||||
id: "33",
|
||||
name: "系统开关",
|
||||
code: "EXAMPLE_CODE3",
|
||||
sort: 100,
|
||||
openLevel: 1,
|
||||
openDescribe: 1,
|
||||
remark: "示例描述示例描述示例描述11144",
|
||||
state: 1,
|
||||
createBy: "admin",
|
||||
createTime: "2023-10-01 12:00:00",
|
||||
updateBy: "admin",
|
||||
updateTime: "2023-10-10 12:00:00",
|
||||
},
|
||||
];
|
||||
|
||||
export const dictDataList: Dict.ResDictData[] = [
|
||||
{
|
||||
id: "210",
|
||||
typeId: "101",
|
||||
name: "字典项1",
|
||||
code: "EXAMPLE_00111",
|
||||
sort:100,
|
||||
level: 1,
|
||||
algoDescribe: null,
|
||||
value: "字典值1",
|
||||
state: 1,
|
||||
createBy: "admin",
|
||||
createTime: "2023-10-01 12:00:00",
|
||||
updateBy: "admin",
|
||||
updateTime: "2023-10-01 14:43:03",
|
||||
},
|
||||
{
|
||||
id: "2210",
|
||||
typeId: "101",
|
||||
name: "字典项2",
|
||||
code: "EXAMPLE_00121",
|
||||
sort:100,
|
||||
level: 2,
|
||||
algoDescribe: null,
|
||||
value: "字典值2",
|
||||
state: 1,
|
||||
createBy: "admin",
|
||||
createTime: "2023-10-03 12:00:00",
|
||||
updateBy: "admin",
|
||||
updateTime: "2023-10-05 14:43:03",
|
||||
},
|
||||
{
|
||||
id: "212",
|
||||
typeId: "101",
|
||||
name: "字典项3",
|
||||
code: "EXAMPLE_00141",
|
||||
sort:100,
|
||||
level: 3,
|
||||
algoDescribe: null,
|
||||
value: "字典值3",
|
||||
state: 0,
|
||||
createBy: "admin",
|
||||
createTime: "2023-10-01 11:00:00",
|
||||
updateBy: "admin",
|
||||
updateTime: "2023-10-05 16:43:03",
|
||||
},
|
||||
{
|
||||
id: "210",
|
||||
typeId: "101",
|
||||
name: "字典项4",
|
||||
code: "EXAMPLE_00311",
|
||||
sort:100,
|
||||
level: null,
|
||||
algoDescribe: null,
|
||||
value: "字典值4",
|
||||
state: 0,
|
||||
createBy: "admin",
|
||||
createTime: "2023-10-03 12:40:00",
|
||||
updateBy: "admin",
|
||||
updateTime: "2023-10-04 14:43:03",
|
||||
},
|
||||
{
|
||||
id: "217",
|
||||
typeId: "101",
|
||||
name: "字典项5",
|
||||
code: "EXAMPLE_00341",
|
||||
sort:100,
|
||||
level: undefined,
|
||||
algoDescribe: null,
|
||||
value: "字典值5",
|
||||
state: 1,
|
||||
createBy: "admin",
|
||||
createTime: "2023-10-06 12:45:03",
|
||||
updateBy: "admin",
|
||||
updateTime: "2023-10-07 19:37:03",
|
||||
},
|
||||
{
|
||||
id: "237",
|
||||
typeId: "101",
|
||||
name: "字典项6",
|
||||
code: "EXAMPLE_00318",
|
||||
sort:100,
|
||||
level: 0,
|
||||
algoDescribe: null,
|
||||
value: "字典值6",
|
||||
state: 1,
|
||||
createBy: "admin",
|
||||
createTime: "2023-10-16 10:45:03",
|
||||
updateBy: "admin",
|
||||
updateTime: "2023-10-17 19:37:03",
|
||||
},
|
||||
];
|
||||
24
frontend/src/api/system/dictionary/dictType/index.ts
Normal file
24
frontend/src/api/system/dictionary/dictType/index.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import http from '@/api'
|
||||
import { type Dict } from '@/api/system/dictionary/interface'
|
||||
|
||||
//获取字典类型
|
||||
export const getDictTypeList = (params: Dict.ReqDictTypeParams) => {
|
||||
return http.post(`/dictType/list`, params)
|
||||
}
|
||||
|
||||
//添加字典类型
|
||||
export const addDictType = (params: Dict.ResDictType) => {
|
||||
return http.post(`/dictType/add`, params)
|
||||
}
|
||||
|
||||
//编辑字典类型
|
||||
export const updateDictType = (params: Dict.ResDictType) => {
|
||||
return http.post(`/dictType/update`, params)
|
||||
}
|
||||
|
||||
//删除字典类型
|
||||
export const deleteDictType = (params: string[]) => {
|
||||
return http.post(`/dictType/delete`, params)
|
||||
}
|
||||
|
||||
|
||||
70
frontend/src/api/system/dictionary/index.ts
Normal file
70
frontend/src/api/system/dictionary/index.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
import http from "@/api";
|
||||
import { ADMIN as rePrefix } from "@/api/config/serviceName";
|
||||
import { type Dict } from "@/api/system/dictionary/interface";
|
||||
|
||||
//获取字典类型
|
||||
export const getDictTypeList = (params: Dict.ReqDictTypeParams) => {
|
||||
return http.post(`${rePrefix}/dict/list`, params);
|
||||
};
|
||||
|
||||
//添加字典类型
|
||||
export const addDictType = (params: Dict.ReqDictTypeParams) => {
|
||||
return http.post(`${rePrefix}/dict/add`,params);
|
||||
};
|
||||
|
||||
//删除字典类型
|
||||
export const deleteDictType = (params: { id: string[] }) => {
|
||||
return http.post(`${rePrefix}/dict/delete`, { data: params });
|
||||
};
|
||||
|
||||
//编辑字典类型
|
||||
export const updateDictType = (params: Dict.ReqDictTypeParams) => {
|
||||
return http.post(`${rePrefix}/dict/update`, params);
|
||||
};
|
||||
|
||||
//导出字典类型
|
||||
export const exportDictType = (params: Dict.ResDictType) => {
|
||||
return http.download(`${rePrefix}/dict/export`, params);
|
||||
};
|
||||
|
||||
//批量添加字典类型
|
||||
export const batchAddDictType = (params: FormData) => {
|
||||
return http.post(`${rePrefix}/dict/import`, params);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//获取字典数据
|
||||
export const getDictDataList = (params: Dict.ReqDictDataParams) => {
|
||||
return http.post(`${rePrefix}/dict-data/list`, params);
|
||||
};
|
||||
|
||||
//添加字典数据
|
||||
export const addDictData = (params: Dict.ReqDictDataParams) => {
|
||||
return http.post(`${rePrefix}/dict-data/add`, params);
|
||||
};
|
||||
|
||||
//删除字典数据
|
||||
export const deleteDictData = (params: { id: string[] }) => {
|
||||
return http.post(`${rePrefix}/dict-data/delete`, { data: params });
|
||||
};
|
||||
|
||||
//编辑字典数据
|
||||
export const updateDictData = (params: Dict.ReqDictDataParams) => {
|
||||
return http.post(`${rePrefix}/dict-data/update`, params);
|
||||
};
|
||||
|
||||
//导出字典数据
|
||||
export const exportDictData = (params: Dict.ResDictData) => {
|
||||
return http.download(`${rePrefix}/dict-data/export`, params);
|
||||
};
|
||||
|
||||
//批量添加字典数据
|
||||
export const batchAddDictData = (params: FormData) => {
|
||||
return http.post(`${rePrefix}/dict-data/import`, params);
|
||||
};
|
||||
|
||||
|
||||
|
||||
82
frontend/src/api/system/dictionary/interface/index.ts
Normal file
82
frontend/src/api/system/dictionary/interface/index.ts
Normal file
@@ -0,0 +1,82 @@
|
||||
import type { ReqPage, ResPage } from '@/api/interface'
|
||||
|
||||
export namespace Dict {
|
||||
|
||||
/**
|
||||
* 一个单表的CRUD需要申明一下几个对象
|
||||
* 1、表格分页查询对象,字段:查询字段?、页码、每页条数;
|
||||
* 2、新增、修改、根据id查询返回的对象;
|
||||
* 3、表格查询分页返回的对象;
|
||||
*/
|
||||
|
||||
/**
|
||||
* 字典类型表格分页查询参数
|
||||
*/
|
||||
export interface ReqDictTypeParams extends ReqPage{
|
||||
name?: string; // 名称
|
||||
code?: string; // 编码
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典类型新增、修改、根据id查询返回的对象
|
||||
*/
|
||||
export interface ResDictType {
|
||||
id: string; // 字典类型表Id
|
||||
name: string; // 名称
|
||||
code: string; // 编码
|
||||
sort: number; // 排序
|
||||
openLevel: number; // 开启等级:0-不开启;1-开启,默认不开启
|
||||
openDescribe: number; // 开启描述:0-不开启;1-开启,默认不开启
|
||||
remark?: string | null; // 描述
|
||||
state: number; // 状态:0-删除 1-正常
|
||||
createBy?: string | null; // 创建用户
|
||||
createTime?: string | null; // 创建时间
|
||||
updateBy?: string | null; // 更新用户
|
||||
updateTime?: string | null; // 更新时间
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典类型表格查询分页返回的对象;
|
||||
*/
|
||||
export interface ResDictTypePage extends ResPage<ResDictType> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 字典数据表格分页查询参数
|
||||
*/
|
||||
export interface ReqDictDataParams extends ReqPage{
|
||||
typeId: string; // 类型id 必填
|
||||
name?: string; // 名称
|
||||
code?: string; // 编码
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典数据新增、修改、根据id查询返回的对象
|
||||
*/
|
||||
export interface ResDictData {
|
||||
id: string; // 字典数据表Id
|
||||
typeId: string; // 字典类型表Id
|
||||
name: string; // 名称
|
||||
code: string; // 编码
|
||||
sort: number; // 排序
|
||||
level?: number | null; // 事件等级:0-普通;1-中等;2-严重 (默认为0)
|
||||
algoDescribe?: number | null; // 与高级算法内部Id描述对应
|
||||
value?: string | null; // 字典针对电压等级
|
||||
state: number; // 状态:0-删除 1-正常
|
||||
createBy?: string | null; // 创建用户
|
||||
createTime?: string | null; // 创建时间
|
||||
updateBy?: string | null; // 更新用户
|
||||
updateTime?: string | null; // 更新时间
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典数据表格查询分页返回的对象;
|
||||
*/
|
||||
export interface ResDictDataPage extends ResPage<ResDictData> {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user