130 lines
3.8 KiB
TypeScript
130 lines
3.8 KiB
TypeScript
import { http, HttpResponse } from '@lingshu/vite-plugin-msw/msw';
|
|
|
|
const handlers = [
|
|
http.get('/api/lcdp/v1/rule/list', () => {
|
|
return HttpResponse.json({
|
|
code: '0',
|
|
data: [
|
|
{
|
|
id: '1',
|
|
name: {
|
|
'zh-CN': '规则1',
|
|
},
|
|
},
|
|
{
|
|
id: '2',
|
|
name: {
|
|
'zh-CN': '规则2',
|
|
},
|
|
},
|
|
{
|
|
id: '3',
|
|
name: {
|
|
'zh-CN': '规则啧啧啧啧规则啧啧啧啧规则啧啧啧啧规则啧啧啧啧规则啧啧啧啧规则啧啧啧啧规则啧啧啧啧3',
|
|
},
|
|
},
|
|
],
|
|
});
|
|
}),
|
|
http.get('/api/lcdp/v1/rule/detail', () => {
|
|
return HttpResponse.json({
|
|
code: '0',
|
|
data: {},
|
|
});
|
|
}),
|
|
http.post('/api/lcdp/v1/rule/delete', () => {
|
|
return HttpResponse.json({
|
|
code: '0',
|
|
data: {},
|
|
});
|
|
}),
|
|
http.post('/api/lcdp/v1/rule/save', () => {
|
|
return HttpResponse.json({
|
|
code: '0',
|
|
data: {},
|
|
});
|
|
}),
|
|
http.post('/api/lcdp/v1/rule/move', () => {
|
|
return HttpResponse.json({
|
|
code: '0',
|
|
data: {},
|
|
});
|
|
}),
|
|
http.post('/api/runtime/v1/lifecycle/mount', () => {
|
|
const mockData = [{ type: 1, targetValueList: [
|
|
{ action: 1, targetField: 'name', targetValue: true }, // 可见,
|
|
{ action: 1, targetField: 'phone', targetValue: false }, // 可见
|
|
] }, {
|
|
type: 2,
|
|
targetValueList: [
|
|
{ action: 2, targetField: 'name', targetValue: true }, // 可编辑
|
|
{ action: 2, targetField: 'phone', targetValue: false }, // 可编辑
|
|
],
|
|
}, {
|
|
type: 3,
|
|
targetValueList: [
|
|
{ action: 3, targetField: 'name', targetValue: true }, // 必填
|
|
{ action: 3, targetField: 'phone', targetValue: false }, // 必填
|
|
],
|
|
}, {
|
|
type: 4,
|
|
targetValueList: [
|
|
{ action: 4, targetField: 'name', targetValue: 'wwwd' }, // 校验提示
|
|
{ action: 4, targetField: 'phone', targetValue: '输入错误' }, // 校验提示
|
|
],
|
|
}, {
|
|
type: 5,
|
|
targetValueList: [
|
|
{ action: 5, targetField: 'name', targetValue: '张 三' }, // 赋值
|
|
{ action: 5, targetField: 'phone', targetValue: '13800138000' }, // 赋值
|
|
],
|
|
}];
|
|
return HttpResponse.json({
|
|
code: '0',
|
|
data: mockData,
|
|
});
|
|
}),
|
|
http.post('/api/runtime/v1/event', async ({ request }) => {
|
|
const { sourceKey, arg } = await request.json() as any;
|
|
let mockData: any[] = [];
|
|
const tagValue = `${arg?.[sourceKey]}`;
|
|
mockData = [{
|
|
type: 2,
|
|
targetValueList: [
|
|
{ action: 2, targetField: 'name', targetValue: ['2', '4', '6'].includes(tagValue) }, // 可编辑
|
|
{ action: 2, targetField: 'phone', targetValue: ['4'].includes(tagValue) }, // 可编辑
|
|
],
|
|
}, {
|
|
type: 3,
|
|
targetValueList: [
|
|
{ action: 3, targetField: 'name', targetValue: ['2', '4', '6'].includes(tagValue) }, // 必填
|
|
{ action: 3, targetField: 'phone', targetValue: ['2'].includes(tagValue) }, // 必填
|
|
],
|
|
}, {
|
|
type: 1,
|
|
targetValueList: [
|
|
{ action: 1, targetField: 'phone', targetValue: true }, // 可见
|
|
],
|
|
}, {
|
|
type: 5,
|
|
targetValueList: [
|
|
{ action: 5, targetField: 'name', targetValue: '王麻子' }, // 赋值
|
|
{ action: 5, targetField: 'phone', targetValue: '13800138000' }, // 赋值
|
|
],
|
|
}, {
|
|
type: 4,
|
|
targetValueList: [
|
|
{ action: 4, targetField: 'phone2', targetValue: '请换一个手机号录入' }, // 校验提示
|
|
{ action: 4, targetField: 'phone', targetValue: '咦~ 这是干嘛呢!!!' }, // 校验提示
|
|
],
|
|
}];
|
|
await new Promise(resolve => setTimeout(resolve, 200));
|
|
return HttpResponse.json({
|
|
code: '0',
|
|
data: mockData,
|
|
});
|
|
}),
|
|
];
|
|
|
|
export default handlers;
|