index.vue 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <div class="asj-container">
  3. <div class="public-search">
  4. <DateRangePicker v-model="dateRange" :timezone="shopInfo.profile.time_zone"></DateRangePicker>
  5. <el-select
  6. v-model="selectedPortfolios"
  7. placeholder="广告组合"
  8. clearable
  9. multiple
  10. style="width: 400px"
  11. collapse-tags
  12. collapse-tags-tooltip
  13. :max-collapse-tags="3"
  14. >
  15. <el-option v-for="info of portfolios" :label="info.name" :value="info.portfolioId"></el-option>
  16. </el-select>
  17. </div>
  18. <div class="asj-tabs">
  19. <div v-for="tab of tabs" :key="tab.name" :class="['asj-tab', { active: tabActiveName === tab.name }]" @click="tabActiveName = tab.name">
  20. {{ tab.label }}
  21. </div>
  22. </div>
  23. <component :is="tabsComponents[tabActiveName]"></component>
  24. </div>
  25. </template>
  26. <script lang="ts" setup>
  27. import { ref, onBeforeMount, Ref, watch, provide } from 'vue'
  28. import { useShopInfo } from '/@/stores/shopInfo'
  29. import { usePublicData } from '/@/stores/publicData'
  30. import { GetList } from '/@/views/adManage/portfolios/api'
  31. import { storeToRefs } from 'pinia'
  32. import DateRangePicker from '/@/components/DateRangePicker/index.vue'
  33. import { recentDaysRange } from '/@/views/adManage/utils/tools'
  34. import Campaigns from './campaigns/index.vue'
  35. import Keywords from './keywords/index.vue'
  36. import Targets from './targets/index.vue'
  37. import SearchTerm from './searchTerm/index.vue'
  38. import AdvertisedProducts from './advertisedProducts/index.vue'
  39. import PurchasedProducts from './purchasedProducts/index.vue'
  40. import Placement from './placement/index.vue'
  41. const shopInfo = useShopInfo()
  42. const publicData = usePublicData()
  43. const selectedPortfolios: Ref<string[]> = ref([])
  44. const portfolios: Ref<Portfolio[]> = ref([])
  45. const { dateRange } = storeToRefs(publicData)
  46. const tabActiveName = ref('Campaigns')
  47. const tabs = [
  48. { label: '广告活动', name: 'Campaigns' },
  49. { label: '关键词投放', name: 'Keywords' },
  50. { label: '商品投放', name: 'Targets' },
  51. { label: '推广商品', name: 'AdvertisedProducts' },
  52. { label: '购买的其他商品', name: 'PurchasedProducts' },
  53. { label: '搜索词', name: 'SearchTerm' },
  54. { label: '广告位', name: 'Placement' }
  55. ]
  56. const tabsComponents: any = {
  57. Campaigns,
  58. Keywords,
  59. Targets,
  60. AdvertisedProducts,
  61. PurchasedProducts,
  62. SearchTerm,
  63. Placement
  64. }
  65. provide('dateRange', dateRange)
  66. onBeforeMount(async () => {
  67. const resp: APIResponseData = await GetList({ limit: 999 })
  68. portfolios.value = resp.data
  69. })
  70. publicData.$subscribe((mutation, state) => {
  71. // console.log(mutation)
  72. // console.log(state.dateRange)
  73. publicData.setDateRange(state.dateRange)
  74. })
  75. </script>
  76. <style scoped></style>