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)', |
huibing.xie | 3ead5ea | 2018-08-30 10:19:49 +0800 | [diff] [blame^] | 21 | 'graduateMonth': '@cword(6, 7)', |
| 22 | 'allowedLeave|1': ['准予', '不准予'], |
| 23 | 'auditLogList|4': [{ |
| 24 | 'auditNode|1': ['后勤处', '财务处', '学生处', '图书馆'], |
| 25 | 'auditResult|1': ['通过', '不通过'], |
| 26 | 'auditOpinionList|3': [{ |
| 27 | 'auditResult|1': ['通过', '不通过'], |
| 28 | 'auditTime': '@datetime', |
| 29 | 'auditor': '@cword(2, 3)', |
| 30 | 'auditOpinion': '@cword(6, 10)' |
| 31 | }] |
| 32 | }], |
| 33 | 'nodelist': [{ |
| 34 | 'auditNode': '后勤处', |
| 35 | 'auditResult|1': ['—', '×', '√'] |
| 36 | }, |
| 37 | { |
| 38 | 'auditNode': '财务处', |
| 39 | 'auditResult|1': ['—', '×', '√'] |
| 40 | }, |
| 41 | { |
| 42 | 'auditNode': '学生处', |
| 43 | 'auditResult|1': ['—', '×', '√'] |
| 44 | }, |
| 45 | { |
| 46 | 'auditNode': '图书馆', |
| 47 | 'auditResult|1': ['—', '×', '√'] |
| 48 | }] |
huibing.xie | 1718f36 | 2018-08-24 14:50:58 +0800 | [diff] [blame] | 49 | }] |
| 50 | }).list |
| 51 | |
huibing.xie | c95b6a2 | 2018-08-29 14:15:43 +0800 | [diff] [blame] | 52 | const leaveSchoolBatchList = Mock.mock( |
| 53 | [{ |
| 54 | 'value': '2018', |
| 55 | 'label': '2018年' |
| 56 | }, |
| 57 | { |
| 58 | 'value': '2017', |
| 59 | 'label': '2017年' |
| 60 | }, |
| 61 | { |
| 62 | 'value': '2016', |
| 63 | 'label': '2016年' |
| 64 | }] |
| 65 | ) |
| 66 | const studentTypeList = Mock.mock( |
| 67 | [{ |
| 68 | 'value': '1', |
| 69 | 'label': '研究生' |
| 70 | }, |
| 71 | { |
| 72 | 'value': '2', |
| 73 | 'label': '本专科生' |
| 74 | }] |
| 75 | ) |
| 76 | const leaveSchoolTypeList = Mock.mock( |
| 77 | [{ |
| 78 | 'value': '1', |
| 79 | 'label': '毕业离校' |
| 80 | }, |
| 81 | { |
| 82 | 'value': '2', |
| 83 | 'label': '其他' |
| 84 | }] |
| 85 | ) |
huibing.xie | 3ead5ea | 2018-08-30 10:19:49 +0800 | [diff] [blame^] | 86 | const auditResultList = Mock.mock( |
| 87 | [{ |
| 88 | 'value': 'TO_BE_AUDITED', |
| 89 | 'label': '待审核' |
| 90 | }, |
| 91 | { |
| 92 | 'value': 'APPROVED', |
| 93 | 'label': '审核通过' |
| 94 | }, |
| 95 | { |
| 96 | 'value': 'NOT_PASSED', |
| 97 | 'label': '审核不通过' |
| 98 | }] |
| 99 | ) |
huibing.xie | 1718f36 | 2018-08-24 14:50:58 +0800 | [diff] [blame] | 100 | export default{ |
| 101 | getList: config => { |
huibing.xie | 3ead5ea | 2018-08-30 10:19:49 +0800 | [diff] [blame^] | 102 | const { studentNumber, name, department, major, clazz, |
| 103 | leaveSchoolBatch, studentType, leaveSchoolType, graduateYear, graduateMonth, |
| 104 | auditNode, allowedLeave, auditResult, |
| 105 | pageIndex = 1, pageSize = 20 } = param2Obj(config.url) |
huibing.xie | 1718f36 | 2018-08-24 14:50:58 +0800 | [diff] [blame] | 106 | const mockList = clsList.filter(item => { |
huibing.xie | c95b6a2 | 2018-08-29 14:15:43 +0800 | [diff] [blame] | 107 | if (studentNumber && item.studentNumber && item.studentNumber !== studentNumber) return false |
| 108 | if (name && item.name && item.name !== name) return false |
| 109 | if (department && item.department && item.department !== department) return false |
| 110 | if (major && item.major && item.major !== major) return false |
| 111 | if (clazz && item.clazz && item.clazz !== clazz) return false |
| 112 | if (leaveSchoolBatch && item.leaveSchoolBatch && item.leaveSchoolBatch !== leaveSchoolBatch) return false |
| 113 | if (studentType && item.studentType && item.studentType !== studentType) return false |
| 114 | if (leaveSchoolType && item.leaveSchoolType && item.leaveSchoolType !== leaveSchoolType) return false |
| 115 | if (graduateYear && item.graduateYear && item.graduateYear !== graduateYear) return false |
| 116 | if (graduateMonth && item.graduateMonth && item.graduateMonth !== graduateMonth) return false |
huibing.xie | 3ead5ea | 2018-08-30 10:19:49 +0800 | [diff] [blame^] | 117 | if (auditNode && item.auditNode && item.auditNode !== auditNode) return false |
| 118 | if (allowedLeave && item.allowedLeave && item.allowedLeave !== allowedLeave) return false |
| 119 | if (auditResult && item.auditResult && item.auditResult !== auditResult) return false |
huibing.xie | 1718f36 | 2018-08-24 14:50:58 +0800 | [diff] [blame] | 120 | return true |
| 121 | }) |
| 122 | |
| 123 | const pageList = mockList.filter((item, index) => index < pageSize * pageIndex && index >= pageSize * (pageIndex - 1)) |
| 124 | return { |
huibing.xie | c95b6a2 | 2018-08-29 14:15:43 +0800 | [diff] [blame] | 125 | departmentList: dept.getDeptList().items, |
| 126 | leaveSchoolTypeList: leaveSchoolTypeList, |
| 127 | studentTypeList: studentTypeList, |
| 128 | leaveSchoolBatchList: leaveSchoolBatchList, |
huibing.xie | 3ead5ea | 2018-08-30 10:19:49 +0800 | [diff] [blame^] | 129 | auditResultList: auditResultList, |
huibing.xie | 1718f36 | 2018-08-24 14:50:58 +0800 | [diff] [blame] | 130 | items: pageList, |
| 131 | recordCount: mockList.length, |
| 132 | code: 200 |
| 133 | } |
huibing.xie | 3ead5ea | 2018-08-30 10:19:49 +0800 | [diff] [blame^] | 134 | }, |
| 135 | saveAudit: config => { |
| 136 | return { |
| 137 | code: 200 |
| 138 | } |
huibing.xie | 1718f36 | 2018-08-24 14:50:58 +0800 | [diff] [blame] | 139 | } |
| 140 | } |
huibing.xie | 3ead5ea | 2018-08-30 10:19:49 +0800 | [diff] [blame^] | 141 | |