<template>
    <div>
        <div  class="autoBox box">
            <div class="crumbs">
                <el-breadcrumb separator="/">
                    <el-breadcrumb-item :to="{ path: 'home' }">{{$t('common.Home')}}</el-breadcrumb-item>
                    <el-breadcrumb-item :to="{ path: 'financialServices' }">{{$t('common.FinancialServices')}}</el-breadcrumb-item>
                    <el-breadcrumb-item>{{$t('common.InvestmentGuide')}}</el-breadcrumb-item>
                </el-breadcrumb>

            </div>
            <div style="padding: 0 20px">
                <div style="background:#fff;margin-top: 14px;">
                    <div style="width: 100%;height:50px;color: #fff;background: #2C558A;text-align: center;font-size: 28px;font-weight: 700;line-height: 50px;border-radius: 6px;">{{$t('common.InvestmentGuidelines')}}</div>
                </div>
                <div style="margin-top: 20px;">
                    <div style="width: 100%;padding:20px 0;border-bottom: 2px solid rgba(151,151,151,.5);color: #666666" v-for="(item,index) in initData" @click="toView('FinancialServicesGuideDetails',item.baseEntityId)">
                        <div style="width: 180px;height:254px;float: left;" v-if="item.photo && item.photo != null">
                            <img :src="'api/file/pub/'+ item.photo" alt="" style="width: 100%;height: 100%;">
                        </div>
                        <div style="width: 180px;height:254px;float: left;position: relative;text-align: center" v-if="!item.photo || item.photo==null" >
                            <img src="@/assets/img/financialService/investmentlogo.png" alt="" style="width: 100%;height: 100%;">
                            <div style="position: absolute;top: 50px;color: #fff; padding: 0 10px;font-size: 10px;width: 89%">
                                {{item.name}}
                            </div>
                            <div style="color: #173F79;font-size: 12px;position: absolute;bottom: 50px;padding: 0 10px;font-size: 10px;width: 89%">
                                {{$t('common.TitleBottom')}}
                            </div>
                        </div>
                        <div style="width:79.5%;height:254px;float: right;margin-left: 10px;position: relative">
                            <span style="font-size: 20px;font-weight: 700;cursor: pointer;" >{{item.name}}</span>
                            <div v-html="item.introduction" style="width: 100%;font-size:16px;text-align: justify;line-height: 20px;overflow: hidden;display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 5;"></div>
                            <div v-if="item.countries" style="width: 100%;font-size: 16px;position: absolute;bottom: 30px">{{$t('common.FocusCountry')}}：<span style="color: #0091FF">{{changeStr(item.countries)}}</span></div>
                            <!--语言版本-->
                            <div style="margin-top: 54px;font-size: 16px;position:absolute;bottom: 0" v-if="languageList[item.baseEntityId]">
                                <span>
                                    <span  v-show="languageList[item.baseEntityId].entityZh == 1">{{$t('common.Chinese')}}</span>

                                    <span  v-show="languageList[item.baseEntityId].entityEn == 1"> | {{$t('common.English')}}</span>

                                    <span v-show="languageList[item.baseEntityId].entityFr == 1"> | {{$t('common.French')}}</span>

                                    <span  v-show="languageList[item.baseEntityId].entityDe == 1"> | {{$t('common.German')}}</span>

                                    <span  v-show="languageList[item.baseEntityId].entityEs == 1"> | {{$t('common.Spanish')}}</span>

                                     <span  v-show="languageList[item.baseEntityId].entityJa == 1"> | {{$t('common.Japanese')}}</span>

                                    <span  v-show="languageList[item.baseEntityId].entityAr == 1"> | {{$t('common.Arabic')}}</span>

                                    <span  v-show="languageList[item.baseEntityId].entityRu == 1"> | {{$t('common.Russian')}}</span>
                                </span>
                                <span style="margin-left: 95px">{{formatDate(item.publishDate)}}</span>
                            </div>
                        </div>

                        <div style="clear: both"></div>
                    </div>
                    <div style="width: 100%;position: relative;height: 100px;">
                        <el-pagination
                                type="index"
                                style="height: 80px;position: absolute;left: 50%;top: 100px;transform: translate(-50%,-50%);"
                                background
                                :index="indexMethod"
                                layout="prev, pager, next"
                                :page-size="5"
                                :total="num-0"
                                @current-change="handleCurrentChange"
                        ></el-pagination>
                    </div>
                </div>
