feat: 老客户-分析: 增加`目的地国家`

main
Lei OT 3 months ago
parent ead5b37ded
commit 16e6ec574a

@ -1,7 +1,8 @@
import { useContext, useEffect, useState } from 'react';
import { observer } from 'mobx-react';
import { stores_Context } from '../config';
import { Table, Row, Col, Divider, Switch, Space, Tabs } from 'antd';
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 { fixTo2Decimals, isEmpty } from '@haina/utils-commons';
@ -16,6 +17,19 @@ const TdCell = (tdprops) => {
const pivotOptions = [
{ key: 'operatorName', label: '顾问' },
{ key: 'country', label: '国籍' },
{
key: 'destinationCountry',
value: 'destinationCountry',
labelX: '目的地国家',
label: (
<>
目的地国家&nbsp;&nbsp;
<Tooltip key="total_data_tips" title={'途径的国家将会重复计算'}>
<InfoCircleOutlined className="ant-tag-gold" />
</Tooltip>
</>
),
},
];
const pivotColOptions = [
{ key: 'hasOld', value: 'hasOld', label: '老客户+推荐' },
@ -171,7 +185,7 @@ const CustomerCareRegularPivot = (props) => {
<TableExportBtn
btnTxt="导出明细"
label={`${formValuesToSub.Date1}-老客户-明细`}
{...{ columns: [{ title: ele.label, dataIndex: pivotRow, key: pivotRow }, ...rowColumns], dataSource: rawData }}
{...{ columns: [{ title: ele.labelX || ele.label, dataIndex: pivotRow, key: pivotRow }, ...rowColumns], dataSource: rawData }}
/>
{/* <Divider type={'vertical'} />
<TableExportBtn
@ -183,7 +197,7 @@ const CustomerCareRegularPivot = (props) => {
<TableExportBtn
btnTxt="导出下表"
label={`${formValuesToSub.Date1}-${ele.label}.${pivotColLabel}`}
{...{ columns: [{ title: ele.label, dataIndex: pivotRow, key: pivotRow }, ...columns], dataSource: dataForExportS }}
{...{ columns: [{ title: ele.labelX || ele.label, dataIndex: pivotRow, key: pivotRow }, ...columns], dataSource: dataForExportS }}
/>
</Divider>
</>

@ -119,9 +119,10 @@ export const TableExportBtn = ({label, columns, dataSource, btnTxt, ...props}) =
const export_val = typeof kset?.dataExport === 'function' ? kset.dataExport('', item) : null;
const render_val = typeof kset?.render === 'function' ? kset.render('', item) : null;
const data_val = kset?.dataIndex ? (Array.isArray(kset.dataIndex) ? getNestedValue(item, kset.dataIndex) : item[kset.dataIndex]) : undefined;
const data_val_str = data_val ? String(data_val) : '';
const x_val = item[`${kset.dataIndex}_X`];
// const _title = kset.title.replace('-[object Object]', '');
const v = { [kset.title]: x_val || export_val || data_val || render_val };
const v = { [kset.title]: x_val || export_val || data_val_str || render_val };
return { ...sv, ...v };
}, {});
return itemMapped;

@ -466,8 +466,8 @@ class CustomerStore {
// mergedData: [],
rawData: [],
searchValues: {
DepartmentList: ['1', '2', '28', '7'].map(kk => groupsMappedByKey[kk]),
WebCode: ['CHT','AH','JH','GH','ZWQD','GH_ZWQD_HW','GHKYZG','GHKYHW'].map(kk => sitesMappedByCode[kk]),
DepartmentList: ['1', '2', '28', '7', '33'].map(kk => groupsMappedByKey[kk]),
WebCode: ['CHT','AH','HTravel','JH','GH','ZWQD','GH_ZWQD_HW','GHKYZG','GHKYHW'].map(kk => sitesMappedByCode[kk]),
DateType: { key: 'applyDate', label: '提交日期'},
IncludeTickets: { key: '0', label: '不含门票' },
},
@ -554,17 +554,19 @@ class CustomerStore {
// console.log('regular_data_pivot -------------------------------------------------------------- rawData 000 ', toJS(this.sales_regular_data.rawData));
// console.log('regular_data_pivot ---- ', pivotRow, pivotCol);
const [result1, result2] = this.sales_regular_data.rawDataArr;
const allRows = Array.from(new Set([...result1.filterHasOld.map(row=>row[pivotRow]), ...result2.filterHasOld.map(row=>row[pivotRow])]));
// const allRows = Array.from(new Set([...result1.filterHasOld.map(row=>row[pivotRow]), ...result2.filterHasOld.map(row=>row[pivotRow])]));
// console.log(' ------ allRows', allRows);
const [pivot1, pivot2] = [result1, result2].map(_result => {
const [{ pivotResult: pivot1, rowValues: rowValues1 }, { pivotResult: pivot2, rowValues: rowValues2 }] = [result1, result2].map(_result => {
const dataColField = pivotCol.replace('_txt', '');
const rawData = pivotCol === 'hasOld' ? _result.filterHasOld : _result.filterHasOld.filter((ele) => ele[dataColField] === '1');
const { data: pivotResult } = pivotBy(rawData, [[pivotRow, pivotCol], [], []]);
return pivotResult;
const { data: pivotResult, columnValues: [[rowValues,], columnsKeys, dateKeys] } = pivotBy(rawData, [[pivotRow, pivotCol], [], []]);
return { pivotResult, rowValues };
});
const allRowValues = Array.from(new Set([...rowValues1, ...rowValues2]));
// console.log(' ------ xx', rowValues1);
const rows1 = groupBy(pivot1, pivotRow);
const rows2 = groupBy(pivot2, pivotRow);
const pivotResultWithCompare = isEmpty(pivot2) ? pivot1 : allRows.reduce((r, rowName) => {
const pivotResultWithCompare = isEmpty(pivot2) ? pivot1 : allRowValues.reduce((r, rowName) => {
const _default = { [pivotRow]: rowName, rowLabel: rows1?.[rowName]?.rowLabel || rows2?.[rowName]?.rowLabel, children: rows1?.[rowName], key: rowName};
const operatorRow = {...(rows1?.[rowName]?.[0] || _default), vsData: rows2?.[rowName]?.[0] || {}};
// 展开的两项: '老客户', '老客户推荐'
@ -582,7 +584,7 @@ class CustomerStore {
// console.log(' ------ pivot1', pivot1, '\npivot2', pivot2, '\npivotResultWithCompare', pivotResultWithCompare);
const filterColValues = uniqWith(
allRows.map((rr) => ({ text: rr, value: rr })),
allRowValues.map((rr) => ({ text: rr, value: rr })),
(a, b) => JSON.stringify(a) === JSON.stringify(b)
).sort((a, b) => a.text.localeCompare(b.text, 'zh-CN'));

Loading…
Cancel
Save