83 lines
2.7 KiB
JavaScript
83 lines
2.7 KiB
JavaScript
const Mock = require('mockjs')
|
|
|
|
//模拟企业信息返回数据
|
|
const custTags = ["001","010","100","011","110","101","111"]
|
|
//生成随机的结果
|
|
|
|
const generateBinaryCombination= ()=>{
|
|
const index = Mock.Random.integer(0,custTags.length-1);
|
|
return custTags[index];
|
|
}
|
|
|
|
const generateRandomPhone = () => {
|
|
const prefixes = ['132','135','136','137','138','139','150','151','152','157','188','187','173','155'];
|
|
return Mock.Random.pick(prefixes)
|
|
}
|
|
|
|
const generateSuffix = () => {
|
|
return Mock.Random.integer(10000000,99999999).toString()
|
|
}
|
|
|
|
|
|
let customerInfoList = Mock.mock({
|
|
'list|187': [{
|
|
'id|+1': 1,
|
|
'custName': '@ctitle(2,4)有限责任公司',
|
|
'belongBranchName': '@ctitle(2,3)支行',
|
|
'belongOutletName': '@ctitle(2,4)网点',
|
|
'belongUserName': '@cname',
|
|
'lpName':'@cname',
|
|
'custPhone': generateRandomPhone()+generateSuffix(),
|
|
'custScale|0-2': 0,
|
|
'custTag': generateBinaryCombination(),
|
|
'custPattern|0-2': 0 ,
|
|
'custType|0-1':0
|
|
}]
|
|
}).list;
|
|
|
|
|
|
module.exports =[
|
|
{
|
|
url: '/system/custBaseInfo/list',
|
|
type: 'get',
|
|
response: config => {
|
|
const params = config.query;
|
|
console.log(params);
|
|
const pagenum = params.pageNum;
|
|
const custType = params.custType;
|
|
const custName1 = params.custName
|
|
const {custScale,custTags} = params;
|
|
// console.log(pageNum,pageSize);
|
|
let filterData = customerInfoList.filter(item => item.custPattern==0)
|
|
//分页返回
|
|
const total = filterData.length;
|
|
const currentPage = parseInt(pagenum) || 1;
|
|
const currentPageSize = 10;
|
|
const start = (currentPage-1) * currentPageSize;
|
|
const currentPageSize2= Math.min(currentPageSize,total-start)
|
|
const end = start+currentPageSize2;
|
|
// console.log(total,'=====',currentPage,'=====',currentPageSize+'=====',start);
|
|
|
|
const pageData = filterData.slice(start,end);
|
|
const finalData = custName1? pageData.filter(item =>{
|
|
return item.custName.includes(custName1)||item.lpName.includes(custName1)
|
|
} ):pageData
|
|
|
|
const custTypeData = (custType||custScale)? finalData.filter(item => {return item.custType==custType||item.custScale==custScale||
|
|
item.custTag==custTags}):finalData;
|
|
return {
|
|
code: 200,
|
|
data: {
|
|
total: (custType||custScale||custTags)?custTypeData.length:custName1?finalData.length:filterData.length,
|
|
pageSize:parseInt(currentPageSize2),
|
|
pageNum: parseInt(currentPage),
|
|
rows: (custType||custScale||custTags)?custTypeData : finalData
|
|
},
|
|
message:'查询成功!'
|
|
}
|
|
}
|
|
}
|
|
]
|
|
|
|
|