@jdlinker/linker
Version:
jdLinker 系统模块
103 lines (96 loc) • 2.75 kB
text/typescript
// 产品分类
import { defHttp } from '@jdlinker/func';
import { useMessage } from '@jdlinker/func';
const { createConfirm } = useMessage();
enum Api {
list = '/product/category/rootList',
save = '/product/category/add',
edit = '/product/category/edit',
deleteIotProductCategory = '/product/category/delete',
importExcel = '/product/category/importExcel',
exportXls = '/product/category/exportXls',
loadTreeData = '/product/category/loadTreeRoot',
getChildList = '/product/category/childList',
getChildListBatch = '/product/category/getChildListBatch'
}
/**
* 导出api
* @param params
*/
export const getExportUrl = Api.exportXls;
/**
* 导入api
* @param params
*/
export const getImportUrl = Api.importExcel;
/**
* 列表接口
* @param params
*/
export const list = (params) => defHttp.get({ url: Api.list, params });
/**
* 删除
*/
export const deleteIotProductCategory = (params, handleSuccess) => {
return defHttp.delete({ url: Api.deleteIotProductCategory, params }, { joinParamsToUrl: true }).then(() => {
handleSuccess();
});
};
/**
* 批量删除
* @param params
*/
export const batchDeleteIotProductCategory = (params, handleSuccess) => {
createConfirm({
iconType: 'warning',
title: '确认删除',
content: '是否删除选中数据',
okText: '确认',
cancelText: '取消',
onOk: () => {
return defHttp.delete({ url: Api.deleteIotProductCategory, data: params }, { joinParamsToUrl: true }).then(() => {
handleSuccess();
});
}
});
};
/**
* 保存或者更新
* @param params
*/
export const saveOrUpdateDict = (params, isUpdate) => {
const url = isUpdate ? Api.edit : Api.save;
return defHttp.post({ url: url, params });
};
/**
* 查询全部树形节点数据
* @param params
*/
export const loadTreeData = (params) => defHttp.get({ url: Api.loadTreeData, params });
/**
* 查询子节点数据
* @param params
*/
export const getChildList = (params) => defHttp.get({ url: Api.getChildList, params });
/**
* 批量查询子节点数据
* @param params
*/
export const getChildListBatch = (params) =>
defHttp.get({ url: Api.getChildListBatch, params }, { isTransformResponse: false });
/**
* 查询产品分类树形数据
*/
export const queryTree = (params?: Record<string, any>) => defHttp.post({ url: '/device/category/_tree', params });
/**
* 保存树形数据
*/
export const saveTree = (data: any) => defHttp.post({ url: '/device/category', data });
/**
* 根据Id修改
*/
export const updateTree = (id: string, data: any) => defHttp.put({ url: `/device/category/${id}`, data });
/**
* 根据Id删除数据
*/
export const deleteTree = (id: string) => defHttp.delete({ url: `/device/category/${id}` });