296 lines
8.7 KiB
TypeScript
296 lines
8.7 KiB
TypeScript
|
|
import { http, HttpResponse } from '@lingshu/vite-plugin-msw/msw';
|
||
|
|
|
||
|
|
function num(limit: number, base = 1) {
|
||
|
|
return Math.floor(Math.random() * limit + base);
|
||
|
|
}
|
||
|
|
|
||
|
|
let number = 0;
|
||
|
|
|
||
|
|
const handlers = [
|
||
|
|
// 分页获取流程列表
|
||
|
|
http.post('/api/lcdp/v1/process/page', () => {
|
||
|
|
const records = Array.from({ length: 50 }).map((_, i) => {
|
||
|
|
return {
|
||
|
|
id: `1917513599163318273${i}`,
|
||
|
|
createTime: new Date().valueOf() + i * 100000, // 创建时间戳
|
||
|
|
updateTime: new Date().valueOf() + i * 200000, // 更新时间戳
|
||
|
|
createBy: {
|
||
|
|
id: `createBy-id${i}`,
|
||
|
|
name: {
|
||
|
|
'zh-CN': `name-name${i}`,
|
||
|
|
},
|
||
|
|
}, // 创建人
|
||
|
|
updateBy: {
|
||
|
|
id: `updateBy-id${i}`,
|
||
|
|
name: {
|
||
|
|
'zh-CN': `updateBy-name${i}`,
|
||
|
|
},
|
||
|
|
}, // 更新人
|
||
|
|
appId: `stringappId${i}`,
|
||
|
|
code: `code${i}`,
|
||
|
|
name: {
|
||
|
|
'zh-CN': `流程name${i}`,
|
||
|
|
},
|
||
|
|
description: {
|
||
|
|
'zh-CN': 'description流程描述description流程描述description流程描述description流程描述description流程描述description流程描述description流程描述description流程描述description流程描述',
|
||
|
|
},
|
||
|
|
model: {
|
||
|
|
id: `model-id${i}`,
|
||
|
|
name: {
|
||
|
|
'zh-CN': `model-name${i}`,
|
||
|
|
},
|
||
|
|
},
|
||
|
|
processVersionId: `processVersionId${i}`, // 流程版本ID(当前使用的流程)
|
||
|
|
thirdProcessId: `thirdProcessId${i}`, // 第三方流程ID(流程引擎ID)
|
||
|
|
status: num(2), // 流程状态:1-未发布,2-已发布
|
||
|
|
publishTime: new Date().valueOf() + i * 300000, // 发布时间(时间戳)
|
||
|
|
published: num(3) === 1,
|
||
|
|
publishBy: {
|
||
|
|
id: `publishBy-id${i}`,
|
||
|
|
name: {
|
||
|
|
'zh-CN': `publishBy-name${i}`,
|
||
|
|
},
|
||
|
|
}, // 更新人
|
||
|
|
};
|
||
|
|
});
|
||
|
|
return HttpResponse.json({
|
||
|
|
code: '0',
|
||
|
|
message: null,
|
||
|
|
data: {
|
||
|
|
current: '1',
|
||
|
|
size: '99999',
|
||
|
|
total: records.length,
|
||
|
|
pages: '1',
|
||
|
|
records,
|
||
|
|
},
|
||
|
|
error: null,
|
||
|
|
success: true,
|
||
|
|
});
|
||
|
|
}),
|
||
|
|
|
||
|
|
// 保存流程
|
||
|
|
http.post('/api/lcdp/v1/process/save', () => {
|
||
|
|
return HttpResponse.json({
|
||
|
|
code: '0',
|
||
|
|
message: null,
|
||
|
|
data: { id: '123123123123' },
|
||
|
|
error: null,
|
||
|
|
success: true,
|
||
|
|
});
|
||
|
|
}),
|
||
|
|
// 保存流程
|
||
|
|
http.post('/api/lcdp/v1/process/trigger-config/save', () => {
|
||
|
|
return HttpResponse.json({
|
||
|
|
code: '0',
|
||
|
|
message: null,
|
||
|
|
data: { id: '123123123123' },
|
||
|
|
error: null,
|
||
|
|
success: true,
|
||
|
|
});
|
||
|
|
}),
|
||
|
|
|
||
|
|
// 保存流程
|
||
|
|
http.post('/api/lcdp/v1/process/version/save', () => {
|
||
|
|
return HttpResponse.json({
|
||
|
|
code: '0',
|
||
|
|
message: null,
|
||
|
|
data: null,
|
||
|
|
error: null,
|
||
|
|
success: true,
|
||
|
|
});
|
||
|
|
}),
|
||
|
|
// 发布流程
|
||
|
|
http.post('/api/lcdp/v1/process/publish', () => {
|
||
|
|
return HttpResponse.json({
|
||
|
|
code: '0',
|
||
|
|
message: null,
|
||
|
|
data: null,
|
||
|
|
error: null,
|
||
|
|
success: true,
|
||
|
|
});
|
||
|
|
}),
|
||
|
|
// 保存流程设计器
|
||
|
|
http.post('/api/bpm/xml/saveXMLConfig', () => {
|
||
|
|
return HttpResponse.json({
|
||
|
|
code: '0',
|
||
|
|
message: null,
|
||
|
|
data: { id: '6666666' },
|
||
|
|
error: null,
|
||
|
|
success: true,
|
||
|
|
});
|
||
|
|
}),
|
||
|
|
// 发布流程设计器
|
||
|
|
http.post('/api/bpm/xml/publishXMLConfig', () => {
|
||
|
|
return HttpResponse.json({
|
||
|
|
code: '0',
|
||
|
|
message: null,
|
||
|
|
data: { id: '7777777' },
|
||
|
|
error: null,
|
||
|
|
success: true,
|
||
|
|
});
|
||
|
|
}),
|
||
|
|
|
||
|
|
// 删除流程前校验 v0.4 TODO
|
||
|
|
http.post('/api/lcdp/v1/process/check-delete', () => {
|
||
|
|
const records = Array.from({ length: 4 }).map((_, i) => {
|
||
|
|
return {
|
||
|
|
id: `1917513599163318273${i}`,
|
||
|
|
createTime: new Date().valueOf() + i * 100000, // 创建时间戳
|
||
|
|
updateTime: new Date().valueOf() + i * 200000, // 更新时间戳
|
||
|
|
createBy: {
|
||
|
|
id: `createBy-id${i}`,
|
||
|
|
name: {
|
||
|
|
'zh-CN': `name-name${i}`,
|
||
|
|
},
|
||
|
|
}, // 创建人
|
||
|
|
updateBy: {
|
||
|
|
id: `updateBy-id${i}`,
|
||
|
|
name: {
|
||
|
|
'zh-CN': `updateBy-name${i}`,
|
||
|
|
},
|
||
|
|
}, // 更新人
|
||
|
|
appId: `stringappId${i}`,
|
||
|
|
code: `code${i}`,
|
||
|
|
name: {
|
||
|
|
'zh-CN': `流程name${i}`,
|
||
|
|
},
|
||
|
|
description: {
|
||
|
|
'zh-CN': 'description流程描述description流程描述description流程描述description流程描述description流程描述description流程描述description流程描述description流程描述description流程描述',
|
||
|
|
},
|
||
|
|
model: {
|
||
|
|
id: `model-id${i}`,
|
||
|
|
name: {
|
||
|
|
'zh-CN': `model-name${i}`,
|
||
|
|
},
|
||
|
|
},
|
||
|
|
processVersionId: `processVersionId${i}`, // 流程版本ID(当前使用的流程)
|
||
|
|
thirdProcessId: `thirdProcessId${i}`, // 第三方流程ID(流程引擎ID)
|
||
|
|
status: num(2), // 流程状态:1-未发布,2-已发布
|
||
|
|
publishTime: new Date().valueOf() + i * 300000, // 发布时间(时间戳)
|
||
|
|
published: num(3) === 1,
|
||
|
|
publishBy: {
|
||
|
|
id: `publishBy-id${i}`,
|
||
|
|
name: {
|
||
|
|
'zh-CN': `publishBy-name${i}`,
|
||
|
|
},
|
||
|
|
}, // 更新人
|
||
|
|
};
|
||
|
|
});
|
||
|
|
return HttpResponse.json({
|
||
|
|
code: '0',
|
||
|
|
message: null,
|
||
|
|
data: {
|
||
|
|
canDeleteIds: records.map(v => v.id),
|
||
|
|
},
|
||
|
|
error: null,
|
||
|
|
success: true,
|
||
|
|
});
|
||
|
|
}),
|
||
|
|
// 删除流程
|
||
|
|
http.post('/api/lcdp/v1/process/delete', () => {
|
||
|
|
return HttpResponse.json({
|
||
|
|
code: '0',
|
||
|
|
message: null,
|
||
|
|
data: null,
|
||
|
|
error: null,
|
||
|
|
success: true,
|
||
|
|
});
|
||
|
|
}),
|
||
|
|
// 分页获取流程列表
|
||
|
|
http.post('/api/lcdp/v1/process/exec-history/page', async () => {
|
||
|
|
// const params = await getPostParams(req);
|
||
|
|
number = 1;
|
||
|
|
const records = Array.from({ length: 10 }).map((_, i) => {
|
||
|
|
const nums = i + 1 + ((number - 1) * 10);
|
||
|
|
return {
|
||
|
|
id: `id${nums}`, // 流程数据ID
|
||
|
|
approvalStatus: num(4), // 审批状态:1-进行中,2-已完成,3-已回退,4-异常
|
||
|
|
currentNode: `currentNode${nums}`, // 当前节点
|
||
|
|
approvalBy: `approvalBy${nums}`, // 当前节点审批人
|
||
|
|
applyBy: `applyBy${nums}`, // 发起人
|
||
|
|
applyTime: new Date().valueOf() + nums * 300000, // 发起时间
|
||
|
|
};
|
||
|
|
});
|
||
|
|
return HttpResponse.json({
|
||
|
|
code: '0',
|
||
|
|
message: null,
|
||
|
|
data: {
|
||
|
|
current: number,
|
||
|
|
size: 50,
|
||
|
|
total: 500,
|
||
|
|
pages: 5,
|
||
|
|
records,
|
||
|
|
},
|
||
|
|
error: null,
|
||
|
|
success: true,
|
||
|
|
});
|
||
|
|
}),
|
||
|
|
// 获取流程详情
|
||
|
|
http.get('/api/lcdp/v1/process/detail', () => {
|
||
|
|
return HttpResponse.json({
|
||
|
|
code: '0',
|
||
|
|
message: null,
|
||
|
|
data: {
|
||
|
|
id: `1917513599163318273$111`,
|
||
|
|
createTime: new Date().valueOf() + 1 * 100000, // 创建时间戳
|
||
|
|
updateTime: new Date().valueOf() + 1 * 200000, // 更新时间戳
|
||
|
|
createBy: {
|
||
|
|
id: `createBy-id111`,
|
||
|
|
name: `name-name111`,
|
||
|
|
}, // 创建人
|
||
|
|
updateBy: {
|
||
|
|
id: `updateBy-id111`,
|
||
|
|
name: `updateBy-name111`,
|
||
|
|
}, // 更新人
|
||
|
|
appId: `730324248886138488`,
|
||
|
|
code: `way_af_for_think`,
|
||
|
|
name: {
|
||
|
|
'zh-CN': `流程name99999999999`,
|
||
|
|
},
|
||
|
|
description: {
|
||
|
|
'zh-CN': 'description流程描述description流程描述description流程描述description流程描述description流程描述description流程描述description流程描述description流程描述description流程描述',
|
||
|
|
},
|
||
|
|
model: {
|
||
|
|
id: `752044299774259473`,
|
||
|
|
name: {
|
||
|
|
'zh-CN': `model-name111`,
|
||
|
|
},
|
||
|
|
},
|
||
|
|
processVersionId: `processVersionId111`, // 流程版本ID(当前使用的流程)
|
||
|
|
thirdProcessId: `thirdProcessId111`, // 第三方流程ID(流程引擎ID)
|
||
|
|
status: num(2), // 流程状态:1-未发布,2-已发布
|
||
|
|
publishTime: new Date().valueOf() + 1 * 300000, // 发布时间(时间戳)
|
||
|
|
publishBy: {
|
||
|
|
id: `publishBy-id111`,
|
||
|
|
name: `publishBy-name111`,
|
||
|
|
}, // 更新人
|
||
|
|
|
||
|
|
preconditionConditionGroup: '[{"type":"group","operator":"OR","children":[{"type":"condition","operator":"AND","condition":{"fieldName":"create_time","innerOperator":"EQ","valueType":"FIXED_VALUE","values":[1756656000000]}}]}]',
|
||
|
|
preconditionExpressions: '',
|
||
|
|
conditionType: 1,
|
||
|
|
triggerRuleId: 'triggerRuleId123',
|
||
|
|
fieldInfoMap: {
|
||
|
|
key: {
|
||
|
|
namePath: {
|
||
|
|
key: 'et id occaecat proident',
|
||
|
|
},
|
||
|
|
description: {
|
||
|
|
key: 'laborum magna occaecat in reprehenderit',
|
||
|
|
},
|
||
|
|
deleted: true,
|
||
|
|
},
|
||
|
|
},
|
||
|
|
// triggerId: ['jump3'],
|
||
|
|
ruleTriggerTimings: [
|
||
|
|
{ source: 'process,custom2,jump3', type: 3 },
|
||
|
|
],
|
||
|
|
},
|
||
|
|
error: null,
|
||
|
|
success: true,
|
||
|
|
});
|
||
|
|
}),
|
||
|
|
|
||
|
|
];
|
||
|
|
|
||
|
|
export default handlers;
|