|
@@ -0,0 +1,94 @@
|
|
|
+<template>
|
|
|
+ <fs-page class="fs-page-custom" v-loading='loading'>
|
|
|
+ <fs-crud ref="crudRef" v-bind="crudBinding">
|
|
|
+ <template #search-left>
|
|
|
+ <DateRangePicker v-model="dateRange" :timezone="shopInfo.profile.time_zone" style="margin-bottom: 5px;"></DateRangePicker>
|
|
|
+ </template>
|
|
|
+ <template v-for="field of Object.keys(BaseColumn)" #[`cell_${field}`]="scope">
|
|
|
+ <p>{{ scope.row[field] }}</p>
|
|
|
+ <el-popover
|
|
|
+ class="box-item"
|
|
|
+ effect="dark"
|
|
|
+ :width="260">
|
|
|
+ <template #reference>
|
|
|
+ <p :class="scope.row[`gap${field}`] > 0 ? 'green' : 'red'" v-show="showCompare">
|
|
|
+ <el-icon v-show="scope.row[field]">
|
|
|
+ <Top v-if="scope.row[`gap${field}`] > 0"/>
|
|
|
+ <Bottom v-else/>
|
|
|
+ </el-icon>
|
|
|
+ <span>{{ scope.row[`gap${field}`] }}%</span>
|
|
|
+ </p>
|
|
|
+ </template>
|
|
|
+ <p>对比周期:{{ placementData.compare_date[0] }} ~ {{ placementData.compare_date[1] }}</p>
|
|
|
+ <p>对比值:{{ scope.row[`prev${field}`] }}</p>
|
|
|
+ </el-popover>
|
|
|
+ </template>
|
|
|
+ <template #toolbar-left>
|
|
|
+ <div>
|
|
|
+ <span>数据对比 </span>
|
|
|
+ <el-switch v-model="showCompare" size="small" />
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </fs-crud>
|
|
|
+ </fs-page>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script lang="ts" setup>
|
|
|
+import { ref, onMounted, Ref, watch } from 'vue'
|
|
|
+import { useFs, FsPage } from '@fast-crud/fast-crud'
|
|
|
+import { createCrudOptions } from './crud'
|
|
|
+import { usePublicData } from '/@/stores/publicData'
|
|
|
+import { useShopInfo } from '/@/stores/shopInfo'
|
|
|
+import DateRangePicker from '/@/components/DateRangePicker/index.vue'
|
|
|
+import { GetList } from './api'
|
|
|
+import { BaseColumn } from '/@/views/adManage/utils/commonTabColumn.js'
|
|
|
+
|
|
|
+defineOptions({
|
|
|
+ name: "Placement"
|
|
|
+})
|
|
|
+const publicData = usePublicData()
|
|
|
+const shopInfo = useShopInfo()
|
|
|
+const dateRange: Ref<string[]> = ref(publicData.data.dateRange)
|
|
|
+const props = defineProps({
|
|
|
+ campaignId: { type: String }
|
|
|
+})
|
|
|
+const loading = ref(true)
|
|
|
+const placementData = ref({items: [], compare_date: []})
|
|
|
+
|
|
|
+const showCompare = ref(false)
|
|
|
+const fetchData = async () => {
|
|
|
+ loading.value = true
|
|
|
+ const resp = await GetList({
|
|
|
+ campaignId: props.campaignId,
|
|
|
+ date__gte: dateRange.value[0],
|
|
|
+ date__lte: dateRange.value[1]
|
|
|
+ })
|
|
|
+ placementData.value = resp.data
|
|
|
+ crudExpose.setTableData(placementData.value.items)
|
|
|
+ loading.value = false
|
|
|
+}
|
|
|
+
|
|
|
+const context = { fetchData }
|
|
|
+
|
|
|
+const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context })
|
|
|
+onMounted(async () => {
|
|
|
+ await fetchData()
|
|
|
+})
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+watch(
|
|
|
+ dateRange,
|
|
|
+ async () => await fetchData()
|
|
|
+)
|
|
|
+
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+.red {
|
|
|
+ color: red;
|
|
|
+}
|
|
|
+.green {
|
|
|
+ color: #1cbc0e;
|
|
|
+}
|
|
|
+</style>
|