|
|
|
|
@ -1,10 +1,11 @@
|
|
|
|
|
import { useContext, useEffect, useState } from 'react';
|
|
|
|
|
import { observer } from 'mobx-react';
|
|
|
|
|
import { toJS } from 'mobx';
|
|
|
|
|
import { stores_Context } from '../config';
|
|
|
|
|
import { Table, Row, Col, Divider, Switch, Space, Tabs, Tooltip } from 'antd';
|
|
|
|
|
import { InfoCircleOutlined } from '@ant-design/icons';
|
|
|
|
|
import SearchForm from '../components/search/SearchForm';
|
|
|
|
|
import { TableExportBtn, VSTag } from '../components/Data';
|
|
|
|
|
import { RenderVSDataCell, TableExportBtn, VSTag } from '../components/Data';
|
|
|
|
|
import { fixTo2Decimals, isEmpty } from '@haina/utils-commons';
|
|
|
|
|
|
|
|
|
|
// 注意TdCell要提到DataTable作用域外声明
|
|
|
|
|
@ -39,8 +40,8 @@ const pivotColOptions = [
|
|
|
|
|
const CustomerCareRegularPivot = (props) => {
|
|
|
|
|
const { date_picker_store: searchFormStore, customer_store } = useContext(stores_Context);
|
|
|
|
|
const { formValues, formValuesToSub, siderBroken } = searchFormStore;
|
|
|
|
|
const { loading, pivotResult, filterColValues, rawData } = customer_store.sales_regular_data;
|
|
|
|
|
|
|
|
|
|
const { loading, pivotResult, filterColValues, rawData, countrySummary } = customer_store.sales_regular_data;
|
|
|
|
|
// console.log('❤❤', countrySummary);
|
|
|
|
|
const [pivotRow, setPivotRow] = useState('operatorName');
|
|
|
|
|
const [pivotCol, setPivotCol] = useState('hasOld');
|
|
|
|
|
const [pivotColLabel, setPivotColLabel] = useState('老客户+推荐');
|
|
|
|
|
@ -57,36 +58,10 @@ const CustomerCareRegularPivot = (props) => {
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if ( ! ifmerge) {
|
|
|
|
|
// setDataSource(pageData[pivotRow].data);
|
|
|
|
|
setDataSource(pivotResult);
|
|
|
|
|
// setDataForExport(
|
|
|
|
|
// // pageData[pivotRow].data.reduce(
|
|
|
|
|
// pivotResult.reduce(
|
|
|
|
|
// (r, c) =>
|
|
|
|
|
// r.concat(
|
|
|
|
|
// [{ ...c, children: undefined }],
|
|
|
|
|
// (c?.children || [])
|
|
|
|
|
// .reduce((rc, ele) => rc.concat([{ ...ele, [pivotRow]: ele.rowLabel }], [{ ...ele.vsData, [pivotRow]: ele.vsData.rowLabel, vsData: {} }]), [])
|
|
|
|
|
// .filter((ele) => ele.SumOrder !== undefined)
|
|
|
|
|
// ),
|
|
|
|
|
// []
|
|
|
|
|
// )
|
|
|
|
|
// );
|
|
|
|
|
setDataForExportS(pivotResult.reduce((r, c) => r.concat([{...c, children: undefined}], [{ ...c.vsData, vsData: {} }]), []).filter((ele) => ele.SumOrder !== undefined));
|
|
|
|
|
} else {
|
|
|
|
|
// setDataSource(pageData[pivotRow].mergedData);
|
|
|
|
|
// setDataForExport(
|
|
|
|
|
// pageData[pivotRow].mergedData.reduce(
|
|
|
|
|
// (r, c) =>
|
|
|
|
|
// r.concat(
|
|
|
|
|
// [{ ...c, children: undefined }],
|
|
|
|
|
// c.children.reduce((rc, ele) => rc.concat([{ ...ele, operatorName: ele.rowLabel }], [{ ...ele.vsData, operatorName: ele.vsData.rowLabel, vsData: {} }]), [])
|
|
|
|
|
// .filter((ele) => ele.SumOrder !== undefined)
|
|
|
|
|
// ),
|
|
|
|
|
// []
|
|
|
|
|
// )
|
|
|
|
|
// );
|
|
|
|
|
// setDataForExportS(pageData[pivotRow].mergedData.reduce((r, c) => r.concat([{...c, children: undefined}], [{ ...c.vsData, vsData: {} }]), []).filter((ele) => ele.SumOrder !== undefined));
|
|
|
|
|
//
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return () => {};
|
|
|
|
|
@ -130,9 +105,10 @@ const CustomerCareRegularPivot = (props) => {
|
|
|
|
|
{ key: 'ConfirmPersonNum', title: '✔人数(SUM)', dataIndex: 'ConfirmPersonNum', width: '5em', render: (v, r) => renderVS(v, r, 'ConfirmPersonNum') },
|
|
|
|
|
{ key: 'confirmTourdays', title: '✔团天数(AVG)', dataIndex: 'confirmTourdays', width: '5em', render: (v, r) => renderVS(v, r, 'confirmTourdays') },
|
|
|
|
|
{ key: 'SumML', title: '预计毛利', dataIndex: 'SumML', width: '5em', render: (v, r) => renderVS(v, r, 'SumML') }, // SumML_txt
|
|
|
|
|
{ key: 'ConfirmRates', title: '成交率', dataIndex: 'ConfirmRates_txt', width: '5em', render: (v, r) => renderVS(v, r, 'ConfirmRates') },
|
|
|
|
|
{ key: 'ConfirmRates', title: '成交率', dataIndex: 'ConfirmRates_txt', width: '5em', render: (v, r) => renderVS(v, r, 'ConfirmRates'), suffix: '%' },
|
|
|
|
|
{ key: 'SingleML', title: '单团毛利', dataIndex: 'SingleML', width: '5em', render: (v, r) => renderVS(v, r, 'SingleML') },
|
|
|
|
|
].map(c => ({...c, sorter: (a, b) => (a[c.key] - b[c.key])}));
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<Row gutter={16} className={siderBroken ? '' : 'sticky-top'}>
|
|
|
|
|
@ -167,32 +143,13 @@ const CustomerCareRegularPivot = (props) => {
|
|
|
|
|
...ele,
|
|
|
|
|
children: (
|
|
|
|
|
<>
|
|
|
|
|
{/* <h2>{ele.label}-老客户, 含推荐</h2> */}
|
|
|
|
|
<>
|
|
|
|
|
<Divider orientation={'right'} style={{backgroundColor: '#fff', margin: 0, padding: '10px 0'}} >
|
|
|
|
|
{/* {dataSource.length > 0 && pivotRow === 'operatorName' && (
|
|
|
|
|
<Switch
|
|
|
|
|
unCheckedChildren="各账户"
|
|
|
|
|
checkedChildren="合并"
|
|
|
|
|
key={'openOrMerge'}
|
|
|
|
|
checked={ifmerge}
|
|
|
|
|
onChange={(e) => {
|
|
|
|
|
setIfmerge(e);
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
<Divider type={'vertical'} /> */}
|
|
|
|
|
<TableExportBtn
|
|
|
|
|
btnTxt="导出明细"
|
|
|
|
|
label={`${formValuesToSub.Date1}-老客户-明细`}
|
|
|
|
|
{...{ columns: [{ title: ele.labelX || ele.label, dataIndex: pivotRow, key: pivotRow }, ...rowColumns], dataSource: rawData }}
|
|
|
|
|
/>
|
|
|
|
|
{/* <Divider type={'vertical'} />
|
|
|
|
|
<TableExportBtn
|
|
|
|
|
btnTxt="导出下表-展开"
|
|
|
|
|
label={`${formValuesToSub.Date1}-${ele.label}.老客户`}
|
|
|
|
|
{...{ columns: [{ title: ele.label, dataIndex: pivotRow, key: pivotRow }, ...columns], dataSource: dataForExport }}
|
|
|
|
|
/> */}
|
|
|
|
|
<Divider type={'vertical'} />
|
|
|
|
|
<TableExportBtn
|
|
|
|
|
btnTxt="导出下表"
|
|
|
|
|
@ -209,12 +166,11 @@ const CustomerCareRegularPivot = (props) => {
|
|
|
|
|
customer_store.regular_data_pivot(pivotRow, sub);
|
|
|
|
|
}}
|
|
|
|
|
items={pivotColOptions.map((col, i) => {
|
|
|
|
|
// const SubjectTableComponent = subjectComponents[ele.key];
|
|
|
|
|
return {
|
|
|
|
|
...col,
|
|
|
|
|
children: (
|
|
|
|
|
<Table
|
|
|
|
|
sticky
|
|
|
|
|
sticky={{ offsetHeader: 88 }}
|
|
|
|
|
dataSource={dataSource}
|
|
|
|
|
loading={loading}
|
|
|
|
|
columns={[
|
|
|
|
|
@ -229,8 +185,24 @@ const CustomerCareRegularPivot = (props) => {
|
|
|
|
|
},
|
|
|
|
|
...columns,
|
|
|
|
|
]}
|
|
|
|
|
summary={() => {
|
|
|
|
|
return (
|
|
|
|
|
pivotRow === 'country' &&
|
|
|
|
|
countrySummary.map((srow) => (
|
|
|
|
|
<Table.Summary.Row key={srow.key}>
|
|
|
|
|
<Table.Summary.Cell index1={0}><b>{srow.country}</b></Table.Summary.Cell>
|
|
|
|
|
{columns.map((td) => (
|
|
|
|
|
<Table.Summary.Cell key={td.key}>
|
|
|
|
|
<RenderVSDataCell data1={srow[td.dataIndex]} data2={srow.vsData?.[td.dataIndex]} showDiffData={toJS(formValuesToSub.DateDiff1)} dataSuffix={td.suffix} />
|
|
|
|
|
</Table.Summary.Cell>
|
|
|
|
|
))}
|
|
|
|
|
</Table.Summary.Row>
|
|
|
|
|
))
|
|
|
|
|
);
|
|
|
|
|
}}
|
|
|
|
|
pagination={false}
|
|
|
|
|
/>)
|
|
|
|
|
/>
|
|
|
|
|
),
|
|
|
|
|
};
|
|
|
|
|
})}
|
|
|
|
|
/>
|
|
|
|
|
|