perf: 老客户. 明细; -->zustand

main
Lei OT 3 months ago
parent a9a2fa8a29
commit a66ed759f8

@ -11,13 +11,13 @@ import { TableExportBtn, RenderVSDataCell } from '../components/Data';
import useCustomerRelationsStore from '../zustand/CustomerRelations'; import useCustomerRelationsStore from '../zustand/CustomerRelations';
import { useShallow } from 'zustand/shallow'; import { useShallow } from 'zustand/shallow';
import { fixTo2Decimals } from '@haina/utils-commons'; import { fixTo2Decimals, isEmpty } from '@haina/utils-commons';
const Customer_care_regular = () => { const Customer_care_regular = () => {
const { date_picker_store, customer_store } = useContext(stores_Context); const { date_picker_store, customer_store } = useContext(stores_Context);
const regular_data = customer_store.regular_data; const regular_data = customer_store.regular_data;
const [loading, loading2, searchValues, ] = useCustomerRelationsStore(useShallow((state) => [state.loading, state.loading2, state.searchValues,])); const [loading, loading2, searchValues, searchValuesToSub] = useCustomerRelationsStore(useShallow((state) => [state.loading, state.loading2, state.searchValues, state.searchValuesToSub]));
const [setSearchValues] = useCustomerRelationsStore(useShallow((state) => [state.setSearchValues])); const [setSearchValues] = useCustomerRelationsStore(useShallow((state) => [state.setSearchValues]));
const [regular] = useCustomerRelationsStore(useShallow((state) => [state.regular])); const [regular] = useCustomerRelationsStore(useShallow((state) => [state.regular]));
@ -284,14 +284,15 @@ const Customer_care_regular = () => {
key: 'OrderNum', key: 'OrderNum',
render: (text, record, index) => ( render: (text, record, index) => (
<> <>
<RenderVSDataCell showDiffData={true} data1={record.OrderNum} data2={record.diff?.OrderNum} /> <RenderVSDataCell showDiffData={!isEmpty(searchValuesToSub.DateDiff1)} data1={record.OrderNum} data2={record.diff?.OrderNum} />
{/* <span>{text}</span> */} {index === 0 && regular.total_data_tips !== '' && (
&nbsp;&nbsp; <>
{ &nbsp;&nbsp;
<Tooltip key="total_data_tips" title={regular.total_data_tips}> <Tooltip key="total_data_tips" title={regular.total_data_tips}>
{index === 0 && regular.total_data_tips !== '' && <InfoCircleOutlined className="ant-tag-gold" />} <InfoCircleOutlined className="ant-tag-gold" />
</Tooltip> </Tooltip>
} </>
)}
</> </>
), ),
}, },
@ -299,49 +300,84 @@ const Customer_care_regular = () => {
title: '订单数占比', title: '订单数占比',
dataIndex: 'OrderRate', dataIndex: 'OrderRate',
key: 'OrderRate', key: 'OrderRate',
render: (text, record) => <RenderVSDataCell showDiffData={true} data1={fixTo2Decimals(record.OrderRate*100)} data2={fixTo2Decimals(record.diff?.OrderRate*100)} dataSuffix='%' /> render: (text, record) => (
<RenderVSDataCell
showDiffData={!isEmpty(searchValuesToSub.DateDiff1)}
data1={fixTo2Decimals(record.OrderRate * 100)}
data2={fixTo2Decimals(record.diff?.OrderRate * 100)}
dataSuffix="%"
/>
),
}, },
{ {
title: '订单数占比(市场)', title: '订单数占比(市场)',
dataIndex: 'OrderRate2', dataIndex: 'OrderRate2',
key: 'OrderRate2', key: 'OrderRate2',
render: (text, record) => <RenderVSDataCell showDiffData={true} data1={fixTo2Decimals(record.OrderRate2*100)} data2={fixTo2Decimals(record.diff?.OrderRate2*100)} dataSuffix='%' /> render: (text, record) => (
<RenderVSDataCell
showDiffData={!isEmpty(searchValuesToSub.DateDiff1)}
data1={fixTo2Decimals(record.OrderRate2 * 100)}
data2={fixTo2Decimals(record.diff?.OrderRate2 * 100)}
dataSuffix="%"
/>
),
}, },
{ {
title: '成行数', title: '成行数',
dataIndex: 'SUCOrderNum', dataIndex: 'SUCOrderNum',
key: 'SUCOrderNum', key: 'SUCOrderNum',
render: (text, record) => <RenderVSDataCell showDiffData={true} data1={(record.SUCOrderNum)} data2={(record.diff?.SUCOrderNum)} /> render: (text, record) => <RenderVSDataCell showDiffData={!isEmpty(searchValuesToSub.DateDiff1)} data1={record.SUCOrderNum} data2={record.diff?.SUCOrderNum} />,
}, },
{ {
title: '成行率', title: '成行率',
dataIndex: 'SUCRate', dataIndex: 'SUCRate',
key: 'SUCRate', key: 'SUCRate',
render: (text, record) => <RenderVSDataCell showDiffData={true} data1={fixTo2Decimals(record.SUCRate*100)} data2={fixTo2Decimals(record.diff?.SUCRate*100)} dataSuffix='%' /> render: (text, record) => (
<RenderVSDataCell
showDiffData={!isEmpty(searchValuesToSub.DateDiff1)}
data1={fixTo2Decimals(record.SUCRate * 100)}
data2={fixTo2Decimals(record.diff?.SUCRate * 100)}
dataSuffix="%"
/>
),
}, },
{ {
title: '毛利', title: '毛利',
dataIndex: 'ML', dataIndex: 'ML',
key: 'ML', key: 'ML',
render: (text, record) => <RenderVSDataCell showDiffData={true} data1={(record.ML)} data2={(record.diff?.ML)} /> render: (text, record) => <RenderVSDataCell showDiffData={!isEmpty(searchValuesToSub.DateDiff1)} data1={record.ML} data2={record.diff?.ML} />,
}, },
{ {
title: '毛利占比', title: '毛利占比',
dataIndex: 'OrderMLRate', dataIndex: 'OrderMLRate',
key: 'OrderMLRate', key: 'OrderMLRate',
render: (text, record) => <RenderVSDataCell showDiffData={true} data1={fixTo2Decimals(record.OrderMLRate*100)} data2={fixTo2Decimals(record.diff?.OrderMLRate*100)} dataSuffix='%' /> render: (text, record) => (
<RenderVSDataCell
showDiffData={!isEmpty(searchValuesToSub.DateDiff1)}
data1={fixTo2Decimals(record.OrderMLRate * 100)}
data2={fixTo2Decimals(record.diff?.OrderMLRate * 100)}
dataSuffix="%"
/>
),
}, },
{ {
title: '毛利占比(市场)', title: '毛利占比(市场)',
dataIndex: 'OrderMLRate2', dataIndex: 'OrderMLRate2',
key: 'OrderMLRate2', key: 'OrderMLRate2',
render: (text, record) => <RenderVSDataCell showDiffData={true} data1={fixTo2Decimals(record.OrderMLRate2*100)} data2={fixTo2Decimals(record.diff?.OrderMLRate2*100)} dataSuffix='%' /> render: (text, record) => (
<RenderVSDataCell
showDiffData={!isEmpty(searchValuesToSub.DateDiff1)}
data1={fixTo2Decimals(record.OrderMLRate2 * 100)}
data2={fixTo2Decimals(record.diff?.OrderMLRate2 * 100)}
dataSuffix="%"
/>
),
}, },
{ {
title: '人数(含成人+儿童)', title: '人数(含成人+儿童)',
dataIndex: 'PersonNum', dataIndex: 'PersonNum',
key: 'PersonNum', key: 'PersonNum',
render: (text, record) => <RenderVSDataCell showDiffData={true} data1={(record.PersonNum)} data2={(record.diff?.PersonNum)} /> render: (text, record) => <RenderVSDataCell showDiffData={!isEmpty(searchValuesToSub.DateDiff1)} data1={record.PersonNum} data2={record.diff?.PersonNum} />,
}, },
]} ]}
size="small" size="small"

