fix: 初始化
This commit is contained in:
41
packages/icpx-workflow/src/api/README.md
Normal file
41
packages/icpx-workflow/src/api/README.md
Normal file
@ -0,0 +1,41 @@
|
||||
## Axios Typescript 使用说明
|
||||
|
||||
目前推荐封装请求方法直接使用 `src/utils/request.ts`
|
||||
使用案例如下:
|
||||
|
||||
#### GET
|
||||
|
||||
```ts
|
||||
async function getUser(id: number) {
|
||||
return request.get<id, UserInfo>(`/user/${id}`);
|
||||
}
|
||||
// 返回结果为
|
||||
// Promise<UserInfo>
|
||||
```
|
||||
|
||||
#### POST / PUT
|
||||
|
||||
```ts
|
||||
async function saveUser(user: UserInfo) {
|
||||
// 定义用于得知是 新增 还是 修改
|
||||
// 可根据自己业务自定义逻辑判断
|
||||
const isNewRecord = user.id > 0;
|
||||
return request<UserInfo, boolean>({
|
||||
url: isNewRecord ? `/user/${id}` : `/user/`,
|
||||
method: isNewRecord ? 'POST' : 'PUT',
|
||||
data: user,
|
||||
});
|
||||
}
|
||||
// 返回结果为
|
||||
// Promise<boolean>
|
||||
```
|
||||
|
||||
#### DELETE
|
||||
|
||||
```ts
|
||||
async function deleteUser(id: number) {
|
||||
return request.delete<number, boolean>(`/user/${id}`);
|
||||
}
|
||||
// 返回结果为
|
||||
// Promise<boolean>
|
||||
```
|
135
packages/icpx-workflow/src/api/commonApi/index.ts
Normal file
135
packages/icpx-workflow/src/api/commonApi/index.ts
Normal file
@ -0,0 +1,135 @@
|
||||
import type { APIMethod } from '@crami/bui-types';
|
||||
//通用接口参数处理
|
||||
import { getInfo, ICP_CONFIG } from '@remote/icpx-platform/utils';
|
||||
import { computed, reactive } from 'vue';
|
||||
|
||||
export const commonApi = () => {
|
||||
const commonParams = computed(() => {
|
||||
return getInfo(ICP_CONFIG);
|
||||
});
|
||||
|
||||
const studioCacheParam = reactive({
|
||||
//产品线
|
||||
productLine: commonParams.value?.project,
|
||||
//语言
|
||||
lang: commonParams.value?.lang,
|
||||
//视图名称
|
||||
// name: commonParams.value?.listView,
|
||||
//行政组
|
||||
// userDept: commonParams.value?.userDept,
|
||||
// //用户组
|
||||
// userGroup: commonParams.value?.userGroup,
|
||||
//项目实例
|
||||
projectCode: commonParams.value?.projectCode,
|
||||
// 多时区
|
||||
timeZone: commonParams.value?.TIME_ZONE,
|
||||
});
|
||||
const systemParam = reactive({
|
||||
// viewName: commonParams.value?.listViewName,
|
||||
lang: commonParams.value?.lang,
|
||||
//数据库连接
|
||||
connect: commonParams.value?.connect,
|
||||
//所属租户
|
||||
companyId: commonParams.value?.companyId,
|
||||
//行政组
|
||||
userDept: commonParams.value?.userDept,
|
||||
//用户组
|
||||
userGroup: commonParams.value?.userGroup,
|
||||
projectCode: commonParams.value?.projectCode,
|
||||
// 多时区
|
||||
timeZone: commonParams.value?.TIME_ZONE,
|
||||
});
|
||||
const paraList = {
|
||||
loadAllStructure: false,
|
||||
lang: commonParams.value?.lang,
|
||||
connect: commonParams.value?.connect,
|
||||
companyId: commonParams.value?.companyId,
|
||||
userGroup: commonParams.value?.userGroup,
|
||||
projectCode: commonParams.value?.projectCode,
|
||||
userDept: commonParams.value?.userDept,
|
||||
};
|
||||
return {
|
||||
studioCache: {
|
||||
getMetaInfo: {
|
||||
url: '/api/studio-cache/page/getMetaInfo',
|
||||
params: studioCacheParam,
|
||||
method: 'post' as APIMethod,
|
||||
},
|
||||
getByProjectAndType: {
|
||||
url: '/api/studio-cache/metaData/getByProjectAndType',
|
||||
params: {
|
||||
productLine: commonParams.value?.project,
|
||||
projectCode: commonParams.value?.projectCode,
|
||||
timeZone: commonParams.value?.TIME_ZONE,
|
||||
},
|
||||
method: 'get' as APIMethod,
|
||||
},
|
||||
},
|
||||
system: {
|
||||
getData: {
|
||||
url: '/api/system/view/getData',
|
||||
params: systemParam,
|
||||
method: 'post' as APIMethod,
|
||||
},
|
||||
getGetOnePageGridDataList: {
|
||||
url: '/api/system/model/getGetOnePageGridDataList',
|
||||
params: {
|
||||
...systemParam,
|
||||
objectType: '',
|
||||
},
|
||||
method: 'post' as APIMethod,
|
||||
},
|
||||
getGetOnePageGridDataListByTenant: {
|
||||
url: '/api/system/tenant/getGetOnePageGridDataList',
|
||||
params: {
|
||||
...systemParam,
|
||||
objectType: '',
|
||||
},
|
||||
method: 'post' as APIMethod,
|
||||
},
|
||||
getSltData: {
|
||||
url: '/api/system/model/getSltData',
|
||||
params: {
|
||||
...systemParam,
|
||||
userId: commonParams.value?.user_id,
|
||||
},
|
||||
method: 'post' as APIMethod,
|
||||
},
|
||||
getGetTreeRootDataList: {
|
||||
url: '/api/system/model/getGetTreeRootDataList',
|
||||
params: {
|
||||
...systemParam,
|
||||
paraList: JSON.stringify(paraList),
|
||||
type: 'tree',
|
||||
loadAllStructure: false,
|
||||
},
|
||||
method: 'post' as APIMethod,
|
||||
},
|
||||
getGetTreeChildDataList: {
|
||||
url: '/api/system/model/getGetTreeChildDataList',
|
||||
params: {
|
||||
...systemParam,
|
||||
type: 'treeChildren',
|
||||
loadAllStructure: false,
|
||||
},
|
||||
method: 'post' as APIMethod,
|
||||
},
|
||||
getObjectDataTestList: {
|
||||
url: '/api/system/model/GetObjectDataTestList',
|
||||
params: {
|
||||
...systemParam,
|
||||
userId: commonParams.value?.user_id,
|
||||
},
|
||||
method: 'post' as APIMethod,
|
||||
},
|
||||
saveObjectData: {
|
||||
url: '/api/msg/sender/saveOrEditMsgSender',
|
||||
params: {
|
||||
...systemParam,
|
||||
userId: commonParams.value?.user_id,
|
||||
},
|
||||
method: 'post' as APIMethod,
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
329
packages/icpx-workflow/src/api/platform/form/index.ts
Normal file
329
packages/icpx-workflow/src/api/platform/form/index.ts
Normal file
@ -0,0 +1,329 @@
|
||||
/*
|
||||
* @Author:lily
|
||||
* @Date: 2022-10-31 17:14:23
|
||||
* @LastEditors: error: git config user.name && git config user.email & please set dead value or install git
|
||||
* @Description:自定义表单模块接口方法
|
||||
*/
|
||||
import request from '@/utils/request';
|
||||
import { Http, useHttp } from '@crami/http';
|
||||
import { getInfo, ICP_CONFIG } from '@remote/icpx-platform/utils';
|
||||
import { message } from '@crami/ui';
|
||||
import { Base64 } from 'js-base64';
|
||||
/**
|
||||
* 新增表单项
|
||||
* @returns
|
||||
*/
|
||||
export async function addItem() {
|
||||
return request.request<any, any>({
|
||||
url: '/system/fun/getApplication',
|
||||
method: 'POST',
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存表单数据
|
||||
* @param templateId 模板id
|
||||
* @param data 表单数据
|
||||
* @param modelCode 表单模型
|
||||
* @param saveVersionInfo 版本信息
|
||||
* @returns Promise
|
||||
*/
|
||||
export function saveFormData(
|
||||
modelCode: string,
|
||||
templateId: string,
|
||||
data: any,
|
||||
saveVersionInfo: any,
|
||||
) {
|
||||
return useHttp({
|
||||
url: '/system/modelForm/saveFormData',
|
||||
method: 'post',
|
||||
data: {
|
||||
templateId: templateId,
|
||||
data: JSON.stringify(data),
|
||||
mode: saveVersionInfo.mode,
|
||||
isPrimary: saveVersionInfo.isPrimary,
|
||||
versionId: saveVersionInfo.versionId,
|
||||
objType: modelCode,
|
||||
lang: getInfo(ICP_CONFIG).lang || 'zhs',
|
||||
companyId: getInfo(ICP_CONFIG).companyId,
|
||||
connect: getInfo(ICP_CONFIG).connect,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表单设计信息
|
||||
* @param modelCode 模型id
|
||||
* @returns
|
||||
*/
|
||||
export async function getFormDesignData(templateId: string, versionId?: string) {
|
||||
// TODO: 修改成用useHttp调用
|
||||
return useHttp({
|
||||
url: '/system/modelForm/getFormDesignData',
|
||||
method: 'POST',
|
||||
data: {
|
||||
// ObjType: modelCode,
|
||||
templateId,
|
||||
versionId,
|
||||
lang: getInfo(ICP_CONFIG).lang || 'zhs',
|
||||
companyId: getInfo(ICP_CONFIG).companyId,
|
||||
connect: getInfo(ICP_CONFIG).connect,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 表单模板发布
|
||||
* @param {string} templateId 模板id
|
||||
* @param {boolean} publish 发布状态,true发布,false取消发布
|
||||
* @return {*} Promise
|
||||
*/
|
||||
export async function publishTemplate(templateId: string, publish: boolean) {
|
||||
return useHttp({
|
||||
params: {
|
||||
templateId,
|
||||
publish,
|
||||
lang: getInfo(ICP_CONFIG).lang || 'zhs',
|
||||
companyId: getInfo(ICP_CONFIG).companyId,
|
||||
connect: getInfo(ICP_CONFIG).connect,
|
||||
},
|
||||
method: 'post',
|
||||
url: '/api/system/modelForm/publish',
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 设为主版本
|
||||
* @param {string} templateId 模板id
|
||||
* @param {string} versionId 版本id
|
||||
* @return {*} Promise
|
||||
*/
|
||||
export function setMainVersion(templateId: string, versionId: string) {
|
||||
return useHttp({
|
||||
params: {
|
||||
templateId,
|
||||
versionId,
|
||||
lang: getInfo(ICP_CONFIG).lang || 'zhs',
|
||||
companyId: getInfo(ICP_CONFIG).companyId,
|
||||
connect: getInfo(ICP_CONFIG).connect,
|
||||
},
|
||||
method: 'post',
|
||||
url: '/api/system/modelForm/setMain',
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @description: 获取模型中表单模板的数量
|
||||
* @param {string} objectType 模型名
|
||||
* @return {*}
|
||||
*/
|
||||
export function getModelTemplateNum(objectType: string) {
|
||||
return useHttp({
|
||||
url: '/api/system/modelForm/modelTableValueCount',
|
||||
method: 'post',
|
||||
params: {
|
||||
objectType,
|
||||
lang: getInfo(ICP_CONFIG).lang || 'zhs',
|
||||
companyId: getInfo(ICP_CONFIG).companyId,
|
||||
connect: getInfo(ICP_CONFIG).connect,
|
||||
},
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @description: 获取表单模型下可用的-表单模板id
|
||||
* @param {string} objectType 表单模型
|
||||
* @return {*}
|
||||
*/
|
||||
export function getModelDesignList(objectType: string) {
|
||||
return useHttp({
|
||||
url: '/api/system/modelForm/getModelDesignList',
|
||||
method: 'POST',
|
||||
params: {
|
||||
objectType,
|
||||
lang: getInfo(ICP_CONFIG).lang || 'zhs',
|
||||
companyId: getInfo(ICP_CONFIG).companyId,
|
||||
connect: getInfo(ICP_CONFIG).connect,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 删除表单实例
|
||||
* @param {string} objectId 表单实例id
|
||||
* @return {*}
|
||||
*/
|
||||
export function deleteFbObjectData(objectId: string) {
|
||||
return useHttp({
|
||||
url: '/api/system/modelForm/deleteFbObjectData',
|
||||
method: 'post',
|
||||
params: {
|
||||
objectId,
|
||||
lang: getInfo(ICP_CONFIG).lang || 'zhs',
|
||||
companyId: getInfo(ICP_CONFIG).companyId,
|
||||
connect: getInfo(ICP_CONFIG).connect,
|
||||
},
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @description: 导出表单
|
||||
* @param {*} id 表单id
|
||||
* @param {*} fileName 文件名
|
||||
* @return {*} void
|
||||
*/
|
||||
export function exportFormFile(id, fileName) {
|
||||
const url = '/api/system/modelForm/exportExcel?param=';
|
||||
const param = {
|
||||
formDataId: id,
|
||||
lang: getInfo(ICP_CONFIG).lang || 'zhs',
|
||||
companyId: getInfo(ICP_CONFIG).companyId,
|
||||
connect: getInfo(ICP_CONFIG).connect,
|
||||
};
|
||||
window.open(url + Base64.encode(JSON.stringify(param)));
|
||||
// Http.get<any>({
|
||||
// url: url + Base64.encode(JSON.stringify(param)),
|
||||
// responseType: 'blob',
|
||||
// }).then(data => {
|
||||
// if (data.code === 200) {
|
||||
// const content = data.data;
|
||||
// const blob = new Blob([content]);
|
||||
// if ('download' in document.createElement('a')) {
|
||||
// const elink = document.createElement('a');
|
||||
// elink.download = fileName;
|
||||
// elink.style.display = 'none';
|
||||
// elink.href = URL.createObjectURL(blob);
|
||||
// document.body.appendChild(elink);
|
||||
// elink.click();
|
||||
// URL.revokeObjectURL(elink.href); // 释放URL 对象
|
||||
// document.body.removeChild(elink);
|
||||
// }
|
||||
// } else {
|
||||
// message.error(data.msg);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 获取模型中的字段
|
||||
* @param {string} objectType 模型名
|
||||
* @param {string} templateId 模板id
|
||||
* @return {*}
|
||||
*/
|
||||
export function getFormUsedFields(objectType: string, templateId: string) {
|
||||
return useHttp({
|
||||
url: '/api/system/modelForm/getFormUsedFields',
|
||||
method: 'post',
|
||||
params: {
|
||||
companyId: getInfo(ICP_CONFIG)?.companyId,
|
||||
connect: getInfo(ICP_CONFIG)?.connect,
|
||||
lang: getInfo(ICP_CONFIG).lang || 'zhs',
|
||||
objectType,
|
||||
templateId,
|
||||
},
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @description: 获取表单模型列表
|
||||
* @return {*}
|
||||
*/
|
||||
export function getFormModelList() {
|
||||
return useHttp({
|
||||
url: '/api/system/modelForm/getModelListByFlowFormPermission',
|
||||
method: 'POST',
|
||||
params: {
|
||||
companyId: getInfo(ICP_CONFIG)?.companyId,
|
||||
connect: getInfo(ICP_CONFIG)?.connect,
|
||||
lang: getInfo(ICP_CONFIG)?.lang || 'zhs',
|
||||
},
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @description: 获取模型下拉选项属性值
|
||||
* @param {string} objectType 表单模型
|
||||
* @param {string} fieldName 字段名
|
||||
* @return {*}
|
||||
*/
|
||||
export function getModelEnumList(objectType: string, fieldName: string) {
|
||||
return useHttp({
|
||||
url: '/api/system/modelForm/getModelEnumList',
|
||||
method: 'post',
|
||||
params: {
|
||||
companyId: getInfo(ICP_CONFIG)?.companyId,
|
||||
connect: getInfo(ICP_CONFIG)?.connect,
|
||||
lang: getInfo(ICP_CONFIG)?.lang,
|
||||
objectType,
|
||||
fieldName,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 新建/编辑表单分类
|
||||
* @param {string} name 分类名称
|
||||
* @param {string} objectId 分类id,若有此参数则为编辑,否则为新建分类
|
||||
* @return {*}
|
||||
*/
|
||||
export function addFormCategory(name: string, objectId?: string) {
|
||||
return useHttp({
|
||||
url: '/api/system/modelForm/addFormCate',
|
||||
method: 'post',
|
||||
params: {
|
||||
companyId: getInfo(ICP_CONFIG)?.companyId,
|
||||
connect: getInfo(ICP_CONFIG)?.connect,
|
||||
lang: getInfo(ICP_CONFIG)?.lang,
|
||||
name,
|
||||
objectId,
|
||||
},
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @description: 根据分类Id删除数据
|
||||
* @param {string} objectId 分类Id
|
||||
* @return {*}
|
||||
*/
|
||||
export function deleteFormCategory(objectId: string) {
|
||||
return useHttp({
|
||||
url: '/api/system/modelForm/deleteFormCate',
|
||||
method: 'post',
|
||||
params: {
|
||||
companyId: getInfo(ICP_CONFIG)?.companyId,
|
||||
connect: getInfo(ICP_CONFIG)?.connect,
|
||||
lang: getInfo(ICP_CONFIG)?.lang,
|
||||
objectId,
|
||||
},
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @description: 添加表单到某分类
|
||||
* @param {string} objectId 分类Id
|
||||
* @param {string} modelName 模型名称
|
||||
* @return {*}
|
||||
*/
|
||||
export function addModelToCategory(objectId: string, modelName: string) {
|
||||
return useHttp({
|
||||
url: '/api/system/modelForm/addModelToCate',
|
||||
method: 'post',
|
||||
params: {
|
||||
companyId: getInfo(ICP_CONFIG)?.companyId,
|
||||
connect: getInfo(ICP_CONFIG)?.connect,
|
||||
lang: getInfo(ICP_CONFIG)?.lang,
|
||||
objectId,
|
||||
modelName,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 获取可选择的分类
|
||||
* @return {*} 返回分类列表
|
||||
*/
|
||||
export function getFormCateList(modelName?) {
|
||||
return useHttp({
|
||||
url: '/api/system/modelForm/getFormCateList ',
|
||||
method: 'post',
|
||||
params: {
|
||||
companyId: getInfo(ICP_CONFIG)?.companyId,
|
||||
connect: getInfo(ICP_CONFIG)?.connect,
|
||||
lang: getInfo(ICP_CONFIG)?.lang,
|
||||
// modelName,
|
||||
},
|
||||
});
|
||||
}
|
21
packages/icpx-workflow/src/api/typing.ts
Normal file
21
packages/icpx-workflow/src/api/typing.ts
Normal file
@ -0,0 +1,21 @@
|
||||
export interface ResponseBody<T = any> {
|
||||
message: string;
|
||||
code: number;
|
||||
data?: T | T[];
|
||||
}
|
||||
|
||||
/** 统一返回结构体 */
|
||||
|
||||
export interface PageResult<T = any> {
|
||||
data: T[];
|
||||
current?: number;
|
||||
pageSize?: number;
|
||||
total?: number;
|
||||
success: boolean;
|
||||
}
|
||||
|
||||
export interface RequestResult<T = any> {
|
||||
data: T;
|
||||
success: boolean;
|
||||
errorMessage: string;
|
||||
}
|
Reference in New Issue
Block a user