Browse Source

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

master
wuqun 2 years ago
parent
commit
ead73682fa
  1. 47
      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

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

@ -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,20 +47,20 @@ 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,
@ -56,8 +71,10 @@ async function salesList(ctx) {
...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,

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

@ -26,7 +26,7 @@ module.exports = dc => {
autoIncrement: false autoIncrement: false
}, },
provinces: { provinces: {
type: DataTypes.ARRAY(DataTypes.STRING), type: DataTypes.STRING,
allowNull: false, allowNull: false,
defaultValue: null, defaultValue: null,
comment: null, comment: null,
@ -35,7 +35,7 @@ module.exports = dc => {
autoIncrement: false autoIncrement: false
}, },
cities: { cities: {
type: DataTypes.ARRAY(DataTypes.STRING), type: DataTypes.STRING,
allowNull: true, allowNull: true,
defaultValue: null, defaultValue: null,
comment: 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, id serial PRIMARY KEY NOT NULL,
pep_user_id int NOT NULL, pep_user_id int NOT NULL,
provinces varchar(255) [] NOT NULL, provinces text NOT NULL,
cities varchar(255) [], cities text,
del boolean DEFAULT false NULL del boolean DEFAULT false NULL
); );
CREATE UNIQUE INDEX sales_distribution_id_uindex ON sales_distribution (id); 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({ postData.push({
pepUserId: rzExist.pepUserId, name, pepUserId: rzExist.pepUserId, name,
provinces: provinces?.split('、') || [], cities: cities?.split('、') || [], provinces: provinces || '', cities: cities || '',
del: false del: false
}) })
} }

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

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

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

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

Loading…
Cancel
Save