huibing.xie | 1718f36 | 2018-08-24 14:50:58 +0800 | [diff] [blame] | 1 | import Mock from 'mockjs' |
| 2 | import { param2Obj } from '@/utils' |
huibing.xie | c95b6a2 | 2018-08-29 14:15:43 +0800 | [diff] [blame] | 3 | import dept from './department' |
huibing.xie | 1718f36 | 2018-08-24 14:50:58 +0800 | [diff] [blame] | 4 | |
| 5 | const clsList = Mock.mock({ |
| 6 | 'list|26': [{ |
| 7 | 'id': '@increment', |
huibing.xie | c95b6a2 | 2018-08-29 14:15:43 +0800 | [diff] [blame] | 8 | 'node|1': ['后勤处', '财务处', '学生处'], |
| 9 | 'studentNumber': '@word(8)', |
| 10 | 'name': '@cword(2, 3)', |
| 11 | 'department|1': ['教育学院', '经管学院', '人文学院', '数学学院', '计算机学院', '电子学院', '电气学院', '生命科学院'], |
| 12 | 'major': '@cword(6, 7)', |
| 13 | 'clazz': '@cword(6, 7)', |
| 14 | 'auditResult|1': ['待审核', '审核通过', '审核不通过'], |
| 15 | 'auditOpinion': '@cword(6, 10)', |
| 16 | 'rownum': '@id', |
| 17 | 'leaveSchoolBatch': '@cword(6, 7)', |
| 18 | 'studentType': '@cword(6, 7)', |
| 19 | 'leaveSchoolType': '@cword(6, 7)', |
| 20 | 'graduateYear': '@cword(6, 7)', |
| 21 | 'graduateMonth': '@cword(6, 7)' |
huibing.xie | 1718f36 | 2018-08-24 14:50:58 +0800 | [diff] [blame] | 22 | }] |
| 23 | }).list |
| 24 | |
huibing.xie | c95b6a2 | 2018-08-29 14:15:43 +0800 | [diff] [blame] | 25 | const leaveSchoolBatchList = Mock.mock( |
| 26 | [{ |
| 27 | 'value': '2018', |
| 28 | 'label': '2018年' |
| 29 | }, |
| 30 | { |
| 31 | 'value': '2017', |
| 32 | 'label': '2017年' |
| 33 | }, |
| 34 | { |
| 35 | 'value': '2016', |
| 36 | 'label': '2016年' |
| 37 | }] |
| 38 | ) |
| 39 | const studentTypeList = Mock.mock( |
| 40 | [{ |
| 41 | 'value': '1', |
| 42 | 'label': '研究生' |
| 43 | }, |
| 44 | { |
| 45 | 'value': '2', |
| 46 | 'label': '本专科生' |
| 47 | }] |
| 48 | ) |
| 49 | const leaveSchoolTypeList = Mock.mock( |
| 50 | [{ |
| 51 | 'value': '1', |
| 52 | 'label': '毕业离校' |
| 53 | }, |
| 54 | { |
| 55 | 'value': '2', |
| 56 | 'label': '其他' |
| 57 | }] |
| 58 | ) |
huibing.xie | 1718f36 | 2018-08-24 14:50:58 +0800 | [diff] [blame] | 59 | export default{ |
| 60 | getList: config => { |
huibing.xie | c95b6a2 | 2018-08-29 14:15:43 +0800 | [diff] [blame] | 61 | const { studentNumber, name, department, major, clazz, leaveSchoolBatch, studentType, leaveSchoolType, graduateYear, graduateMonth, pageIndex = 1, pageSize = 20 } = param2Obj(config.url) |
huibing.xie | 1718f36 | 2018-08-24 14:50:58 +0800 | [diff] [blame] | 62 | const mockList = clsList.filter(item => { |
huibing.xie | c95b6a2 | 2018-08-29 14:15:43 +0800 | [diff] [blame] | 63 | if (studentNumber && item.studentNumber && item.studentNumber !== studentNumber) return false |
| 64 | if (name && item.name && item.name !== name) return false |
| 65 | if (department && item.department && item.department !== department) return false |
| 66 | if (major && item.major && item.major !== major) return false |
| 67 | if (clazz && item.clazz && item.clazz !== clazz) return false |
| 68 | if (leaveSchoolBatch && item.leaveSchoolBatch && item.leaveSchoolBatch !== leaveSchoolBatch) return false |
| 69 | if (studentType && item.studentType && item.studentType !== studentType) return false |
| 70 | if (leaveSchoolType && item.leaveSchoolType && item.leaveSchoolType !== leaveSchoolType) return false |
| 71 | if (graduateYear && item.graduateYear && item.graduateYear !== graduateYear) return false |
| 72 | if (graduateMonth && item.graduateMonth && item.graduateMonth !== graduateMonth) return false |
huibing.xie | 1718f36 | 2018-08-24 14:50:58 +0800 | [diff] [blame] | 73 | return true |
| 74 | }) |
| 75 | |
| 76 | const pageList = mockList.filter((item, index) => index < pageSize * pageIndex && index >= pageSize * (pageIndex - 1)) |
| 77 | return { |
huibing.xie | c95b6a2 | 2018-08-29 14:15:43 +0800 | [diff] [blame] | 78 | departmentList: dept.getDeptList().items, |
| 79 | leaveSchoolTypeList: leaveSchoolTypeList, |
| 80 | studentTypeList: studentTypeList, |
| 81 | leaveSchoolBatchList: leaveSchoolBatchList, |
huibing.xie | 1718f36 | 2018-08-24 14:50:58 +0800 | [diff] [blame] | 82 | items: pageList, |
| 83 | recordCount: mockList.length, |
| 84 | code: 200 |
| 85 | } |
| 86 | } |
| 87 | } |