import Api from "~/service/Api"
import Utils from "~/utils/index"
export default {
    onLitp1Butgetref() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("ditopn/litp1_butgetref", { data: this.model })
            if (rtnmsg.retcod == SUCCESS) {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onLitp1Hth() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("ditopn/litp1_hth", { data: this.model })
            if (rtnmsg.retcod == SUCCESS) {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onAplpDet() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("ditopn/aplp_det", { data: this.model })
            if (rtnmsg.retcod == SUCCESS) {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onAdvpDet() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("ditopn/advp_det", { data: this.model })
            if (rtnmsg.retcod == SUCCESS) {
                //TODO 处理数据逻辑

            }
            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", { data: this.model })
            if (rtnmsg.retcod == SUCCESS) {
                //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", { data: this.model })
            if (rtnmsg.retcod == SUCCESS) {
                //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", { data: this.model })
            if (rtnmsg.retcod == SUCCESS) {
                //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", { data: this.model })
            if (rtnmsg.retcod == SUCCESS) {
                //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", { data: this.model })
            if (rtnmsg.retcod == SUCCESS) {
                //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", { data: this.model })
            if (rtnmsg.retcod == SUCCESS) {
                //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", { data: this.model })
            if (rtnmsg.retcod == SUCCESS) {
                //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", { data: this.model })
            if (rtnmsg.retcod == SUCCESS) {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onAgepDet() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("ditopn/agep_det", { data: this.model })
            if (rtnmsg.retcod == SUCCESS) {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onYfbpDet() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("ditopn/yfbp_det", { data: this.model })
            if (rtnmsg.retcod == SUCCESS) {
                //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", { data: this.model })
            if (rtnmsg.retcod == SUCCESS) {
                //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", { data: this.model })
            if (rtnmsg.retcod == SUCCESS) {
                //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", { data: this.model })
            if (rtnmsg.retcod == SUCCESS) {
                //TODO 处理数据逻辑

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

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onLiaccvDel() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("ditopn/liaccv_del", { data: this.model })
            if (rtnmsg.retcod == SUCCESS) {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    async BlurBennam(e) {
        let rtnmsg = await Api.post("ditopn/executeDefault/litp1.remark", Utils.getRequestDataFn.call(this))
        if (rtnmsg.respCode == "AAAAAA") {
            //TODO 处理数据逻辑
            this.model.litp1.remark = rtnmsg.data.litp1_remark
        }
    },
    async BlurAplname(e) {
        let rtnmsg = await Api.post("ditopn/executeDefault/litp1.remark", Utils.getRequestDataFn.call(this))
        if (rtnmsg.respCode == "AAAAAA") {
            //TODO 处理数据逻辑
            this.model.litp1.remark = rtnmsg.data.litp1_remark
        }
    },
    async BlurSignam(e) {
        let rtnmsg = await Api.post("ditopn/executeDefault/litp1.remark", Utils.getRequestDataFn.call(this))
        if (rtnmsg.respCode == "AAAAAA") {
            //TODO 处理数据逻辑
            this.model.litp1.remark = rtnmsg.data.litp1_remark
        }
    },


    

    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 处理数据逻辑
            console.log("11111111111111111111111111111")
            this.title = row.pandsc
            this.centerDialogVisible = true,
                this.dialog = rtnmsg.data.trnmod_trndoc_doceot[index]
            this.index = index
        }
    },


}