import Api from "~/service/Api"
import Utils from "~/utils/index"
export default {
    async onDitpButgetref() {
        let rtnmsg = await Api.post("ditopn/executeRule/ditp.butgetref", Utils.getRequestDataFn.call(this))
        if (rtnmsg.respCode == "AAAAAA") {
            //TODO 处理数据逻辑
            this.model.didgrp.rec.ownref=rtnmsg.data.didgrp_rec_ownref
            this.$message({
                type: 'success',
                message: '获取成功！'
            });
        }
        else {
            this.$notify.error({ title: '错误', message: '服务请求失败！' });
        }
    },
    async onAplpDet() {
        let rtnmsg = await Api.post("ditopn/executeRule/ditp.aplp.det", Utils.getRequestDataFn.call(this))
        if (rtnmsg.respCode == "AAAAAA") {
            //TODO 处理数据逻辑
            // console.log(rtnmsg.data);
        }
        else {
            this.$notify.error({ title: '错误', message: '服务请求失败！' });
        }
    },
    onBenpDet() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("ditopn/benp_det", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onRevclauseButtxmsel() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("ditopn/revclause_buttxmsel", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onLcrgodButtxmsel() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("ditopn/lcrgod_buttxmsel", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onLcrdocButtxmsel() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("ditopn/lcrdoc_buttxmsel", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onAdlcndButtxmsel() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("ditopn/adlcnd_buttxmsel", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onInsbnkButtxmsel() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("ditopn/insbnk_buttxmsel", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onRmbpDet() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("ditopn/rmbp_det", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onDefdetButtxmsel() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("ditopn/defdet_buttxmsel", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onPreperButtxmsel() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("ditopn/preper_buttxmsel", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onSetmodDet() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("ditopn/setmod_det", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onLiaallButmisamt() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("ditopn/liaall_butmisamt", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onLiaallButmissig() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("ditopn/liaall_butmissig", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onWrkpDet() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("ditopn/wrkp_det", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onOthpDet() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("ditopn/othp_det", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onLimptsGet1() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("ditopn/limpts_get1", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onLimptsGet2() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("ditopn/limpts_get2", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onLimmodTrycal() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("ditopn/limmod_trycal", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    async onLiaccvAdd() {
        // this.root.$refs.modelForm.validate(async valid => {
        //     if (!valid)
        //         return;
        //     let rtnmsg = await Api.post("ditopn/liaccv_add", Utils.getRequestDataFn.call(this))
        //     if (rtnmsg.respCode == "AAAAAA") {
        //         //TODO 处理数据逻辑

        //     }
        //     else {
        //         this.$notify.error({ title: '错误', message: '服务请求失败！' });
        //     }
        // })
        let rtnmsg = await Api.post("ditopn/executeRule/liaall.liaccv.add", Utils.getRequestDataFn.call(this))
        //const that = this.root;
        if (rtnmsg.respCode == "AAAAAA") {
            //TODO 处理数据逻辑
            debugger;
            this.stmData.data = rtnmsg.data.liaall_liaccv_stgstm.rows;
            this.dialogTableVisible = true;


        }
        else {
            this.$notify.error({ title: '错误', message: '服务请求失败！' });
        }
    },
    async onLiaccvDel() {
        // this.root.$refs.modelForm.validate(async valid => {
        //     if (!valid)
        //         return;
        //     let rtnmsg = await Api.post("ditopn/executeRule/liaall.liaccv.del", Utils.getRequestDataFn.call(this))
        //     if (rtnmsg.respCode == "AAAAAA") {
        //         //TODO 处理数据逻辑

        //     }
        //     else {
        //         this.$notify.error({ title: '错误', message: '服务请求失败！' });
        //     }
        // })
        let rtnmsg = await Api.post("ditopn/executeRule/liaall.liaccv.del", Utils.getRequestDataFn.call(this))
        //const that = this.root;
        if (rtnmsg.respCode == "AAAAAA") {
            //TODO 处理数据逻辑
            debugger;
            this.$message({
                type: 'success',
                message: '删除成功！'
            });
            //this.model.liaall.liaccv.liaccvg = [];
            Utils.copyValueFromVO(this.model,rtnmsg.data);

        }
        else {
            this.$notify.error({ title: '错误', message: '服务请求失败！' });
        }
    },
    onSeainf() {

    },
    async handleDisplay(index, row){
        let cortyp = row.cortyp
        let rtnmsg
        if (cortyp == 'SWT'|| cortyp == 'FMT' || cortyp == 'CMT') {
            this.model.setmod.msgmod.doccod = row.id
            rtnmsg = await Api.post('cptopn/msgmod_butshw', {  data: Utils.getRequestDataFn.call(this) })
        } else {
            this.model.trnmod.trndoc.doccod = row.id
            this.model.trnmod.trndoc.cortyp = cortyp
            const params = {
                index: index
            }
            rtnmsg = await Api.post("ditopn/executeDocpan", Utils.getRequestDataFn.call(this, params))
        }
        if (rtnmsg.respCode == "AAAAAA") {
            if (cortyp == 'SWT' || cortyp == 'FMT' || cortyp == 'CMT') {
                let viewurl = rtnmsg.data.setmod_msgmod_docpth; 
                this.viewurl = viewurl
                this.title="报文"
                //window.open(viewurl, 'newwindow', 'height=1200,width=800,top=100,left=100,toolbar=no,resizable=no,menubar=no,location=no, status=no');
            } 
            else if(cortyp == 'ELC')
            {
                 Modal.info({title:'电证报文',content:<div style={{height:400,overflow:'auto'}}><ELCMessage mty={row.id} message={rtnmsg.data["\\trnmod\\trndoc\\docinf"]}/></div>,
                         width:1000,
                        
                     })
            }
            else {
                // let url = rtnmsg.data.trnmod_trndoc_smh_docpth;
                this.title = "面函"
                let viewurl = "/#/docpan/show";
                let XMLdata;
                if(row.pandsc=="国内信用证"){
                    window.sessionStorage.docTXT = ''
                    window.sessionStorage.docXML = rtnmsg.data.litbenl1blk;
                }
                else if(row.pandsc=="开立国内信用证备查表"){
                    window.sessionStorage.docTXT = ''
                    window.sessionStorage.docXML= rtnmsg.data.litapll1blk
                }
                else if(row.pandsc=="elcs.101.001.01"){
                    window.sessionStorage.docXML = ''
                    window.sessionStorage.docTXT = ''
                    rtnmsg.data.trnmod_trndoc_doceot[index].doctxt.rows.forEach(element => {
                        window.sessionStorage.docTXT +=element+"\r\n"
                    });
                   
                }  
                else if(row.pandsc=="MT799"){
                    window.sessionStorage.docTXT = ''
                    XMLdata = rtnmsg.data.litbenl1blk
                }
                // console.log( window.sessionStorage.docTXT);
                // console.log( window.sessionStorage.docXML);
                window.open(viewurl, 'newwindow', 'height=1200,width=800,top=100,left=100,toolbar=no,resizable=no,menubar=no,location=no, status=no');
            }
            this.dialogOpen=true
        }
        else {
            this.$notify.error({title: '错误',message: '服务请求失败！'})
        }
    },
    async handleDetail(index, row){
        const params = {
            index: index
        }
        let rtnmsg = await Api.post("ditopn/executeDocpanDetail", {  ...Utils.getRequestDataFn.call(this), params })
        if (rtnmsg.respCode == "AAAAAA") {
            //TODO 处理数据逻辑
            this.title = row.pandsc
            this.centerDialogVisible = true,
                this.dialog = rtnmsg.data.trnmod_trndoc_doceot[index]
            this.index = index
        }
    },
    async BlurBennam(e){
        let rtnmsg = await Api.post("ditopn/executeDefault/ditp.remark", Utils.getRequestDataFn.call(this))
        if (rtnmsg.respCode == "AAAAAA") {
            //TODO 处理数据逻辑
            this.model.ditp.remark = rtnmsg.data.ditp_remark
        }
    },
    async BlurAplname(e){
        let rtnmsg = await Api.post("ditopn/executeDefault/ditp.remark", Utils.getRequestDataFn.call(this))
        if (rtnmsg.respCode == "AAAAAA") {
            //TODO 处理数据逻辑
            this.model.ditp.remark = rtnmsg.data.ditp_remark
        }
    },
    async BlurSignam(e){
        let rtnmsg = await Api.post("ditopn/executeDefault/ditp.remark", Utils.getRequestDataFn.call(this))
        if (rtnmsg.respCode == "AAAAAA") {
            //TODO 处理数据逻辑
            this.model.ditp.remark = rtnmsg.data.ditp_remark
        }
    },
    async onExtkey(e){

    },
    async pickDepItem(row){
        debugger;
        var params = {'selsptinr':row[0]};
        //{params:{'selsptinr':row[0]}}
        let rtnmsg = await Api.post("ditopn/executeRule/liaall.liaccv.add",{...Utils.flatObject(this.model),params})
        if (rtnmsg.respCode == "AAAAAA") {
            this.dialogTableVisible = false;
            Utils.copyValueFromVO(this.model,rtnmsg.data);
        }
    },
    // didgrp.iss.pts.extkey
    async changeExtkey( ){

        let rtnmsg = await Api.post("ditopn/executeRule/didgrp.iss.pts.extkey",{...Utils.getRequestDataFn.call(this)})
        if (rtnmsg.respCode == "AAAAAA") {
            Utils.copyValueFromVO(this.model,rtnmsg.data);
        }
    }
   
}