diff --git a/src/stores/CustomerStore.js b/src/stores/CustomerStore.js
index 3a79db9..b74284e 100644
--- a/src/stores/CustomerStore.js
+++ b/src/stores/CustomerStore.js
@@ -1,7 +1,7 @@
import {makeAutoObservable, runInAction} from "mobx";
import { fetchJSON } from '../utils/request';
import * as config from "../config";
-import { groupsMappedByKey, dataFieldAlias, sitesMappedByCode, pivotBy } from './../libs/ht';
+import { groupsMappedByKey, sitesMappedByCode, pivotBy } from './../libs/ht';
/**
* 用于透视的数据
@@ -258,6 +258,7 @@ class CustomerStore {
sales_regular_data = {
loading: false,
data: [],
+ mergedData: [],
rawData: [],
searchValues: {
DepartmentList: ['1', '2', '28', '7'].map(kk => groupsMappedByKey[kk]),
@@ -269,12 +270,13 @@ class CustomerStore {
get_sales_regular_data = async (param) => {
this.sales_regular_data.loading = true;
const rawData = await getDetailData({...param, IncludeTickets: 1});
- const filterHasOld = rawData.filter(ele => (ele.IsOld === '1' || ele.isCusCommend === '1'));
- const { data: hasOldData, columnValues, summaryRows, summaryColumns, pivotKeys, summaryMix } = pivotBy(filterHasOld, [['hasOld', 'operatorName'], [], []]);
+ const filterHasOld = rawData.filter(ele => (ele.IsOld === '1' || ele.isCusCommend === '1')).map(e => ({...e, operatorNameB: e.operatorName.replace(/\([^)]*\)/gi, '').toLowerCase()}));
+
+ const { data: hasOldData, } = pivotBy(filterHasOld, [['hasOld', 'operatorName'], [], []]);
const { data: IsOldData, } = pivotBy(filterHasOld.filter(ele => ele.IsOld === '1'), [['operatorName', 'IsOld_txt', ], [], []]);
const { data: isCusCommendData, } = pivotBy(filterHasOld.filter(ele => ele.isCusCommend === '1'), [['operatorName', 'isCusCommend_txt', ], [], []]);
// console.log('IsOldData====', IsOldData, '\nisCusCommend', isCusCommendData);
- // console.log('data====', data, '\ncolumnValues', columnValues, '\nsummaryRows', summaryRows, '\nsummaryColumns', summaryColumns, '\nsummaryMix', summaryMix, '\nhasOld',filterHasOld);
+ // console.log('data====', rawData, '\ncolumnValues', columnValues, '\nsummaryRows', summaryRows, '\nsummaryColumns', summaryColumns, '\nsummaryMix', summaryMix, '\nhasOld',filterHasOld);
const mergeDataBySales = hasOldData.map((ele) => ({
...ele,
children: [].concat(
@@ -282,9 +284,25 @@ class CustomerStore {
isCusCommendData.filter((ele2) => ele2.operatorName === ele.operatorName).map(o => ({...o, operatorName: o.isCusCommend_txt, key: o.rowLabel}))
),
}));
- // console.log('merge', mergeDataBySales);
+
+ // 合并顾问的账户
+ const { data: hasOldDataSales, } = pivotBy(filterHasOld, [['hasOld', 'operatorNameB'], [], []]);
+ const { data: IsOldDataSales, } = pivotBy(filterHasOld.filter(ele => ele.IsOld === '1'), [['operatorNameB', 'IsOld_txt', ], [], []]);
+ const { data: isCusCommendDataSales, } = pivotBy(filterHasOld.filter(ele => ele.isCusCommend === '1'), [['operatorNameB', 'isCusCommend_txt', ], [], []]);
+ const mergeDataBySalesAccount = hasOldDataSales.map((ele) => ({
+ ...ele,
+ operatorName: ele.operatorNameB,
+ children: [].concat(
+ IsOldDataSales.filter((ele1) => ele1.operatorNameB === ele.operatorNameB).map(o => ({...o, operatorName: o.IsOld_txt, key: o.rowLabel})),
+ isCusCommendDataSales.filter((ele2) => ele2.operatorNameB === ele.operatorNameB).map(o => ({...o, operatorName: o.isCusCommend_txt, key: o.rowLabel}))
+ ),
+ }));
+ // console.log('IsOldDataSales====', IsOldDataSales, '\nisCusCommendDataSales', isCusCommendDataSales);
+ // console.log('mergeDataBySalesAccount====', mergeDataBySalesAccount);
+
this.sales_regular_data.loading = false;
this.sales_regular_data.data = mergeDataBySales;
+ this.sales_regular_data.mergedData = mergeDataBySalesAccount;
this.sales_regular_data.rawData = filterHasOld;
};
diff --git a/src/views/SalesCustomerCareRegular.jsx b/src/views/SalesCustomerCareRegular.jsx
index 57ea4a1..ed8cd22 100644
--- a/src/views/SalesCustomerCareRegular.jsx
+++ b/src/views/SalesCustomerCareRegular.jsx
@@ -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 } from 'antd';
+import { Table, Row, Col, Divider, Button, Switch } from 'antd';
import SearchForm from '../components/search/SearchForm';
import { TableExportBtn } from './../components/Data';
-import { uniqWith } from './../utils/commons';
+import { uniqWith, groupBy } from './../utils/commons';
// 注意TdCell要提到DataTable作用域外声明
const TdCell = (tdprops) => {
@@ -14,22 +14,45 @@ const TdCell = (tdprops) => {
};
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 { sales_regular_data: pageData } = customer_store;
- const [expandRowKeys, setExpandRowKeys] = 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(
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));
+ 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 = [
{ title: '顾问', dataIndex: 'operatorName', key: 'operatorName' },
{ title: '订单号', dataIndex: 'o_id', key: 'o_id' },
@@ -48,7 +71,7 @@ const SalesCustomerCareRegular = (props) => {
{ title: '页面类型', dataIndex: 'COLI_LineClass', key: 'COLI_LineClass' },
];
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: 'ConfirmOrder', title: '成交数', dataIndex: 'ConfirmOrder', 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: 'action', title: '', width: '5em', render: (_, r) => {
const rowChildren = pageData.rawData.filter(ele => ele.operatorName === r.operatorName);
- return r.hasOld ?