diff --git a/api/.vscode/launch.json b/api/.vscode/launch.json index 3a4a4a3..efc0fbb 100644 --- a/api/.vscode/launch.json +++ b/api/.vscode/launch.json @@ -19,9 +19,9 @@ "-g postgres://postgres:123@10.8.30.166:5432/hr-dev", "--redisHost 10.8.30.112", "--redisPort 6379", - // "--apiEmisUrl http://10.8.30.112:14000", + "--apiEmisUrl http://10.8.30.112:14000", // 测试 - "--apiEmisUrl http://10.8.30.161:1111", + // "--apiEmisUrl http://10.8.30.161:1111", "--qnak XuDgkao6cL0HidoMAPnA5OB10Mc_Ew08mpIfRJK5", "--qnsk yewcieZLzKZuDfig0wLZ9if9jKp2P_1jd3CMJPSa", "--qnbkt dev-hr", diff --git a/api/app/lib/controllers/attendance/index.js b/api/app/lib/controllers/attendance/index.js index d5b08c7..c01ca40 100644 --- a/api/app/lib/controllers/attendance/index.js +++ b/api/app/lib/controllers/attendance/index.js @@ -29,7 +29,9 @@ async function overtimeStatistic (ctx) { }) returnD.forEach(u => { - u.overtimeStatistic = sumRes.filter(s => s.pepUserId == u.pepUserId) + let overtimeStatistic = sumRes.filter(s => s.pepUserId == u.pepUserId) + u.overtimeDuration = overtimeStatistic.reduce((sum, os) => sum + os.duration, 0) + u.overtimeStatistic = overtimeStatistic }) ctx.status = 200; ctx.body = { @@ -204,7 +206,9 @@ async function vacateStatistic (ctx) { }) returnD.forEach(u => { - u.vacateStatistic = sumRes.filter(s => s.pepUserId == u.pepUserId) + let vacateStatistic = sumRes.filter(s => s.pepUserId == u.pepUserId) + u.vacateDuration = vacateStatistic.reduce((sum, vs) => sum + vs.duration, 0) + u.vacateStatistic = vacateStatistic }) ctx.status = 200; ctx.body = { diff --git a/api/app/lib/controllers/auth/index.js b/api/app/lib/controllers/auth/index.js index 7b6c00f..022e665 100644 --- a/api/app/lib/controllers/auth/index.js +++ b/api/app/lib/controllers/auth/index.js @@ -10,9 +10,18 @@ async function login (ctx, next) { const models = ctx.fs.dc.models; const params = ctx.request.body; - const emisLoginRes = await ctx.app.fs.emisRequest.post('login', { - data: params - }) + let emisLoginRes = null + if (params.username && params.password) { + emisLoginRes = await ctx.app.fs.emisRequest.post('login', { + data: { ...params, code: 'HR' } + }) + } else if (params.token) { + emisLoginRes = await ctx.app.fs.emisRequest.get('user-info', { + query: { + token: params.token, code: 'HR' + } + }) + } if (!emisLoginRes) { throw "无此用户,请使用正确的登录信息" diff --git a/api/app/lib/controllers/salesDistribution/index.js b/api/app/lib/controllers/salesDistribution/index.js index 1e238cd..7da2d1f 100644 --- a/api/app/lib/controllers/salesDistribution/index.js +++ b/api/app/lib/controllers/salesDistribution/index.js @@ -47,20 +47,7 @@ async function salesList(ctx) { let rslt = [] res.rows.map(d => { - //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, @@ -71,10 +58,7 @@ async function salesList(ctx) { ...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, @@ -92,7 +76,7 @@ async function salesList(ctx) { async function add(ctx) { try { const { models } = ctx.fs.dc; - const { pepUserId, provinces, cities } = ctx.request.body + const { pepUserId, provinces, cities, businessLines } = ctx.request.body const existRes = await models.SalesDistribution.findOne({ where: { pepUserId } @@ -102,7 +86,7 @@ async function add(ctx) { throw '当前销售人员信息已存在' } - let storageData = { pepUserId, provinces, cities, del: false } + let storageData = { pepUserId, provinces, cities, businessLines, del: false } if (existRes && existRes.del) { await models.SalesDistribution.update(storageData, { where: { pepUserId } @@ -123,7 +107,7 @@ async function add(ctx) { async function edit(ctx) { try { const { models } = ctx.fs.dc; - const { pepUserId, provinces, cities } = ctx.request.body + const { pepUserId, provinces, cities, businessLines } = ctx.request.body const existRes = await models.SalesDistribution.findOne({ where: { pepUserId } @@ -133,7 +117,7 @@ async function edit(ctx) { throw '当前销售人员信息不存在' } - let storageData = { pepUserId, provinces, cities, del: false } + let storageData = { pepUserId, provinces, cities, businessLines, del: false } await models.SalesDistribution.update(storageData, { where: { @@ -321,11 +305,12 @@ async function addSalesMemberBulk(ctx) { //处理编辑的 if (editArr.length) { for (let i in editArr) { - let { pepUserId, provinces, cities, del = false } = editArr[i]; + let { pepUserId, provinces, cities, businessLines, del = false } = editArr[i]; let dataToUpdate = { provinces, cities, + businessLines, del } await models.SalesDistribution.update(dataToUpdate, { where: { pepUserId: pepUserId } }); diff --git a/api/app/lib/models/sales_distribution.js b/api/app/lib/models/sales_distribution.js index bdc30dc..1d46830 100644 --- a/api/app/lib/models/sales_distribution.js +++ b/api/app/lib/models/sales_distribution.js @@ -51,6 +51,15 @@ module.exports = dc => { primaryKey: false, field: "del", autoIncrement: false + }, + businessLines: { + type: DataTypes.STRING, + allowNull: true, + defaultValue: null, + comment: null, + primaryKey: false, + field: "business_lines", + autoIncrement: false } }, { tableName: "sales_distribution", diff --git a/doc/scripts/PEP V3.0.0/schema/1.sales_distribution_modify.sql b/doc/scripts/PEP V3.0.0/schema/1.sales_distribution_modify.sql new file mode 100644 index 0000000..82a1085 --- /dev/null +++ b/doc/scripts/PEP V3.0.0/schema/1.sales_distribution_modify.sql @@ -0,0 +1,4 @@ + + +alter table sales_distribution + add "business_lines" text; \ No newline at end of file diff --git a/web/client/src/sections/humanAffairs/containers/salersDistribution/constans.jsx b/web/client/src/sections/humanAffairs/containers/salersDistribution/constans.jsx new file mode 100644 index 0000000..86adcba --- /dev/null +++ b/web/client/src/sections/humanAffairs/containers/salersDistribution/constans.jsx @@ -0,0 +1,4 @@ + + +export const businessLinesConst = ['市政', '地灾', '水利', '智慧城市', '工地', + '环保', '安防', '产品投标', '交通', '矿山', '产品线'] \ 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 3723dc5..0a02075 100644 --- a/web/client/src/sections/humanAffairs/containers/salersDistribution/importSalersModal.js +++ b/web/client/src/sections/humanAffairs/containers/salersDistribution/importSalersModal.js @@ -4,6 +4,7 @@ import { connect } from 'react-redux'; import { Modal, Form, Button, Notification } from '@douyinfe/semi-ui'; import { IconUpload } from '@douyinfe/semi-icons'; import cityData from '../../components/city.json'; +import { businessLinesConst } from './constans' import XLSX from 'xlsx' //下载模板和上传文件读取 const ImportSalersModal = props => { @@ -38,7 +39,7 @@ const ImportSalersModal = props => { const dldCsvMb = () => { //表头 - let head = "员工编号,姓名,销售区域(省/直辖市),销售区域(市)\n" + let head = "员工编号,姓名,销售区域(省/直辖市),销售区域(市),业务线\n" //数据 //let data = 1 + ',' + 2 + ',' + 3 + ',' + 4 + ',' + 5 let templateCsv = "data:text/csv;charset=utf-8,\ufeff" + head; @@ -142,6 +143,19 @@ const ImportSalersModal = props => { return !noMark; } + const judgeLines = (businessLines) => { + if (!businessLines) {//可以不填 + return true; + } + let noMark = 0; + businessLines?.split('、')?.map(p => { + if (businessLinesConst.indexOf(p) == -1) { + noMark++ + } + }) + return !noMark; + } + const judgeNull = (value) => { return value ? String(value).trim().replace(/\s*/g, "") : null; } @@ -191,6 +205,7 @@ const ImportSalersModal = props => { let name = judgeNull(d['姓名']); let provinces = judgeNull(d['销售区域(省/直辖市)']); let cities = judgeNull(d['销售区域(市)']); + let businessLines = judgeNull(d['业务线']); if (!number) {//人员编号不为空,唯一,字母和数字 error(`第${i + 2}行人员编号为空,请填写`) return @@ -226,9 +241,14 @@ const ImportSalersModal = props => { error(`第${i + 2}行销售区域(市)错误`) return } + let bValid = judgeLines(businessLines); + if (!bValid) { + error(`第${i + 2}行业务线错误`) + return + } postData.push({ pepUserId: rzExist.pepUserId, name, number, - provinces: provinces || '', cities: cities || '', + provinces: provinces || '', cities: cities || '', businessLines: businessLines || '', del: false }) } @@ -252,6 +272,7 @@ const ImportSalersModal = props => {