Browse Source

(*)销售区域字段类型改为字符串

master
wuqun 2 years ago
parent
commit
ead73682fa
  1. 65
      api/app/lib/controllers/salesDistribution/index.js
  2. 4
      api/app/lib/models/sales_distribution.js
  3. 4
      doc/scripts/0.0.4/schema/1.sales_distribution.sql
  4. 2
      web/client/src/sections/humanAffairs/containers/salersDistribution/importSalersModal.js
  5. 4
      web/client/src/sections/humanAffairs/containers/salersDistribution/personnelDistribution.jsx
  6. 6
      web/client/src/sections/humanAffairs/containers/salersDistribution/salesMemberModal.js

65
api/app/lib/controllers/salesDistribution/index.js

@ -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,

4
api/app/lib/models/sales_distribution.js

@ -26,7 +26,7 @@ module.exports = dc => {
autoIncrement: false
},
provinces: {
type: DataTypes.ARRAY(DataTypes.STRING),
type: DataTypes.STRING,
allowNull: false,
defaultValue: null,
comment: null,
@ -35,7 +35,7 @@ module.exports = dc => {
autoIncrement: false
},
cities: {
type: DataTypes.ARRAY(DataTypes.STRING),
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: null,

4
doc/scripts/0.0.4/schema/1.sales_distribution.sql

@ -4,8 +4,8 @@ CREATE TABLE sales_distribution
(
id serial PRIMARY KEY NOT NULL,
pep_user_id int NOT NULL,
provinces varchar(255) [] NOT NULL,
cities varchar(255) [],
provinces text NOT NULL,
cities text,
del boolean DEFAULT false NULL
);
CREATE UNIQUE INDEX sales_distribution_id_uindex ON sales_distribution (id);

2
web/client/src/sections/humanAffairs/containers/salersDistribution/importSalersModal.js

@ -228,7 +228,7 @@ const ImportSalersModal = props => {
}
postData.push({
pepUserId: rzExist.pepUserId, name,
provinces: provinces?.split('、') || [], cities: cities?.split('、') || [],
provinces: provinces || '', cities: cities || '',
del: false
})
}

4
web/client/src/sections/humanAffairs/containers/salersDistribution/personnelDistribution.jsx

@ -123,7 +123,7 @@ const PersonnelDistribution = (props) => {
key: 'provinces',
width: '15%',
render: (text, record, index) => {
return getMultis(text);
return getMultis(text?.split('、') || []);
}
}, {
title: '销售区域(市)',
@ -131,7 +131,7 @@ const PersonnelDistribution = (props) => {
key: 'cities',
width: '15%',
render: (text, record, index) => {
return getMultis(text);
return getMultis(text?.split('、') || []);
}
}, {
title: starHeader('岗位'),

6
web/client/src/sections/humanAffairs/containers/salersDistribution/salesMemberModal.js

@ -20,7 +20,7 @@ const SalesMemberModal = (props) => {
setOptions(optionItems);
if (dataToEdit) {
setPeoplePro(dataToEdit);
onChange(dataToEdit.provinces);//市options
onChange(dataToEdit.provinces?.split('、') || []);//市options
}
}, []);
@ -57,6 +57,8 @@ const SalesMemberModal = (props) => {
})
} else if (peoplePro?.userCode) {
if (values.userCode == peoplePro.userCode) {
values.provinces = values.provinces.join('、')
values.cities = values.cities.join('、')
if (dataToEdit) {
dispatch(humanAffairs.editSalesMember({ pepUserId: peoplePro.pepUserId, msg: '编辑销售人员信息', ...values })).then((res) => {
if (res.success) {
@ -202,7 +204,7 @@ const SalesMemberModal = (props) => {
{peoplePro ? renderSimpleInfo() : ''}
<Form.Select
initValue={dataToEdit?.provinces || []}
initValue={dataToEdit?.provinces?.split('、') || []}
label="销售区域(省/直辖市)"
field='provinces'
showClear

Loading…
Cancel
Save