index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <fs-page class="fs-page-custom">
  3. <fs-crud ref="crudRef" v-bind="crudBinding">
  4. <template #header-middle>
  5. <el-tabs v-model="tabActiveName" class="chart-tabs" type="border-card" @tab-change="changeTab">
  6. <el-tab-pane label="数据趋势" name="dataTendency">
  7. <MetricsCards v-model="metrics" :metric-items="options" @change="changeMetric"></MetricsCards>
  8. <DataTendencyChart ref="dataTendencyRef"/>
  9. </el-tab-pane>
  10. <el-tab-pane label="广告结构" name="adStruct" :lazy="true">
  11. <AdStructChart ref="adStructChartRef" />
  12. </el-tab-pane>
  13. <el-tab-pane label="散点视图" name="scatterView" :lazy="true"></el-tab-pane>
  14. </el-tabs>
  15. </template>
  16. </fs-crud>
  17. </fs-page>
  18. </template>
  19. <script lang="ts" setup>
  20. import { ref, onMounted, onBeforeUnmount, watch,nextTick, onActivated } from 'vue';
  21. import { useFs, FsPage } from '@fast-crud/fast-crud';
  22. import { createCrudOptions } from './crud';
  23. import { useRoute, useRouter } from 'vue-router'
  24. import MetricsCards from '/@/components/MetricsCards/index.vue'
  25. import AdStructChart from '/@/views/adManage/sp/campaigns/chartComponents/adStruct.vue'
  26. import DataTendencyChart from '/@/views/adManage/sp/campaigns/chartComponents/dataTendency.vue'
  27. const tabActiveName = ref("dataTendency")
  28. const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context: {} });
  29. const metrics = ref([{metric: 'ACOS', color: 'blue'}])
  30. const options = ref([
  31. {label: 'ACOS', value: 'ACOS', metricVal: "18.00%", preVal: '20.15%', gapVal: '-2.00%', disabled:true},
  32. {label: '点击量', value: 'clicks', metricVal: "19.00%", preVal: '20.15%', gapVal: '-1.00%', disabled:true},
  33. {label: '曝光量', value: 'impression', metricVal: "20.00%", preVal: '15.00%', gapVal: '5.00%', disabled:true},
  34. {label: '转化率1', value: 'rate1', metricVal: "1.00%", preVal: '15.00%', gapVal: '5.00%', disabled:true},
  35. {label: '转化率2', value: 'rate2', metricVal: "2.00%", preVal: '15.00%', gapVal: '5.00%', disabled:true},
  36. {label: '转化率3', value: 'rate3', metricVal: "3.00%", preVal: '15.00%', gapVal: '5.00%', disabled:true},
  37. {label: '转化率4', value: 'rate4', metricVal: "4.00%", preVal: '15.00%', gapVal: '5.00%'},
  38. {label: '转化率5', value: 'rate5', metricVal: "5.00%", preVal: '15.00%', gapVal: '5.00%'},
  39. {label: '转化率6', value: 'rate6', metricVal: "6.00%", preVal: '15.00%', gapVal: '5.00%'},
  40. ])
  41. const route = useRoute()
  42. const router = useRouter()
  43. const adStructChartRef = ref()
  44. const dataTendencyRef = ref()
  45. onMounted(() => {
  46. crudExpose.doRefresh();
  47. })
  48. const resizeTabChart = () => {
  49. if (tabActiveName.value === "dataTendency") {
  50. dataTendencyRef.value.resizeChart()
  51. } else if (tabActiveName.value === "adStruct"){
  52. adStructChartRef.value.resizeChart()
  53. }
  54. // dataTendencyRef.value.resizeChart()
  55. // adStructChartRef.value.resizeChart()
  56. }
  57. const changeTab = () => {
  58. nextTick(() => {
  59. resizeTabChart()
  60. })
  61. }
  62. const changeMetric = () => {
  63. console.log(metrics.value)
  64. }
  65. // const jumpGroup = (row: any) => {
  66. // router.push({
  67. // name: 'CampaignDetail',
  68. // query: { id: row.id, campaignId: row.campaignId, tagsViewName: row.campaignName },
  69. // })
  70. // }
  71. defineExpose({ resizeTabChart })
  72. </script>
  73. <style lang="scss">
  74. .chart-tabs {
  75. margin: 5px 0;
  76. .el-tabs__nav {
  77. padding-left: 0 !important;
  78. }
  79. }
  80. </style>