File was renamed from _mock/rule.service.ts |
| | |
| | | import { HttpRequest } from '@angular/common/http'; |
| | | import { MockRequest } from '@delon/mock'; |
| | | |
| | | const list = []; |
| | | |
| | | for (let i = 0; i < 46; i += 1) { |
| | |
| | | }); |
| | | } |
| | | |
| | | export function getRule(params: any) { |
| | | function getRule(params: any) { |
| | | let ret = [...list]; |
| | | if (params.sorter) { |
| | | const s = params.sorter.split('_'); |
| | |
| | | return ret; |
| | | } |
| | | |
| | | export function removeRule(no: string): boolean { |
| | | function removeRule(nos: string): boolean { |
| | | nos.split(',').forEach(no => { |
| | | const idx = list.findIndex(w => w.no === no); |
| | | if (idx !== -1) { |
| | | list.splice(idx, 1); |
| | | if (idx !== -1) list.splice(idx, 1); |
| | | }); |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | export function saveRule(description: string) { |
| | | function saveRule(description: string) { |
| | | const i = Math.ceil(Math.random() * 10000); |
| | | list.unshift({ |
| | | key: i, |
| | |
| | | progress: Math.ceil(Math.random() * 100), |
| | | }); |
| | | } |
| | | |
| | | export const RULES = { |
| | | '/rule': (req: MockRequest) => getRule(req.queryString), |
| | | 'DELETE /rule': (req: MockRequest) => removeRule(req.queryString.nos), |
| | | 'POST /rule': (req: MockRequest) => saveRule(req.body.description) |
| | | }; |