<template>
  <div class="guidelines-data-wrap">
    <div class="filter-wrap bg-#fff rounded-8px border-1px border-#D7D7D9 border-solid">
      <div class="top flex h-64px px-24px py-10px justify-between items-center">
        <p class="text-18px font-400 lh-26px color-#211F24 title">投放信息</p>
      </div>

      <div class="container px-24px pt-12px pb-24px">
        <a-row class="grid-demo" :gutter="24">
          <a-col :span="12">
            <div class="">
              <a-space direction="vertical">
                <span>账户</span>
                <span>{{ detailData?.account }}</span>
              </a-space>
            </div>
          </a-col>

          <a-col :span="12">
            <div class="">
              <a-space direction="vertical">
                <span>计划</span>
                <span>3</span>
              </a-space>
            </div>
          </a-col>
        </a-row>
        <a-row class="grid-demo" :gutter="24" style="margin-top: 30px">
          <a-col :span="12">
            <div class="">
              <a-space direction="vertical">
                <span>平台</span>
                <span class="mr-5px" v-if="detailData.platform.length > 0" v-for="(item, index) in detailData.platform">
                  <img :src="PLATFORM_LIST[item].icon" width="19" class="mr-4px" />
                  <span>{{ PLATFORM_LIST[item].label }}</span>
                </span>
              </a-space>
            </div>
          </a-col>

          <a-col :span="12">
            <div class="">
              <a-space direction="vertical">
                <span>生成时间</span>
                <span>{{ detailData.created_at }}</span>
              </a-space>
            </div>
          </a-col>
        </a-row>
      </div>
    </div>
    <div>
      <MonthData :overview="aiResult.overview"></MonthData>

      <!--    投放建议-->
      <PlacementSuggestions :optimization="aiResult.optimization"></PlacementSuggestions>
      <!--      投放行动指南-->
      <ActionGuideDistribution :action_guide="aiResult.action_guide"></ActionGuideDistribution>
    </div>
  </div>
</template>

<script setup lang="ts">
import { reactive, ref } from 'vue';

import MonthData from './components/month-data/index.vue';
import PlacementSuggestions from './components/placement-suggestions/index.vue';
import ActionGuideDistribution from './components/action-guide-distribution';
import { PLATFORM_LIST } from '@/views/property-marketing/put-account/common_constants.ts';
import { getPlacementGuideDetail } from '@/api/all/propertyMarketing';
import { useRoute } from 'vue-router';

const aiResult = reactive({
  optimization: [], // 投放建议优化
  action_guide: [], // 新投放建议生成
  overview: [], // 新投放建议生成
});

const detailData = reactive({
  created_at: '',
  account: '',
  platform: [],
});
const route = useRoute();
const id = route.params.id;
const getDetail = async () => {
  const { code, data } = await getPlacementGuideDetail(id);
  if (code === 200) {
    Object.assign(aiResult, data.ai_result);
    Object.assign(detailData, data);
    console.log(aiResult, 'aiResult');
  }
};

onMounted(() => {
  getDetail();
});
</script>

<style lang="scss">
@import './style.scss';
</style>
