/*
    研报及审批配置,涉及到:
    智能研报
    中文研报(除晨周报)
    英文研报
    审批流配置
    审批管理
    审批详情
 */
import {etaBaseConfigInterence} from '@/api/modules/etaBaseConfigApi.js';
import {approveInterence} from '@/api/modules/approve.js';
export default{
    data(){
        return{
            ReportApproveType:'',
            IsReportApprove:false,
            pageLoading:false,
            hasApproveFlow:false,
            checkLoading:false,
        }
    },
    computed:{
        //是否开启审批流
        isApprove(){
            return this.IsReportApprove
        },
        //是否开启了ETA审批流
        isETAApprove(){
            return this.IsReportApprove&&this.ReportApproveType==='eta'
        },
        //是否开启了接口审批
        isOtherApprove(){
            return this.IsReportApprove&&this.ReportApproveType==='other'
        },
    },
    methods:{
        async getBaseConfig(){
            //从基本配置中获取是否开启审批流的数据
            this.pageLoading = true
            const res = await etaBaseConfigInterence.getBaseConfig()
            this.pageLoading = false
            if(res.Ret!==200) return
            const {IsReportApprove='',ReportApproveType=''} = res.Data
            this.IsReportApprove = IsReportApprove==='true'?true:false,
            this.ReportApproveType = ReportApproveType
        },
        //检查是否有审批流
        checkClassifyNameArr(type=1,classify=[]){
            this.checkLoading=true
            let params = {
                ReportType:type,
                ClassifyFirstId:classify[classify.length-2]||0,
                ClassifySecondId:classify[classify.length-1]||0,
            }
            approveInterence.checkClassifyApprove(params).then(res=>{
                this.checkLoading=false
                if(res.Ret!==200) return 
                this.hasApproveFlow = res.Data||false
            })
        },
    },
    mounted(){
        this.getBaseConfig()
    }
}