<template>
    <div class="autoBox box" style="min-height: 900px;position: relative;">
        <div class="crumbs">
            <div style="overflow: hidden">
                <el-breadcrumb separator-class="el-icon-arrow-right" style="float: left">
                    <el-breadcrumb-item :to="{ path: 'home' }">{{$t('common.Home')}}</el-breadcrumb-item>
                    <el-breadcrumb-item :to="{ path: 'resourceSharing' }" class="pointer">{{$t('common.ResourceSharing')}}</el-breadcrumb-item>
                    <el-breadcrumb-item>{{$t('common.resourceResearchResourceIssue')}}</el-breadcrumb-item>
                </el-breadcrumb>
            </div>
            <div class="content">
                <div class="addLanguage">
                    <i class="el-icon-orange" style="font-size: 30px;line-height: 50px;color: #E6A23C;vertical-align: middle;"></i>
                    <span style="font-size: 18px;line-height: 50px;margin-left: 20px;vertical-align: middle;">{{$t('common.resourceLanguageVersion')}}</span>
<!--                    <i class="el-icon-plus" style="font-size: 30px;font-weight: 600;margin-left: 20px;line-height: 50px; color: #E6A23C;vertical-align: middle;"></i>-->
<!--                        <i class="el-icon-plus" style="font-size: 30px;font-weight: 600;margin-left: 20px;line-height: 50px; color: #E6A23C;vertical-align: middle;"-->
<!--                           @click="addTabDialog(editableTabsValue)"></i>-->
                </div>
                <div class="issue">
                    <el-tabs v-model="editableTabsValue" type="card" closable @tab-remove="removeTab">
                        <el-tab-pane
                                v-for="(item, index) in languageList"
                                :key="item.name"
                                :label="$t(item.title)"
                                :name="item.name"
                        >
                            <div style="width: 100%;padding: 0 150px;box-sizing: border-box">
                                <el-form ref="form" :model="form" :rules="rules" label-width="140px">
                                    <!--资源类型  调研资源-->
                                    <el-form-item required :label="$t('common.resourceTheResourceType')">
                                        <!--<el-select style="width: 320px;" v-model="form.public.resourceTypeSelectValue1" :placeholder="$t('common.resource')" @change="resourceType">
                                            <el-option
                                                    v-for="item in form.public.resourceTypeSelect"
                                                    :label="item.value"
                                                    :value="item">
                                            </el-option>
                                        </el-select>-->
                                        <el-input :value="$t('common.researchResource')" style="width: 320px;float: left;" disabled class="research"></el-input>
                                        <el-select v-model="form.public.resourceTypeSelectValue" :placeholder="$t('common.resourcePleaseSelectTheSecondaryType')" style="width: 320px;float: right;">
                                            <el-option
                                                    v-for="item in form.public.resourceTypeSelect"
                                                    :label="item.label"
                                                    :value="item">
                                            </el-option>
                                        </el-select>
                                    </el-form-item>
                                    <!--媒体-->
                                    <el-form-item :label="$t('common.resourceResearchResourceMedia')">
                                        <el-upload
                                                class="upload-demo"
                                                action="/api/file/upload/attachment?module=BaseResearchResourcesInfoForm&attachmentBusinessType=base_research_resource_info_media"
                                                :before-upload="beforeUploadMedia"
                                                :on-remove="onRemoveMedia"
                                                :on-preview="onPreviewMedia"
                                                list-type="picture"
                                                :on-success="handleAvatarSuccessMedia"
                                                :limit="1"
                                                :headers="myHeaders"
                                                :file-list="fileList">
                                            <el-button size="small" type="primary">{{$t('common.resourceSelectUploadFile')}}</el-button>
                                            <div slot="tip" class="el-upload__tip" style="display: inline-block;margin-left: 5px;">{{$t('common.resourceUploadJPGPNG')}}，{{$t('common.resourceFilesCannotExceed10Mb')}}，{{$t('common.resourceUploadOne')}}</div>
                                        </el-upload>
                                    </el-form-item>
                                    <!--名称-->
                                    <el-form-item required :label="$t('common.resourceName')">
                                        <el-input v-model="form[item.language].name"
                                                  :placeholder="$t('common.resourcePleaseEnterTheName')"
                                        ></el-input>
                                    </el-form-item>
                                    <!--所属单位-->
                                    <el-form-item required :label="$t('common.resourceSubordinateUnits')">
                                        <el-input v-model="form[item.language].affiliatedUnitName"
                                                  :placeholder="$t('common.resourcePleaseEnterUnit')"
                                        ></el-input>
                                    </el-form-item>
                                    <!--国家-->
                                    <el-form-item required :label="$t('common.resourceCountries')">
                                        <el-select style="width: 320px;" v-model="form.public.resourceCountrySelectValue1" :placeholder="$t('common.resourcePleaseSelectContinent')" @change="resourceCountry">
                                            <el-option
                                                    v-for="item in form.public.resourceCountrySelect"
                                                    :label="item.label"
                                                    :value="item">
                                            </el-option>
                                        </el-select>
                                        <el-select v-model="form.public.resourceCountrySelectValue2" :placeholder="$t('common.resourcePleaseSelectCountry')"  style="width: 320px;float: right;">
                                            <el-option
                                                    v-for="item in form.public.resourceCountrySelectValue1.data"
                                                    :label="item.label"
                                                    :value="item">
                                            </el-option>
                                        </el-select>
                                    </el-form-item>
                                    <!--联系人-->
                                    <el-form-item required :label="$t('common.resourceTheContact')">
                                        <el-input v-model="form[item.language].contactsName"
                                                  :placeholder="$t('common.resourcePleaseEnterTheContactName')"
                                        ></el-input>
                                    </el-form-item>
                                    <!--联系电话-->
                                    <el-form-item :label="$t('common.resourceContactPhoneNumber')">
                                        <el-input v-model="form[item.language].contactsNumber"
                                                  :placeholder="$t('common.resourcePleaseEnterYourContactNumber')"
                                        ></el-input>
                                    </el-form-item>
                                    <!--摘要-->
                                    <el-form-item :label="$t('common.resourceDetailsAbstract')">
                                        <el-input
                                                type="textarea"
                                                :placeholder="$t('common.resourcePleaseEnterSummary')"
                                                v-model="form[item.language].details"
                                                maxlength="500"
                                                show-word-limit
                                                rows="6"
                                        >
                                        </el-input>
                                    </el-form-item>
                                    <!--视频-->
                                    <el-form-item :label="$t('common.resourceResearchResourceVideo')">
                                        <el-upload
                                                class="upload-demo"
                                                action="/api/resourceshare/baseResearchResourcesInfos/uploadVideo"
                                                :before-upload="beforeUploadVideo"
                                                :on-remove="onRemoveVideo"
                                                :on-preview="onPreviewVideo"
                                                :on-success="handleAvatarSuccessVideo"
                                                :limit="1"
                                                :headers="myHeadersVideo"
                                                :file-list="fileList"
                                                :data="video"
                                                name="layuiVideo">
                                            <el-button size="small" type="primary">{{$t('common.resourceSelectUploadFile')}}</el-button>
                                            <div slot="tip" class="el-upload__tip" style="display: inline-block;margin-left: 5px;">{{$t('common.resourceUploadJPGPNG')}}，{{$t('common.resourceFilesCannotExceed')}}50MB，{{$t('common.resourceUploadOne')}}</div>
                                        </el-upload>
                                    </el-form-item>
                                    <!--附件-->
                                    <el-form-item :label="$t('common.resourceTheAttachment')">
                                        <el-upload
                                                class="upload-demo"
                                                action="/api/file/upload/attachment?module=BaseResearchResourcesInfoForm&attachmentBusinessType=base_research_resource_info_file"
                                                :before-upload="beforeUploadFile"
                                                :on-remove="onRemoveFile"
                                                :on-preview="onPreviewFile"
                                                :on-success="handleAvatarSuccessFile"
                                                :limit="1"
                                                :headers="myHeaders"
                                                :file-list="fileList">
                                            <el-button size="small" type="primary">{{$t('common.resourceSelectUploadFile')}}</el-button>
                                            <div slot="tip" class="el-upload__tip" style="display: inline-block;margin-left: 5px;">{{$t('common.resourceUploadPDF')}}，{{$t('common.resourceFilesCannotExceed50Mb')}}</div>
                                        </el-upload>
                                    </el-form-item>
                                    <!--轮播图-->
                                    <el-form-item :label="$t('common.resourceSlideshow')">
                                        <el-upload
                                                class="upload-demo"
                                                action="/api/file/upload/img?module=BaseResearchResourcesEntityForm"
                                                :before-upload="beforeUploadBanner"
                                                :on-remove="onRemoveBanner"
                                                :on-preview="onPreviewBanner"
                                                list-type="picture"
                                                :on-success="handleAvatarSuccessBanner"
                                                :limit="1"
                                                :headers="myHeaders"
                                                :file-list="fileList">
                                            <el-button size="small" type="primary">{{$t('common.resourceSelectUploadFile')}}</el-button>
                                            <div slot="tip" class="el-upload__tip" style="display: inline-block;margin-left: 5px;">{{$t('common.resourceUploadJPGPNG')}}，{{$t('common.resourceFilesCannotExceed10Mb')}}</div>
                                        </el-upload>
                                    </el-form-item>
                                    <el-form-item style="text-align: center;">
                                        <el-button style="margin-right: 50px;">{{$t('common.resourceCancel')}}</el-button>
                                        <el-button type="primary" @click="onSubmit">{{$t('common.resourceRelease')}}</el-button>
                                    </el-form-item>
                                </el-form>
                            </div>
                        </el-tab-pane>
                    </el-tabs>
                </div>
            </div>
        </div>
        <el-dialog
                :visible.sync="dialogVisible"
                width="60%"
                height="80%"
                :before-close="beforeClose">
            <div>
                <!--                <img :src="'api/file/pub/'+ dialogVisibleImg" alt="">-->
                <img :src="'api/file/pub/'+ dialogVisibleImg" alt="" style="width: 100%" v-show="dialogVisibleImg!=''">
                <video :src="'api/file/pub/'+ dialogVisibleVideo" style="width: 100%" v-show="dialogVisibleVideo!=''"
                       type="video/mp4" controls="controls"  width="100%"  autoplay preload="auto"></video>
                <iframe :src="'api/file/pub/'+ dialogVisiblePdf" frameborder="0" v-show="dialogVisiblePdf!=''" style="width: 100%;height: 800px;"></iframe>
            </div>
        </el-dialog>
        <el-dialog
            :title="$t('common.resourceLanguageVersion')"
            :visible.sync="addLanguage"
            width="30%">
                <div>
                    <el-select v-model="addLanguageValue">
                        <el-option
                                v-for="item in addLanguageOptions"
                                :label="$t(item.label)"
                                :value="item"
                                :style="!item.label==languageList.title">
                        </el-option>
                    </el-select>
                </div>
                <span slot="footer" class="dialog-footer">
                    <el-button @click="languageClose">取 消</el-button>
                    <el-button type="primary" @click="addTab">确 定</el-button>
                </span>
        </el-dialog>
    </div>
