From ead73682fa9702e4973b0d65921c6311a361411c Mon Sep 17 00:00:00 2001 From: wuqun Date: Thu, 24 Nov 2022 18:32:41 +0800 Subject: [PATCH] =?UTF-8?q?(*)=E9=94=80=E5=94=AE=E5=8C=BA=E5=9F=9F?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E7=B1=BB=E5=9E=8B=E6=94=B9=E4=B8=BA=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E4=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/salesDistribution/index.js | 65 ++++++++++++------- api/app/lib/models/sales_distribution.js | 4 +- .../0.0.4/schema/1.sales_distribution.sql | 4 +- .../salersDistribution/importSalersModal.js | 2 +- .../personnelDistribution.jsx | 4 +- .../salersDistribution/salesMemberModal.js | 6 +- 6 files changed, 52 insertions(+), 33 deletions(-) diff --git a/api/app/lib/controllers/salesDistribution/index.js b/api/app/lib/controllers/salesDistribution/index.js index e8d551b..1e238cd 100644 --- a/api/app/lib/controllers/salesDistribution/index.js +++ b/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, diff --git a/api/app/lib/models/sales_distribution.js b/api/app/lib/models/sales_distribution.js index 6d7bf6c..bdc30dc 100644 --- a/api/app/lib/models/sales_distribution.js +++ b/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, diff --git a/doc/scripts/0.0.4/schema/1.sales_distribution.sql b/doc/scripts/0.0.4/schema/1.sales_distribution.sql index 197851a..28d3160 100644 --- a/doc/scripts/0.0.4/schema/1.sales_distribution.sql +++ b/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); \ No newline at end of file diff --git a/web/client/src/sections/humanAffairs/containers/salersDistribution/importSalersModal.js b/web/client/src/sections/humanAffairs/containers/salersDistribution/importSalersModal.js index 86ec5ce..784d743 100644 --- a/web/client/src/sections/humanAffairs/containers/salersDistribution/importSalersModal.js +++ b/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 }) } diff --git a/web/client/src/sections/humanAffairs/containers/salersDistribution/personnelDistribution.jsx b/web/client/src/sections/humanAffairs/containers/salersDistribution/personnelDistribution.jsx index bc53ec6..4477e3f 100644 --- a/web/client/src/sections/humanAffairs/containers/salersDistribution/personnelDistribution.jsx +++ b/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('岗位'), diff --git a/web/client/src/sections/humanAffairs/containers/salersDistribution/salesMemberModal.js b/web/client/src/sections/humanAffairs/containers/salersDistribution/salesMemberModal.js index 61e8b92..d5c2b33 100644 --- a/web/client/src/sections/humanAffairs/containers/salersDistribution/salesMemberModal.js +++ b/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() : ''}