<template>
  <fs-page class="fs-page-custom">
    <fs-crud ref="crudRef" v-bind="crudBinding">
      <template #search-left>
        <DateRangePicker v-model="dateRange" timezone="America/Los_Angeles" style="margin-bottom: 5px;"></DateRangePicker>
      </template>
      <template #header-middle>
        <AdGroupChart />
      </template>
      <template #cell_adGroupName="scope">
        <el-link type="primary" :underline="false" @click="jumpAds(scope.row)">{{ scope.row.adGroupName }}</el-link>
      </template>
		</fs-crud>
	</fs-page>
</template>

<script lang="ts" setup>
import { Ref, ref, onMounted } from 'vue'
import { useFs, FsPage } from '@fast-crud/fast-crud';
import { createCrudOptions } from './crud'
import { useRoute, useRouter, LocationQueryValue } from 'vue-router'
import DateRangePicker from '/@/components/DateRangePicker/index.vue'
import AdGroupChart from './chartComponents/adGroupChart.vue'
import { usePublicData } from '/@/stores/publicData'
// import DataTendencyChart from '/@/views/adManage/sp/chartComponents/dataTendency.vue'
// import { getCardData, getLineData } from './api'

const publicData = usePublicData()
const router = useRouter()
interface Props {
  campaignId: LocationQueryValue | LocationQueryValue[]
}
const props = defineProps<Props>()
const dateRange: Ref<string[]> = ref(publicData.dateRange)
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context: { campaignId: props.campaignId } })

onMounted(() => {
	crudExpose.doRefresh();
})
const jumpAds = (row: any) => {
  router.push({
    name: 'AdGroupDetail',
    query: { id: row.id, adGroupId: row.adGroupId, tagsViewName: row.adGroupName }
  })
}

</script>

<style scoped>

</style>