blob: 919aef497bcbbc3fce8f685c963db4b7f06c5972 [file] [log] [blame]
huibing.xie1718f362018-08-24 14:50:58 +08001import Mock from 'mockjs'
2import { param2Obj } from '@/utils'
huibing.xiec95b6a22018-08-29 14:15:43 +08003import dept from './department'
huibing.xie1718f362018-08-24 14:50:58 +08004
5const clsList = Mock.mock({
6 'list|26': [{
7 'id': '@increment',
huibing.xiec95b6a22018-08-29 14:15:43 +08008 '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.xie3ead5ea2018-08-30 10:19:49 +080021 '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.xie1718f362018-08-24 14:50:58 +080049 }]
50}).list
51
huibing.xiec95b6a22018-08-29 14:15:43 +080052const 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)
66const studentTypeList = Mock.mock(
67 [{
68 'value': '1',
69 'label': '研究生'
70 },
71 {
72 'value': '2',
73 'label': '本专科生'
74 }]
75)
76const leaveSchoolTypeList = Mock.mock(
77 [{
78 'value': '1',
79 'label': '毕业离校'
80 },
81 {
82 'value': '2',
83 'label': '其他'
84 }]
85)
huibing.xie3ead5ea2018-08-30 10:19:49 +080086const 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.xie1718f362018-08-24 14:50:58 +0800100export default{
101 getList: config => {
huibing.xie3ead5ea2018-08-30 10:19:49 +0800102 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.xie1718f362018-08-24 14:50:58 +0800106 const mockList = clsList.filter(item => {
huibing.xiec95b6a22018-08-29 14:15:43 +0800107 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.xie3ead5ea2018-08-30 10:19:49 +0800117 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.xie1718f362018-08-24 14:50:58 +0800120 return true
121 })
122
123 const pageList = mockList.filter((item, index) => index < pageSize * pageIndex && index >= pageSize * (pageIndex - 1))
124 return {
huibing.xiec95b6a22018-08-29 14:15:43 +0800125 departmentList: dept.getDeptList().items,
126 leaveSchoolTypeList: leaveSchoolTypeList,
127 studentTypeList: studentTypeList,
128 leaveSchoolBatchList: leaveSchoolBatchList,
huibing.xie3ead5ea2018-08-30 10:19:49 +0800129 auditResultList: auditResultList,
huibing.xie1718f362018-08-24 14:50:58 +0800130 items: pageList,
131 recordCount: mockList.length,
132 code: 200
133 }
huibing.xie3ead5ea2018-08-30 10:19:49 +0800134 },
135 saveAudit: config => {
136 return {
137 code: 200
138 }
huibing.xie1718f362018-08-24 14:50:58 +0800139 }
140}
huibing.xie3ead5ea2018-08-30 10:19:49 +0800141