import Api from "../service/Api";

//对sel系列交易做全局处理
const trns = {
    did:"ditsel",
    lid:"litsel",
    cpd:"cptsel",
    ded:"detsel",
    led:"letsel",
    bpd:"bptsel",
    ccd:"cctsel",
    ged:"getsel",
    gid:"gitsel",
    mcd:"mctsel",
    trd:"trtsel"
}

export default {
    mounted() {
        if(!this.trnName){
            //非顶级vue实例，不需要执行
            return;
        }
       if(!this.isTrnSupport()){
           return
       }
        setTimeout(()=>{
            this.dealGlobalSearch()
        },50)
    },
    methods:{
        async dealGlobalSearch(){
           let params = this.$route.query
           if(!(params && params.ownref && params.objtyp)){
               return
           } 
           let ownref = params.ownref;
           let ownrefPath = params.objtyp+"grp.rec.ownref"
           let rtnmsg =  await this.executeRule(ownrefPath,undefined,()=>{
                this.model[params.objtyp+"grp"].rec.ownref=ownref
           })
           if(rtnmsg.respCode == SUCCESS)
           {
                this.updateModel(rtnmsg.data)
           }
        },
        isTrnSupport(){
           let trnName =  this.declareParams.trnName
           return Object.values(trns).includes(trnName)

           
        }
    }
    
}