Skip to content

Commit 4b8f520

Browse files
authored
Add files via upload
1 parent f6fa631 commit 4b8f520

26 files changed

+99447
-0
lines changed

ui/WorkOrder/LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Alipay.inc
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

ui/WorkOrder/jest.config.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
testURL: 'http://localhost:8000',
3+
verbose: false,
4+
extraSetupFiles: ['./tests/setupTests.js'],
5+
globals: {
6+
ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION: false,
7+
localStorage: null,
8+
},
9+
};

ui/WorkOrder/jsconfig.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"compilerOptions": {
3+
"jsx": "react-jsx",
4+
"emitDecoratorMetadata": true,
5+
"experimentalDecorators": true,
6+
"baseUrl": ".",
7+
"paths": {
8+
"@/*": ["./src/*"]
9+
}
10+
}
11+
}

ui/WorkOrder/mock/listTableList.ts

+174
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
import { Request, Response } from 'express';
2+
import moment from 'moment';
3+
import { parse } from 'url';
4+
5+
// mock tableListDataSource
6+
const genList = (current: number, pageSize: number) => {
7+
const tableListDataSource: API.RuleListItem[] = [];
8+
9+
for (let i = 0; i < pageSize; i += 1) {
10+
const index = (current - 1) * 10 + i;
11+
tableListDataSource.push({
12+
key: index,
13+
disabled: i % 6 === 0,
14+
href: 'https://ant.design',
15+
avatar: [
16+
'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
17+
'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
18+
][i % 2],
19+
name: `TradeCode ${index}`,
20+
owner: '曲丽丽',
21+
desc: '这是一段描述',
22+
callNo: Math.floor(Math.random() * 1000),
23+
status: Math.floor(Math.random() * 10) % 4,
24+
updatedAt: moment().format('YYYY-MM-DD'),
25+
createdAt: moment().format('YYYY-MM-DD'),
26+
progress: Math.ceil(Math.random() * 100),
27+
});
28+
}
29+
tableListDataSource.reverse();
30+
return tableListDataSource;
31+
};
32+
33+
let tableListDataSource = genList(1, 100);
34+
35+
function getRule(req: Request, res: Response, u: string) {
36+
let realUrl = u;
37+
if (!realUrl || Object.prototype.toString.call(realUrl) !== '[object String]') {
38+
realUrl = req.url;
39+
}
40+
const { current = 1, pageSize = 10 } = req.query;
41+
const params = parse(realUrl, true).query as unknown as API.PageParams &
42+
API.RuleListItem & {
43+
sorter: any;
44+
filter: any;
45+
};
46+
47+
let dataSource = [...tableListDataSource].slice(
48+
((current as number) - 1) * (pageSize as number),
49+
(current as number) * (pageSize as number),
50+
);
51+
if (params.sorter) {
52+
const sorter = JSON.parse(params.sorter);
53+
dataSource = dataSource.sort((prev, next) => {
54+
let sortNumber = 0;
55+
Object.keys(sorter).forEach((key) => {
56+
if (sorter[key] === 'descend') {
57+
if (prev[key] - next[key] > 0) {
58+
sortNumber += -1;
59+
} else {
60+
sortNumber += 1;
61+
}
62+
return;
63+
}
64+
if (prev[key] - next[key] > 0) {
65+
sortNumber += 1;
66+
} else {
67+
sortNumber += -1;
68+
}
69+
});
70+
return sortNumber;
71+
});
72+
}
73+
if (params.filter) {
74+
const filter = JSON.parse(params.filter as any) as {
75+
[key: string]: string[];
76+
};
77+
if (Object.keys(filter).length > 0) {
78+
dataSource = dataSource.filter((item) => {
79+
return Object.keys(filter).some((key) => {
80+
if (!filter[key]) {
81+
return true;
82+
}
83+
if (filter[key].includes(`${item[key]}`)) {
84+
return true;
85+
}
86+
return false;
87+
});
88+
});
89+
}
90+
}
91+
92+
if (params.name) {
93+
dataSource = dataSource.filter((data) => data?.name?.includes(params.name || ''));
94+
}
95+
const result = {
96+
data: dataSource,
97+
total: tableListDataSource.length,
98+
success: true,
99+
pageSize,
100+
current: parseInt(`${params.current}`, 10) || 1,
101+
};
102+
103+
return res.json(result);
104+
}
105+
106+
function postRule(req: Request, res: Response, u: string, b: Request) {
107+
let realUrl = u;
108+
if (!realUrl || Object.prototype.toString.call(realUrl) !== '[object String]') {
109+
realUrl = req.url;
110+
}
111+
112+
const body = (b && b.body) || req.body;
113+
const { method, name, desc, key } = body;
114+
115+
switch (method) {
116+
/* eslint no-case-declarations:0 */
117+
case 'delete':
118+
tableListDataSource = tableListDataSource.filter((item) => key.indexOf(item.key) === -1);
119+
break;
120+
case 'post':
121+
(() => {
122+
const i = Math.ceil(Math.random() * 10000);
123+
const newRule: API.RuleListItem = {
124+
key: tableListDataSource.length,
125+
href: 'https://ant.design',
126+
avatar: [
127+
'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
128+
'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
129+
][i % 2],
130+
name,
131+
owner: '曲丽丽',
132+
desc,
133+
callNo: Math.floor(Math.random() * 1000),
134+
status: Math.floor(Math.random() * 10) % 2,
135+
updatedAt: moment().format('YYYY-MM-DD'),
136+
createdAt: moment().format('YYYY-MM-DD'),
137+
progress: Math.ceil(Math.random() * 100),
138+
};
139+
tableListDataSource.unshift(newRule);
140+
return res.json(newRule);
141+
})();
142+
return;
143+
144+
case 'update':
145+
(() => {
146+
let newRule = {};
147+
tableListDataSource = tableListDataSource.map((item) => {
148+
if (item.key === key) {
149+
newRule = { ...item, desc, name };
150+
return { ...item, desc, name };
151+
}
152+
return item;
153+
});
154+
return res.json(newRule);
155+
})();
156+
return;
157+
default:
158+
break;
159+
}
160+
161+
const result = {
162+
list: tableListDataSource,
163+
pagination: {
164+
total: tableListDataSource.length,
165+
},
166+
};
167+
168+
res.json(result);
169+
}
170+
171+
export default {
172+
'GET /api/rule': getRule,
173+
'POST /api/rule': postRule,
174+
};

