<template>
    <sanctions-situation :enterprise-info="enterpriseInfo" :line-data="lineData"></sanctions-situation>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue';
import { getMarketCapList } from '@/api/companyPages';
import SanctionsSituation, { LineDataItem } from './SanctionsSituation.vue';


// 定义组件属性
const props = defineProps({
    enterpriseInfo: {
        type: Object,
        default: {}
    }
});

const lineData = ref<LineDataItem[]>([])

onMounted(async () => {
    await intData()
})
async function intData() {
    const { data } = await getMarketCapList(props.enterpriseInfo.id)
    lineData.value = data?.map(item => ({
        time: new Date(item.year, 1, 1),
        value: item.value,
        type: '市值变化',
        unit: item.unit ?? '亿元'
    })) ?? []
}
</script>