| // import Mock from 'mockjs' |
| import { param2Obj } from '@/utils' |
| |
| const typeList = [{ |
| 'id': '1', |
| 'code': 'sex', |
| 'name': '性别' |
| }, |
| { |
| 'id': '2', |
| 'code': 'zzmm', |
| 'name': '政治面貌' |
| }] |
| const dicList = [{ |
| 'id': '1', |
| 'type': 'classCode', |
| 'name': '院系' |
| }, |
| { |
| 'id': '2', |
| 'type': 'classCode', |
| 'name': '部门' |
| }, |
| { |
| 'id': '3', |
| 'type': 'gjzybz', |
| 'name': '文学' |
| }, |
| { |
| 'id': '4', |
| 'type': 'gjzybz', |
| 'name': '物理' |
| }, |
| { |
| 'id': '5', |
| 'type': 'gjzybz', |
| 'name': '数学' |
| }, |
| { |
| 'id': '6', |
| 'type': 'nj', |
| 'name': '2017' |
| }, |
| { |
| 'id': '7', |
| 'type': 'nj', |
| 'name': '2018' |
| }, |
| { |
| 'id': '8', |
| 'type': 'nj', |
| 'name': '2019' |
| }, |
| { |
| 'id': '9', |
| 'type': 'zzmm', |
| 'code': 'dy', |
| 'name': '党员' |
| }, |
| { |
| 'id': '10', |
| 'type': 'zzmm', |
| 'code': 'qz', |
| 'name': '群众' |
| }, |
| { |
| 'id': '11', |
| 'type': 'sex', |
| 'code': 'male', |
| 'name': '男' |
| }, |
| { |
| 'id': '12', |
| 'type': 'sex', |
| 'code': 'female', |
| 'name': '女' |
| }, |
| { |
| 'id': '13', |
| 'type': 'xswz', |
| 'name': '置顶' |
| }, |
| { |
| 'id': '14', |
| 'type': 'xswz', |
| 'name': '其他' |
| }, |
| { |
| 'id': '15', |
| 'type': 'gglx', |
| 'name': '离校公告' |
| }, |
| { |
| 'id': '16', |
| 'type': 'jszlx', |
| 'name': '所有人' |
| }, |
| { |
| 'id': '17', |
| 'type': 'jszlx', |
| 'name': '所有学生' |
| }, |
| { |
| 'id': '18', |
| 'type': 'jszlx', |
| 'name': '所有教职工' |
| }, |
| { |
| 'id': '19', |
| 'type': 'xslb', |
| 'name': '本专科生' |
| }, |
| { |
| 'id': '20', |
| 'type': 'xslb', |
| 'name': '研究生' |
| }, |
| { |
| 'id': '21', |
| 'type': 'scope', |
| 'name': '辅导员范围' |
| }, |
| { |
| 'id': '22', |
| 'type': 'defaultAuditStatus', |
| 'name': '待审核' |
| }, |
| { |
| 'id': '23', |
| 'type': 'defaultAuditStatus', |
| 'name': '审核通过' |
| }, |
| { |
| 'id': '24', |
| 'type': 'defaultAuditStatus', |
| 'name': '审核不通过' |
| }, |
| { |
| 'id': '25', |
| 'type': 'auditType', |
| 'name': '手动' |
| }, |
| { |
| 'id': '26', |
| 'type': 'auditType', |
| 'name': '自动' |
| }, |
| { |
| 'id': '27', |
| 'type': 'scope', |
| 'name': '全校范围' |
| }, |
| { |
| 'id': '28', |
| 'type': 'scope', |
| 'name': '院系范围' |
| }] |
| |
| export default{ |
| getPage: config => { |
| const { name, pageIndex = 1, pageSize = 20 } = param2Obj(config.url) |
| const mockList = typeList.filter(item => { |
| if (name && item.name !== name && item.code !== name) return false |
| return true |
| }) |
| |
| const pageList = mockList.filter((item, index) => index < pageSize * pageIndex && index >= pageSize * (pageIndex - 1)) |
| return { |
| items: pageList, |
| recordCount: mockList.length, |
| code: 200 |
| } |
| }, |
| getDicList: config => { |
| let type = '' |
| if (config.dicType) { |
| type = config.dicType |
| } else { |
| const { dicType } = param2Obj(config.url) |
| type = dicType |
| } |
| const mockList = dicList.filter(item => { |
| if (type && item.type !== type) return false |
| return true |
| }) |
| |
| return { |
| items: mockList, |
| code: 200 |
| } |
| }, |
| getType: config => { |
| const { id } = param2Obj(config.url) |
| const mockList = typeList.filter(item => item.id + '' === id + '') |
| return { |
| data: mockList.length > 0 ? mockList[0] : null, |
| code: 200 |
| } |
| }, |
| createType: config => { |
| const type = JSON.parse(config.body) |
| if (!type.id) { |
| type.id = '' + parseInt(Math.random() * 100) + 1024 // mock a id |
| typeList.unshift(type) |
| } else { |
| for (let i = 0; i < typeList.length; i++) { |
| if (typeList[i].id + '' === type.id + '') { |
| typeList.splice(i, 1, type) |
| break |
| } |
| } |
| } |
| return { |
| item: type, |
| code: 200 |
| } |
| }, |
| deleteType: config => { |
| const type = JSON.parse(config.body) |
| let index = -1 |
| for (let i = 0; i < typeList.length; i++) { |
| if (typeList[i].id + '' === type.id + '') { |
| index = i |
| break |
| } |
| } |
| if (index > -1) { |
| typeList.splice(index, 1) |
| } |
| return { |
| code: 200 |
| } |
| }, |
| getDic: config => { |
| const { id } = param2Obj(config.url) |
| const mockList = dicList.filter(item => item.id + '' === id + '') |
| return { |
| data: mockList.length > 0 ? mockList[0] : null, |
| code: 200 |
| } |
| }, |
| createDic: config => { |
| const dic = JSON.parse(config.body) |
| if (!dic.id) { |
| dic.id = '' + parseInt(Math.random() * 100) + 1024 // mock a id |
| dicList.unshift(dic) |
| } else { |
| for (let i = 0; i < dicList.length; i++) { |
| if (dicList[i].id + '' === dic.id + '') { |
| dicList.splice(i, 1, dic) |
| break |
| } |
| } |
| } |
| return { |
| item: dic, |
| code: 200 |
| } |
| }, |
| deleteDic: config => { |
| const dic = JSON.parse(config.body) |
| let index = -1 |
| for (let i = 0; i < dicList.length; i++) { |
| if (dicList[i].id + '' === dic.id + '') { |
| index = i |
| break |
| } |
| } |
| if (index > -1) { |
| dicList.splice(index, 1) |
| } |
| return { |
| code: 200 |
| } |
| } |
| } |