|
@@ -18,7 +18,7 @@ import type {
|
|
|
import { FilterType } from '@/types/table'
|
|
|
import { CustomFilterValueType } from '@/types/customFilter'
|
|
|
|
|
|
-import { reactive, ref } from 'vue'
|
|
|
+import { computed, reactive, ref } from 'vue'
|
|
|
import { useRequest } from '@/hooks/useRequest'
|
|
|
import { useAnalysis } from '@/hooks/useAnalysis'
|
|
|
import { useCommonStore } from '@/stores/useCommon'
|
|
@@ -28,6 +28,7 @@ import { usePage } from '@/hooks/usePage'
|
|
|
|
|
|
import Table from '@/components/table/CustomTable.vue'
|
|
|
import { FieldSpecialEffectType, TagType, TextType } from '@/types/tableText'
|
|
|
+import type { EChartsOption } from 'echarts/types/dist/shared'
|
|
|
|
|
|
type TableType = InstanceType<typeof Table>
|
|
|
|
|
@@ -310,6 +311,86 @@ const updateAllReq = (pf: string, gid: string) => {
|
|
|
const backupSelect = reactive([]) // 保存选择数据
|
|
|
|
|
|
watchPageChange(() => [selectInfo.pf, selectInfo.gid], backupSelect, updateAllReq)
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取合计数据
|
|
|
+ * @param _data 当前页表格数据,如果不是远程分页查询,则是全部数据
|
|
|
+ * @param total 表格总数
|
|
|
+ * @param needOther 是否需要自定义其他内容,为false则只返回数据总条数
|
|
|
+ * @returns 合计数据数组
|
|
|
+ */
|
|
|
+const getSummary = (_data: any, total: number, needOther = false) => {
|
|
|
+ if (!needOther) return [total + '条数据']
|
|
|
+ // 如需其他内容则在此处补充
|
|
|
+ return []
|
|
|
+}
|
|
|
+
|
|
|
+const pieChartOptions: EChartsOption = {
|
|
|
+ tooltip: {
|
|
|
+ trigger: 'item'
|
|
|
+ },
|
|
|
+ legend: {
|
|
|
+ top: '5%',
|
|
|
+ left: 'center'
|
|
|
+ },
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ name: 'Access From',
|
|
|
+ type: 'pie',
|
|
|
+ radius: ['40%', '70%'],
|
|
|
+ avoidLabelOverlap: false,
|
|
|
+ itemStyle: {
|
|
|
+ borderRadius: 10,
|
|
|
+ borderColor: '#fff',
|
|
|
+ borderWidth: 2
|
|
|
+ },
|
|
|
+ label: {
|
|
|
+ show: false,
|
|
|
+ position: 'center'
|
|
|
+ },
|
|
|
+ emphasis: {
|
|
|
+ label: {
|
|
|
+ show: true,
|
|
|
+ fontSize: 40,
|
|
|
+ fontWeight: 'bold'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ labelLine: {
|
|
|
+ show: false
|
|
|
+ },
|
|
|
+ data: [
|
|
|
+ { value: 1048, name: 'Search Engine' },
|
|
|
+ { value: 735, name: 'Direct' },
|
|
|
+ { value: 580, name: 'Email' },
|
|
|
+ { value: 484, name: 'Union Ads' },
|
|
|
+ { value: 300, name: 'Video Ads' }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ]
|
|
|
+}
|
|
|
+
|
|
|
+const barChartOptions: EChartsOption = {
|
|
|
+ xAxis: {
|
|
|
+ type: 'category',
|
|
|
+ data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
|
|
|
+ },
|
|
|
+ yAxis: {
|
|
|
+ type: 'value'
|
|
|
+ },
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ data: [120, 200, 150, 80, 70, 110, 130],
|
|
|
+ type: 'bar'
|
|
|
+ }
|
|
|
+ ]
|
|
|
+}
|
|
|
+
|
|
|
+const isPie = ref(false)
|
|
|
+
|
|
|
+const chartOptions = computed(() => {
|
|
|
+ console.log(isPie.value)
|
|
|
+ return isPie.value ? pieChartOptions : barChartOptions
|
|
|
+})
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
@@ -328,7 +409,23 @@ watchPageChange(() => [selectInfo.pf, selectInfo.gid], backupSelect, updateAllRe
|
|
|
:open-page-query="true"
|
|
|
:open-filter-query="true"
|
|
|
:tools="tableToolsConfig"
|
|
|
- ></Table>
|
|
|
+ :need-total="true"
|
|
|
+ :total-func="getSummary"
|
|
|
+ >
|
|
|
+ <template #chart>
|
|
|
+ <div class="chartContainer">
|
|
|
+ <div class="chartsTools">
|
|
|
+ <el-radio-group class="formChangeRadioGroup" v-model="isPie" size="small">
|
|
|
+ <el-radio-button label="饼图" :value="true" />
|
|
|
+ <el-radio-button label="柱状图" :value="false" />
|
|
|
+ </el-radio-group>
|
|
|
+ </div>
|
|
|
+ <div class="chartDisplay">
|
|
|
+ <PieBorderRadius :options="chartOptions"></PieBorderRadius>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </Table>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -347,4 +444,16 @@ watchPageChange(() => [selectInfo.pf, selectInfo.gid], backupSelect, updateAllRe
|
|
|
padding: 0 24px;
|
|
|
background-color: white;
|
|
|
}
|
|
|
+
|
|
|
+.chartContainer {
|
|
|
+ width: 100%;
|
|
|
+ position: relative;
|
|
|
+}
|
|
|
+
|
|
|
+.chartsTools {
|
|
|
+ width: 100%;
|
|
|
+ position: relative;
|
|
|
+ display: flex;
|
|
|
+ justify-content: flex-end;
|
|
|
+}
|
|
|
</style>
|