@ -26,7 +26,7 @@ export const fetchRegularCustomer = async (params) => {
...params, ...params,
}; };
const { WebCode, DepartmentList, DateType, Date1, Date2, ...readyParams } = _params; const { WebCode, DepartmentList, DateType, Date1, Date2, ...readyParams } = _params;
const [result1, result2] = await Promise.all([ const [result1=[], result2=[]] = await Promise.all([
fetchJSON(HT_HOST + '/service-tourdesign/RegularCusOrder', { ...defaultParams, ...readyParams }), fetchJSON(HT_HOST + '/service-tourdesign/RegularCusOrder', { ...defaultParams, ...readyParams }),
...(params.DateDiff1 && params.IsDetail === 0 ...(params.DateDiff1 && params.IsDetail === 0
? [ ? [
@ -55,7 +55,6 @@ export const fetchRegularCustomer = async (params) => {
x[key] = { ...(result1Mapped?.[key] || { ItemName: key }), diff: result2Mapped[key] || {} }; x[key] = { ...(result1Mapped?.[key] || { ItemName: key }), diff: result2Mapped[key] || {} };
}); });
ret.result1 = Object.values(x); ret.result1 = Object.values(x);
console.log(ret);
return { result1: ret.result1 }; // { result1, result2 }; return { result1: ret.result1 }; // { result1, result2 };
}; };
@ -154,10 +153,12 @@ const useCustomerRelationsStore = create(
state.regular.pivotX = pivotByDate; state.regular.pivotX = pivotByDate;
state.regular.pivotY = pivotByOrder; state.regular.pivotY = pivotByOrder;
} else { } else {
console.log('0000');
state.regular.data = result1; state.regular.data = result1;
} }
}); });
} catch (error) { } catch (error) {
console.error(error);
} finally { } finally {
setLoading(false); setLoading(false);
IsDetail === 1 && setLoading2(false); IsDetail === 1 && setLoading2(false);

Loading…
Cancel
Save