var Mock = require('mockjs')
const Random = Mock.Random;
// import {
// getQuery
// } from '../../../utils/methods'
function param2Obj(url) {
const search = url.split('?')[1]
if (!search) {
return {}
}
return JSON.parse('{"' + decodeURIComponent(search).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g, '":"') + '"}')
}
let riskData = []
for (let i = 0; i < 25; i++) {
let dataItem = {
"id": i,
"orgId": '123',
"orgName": "寿险",
"name": "风险事项名",
"riskType": ["INSPECT", "TAXAT", "POLICY"][Math.floor(Math.random() * 3)],
"startTime": "2015-03",
"endTime": "2019-05",
"itemDetail": "风险事项详情",
"updatedBy": Random.cname(),
"updatedDate": Random.date() + ' ' + Random.time(),
}
riskData.push(dataItem);
}
let riskList = function (options) {
console.log(options)
// console.log(JSON.parse(options.url));
let rtype = options.type.toLowerCase(); //获取请求类型
switch (rtype) {
case 'post':
let obj = JSON.parse(options.body) //把body属性值得字符串转换未js对象。
let {
orgId,
name,
riskType,
startTime,
endTime,
itemDetail
} = obj
riskData.push({
id: riskData.length + 1,
orgId: orgId,
orgName: orgId,
name: name,
riskType: riskType,
startTime: startTime,
endTime: endTime,
itemDetail: itemDetail,
updatedBy: "ex-luoyong003",
updatedDate: new Date().format("yyyy-MM-dd hh:mm:ss"),
})
return {
'responseCode': '0',
'responseMsg': '操作成功!',
'page': {
'currentPage': 1,
'pageReasonable': true,
'pageSize': 10,
'total': riskData.length
},
'result': riskData //返回这个数组,也就是返回处理后的假数据
}
break;
case 'delete':
{
// let {
// id
// } = param2Obj(options.url)
// console.log(id);
// riskData = riskData.filter(val => {
// return val.id != id; //把这个id对应的对象从数组里删除.
// })
let obj = param2Obj(options.url)
console.log(obj);
obj = Object.values(obj);
console.log(obj);
let ids = [];
ids = obj.map((value) => {
return parseInt(value);
})
console.log(ids);
riskData = riskData.filter(item => !ids.includes(item.id))
return {
'responseCode': '0',
'responseMsg': '操作成功!',
'page': {
'currentPage': 1,
'pageReasonable': true,
'pageSize': 10,
'total': riskData.length
},
'result': riskData //返回这个数组,也就是返回处理后的假数据
}
break;
}
case 'put':
{
let obj = JSON.parse(options.body) //把body属性值得字符串转换未js对象。
let {
id,
orgId,
name,
riskType,
startTime,
endTime,
itemDetail
} = obj
riskData.forEach(item => {
if (item.id === id) {
item.orgId = orgId
item.orgName = orgId
item.name = name
item.riskType = riskType
item.startTime = startTime
item.endTime = endTime
item.itemDetail = itemDetail
}
})
return {
'responseCode': '0',
'responseMsg': '操作成功!',
'page': {
'currentPage': 1,
'pageReasonable': true,
'pageSize': 10,
'total': riskData.length
},
'result': riskData //返回这个数组,也就是返回处理后的假数据
}
break;
}
case 'get':
{
let {
currentPage = 1,
pageSize = 10
} = param2Obj(options.url)
const pageList = riskData.filter((item, index) => index < currentPage * pageSize && index >= pageSize * (currentPage - 1))
return {
responseCode: '0',
responseMsg: '操作成功!',
page: {
'currentPage': currentPage,
'pageReasonable': true,
'pageSize': pageSize,
'total': riskData.length
},
result: pageList
}
}
break;
default:
}
}
//风险预警增加,删除,改,查。
Mock.mock(RegExp('itax-core-analysis/taxation-early'), riskList)
// 下面是税负申请数据的查询数据 后台的模拟。
let taxData = []
for (let i = 0; i < 24; i++) {
taxData.push(Mock.mock({
"id": i,
'applyNum': '20190617140555',
'orgId': '寿险核销法人XX',
'dataType': ["CURRENT", "HISTORY"][Math.floor(Math.random() * 2)],
'region': '2019-05',
'attachList': [{
"attachId": 123456,
"attachCode": "sfsfascv4564c5a4s56",
"attachName": '@cname().xslx'
}],
'status': ["UNCOMMITTED", "APPROVEING", "APPPASS", "UNAPPPASS"][Math.floor(Math.random() * 4)],
'updatedBy': '@cname()',
"updatedDate": Random.date() + ' ' + Random.time(),
}));
}
let taxList = function (options) {
console.log(options)
let rtype = options.type.toLowerCase(); //获取请求类型
switch (rtype) {
case 'post':
{
let obj = JSON.parse(options.body) //把body属性值得字符串转换未js对象。
let {
applyNum,
orgId,
dataType,
region,
attachList,
status,
operation
} = obj
taxData.push({
id: taxData.length + 1,
applyNum: applyNum,
orgId: orgId,
dataType: dataType,
region: region,
attachList: attachList,
status: status, //1是未提交审批
updatedBy: "ex-luoyong003",
updatedDate: Random.date() + ' ' + Random.time(),
})
return {
'responseCode': '0',
'responseMsg': '操作成功!',
}
break;
}
case 'delete':
{
let obj = param2Obj(options.url)
obj = Object.values(obj);
let ids = [];
ids = obj.map((value) => {
return parseInt(value);
})
taxData = taxData.filter(item => !ids.includes(item.id))
return {
'responseCode': '0',
'responseMsg': '操作成功!',
}
break;
}
case 'put':
{
let obj = JSON.parse(options.body) //把body属性值得字符串转换未js对象。
let {
id,
applyNum,
orgId,
dataType,
region,
attachList,
status,
operation
} = obj
taxData.forEach(item => {
if (item.id === id) {
item.applyNum = applyNum
item.orgId = orgId
item.dataType = dataType
item.region = region
item.attachList = attachList
item.status = status
item.updatedDate = Random.date() + ' ' + Random.time()
}
})
return {
'responseCode': '0',
'responseMsg': '操作成功!'
}
break;
}
case 'get':
{
let {
orgId,
region,
status,
currentPage,
pageSize
} = param2Obj(options.url)
let pageList = ''
pageList = taxData.filter((item, index) => index < currentPage * pageSize && index >= pageSize * (currentPage - 1))
// if (status == '') {
// pageList = taxData.filter((item, index) => index < currentPage * pageSize && index >= pageSize * (currentPage - 1) && item.region == region)
// } else if(region == ''){
// pageList = taxData.filter((item, index) => index < currentPage * pageSize && index >= pageSize * (currentPage - 1) && item.status == status)
// }else {
// pageList = taxData.filter((item, index) => index < currentPage * pageSize && index >= pageSize * (currentPage - 1) && item.status == status && item.region == region)
// }
return {
responseCode: '0',
responseMsg: '操作成功!',
page: {
'currentPage': currentPage,
'pageReasonable': true,
'pageSize': pageSize,
'total': taxData.length
},
result: pageList
}
}
break;
default:
}
}
//税务数据增加,删除,改,查。
// Mock.mock(RegExp('itax-core-analysis/taxation-impapply'), taxList)
//税负申请开关的接口后台模拟
// Mock.mock(RegExp('itax-core-analysis/taxtaion-disjunctor'), {
// 'responseCode': '0',
// 'responseMsg': '操作成功!',
// 'result': {
// disjunctor: "on",
// dataType: [
// "CURRENT",
// "HISTORY"
// ]
// }
// })
//税负申请模板名的后台模拟
// Mock.mock(RegExp('itax-core-analysis/taxation-impapply/temp-name'), {
// 'responseCode': '0',
// 'responseMsg': '操作成功',
// 'result': {
// name: "金服",
// }
// })
let detailData = []
for (let i = 0; i < 26; i++) {
detailData.push(Mock.mock({
"id": i,
'target': "指标名",
'dataType': '201904',
'partyAmount': '@integer(1000, 40000)',
'yearSum': '@integer(0, 50000)',
}));
}
let detailList = function (options) {
console.log(options)
let rtype = options.type.toLowerCase(); //获取请求类型
switch (rtype) {
case 'get':
{
let {
id,
currentPage,
pageSize
} = param2Obj(options.url)
const pageList = detailData.filter((item, index) => index < currentPage * pageSize && index >= pageSize * (currentPage - 1))
return {
responseCode: '0',
responseMsg: '操作成功!',
page: {
'currentPage': currentPage,
'pageReasonable': true,
'pageSize': pageSize,
'total': detailData.length
},
result: pageList
}
}
break;
default:
}
}
//数据详情接口
// Mock.mock(RegExp('itax-core-analysis/taxation-data/detail'), detailList)
//申请提交按钮的接口
// let changeTaxList = function (options) {
// console.log(options)
// let rtype = options.type.toLowerCase(); //获取请求类型
// switch (rtype) {
// case 'get':
// {
// let {
// id,
// operation
// } = param2Obj(options.url)
// console.log("变id:" + id);
// if (operation == 'submit') {
// taxData.forEach(item => {
// if (item.id == id) {
// item.status = 'APPROVEING'
// console.log("item.status:" + item.status);
// }
// })
// return {
// 'responseCode': '0',
// 'responseMsg': '操作成功!',
// }
// } else {
// taxData.forEach(item => {
// if (item.id == id) {
// item.status = 'UNCOMMITTED'
// console.log("item.status:" + item.status);
// }
// })
// return {
// 'responseCode': '0',
// 'responseMsg': '操作成功!',
// }
// }
// break;
// }
// default:
// }
// }
// Mock.mock(RegExp('itax-core-analysis/taxation-refer'), changeTaxList)
//风险分类的接口
// Mock.mock(RegExp('itax-core-base/dictItems'), {
// responseCode: '0',
// responseMsg: '操作成功!',
// result: [{
// 'itemCode': 'INSPECT',
// 'itemName': '稽查'
// }, {
// 'itemCode': 'TAXAT',
// 'itemName': '税负'
// }, {
// 'itemCode': 'POLICY',
// 'itemName': '政策'
// }, ]
// })
//申请状态的接口
Mock.mock(RegExp('itax-core-base/dictItems'), {
responseCode: '0',
responseMsg: '操作成功!',
result: [{
'itemCode': 'UNCOMMITTED',
'itemName': '未提交审批'
}, {
'itemCode': 'APPROVEING',
'itemName': '审批中'
}, {
'itemCode': 'APPPASS',
'itemName': '审批通过'
}, {
'itemCode': 'UNAPPPASS',
'itemName': '审批不通过'
}]
})
let eoa = options =>{
console.log(options)
return {
"responseCode": "0",
"responseMsg": "操作成功!",
"result": [{
"chainInfoId": "3500de12-3cb1-41e3-8788-52e60f793984",
"infoNo": "20190624969291",
"isSubmitterUpdate": 0,
"approvalChainPostDetailList": [{
"chainPostId": "89c49158-7241-4b1e-989c-9268c519dfdb",
"postId": "40214",
"postName": "专业公司总部税务经理",
"roleId": "",
"roleName": "",
"chainInfoId": "3500de12-3cb1-41e3-8788-52e60f793984",
"seqNo": 1,
"organizationNodeId": "640001",
"startAmount": null,
"endAmount": null,
"isSubmitterUpdate": 0,
"handType": "6666",
"approvalProcess": "",
"umAccountList": [{name: "胡军", nwSw: "集团财务企划中心集团财务部税务管理室", umNo: "HUXUE004"},{name: "潘嘉凌", nwSw: "集团财务企划中心集团财务部税务管理室", umNo: "PANJIALING001"}]
}]
}]
}
}
//获取eoa 审批链接口
// Mock.mock(RegExp('itax-core-analysis/taxation-impapply/eoa-approval-chain'), eoa)