<!--                <div style="clear: both"></div>-->
                <!--            <div style="width:28%;height:100px;float: right;margin: 40px 0;">-->
                <!--其他机构相关研究报告-->
                <!--                <div class="relevanInformation">-->
                <!--                    <div class="informationTitle">{{$t('common.RelatedResearch')}}</div>-->
                <!--                    <div class="informationList">-->
                <!--                        <ul>-->
                <!--                            <li style="list-style: disc;margin-left: 20px;" v-for="reportIltem in reportList" @click="toInformationList1(reportIltem)">-->
                <!--                                <div class="list">-->
                <!--                                    {{reportIltem.name}}-->
                <!--                                </div>-->
                <!--                            </li>-->
                <!--                        </ul>-->
                <!--                    </div>-->
                <!--                </div>-->
                <!--投融资会议及活动-->
                <!--                <div class="relevanInformation">-->
                <!--                    <div class="informationTitle">{{$t('common.InvestmentAndFinancing')}}</div>-->
                <!--                    <div class="informationList">-->
                <!--                        <ul>-->
                <!--                            <li style="list-style: disc;margin-left: 20px" v-for="(InvestItem,index) in InvestmentList" @click="toDetails('ConferenceResult',InvestItem.id)">-->
                <!--                                <div class="list">-->
                <!--                                    {{$i18n.locale=='en'?InvestItem.meetingNameEn: InvestItem.meetingName}}-->
                <!--                                </div>-->
                <!--                            </li>-->
                <!--                            <li style="list-style: disc;margin-left: 20px" v-for="(activeItem,index) in activityList" @click="toDetails('cooperationExchangeListDetails',activeItem.baseActivityEntityId)">-->
                <!--                                <div class="list">-->
                <!--                                    {{activeItem.activityName}}-->
                <!--                                </div>-->
                <!--                            </li>-->
                <!--                        </ul>-->
                <!--                    </div>-->
                <!--                </div>-->

            </div>

        </div>
    </div>
</template>

