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