fix: crm statistics
This commit is contained in:
@@ -133,7 +133,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
<FormModal @success="handleRefresh" />
|
<FormModal @success="handleRefresh" />
|
||||||
<Grid>
|
<Grid>
|
||||||
<template #toolbar-actions>
|
<template #toolbar-actions>
|
||||||
<Tabs class="-mt-11 w-full" @change="handleChangeSceneType">
|
<Tabs class="w-full" @change="handleChangeSceneType">
|
||||||
<Tabs.TabPane tab="我负责的" key="1" />
|
<Tabs.TabPane tab="我负责的" key="1" />
|
||||||
<Tabs.TabPane tab="我参与的" key="2" />
|
<Tabs.TabPane tab="我参与的" key="2" />
|
||||||
<Tabs.TabPane tab="下属负责的" key="3" />
|
<Tabs.TabPane tab="下属负责的" key="3" />
|
||||||
|
|||||||
@@ -348,7 +348,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '未回款金额(元)',
|
title: '未回款金额(元)',
|
||||||
field: 'totalReceivablePrice',
|
field: 'unReceivablePrice',
|
||||||
minWidth: 140,
|
minWidth: 140,
|
||||||
formatter: ({ row }) => {
|
formatter: ({ row }) => {
|
||||||
return erpPriceInputFormatter(
|
return erpPriceInputFormatter(
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
<FormModal @success="handleRefresh" />
|
<FormModal @success="handleRefresh" />
|
||||||
<Grid>
|
<Grid>
|
||||||
<template #toolbar-actions>
|
<template #toolbar-actions>
|
||||||
<Tabs class="-mt-11 w-full" @change="handleChangeSceneType">
|
<Tabs class="w-full" @change="handleChangeSceneType">
|
||||||
<Tabs.TabPane tab="我负责的" key="1" />
|
<Tabs.TabPane tab="我负责的" key="1" />
|
||||||
<Tabs.TabPane tab="我参与的" key="2" />
|
<Tabs.TabPane tab="我参与的" key="2" />
|
||||||
<Tabs.TabPane tab="下属负责的" key="3" />
|
<Tabs.TabPane tab="下属负责的" key="3" />
|
||||||
|
|||||||
@@ -4,15 +4,17 @@ import type { EchartsUIType } from '@vben/plugins/echarts';
|
|||||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
import type { CrmStatisticsCustomerApi } from '#/api/crm/statistics/customer';
|
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 { EchartsUI, useEcharts } from '@vben/plugins/echarts';
|
||||||
|
|
||||||
import { Tabs } from 'ant-design-vue';
|
import { Tabs } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { useVbenForm } from '#/adapter/form';
|
||||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
import { getChartDatas, getDatas } from '#/api/crm/statistics/customer';
|
import { getChartDatas } from '#/api/crm/statistics/customer';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
import { getChartOptions } from './chartOptions';
|
import { getChartOptions } from './chartOptions';
|
||||||
import { customerSummaryTabs, useGridColumns, useGridFormSchema } from './data';
|
import { customerSummaryTabs, useGridColumns, useGridFormSchema } from './data';
|
||||||
@@ -21,10 +23,26 @@ const activeTabName = ref('customerSummary');
|
|||||||
const chartRef = ref<EchartsUIType>();
|
const chartRef = ref<EchartsUIType>();
|
||||||
const { renderEcharts } = useEcharts(chartRef);
|
const { renderEcharts } = useEcharts(chartRef);
|
||||||
|
|
||||||
const [Grid, gridApi] = useVbenVxeGrid({
|
const [QueryForm, formApi] = useVbenForm({
|
||||||
formOptions: {
|
commonConfig: {
|
||||||
schema: useGridFormSchema(),
|
// 所有表单项
|
||||||
|
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: {
|
gridOptions: {
|
||||||
columns: useGridColumns(activeTabName.value),
|
columns: useGridColumns(activeTabName.value),
|
||||||
height: 'auto',
|
height: 'auto',
|
||||||
@@ -32,15 +50,6 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
pagerConfig: {
|
pagerConfig: {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
},
|
},
|
||||||
proxyConfig: {
|
|
||||||
ajax: {
|
|
||||||
query: async (_, formValues) => {
|
|
||||||
const res = await getChartDatas(activeTabName.value, formValues);
|
|
||||||
await renderEcharts(getChartOptions(activeTabName.value, res));
|
|
||||||
return getDatas(activeTabName.value, formValues);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
rowConfig: {
|
rowConfig: {
|
||||||
keyField: 'id',
|
keyField: 'id',
|
||||||
isHover: true,
|
isHover: true,
|
||||||
@@ -57,14 +66,21 @@ async function handleTabChange(key: any) {
|
|||||||
gridApi.setGridOptions({
|
gridApi.setGridOptions({
|
||||||
columns: useGridColumns(key),
|
columns: useGridColumns(key),
|
||||||
});
|
});
|
||||||
await gridApi.reload();
|
const queryParams = await formApi.getValues();
|
||||||
|
const res = await getChartDatas(activeTabName.value, queryParams);
|
||||||
|
await renderEcharts(getChartOptions(activeTabName.value, res));
|
||||||
|
await gridApi.grid.reloadData(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
handleTabChange(activeTabName.value);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page auto-content-height>
|
<Page auto-content-height>
|
||||||
<Grid>
|
<ContentWrap>
|
||||||
<template #toolbar-actions>
|
<QueryForm />
|
||||||
<Tabs
|
<Tabs
|
||||||
v-model:active-key="activeTabName"
|
v-model:active-key="activeTabName"
|
||||||
class="w-full"
|
class="w-full"
|
||||||
@@ -78,7 +94,7 @@ async function handleTabChange(key: any) {
|
|||||||
/>
|
/>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
<EchartsUI class="mb-20 h-full w-full" ref="chartRef" />
|
<EchartsUI class="mb-20 h-full w-full" ref="chartRef" />
|
||||||
</template>
|
<Grid />
|
||||||
</Grid>
|
</ContentWrap>
|
||||||
</Page>
|
</Page>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,18 +1,23 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { EchartsUIType } from '@vben/plugins/echarts';
|
import type { EchartsUIType } from '@vben/plugins/echarts';
|
||||||
|
|
||||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type {
|
||||||
|
VxeGridListeners,
|
||||||
|
VxeTableGridOptions,
|
||||||
|
} from '#/adapter/vxe-table';
|
||||||
import type { CrmStatisticsFunnelApi } from '#/api/crm/statistics/funnel';
|
import type { CrmStatisticsFunnelApi } from '#/api/crm/statistics/funnel';
|
||||||
|
|
||||||
import { ref } from 'vue';
|
import { reactive, ref } from 'vue';
|
||||||
|
|
||||||
import { Page } from '@vben/common-ui';
|
import { ContentWrap, Page } from '@vben/common-ui';
|
||||||
import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
|
import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
|
||||||
|
|
||||||
import { Button, ButtonGroup, Tabs } from 'ant-design-vue';
|
import { Button, ButtonGroup, Tabs } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { useVbenForm } from '#/adapter/form';
|
||||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
import { getChartDatas, getDatas } from '#/api/crm/statistics/funnel';
|
import { getChartDatas, getDatas } from '#/api/crm/statistics/funnel';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
import { getChartOptions } from './chartOptions';
|
import { getChartOptions } from './chartOptions';
|
||||||
import { customerSummaryTabs, useGridColumns, useGridFormSchema } from './data';
|
import { customerSummaryTabs, useGridColumns, useGridFormSchema } from './data';
|
||||||
@@ -22,11 +27,39 @@ const chartRef = ref<EchartsUIType>();
|
|||||||
const { renderEcharts } = useEcharts(chartRef);
|
const { renderEcharts } = useEcharts(chartRef);
|
||||||
|
|
||||||
const active = ref(true);
|
const active = ref(true);
|
||||||
|
const pagerVO = reactive({
|
||||||
|
total: 0,
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
});
|
||||||
|
|
||||||
|
const gridEvents: VxeGridListeners = {
|
||||||
|
async pageChange({ pageSize, currentPage }) {
|
||||||
|
pagerVO.pageNo = currentPage;
|
||||||
|
pagerVO.pageSize = pageSize;
|
||||||
|
await handleTabChange(activeTabName.value);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
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({
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
formOptions: {
|
|
||||||
schema: useGridFormSchema(),
|
|
||||||
},
|
|
||||||
gridOptions: {
|
gridOptions: {
|
||||||
columns: useGridColumns(activeTabName.value),
|
columns: useGridColumns(activeTabName.value),
|
||||||
height: 'auto',
|
height: 'auto',
|
||||||
@@ -34,21 +67,6 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
pagerConfig: {
|
pagerConfig: {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
},
|
},
|
||||||
proxyConfig: {
|
|
||||||
ajax: {
|
|
||||||
query: async ({ page }, formValues) => {
|
|
||||||
const res = await getChartDatas(activeTabName.value, formValues);
|
|
||||||
await renderEcharts(
|
|
||||||
getChartOptions(activeTabName.value, active.value, res),
|
|
||||||
);
|
|
||||||
return getDatas(activeTabName.value, {
|
|
||||||
pageNo: page.currentPage,
|
|
||||||
pageSize: page.pageSize,
|
|
||||||
...formValues,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
rowConfig: {
|
rowConfig: {
|
||||||
keyField: 'id',
|
keyField: 'id',
|
||||||
isHover: true,
|
isHover: true,
|
||||||
@@ -64,30 +82,35 @@ async function handleTabChange(key: any) {
|
|||||||
activeTabName.value = key;
|
activeTabName.value = key;
|
||||||
gridApi.setGridOptions({
|
gridApi.setGridOptions({
|
||||||
columns: useGridColumns(key),
|
columns: useGridColumns(key),
|
||||||
|
height: '400px',
|
||||||
|
keepSource: true,
|
||||||
pagerConfig: {
|
pagerConfig: {
|
||||||
enabled: activeTabName.value !== 'funnelRef',
|
enabled: activeTabName.value !== 'funnel',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
await gridApi.reload();
|
const queryParams = await formApi.getValues();
|
||||||
|
const res = await getChartDatas(activeTabName.value, queryParams);
|
||||||
|
await renderEcharts(getChartOptions(activeTabName.value, active.value, res));
|
||||||
|
const data: any = await getDatas(activeTabName.value, queryParams);
|
||||||
|
await gridApi.grid.reloadData(
|
||||||
|
activeTabName.value === 'funnel' ? data : data.list,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 视角切换 */
|
/** 视角切换 */
|
||||||
function handleActive(value: boolean) {
|
async function handleActive(value: boolean) {
|
||||||
active.value = value;
|
active.value = value;
|
||||||
|
const queryParams = await formApi.getValues();
|
||||||
renderEcharts(
|
renderEcharts(
|
||||||
getChartOptions(
|
getChartOptions(activeTabName.value, active.value, queryParams),
|
||||||
activeTabName.value,
|
|
||||||
active.value,
|
|
||||||
gridApi.formApi.getValues(),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page auto-content-height>
|
<Page auto-content-height>
|
||||||
<Grid>
|
<ContentWrap>
|
||||||
<template #toolbar-actions>
|
<QueryForm />
|
||||||
<Tabs
|
<Tabs
|
||||||
v-model:active-key="activeTabName"
|
v-model:active-key="activeTabName"
|
||||||
class="w-full"
|
class="w-full"
|
||||||
@@ -117,7 +140,7 @@ function handleActive(value: boolean) {
|
|||||||
</Button>
|
</Button>
|
||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
<EchartsUI class="mb-20 h-2/5 w-full" ref="chartRef" />
|
<EchartsUI class="mb-20 h-2/5 w-full" ref="chartRef" />
|
||||||
</template>
|
<Grid v-on="gridEvents" />
|
||||||
</Grid>
|
</ContentWrap>
|
||||||
</Page>
|
</Page>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -6,17 +6,19 @@ import type { CrmStatisticsCustomerApi } from '#/api/crm/statistics/customer';
|
|||||||
|
|
||||||
import { onMounted, 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 { EchartsUI, useEcharts } from '@vben/plugins/echarts';
|
||||||
|
|
||||||
import { Tabs } from 'ant-design-vue';
|
import { Tabs } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { useVbenForm } from '#/adapter/form';
|
||||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
import {
|
import {
|
||||||
getContractCountPerformance,
|
getContractCountPerformance,
|
||||||
getContractPricePerformance,
|
getContractPricePerformance,
|
||||||
getReceivablePricePerformance,
|
getReceivablePricePerformance,
|
||||||
} from '#/api/crm/statistics/performance';
|
} from '#/api/crm/statistics/performance';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
import { getChartOptions } from './chartOptions';
|
import { getChartOptions } from './chartOptions';
|
||||||
import { customerSummaryTabs, useGridFormSchema } from './data';
|
import { customerSummaryTabs, useGridFormSchema } from './data';
|
||||||
@@ -25,13 +27,25 @@ const activeTabName = ref('ContractCountPerformance');
|
|||||||
const chartRef = ref<EchartsUIType>();
|
const chartRef = ref<EchartsUIType>();
|
||||||
const { renderEcharts } = useEcharts(chartRef);
|
const { renderEcharts } = useEcharts(chartRef);
|
||||||
|
|
||||||
const [Grid, gridApi] = useVbenVxeGrid({
|
const [QueryForm, formApi] = useVbenForm({
|
||||||
formOptions: {
|
commonConfig: {
|
||||||
|
// 所有表单项
|
||||||
|
componentProps: {
|
||||||
|
class: 'w-full',
|
||||||
|
},
|
||||||
|
},
|
||||||
schema: useGridFormSchema(),
|
schema: useGridFormSchema(),
|
||||||
|
// 是否可展开
|
||||||
|
showCollapseButton: true,
|
||||||
|
submitButtonOptions: {
|
||||||
|
content: $t('common.query'),
|
||||||
|
},
|
||||||
|
wrapperClass: 'grid-cols-1 md:grid-cols-2',
|
||||||
handleSubmit: async () => {
|
handleSubmit: async () => {
|
||||||
await handleTabChange(activeTabName.value);
|
await handleTabChange(activeTabName.value);
|
||||||
},
|
},
|
||||||
},
|
});
|
||||||
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
gridOptions: {
|
gridOptions: {
|
||||||
columns: [],
|
columns: [],
|
||||||
height: 'auto',
|
height: 'auto',
|
||||||
@@ -42,7 +56,6 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
proxyConfig: {
|
proxyConfig: {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
},
|
},
|
||||||
data: [],
|
|
||||||
rowConfig: {
|
rowConfig: {
|
||||||
keyField: 'id',
|
keyField: 'id',
|
||||||
isHover: true,
|
isHover: true,
|
||||||
@@ -56,7 +69,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
/** tab 切换 */
|
/** tab 切换 */
|
||||||
async function handleTabChange(key: any) {
|
async function handleTabChange(key: any) {
|
||||||
activeTabName.value = key;
|
activeTabName.value = key;
|
||||||
const params = (await gridApi.formApi.getValues()) as any;
|
const queryParams = (await formApi.getValues()) as any;
|
||||||
let data: any[] = [];
|
let data: any[] = [];
|
||||||
const columnsData: any[] = [];
|
const columnsData: any[] = [];
|
||||||
let tableData: any[] = [];
|
let tableData: any[] = [];
|
||||||
@@ -69,7 +82,7 @@ async function handleTabChange(key: any) {
|
|||||||
{ title: '环比增长率(%)' },
|
{ title: '环比增长率(%)' },
|
||||||
{ title: '同比增长率(%)' },
|
{ title: '同比增长率(%)' },
|
||||||
];
|
];
|
||||||
data = await getContractCountPerformance(params);
|
data = await getContractCountPerformance(queryParams);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'ContractPricePerformance': {
|
case 'ContractPricePerformance': {
|
||||||
@@ -80,7 +93,7 @@ async function handleTabChange(key: any) {
|
|||||||
{ title: '环比增长率(%)' },
|
{ title: '环比增长率(%)' },
|
||||||
{ title: '同比增长率(%)' },
|
{ title: '同比增长率(%)' },
|
||||||
];
|
];
|
||||||
data = await getContractPricePerformance(params);
|
data = await getContractPricePerformance(queryParams);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'ReceivablePricePerformance': {
|
case 'ReceivablePricePerformance': {
|
||||||
@@ -91,7 +104,7 @@ async function handleTabChange(key: any) {
|
|||||||
{ title: '环比增长率(%)' },
|
{ title: '环比增长率(%)' },
|
||||||
{ title: '同比增长率(%)' },
|
{ title: '同比增长率(%)' },
|
||||||
];
|
];
|
||||||
data = await getReceivablePricePerformance(params);
|
data = await getReceivablePricePerformance(queryParams);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
@@ -142,8 +155,8 @@ onMounted(() => {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page auto-content-height>
|
<Page auto-content-height>
|
||||||
<Grid>
|
<ContentWrap>
|
||||||
<template #toolbar-actions>
|
<QueryForm />
|
||||||
<Tabs
|
<Tabs
|
||||||
v-model:active-key="activeTabName"
|
v-model:active-key="activeTabName"
|
||||||
class="w-full"
|
class="w-full"
|
||||||
@@ -157,7 +170,7 @@ onMounted(() => {
|
|||||||
/>
|
/>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
<EchartsUI class="mb-20 h-full w-full" ref="chartRef" />
|
<EchartsUI class="mb-20 h-full w-full" ref="chartRef" />
|
||||||
</template>
|
<Grid class="min-h-[400px]" />
|
||||||
</Grid>
|
</ContentWrap>
|
||||||
</Page>
|
</Page>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -4,15 +4,17 @@ import type { EchartsUIType } from '@vben/plugins/echarts';
|
|||||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
import type { CrmStatisticsCustomerApi } from '#/api/crm/statistics/customer';
|
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 { EchartsUI, useEcharts } from '@vben/plugins/echarts';
|
||||||
|
|
||||||
import { Tabs } from 'ant-design-vue';
|
import { Tabs } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { useVbenForm } from '#/adapter/form';
|
||||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
import { getDatas } from '#/api/crm/statistics/portrait';
|
import { getDatas } from '#/api/crm/statistics/portrait';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
import { getChartOptions } from './chartOptions';
|
import { getChartOptions } from './chartOptions';
|
||||||
import { customerSummaryTabs, useGridColumns, useGridFormSchema } from './data';
|
import { customerSummaryTabs, useGridColumns, useGridFormSchema } from './data';
|
||||||
@@ -23,10 +25,25 @@ const rightChartRef = ref<EchartsUIType>();
|
|||||||
const { renderEcharts: renderLeftEcharts } = useEcharts(leftChartRef);
|
const { renderEcharts: renderLeftEcharts } = useEcharts(leftChartRef);
|
||||||
const { renderEcharts: renderRightEcharts } = useEcharts(rightChartRef);
|
const { renderEcharts: renderRightEcharts } = useEcharts(rightChartRef);
|
||||||
|
|
||||||
const [Grid, gridApi] = useVbenVxeGrid({
|
const [QueryForm, formApi] = useVbenForm({
|
||||||
formOptions: {
|
commonConfig: {
|
||||||
schema: useGridFormSchema(),
|
// 所有表单项
|
||||||
|
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: {
|
gridOptions: {
|
||||||
columns: useGridColumns(activeTabName.value),
|
columns: useGridColumns(activeTabName.value),
|
||||||
height: 'auto',
|
height: 'auto',
|
||||||
@@ -34,20 +51,6 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
pagerConfig: {
|
pagerConfig: {
|
||||||
enabled: false,
|
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: {
|
rowConfig: {
|
||||||
keyField: 'id',
|
keyField: 'id',
|
||||||
isHover: true,
|
isHover: true,
|
||||||
@@ -64,14 +67,22 @@ async function handleTabChange(key: any) {
|
|||||||
gridApi.setGridOptions({
|
gridApi.setGridOptions({
|
||||||
columns: useGridColumns(key),
|
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>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page auto-content-height>
|
<Page auto-content-height>
|
||||||
<Grid>
|
<ContentWrap>
|
||||||
<template #toolbar-actions>
|
<QueryForm />
|
||||||
<Tabs
|
<Tabs
|
||||||
v-model:active-key="activeTabName"
|
v-model:active-key="activeTabName"
|
||||||
class="w-full"
|
class="w-full"
|
||||||
@@ -88,7 +99,7 @@ async function handleTabChange(key: any) {
|
|||||||
<EchartsUI class="m-4 w-1/2" ref="leftChartRef" />
|
<EchartsUI class="m-4 w-1/2" ref="leftChartRef" />
|
||||||
<EchartsUI class="m-4 w-1/2" ref="rightChartRef" />
|
<EchartsUI class="m-4 w-1/2" ref="rightChartRef" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
<Grid v-show="activeTabName !== 'area'" />
|
||||||
</Grid>
|
</ContentWrap>
|
||||||
</Page>
|
</Page>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -4,15 +4,17 @@ import type { EchartsUIType } from '@vben/plugins/echarts';
|
|||||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
import type { CrmStatisticsCustomerApi } from '#/api/crm/statistics/customer';
|
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 { EchartsUI, useEcharts } from '@vben/plugins/echarts';
|
||||||
|
|
||||||
import { Tabs } from 'ant-design-vue';
|
import { Tabs } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { useVbenForm } from '#/adapter/form';
|
||||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
import { getDatas } from '#/api/crm/statistics/customer';
|
import { getDatas } from '#/api/crm/statistics/customer';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
import { getChartOptions } from './chartOptions';
|
import { getChartOptions } from './chartOptions';
|
||||||
import { customerSummaryTabs, useGridColumns, useGridFormSchema } from './data';
|
import { customerSummaryTabs, useGridColumns, useGridFormSchema } from './data';
|
||||||
@@ -21,10 +23,26 @@ const activeTabName = ref('contractPriceRank');
|
|||||||
const chartRef = ref<EchartsUIType>();
|
const chartRef = ref<EchartsUIType>();
|
||||||
const { renderEcharts } = useEcharts(chartRef);
|
const { renderEcharts } = useEcharts(chartRef);
|
||||||
|
|
||||||
const [Grid, gridApi] = useVbenVxeGrid({
|
const [QueryForm, formApi] = useVbenForm({
|
||||||
formOptions: {
|
commonConfig: {
|
||||||
schema: useGridFormSchema(),
|
// 所有表单项
|
||||||
|
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: {
|
gridOptions: {
|
||||||
columns: useGridColumns(activeTabName.value),
|
columns: useGridColumns(activeTabName.value),
|
||||||
height: 'auto',
|
height: 'auto',
|
||||||
@@ -57,14 +75,21 @@ async function handleTabChange(key: any) {
|
|||||||
gridApi.setGridOptions({
|
gridApi.setGridOptions({
|
||||||
columns: useGridColumns(key),
|
columns: useGridColumns(key),
|
||||||
});
|
});
|
||||||
await gridApi.reload();
|
const queryParams = await formApi.getValues();
|
||||||
|
const res = await getDatas(activeTabName.value, queryParams);
|
||||||
|
await renderEcharts(getChartOptions(activeTabName.value, res));
|
||||||
|
await gridApi.grid.reloadData(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
handleTabChange(activeTabName.value);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page auto-content-height>
|
<Page auto-content-height>
|
||||||
<Grid>
|
<ContentWrap>
|
||||||
<template #toolbar-actions>
|
<QueryForm />
|
||||||
<Tabs
|
<Tabs
|
||||||
v-model:active-key="activeTabName"
|
v-model:active-key="activeTabName"
|
||||||
class="w-full"
|
class="w-full"
|
||||||
@@ -78,7 +103,7 @@ async function handleTabChange(key: any) {
|
|||||||
/>
|
/>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
<EchartsUI class="mb-20 h-full w-full" ref="chartRef" />
|
<EchartsUI class="mb-20 h-full w-full" ref="chartRef" />
|
||||||
</template>
|
<Grid />
|
||||||
</Grid>
|
</ContentWrap>
|
||||||
</Page>
|
</Page>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import type { ComposeOption } from 'echarts/core';
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
BarChart,
|
BarChart,
|
||||||
|
FunnelChart,
|
||||||
GaugeChart,
|
GaugeChart,
|
||||||
LineChart,
|
LineChart,
|
||||||
MapChart,
|
MapChart,
|
||||||
@@ -66,6 +67,7 @@ echarts.use([
|
|||||||
TransformComponent,
|
TransformComponent,
|
||||||
BarChart,
|
BarChart,
|
||||||
LineChart,
|
LineChart,
|
||||||
|
FunnelChart,
|
||||||
GaugeChart,
|
GaugeChart,
|
||||||
LabelLayout,
|
LabelLayout,
|
||||||
UniversalTransition,
|
UniversalTransition,
|
||||||
|
|||||||
Reference in New Issue
Block a user