fix: crm statistics
This commit is contained in:
@@ -4,15 +4,17 @@ import type { EchartsUIType } from '@vben/plugins/echarts';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { CrmStatisticsCustomerApi } from '#/api/crm/statistics/customer';
|
||||
|
||||
import { ref } from 'vue';
|
||||
import { onMounted, ref } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { ContentWrap, Page } from '@vben/common-ui';
|
||||
import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
|
||||
|
||||
import { Tabs } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getDatas } from '#/api/crm/statistics/portrait';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { getChartOptions } from './chartOptions';
|
||||
import { customerSummaryTabs, useGridColumns, useGridFormSchema } from './data';
|
||||
@@ -23,10 +25,25 @@ const rightChartRef = ref<EchartsUIType>();
|
||||
const { renderEcharts: renderLeftEcharts } = useEcharts(leftChartRef);
|
||||
const { renderEcharts: renderRightEcharts } = useEcharts(rightChartRef);
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: useGridFormSchema(),
|
||||
const [QueryForm, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
// 所有表单项
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
},
|
||||
schema: useGridFormSchema(),
|
||||
// 是否可展开
|
||||
showCollapseButton: true,
|
||||
submitButtonOptions: {
|
||||
content: $t('common.query'),
|
||||
},
|
||||
wrapperClass: 'grid-cols-1 md:grid-cols-2',
|
||||
handleSubmit: async () => {
|
||||
await handleTabChange(activeTabName.value);
|
||||
},
|
||||
});
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
columns: useGridColumns(activeTabName.value),
|
||||
height: 'auto',
|
||||
@@ -34,20 +51,6 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
pagerConfig: {
|
||||
enabled: false,
|
||||
},
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async (_, formValues) => {
|
||||
const res = await getDatas(activeTabName.value, formValues);
|
||||
await renderLeftEcharts(
|
||||
getChartOptions(activeTabName.value, res).left,
|
||||
);
|
||||
await renderRightEcharts(
|
||||
getChartOptions(activeTabName.value, res).right,
|
||||
);
|
||||
return res;
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
@@ -64,31 +67,39 @@ async function handleTabChange(key: any) {
|
||||
gridApi.setGridOptions({
|
||||
columns: useGridColumns(key),
|
||||
});
|
||||
await gridApi.reload();
|
||||
const queryParams = await formApi.getValues();
|
||||
const res = await getDatas(activeTabName.value, queryParams);
|
||||
await renderLeftEcharts(getChartOptions(activeTabName.value, res).left);
|
||||
await renderRightEcharts(getChartOptions(activeTabName.value, res).right);
|
||||
await gridApi.grid.reloadData(res);
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
handleTabChange(activeTabName.value);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<Grid>
|
||||
<template #toolbar-actions>
|
||||
<Tabs
|
||||
v-model:active-key="activeTabName"
|
||||
class="w-full"
|
||||
@change="handleTabChange"
|
||||
>
|
||||
<Tabs.TabPane
|
||||
v-for="item in customerSummaryTabs"
|
||||
:key="item.key"
|
||||
:tab="item.tab"
|
||||
:force-render="true"
|
||||
/>
|
||||
</Tabs>
|
||||
<div class="mt-5 flex">
|
||||
<EchartsUI class="m-4 w-1/2" ref="leftChartRef" />
|
||||
<EchartsUI class="m-4 w-1/2" ref="rightChartRef" />
|
||||
</div>
|
||||
</template>
|
||||
</Grid>
|
||||
<ContentWrap>
|
||||
<QueryForm />
|
||||
<Tabs
|
||||
v-model:active-key="activeTabName"
|
||||
class="w-full"
|
||||
@change="handleTabChange"
|
||||
>
|
||||
<Tabs.TabPane
|
||||
v-for="item in customerSummaryTabs"
|
||||
:key="item.key"
|
||||
:tab="item.tab"
|
||||
:force-render="true"
|
||||
/>
|
||||
</Tabs>
|
||||
<div class="mt-5 flex">
|
||||
<EchartsUI class="m-4 w-1/2" ref="leftChartRef" />
|
||||
<EchartsUI class="m-4 w-1/2" ref="rightChartRef" />
|
||||
</div>
|
||||
<Grid v-show="activeTabName !== 'area'" />
|
||||
</ContentWrap>
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user