ui/WorkOrder/mock/notices.ts

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import { Request, Response } from 'express';
2+
3+
const getNotices = (req: Request, res: Response) => {
4+
res.json({
5+
data: [
6+
{
7+
id: '000000001',
8+
avatar: 'https://mdn.alipayobjects.com/yuyan_qk0oxh/afts/img/MSbDR4FR2MUAAAAAAAAAAAAAFl94AQBr',
9+
title: '你收到了 14 份新周报',
10+
datetime: '2017-08-09',
11+
type: 'notification',
12+
},
13+
{
14+
id: '000000002',
15+
avatar: 'https://mdn.alipayobjects.com/yuyan_qk0oxh/afts/img/hX-PTavYIq4AAAAAAAAAAAAAFl94AQBr',
16+
title: '你推荐的 曲妮妮 已通过第三轮面试',
17+
datetime: '2017-08-08',
18+
type: 'notification',
19+
},
20+
{
21+
id: '000000003',
22+
avatar: 'https://mdn.alipayobjects.com/yuyan_qk0oxh/afts/img/jHX5R5l3QjQAAAAAAAAAAAAAFl94AQBr',
23+
title: '这种模板可以区分多种通知类型',
24+
datetime: '2017-08-07',
25+
read: true,
26+
type: 'notification',
27+
},
28+
{
29+
id: '000000004',
30+
avatar: 'https://mdn.alipayobjects.com/yuyan_qk0oxh/afts/img/Wr4mQqx6jfwAAAAAAAAAAAAAFl94AQBr',
31+
title: '左侧图标用于区分不同的类型',
32+
datetime: '2017-08-07',
33+
type: 'notification',
34+
},
35+
{
36+
id: '000000005',
37+
avatar: 'https://mdn.alipayobjects.com/yuyan_qk0oxh/afts/img/Mzj_TbcWUj4AAAAAAAAAAAAAFl94AQBr',
38+
title: '内容不要超过两行字,超出时自动截断',
39+
datetime: '2017-08-07',
40+
type: 'notification',
41+
},
42+
{
43+
id: '000000006',
44+
avatar: 'https://mdn.alipayobjects.com/yuyan_qk0oxh/afts/img/eXLzRbPqQE4AAAAAAAAAAAAAFl94AQBr',
45+
title: '曲丽丽 评论了你',
46+
description: '描述信息描述信息描述信息',
47+
datetime: '2017-08-07',
48+
type: 'message',
49+
clickClose: true,
50+
},
51+
{
52+
id: '000000007',
53+
avatar: 'https://mdn.alipayobjects.com/yuyan_qk0oxh/afts/img/w5mRQY2AmEEAAAAAAAAAAAAAFl94AQBr',
54+
title: '朱偏右 回复了你',
55+
description: '这种模板用于提醒谁与你发生了互动,左侧放『谁』的头像',
56+
datetime: '2017-08-07',
57+
type: 'message',
58+
clickClose: true,
59+
},
60+
{
61+
id: '000000008',
62+
avatar: 'https://mdn.alipayobjects.com/yuyan_qk0oxh/afts/img/wPadR5M9918AAAAAAAAAAAAAFl94AQBr',
63+
title: '标题',
64+
description: '这种模板用于提醒谁与你发生了互动,左侧放『谁』的头像',
65+
datetime: '2017-08-07',
66+
type: 'message',
67+
clickClose: true,
68+
},
69+
{
70+
id: '000000009',
71+
title: '任务名称',
72+
description: '任务需要在 2017-01-12 20:00 前启动',
73+
extra: '未开始',
74+
status: 'todo',
75+
type: 'event',
76+
},
77+
{
78+
id: '000000010',
79+
title: '第三方紧急代码变更',
80+
description: '冠霖提交于 2017-01-06,需在 2017-01-07 前完成代码变更任务',
81+
extra: '马上到期',
82+
status: 'urgent',
83+
type: 'event',
84+
},
85+
{
86+
id: '000000011',
87+
title: '信息安全考试',
88+
description: '指派竹尔于 2017-01-09 前完成更新并发布',
89+
extra: '已耗时 8 天',
90+
status: 'doing',
91+
type: 'event',
92+
},
93+
{
94+
id: '000000012',
95+
title: 'ABCD 版本发布',
96+
description: '冠霖提交于 2017-01-06,需在 2017-01-07 前完成代码变更任务',
97+
extra: '进行中',
98+
status: 'processing',
99+
type: 'event',
100+
},
101+
],
102+
});
103+
};
104+
105+
export default {
106+
'GET /api/notices': getNotices,
107+
};

ui/WorkOrder/mock/route.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default {
2+
'/api/auth_routes': {
3+
'/form/advanced-form': { authority: ['admin', 'user'] },
4+
},
5+
};

0 commit comments

Comments
 (0)