From 67729bcf3db54624bf0ec2e415e1d384da013c12 Mon Sep 17 00:00:00 2001 From: ww664853070 Date: Mon, 5 Dec 2022 11:55:59 +0800 Subject: [PATCH] =?UTF-8?q?(*)=E5=AE=A2=E6=88=B7=E8=81=94=E7=B3=BB?= =?UTF-8?q?=E4=BA=BA=E5=AF=B9=E6=8E=A5=E8=B7=9F=E8=BF=9B=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../customerContactsFollup/index.js | 4 +- .../customer/customerContactFollowup.jsx | 93 ++++++++++++++----- web/package.json | 4 +- 3 files changed, 73 insertions(+), 28 deletions(-) diff --git a/api/app/lib/controllers/customerContactsFollup/index.js b/api/app/lib/controllers/customerContactsFollup/index.js index 2a615e3..145fadb 100644 --- a/api/app/lib/controllers/customerContactsFollup/index.js +++ b/api/app/lib/controllers/customerContactsFollup/index.js @@ -1,11 +1,11 @@ 'use strict'; -// 查询储备项目统计表 +// 查询客户联系人对接跟进 async function getCustomerContactsFollowup(ctx, next) { const { type } = ctx.params; let rslt = null; try { - rslt = await ctx.fs.dc.models.ReserveItemReport.findAll({ + rslt = await ctx.fs.dc.models.CustomerContactsFollowup.findAll({ order: [['id', 'DESC']], // where: { type: type } }) diff --git a/web/client/src/sections/business/containers/customer/customerContactFollowup.jsx b/web/client/src/sections/business/containers/customer/customerContactFollowup.jsx index 8be2127..46cf5b7 100644 --- a/web/client/src/sections/business/containers/customer/customerContactFollowup.jsx +++ b/web/client/src/sections/business/containers/customer/customerContactFollowup.jsx @@ -4,13 +4,18 @@ import { Select, Input, Button, Banner, Radio, Tooltip, Table } from '@douyinfe/ import { IconSearch } from '@douyinfe/semi-icons'; import '../../style.less' import moment from 'moment' +import FileSaver from 'file-saver'; +import xlsx from 'xlsx'; const CustomerContactFollowup = (props) => { - const { dispatch,actions } = props + const { dispatch, actions, customerContactsFollowupList } = props + const [keyType, setKeyType] = useState('customer'); + const [keyTypeSearch, setKeyTypeSearch] = useState('customer'); + const [keyword, setKeyword] = useState(''); + const [keywordSearch, setKeywordSearch] = useState(''); useEffect(() => { dispatch(actions.businessManagement.getCustomerContactsFollowup()); }, []); - const columns = [ { title: '序号', @@ -19,46 +24,84 @@ const CustomerContactFollowup = (props) => { }, { title: '客户名称', - dataIndex: 'department', + dataIndex: 'customer', + render: (text, record) => text == null ? '---' : text }, { title: '项目名称', - dataIndex: 'salesManager', + dataIndex: 'items', + render: (text, record) => text == null ? '---' : text }, { title: '部门', - dataIndex: 'projectName', + dataIndex: 'department', + render: (text, record) => text == null ? '---' : text }, { title: '跟进人员', - dataIndex: 'customerName', + dataIndex: 'sale', + render: (text, record) => text == null ? '---' : text }, { title: '跟进日期', - dataIndex: 'projectType', + dataIndex: 'updatetime', + render: (text, record) => text == null ? '---' : moment(text).format('YYYY-MM-DD') }, { title: '客户联系人', - dataIndex: 'projectState', + dataIndex: 'customerContacts', + render: (text, record) => text == null ? '---' : text }, { title: '联系方式', - dataIndex: 'projectDescribe', + dataIndex: 'phone', + render: (text, record) => text == null ? '---' : text }, { title: '拜访方式', - dataIndex: 'creationTime', + dataIndex: 'visitStyle', + render: (text, record) => text == null ? '---' : text }, { title: '项目进展', - dataIndex: 'reserveProjectCycle', + dataIndex: 'itemText', + render: (text, record) => text == null ? '---' : text } ]; - const data = []; - const exportAll = () => { + let data = customerContactsFollowupList; + if (keywordSearch != '') { + switch (keyTypeSearch) { + case 'customer': + data = customerContactsFollowupList.filter(e => e.customer.match(keywordSearch)) + break; + case 'items': + data = customerContactsFollowupList.filter(e => e.items.match(keywordSearch)) + break; + case 'sale': + data = customerContactsFollowupList.filter(e => e.sale.match(keywordSearch)) + break; + default: + break; + } } - + const search = () => { + setKeywordSearch(keyword) + setKeyTypeSearch(keyType) + } + const exportAll = () => { + // const allList = this.props.projectList.rows; + if (JSON.stringify(customerContactsFollowupList) != '[]') { + const strs = "\uFEFF" + ['序号,客户名称,项目名称,部门,跟进人员,跟进日期,客户联系人,联系方式,拜访方式,项目进展'].concat(customerContactsFollowupList.map((d, i) => { + let update = d.updatetime ? moment(d.updatetime).format('YYYY-MM-DD') : '' + return [`"${i + 1}"`, `"${d['customer'] ? d['customer'] : ''}"`, `"${d['items'] ? d['items'] : ''}"`, `"${d['department'] ? d['department'] : ''}"`, `"${d['sale'] ? d['sale'] : ''}"`, `"${update}"`, `"${d['customerContacts'] ? d['customerContacts'] : ''}"`, `"${d['phone'] ? d['phone'] : ''}"`, `"${d['visitStyle'] ? d['visitStyle'] : ''}"`, `"${d['itemText'] ? d['itemText'] : ''}"`,].join(',') + })).join('\r\n'); + let blob = new Blob([strs], { type: 'text/csv' }); + FileSaver.saveAs(blob, `客户联系人对接跟进记录${moment().format('YYYY-MM-DD')}.csv`); + } else if (JSON.stringify(customerContactsFollowupList) == '[]') { + message.warning('暂无导出的数据') + } + } return ( <>
@@ -80,29 +123,27 @@ const CustomerContactFollowup = (props) => {
+ } showClear placeholder='请输入关键字' style={{ width: 346 }} - // onChange={seachValueChange} + onChange={(value) => { setKeyword(value) }} >
- +
- +
@@ -112,10 +153,12 @@ const CustomerContactFollowup = (props) => { function mapStateToProps(state) { - const { auth, global } = state; + const { auth, global, customerContactsFollowupList } = state; return { user: auth.user, actions: global.actions, + customerContactsFollowupList: customerContactsFollowupList.data || [], + isRequesting: customerContactsFollowupList.isRequesting }; } diff --git a/web/package.json b/web/package.json index c66ff68..51976e1 100644 --- a/web/package.json +++ b/web/package.json @@ -58,6 +58,7 @@ "echarts": "^5.3.3", "echarts-for-react": "^3.0.2", "ezuikit-js": "^0.6.1", + "file-saver": "^2.0.5", "fs-attachment": "^1.0.0", "fs-web-server-scaffold": "^1.0.6", "js-cookie": "^3.0.1", @@ -78,6 +79,7 @@ "webpack-cli": "^4.2.0", "webpack-dev-middleware": "^4.0.2", "webpack-dev-server": "^3.11.2", - "webpack-hot-middleware": "^2.25.0" + "webpack-hot-middleware": "^2.25.0", + "xlsx": "^0.18.5" } }