huibing.xie | 1718f36 | 2018-08-24 14:50:58 +0800 | [diff] [blame^] | 1 | import Mock from 'mockjs' |
| 2 | import { param2Obj } from '@/utils' |
| 3 | |
| 4 | const clsList = Mock.mock({ |
| 5 | 'list|26': [{ |
| 6 | 'id': '@increment', |
| 7 | 'hjmc|1': ['后勤处', '财务处', '学生处'], |
| 8 | 'xh': '@word(8)', |
| 9 | 'xm': '@cword(2, 3)', |
| 10 | 'yx|1': ['教育学院', '经管学院', '人文学院', '数学学院', '计算机学院', '电子学院', '电气学院', '生命科学院'], |
| 11 | 'yxid|1': ['1', '2', '3', '4', '5', '6', '7', '8'], |
| 12 | 'zy': '@cword(6, 7)', |
| 13 | 'bj': '@cword(6, 7)', |
| 14 | 'shzt|1': ['待审核', '审核通过', '审核不通过'], |
| 15 | 'shyj': '@cword(6, 10)', |
| 16 | 'shztcode|1': ['1', '2', '3'] |
| 17 | }] |
| 18 | }).list |
| 19 | |
| 20 | export default{ |
| 21 | getList: config => { |
| 22 | const { xh, xm, pcmc, xslb, bynf, byyf, yx, zy, xb, shhj, shzt, pageIndex = 1, pageSize = 20 } = param2Obj(config.url) |
| 23 | const mockList = clsList.filter(item => { |
| 24 | if (pcmc && item.pcmc && item.pcmc + '' !== pcmc + '') return false |
| 25 | if (xslb && item.xslb && item.xslb !== xslb) return false |
| 26 | if (bynf && item.bynf && item.bynf !== bynf) return false |
| 27 | if (byyf && item.byyf && item.byyf !== byyf) return false |
| 28 | if (yx && item.yxid && item.yxid !== yx) return false |
| 29 | if (zy && item.zy && item.zy !== zy) return false |
| 30 | if (xb && item.xb && item.xb !== xb) return false |
| 31 | if (shhj && item.shhj && item.shhj !== shhj) return false |
| 32 | if (shzt && item.shztcode && item.shztcode !== shzt) return false |
| 33 | if (xh && item.xh && item.xh !== xh) return false |
| 34 | if (xm && item.xm && item.xm !== xm) return false |
| 35 | return true |
| 36 | }) |
| 37 | |
| 38 | const pageList = mockList.filter((item, index) => index < pageSize * pageIndex && index >= pageSize * (pageIndex - 1)) |
| 39 | return { |
| 40 | items: pageList, |
| 41 | recordCount: mockList.length, |
| 42 | code: 200 |
| 43 | } |
| 44 | } |
| 45 | } |