@jdlinker/system
Version:
jdLinker 系统模块
120 lines (107 loc) • 3.35 kB
text/typescript
import { defHttp } from '@jdlinker/func';
import { Modal } from 'ant-design-vue';
enum Api {
list = '/online/cgform/head/list',
deleteRecord = '/online/cgform/head/delete',
removeRecord = '/online/cgform/head/removeRecord',
deleteBatch = '/online/cgform/head/deleteBatch',
save = '/online/cgform/head/add',
edit = '/online/cgform/head/edit',
queryTables = '/online/cgform/head/queryTables',
transTables = '/online/cgform/head/transTables',
indexList = '/online/cgform/index/listByHeadId',
saveAll = '/online/cgform/api/addAll',
editAll = '/online/cgform/api/editAll',
codeGenerate = '/online/cgform/api/codeGenerate',
doDbSynch = '/online/cgform/api/doDbSynch'
}
/**
* 列表接口
* @param params
*/
export const list = (params) => defHttp.get({ url: Api.list, params });
/**
* 删除
*/
export const deleteRecord = (params, handleSuccess) => {
return defHttp.delete({ url: Api.deleteRecord, params }, { joinParamsToUrl: true }).then(() => {
handleSuccess();
});
};
/**
* 移除
*/
export const removeRecord = (params, handleSuccess) => {
return defHttp.delete({ url: Api.removeRecord, params }, { joinParamsToUrl: true }).then(() => {
handleSuccess();
});
};
/**
* 批量删除
* @param params
* @param handleSuccess
*/
export const batchDelete = (params, handleSuccess) => {
Modal.confirm({
title: '删除',
iconType: 'warning',
content: '移除只会删除表单配置;\n' + '删除则会删除对应的数据库表以及子表。\n' + '请确认您的操作…',
okText: '移除',
cancelText: '删除',
onOk: () => {
params.flag = 0;
return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
handleSuccess();
});
},
onCancel() {
params.flag = 1;
return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
handleSuccess();
});
}
});
};
/**
* 保存或者更新用户
* @param params
* @param isUpdate
*/
export const saveOrUpdate = (params, isUpdate) => {
const url = isUpdate ? Api.edit : Api.save;
return defHttp.post({ url: url, params });
};
export const saveOrUpdateAll = (params, isUpdate) => {
const url = isUpdate ? Api.editAll : Api.saveAll;
return defHttp.post({ url: url, params });
};
/**
* 数据库列表
*/
export const queryTables = () => defHttp.get({ url: Api.queryTables }, { isTransformResponse: false });
export const transTables = (params) => {
const url = Api.transTables + '/' + params;
return defHttp.post({ url: url }, { isTransformResponse: false });
};
export const indexList = (params) => defHttp.get({ url: Api.indexList, params });
/**
* 生成代码
*/
export const codeGenerate = (params, handleSuccess) => {
return defHttp.post({ url: Api.codeGenerate, params }, { joinParamsToUrl: true }).then(() => {
handleSuccess();
});
};
/**
* 同步数据库
*/
export const doDbSynch = (params, handleSuccess) => {
const url = Api.doDbSynch + '/' + params.code + '/' + params.synMethod;
return defHttp.post({ url: url, data: params }, { joinParamsToUrl: true }).then(() => {
handleSuccess();
});
};
// 预览生成代码
export const previewCodegen = (id: any) => {
return defHttp.get({ url: `/infra/codegen/preview?tableId=${id}` });
};