_other.ts 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917
  1. import { MockRequest, MockStatusError } from '@delon/mock';
  2. import { deepCopy } from '@delon/util';
  3. import format from 'date-fns/format';
  4. import getDaysInMonth from 'date-fns/getDaysInMonth';
  5. import startOfMonth from 'date-fns/startOfMonth';
  6. import { Random } from 'mockjs';
  7. import { genArr, genBigMp, genColorName, genData, genLabel, genMp, genName, genTag } from './utils';
  8. let ID = 1;
  9. const DATA: any = {
  10. kanban: null,
  11. task: null,
  12. email: null,
  13. project: null,
  14. client: null,
  15. contact: null,
  16. pricing: null,
  17. billing: null,
  18. course: null,
  19. chat: null,
  20. gallery: null,
  21. article: null,
  22. voting: null,
  23. invoice: null,
  24. faq: null,
  25. calendar: null,
  26. quick: null,
  27. dd: null
  28. };
  29. function getIdx(type: string, id: number): number {
  30. id = +id;
  31. const idx = DATA[type].findIndex((w: any) => w.id === id);
  32. if (idx === -1) {
  33. throw new MockStatusError(404);
  34. }
  35. return idx;
  36. }
  37. function save(type: string, body: any): any {
  38. const id = body.id || 0;
  39. if (id > 0) {
  40. const idx = getIdx(type, id);
  41. DATA[type][idx] = { ...DATA[type][idx], ...body };
  42. return { msg: 'ok', item: DATA[type][idx], type: 'edit' };
  43. }
  44. const item = { ...body, id: DATA[type].sort((a: any, b: any) => b.id - a.id)[0].id + 1 };
  45. (DATA[type] as any[]).splice(0, 0, item);
  46. return { msg: 'ok', item, type: 'add' };
  47. }
  48. function del(type: string, p: any): any {
  49. const cid = +(p.cid || '0');
  50. let list: any[] = DATA[type];
  51. if (cid > 0) {
  52. list = DATA[type].find((w: any) => w.id === cid).list;
  53. }
  54. const idx = list.findIndex(w => w.id === p.id);
  55. list.splice(idx, 1);
  56. return { msg: 'ok' };
  57. }
  58. function genHtml(): string {
  59. return `<p>${new Array(Random.natural(1, 3))
  60. .fill('')
  61. .map(v => Random.sentence())
  62. .join('</p><p>')}</p>`;
  63. }
  64. function attachements(): any {
  65. return new Array(Random.natural(2, 6)).fill({}).map((v, idx) => {
  66. const item = {
  67. url: Random.url(),
  68. type: genArr(['jpg', 'zip', 'pdf']),
  69. filename: Random.name(false),
  70. size: genArr(['100KB', '980KB', '1.56MB'])
  71. };
  72. if (item.type === 'jpg') {
  73. item.url = genBigMp();
  74. }
  75. return item;
  76. });
  77. }
  78. function genPage(type: string, queryString: any, qField: string = 'name'): any {
  79. const pi = +(queryString.pi || 1);
  80. const ps = +(queryString.ps || 10);
  81. // data
  82. let data = deepCopy(DATA[type]);
  83. if (queryString.q) {
  84. data = data.filter((data: any) => data[qField].indexOf(queryString.q) > -1);
  85. }
  86. return {
  87. total: data.length,
  88. list: data.slice((pi - 1) * ps, pi * ps)
  89. };
  90. }
  91. // #region kanban
  92. function kanbanList(): any {
  93. if (DATA.kanban) {
  94. return DATA.kanban;
  95. }
  96. const res: any[] = [
  97. {
  98. id: 1,
  99. title: 'To Do',
  100. list: [],
  101. color: '#fadb14',
  102. icon: 'warning'
  103. },
  104. { id: 2, title: 'In progress', color: '#1890ff', icon: 'tool', list: [] },
  105. { id: 3, title: 'Done', color: '#52c41a', icon: 'check-circle', list: [] },
  106. { id: 4, title: 'Gone', color: '#f5222d', icon: 'delete', list: [] }
  107. ];
  108. for (const i of res) {
  109. i.list = new Array(Random.natural(2, 6)).fill({}).map((v, idx) => ({
  110. id: idx + 1,
  111. title: Random.ctitle(3, 4),
  112. content: Random.ctitle(0, 50),
  113. attachement: Random.boolean() && Random.boolean() && Random.boolean()
  114. }));
  115. }
  116. // new
  117. if (res[0].list.length > 0) {
  118. res[0].list[Random.natural(0, res[0].list.length - 1)].label = {
  119. color: 'green',
  120. text: 'Clients'
  121. };
  122. }
  123. if (res[1].list.length > 0) {
  124. res[1].list[Random.natural(0, res[1].list.length - 1)].label = {
  125. color: 'red',
  126. text: 'Important'
  127. };
  128. }
  129. if (res[2].list.length > 0) {
  130. res[2].list[Random.natural(0, res[2].list.length - 1)].label = {
  131. color: 'blue',
  132. text: 'Other'
  133. };
  134. }
  135. // labels
  136. DATA.kanban = res;
  137. return res;
  138. }
  139. // #endregion
  140. // #region task
  141. function taskList(): any {
  142. if (DATA.task) {
  143. return DATA.task;
  144. }
  145. const res: any[] = [
  146. { id: 1, title: 'Today', list: [] },
  147. { id: 2, title: 'Tomorrow', list: [] },
  148. { id: 3, title: 'Next week', list: [] }
  149. ];
  150. for (const i of res) {
  151. i.list = new Array(Random.natural(2, 8)).fill({}).map((v, idx) => ({
  152. id: idx + 1,
  153. title: Random.ctitle(3, 16),
  154. due: i.id === 1 && Random.boolean() ? `${Random.natural(1, 59)} ${Random.boolean() ? 'mins' : 'hours'} left` : null
  155. }));
  156. }
  157. // new
  158. if (res[0].list.length > 0) {
  159. res[0].list[Random.natural(0, res[0].list.length - 1)].label = {
  160. color: 'green',
  161. text: 'Clients'
  162. };
  163. }
  164. if (res[1].list.length > 0) {
  165. res[1].list[Random.natural(0, res[1].list.length - 1)].label = {
  166. color: 'red',
  167. text: 'Important'
  168. };
  169. res[0].list[Random.natural(0, res[0].list.length - 1)].done = true;
  170. }
  171. if (res[2].list.length > 0) {
  172. res[2].list[Random.natural(0, res[2].list.length - 1)].label = {
  173. color: 'blue',
  174. text: 'Other'
  175. };
  176. res[0].list[Random.natural(0, res[0].list.length - 1)].done = true;
  177. }
  178. // labels
  179. DATA.task = res;
  180. return res;
  181. }
  182. // #endregion
  183. // #region email
  184. function emailList(queryString: any): any {
  185. if (DATA.email) {
  186. return genPage('email', queryString, 'subject');
  187. }
  188. const res: any[] = new Array(20).fill({}).map((v, idx) => ({
  189. id: ID++,
  190. from: Random.email(),
  191. from_name: genName(),
  192. to: Random.email(),
  193. to_name: Random.name(),
  194. cc: [Random.email(), Random.email()],
  195. subject: Random.title(1, 6),
  196. body: Random.paragraph(),
  197. read: idx % 2 === 0 && Random.boolean(),
  198. star: Random.boolean(),
  199. label: genLabel(),
  200. attach: idx % 3 === 0 && Random.boolean(),
  201. time: `1${Random.boolean() ? 'h' : 'd'} ago`
  202. }));
  203. // labels
  204. DATA.email = res;
  205. return genPage('email', queryString, 'subject');
  206. }
  207. function emailGet(id: number): any {
  208. const idx = getIdx('email', id || 0);
  209. const item = { ...DATA.email[idx], mp: genMp(), desc: genHtml(), attachements: attachements() };
  210. return item;
  211. }
  212. // #endregion
  213. // #region project
  214. function projectList(): any {
  215. if (DATA.project) {
  216. return DATA.project;
  217. }
  218. const res: any[] = new Array(5).fill({}).map((v, idx) => ({
  219. id: idx + 1,
  220. title: genArr(['UI update', 'Web Design', 'Pro Design', 'Ng Alain', 'Delon', 'SEO']),
  221. status: idx % 2 ? genArr(['active', 'pending', 'complete']) : 'active',
  222. task: {
  223. process: Random.natural(1, 100),
  224. opened: Random.natural(1, 100),
  225. completed: Random.natural(1, 100)
  226. },
  227. remark: Random.title(5, 10),
  228. created: Random.date(),
  229. deadline: Random.date(),
  230. tean: new Array(Random.natural(1, 6)).fill({}).map(() => ({
  231. name: genName(),
  232. mp: genMp()
  233. })),
  234. leaders: new Array(Random.natural(1, 2)).fill({}).map(() => ({
  235. name: genName(),
  236. mp: genMp()
  237. })),
  238. participants: new Array(Random.natural(1, 6)).fill({}).map(() => ({
  239. name: Random.name(),
  240. mp: genMp()
  241. }))
  242. }));
  243. // labels
  244. DATA.project = res;
  245. return res;
  246. }
  247. function projectGet(id: number): any {
  248. const idx = getIdx('project', id || 0);
  249. const item = {
  250. ...DATA.project[idx],
  251. user_name: genName(),
  252. desc: genHtml(),
  253. attachements: attachements(),
  254. tasks: DATA.task,
  255. discussions: new Array(Random.natural(3, 8)).fill({}).map((v, idx) => ({
  256. id: idx + 1,
  257. user_avatar: genMp(),
  258. user_name: genName(),
  259. time: Random.datetime(),
  260. content: Random.paragraph(1, 1)
  261. })),
  262. activities: new Array(Random.natural(3, 12)).fill({}).map((v, idx) => ({
  263. id: idx + 1,
  264. user_avatar: genMp(),
  265. user_name: genName(),
  266. time: Random.datetime(),
  267. type: idx % 2 === 0 ? genArr(['add', 'completed', 'assigned']) : 'push',
  268. commit: Random.natural(10000, 99999),
  269. assigne_name: Random.name(),
  270. message: Random.title()
  271. }))
  272. };
  273. return item;
  274. }
  275. // #endregion
  276. // #region billing
  277. function billingList(queryString: any): any {
  278. if (DATA.billing) {
  279. return genPage('billing', queryString, 'client');
  280. }
  281. const res: any[] = new Array(11).fill({}).map((v, idx) => ({
  282. id: idx + 1,
  283. order: `FR0${Random.natural(10, 99)}`,
  284. client: genArr(['Google', 'Alibaba', 'Tencent']),
  285. fee: Random.float(0, 9.0),
  286. amount: Random.float(0.1, 99999.0),
  287. date: Random.now('day'),
  288. status: idx % 2 ? genArr(['Completed', 'Pending', 'Rejected']) : 'Completed',
  289. auth_code: Random.natural(100000000),
  290. address: (Random as any).county(true),
  291. first_name: Random.first(),
  292. last_name: Random.last(),
  293. country: 'China'
  294. }));
  295. // labels
  296. DATA.billing = res;
  297. return genPage('billing', queryString, 'client');
  298. }
  299. function billingGet(id: number): any {
  300. const idx = getIdx('billing', id || 0);
  301. const item = {
  302. ...DATA.billing[idx],
  303. messages: new Array(Random.natural(0, 5)).fill({}).map((v, idx) => ({
  304. id: idx + 1,
  305. time: `${Random.natural(1, 6)} day ago`,
  306. message: Random.paragraph(1, 1)
  307. }))
  308. };
  309. return item;
  310. }
  311. // #endregion
  312. // #region contact
  313. function contactList(queryString: any): any {
  314. if (DATA.contact) {
  315. return genPage('contact', queryString, 'contact');
  316. }
  317. const res: any[] = new Array(11).fill({}).map((v, idx) => ({
  318. id: idx + 1,
  319. mp: genMp(),
  320. name: genName(),
  321. user_name: Random.name(false),
  322. company: Random.title(1, 3),
  323. email: Random.email(),
  324. tel: Random.natural(10000000000, 16000000000)
  325. }));
  326. // labels
  327. DATA.contact = res;
  328. return genPage('contact', queryString, 'company');
  329. }
  330. // #endregion
  331. // #region pricing
  332. function pricingList(): any {
  333. if (DATA.pricing) {
  334. return DATA.pricing;
  335. }
  336. const res: any = {
  337. prices: [
  338. {
  339. id: 1,
  340. title: 'Basic',
  341. icon: 'shop',
  342. mo: 12,
  343. yr: 12 * 12,
  344. user: 5,
  345. project: 5,
  346. space: '100GB'
  347. },
  348. {
  349. id: 2,
  350. title: 'Company',
  351. icon: 'bank',
  352. mo: 25,
  353. yr: 25 * 12,
  354. user: 30,
  355. project: 150,
  356. space: '300GB'
  357. },
  358. {
  359. id: 3,
  360. title: 'Enterprise',
  361. icon: 'crown',
  362. mo: 50,
  363. yr: 50 * 12,
  364. user: -1,
  365. project: -1,
  366. space: '1000GB'
  367. }
  368. ],
  369. faq: [
  370. {
  371. q: 'Can I cancel at anytime?',
  372. a: 'Yes, you can cancel anytime no questions are asked while you cancel but we would highly appreciate if you will give us some feedback.'
  373. },
  374. {
  375. q: 'My team has credits. How do we use them?',
  376. a: 'Once your team signs up for a subscription plan. enim eiusmod high life accusamus eoset dignissimos.'
  377. },
  378. {
  379. q: `How does Front's pricing work?`,
  380. a: 'Our subscriptions are tiered. based on the number of people enim eiusmod high life accusamus terry richardson ad squid.'
  381. },
  382. {
  383. q: 'How secure is Front?',
  384. a: 'Protecting the data you trust to Front is our first priority. at vero eoset dignissimos ducimus qui blanditiis.'
  385. },
  386. {
  387. q: 'Do you offer discounts?',
  388. a: `We've built in discounts at each tier for teams. leggings occaecat craft beer farm-to-table. raw denim aesthetic synth nesciunt.`
  389. },
  390. {
  391. q: 'What is your refund policy?',
  392. a: 'We do not offer refunds apart leggings occaecat craft beer farm-to-table. raw leggings occaecat craft.'
  393. }
  394. ]
  395. };
  396. // labels
  397. DATA.pricing = res;
  398. return res;
  399. }
  400. // #endregion
  401. // #region client
  402. function clientList(queryString: any): any {
  403. if (DATA.client) {
  404. return genPage('client', queryString, 'company');
  405. }
  406. const res: any[] = new Array(11).fill({}).map((v, idx) => ({
  407. id: idx + 1,
  408. mp: genMp(),
  409. name: genName(),
  410. user_name: Random.name(false),
  411. company: Random.title(1, 3),
  412. email: Random.email(),
  413. tel: Random.natural(10000000000, 16000000000),
  414. status: idx % 2 ? genArr(['active', 'pending', 'progress']) : 'active'
  415. }));
  416. // labels
  417. DATA.client = res;
  418. return genPage('client', queryString, 'company');
  419. }
  420. function clientGet(id: number): any {
  421. const idx = getIdx('client', id || 0);
  422. const item = {
  423. ...DATA.client[idx],
  424. messages: new Array(Random.natural(0, 5)).fill({}).map((v, idx) => ({
  425. id: idx + 1,
  426. time: `${Random.natural(1, 6)} day ago`,
  427. message: Random.paragraph(1, 1)
  428. }))
  429. };
  430. return item;
  431. }
  432. // #endregion
  433. // #region course
  434. function courseList(queryString: any): any {
  435. if (DATA.course) {
  436. return genPage('course', queryString, 'title');
  437. }
  438. const res: any[] = new Array(10).fill({}).map((v, idx) => ({
  439. id: idx + 1,
  440. mp: genBigMp(),
  441. tags: genTag(),
  442. price: idx === 0 ? 0 : Random.natural(0, 100),
  443. title: Random.title(2, 5),
  444. remark: Random.paragraph(1, 1),
  445. star: genArr([4, 4.5, 5]),
  446. hour: Random.natural(10, 99)
  447. }));
  448. // labels
  449. DATA.course = res;
  450. return genPage('course', queryString, 'title');
  451. }
  452. // #endregion
  453. // #region chat
  454. function chatList(): any {
  455. if (DATA.chat) {
  456. return DATA.chat;
  457. }
  458. const res: any = {
  459. users: new Array(10).fill({}).map((v, idx) => ({
  460. id: idx + 1,
  461. mp: genMp(),
  462. name: genName(),
  463. count: idx % 3 === 0 ? Random.natural(0, 5) : 0,
  464. online: idx < 5 ? true : false,
  465. unread: Random.boolean() && Random.boolean() ? Random.natural(0, 5) : 0
  466. }))
  467. };
  468. // labels
  469. DATA.chat = res;
  470. return res;
  471. }
  472. // #endregion
  473. // #region gallery
  474. function galleryList(): any {
  475. if (DATA.gallery) {
  476. return DATA.gallery;
  477. }
  478. const res: any = new Array(16).fill({}).map((v, idx) => ({
  479. id: idx + 1,
  480. url: genBigMp(),
  481. title: Random.title(),
  482. type: genArr(['Nature', 'Beach', 'Animal', 'Other'])
  483. }));
  484. // labels
  485. DATA.gallery = res;
  486. return res;
  487. }
  488. // #endregion
  489. // #region article
  490. function articleList(queryString: any): any {
  491. if (DATA.article) {
  492. return genPage('article', queryString, 'title');
  493. }
  494. const res: any[] = new Array(11).fill({}).map((v, idx) => ({
  495. id: idx + 1,
  496. mp: genMp(),
  497. name: genName(),
  498. title: Random.ctitle(),
  499. likes: Random.natural(0, 1000),
  500. comments: Random.natural(0, 1000),
  501. created: Random.now('day'),
  502. status: idx % 2 ? genArr(['Published', 'Draft', 'Deleted']) : 'Published'
  503. }));
  504. // labels
  505. DATA.article = res;
  506. return genPage('article', queryString, 'title');
  507. }
  508. function articleGet(id: number): any {
  509. const idx = getIdx('article', id || 0);
  510. const item = { ...DATA.article[idx] };
  511. return item;
  512. }
  513. // #endregion
  514. // #region voting
  515. function votingList(queryString: any): any {
  516. if (DATA.voting) {
  517. return genPage('voting', queryString, 'title');
  518. }
  519. const res: any[] = new Array(11).fill({}).map((v, idx) => ({
  520. id: idx + 1,
  521. voting: Random.integer(-10, 10000),
  522. title: Random.title(5, 10),
  523. content: Random.paragraph(),
  524. likes: Random.natural(0, 1000),
  525. created: Random.now('day')
  526. }));
  527. // labels
  528. DATA.voting = res;
  529. return genPage('voting', queryString, 'title');
  530. }
  531. function votingSave(req: any): any {
  532. const idx = getIdx('voting', req.id || 0);
  533. DATA.voting[idx].value += req.voting;
  534. return { msg: 'ok', item: DATA.voting[idx] };
  535. }
  536. // #endregion
  537. // #region voting
  538. function invoice(): any {
  539. if (DATA.invoice) {
  540. return deepCopy(DATA.invoice);
  541. }
  542. const res: any = {
  543. id: Random.integer(10000, 99999),
  544. zone: 'Mountain View, CA 94043 United States',
  545. address: '1600 Amphitheatre Parkway',
  546. tel: '15900000000, +86 (021) 99999999',
  547. date: genData(0),
  548. to: {
  549. company: 'XXX Company LTD',
  550. zone: 'Mountain View, CA 94043 United States',
  551. address: '1600 Amphitheatre Parkway',
  552. tel: '15900000000, +86 (021) 99999999',
  553. email: 'cipchk@qq.com'
  554. },
  555. payment: {
  556. total: 0,
  557. bank: 'XXXX Bank',
  558. country: 'China',
  559. city: 'Shang Hai',
  560. address: 'xxx xxxx',
  561. code: '012384'
  562. },
  563. wares: [
  564. {
  565. id: 1,
  566. title: Random.title(),
  567. remark: Random.title(),
  568. price: +Random.float(0.1, 999).toFixed(2),
  569. num: +Random.natural(1, 10)
  570. },
  571. {
  572. id: 2,
  573. title: Random.title(),
  574. remark: Random.title(),
  575. price: +Random.float(0.1, 999).toFixed(2),
  576. num: +Random.natural(1, 10)
  577. }
  578. ],
  579. note: Random.paragraph()
  580. };
  581. // total
  582. res.wares.forEach((i: any) => {
  583. i.total = +(i.price * i.num).toFixed(2);
  584. });
  585. res.tax_rate = 0.2;
  586. res.total = +(res.wares as any[]).reduce((a, b) => (a += b.total), 0).toFixed(2);
  587. res.tax = +(res.total * 0.2).toFixed(2);
  588. res.payment_total = +(res.total + res.tax).toFixed(2);
  589. DATA.invoice = res;
  590. return deepCopy(DATA.invoice);
  591. }
  592. // #endregion
  593. // #region faq
  594. function faq(): any {
  595. if (DATA.faq) {
  596. return deepCopy(DATA.faq);
  597. }
  598. DATA.faq = new Array(6).fill({}).map((v, idx) => ({
  599. title: `Knowledge ${idx + 1}`,
  600. icon: 'question-circle',
  601. primary: idx < 3,
  602. remark: 'The list of FAQ',
  603. children: new Array(Random.natural(3, 6)).fill({}).map((v, idx) => ({
  604. active: idx === 0,
  605. q: 'What is a product key?',
  606. a: genHtml()
  607. }))
  608. }));
  609. return deepCopy(DATA.faq);
  610. }
  611. // #endregion
  612. // #region calendar
  613. function calendar(req: any): any {
  614. const cur = new Date(+req.time || new Date());
  615. const startDate = startOfMonth(cur);
  616. const max = getDaysInMonth(cur);
  617. const start = format(startDate, 'yyyy-MM');
  618. const now = format(new Date(), 'yyyy-MM-dd');
  619. return [
  620. {
  621. id: 1,
  622. title: 'All Day Event',
  623. start: `${start}-1`,
  624. className: 'fc-event-danger fc-event-fill-warning'
  625. },
  626. {
  627. id: 2,
  628. title: 'Reporting',
  629. start: `${start}-7T13:30:00`,
  630. end: `${start}-7`,
  631. className: 'fc-event-success'
  632. },
  633. {
  634. id: 3,
  635. title: 'Company Trip',
  636. start: `${start}-12`,
  637. end: `${start}-14`,
  638. className: 'fc-event-primary'
  639. },
  640. {
  641. id: 4,
  642. title: 'Product Release',
  643. start: `${start}-3`,
  644. end: `${start}-5`,
  645. className: 'fc-event-light fc-event-fill-primary'
  646. },
  647. {
  648. id: 5,
  649. title: 'Repeating Event',
  650. start: `${start}-09T16:00:00`,
  651. className: 'fc-event-purple'
  652. },
  653. { id: 6, title: 'Repeating Event', start: `${start}-11T16:00:00` },
  654. {
  655. id: 7,
  656. title: 'Meeting',
  657. start: `${now}T10:00:00`,
  658. end: `${now}T11:30:00`
  659. },
  660. { id: 8, title: 'Lunch', start: `${now}T12:00:00` },
  661. {
  662. id: 9,
  663. title: 'Meeting',
  664. start: `${now}T14:00:00`,
  665. className: 'fc-event-warning'
  666. },
  667. {
  668. id: 10,
  669. title: 'Happy Hour',
  670. start: `${now}T17:30:00`,
  671. className: 'fc-event-success'
  672. },
  673. {
  674. id: 11,
  675. title: 'Dinner',
  676. start: `${now}T18:30:00`,
  677. className: 'fc-event-fill-danger fc-event-light'
  678. },
  679. {
  680. id: 12,
  681. title: 'Birthday Party',
  682. start: `${now}T21:00:00`,
  683. className: 'fc-event-primary'
  684. },
  685. {
  686. id: 13,
  687. title: 'Click for Ng Alain',
  688. url: 'https://ng-alain.com',
  689. start: `${start}-27`,
  690. className: 'fc-event-fill-success fc-event-light'
  691. },
  692. {
  693. id: 14,
  694. title: 'Repeating Event',
  695. start: `${start}-09T08:00:00`,
  696. className: 'fc-event-magenta'
  697. }
  698. ];
  699. }
  700. // #endregion
  701. // #region quick
  702. function quick(): any {
  703. if (DATA.quick) {
  704. return deepCopy(DATA.quick);
  705. }
  706. DATA.quick = {
  707. notifications: new Array(6).fill({}).map(() => ({
  708. dot: genArr([
  709. { icon: 'warning', bg: 'error' },
  710. { icon: 'pie-chart', bg: 'primary' },
  711. { icon: 'message', bg: 'success' },
  712. { icon: 'bell', bg: 'cyan' }
  713. ]),
  714. content: Random.title(5, 15),
  715. time: genArr(['01:01 PM', '09:00 AM', '18:56']),
  716. tags: genTag().join(',')
  717. })),
  718. actions: new Array(6).fill({}).map(() => ({
  719. bg: genColorName(),
  720. title: Random.title(2, 3),
  721. content: Random.title(5, 15)
  722. })),
  723. settings: {
  724. notification: true,
  725. audit_log: false,
  726. new_order: false,
  727. tracking_order: false,
  728. reports_order: true,
  729. new_customer: true,
  730. reporting_customer: true
  731. }
  732. };
  733. return deepCopy(DATA.quick);
  734. }
  735. // #endregion
  736. // #region dd
  737. function ddList(): any {
  738. if (DATA.dd) {
  739. return DATA.dd;
  740. }
  741. DATA.dd = [
  742. {
  743. name: 'total-sales',
  744. title: '总数-总销售额',
  745. enabled: true,
  746. params: { title: '总销售额', total: 100, week: 10, day: 11, daySales: 1000 }
  747. },
  748. {
  749. name: 'total-sales',
  750. title: '总数-总订单量',
  751. enabled: false,
  752. params: { title: '总订单量', total: 5500, week: 320, day: 5, daySales: 5422 }
  753. },
  754. {
  755. name: 'total-sales',
  756. title: '总数-总用户量',
  757. enabled: false,
  758. params: { title: '总用户量', total: 500, week: 80, day: 23, daySales: 6666 }
  759. },
  760. {
  761. name: 'total-sales',
  762. title: '总数-其他',
  763. enabled: false,
  764. params: { title: '其他', total: 200, week: 80, day: 23, daySales: 77777 }
  765. },
  766. {
  767. name: 'visits',
  768. title: '访问量',
  769. enabled: true,
  770. params: { url: '/chart' }
  771. },
  772. {
  773. name: 'effect',
  774. title: '访问量',
  775. enabled: true,
  776. params: { percent: 66, week: 11, day: 23 }
  777. },
  778. {
  779. name: 'gauge',
  780. title: '核销率',
  781. enabled: true
  782. },
  783. {
  784. name: 'radar',
  785. title: '指数',
  786. enabled: true,
  787. params: { title: '贡献指数', url: '/chart' }
  788. },
  789. {
  790. name: 'activities',
  791. title: '动态',
  792. enabled: true,
  793. params: { title: '动态', url: '/api/activities' }
  794. }
  795. ];
  796. return DATA.dd;
  797. }
  798. function ddSave(req: any): any {
  799. DATA.dd = req;
  800. return { msg: 'ok' };
  801. }
  802. // #endregion
  803. export const OTHERS = {
  804. '/kanban-board': kanbanList(),
  805. 'DELETE /kanban-board': (req: MockRequest) => del('kanban', req.queryString),
  806. '/task': taskList(),
  807. 'DELETE /task': (req: MockRequest) => del('task', req.queryString),
  808. '/email': (req: MockRequest) => emailList(req.queryString),
  809. '/email/:id': (req: MockRequest) => emailGet(+req.params.id),
  810. 'DELETE /email': (req: MockRequest) => del('email', req.queryString),
  811. '/project': projectList(),
  812. '/project/:id': (req: MockRequest) => projectGet(+req.params.id),
  813. 'DELETE /project': (req: MockRequest) => del('project', req.queryString),
  814. '/client': (req: MockRequest) => clientList(req.queryString),
  815. '/client/:id': (req: MockRequest) => clientGet(+req.params.id),
  816. '/contact': (req: MockRequest) => contactList(req.queryString),
  817. 'DELETE /contact': (req: MockRequest) => del('contact', req.queryString),
  818. '/pricing': () => pricingList(),
  819. '/billing': (req: MockRequest) => billingList(req.queryString),
  820. '/course': (req: MockRequest) => courseList(req.queryString),
  821. '/chat': () => chatList(),
  822. '/chat/message': () => {
  823. const item: any = {
  824. type: Random.boolean() && Random.boolean() ? 'image' : 'text',
  825. dir: Random.boolean() ? 'left' : 'right'
  826. };
  827. item.msg = item.type === 'text' ? Random.paragraph(1, 1) : genBigMp();
  828. return item;
  829. },
  830. '/gallery': () => galleryList(),
  831. '/article': (req: MockRequest) => articleList(req.queryString),
  832. '/article/:id': (req: MockRequest) => articleGet(+req.params.id),
  833. 'DELETE /article': (req: MockRequest) => del('article', req.queryString),
  834. 'POST /article': (req: MockRequest) => save('article', req.body),
  835. '/voting': (req: MockRequest) => votingList(req.queryString),
  836. 'POST /voting': (req: MockRequest) => votingSave(req.body),
  837. '/invoice': () => invoice(),
  838. '/faq': () => faq(),
  839. '/calendar': (req: MockRequest) => calendar(req.queryString),
  840. '/quick': () => quick(),
  841. '/dd': () => ddList(),
  842. 'POST /dd': (req: MockRequest) => ddSave(req.body)
  843. };