Sanakey
3 天以前 b5c1614fe473330ceca8b7cff0f1802e19bd5039
提交 | 用户 | age
ec4248 1 import { MockMethod } from 'vite-plugin-mock';
S 2 import { Random } from 'mockjs';
3 import { resultPageSuccess } from '../_util';
4
5 function getRandomPics(count = 10): string[] {
6   const arr: string[] = [];
7   for (let i = 0; i < count; i++) {
8     arr.push(Random.image('800x600', Random.color(), Random.color(), Random.title()));
9   }
10   return arr;
11 }
12
13 const demoList = (() => {
14   const result: any[] = [];
15   for (let index = 0; index < 200; index++) {
16     result.push({
17       id: `${index}`,
cb1651 18       color: Random.color(),
ec4248 19       cluesName: '@ctitle()',
S 20       formId: `@integer(100000, 999999)`,
21       archiveTime: '@datetime',
22       statusId: '@integer()',
23       status: '@ctitle()',
24       followUpTime: '@datetime',
25       failType: '@integer()',
26       failStatus: '@integer()',
27       failStatusName: '@ctitle()',
28       failReason: '@ctitle()',
29       privateTime: '@datetime',
30       publicTime: '@datetime',
31       isPublic: '@boolean()',
32       star: '@integer(1-5)',
33       nextFollowUpTime: '@datetime',
34       duplicateFlag: '@boolean()',
35       tagList: [{name:'@cname()',color:Random.color()}, {name:'@cname()',color:Random.color()}],
36       homepage: '@url()',
37       originList: `$range(10)`,
38       shortName: '@cname()',
39       country: '@region()',
40       province: '@province()',
41       city: '@city()',
42       corporate: '@ctitle()',
43       bizType: '@ctitle()',
44       telAreaCode: '@integer(100, 999)',
45       tel: '@integer(100000, 199999)',
46       intentionLevel: '@ctitle()',
47       annualProcurement: '@float()',
48       timezone: '@ctitle()',
49       address: '@county()',
50       adKeyword: '@ctitle()',
51       imageList: getRandomPics(Math.ceil(Math.random() * 3) + 1),
52       hdmeno: '@cname()',
53       scaleId: '@character()',
54       seller: '@cname()',
55       inquiryOrigin: '@ctitle()',
56       categoryIds: `@Integer(100, 999)`,
57       inquiryCountry: '@city()',
58       pinFlag: '@boolean()',
59
60       email: '@email()',
61       ip: '@ip()',
62       beginTime: '@datetime',
63       endTime: '@datetime',
64       name: '@cname()',
65       name1: '@cname()',
66       name2: '@cname()',
67       name3: '@cname()',
68       name4: '@cname()',
69       name5: '@cname()',
70       name6: '@cname()',
71       name7: '@cname()',
72       name8: '@cname()',
73       radio1: `选项${index + 1}`,
74       radio2: `选项${index + 1}`,
75       radio3: `选项${index + 1}`,
76       avatar: Random.image('400x400', Random.color(), Random.color(), Random.first()),
77       imgArr: getRandomPics(Math.ceil(Math.random() * 3) + 1),
78       date: `@date('yyyy-MM-dd')`,
79       time: `@time('HH:mm')`,
80       'no|100000-10000000': 100000,
81       'status|1': ['normal', 'enable', 'disable'],
82     });
83   }
84   return result;
85 })();
86
87 export default [
88   {
89     // url: '/basic-api/table/getDemoList',
b5c161 90     url: '/basic-api/crm/clues/table',
ec4248 91     timeout: 100,
S 92     method: 'get',
93     response: ({ query }) => {
94       const { page = 1, pageSize = 20 } = query;
95       return resultPageSuccess(page, pageSize, demoList);
96     },
97   },
98 ] as MockMethod[];