</template>

<script>
    import Base from "@/views/base/Base";
    import {getDicts} from '@/api/dict';
    import { saveOrUpdate,UpdateVideo } from "@/api/research/resource/baseResearchResourcesEntity";
    import { getToken ,resetToken} from '@/utils/auth'
    import { getTreeByLanguagePortal } from "@/api/operation/baseCityInformationDict";
    export default {
        name: "resourceSharingResourceIssue",
        extends: Base,
        data(){
            return{
                dialogVisible:false,
                dialogVisibleImg:'',
                dialogVisibleVideo:'',
                dialogVisiblePdf:'',
                addLanguage:false,
                addLanguageOptions: [
                    {
                        label: "common.Chinese",
                        name: '1',
                        value: 'CN',
                    },
                    {
                        label: 'common.English',
                        name: '2',
                        value: 'EN',
                    }
                ],
                addLanguageValue: '',
                video:{dir:'media'},
                myHeaders: {Authorization: ('Bearer ' +getToken())},
                myHeadersVideo: {Authorization: ('Bearer ' +getToken())},
                fileList:[],
                editableTabsValue: '1',
                languageList:[
                    {
                        title: "common.Chinese",
                        name: '1',
                        language: 'CN',
                    },
                    {
                        title: 'common.English',
                        name: '2',
                        language: 'EN',
                    }
                ],
                tabIndex: 2,
                form: {
                    public:{
                        resourceTypeSelectValue:'',
                        resourceTypeSelect:[],

                        resourceCountrySelectValue1:'',
                        resourceCountrySelectValue2:'',
                        resourceCountrySelectValue:'',
                        resourceCountrySelect:[],
                    },
                    CN:{
                        language:"ZH",
                        reserveOne:2, // 资源类型
                        researchResourcesType:'',
                        name:'',
                        affiliatedUnitName:'',
                        country:'',//国家
                        continent:'',//大洲
                        contactsName:'',
                        contactsNumber:'',
                        researchResourceAbstract:'',
                        researchResourcesMediaVideo:'',
                        reserveTwo:'',//轮播图
                    },
                    EN:{
                        language:"EN",
                        reserveOne:2, // 资源类型
                        researchResourcesType:'',
                        name:'',
                        affiliatedUnitName:'',
                        country:'',//国家
                        continent:'',//大洲
                        contactsName:'',
                        contactsNumber:'',
                        researchResourceAbstract:'',
                        researchResourcesMediaVideo:'',
                        reserveTwo:'',//轮播图
                    }
                },
                baseResearchResourcesInfo:{
                    reserveOne:2, // 资源类型
                    researchResourcesType:'',
                    researchResourcesMedia:'',
                    name:'',
                    affiliatedUnitName:'',
                    country:'',//国家
                    continent:'',//大洲
                    contactsName:'',
                    contactsNumber:'',
                    details:'',
                    researchResourcesMediaVideo:'',
                    fileAddress:'',
                    reserveTwo:'',
                },
                mediaFileMap: new Map(),
                fileMap: new Map(),
                rules: {
                    name: [
                        { required: true},
                    ],
                },
            }
        },
        mounted() {
            if (!this.$Cookies.get('token')){
                this.toView('resourceSharing',1)
            }else{
                this.initData();
            };
        },
        watch:{
            '$i18n.locale'(){
                this.initData();
            },
        },
        methods:{
            initData(){
                this.getData();
            },
            resourceType(data){
                let that = this;
                if (data.value === 'Research results' || data.value === '研究成果'){
                    that.baseResearchResourcesInfo.reserveOne = 1;
                }else{
                    that.baseResearchResourcesInfo.reserveOne = 2;
                }
            },
            resourceCountry(data){
                this.form.public.resourceTypeSelectValue2 = '';
                let that = this;
            },
            addTabDialog(){
                const that = this;
                that.addLanguage = true;
            },
            languageClose(){
                const that = this;
                that.addLanguage = false;
            },
            addTab(targetName) {
                const that = this;

                that.addLanguage = false;


                // let newTabName = ++this.tabIndex + '';
                // this.languageList.push({
                //     title: 'New Tab',
                //     name: newTabName,
                //     content: 'New Tab content'
                // });
                // this.editableTabsValue = newTabName;
            },
            removeTab(targetName) {
                let tabs = this.languageList;
                let activeName = this.editableTabsValue;
                if (activeName === targetName) {
                    tabs.forEach((tab, index) => {
                        if (tab.name === targetName) {
                            let nextTab = tabs[index + 1] || tabs[index - 1];
                            if (nextTab) {
                                activeName = nextTab.name;
                            }
                        }
                    });
                }
                this.editableTabsValue = activeName;
                this.languageList = tabs.filter(tab => tab.name !== targetName);
            },
            onSubmit() {
                const that = this;
                //选择器
                that.form.CN.researchResourcesType = that.form.EN.researchResourcesType = that.form.public.resourceTypeSelectValue.value;
                that.form.CN.continent = that.form.EN.continent = that.form.public.resourceCountrySelectValue1.value;
                that.form.CN.country = that.form.EN.country = that.form.public.resourceCountrySelectValue2.value;


                let data = []
                data.push(that.form.CN)
                data.push(that.form.EN)

                let token = getToken();
                this.submitHandler((token) => {
                    saveOrUpdate(
                        JSON.stringify(data), 
                        JSON.stringify(that.mediaFileMap), 
                        JSON.stringify(that.fileMap), 
                        token
                    ).then(result => {
                        if (this.$i18n.locale.toUpperCase() == 'ZH') {
                            alert('发布成功');

                        } else {
                            alert('Release Success');
                        }
                    }).catch((error) => {
                        this.resetToken();
                        if (this.$i18n.locale.toUpperCase() == 'ZH') {
                            alert('发布失败');
                        } else {
                            alert('Release Error');
                        }
                    });
                    this.toResourceSharing()
                });
            },

            beforeUploadMedia(file) {
                var FileExt = file.name.replace(/.+\./, "");
                if (['jpg', 'png'].indexOf(FileExt.toLowerCase()) === -1) {
                    if (this.$i18n.locale.toUpperCase() == 'ZH') {
                        this.$message({
                            type: 'warning',
                            message: '请上传jpg,png的图片！'
                        });
                    } else {
                        this.$message({
                            type: 'warning',
                            message: 'Please upload the picture of jpg, png!'
                        });
                    }
                    return false;
                }
                this.isLt2k = file.size / 1024 / 1024 < 10 ? '1' : '0';
                if (this.isLt2k === '0') {
                    if (this.$i18n.locale.toUpperCase() == 'ZH') {
                        this.$message({
                            message: '上传文件大小不能超过10M!',
                            type: 'error'
                        });
                    } else {
                        this.$message({
                            message: 'Upload file size cannot exceed 10M!',
                            type: 'error'
                        });
                    }
                    return false;
                }
            },
            beforeUploadVideo(file) {
                const isLt200M = file.size / 1024 / 1024  < 200;
                if (['video/mp4'].indexOf(file.type) == -1) {
                    if (this.$i18n.locale.toUpperCase() == 'ZH') {
                        this.$message({
                            type: 'warning',
                            message: '请上传mp4的视频！'
                        });
                    } else {
                        this.$message({
                            type: 'warning',
                            message: 'Please upload the Video of MP4!'
                        });
                    }
                    return false;
                }
                if (!isLt200M) {
                    if (this.$i18n.locale.toUpperCase() == 'ZH') {
                        this.$message({
                            message: '上传文件大小不能超过200M!',
                            type: 'error'
                        });
                    } else {
                        this.$message({
                            message: 'Upload file size cannot exceed 200M!',
                            type: 'error'
                        });
                    }
                    return false;
                }
            },
            beforeUploadFile(file) {
                var FileExt = file.name.replace(/.+\./, "");
                if (['pdf'].indexOf(FileExt.toLowerCase()) === -1) {
                    if (this.$i18n.locale.toUpperCase() == 'ZH') {
                        this.$message({
                            type: 'warning',
                            message: '请上传pdf的附件！'
                        });
                    } else {
                        this.$message({
                            type: 'warning',
                            message: 'Please upload the attachment of PDF!'
                        });
                    }
                    return false;
                }
                this.isLt2k = file.size / 1024 / 1024 < 50 ? '1' : '0';
                if (this.isLt2k === '0') {
                    if (this.$i18n.locale.toUpperCase() == 'ZH') {
                        this.$message({
                            message: '上传文件大小不能超过50M!',
                            type: 'error'
                        });
                    } else {
                        this.$message({
                            message: 'Upload file size cannot exceed 50M!',
                            type: 'error'
                        });
                    }
                    return false;
                }
            },
            beforeUploadBanner(file) {
                var FileExt = file.name.replace(/.+\./, "");
                if (['jpg', 'png'].indexOf(FileExt.toLowerCase()) === -1) {
                    if (this.$i18n.locale.toUpperCase() == 'ZH') {
                        this.$message({
                            type: 'warning',
                            message: '请上传jpg,png的图片！'
                        });
                    } else {
                        this.$message({
                            type: 'warning',
                            message: 'Please upload the picture of jpg, png!'
                        });
                    }
                    return false;
                }
                this.isLt2k = file.size / 1024 / 1024 < 10 ? '1' : '0';
                if (this.isLt2k === '0') {
                    if (this.$i18n.locale.toUpperCase() == 'ZH') {
                        this.$message({
                            message: '上传文件大小不能超过10M!',
                            type: 'error'
                        });
                    } else {
                        this.$message({
                            message: 'Upload file size cannot exceed 10M!',
                            type: 'error'
                        });
                    }
                    return false;
                }
            },
            onRemoveMedia() {
                if(this.editableTabsValue == 1){
                    this.researchResourcesMediaVideo.delete("ZH")
                }else{
                    this.researchResourcesMediaVideo.delete("EN")
                }
            },
            onRemoveVideo() {
                if(this.editableTabsValue == 1){
                    this.form.ZH.researchResourcesMediaVideo = ''
                }else{
                    this.form.EN.researchResourcesMediaVideo = ''
                }
            },
            onRemoveFile() {
                if(this.editableTabsValue == 1){
                    this.fileMap.delete("ZH")
                }else{
                    this.fileMap.delete("EN")
                }
            },
            onRemoveBanner() {
                if(this.editableTabsValue == 1){
                    this.form.ZH.reserveTwo = ''
                }else{
                    this.form.EN.reserveTwo = ''
                }
            },
            onPreviewMedia(file){
                this.dialogVisible = true;
                this.dialogVisibleImg = file.response.data.path;
            },
            onPreviewVideo(file){
                this.dialogVisible = true;
                this.dialogVisibleVideo = file.response.url;
            },
            onPreviewFile(file){
                console.log(file)
                this.dialogVisible = true;
                this.dialogVisiblePdf = file.response.data.path;
            },
            onPreviewBanner(file){
                this.dialogVisible = true;
                this.dialogVisibleImg = file.response.data;
            },

            handleAvatarSuccessMedia(res,file){
                /*if(this.editableTabsValue == 1){
                    let url = res.data;
                    this.form.CN.researchResultCover = JSON.stringify(url);
                    this.form.CN.researchResultCover = this.form.CN.researchResultCover.replace(/"/g, "")
                }else{
                    let url = res.data;
                    this.form.EN.researchResultCover = JSON.stringify(url);
                    this.form.EN.researchResultCover = this.form.CN.researchResultCover.replace(/"/g, "")
                }*/
                if(this.editableTabsValue == 1){
                    this.mediaFileMap.set("ZH",res.data.attachmentId)
                }else{
                    this.mediaFileMap.set("EN",res.data.attachmentId)
                }
            },
            handleAvatarSuccessVideo(res,file){
                if(this.editableTabsValue == 1){
                    let url = res.url;
                    this.form.CN.researchResourcesMediaVideo = JSON.stringify(url);
                    this.form.CN.researchResourcesMediaVideo = this.form.CN.researchResourcesMediaVideo.replace(/"/g, "")
                }else{
                    let url = res.data;
                    this.form.EN.researchResourcesMediaVideo = JSON.stringify(url);
                    this.form.EN.researchResourcesMediaVideo = this.form.CN.researchResourcesMediaVideo.replace(/"/g, "")
                }
            },
            handleAvatarSuccessFile(res,file){
                /*if(this.editableTabsValue == 1){
                    let url = res.data;
                    this.form.CN.researchResultFile = JSON.stringify(url);
                    this.form.CN.researchResultFile = this.form.CN.researchResultFile.replace(/"/g, "")
                }else{
                    let url = res.data;
                    this.form.EN.researchResultFile = JSON.stringify(url);
                    this.form.EN.researchResultFile = this.form.CN.researchResultFile.replace(/"/g, "")
                }*/
                if(this.editableTabsValue == 1){
                    this.fileMap.set("ZH",res.data.attachmentId)
                }else{
                    this.fileMap.set("EN",res.data.attachmentId)
                }
            },
            handleAvatarSuccessBanner(res,file){
                if(this.editableTabsValue == 1){
                    let url = res.data;
                    this.form.CN.reserveTwo = JSON.stringify(url);
                    this.form.CN.reserveTwo = this.form.CN.reserveTwo.replace(/"/g, "")
                }else{
                    let url = res.data;
                    this.form.EN.reserveTwo = JSON.stringify(url);
                    this.form.EN.reserveTwo = this.form.CN.reserveTwo.replace(/"/g, "")
                }
            },
            async getData(){
                const that = this;
                that.form.public.resourceCountrySelectValue1 = '';
                that.form.public.resourceCountrySelectValue2 = '';
                if (this.$i18n.locale.toUpperCase() == 'ZH') {
                    await getDicts(
                        "RESEARCH_RESOURCE_TYPE_DICT"
                    ).then(result => {
                        if (result.data) {
                            that.form.public.resourceTypeSelect = result.data[0];
                        }
                    })
                    await getTreeByLanguagePortal('ZH').then(result => {
                        if (result.data) {
                            let values = Object.values(result.data);
                            that.form.public.resourceCountrySelect = values;
                        }
                    })
                }else if (this.$i18n.locale.toUpperCase() == 'EN'){
                    await getDicts(
                        "RESEARCH_RESOURCE_TYPE_DICT_EN"
                    ).then(result => {
                        if (result.data) {
                            that.form.public.resourceTypeSelect = result.data[0];
                        }
                    })
                    await getTreeByLanguagePortal('EN').then(result => {
                        if (result.data) {
                            let values = Object.values(result.data);
                            that.form.public.resourceCountrySelect = values;
                        }
                    })
                }
            },
            toView(router, json) {
                clearInterval(this.timer);
                this.$router.push({ name: router, params: {key:json} });
            },
            beforeClose(done){
                this.dialogVisibleImg = '';
                this.dialogVisibleVideo = '';
                this.dialogVisiblePdf = '';
                done()
            },
            toResourceSharing(){
                this.toView('resourceSharing',1)
            },
        }
    }
</script>

<style scoped>
    .box {
        margin-top: 10px;
        background: #fff;
        /* height: 500px; */
        padding: 20px 0;
    }
    .crumbs {
        margin:0 20px;
    }
    .content{
        width: 100%;
        padding: 20px 10px;
        box-sizing: border-box;
    }
    .content .addLanguage{
        width: 100%;
        height: 50px;
        border-bottom: 1px solid #666666;
    }
    .content .issue{
        margin-top: 15px;
    }
</style>
<style>
    .research input[type=text].el-input__inner{
        color: red;
    }
</style>