import Api from "~/service/Api"
import Utils from "~/utils/index"
export default {
    async onDitpButgetref() {
        let rtnmsg = await this.executeRule("ditp.butgetref")
        if (rtnmsg.respCode == SUCCESS) {
            //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 this.executeRule("ditp.aplp.det")
        if (rtnmsg.respCode == SUCCESS) {
            //TODO 处理数据逻辑
            // console.log(rtnmsg.data);
        }
        else {
            this.$notify.error({ title: '错误', message: '服务请求失败！' });
        }
    },
    async onBenpDet() {
        let rtnmsg = await this.executeRule("benp_det")
        if (rtnmsg.respCode == SUCCESS) {
            //TODO 处理数据逻辑

        }
        else {
            this.$notify.error({ title: '错误', message: '服务请求失败！' });
        }
    },
    async onRevclauseButtxmsel() {
        let rtnmsg = await this.executeRule("revclause_buttxmsel")
        if (rtnmsg.respCode == SUCCESS) {
            //TODO 处理数据逻辑

        }
        else {
            this.$notify.error({ title: '错误', message: '服务请求失败！' });
        }
    },
    async onLcrgodButtxmsel() {
        let rtnmsg = await this.executeRule("lcrgod_buttxmsel")
        if (rtnmsg.respCode == SUCCESS) {
            //TODO 处理数据逻辑

        }
        else {
            this.$notify.error({ title: '错误', message: '服务请求失败！' });
        }
    },
    async onLcrdocButtxmsel() {
        let rtnmsg = await this.executeRule("lcrdoc_buttxmsel")
        if (rtnmsg.respCode == SUCCESS) {
            //TODO 处理数据逻辑

        }
        else {
            this.$notify.error({ title: '错误', message: '服务请求失败！' });
        }
    },
    async onAdlcndButtxmsel() {
        let rtnmsg = await this.executeRule("adlcnd_buttxmsel")
        if (rtnmsg.respCode == SUCCESS) {
            //TODO 处理数据逻辑

        }
        else {
            this.$notify.error({ title: '错误', message: '服务请求失败！' });
        }
    },
    async onInsbnkButtxmsel() {
        let rtnmsg = await this.executeRule("insbnk_buttxmsel")
        if (rtnmsg.respCode == SUCCESS) {
            //TODO 处理数据逻辑

        }
        else {
            this.$notify.error({ title: '错误', message: '服务请求失败！' });
        }
    },
    async onRmbpDet() {
        let rtnmsg = await this.executeRule("rmbp_det")
        if (rtnmsg.respCode == SUCCESS) {
            //TODO 处理数据逻辑

        }
        else {
            this.$notify.error({ title: '错误', message: '服务请求失败！' });
        }
    },
    async onDefdetButtxmsel() {
        let rtnmsg = await this.executeRule("defdet_buttxmsel")
        if (rtnmsg.respCode == SUCCESS) {
            //TODO 处理数据逻辑

        }
        else {
            this.$notify.error({ title: '错误', message: '服务请求失败！' });
        }
    },
    async onPreperButtxmsel() {
        let rtnmsg = await this.executeRule("preper_buttxmsel")
        if (rtnmsg.respCode == SUCCESS) {
            //TODO 处理数据逻辑

        }
        else {
            this.$notify.error({ title: '错误', message: '服务请求失败！' });
        }
    },
    async onSetmodDet() {
        let rtnmsg = await this.executeRule("setmod_det")
        if (rtnmsg.respCode == SUCCESS) {
            //TODO 处理数据逻辑

        }
        else {
            this.$notify.error({ title: '错误', message: '服务请求失败！' });
        }
    },
    async onLiaallButmisamt() {
        let rtnmsg = await this.executeRule("liaall_butmisamt")
        if (rtnmsg.respCode == SUCCESS) {
            //TODO 处理数据逻辑

        }
        else {
            this.$notify.error({ title: '错误', message: '服务请求失败！' });
        }
    },
    async onLiaallButmissig() {
        let rtnmsg = await this.executeRule("liaall_butmissig")
        if (rtnmsg.respCode == SUCCESS) {
            //TODO 处理数据逻辑

        }
        else {
            this.$notify.error({ title: '错误', message: '服务请求失败！' });
        }
    },
    async onWrkpDet() {
        let rtnmsg = await this.executeRule("wrkp_det")
        if (rtnmsg.respCode == SUCCESS) {
            //TODO 处理数据逻辑

        }
        else {
            this.$notify.error({ title: '错误', message: '服务请求失败！' });
        }
    },
    async onOthpDet() {
        let rtnmsg = await this.executeRule("othp_det")
        if (rtnmsg.respCode == SUCCESS) {
            //TODO 处理数据逻辑

        }
        else {
            this.$notify.error({ title: '错误', message: '服务请求失败！' });
        }
    },
    async onLimptsGet1() {
        let rtnmsg = await this.executeRule("limpts_get1")
        if (rtnmsg.respCode == SUCCESS) {
            //TODO 处理数据逻辑

        }
        else {
            this.$notify.error({ title: '错误', message: '服务请求失败！' });
        }
    },
    async onLimptsGet2() {
        let rtnmsg = await this.executeRule("limpts_get2")
        if (rtnmsg.respCode == SUCCESS) {
            //TODO 处理数据逻辑

        }
        else {
            this.$notify.error({ title: '错误', message: '服务请求失败！' });
        }
    },
    async onLimmodTrycal() {
        let rtnmsg = await this.executeRule("limmod_trycal")
        if (rtnmsg.respCode == SUCCESS) {
            //TODO 处理数据逻辑

        }
        else {
            this.$notify.error({ title: '错误', message: '服务请求失败！' });
        }
    },
    async onLiaccvAdd() {
        let rtnmsg = await this.executeRule("liaall.liaccv.add")
        //const that = this.root;
        if (rtnmsg.respCode == SUCCESS) {
            //TODO 处理数据逻辑
            debugger;
            this.stmData.data = rtnmsg.data.vals.rows;
            this.dialogTableVisible = true;
        }
        else {
            this.$notify.error({ title: '错误', message: '服务请求失败！' });
        }
    },
    async onLiaccvDel(index,row) {
        const idx = index+1;
        let rule = "liaall.liaccv.del";
        let params = {selDst:"liaall.liaccv.liaccvg",selIdx:idx};
        let rtnmsg = await this.executeRule(rule,params)
        if (rtnmsg.respCode == SUCCESS) {
            //TODO 处理数据逻辑
            debugger;
            this.$message({
                type: 'success',
                message: '删除成功！'
            });
            //this.model.liaall.liaccv.liaccvg = [];
            Utils.copyValueFromVO(this.model, rtnmsg.data);

        }
        else {
            this.$notify.error({ title: '错误', message: '服务请求失败！' });
        }
    },
    async onSeaParty(path) {
        let rtnmsg =  await this.executeRule(path) 
        if (rtnmsg.respCode == SUCCESS) {
            Utils.copyValueFromVO(this.model,rtnmsg.data);
        }

    },

    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', this.wrapper())
        } else {
            this.model.trnmod.trndoc.doccod = row.id
            this.model.trnmod.trndoc.cortyp = cortyp
            const params = {
                index: index
            }
            rtnmsg = await Api.post("ditopn/executeDocpan", this.wrapper(params))
        }
        if (rtnmsg.respCode == SUCCESS) {
            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", this.wrapper(params))
        if (rtnmsg.respCode == SUCCESS) {
            //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 this.executeDefault("ditp.remark")
        if (rtnmsg.respCode == SUCCESS) {
            //TODO 处理数据逻辑
            this.model.ditp.remark = rtnmsg.data.ditp_remark
        }
    },
    async BlurAplname(e) {
        let rtnmsg = await this.executeDefault("ditp.remark")
        if (rtnmsg.respCode == SUCCESS) {
            //TODO 处理数据逻辑
            this.model.ditp.remark = rtnmsg.data.ditp_remark
        }
    },
    async BlurSignam(e) {
        let rtnmsg = await this.executeDefault("ditp.remark")
        if (rtnmsg.respCode == SUCCESS) {
            //TODO 处理数据逻辑
            this.model.ditp.remark = rtnmsg.data.ditp_remark
        }
    },
    async onExtkey(e) {

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

}