|
@@ -2,22 +2,24 @@
|
|
<fs-page class="fs-page-custom">
|
|
<fs-page class="fs-page-custom">
|
|
<fs-crud ref="crudRef" v-bind="crudBinding">
|
|
<fs-crud ref="crudRef" v-bind="crudBinding">
|
|
<template #header-middle>
|
|
<template #header-middle>
|
|
- <el-tabs type="border-card" @click="clickFn" class="chart-tabs">
|
|
|
|
|
|
+ <el-tabs type="border-card" @click="changeTab" class="chart-tabs">
|
|
<el-tab-pane label="数据趋势">
|
|
<el-tab-pane label="数据趋势">
|
|
<MetricsCards v-model="metrics" :metric-items="options" @change="changeMetric"></MetricsCards>
|
|
<MetricsCards v-model="metrics" :metric-items="options" @change="changeMetric"></MetricsCards>
|
|
<div style="display: flex; justify-content: flex-end">
|
|
<div style="display: flex; justify-content: flex-end">
|
|
<el-button-group class="ml-4" style="margin-top: 10px; margin-right: 30px">
|
|
<el-button-group class="ml-4" style="margin-top: 10px; margin-right: 30px">
|
|
- <el-button type="primary">日</el-button>
|
|
|
|
- <el-button type="primary">周</el-button>
|
|
|
|
- <el-button type="primary">月</el-button>
|
|
|
|
|
|
+ <el-button type="primary" @click="changeChartData">日</el-button>
|
|
|
|
+ <el-button type="primary" @click="changeChartData">周</el-button>
|
|
|
|
+ <el-button type="primary" @click="changeChartData">月</el-button>
|
|
</el-button-group>
|
|
</el-button-group>
|
|
</div>
|
|
</div>
|
|
<BarLineChart ref="barLine" :barLineData="barLineData"/>
|
|
<BarLineChart ref="barLine" :barLineData="barLineData"/>
|
|
</el-tab-pane>
|
|
</el-tab-pane>
|
|
<el-tab-pane label="广告结构">
|
|
<el-tab-pane label="广告结构">
|
|
- <PieBarChart ref="pieBar"/>
|
|
|
|
|
|
+ <PieBarChart ref="pieBar" :pieBarChartData="pieBarChartData"/>
|
|
|
|
+ </el-tab-pane>
|
|
|
|
+ <el-tab-pane label="散点透视">
|
|
|
|
+ <!--<ScatterChart ref="scatter"/>-->
|
|
</el-tab-pane>
|
|
</el-tab-pane>
|
|
- <el-tab-pane label="散点透视"><ScatterChart ref="scatter"/></el-tab-pane>
|
|
|
|
</el-tabs>
|
|
</el-tabs>
|
|
</template>
|
|
</template>
|
|
</fs-crud>
|
|
</fs-crud>
|
|
@@ -25,7 +27,7 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
-import { ref, onMounted, reactive } from 'vue'
|
|
|
|
|
|
+import { ref, onMounted, inject, nextTick } from 'vue'
|
|
import { useFs, FsPage } from '@fast-crud/fast-crud'
|
|
import { useFs, FsPage } from '@fast-crud/fast-crud'
|
|
import { createCrudOptions } from './crud'
|
|
import { createCrudOptions } from './crud'
|
|
import BarLineChart from '/@/components/echartsComponents/BarLineChart.vue'
|
|
import BarLineChart from '/@/components/echartsComponents/BarLineChart.vue'
|
|
@@ -35,69 +37,63 @@ import MetricsCards from "/@/components/MetricsCards/index.vue"
|
|
|
|
|
|
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context: {} })
|
|
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context: {} })
|
|
|
|
|
|
-let barLineData = reactive({
|
|
|
|
- xData: ['2023-10-18', '2023-10-19', '2023-10-20', '2023-10-21', '2023-10-22', '2023-10-23', '2023-10-24'],
|
|
|
|
- barData: [12, 13.4, 12.5, 16, 14.5, 15.6, 12.3],
|
|
|
|
- yData1: [5, 6, 7, 8, 9, 10, 11],
|
|
|
|
- yData2: [14, 15, 12, 16, 15, 13, 14.5]
|
|
|
|
-})
|
|
|
|
-
|
|
|
|
-let scatterData = [
|
|
|
|
- [10.0, 8.04],
|
|
|
|
- [8.07, 6.95],
|
|
|
|
- [13.0, 7.58],
|
|
|
|
- [9.05, 8.81],
|
|
|
|
- [11.0, 8.33],
|
|
|
|
- [14.0, 7.66],
|
|
|
|
- [13.4, 6.81],
|
|
|
|
- [10.0, 6.33],
|
|
|
|
- [14.0, 8.96],
|
|
|
|
- [12.5, 6.82],
|
|
|
|
- [9.15, 7.2],
|
|
|
|
- [11.5, 7.2],
|
|
|
|
- [3.03, 4.23],
|
|
|
|
- [12.2, 7.83],
|
|
|
|
- [2.02, 4.47],
|
|
|
|
- [1.05, 3.33],
|
|
|
|
- [4.05, 4.96],
|
|
|
|
- [6.03, 7.24],
|
|
|
|
- [12.0, 6.26],
|
|
|
|
- [12.0, 8.84],
|
|
|
|
- [7.08, 5.82],
|
|
|
|
- [5.02, 5.68]
|
|
|
|
-]
|
|
|
|
-
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
crudExpose.doRefresh()
|
|
crudExpose.doRefresh()
|
|
})
|
|
})
|
|
|
|
|
|
-const pieBar = ref(null)
|
|
|
|
-const barLine = ref(null)
|
|
|
|
-const scatter = ref(null)
|
|
|
|
|
|
+let barLineData= inject('barLineData')
|
|
|
|
+let pieBarChartData = inject('pieBarChartData')
|
|
|
|
+const pieBar = ref()
|
|
|
|
+const barLine = ref()
|
|
|
|
+const scatter = ref()
|
|
|
|
|
|
-function clickFn() {
|
|
|
|
|
|
+function resizeTabChart() {
|
|
pieBar.value.resizeChart()
|
|
pieBar.value.resizeChart()
|
|
barLine.value.resizeChart()
|
|
barLine.value.resizeChart()
|
|
- scatter.value.resizeChart()
|
|
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const changeTab = () => {
|
|
|
|
+ nextTick(() => {
|
|
|
|
+ resizeTabChart()
|
|
|
|
+ })
|
|
}
|
|
}
|
|
|
|
|
|
const metrics = ref([{ metric: 'ACOS', color: 'blue' }])
|
|
const metrics = ref([{ metric: 'ACOS', color: 'blue' }])
|
|
const options = ref([
|
|
const options = ref([
|
|
- { label: 'ACOS', value: 'ACOS', metricVal: "18.00%", preVal: '20.15%', gapVal: '-2.00%', disabled: true },
|
|
|
|
- { label: '点击量', value: 'clicks', metricVal: "19.00%", preVal: '20.15%', gapVal: '-1.00%', disabled: true },
|
|
|
|
- { label: '曝光量', value: 'impression', metricVal: "20.00%", preVal: '15.00%', gapVal: '5.00%', disabled: true },
|
|
|
|
- { label: '转化率1', value: 'rate1', metricVal: "1.00%", preVal: '15.00%', gapVal: '5.00%', disabled: true },
|
|
|
|
- { label: '转化率2', value: 'rate2', metricVal: "2.00%", preVal: '15.00%', gapVal: '5.00%', disabled: true },
|
|
|
|
- { label: '转化率3', value: 'rate3', metricVal: "3.00%", preVal: '15.00%', gapVal: '5.00%', disabled: true },
|
|
|
|
- { label: '转化率4', value: 'rate4', metricVal: "4.00%", preVal: '15.00%', gapVal: '5.00%' },
|
|
|
|
- { label: '转化率5', value: 'rate5', metricVal: "5.00%", preVal: '15.00%', gapVal: '5.00%' },
|
|
|
|
- { label: '转化率6', value: 'rate6', metricVal: "6.00%", preVal: '15.00%', gapVal: '5.00%' },
|
|
|
|
|
|
+ {label: 'ACOS', value: 'ACOS', metricVal: "18.00%", preVal: '20.15%', gapVal: '-2.00%', disabled:true},
|
|
|
|
+ {label: '点击量', value: 'clicks', metricVal: "19.00%", preVal: '20.15%', gapVal: '-1.00%', disabled:true},
|
|
|
|
+ {label: '曝光量', value: 'impression', metricVal: "20.00%", preVal: '15.00%', gapVal: '5.00%', disabled:true},
|
|
|
|
+ {label: '转化率1', value: 'rate1', metricVal: "1.00%", preVal: '15.00%', gapVal: '5.00%', disabled:true},
|
|
|
|
+ {label: '转化率2', value: 'rate2', metricVal: "2.00%", preVal: '15.00%', gapVal: '5.00%', disabled:true},
|
|
|
|
+ {label: '转化率3', value: 'rate3', metricVal: "3.00%", preVal: '15.00%', gapVal: '5.00%', disabled:true},
|
|
|
|
+ {label: '转化率4', value: 'rate4', metricVal: "4.00%", preVal: '15.00%', gapVal: '5.00%'},
|
|
|
|
+ {label: '转化率5', value: 'rate5', metricVal: "5.00%", preVal: '15.00%', gapVal: '5.00%'},
|
|
|
|
+ {label: '转化率6', value: 'rate6', metricVal: "6.00%", preVal: '15.00%', gapVal: '5.00%'},
|
|
])
|
|
])
|
|
|
|
|
|
function changeMetric() {
|
|
function changeMetric() {
|
|
console.log(metrics.value)
|
|
console.log(metrics.value)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// todo 发送请求获取数据切换图表
|
|
|
|
+function changeChartData() {
|
|
|
|
+ updateData({
|
|
|
|
+ xData: ['2023-10-18', '2023-10-19', '2023-10-20', '2023-10-21', '2023-10-22', '2023-10-23', '2023-10-24'],
|
|
|
|
+ barData: [10, 13.4, 12, 14, 20, 14, 11.1],
|
|
|
|
+ yData1: [7, 2, 4, 8, 4, 15, 10],
|
|
|
|
+ yData2: [15, 10, 12, 14, 12, 10, 12.5]
|
|
|
|
+ });
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function updateData(newData) {
|
|
|
|
+ // 更新响应式数据
|
|
|
|
+ Object.assign(barLineData, newData)
|
|
|
|
+ // 然后更新图表
|
|
|
|
+ barLine.value.updateChart()
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+defineExpose({ resizeTabChart })
|
|
|
|
+
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
<style scoped>
|