|
|
@ -1,10 +1,10 @@
|
|
|
|
import { createContext, useContext, useEffect, useState } from 'react';
|
|
|
|
import { createContext, useContext, useEffect, useState } from 'react';
|
|
|
|
import { observer } from 'mobx-react';
|
|
|
|
import { observer } from 'mobx-react';
|
|
|
|
import { stores_Context } from '../config';
|
|
|
|
import { stores_Context } from '../config';
|
|
|
|
import { Table, Row, Col, Divider, Button } from 'antd';
|
|
|
|
import { Table, Row, Col, Divider, Button, Switch } from 'antd';
|
|
|
|
import SearchForm from '../components/search/SearchForm';
|
|
|
|
import SearchForm from '../components/search/SearchForm';
|
|
|
|
import { TableExportBtn } from './../components/Data';
|
|
|
|
import { TableExportBtn } from './../components/Data';
|
|
|
|
import { uniqWith } from './../utils/commons';
|
|
|
|
import { uniqWith, groupBy } from './../utils/commons';
|
|
|
|
|
|
|
|
|
|
|
|
// 注意TdCell要提到DataTable作用域外声明
|
|
|
|
// 注意TdCell要提到DataTable作用域外声明
|
|
|
|
const TdCell = (tdprops) => {
|
|
|
|
const TdCell = (tdprops) => {
|
|
|
@ -14,22 +14,45 @@ const TdCell = (tdprops) => {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const SalesCustomerCareRegular = (props) => {
|
|
|
|
const SalesCustomerCareRegular = (props) => {
|
|
|
|
const { orders_store, date_picker_store: searchFormStore, customer_store } = useContext(stores_Context);
|
|
|
|
const { date_picker_store: searchFormStore, customer_store } = useContext(stores_Context);
|
|
|
|
const { formValues, formValuesToSub, siderBroken } = searchFormStore;
|
|
|
|
const { formValues, formValuesToSub, siderBroken } = searchFormStore;
|
|
|
|
const { sales_regular_data: pageData } = customer_store;
|
|
|
|
const { sales_regular_data: pageData } = customer_store;
|
|
|
|
const [expandRowKeys, setExpandRowKeys] = useState([]);
|
|
|
|
|
|
|
|
const [dataForExport, setDataForExport] = useState([]);
|
|
|
|
const [dataForExport, setDataForExport] = useState([]);
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
|
|
setExpandRowKeys(pageData.data.map((ele) => ele.key));
|
|
|
|
|
|
|
|
setDataForExport(pageData.data.reduce((r, c) => r.concat([{...c, children: undefined}], c.children.map(ele => ({...ele, operatorName: ele.rowLabel}))), []));
|
|
|
|
|
|
|
|
return () => {};
|
|
|
|
|
|
|
|
}, [pageData.data]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const allOPI1 = uniqWith(
|
|
|
|
const allOPI1 = uniqWith(
|
|
|
|
pageData.data.map((rr) => ({ text: rr.operatorName, value: rr.operatorName })),
|
|
|
|
pageData.data.map((rr) => ({ text: rr.operatorName, value: rr.operatorName })),
|
|
|
|
(a, b) => JSON.stringify(a) === JSON.stringify(b)
|
|
|
|
(a, b) => JSON.stringify(a) === JSON.stringify(b)
|
|
|
|
).sort((a, b) => a.text.localeCompare(b.text));
|
|
|
|
).sort((a, b) => a.text.localeCompare(b.text));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const [OPIFilters, setOPIFilters] = useState([]);
|
|
|
|
|
|
|
|
const [dataSource, setDataSource] = useState([]);
|
|
|
|
|
|
|
|
const [ifmerge, setIfmerge] = useState(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
|
|
if ( ! ifmerge) {
|
|
|
|
|
|
|
|
// const allOPI1 = uniqWith(
|
|
|
|
|
|
|
|
// pageData.data.map((rr) => ({ text: rr.operatorName, value: rr.operatorName })),
|
|
|
|
|
|
|
|
// (a, b) => JSON.stringify(a) === JSON.stringify(b)
|
|
|
|
|
|
|
|
// ).sort((a, b) => a.text.localeCompare(b.text));
|
|
|
|
|
|
|
|
// setOPIFilters(allOPI1);
|
|
|
|
|
|
|
|
setDataSource(pageData.data);
|
|
|
|
|
|
|
|
setDataForExport(pageData.data.reduce((r, c) => r.concat([{...c, children: undefined}], c.children.map(ele => ({...ele, operatorName: ele.rowLabel}))), []));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// const allOPI1 = uniqWith(
|
|
|
|
|
|
|
|
// pageData.mergedData.map((rr) => ({ text: rr.operatorName, value: rr.operatorName })),
|
|
|
|
|
|
|
|
// (a, b) => JSON.stringify(a) === JSON.stringify(b)
|
|
|
|
|
|
|
|
// ).sort((a, b) => a.text.localeCompare(b.text));
|
|
|
|
|
|
|
|
// setOPIFilters(allOPI1);
|
|
|
|
|
|
|
|
setDataSource(pageData.mergedData);
|
|
|
|
|
|
|
|
setDataForExport(pageData.mergedData.reduce((r, c) => r.concat([{...c, children: undefined}], c.children.map(ele => ({...ele, operatorName: ele.rowLabel}))), []));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}, [ifmerge, pageData.data]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const rowColumns = [
|
|
|
|
const rowColumns = [
|
|
|
|
{ title: '顾问', dataIndex: 'operatorName', key: 'operatorName' },
|
|
|
|
{ title: '顾问', dataIndex: 'operatorName', key: 'operatorName' },
|
|
|
|
{ title: '订单号', dataIndex: 'o_id', key: 'o_id' },
|
|
|
|
{ title: '订单号', dataIndex: 'o_id', key: 'o_id' },
|
|
|
@ -48,7 +71,7 @@ const SalesCustomerCareRegular = (props) => {
|
|
|
|
{ title: '页面类型', dataIndex: 'COLI_LineClass', key: 'COLI_LineClass' },
|
|
|
|
{ title: '页面类型', dataIndex: 'COLI_LineClass', key: 'COLI_LineClass' },
|
|
|
|
];
|
|
|
|
];
|
|
|
|
const columns = [
|
|
|
|
const columns = [
|
|
|
|
{ key: 'operatorName', title: '顾问', dataIndex: 'operatorName', width: '6em', filters: allOPI1, onFilter: (value, record) => record.operatorName === value, filterSearch: true },
|
|
|
|
{ key: 'operatorName', title: '顾问', dataIndex: 'operatorName', width: '6em', filters: allOPI1, onFilter: (value, record) => value.includes(record.operatorName), filterSearch: true },
|
|
|
|
{ key: 'SumOrder', title: '订单数', dataIndex: 'SumOrder', width: '5em' },
|
|
|
|
{ key: 'SumOrder', title: '订单数', dataIndex: 'SumOrder', width: '5em' },
|
|
|
|
{ key: 'ConfirmOrder', title: '成交数', dataIndex: 'ConfirmOrder', width: '5em' },
|
|
|
|
{ key: 'ConfirmOrder', title: '成交数', dataIndex: 'ConfirmOrder', width: '5em' },
|
|
|
|
{ key: 'ConfirmPersonNum', title: '✔人数(SUM)', dataIndex: 'ConfirmPersonNum', width: '5em' },
|
|
|
|
{ key: 'ConfirmPersonNum', title: '✔人数(SUM)', dataIndex: 'ConfirmPersonNum', width: '5em' },
|
|
|
@ -58,7 +81,7 @@ const SalesCustomerCareRegular = (props) => {
|
|
|
|
{ key: 'SingleML', title: '单团毛利', dataIndex: 'SingleML', width: '5em' },
|
|
|
|
{ key: 'SingleML', title: '单团毛利', dataIndex: 'SingleML', width: '5em' },
|
|
|
|
{ key: 'action', title: '', width: '5em', render: (_, r) => {
|
|
|
|
{ key: 'action', title: '', width: '5em', render: (_, r) => {
|
|
|
|
const rowChildren = pageData.rawData.filter(ele => ele.operatorName === r.operatorName);
|
|
|
|
const rowChildren = pageData.rawData.filter(ele => ele.operatorName === r.operatorName);
|
|
|
|
return r.hasOld ? <TableExportBtn btnTxt='导出' label={`老客户-${r.operatorName}`} {...{ columns: rowColumns, dataSource: rowChildren }} /> : null;
|
|
|
|
return r.hasOld ? <TableExportBtn btnTxt='明细' label={`老客户明细-${r.operatorName}`} {...{ columns: rowColumns, dataSource: rowChildren }} /> : null;
|
|
|
|
} },
|
|
|
|
} },
|
|
|
|
];
|
|
|
|
];
|
|
|
|
return (
|
|
|
|
return (
|
|
|
@ -89,18 +112,30 @@ const SalesCustomerCareRegular = (props) => {
|
|
|
|
</Row>
|
|
|
|
</Row>
|
|
|
|
<h2>销售-老客户, 含推荐</h2>
|
|
|
|
<h2>销售-老客户, 含推荐</h2>
|
|
|
|
<Divider orientation="right" plain>
|
|
|
|
<Divider orientation="right" plain>
|
|
|
|
|
|
|
|
{pageData.data.length > 0 && (
|
|
|
|
|
|
|
|
<Switch
|
|
|
|
|
|
|
|
unCheckedChildren="各账户"
|
|
|
|
|
|
|
|
checkedChildren="合并"
|
|
|
|
|
|
|
|
key={'openOrMerge'}
|
|
|
|
|
|
|
|
checked={ifmerge}
|
|
|
|
|
|
|
|
onChange={(e) => {
|
|
|
|
|
|
|
|
setIfmerge(e);
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
<Divider type={'vertical'} />
|
|
|
|
<TableExportBtn btnTxt='导出明细' label={`${formValuesToSub.Date1}-销售.老客户-明细`} {...{ columns: rowColumns, dataSource: pageData.rawData }} />
|
|
|
|
<TableExportBtn btnTxt='导出明细' label={`${formValuesToSub.Date1}-销售.老客户-明细`} {...{ columns: rowColumns, dataSource: pageData.rawData }} />
|
|
|
|
<Divider type={'vertical'} />
|
|
|
|
<Divider type={'vertical'} />
|
|
|
|
<TableExportBtn btnTxt='导出下表' label={`${formValuesToSub.Date1}-销售.老客户`} {...{ columns, dataSource: dataForExport }} />
|
|
|
|
<TableExportBtn btnTxt='导出下表' label={`${formValuesToSub.Date1}-销售.老客户`} {...{ columns, dataSource: dataForExport }} />
|
|
|
|
</Divider>
|
|
|
|
</Divider>
|
|
|
|
<Table
|
|
|
|
<Table
|
|
|
|
sticky
|
|
|
|
sticky
|
|
|
|
dataSource={pageData.data}
|
|
|
|
dataSource={dataSource}
|
|
|
|
loading={pageData.loading}
|
|
|
|
loading={pageData.loading}
|
|
|
|
columns={columns}
|
|
|
|
columns={columns}
|
|
|
|
pagination={false}
|
|
|
|
pagination={false}
|
|
|
|
defaultExpandAllRows
|
|
|
|
// defaultExpandAllRows
|
|
|
|
expandable={{ defaultExpandAllRows: true, defaultExpandedRowKeys: pageData.data.map((ele) => ele.key) }}
|
|
|
|
// expandable={{ defaultExpandAllRows: true, expandedRowKeys: pageData.data.map((ele) => ele.key), }}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
);
|
|
|
|