|
@ -23,8 +23,23 @@ async function salesList(ctx) { |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
const { models } = ctx.fs.dc; |
|
|
const { models } = ctx.fs.dc; |
|
|
|
|
|
|
|
|
|
|
|
let mIds = members.map(m => m.pepUserId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let where = { |
|
|
|
|
|
del: false, |
|
|
|
|
|
pepUserId: { $in: mIds } |
|
|
|
|
|
} |
|
|
|
|
|
if (placeSearch) { |
|
|
|
|
|
where.$or = [{ |
|
|
|
|
|
provinces: { $like: `%${placeSearch}%` } |
|
|
|
|
|
}, { |
|
|
|
|
|
cities: { $like: `%${placeSearch}%` } |
|
|
|
|
|
}] |
|
|
|
|
|
} |
|
|
let res = await models.SalesDistribution.findAndCountAll({ |
|
|
let res = await models.SalesDistribution.findAndCountAll({ |
|
|
where: { del: false }, |
|
|
where: where, |
|
|
offset: Number(page) * Number(limit), |
|
|
offset: Number(page) * Number(limit), |
|
|
limit: Number(limit), |
|
|
limit: Number(limit), |
|
|
order: [['id', 'DESC']] |
|
|
order: [['id', 'DESC']] |
|
@ -32,32 +47,34 @@ async function salesList(ctx) { |
|
|
|
|
|
|
|
|
let rslt = [] |
|
|
let rslt = [] |
|
|
res.rows.map(d => { |
|
|
res.rows.map(d => { |
|
|
let valid = false; |
|
|
//let valid = false;
|
|
|
let info = members.find(m => m.pepUserId == d.dataValues.pepUserId); |
|
|
let info = members.find(m => m.pepUserId == d.dataValues.pepUserId); |
|
|
if (info) { |
|
|
// if (info) {
|
|
|
if (placeSearch) { |
|
|
// if (placeSearch) {
|
|
|
let exist1 = d.dataValues.provinces.join(',').indexOf(placeSearch) != -1 |
|
|
// let exist1 = d.dataValues.provinces.join(',').indexOf(placeSearch) != -1
|
|
|
let exist2 = d.dataValues.cities.join(',').indexOf(placeSearch) != -1 |
|
|
// let exist2 = d.dataValues.cities.join(',').indexOf(placeSearch) != -1
|
|
|
if (exist1 || exist2) { |
|
|
// if (exist1 || exist2) {
|
|
|
valid = true; |
|
|
// valid = true;
|
|
|
} |
|
|
// }
|
|
|
} else { |
|
|
// } else {
|
|
|
valid = true; |
|
|
// valid = true;
|
|
|
} |
|
|
// }
|
|
|
} |
|
|
// }
|
|
|
if (valid) { |
|
|
//if (valid) {
|
|
|
let item = { |
|
|
let item = { |
|
|
name: info.userName, |
|
|
name: info.userName, |
|
|
userCode: info.userCode, |
|
|
userCode: info.userCode, |
|
|
post: info.userPost, |
|
|
post: info.userPost, |
|
|
department: info.departmrnt, |
|
|
department: info.departmrnt, |
|
|
hireDate: info.hiredate,//入职时间
|
|
|
hireDate: info.hiredate,//入职时间
|
|
|
regularDate: info.regularDate,//转正时间
|
|
|
regularDate: info.regularDate,//转正时间
|
|
|
...d.dataValues |
|
|
...d.dataValues |
|
|
} |
|
|
|
|
|
rslt.push(item); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
rslt.push(item); |
|
|
|
|
|
//}
|
|
|
}) |
|
|
}) |
|
|
|
|
|
// let end = Number(page) * Number(limit) + Number(limit)
|
|
|
|
|
|
// let arr = rslt.slice(Number(page) * Number(limit), end)
|
|
|
ctx.status = 200; |
|
|
ctx.status = 200; |
|
|
ctx.body = { |
|
|
ctx.body = { |
|
|
count: res.count, |
|
|
count: res.count, |
|
|