Browse Source

(*)销售人员分布添加“业务线”字段

master
wuqun 2 years ago
parent
commit
72bfffcbf5
  1. 2
      api/.vscode/launch.json
  2. 27
      api/app/lib/controllers/salesDistribution/index.js
  3. 9
      api/app/lib/models/sales_distribution.js
  4. 4
      doc/scripts/PEP V3.0.0/schema/1.sales_distribution_modify.sql
  5. 6
      web/client/src/sections/humanAffairs/containers/salersDistribution/importSalersModal.js
  6. 35
      web/client/src/sections/humanAffairs/containers/salersDistribution/personnelDistribution.jsx
  7. 45
      web/client/src/sections/humanAffairs/containers/salersDistribution/salesMemberModal.js

2
api/.vscode/launch.json

@ -42,7 +42,7 @@
//
"--clickHouseUrl http://10.8.30.161",
"--clickHousePepEmis pepca_dev",
"--clickHousePepEmis pepca8",
"--clickHouseCamworkflow camworkflow",
"--clickHouseHr hrm",
]

27
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 } });

9
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",

4
doc/scripts/PEP V3.0.0/schema/1.sales_distribution_modify.sql

@ -0,0 +1,4 @@
alter table sales_distribution
add "business_lines" text;

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

@ -38,7 +38,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;
@ -191,6 +191,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 +227,10 @@ const ImportSalersModal = props => {
error(`${i + 2}行销售区域(市)错误`)
return
}
//todo 业务线判断
postData.push({
pepUserId: rzExist.pepUserId, name, number,
provinces: provinces || '', cities: cities || '',
provinces: provinces || '', cities: cities || '', businessLines: businessLines || '',
del: false
})
}

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

