123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <script setup>
- import {computed,onMounted,ref} from 'vue'
- import apiChart from '@/api/chart.js'
- import {chartRender,useChartRender} from '@/hooks/chart/render'
- const {setLimitData,isUseSelfLimit}=useChartRender()
- const props=defineProps({
- itemData:{
- type:Object,
- default:{}
- }
- })
- const renderId=computed(()=>{
- if(props.itemData?.chartId){
- return 'chart'+props.itemData.chartId+'_'+props.itemData.pptPageIndex+'_'+props.itemData.position
- }
- })
- const sourceFrom=ref(null)
- // 获取图表详情
- let chartIsDelete=ref(false)//图表是否被删除
- async function getChartInfo(){
- const res=await apiChart.chartInfoByCode({UniqueCode:props.itemData.chartId,IsCache: true})
- if(res.Ret===200){
- if(!res.Data.ChartInfo){
- chartIsDelete.value=true
- return
- }
- let showChartTitle=false
- const {Source,ChartType}=res.Data.ChartInfo
- sourceFrom.value= res.Data.ChartInfo.SourcesFrom?JSON.parse(res.Data.ChartInfo.SourcesFrom):''
- if((Source==1&&[2,7,10].includes(ChartType))||(Source==2&&ChartType==8)){
- showChartTitle=true
- }
- //初始化上下限
- isUseSelfLimit.value = true
- setLimitData(res.Data)
- chartRender({
- data:res.Data,
- renderId:renderId.value,
- lang:window.location.pathname.startsWith('/ppten')?'en':'zh',
- changeLangIsCheck:true,
- showChartTitle,
- shouldUseSelfLimit:true,
- })
- }
- }
- onMounted(()=>{
- getChartInfo()
- })
- </script>
- <template>
- <div class="ppt-chart-box">
- <div class="chart-box" :id="renderId">
- <img v-if="chartIsDelete" class="empty-img" src="https://hzstatic.hzinsights.com/static/ppt_default.png" alt="">
- </div>
- <div class="chart-source">
- <span
- v-if="sourceFrom && sourceFrom.isShow"
- :style="`color: ${sourceFrom.isShow ? sourceFrom.color : '#999'};font-size: ${ sourceFrom.fontSize }px;`"
- >来源:{{ sourceFrom.text}}</span>
- </div>
- </div>
- </template>
- <style lang="scss" scoped>
- .ppt-chart-box{
- width: 100%;
- height: 100%;
- position: relative;
- z-index: 10;
- display: flex;
- flex-direction: column;
- .chart-box{
- width: 100%;
- // height: 100%;
- flex-grow: 1;
- .empty-img{
- width: 100%;
- height: 100%;
- object-fit: contain;
- }
- }
- .chart-source{
- width: 100%;
- text-overflow: ellipsis;
- white-space: nowrap;
- overflow: hidden;
- }
- }
- </style>
|