| import { param2Obj } from '@/utils' |
| |
| const nodeList = [ |
| { |
| 'id': '26', |
| 'name': '后勤处', |
| 'department': { 'id': '2', 'name': '后勤处' }, |
| 'contact': '张三', |
| 'phoneNumber': '021-65431991', |
| 'scope': { 'id': '27', 'name': '全校范围' }, |
| 'auditType': { 'id': '25', 'name': '手动' }, |
| 'defaultAuditStatus': { 'id': '22', 'name': '待审核' }, |
| 'auditNodeDuty': '', |
| 'auditNodeAddress': '', |
| 'deleted': '0' |
| }, |
| { |
| 'id': '27', |
| 'name': '财务处', |
| 'department': { 'id': '3', 'name': '财务处' }, |
| 'contact': '李四', |
| 'phoneNumber': '021-65431921', |
| 'scope': { 'id': '27', 'name': '全校范围' }, |
| 'auditType': { 'id': '26', 'name': '自动' }, |
| 'defaultAuditStatus': { 'id': '22', 'name': '待审核' }, |
| 'auditNodeDuty': '', |
| 'auditNodeAddress': '', |
| 'deleted': '0' |
| }, |
| { |
| 'id': '28', |
| 'name': '图书馆', |
| 'department': { 'id': '4', 'name': '图书馆' }, |
| 'contact': '王五', |
| 'phoneNumber': '021-65431931', |
| 'scope': { 'id': '27', 'name': '全校范围' }, |
| 'auditType': { 'id': '25', 'name': '手动' }, |
| 'defaultAuditStatus': { 'id': '22', 'name': '待审核' }, |
| 'auditNodeDuty': '', |
| 'auditNodeAddress': '', |
| 'deleted': '0' |
| } |
| ] |
| |
| const userList = [ |
| { |
| 'id': '1', |
| 'xm': '张三', |
| 'xb': { 'value': 'male', 'label': '男' }, |
| 'ghxh': '11' |
| }, |
| { |
| 'id': '2', |
| 'xm': '李四', |
| 'xb': { 'value': 'female', 'label': '女' }, |
| 'ghxh': '22' |
| } |
| ] |
| |
| const auditorList = [ |
| { |
| 'id': '11', |
| 'auditNode': { 'id': '26', 'name': '后勤处' }, |
| 'user': { 'id': '3', 'ghxh': '33', 'xm': '王五', 'xb': { 'value': 'male', 'label': '男' }} |
| }, |
| { |
| 'id': '22', |
| 'auditNode': { 'id': '28', 'name': '图书馆' }, |
| 'user': { 'id': '4', 'ghxh': '44', 'xm': '赵六', 'xb': { 'value': 'female', 'label': '女' }} |
| } |
| ] |
| |
| const principalList = [ |
| { |
| 'id': '11', |
| 'auditNode': { 'id': '26', 'name': '后勤处' }, |
| 'user': { 'id': '3', 'ghxh': '33', 'xm': '王六', 'xb': { 'value': 'male', 'label': '男' }} |
| }, |
| { |
| 'id': '11', |
| 'auditNode': { 'id': '28', 'name': '图书馆' }, |
| 'user': { 'id': '4', 'ghxh': '44', 'xm': '赵七', 'xb': { 'value': 'female', 'label': '女' }} |
| } |
| ] |
| |
| export default{ |
| getList: config => { |
| const { name, auditType, pageIndex = 1, pageSize = 20 } = param2Obj(config.url) |
| const mockList = nodeList.filter(item => { |
| if (name && item.name !== name) return false |
| if (auditType && item.auditType.id !== auditType) 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 |
| } |
| }, |
| getItem: config => { |
| const { id } = param2Obj(config.url) |
| const mockList = nodeList.filter(item => item.id + '' === id + '') |
| return { |
| data: mockList.length > 0 ? mockList[0] : null, |
| code: 200 |
| } |
| }, |
| createData: config => { |
| const node = JSON.parse(config.body) |
| if (!node.id) { |
| node.id = '' + parseInt(Math.random() * 100) + 1024 // mock a id |
| nodeList.unshift(node) |
| } else { |
| for (let i = 0; i < nodeList.length; i++) { |
| if (nodeList[i].id + '' === node.id + '') { |
| nodeList.splice(i, 1, node) |
| break |
| } |
| } |
| } |
| return { |
| item: node, |
| code: 200 |
| } |
| }, |
| deleteData: config => { |
| const node = JSON.parse(config.body) |
| let index = -1 |
| for (let i = 0; i < nodeList.length; i++) { |
| if (nodeList[i].id + '' === node.id + '') { |
| index = i |
| break |
| } |
| } |
| if (index > -1) { |
| nodeList.splice(index, 1) |
| } |
| return { |
| code: 200 |
| } |
| }, |
| getUser: config => { |
| const { ghxh } = param2Obj(config.url) |
| const mockList = userList.filter(item => item.ghxh + '' === ghxh + '') |
| return { |
| data: mockList.length > 0 ? mockList[0] : null, |
| code: 200 |
| } |
| }, |
| getAuditorList: config => { |
| const { nodeId } = param2Obj(config.url) |
| const mockList = auditorList.filter(item => item.auditNode.id + '' === nodeId + '') |
| return { |
| items: mockList, |
| code: 200 |
| } |
| }, |
| createNodeAuditor: config => { |
| const nodeAuditor = JSON.parse(config.body) |
| if (!nodeAuditor.id) { |
| nodeAuditor.id = '' + parseInt(Math.random() * 100) + 1024 // mock a id |
| auditorList.unshift(nodeAuditor) |
| } else { |
| for (let i = 0; i < auditorList.length; i++) { |
| if (auditorList[i].id + '' === nodeAuditor.id + '') { |
| auditorList.splice(i, 1, nodeAuditor) |
| break |
| } |
| } |
| } |
| return { |
| item: nodeAuditor, |
| code: 200 |
| } |
| }, |
| deleteNodeAuditor: config => { |
| const nodeAuditor = JSON.parse(config.body) |
| let index = -1 |
| for (let i = 0; i < auditorList.length; i++) { |
| if (auditorList[i].id + '' === nodeAuditor.id + '') { |
| index = i |
| break |
| } |
| } |
| if (index > -1) { |
| auditorList.splice(index, 1) |
| } |
| return { |
| code: 200 |
| } |
| }, |
| getPrincipalList: config => { |
| const { nodeId } = param2Obj(config.url) |
| const mockList = principalList.filter(item => item.auditNode.id + '' === nodeId + '') |
| return { |
| items: mockList, |
| code: 200 |
| } |
| }, |
| createNodePrincipal: config => { |
| const nodePrincipal = JSON.parse(config.body) |
| if (!nodePrincipal.id) { |
| nodePrincipal.id = '' + parseInt(Math.random() * 100) + 1024 // mock a id |
| principalList.unshift(nodePrincipal) |
| } else { |
| for (let i = 0; i < principalList.length; i++) { |
| if (principalList[i].id + '' === nodePrincipal.id + '') { |
| principalList.splice(i, 1, nodePrincipal) |
| break |
| } |
| } |
| } |
| return { |
| item: nodePrincipal, |
| code: 200 |
| } |
| }, |
| deleteNodePrincipal: config => { |
| const nodePrincipal = JSON.parse(config.body) |
| let index = -1 |
| for (let i = 0; i < principalList.length; i++) { |
| if (principalList[i].id + '' === nodePrincipal.id + '') { |
| index = i |
| break |
| } |
| } |
| if (index > -1) { |
| principalList.splice(index, 1) |
| } |
| return { |
| code: 200 |
| } |
| } |
| } |