|
|
|
@ -1,10 +1,10 @@
|
|
|
|
|
import { createContext, useContext, useEffect, useState } from 'react';
|
|
|
|
|
import { observer } from 'mobx-react';
|
|
|
|
|
import { stores_Context } from '../config';
|
|
|
|
|
import { Table, Row, Col, Divider, Button, Switch } from 'antd';
|
|
|
|
|
import { Table, Row, Col, Divider, Button, Switch, Space } from 'antd';
|
|
|
|
|
import SearchForm from '../components/search/SearchForm';
|
|
|
|
|
import { TableExportBtn } from './../components/Data';
|
|
|
|
|
import { uniqWith, groupBy } from './../utils/commons';
|
|
|
|
|
import { TableExportBtn, VSTag } from './../components/Data';
|
|
|
|
|
import { uniqWith, groupBy, fixTo2Decimals, isEmpty } from './../utils/commons';
|
|
|
|
|
|
|
|
|
|
// 注意TdCell要提到DataTable作用域外声明
|
|
|
|
|
const TdCell = (tdprops) => {
|
|
|
|
@ -37,8 +37,19 @@ const SalesCustomerCareRegular = (props) => {
|
|
|
|
|
// ).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}))), []));
|
|
|
|
|
setDataForExportS(pageData.data.reduce((r, c) => r.concat([{...c, children: undefined}]), []));
|
|
|
|
|
setDataForExport(
|
|
|
|
|
pageData.data.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.data.reduce((r, c) => r.concat([{...c, children: undefined}], [{ ...c.vsData, vsData: {} }]), []).filter((ele) => ele.SumOrder !== undefined));
|
|
|
|
|
} else {
|
|
|
|
|
// const allOPI1 = uniqWith(
|
|
|
|
|
// pageData.mergedData.map((rr) => ({ text: rr.operatorName, value: rr.operatorName })),
|
|
|
|
@ -46,8 +57,18 @@ const SalesCustomerCareRegular = (props) => {
|
|
|
|
|
// ).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}))), []));
|
|
|
|
|
setDataForExportS(pageData.mergedData.reduce((r, c) => r.concat([{...c, children: undefined}]), []));
|
|
|
|
|
setDataForExport(
|
|
|
|
|
pageData.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.mergedData.reduce((r, c) => r.concat([{...c, children: undefined}], [{ ...c.vsData, vsData: {} }]), []).filter((ele) => ele.SumOrder !== undefined));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
@ -57,6 +78,7 @@ const SalesCustomerCareRegular = (props) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const rowColumns = [
|
|
|
|
|
{ title: '日期区间', dataIndex: 'seriesKey', key: 'seriesKey' },
|
|
|
|
|
{ title: '顾问', dataIndex: 'operatorName', key: 'operatorName' },
|
|
|
|
|
{ title: '订单号', dataIndex: 'o_id', key: 'o_id' },
|
|
|
|
|
{ title: '预定日期', dataIndex: 'applyDate', key: 'applyDate' },
|
|
|
|
@ -73,17 +95,30 @@ const SalesCustomerCareRegular = (props) => {
|
|
|
|
|
{ title: '来源', dataIndex: 'SourceType', key: 'SourceType' },
|
|
|
|
|
{ title: '页面类型', dataIndex: 'COLI_LineClass', key: 'COLI_LineClass' },
|
|
|
|
|
];
|
|
|
|
|
const calcDelta = (r, key) => !isEmpty(Number(r.vsData[key])) ? fixTo2Decimals((Number(r[key] || 0) - Number(r.vsData[key]))/Number(r.vsData[key]) *100) : null;
|
|
|
|
|
const renderVS = (v, r, key) => {
|
|
|
|
|
const delta = calcDelta(r, key);
|
|
|
|
|
return <>
|
|
|
|
|
<Space direction={'vertical'}>
|
|
|
|
|
<span>
|
|
|
|
|
{v || 0}
|
|
|
|
|
{r.vsData[key] ? <span type="secondary"> VS {r.vsData[key]}</span> : null}
|
|
|
|
|
</span>
|
|
|
|
|
{delta && <VSTag diffPercent={delta} />}
|
|
|
|
|
</Space>
|
|
|
|
|
</>;
|
|
|
|
|
};
|
|
|
|
|
const columns = [
|
|
|
|
|
{ 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: 'ConfirmOrder', title: '成交数', dataIndex: 'ConfirmOrder', width: '5em' },
|
|
|
|
|
{ key: 'ConfirmPersonNum', title: '✔人数(SUM)', dataIndex: 'ConfirmPersonNum', width: '5em' },
|
|
|
|
|
{ key: 'confirmTourdays', title: '✔团天数(AVG)', dataIndex: 'confirmTourdays', width: '5em' },
|
|
|
|
|
{ key: 'SumML', title: '预计毛利', dataIndex: 'SumML', width: '5em' }, // SumML_txt
|
|
|
|
|
{ key: 'ConfirmRates', title: '成交率', dataIndex: 'ConfirmRates_txt', width: '5em' },
|
|
|
|
|
{ key: 'SingleML', title: '单团毛利', dataIndex: 'SingleML', width: '5em' },
|
|
|
|
|
{ key: 'SumOrder', title: '订单数', dataIndex: 'SumOrder', width: '5em', render: (v, r) => renderVS(v, r, 'SumOrder') },
|
|
|
|
|
{ key: 'ConfirmOrder', title: '成交数', dataIndex: 'ConfirmOrder', width: '5em', render: (v, r) => renderVS(v, r, 'ConfirmOrder') },
|
|
|
|
|
{ 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: 'SingleML', title: '单团毛利', dataIndex: 'SingleML', width: '5em', render: (v, r) => renderVS(v, r, 'SingleML') },
|
|
|
|
|
{ key: 'action', title: '', width: '5em', render: (_, r) => {
|
|
|
|
|
const rowChildren = pageData.rawData.filter(ele => ele.operatorName === r.operatorName);
|
|
|
|
|
const rowChildren = ifmerge ? pageData.rawData.filter(ele => ele.operatorName.includes(r.operatorName)) : pageData.rawData.filter(ele => ele.operatorName === r.operatorName);
|
|
|
|
|
return r.hasOld ? <TableExportBtn btnTxt='明细' label={`老客户明细-${r.operatorName}`} {...{ columns: rowColumns, dataSource: rowChildren }} /> : null;
|
|
|
|
|
} },
|
|
|
|
|
];
|
|
|
|
@ -101,12 +136,12 @@ const SalesCustomerCareRegular = (props) => {
|
|
|
|
|
fieldProps: {
|
|
|
|
|
DepartmentList: { show_all: false, mode: 'multiple' },
|
|
|
|
|
WebCode: { show_all: false, mode: 'multiple' },
|
|
|
|
|
dates: { hide_vs: true },
|
|
|
|
|
dates: { hide_vs: false },
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
onSubmit={(_err, obj, form, str) => {
|
|
|
|
|
customer_store.setSearchValues(obj, form, 'sales_regular_data');
|
|
|
|
|
customer_store.get_sales_regular_data(obj);
|
|
|
|
|
customer_store.get_sales_regular_data_vs(obj);
|
|
|
|
|
// MeetingDataStore.setSearchValues(form);
|
|
|
|
|
// dataRefresh(obj);
|
|
|
|
|
}}
|
|
|
|
@ -129,9 +164,9 @@ const SalesCustomerCareRegular = (props) => {
|
|
|
|
|
<Divider type={'vertical'} />
|
|
|
|
|
<TableExportBtn btnTxt='导出明细' label={`${formValuesToSub.Date1}-销售.老客户-明细`} {...{ columns: rowColumns, dataSource: pageData.rawData }} />
|
|
|
|
|
<Divider type={'vertical'} />
|
|
|
|
|
<TableExportBtn btnTxt='导出下表-展开' label={`${formValuesToSub.Date1}-销售.老客户`} {...{ columns, dataSource: dataForExport }} />
|
|
|
|
|
<TableExportBtn btnTxt='导出下表-展开' label={`${formValuesToSub.Date1}-销售.老客户`} {...{ columns: [rowColumns[0], ...columns], dataSource: dataForExport }} />
|
|
|
|
|
<Divider type={'vertical'} />
|
|
|
|
|
<TableExportBtn btnTxt='导出下表-总' label={`${formValuesToSub.Date1}-销售.老客户`} {...{ columns, dataSource: dataForExportS }} />
|
|
|
|
|
<TableExportBtn btnTxt='导出下表-总' label={`${formValuesToSub.Date1}-销售.老客户`} {...{ columns: [rowColumns[0], ...columns], dataSource: dataForExportS }} />
|
|
|
|
|
</Divider>
|
|
|
|
|
<Table
|
|
|
|
|
sticky
|
|
|
|
|