@ -1,4 +1,4 @@
import React, { useEffect, useRef, useState } from 'react';
import React, { useEffect, useRef, useState, useMemo } from 'react';
import { connect } from 'react-redux';
import moment from 'moment'
import { Select, Input, Button, Popconfirm, Radio, Tooltip, Table, Pagination, Skeleton } from '@douyinfe/semi-ui';
@ -100,19 +100,19 @@ const PersonnelDistribution = (props) => {
title: '序号',
dataIndex: 'id',
key: 'id',
width: '5%',
width: 60,
render: (text, record, index) => index + 1
}, {
title: starHeader('姓名'),
dataIndex: 'name',
key: 'name',
width: '5%'
width: 80
},
{
title: starHeader('部门名称'),
dataIndex: 'department',
key: 'department',
width: '18%',
width: 200,
render: (text, r, index) => {
let arrStr = text.map(t => t.name);
return getMultis(arrStr);
@ -121,7 +121,7 @@ const PersonnelDistribution = (props) => {
title: '销售区域(省/直辖市)',
dataIndex: 'provinces',
key: 'provinces',
width: '15%',
width: 160,
render: (text, record, index) => {
return getMultis(text?.split('、') || []);
}
@ -129,40 +129,48 @@ const PersonnelDistribution = (props) => {
title: '销售区域(市)',
dataIndex: 'cities',
key: 'cities',
width: '15%',
width: 160,
render: (text, record, index) => {
return getMultis(text?.split('、') || []);
return text ? getMultis(text?.split('、') || []) : '-';
}
}, {
title: '业务线',
dataIndex: 'businessLines',
key: 'businessLines',
width: 120,
render: (text, record, index) => {
return text ? getMultis(text?.split('、') || []) : '-';
}
}, {
title: starHeader('岗位'),
dataIndex: 'post',
key: 'post',
width: '11%',
width: 120,
render: (text, record) => <span>{text || '-'}</span>
}, {
title: starHeader('入职时间'),
dataIndex: 'hireDate',
key: 'hireDate',
width: '8%',
width: 120,
render: (text, record) => <span>{text || '-'}</span>
}, {
title: starHeader('转正时间'),
dataIndex: 'regularDate',
key: 'regularDate',
width: '8%',
width: 120,
render: (text, record) => <span>{text || '-'}</span>
}, {
title: starHeader('工龄'),
dataIndex: 'workYears',
key: 'workYears',
width: '5%',
width: 120,
render: (_, r, index) => {
return (r.hireDate ? <span style={{ color: '#1890FF' }}>{String(moment(new Date()).diff(r.hireDate, 'years', true)).substring(0, 3) + '年'}</span> : '-')
},
}, {
title: '操作',
dataIndex: 'action',
width: '10%',
width: 120,
render: (text, record) => {
return <div>
<span style={{ color: '#1890FF', cursor: 'pointer' }} onClick={() => onEdit(record)}>编辑</span>&nbsp;&nbsp;
@ -186,7 +194,7 @@ const PersonnelDistribution = (props) => {
}
});
}
const scroll = useMemo(() => ({}), []);
return (<div style={{ padding: '0px 12px' }}>
<div style={{ display: 'flex' }}>
<div style={{ color: 'rgba(0,0,0,0.45)', fontSize: 14 }}>招聘</div>
@ -294,6 +302,7 @@ const PersonnelDistribution = (props) => {
justifyContent: "space-between",
padding: "20px 20px",
}}>
<div></div>
<div style={{ display: 'flex', }}>
<span style={{ lineHeight: "30px", fontSize: 13, color: 'rgba(0,90,189,0.8)' }}>
{limits}条信息

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

@ -3,10 +3,12 @@ import moment from 'moment';
import { connect } from "react-redux";
import { Select, Modal, Form, Notification } from "@douyinfe/semi-ui";
import cityData from '../../components/city.json';
const businessLines = ['市政', '地灾', '水利', '智慧城市', '工地', '环保', '安防', '产品投标', '交通', '矿山', '产品线']
const SalesMemberModal = (props) => {
const { dispatch, actions, user, meetingList, onConfirm, getMultis, onCancel, close, rzMembers, dataToEdit } = props;
const { humanAffairs } = actions;
const form = useRef();//表单
const [lineOptions, setLineOptions] = useState([]);
const [options, setOptions] = useState([]);
const [cityOptions, setCityOptions] = useState([]);
const [peoplePro, setPeoplePro] = useState({}); //人员信息
@ -18,6 +20,14 @@ const SalesMemberModal = (props) => {
</Select.Option>
})
setOptions(optionItems);
let lineOptions = businessLines.map((l, index) => {
return <Select.Option value={l} key={index}>
{l}
</Select.Option>
})
setLineOptions(lineOptions);
if (dataToEdit) {
setPeoplePro(dataToEdit);
onChange(dataToEdit.provinces?.split('、') || []);//市options
@ -59,6 +69,7 @@ const SalesMemberModal = (props) => {
if (values.userCode == peoplePro.userCode) {
values.provinces = values.provinces.join('、')
values.cities = values.cities.join('、')
values.businessLines = values.businessLines.join('、')
if (dataToEdit) {
dispatch(humanAffairs.editSalesMember({ pepUserId: peoplePro.pepUserId, msg: '编辑销售人员信息', ...values })).then((res) => {
if (res.success) {
@ -163,14 +174,6 @@ const SalesMemberModal = (props) => {
</div>
}
// const handleDeselect = (value) => {//删除
// let ranges = cityData.find(td => td.name == value)?.children || []
// if (ranges) {
// let formList = form.current.getValues().cities;
// }
// }
const onClear = () => {
form.current.setValue('cities', [])
}
@ -212,36 +215,36 @@ const SalesMemberModal = (props) => {
placeholder='请选择销售区域(省/直辖市)'
multiple filter
style={{ width: '100%' }}
// optionFilterProp='children'
// getPopupContainer={triggerNode => triggerNode.parentNode}
// filterOption={(input, option) => option.props.children
// .toLowerCase().indexOf(input.toLowerCase()) >= 0}
// value={selectedKeys || []}
onClear={() => onClear()}
onChange={value => onChange(value)}
//onDeselect={value => handleDeselect(value)}
maxTagCount={5}
>
{options}
</Form.Select>
<Form.Select
initValue={dataToEdit?.cities || []}
initValue={dataToEdit?.cities ? dataToEdit?.cities?.split('、') : []}
label="销售区域(市)"
field='cities'
showClear
placeholder='请选择销售区域(市)'
multiple filter
style={{ width: '100%' }}
// optionFilterProp='children'
// getPopupContainer={triggerNode => triggerNode.parentNode}
// filterOption={(input, option) => option.props.children
// .toLowerCase().indexOf(input.toLowerCase()) >= 0}
// value={selectedKeys || []}
//onDeselect={value => handleDeselect(value)}
maxTagCount={5}
>
{cityOptions}
</Form.Select>
<Form.Select
initValue={dataToEdit?.businessLines ? dataToEdit?.businessLines?.split('、') : []}
label="业务线"
field='businessLines'
showClear
placeholder='请选择业务线'
multiple filter
style={{ width: '100%' }}
maxTagCount={5}
>
{lineOptions}
</Form.Select>
</Form>
</Modal>
)

Loading…
Cancel
Save