<script>
    import {getBaseInvestmentGuidelinesInfos} from '@/api/financialService/baseInvestmentGuidelinesInfo';
    import { getDicts } from "@/api/dict";
    import {getConfrences} from "../../api/meeting/meetingOutInfo";
    import {activityInfos} from "../../api/cooperation/baseCooperationUnit";
    import {getBaseResearchResultViews} from "../../api/research/baseResearchResultView";
    export default{
        name:'FinancialServiceInvestmentGuide',
        data(){
            return{
                initData:[],
                num:0,
                params:{
                    pageSize:"5",
                    pageNo:"1",
                    language:'',
                    statusDict:'2'
                },
                reportList:[],
                InvestmentList:[],
                activityList:[],
                dictList:[],
                languageList:'',
            }
        },
        computed:{
            countryDictsMap: function () {
                return this.dictList.array2Obj('value', 'label');
            },
            changeStr(){
                return function (str) {
                    let newStr = '';
                    str.split(',').forEach(item =>{
                        newStr = newStr + this.countryDictsMap[item] + '、'
                    });
                    newStr = newStr.substring(0, newStr.lastIndexOf("、"));
                    return newStr ;
                }
            }
        },
        mounted() {
            this.getData();
            this.getDict();
            this.getMeetingAndActive();
            this.getactivityStatusDict();
            this.getreportList()
        },
        watch: {
            '$i18n.locale'(){
                this.getData();
                this.getDict();
                this.getMeetingAndActive();
                this.getactivityStatusDict();
                this.getreportList()

            },
        },
        methods:{
            getDict() {
                const that = this;
                if(this.$i18n.locale=='zh'){
                    getDicts(
                        "UNIT_COUNTRY_DICT"
                    ).then((res) => {
                        this.dictList = res.data[0];
                    });
                }else if(this.$i18n.locale=='en'){
                    getDicts(
                        "unit_country_dict_en"
                    ).then((res) => {
                        this.dictList = res.data[0];

                    });
                }
            },
            getData(dict){
                const that =this;
                this.params.language = this.$i18n.locale.toUpperCase();
                getBaseInvestmentGuidelinesInfos(this.params).then((res)=>{
                    this.initData = res.data.baseInvestmentGuidelinesInfos;
                    this.languageList = res.data.investmentGuidelinesEntitiesMap;
                    console.log(this.languageList)
                    if (this.initData){
                        this.num = res.data.page.totalCount;
                    }else{
                        this.num = '';
                    }
                    this.loading = false;

                })

            },
            toInformationList1(ele){
                let params = {
                    entityId:ele.entityId,
                    // researchResultFileId:ele.researchResultFileId,
                }
                this.toViewInformationList('resourceSharingDetails',params)
            },
            toViewInformationList(router, json) {
                clearInterval(this.timer);
                const {href} = this.$router.resolve({
                    name: router,
                    query: {
                        key:JSON.stringify(json),
                    }
                });
                window.open(href, '_blank');

            },
            toView(router,json){
                this.$router.push({
                    name:router,
                    query:{key:json}
                })
            },
            toDetails(router,json){
                // this.$store.commit('modify', router);
                window.localStorage.setItem('router', router);
                localStorage.setItem('conferenceId', json);
                const {href} = this.$router.resolve({
                    name: router,
                    query: {
                        key: json
                    }
                });
                window.open(href, '_blank');
            },
            getMeetingAndActive(){
                // 获取会议
                getConfrences().then((res)=>{
                    if(res.data.meetingBasicInfos){
                        let meetingLength = res.data.meetingBasicInfos.length;
                        this.InvestmentList = [];
                        for(let i=0;i<meetingLength;i++){
                            if(i<3){
                                this.InvestmentList.push(res.data.meetingBasicInfos[i])
                            }
                        }
                    }
                });
            },
            getactivityStatusDict(){
                let list={
                    pageSize:9,
                    pageNo:1,
                    language:this.$i18n.locale.toUpperCase(),
                    activityStatusDict:1, // 活动类型

                    activityArea:"",// 大洲

                }
                activityInfos(list).then(res=>{
                    if(JSON.stringify(res.data)!=='{}'){
                        let activityLength = res.data.activityInfos.length;
                        this.activityList = [];
                        for(let i=0;i<activityLength;i++){
                            if(i<2){
                                this.activityList.push(res.data.activityInfos[i])
                            }
                        }
                    }
                })
            },
            getreportList(){
                const that = this;
                let reportParams = {
                    pageSize: 5,
                    pageNo: 1,
                    language:this.$i18n.locale.toUpperCase(),
                    totalPage:'',
                    descStatus:'0'
                };
                getBaseResearchResultViews(reportParams).then((res)=>{
                    this.reportList = res.data.baseResearchResultViews;
                    console.log(this.reportList,'-----------------------------研究报告')
                })
            },
            //分页索引接着上一页的索引
            indexMethod(index){
                return (this.page-1)*10+index+1;
            },
            handleCurrentChange(val) {
                this.params.pageNo = val;
                this.loading = true;
                this.getData();
            },
        }

    }
</script>

<style scoped>
    .box {
        margin-top: 10px;
        background: #fff;
        /* height: 500px; */
        padding: 20px 0;
    }
    .crumbs {
        margin-left: 20px;
    }
    body {
        margin: 0;
    }
    p{
        margin: 0;
        padding: 0;
    }
    .relevanInformation{
        min-height: 200px;
        padding: 0 0 0 20px;
        overflow: hidden;
    }
    .informationTitle{
        border-bottom: 1px solid  #2C558A;
        padding: 0 0 10px 0;
        font-weight: 600;
        font-size: 20px;
        color: #666666;
        opacity: 0.9;
        color: #2C558A;
    }
    .informationList ul{
        margin-top: 14px;
        font-size: 14px;
        list-style-type:disc;
        padding: 0 30px 0 0;
        box-sizing: border-box;
    }
    .informationList ul li{
        width: 100%;
        /*height: 34px;*/
        line-height: 34px;
        margin-bottom: 12px;
        color: #666666;
        cursor: pointer;
        list-style-type: disc;
    }
    .informationList ul li .list{
        width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        display:-webkit-box;
        -webkit-box-orient:vertical;
        -webkit-line-clamp:3;

    }
</style>
