// 此文件存放交易流转的一些公共方法
import Api from '~/service/Api';
import Utils from "~/utils"
import commonFunctions from '../mixin/commonFunctions.js';
import macBalance from '../mixin/macBalanceMixin.js';
import setmod from '~/components/business/setmod/event';
import ccvpan from '~/components/business/ccvpan/event';
import glentry from '~/components/business/glentry/event';
import engp from '~/components/business/engp/event';
import docpan from '~/components/business/docpan/event';
import limitbody from '~/components/business/limitbody/event';
import doctre from '~/components/business/doctre2/event';
import usrmd from '~/components/business/Usrmd/event';
import forexmod from '~/components/business/Forexmod/event';
import entmod from '~/components/business/entmod/event';
import rmbbop from '../components/business/rmb/rmbbop/event';
import jshmod from '../components/business/jshmod/event';
import cfagit from '~/components/business/Cfagit/event';
import cfabop from '~/components/business/cfa/cfabop/event';
import yapin from '~/components/business/yapin/event';
import dftcre from '~/components/business/dftcre/event';
import trtcre from '~/components/business/trtcre/event';
import bptbck from '~/components/business/bptbck/event';
import gedmod from '~/components/business/gedmod/event';
import bopgat from '~/components/business/Bopgat/event';
import boprem from '~/components/business/Boprem/event';
import boppay from '~/components/business/Boppay/event';
import invchkpan from '~/components/business/Invchkpan/event';
import PubCheckEvent from '../components/business/commonModel/CommonCheckEvent.js';
import {cloneDeep} from "lodash";

import pendingMixin from "./pendingMixin.js"

export default {
    mixins: [commonFunctions, pendingMixin, setmod,invchkpan, ccvpan, glentry, engp, docpan, limitbody,entmod, doctre, usrmd, forexmod,rmbbop, jshmod, cfagit, cfabop, bopgat, boprem, boppay, macBalance, yapin, dftcre, trtcre, bptbck, gedmod],
    methods: {
        //  初始化
        async init(data) {
            return new Promise(async (resolve) => {
                //清除缓存变量
                delete this.$store.state["infoEntrank"];
                delete this.$store.state["infoChkmsg"];
                let params = {
                    ...data,
                    businessInr: this.$route.query.businessInr,
                    businessType: this.$route.query.businessType,
                    operation: this.$route.query.type
                };
                if (this.$router.history.getCurrentLocation().indexOf("display") > -1) {
                    params.operation = "view"
                }
                this.$initParams = {
                    params,
                    //此参数为了退出时候取路由module
                    currentRouteModule: this.$route.meta.module || 'business'
                };
                this.$store.commit('setLoadingStash', true);
                const loading = this.loading();
                const rtnmsg = await Api.post(`/${this.moduleRouter()}/${this.trnName}/init`, params);
//异步关闭,避免关闭过快
                this.$nextTick(() => setTimeout(() => {
                    this.$store.commit('setLoadingStash', false);
                    loading.close()
                }, 1500));
                if (rtnmsg.respCode === SUCCESS) {
                    this._rtnmsg = rtnmsg;
                    //收单行上收标时,modifiedSet忽略
                    let ignoreModFlg = !this.isInDisplay && rtnmsg.data.trnInfo && rtnmsg.data.trnInfo.sptHldflg;
                    Utils.copyValueFromVoData(this.model, rtnmsg.data, ignoreModFlg);
                    if (this.model.setmod) {
                        Utils.copyValueFromVoData(this.model.setmod, rtnmsg.data, ignoreModFlg);
                        Utils.copyValueFromVoData(this.model.setmod, rtnmsg.data.setmod, ignoreModFlg);
                    }
                    if (this.model.mtabut) {
                        Utils.copyValueFromVoData(this.model.mtabut, rtnmsg.data, ignoreModFlg);
                    }
                    if (this.model.trnmod) {
                        Utils.copyValueFromVoData(this.model.trnmod, rtnmsg.data, ignoreModFlg)
                    }
                    if (this.model.liaall) {
                        Utils.copyValueFromVoData(this.model.liaall, rtnmsg.data, ignoreModFlg);
                        Utils.copyValueFromVoData(this.model.liaall, rtnmsg.data.liaall, ignoreModFlg);
                    }
                    if (this.model.liaccv) {
                        Utils.copyValueFromVoData(this.model.liaccv, rtnmsg.data, ignoreModFlg);
                        Utils.copyValueFromVoData(this.model.liaccv, rtnmsg.data.liaccv, ignoreModFlg);
                    }
                    if (this.model.docpan) {
                        Utils.copyValueFromVoData(this.model.docpan, rtnmsg.data, ignoreModFlg);
                    }
                    if (this.model.limmod) {
                        Utils.copyValueFromVoData(this.model.limmod, rtnmsg.data.limmod, ignoreModFlg);
                        //复核时候判断额度试算按钮亮灰显
                        if (this.isInDisplay) {
                            this.judgementAmeamt()
                        }
                    }
                    if (this.model.umdmod) {
                        Utils.copyValueFromVoData(this.model.umdmod, rtnmsg.data.umdmod, ignoreModFlg);
                    }
                    if (this.model.ypnmod) {
                        Utils.copyValueFromVoData(this.model.ypnmod, rtnmsg.data.ypnmod, ignoreModFlg);
                    }
                    if (this.model.trndia) {
                        Utils.copyValueFromVoData(this.model.trndia, rtnmsg.data, ignoreModFlg);
                        Utils.copyValueFromVoData(this.model.trndia, rtnmsg.data.trndia, ignoreModFlg);
                    }
                    if (this.model.rmbbop) {
                        Utils.copyValueFromVoData(this.model.rmbbop, rtnmsg.data.rmbbop, ignoreModFlg);
                    }
                    if (this.model.cfagit) {
                        Utils.copyValueFromVoData(this.model.cfagit, rtnmsg.data.cfagit, ignoreModFlg);
                    }
                    if (this.model.cfabop) {
                        Utils.copyValueFromVoData(this.model.cfabop, rtnmsg.data.cfabop, ignoreModFlg);
                    }
                    if (this.model.bopgat) {
                        Utils.copyValueFromVoData(this.model.bopgat, rtnmsg.data.bopgat, ignoreModFlg);
                    }
                    if (this.model.boprem) {
                        Utils.copyValueFromVoData(this.model.boprem, rtnmsg.data.boprem, ignoreModFlg);
                    }
                    if (this.model.boppay) {
                        Utils.copyValueFromVoData(this.model.boppay, rtnmsg.data.boppay, ignoreModFlg);
                    }
                    if (this.model.textTempData) {
                        this.model.textTempData = rtnmsg.data.textTempData || {}
                    }
                    if (this.model.textTempDatac) {
                        this.model.textTempDatac = rtnmsg.data.textTempDatac || {}
                    }
                    // 附件相关数据
                    if (rtnmsg.data.shwinc) {
                        this.$set(this.model, 'shwinc', ignoreModFlg ? [] : rtnmsg.data.shwinc || [])
                    }
                    // 附件相关数据
                    if (rtnmsg.data.shwout) {
                        this.$set(this.model, 'shwout', ignoreModFlg ? [] : rtnmsg.data.shwout || [])
                    }
                    //影像使用,针对model中位定义trnInfo的进行处理
                    if (!this.model.trnInfo) {
                        this.$set(this.model, "trnInfo", rtnmsg.data.trnInfo);
                    }
                    if ("gmgfVo" in this.model) {
                        //国贸公服
                        this.$set(this.model, "gmgfVo", rtnmsg.data.gmgfVo);
                    }
                    //更新表单号,避免重复提交
                    this.model.trnInfo.formNo = rtnmsg.data.trnInfo.formNo;

                    if (!this.model.spt) {
                        this.$set(this.model, "spt", rtnmsg.data.spt);
                    } else {
                        //修正某些交易spt节点没加添smhinr的问题
                        if (rtnmsg.data.spt && rtnmsg.data.spt.smhinr && !this.model.spt.smhinr) {
                            this.$set(this.model.spt, "smhinr", rtnmsg.data.spt.smhinr);
                        }
                        if (rtnmsg.data.spt) {
                            this.$set(this.model.spt, "inr", rtnmsg.data.spt.inr)
                        }
                    }
                    await resolve(rtnmsg.data);
                    await this.handleWarning(rtnmsg.data);
                    // 执行各交易中的default
                    await this.initDefault();
                    // 复核,快照交易去除校验
                    this.handleIsImportRules();
                    // console.log('this=========', this.model)
                    //异步关闭,避免关闭过快
                    this.$nextTick(() => setTimeout(() => {
                        this.$store.commit('setLoadingStash', false);
                        loading.close();
                    }, 1500));
                    //oit的提示
                    this.oitcheck();
                } else if (rtnmsg.respCode === '400001' || rtnmsg.respCode === '600000') {
                    //锁定失败和数据状态发生变化关闭页面
                    this.$store.commit('setLoadingStash', false);
                    loading.close();
                    this.$store.commit('delTagsArry', this.$route.path);
                    this.$router.back()
                } else if (rtnmsg.respCode === '500001') {
                    //非收单不可做交易提示信息
                    this.$store.commit('setLoadingStash', false);
                    loading.close();
                    const h = this.$createElement;
                    this.$confirm(h('div', [
                        h('p', rtnmsg.respMsg)
                    ]), '提示', {
                        confirmButtonText: '确定', //确认按钮的文字
                        showCancelButton: false,
                        type: 'warning'
                    }).then(() => {
                        this.$store.commit('delTagsArry', this.$route.path);
                        this.$router.back()
                    })
                }
            })
        },
        oitcheck() {
            let extkey = '';
            let objtyp = '';
            let path = '';

            if (this.model.gidgrp) {
                extkey = this.model.gidgrp.rec.ownref;
                objtyp = 'gid';
                path = 'gidgrp.rec.ownref'
            }
            if (this.model.nidgrp) {
                extkey = this.model.nidgrp.rec.ownref;
                objtyp = 'nid';
                path = 'nidgrp.rec.ownref'
            }
            this.ejectOitWarning(objtyp, extkey, path);
        },
        // 复核、快照交易去除初始化校验
        handleIsImportRules() {
            if (this.$route.path.startsWith("/review") || this.$route.path.startsWith("/display")) {
                this.$nextTick(() => {
                    this.$refs['modelForm'].clearValidate()
                })
            }
        },
        // 处理warning的问题
        handleWarning(rtnmsg) {
            this.$set(this.model, 'warnList', rtnmsg.warnList || []);
            this.$set(this.model, 'warnFlg', '')
        },
        // 点击提交时,先弹出warning弹框,点击弹框确定执行
        handleSureWarning() {
            this.submitCallback()
        },
        // 初始化default
        initDefault() {
            let trnName = (this.$sourceTrnName || this.trnName);
            trnName = trnName.replace(trnName.charAt(0), trnName.charAt(0).toUpperCase());
            let moduleDefault = null;
            try {
                moduleDefault = require(`~/page/${this.moduleRouter(true)}/${trnName}/model/default.js`);
            } catch (e) {
                console.log(`~/page/${this.moduleRouter(true)}/${trnName}/model/default.js` + '加载失败');
                return
            }
            let mothodsObj = {};
            if (moduleDefault.default && moduleDefault.default.methods) {
                mothodsObj = moduleDefault.default.methods;
            }
            let fnKeys = Object.keys(mothodsObj);
            fnKeys.map((item) => {
                mothodsObj[item].call(this)
            })
        },
        async getTemplateMap(gtxinr, objtyp) {
            return new Promise(async (resolve) => {
                let params = {
                    objinr: gtxinr,
                    objtyp: objtyp
                };
                let res = await Api.post("/manager/gtxUse/listGidTmplVar", params);
                if (res.respCode === SUCCESS) {
                    resolve(res.data)
                } else {
                    this.$notify.error({
                        title: "错误",
                        message: "服务请求失败!"
                    });
                }
            })
        },
        // 格式化保函模板
        formatTxtp(template, gtxinr, objtyp, fieldDataMap, code, type) {
            if (!template || !gtxinr) {
                return;
            }
            this.getTemplateMap(gtxinr, objtyp).then(async (tmpList) => {
                let templateMap = {
                    ...fieldDataMap
                };
                tmpList.map((item) => {
                    if (item.showflg !== 'Y') {
                        templateMap[item.cod] = item.path
                    }
                });
                let params = {
                    vo: {
                        ...this.model,
                        transName: this.trnName,
                        spt: {
                            inr: this.$route.query.businessInr,
                        },
                        liaccvg: this.model.liaccv === undefined ? null : this.model.liaccv.liaccvg,
                        liaccv: this.model.liaccv === undefined ? null : this.model.liaccv,
                        liaallg: this.model.liaall === undefined ? null : this.model.liaall.liaallg,
                        liaall: this.model.liaall === undefined ? null : this.model.liaall,
                        setmod: this.model.setmod === undefined ? null : this.model.setmod,
                        setfog: this.model.setmod === undefined ? null : this.model.setmod.setfog,
                        setfeg: this.model.setmod === undefined ? null : this.model.setmod.setfeg,
                        setglg: this.model.setmod === undefined ? null : this.model.setmod.setglg,
                        doceot: this.model.docpan === undefined ? null : this.model.docpan.doceot,
                        limmod: this.model.limmod === undefined ? null : this.model.limmod,
                        ypnmod: this.model.ypnmod === undefined ? null : this.model.ypnmod,
                    },
                    template: template,
                    fieldMap: templateMap,
                };
                const rtnmsg = await Api.post(`/${this.moduleRouter()}/${this.trnName}/showText`, params);
                if (rtnmsg.respCode === SUCCESS) {
                    if (type === 'gtxinrmw') {
                        this.model[code].blk.gidtxtmw = rtnmsg.data;
                    } else if (type === 'fdb') {
                        this.model.nitp.indirectswiadd = rtnmsg.data;
                        if (!this.model.nidgrp.blk.modifySet || !this.model.nidgrp.blk.modifySet.includes("gidtxt")) {
                            let str = this.model.nitp.indirectswiadd + this.model.nidgrp.blk.gidtxt;
                            this.model.nidgrp.blk.gidtxt = str
                        }
                        //		优化反担保协议保函标题从居中放置保函初始
                        //		this.model.nitp.indirectswiadd = rtnmsg.data
                        //		if(!this.model.nidgrp.blk.modifySet || !this.model.nidgrp.blk.modifySet.includes("gidtxt")){
                        // 处理存在反担保协议的保函文本
                        //			if(this.model.nitp.indirectswiadd && (this.model.nidgrp.rec.giduil && this.model.nidgrp.rec.giduil !='CN')){
                        //				let gtxgidtxt = this.model.nidgrp.blk.gtxgidtxt
                        //				let blkgidtxt = this.model.nidgrp.blk.gidtxt
                        //				let title
                        //				let linkdata
                        //           if(gtxgidtxt && gtxgidtxt.includes('{LETTERNAME}') && blkgidtxt.length > 4){
                        //						title = blkgidtxt.substring(0, blkgidtxt.indexOf("</p>") + 4);
                        //						linkdata = blkgidtxt.substring(blkgidtxt.indexOf("</p>") + 4, blkgidtxt.length);
                        //						this.model.nidgrp.blk.gidtxt = title + this.model.nitp.indirectswiadd + linkdata
                        //					 }else{
                        //						let str = this.model.nitp.indirectswiadd + this.model.nidgrp.blk.gidtxt
                        //						this.model.nidgrp.blk.gidtxt = str
                        //					 }
                        //			}
                        //		}
                    } else if (type === 'dz'){
                        if (!this.model.nidgrp.blk.modifySet || !this.model.nidgrp.blk.modifySet.includes("gidtxt")) {
                            let str = this.model.nidgrp.blk.gidtxt + rtnmsg.data;
                            this.model.nidgrp.blk.gidtxt = str
                        }
                    }else if (type === true) {
                        this.model[code].blk.gidtxtc = rtnmsg.data
                    } else {
                        this.model[code].blk.gidtxt = rtnmsg.data
                    }
                }
            })
        },
        getHistory(params) {
            return new Promise(async (resolve) => {
                const rtnmsg = await Api.post(`/public/quesel/getAllOreList`, params);
                if (rtnmsg.respCode === SUCCESS) {
                    this.historyRemark = rtnmsg.data;
                    resolve(rtnmsg.data)
                }
            })
        },
        async tabClick(tab, isChecking) {
            const rmbbopTabs = ['rmb', 'ads2101', 'ads2103', 'ads2106', 'ads2107', 'ads2108', 'ads2111', 'ads2112', 'ads2122', 'ads2123'];
            const cfabopTabs = ['cfacomp', 'cfaeca', 'cfaead', 'cfaeaf'];
            const jshmodTabs = ['jsh', 'basp', 'vrfp'];
            if (rmbbopTabs.includes(tab.name)) {
                this.$refs.rmbbop.activeName = tab.name;
                this.tabVal = 'rmbbop';
            } else if (cfabopTabs.includes(tab.name)) {
                this.$refs.cfabop.activeName = tab.name;
                this.tabVal = 'cfabop';
            } else if (jshmodTabs.includes(tab.name)) {
                this.$refs.jshmod.activeName = tab.name;
                this.tabVal = 'jshmod';
            } else {
                this.tabVal = tab.name;
            }
            if (tab.name === 'liacombo' && (this.model.limmod.buildParams == undefined || this.model.limmod.buildParams == null)) {
                //解决额度只check不手动点击页签不走交易初始化common问题
                this.model.limmod.buildParams = this.buildCommonData(this.model, this.trnName);
            }
            //如果是检核报错触发的tabclick 不走后端试算逻辑 (统一名单由于没有试算 需要触发tabclick)
            if (isChecking && isChecking === '1' && tab.name !== 'usrmd' && tab.name !== 'bptbck') {
                if (tab.name === 'setpan') {
                    //触发业务信息赋值逻辑
                    let params = this.buildCommonData(this.model, this.trnName);
                    this.getSetmodCodeTable(params);
                }
                return;
            }
            if (this.isInDisplay) {
                return
            }
            let name = tab.name;
            switch (name) {
                case 'trtcre':
                    this.executeAfterKey("trtcre", tab.$parent);
                    break;
                case 'dftcre':
                    this.executeAfterKey("dftcre", tab.$parent);
                    break;
                case 'ccvpan':
                    this.executeAfterKey("liaccv", tab.$parent);
                    // let buildCcvpan = this.buildCommonData(this.model, this.trnName);
                    // this.initCcvpan(buildCcvpan);
                    break;
                case 'engp':
                    this.executeAfterKey("liaall", tab.$parent);
                    // let buildEngp = this.buildCommonData(this.model, this.trnName);
                    // this.initEngp(buildEngp);
                    break;
                case 'liauni':
                    this.executeAfterKey("liaccv", tab.$parent);
                    // let buildEngp = this.buildCommonData(this.model, this.trnName);
                    // this.initEngp(buildEngp);
                    break;
                case 'setpan':
                    this.executeAfterKey("setglg", tab.$parent);
                    // let buildSetmod = this.buildCommonData(this.model, this.trnName);
                    // this.initSetmod(buildSetmod);
                    break;
                case 'docpan':
                    this.executeAfterKey(name, tab.$parent);
                    // let buildDocpan = this.buildCommonData(this.model, this.trnName);
                    // this.initDocpan(buildDocpan);
                    break;
                case 'msdetail':
                    this.executeAfterKey("docpan", tab.$parent);
                    break;
                case 'glepan':
                    this.executeAfterKey(name, tab.$parent);
                    // let buildGlepan = this.buildCommonData(this.model, this.trnName);
                    // this.initGlepan(buildGlepan);
										break;
								//发票切换页签初始化
								case 'invchkpan':
										this.model.imgInvmod.pageTable.tableData =this.paginate(this.model.imgInvmod.pageTable.currentPage,this.model.imgInvmod.pageTable.pageSize);
										break
								case 'limitbody':
                    this.executeAfterKey(name, tab.$parent);
                    // let buildLimitbody = this.buildCommonData(this.model, this.trnName);
                    // this.initLimitbody(buildLimitbody);
                    break;
                case 'liacombo':
                    this.executeAfterKey("limitbody", tab.$parent);
                    break;
                case 'doctre':
                    let buildDoctre = this.buildCommonData(this.model, this.trnName);
                    this.initDoctre(buildDoctre);
                    break;
                case 'regulat':
										this.isEntmodDisplay()
                    this.executeAfterKey('forexmod', tab.$parent);
                    // let buildUsrmd = this.buildCommonData(this.model, this.trnName);
                    // this.initUsrmd(buildUsrmd);
                    break;
                // 人民币报送开立和修改
                case 'rmbbop':
                    this.executeAfterKey(name, tab.$parent);
                    break;
                case 'ads2106':
                    this.initRmbbop(this.buildCommonData(this.model, this.trnName));
                    break;
                case 'jshmod':
                    this.executeAfterKey(name, tab.$parent);
                    break;
                // 人民币报送赔付
                case 'rmbbopPf':
                    let buildRmbbopPf = this.buildCommonData(this.model, this.trnName);
                    let transNamePf = buildRmbbopPf.transName;
                    //	let rmbflg2111 = this.model.rmbbop.rmbbop2111Vo.rmbflg
                    this.executeAfterKey(name, tab.$parent);
                    let rmbflg2123 = this.model.rmbbop.rmbbop2123Vo.rmbflg;
                    if (rmbflg2123 === '1') {
                        if (transNamePf.startsWith('g')) {
                            this.init2123gcd(buildRmbbopPf)
                        } else {
                            this.init2123ncd(buildRmbbopPf)
                        }
                    }
                    break;
                // 人民币报送收回
                case 'rmbbopSh':
                    let buildRmbbopSh = this.buildCommonData(this.model, this.trnName);
                    let transNameSh = buildRmbbopSh.transName;
                    //let rmbflg2101Sh = this.model.rmbbop.rmb2101.rmbflg
                    this.executeAfterKey(name, tab.$parent);
                    let rmbflg2112Sh = this.model.rmbbop.rmb2112.rmbflg;
                    if (rmbflg2112Sh === '1') {
                        if (transNameSh.startsWith('g')) {
                            this.init2112gid(buildRmbbopSh)
                        } else {
                            this.init2112nid(buildRmbbopSh)
                        }
                    }
                    let rmbflg2123Sh = this.model.rmbbop.rmbbop2123Vo.rmbflg;
                    if (rmbflg2123Sh === '1') {
                        if (transNameSh.startsWith('g')) {
                            this.init2123gcd(buildRmbbopSh)
                        } else {
                            this.init2123ncd(buildRmbbopSh)
                        }
                    }
                    break;
                case 'cfagit':
                    let buildCfaggi = this.buildCommonData(this.model, this.trnName);
                    this.initCfa(buildCfaggi);
                    break;
                //资本项目报送
                case 'cfabop':
                    this.executeAfterKey(name, tab.$parent);
                    break;
                case 'bopgat':
                    this.executeAfterKey(name, tab.$parent);
                    break;
                case 'boprem':
                    this.executeAfterKey(name, tab.$parent);
                    break;
                case 'boppay':
                    this.executeAfterKey(name, tab.$parent);
                    break;
                case 'yapin':
                    let buildYapin = this.buildCommonData(this.model, this.trnName);
                    this.initYapin(buildYapin);
                    break;
                case 'bptbck':
                    let buildBptbck = this.buildCommonData(this.model, this.trnName);
                    this.initBptbck(buildBptbck);
                    break;
                case 'gedmod':
                    this.initGedmod();
                    break;
                default:
                    return;
            }
        },

        // 提交
        async handleSubmit() {
            if (this.validateSptInr()) {
                return;
            }
            let curWarnList = this.model.warnList;
            // 判断是否存在未读二级warning
            let isHasNoRead = false;
            if (curWarnList && curWarnList.length > 0) {
                isHasNoRead = curWarnList.some((item) => {
                    return item.level === '2' && item.readFlag === 'N'
                })
            }
            if (isHasNoRead) {
                this.$store.commit('updateWarningVisible', true);
                return;
            }
            // 判断是否存在level为1的warning
            let isHasLevel1 = false;
            if (curWarnList && curWarnList.length > 0) {
                isHasLevel1 = curWarnList.some((item) => {
                    return item.level === '1'
                })
            }
            if (isHasLevel1) {
                this.$store.commit('updateWarningVisible', true);
                return;
            }
            await this.submitCallback()
        },
        async submitCallback() {
            // 前端检验
            this.$refs['modelForm'].clearValidate();
            this.$refs['modelForm'].validate(async (validStatic) => {
                if (validStatic) {
                    // 备案表核验
                    if (this.txfmodpCheckFn && typeof this.txfmodpCheckFn == 'function') {
                        let txfmodp = await this.txfmodpCheckFn();
                        if (txfmodp && txfmodp == '1') {
                            return;
                        }
                    }
                    // 额度等校验
                    let commonRule = this.commonComponentCheckCallBack();
                    if (commonRule && commonRule.isOk) {
                        return
                    }
                    let params = {
                        ...this.model,
                        transName: this.trnName,
                        spt: {
                            inr: this.$route.query.businessInr,
                        },
                        liaccvg: this.model.liaccv === undefined ? null : this.model.liaccv.liaccvg,
                        liaccv: this.model.liaccv === undefined ? null : this.model.liaccv,
                        liaallg: this.model.liaall === undefined ? null : this.model.liaall.liaallg,
                        liaall: this.model.liaall === undefined ? null : this.model.liaall,
                        setmod: this.model.setmod === undefined ? null : this.model.setmod,
                        setfog: this.model.setmod === undefined ? null : this.model.setmod.setfog,
                        setfeg: this.model.setmod === undefined ? null : this.model.setmod.setfeg,
                        setglg: this.model.setmod === undefined ? null : this.model.setmod.setglg,
                        doceot: this.model.docpan === undefined ? null : this.model.docpan.doceot,
                        limmod: this.model.limmod === undefined ? null : this.model.limmod,
                        trndia: this.model.trndia === undefined ? null : this.model.trndia,
                        dias: this.model.trndia === undefined ? null : this.model.trndia.dias,
                        remark: this.model.remark === undefined ? null : this.model.remark,
                        umdmod: this.model.umdmod === undefined ? null : this.model.umdmod,
                        ypnmod: this.model.ypnmod === undefined ? null : this.model.ypnmod,
                    };
                    params = this.simplifyRequest(params);
                    const loading = this.loading();
                    this.$store.commit('setLoadingSubmit', true);
                    const rtnmsg = await Api.post(`/${this.moduleRouter()}/${this.trnName}/save`, params);
                    if (rtnmsg.respCode === SUCCESS) {
                        this.checkCallback(rtnmsg.data, true).then(() => {
                            this.$notify({
                                title: '成功',
                                message: '提交成功',
                                type: 'success',
                            });
                            this.$nextTick(() => {
                                this.$store.commit('delTagsArry', this.$route.path);
                                this.$router.back()
                            })
                        }).catch(() => {

                            Utils.copyValueFromVoData(this.model, rtnmsg.data);
                            if (this.model.setmod) {
                                Utils.copyValueFromVoData(this.model.setmod, rtnmsg.data);
                                Utils.copyValueFromVoData(this.model.setmod, rtnmsg.data.setmod);
                            }
                            if (this.model.mtabut) {
                                Utils.copyValueFromVoData(this.model.mtabut, rtnmsg.data);
                            }
                            if (this.model.trnmod) {
                                Utils.copyValueFromVoData(this.model.trnmod, rtnmsg.data);
                                this.model.trnmod.doctreTableData1 = [];
                                this.model.trnmod.doctreTableData2 = rtnmsg.data.modifySet || []
                            }
                            if (this.model.liaall) {
                                Utils.copyValueFromVoData(this.model.liaall, rtnmsg.data);
                                Utils.copyValueFromVoData(this.model.liaall, rtnmsg.data.liaall);
                            }
                            if (this.model.liaccv) {
                                Utils.copyValueFromVoData(this.model.liaccv, rtnmsg.data);
                                Utils.copyValueFromVoData(this.model.liaccv, rtnmsg.data.liaccv);
                            }
                            if (this.model.docpan) {
                                Utils.copyValueFromVoData(this.model.docpan, rtnmsg.data);
                            }
                            if (this.model.limmod) {
                                if (this.trnName === 'GITZSQ' || this.trnName === 'NITZSQ') {
                                    //do nothing
                                } else {
                                    Utils.copyValueFromVoData(this.model.limmod, rtnmsg.data.limmod);
                                }
                            }
                            if (this.model.trndia) {
                                Utils.copyValueFromVoData(this.model.trndia, rtnmsg.data);
                                Utils.copyValueFromVoData(this.model.trndia, rtnmsg.data.trndia);
                            }
                            // 如果返回了统一名单,则将统一名单更新
                            if (this.model.umdmod && rtnmsg.data && rtnmsg.data.umdmod) {
                                Utils.copyValueFromVoData(this.model.umdmod, rtnmsg.data.umdmod);
                            }

                            let errorMap = rtnmsg.data.errorMap;
                            // 后端校验未通过时,返回的errorMap
                            let errorRules = {};
                            if (errorMap && errorMap.ruleMap) {
                                errorRules = errorMap.ruleMap
                            }
                            this.$nextTick(() => {
                                this.showBackendErrors2(errorRules)
                            })
                        })
                    } else {
                        this.$notify({
                            title: "错误",
                            message: rtnmsg.respMsg,
                            type: "error",
                        });
                    }
                    loading.close();
                    this.$store.commit('setLoadingSubmit', false)
                } else {
                    // 前端校验失败
                    this.$notify({
                        title: '失败',
                        message: '校验失败',
                        type: 'error',
                    });
                    this.showFrontendErrors()
                }
            })
        },
        // 检核
        async handleCheck() {
            // 前端检验
            this.$refs['modelForm'].clearValidate();
            this.$refs['modelForm'].validate(async (validStatic) => {
                if (validStatic) {
                    // 备案表核验
                    if (this.txfmodpCheckFn && typeof this.txfmodpCheckFn == 'function') {
                        let txfmodp = await this.txfmodpCheckFn();
                        if (txfmodp && txfmodp == '1') {
                            return;
                        }
                    }
                    // 额度等校验
                    let commonRule = this.commonComponentCheckCallBack();
                    if (commonRule && commonRule.isOk) {
                        return
                    }
                    const loading = this.loading('正在校验数据');
                    this.$store.commit('setLoadingCheck', true);
                    let params = {
                        ...this.model,
                        transName: this.trnName,
                        liaccvg: this.model.liaccv === undefined ? null : this.model.liaccv.liaccvg,
                        liaccv: this.model.liaccv === undefined ? null : this.model.liaccv,
                        liaallg: this.model.liaall === undefined ? null : this.model.liaall.liaallg,
                        liaall: this.model.liaall === undefined ? null : this.model.liaall,
                        setmod: this.model.setmod === undefined ? null : this.model.setmod,
                        setfog: this.model.setmod === undefined ? null : this.model.setmod.setfog,
                        setfeg: this.model.setmod === undefined ? null : this.model.setmod.setfeg,
                        setglg: this.model.setmod === undefined ? null : this.model.setmod.setglg,
                        doceot: this.model.docpan === undefined ? null : this.model.docpan.doceot,
                        limmod: this.model.limmod === undefined ? null : this.model.limmod,
                        trndia: this.model.trndia === undefined ? null : this.model.trndia,
                        dias: this.model.trndia === undefined ? null : this.model.trndia.dias,
                        umdmod: this.model.umdmod === undefined ? null : this.model.umdmod,
                        ypnmod: this.model.ypnmod === undefined ? null : this.model.ypnmod,
                    };
                    params = this.simplifyRequest(params);
                    const rtnmsg = await Api.post(`/${this.moduleRouter()}/${this.trnName}/checkAll`, params);
                    if (rtnmsg.respCode === SUCCESS) {
                        Utils.copyValueFromVoData(this.model, rtnmsg.data);
                        if (this.model.setmod) {
                            Utils.copyValueFromVoData(this.model.setmod, rtnmsg.data);
                            Utils.copyValueFromVoData(this.model.setmod, rtnmsg.data.setmod);
                        }
                        if (this.model.mtabut) {
                            Utils.copyValueFromVoData(this.model.mtabut, rtnmsg.data);
                        }
                        if (this.model.trnmod) {
                            Utils.copyValueFromVoData(this.model.trnmod, rtnmsg.data);
                            this.model.trnmod.doctreTableData1 = [];
                            this.model.trnmod.doctreTableData2 = rtnmsg.data.modifySet || []
                        }
                        if (this.model.liaall) {
                            Utils.copyValueFromVoData(this.model.liaall, rtnmsg.data);
                            Utils.copyValueFromVoData(this.model.liaall, rtnmsg.data.liaall);
                        }
                        if (this.model.liaccv) {
                            Utils.copyValueFromVoData(this.model.liaccv, rtnmsg.data);
                            Utils.copyValueFromVoData(this.model.liaccv, rtnmsg.data.liaccv);
                        }
                        if (this.model.docpan) {
                            Utils.copyValueFromVoData(this.model.docpan, rtnmsg.data);
                        }
                        if (this.model.limmod) {
                            if (this.trnName === 'GITZSQ' || this.trnName === 'NITZSQ') {
                                //do nothing
                            } else {
                                Utils.copyValueFromVoData(this.model.limmod, rtnmsg.data.limmod);
                            }
                        }
                        if (this.model.trndia) {
                            Utils.copyValueFromVoData(this.model.trndia, rtnmsg.data);
                            Utils.copyValueFromVoData(this.model.trndia, rtnmsg.data.trndia);
                        }
                        // 如果返回了统一名单,则将统一名单更新
                        if (this.model.umdmod && rtnmsg.data && rtnmsg.data.umdmod) {
                            Utils.copyValueFromVoData(this.model.umdmod, rtnmsg.data.umdmod);
                        }
                        this.$nextTick(
                            () => this.checkCallback(rtnmsg.data).then(async () => {
                                await this.recalcLimitBody();
                            })
                        )
                    }
                    loading.close();
                    this.$store.commit('setLoadingCheck', false)
                } else {
                    // 前端校验失败
                    this.$notify({
                        title: '失败',
                        message: '校验失败',
                        type: 'error',
                    });
                    this.showFrontendErrors()
                }
            })
				},
				isEntmodDisplay(){
					if (this.model.entmod){
						this.model.entmod.visflg = '';
						let trnName = this.trnName;
						if ("-CPTOPN-CPTATO-".includes(trnName.toUpperCase())) {
							if (this.model.cpdgrp.rec.trntyp === '01') {
								this.model.entmod.visflg = 'X';
							}
						}
						if ("-CPTREP-CPTADV-CPTATI-".includes(trnName.toUpperCase())) {
							if (this.model.cpdgrp.rec.trntyp === '01' && this.model.cpdgrp.rec.accmod != '2') {
								this.model.entmod.visflg = 'X';
							}
						}
						if ("-BOTDAV1-BCTDAV1-BOTSET-BCTSET1-BETSET-TRTOPN-BCTACC1-LETOPN-LETRSV1-LETDRW1-LTTOPN1-LTTAME1-BTTSET-".includes(trnName.toUpperCase())) {
							this.model.entmod.visflg = 'X';
						}
						if ("-BRTUDP1-BRTSET1-LITOPN1-".includes(trnName.toUpperCase())) {
							if (this.model.lidgrp.rec.dkflg === 'X') {
								let extkey = this.model.lidgrp.apo.pts.extkey;
								if (extkey.startsWith('9999') || extkey.startsWith('Temp')) {
									this.model.entmod.visflg = '';
								} else {
									this.model.entmod.visflg = 'X';
								}
							} else {
								this.model.entmod.visflg = 'X';
							}
						}
						if (trnName === 'bptopn') {
								if ("-I-P-D-".includes(this.model.bpdgrp.rec.fintyp)) {
									this.model.entmod.visflg = 'X';
								}
								if ("-F-U-".includes(this.model.bpdgrp.rec.fintyp) && this.model.bpdgrp.rec.fortyp === '1') {
									this.model.entmod.visflg = 'X';
								}
						}
						if (trnName === 'litame' || trnName === 'litame1') {
							if (this.model.lidgrp.rec.dkflg === 'X') {
								let extkey = this.model.lidgrp.apo.pts.extkey;
								if (extkey.startsWith('9999') || extkey.startsWith('Temp')) {
										this.model.entmod.visflg = '';
								} else {
										this.model.entmod.visflg = 'X';
								}
							} else {
								this.model.entmod.visflg = 'X';
							}
						}
						if (trnName === 'jstopn' || trnName === 'jstopt') {
							if (this.model.jsdgrp.rec.maimpz === '4' && this.model.verifyFlag === 'X') {
								this.model.entmod.visflg = 'X';
							}
						}
						if (this.model.entmod.visflg === '') {
							this.model.entmod.isShowErrorMsg = false;
						}
					}
				},
        showBackendErrors2(errorRules) {
            let keysList = Object.keys(errorRules);
            if (!keysList.length) {
                return
            }
            const tab = this.showBackendErrors(errorRules);
            if (tab) {
                // 判断校验失败的表单不属于当前的tab,则切换tab到对应报错的tab页面
                if (tab.name !== this.tabVal) {
                    this.tabClick(tab, '1');
                }
            }

            let errorRuleList = [];
            keysList.map((item) => {
                let idx = this.$refs.modelForm.fields.findIndex(field => {
                    return field.prop === item
                });
                if (idx < 0 && item != 'entmod.rtyflg') {
                    errorRuleList.push({
                        msg: `${item}:${errorRules[item]}`
                    })
                }
                // if (this.rules[item] === undefined || this.rules[item] === null) {

                // }
            });
            if (errorRuleList.length > 0) {
                this.$store.commit('updateErrorRuleVisible', true);
                this.$store.commit('updateErrorRuleList', errorRuleList)

            }
        },
        // 校验回调
        checkCallback(rtnmsg, isSubmit) {
            this.handleWarning(rtnmsg);
            return new Promise((resolve, reject) => {
                let errorMap = rtnmsg.errorMap;
                let errorList = [];
                if (errorMap && errorMap.errorList) {
                    errorList = errorMap.errorList
                }
                let shouldRej = false;
                // 判断是否弹出error
                if (errorList && errorList.length > 0) {
                    let errorMsg = '<div>';
                    errorList.map((errorItem) => {
                        errorMsg += `<div>${errorItem.message}</div>`
                    });
                    errorMsg += '</div>';

                    this.$notify({
                        title: "提示",
                        dangerouslyUseHTMLString: true,
                        message: errorMsg,
                        type: "warning",
                    });
                    shouldRej = true
                }
                // 后端校验未通过时,返回的errorMap
                let errorRules = {};
                if (errorMap && errorMap.ruleMap) {
                    errorRules = errorMap.ruleMap
                }
                let keysList = Object.keys(errorRules);
                // 如果后端返回的对象为空,则后端校验成功
                if (!shouldRej && !keysList.length) {
                    // 清除之前的校验状态
                    this.$refs['modelForm'].clearValidate();
                    if (!isSubmit) {
                        this.$notify({
                            title: "成功",
                            message: "校验成功",
                            type: "success",
                        });
                    }
                } else {
                    if (!isSubmit || isSubmit === -1) {
                        this.showBackendErrors2(errorRules)
                    }
                    shouldRej = true
                }
                // warning有变化时
                if (errorMap && errorMap.warningListChange && errorMap.warningListChange === 'Y') {
                    // this.$alert('警告信息有变化,请查看', 'warning', {
                    //     confirmButtonText: '我知道了',
                    //     callback: action => {
                    //     }
                    // });
                    this.$set(this.model, 'warnFlg', 'Y');
                    shouldRej = true
                } else {
                    this.$set(this.model, 'warnFlg', '')
                }
                if (shouldRej) {
                    reject("校验失败");
                } else {
                    resolve()
                }
            })
        },
        // 公共组件的一些校验事件
        commonComponentCheckCallBack() {
            let commonFn = PubCheckEvent;
            let commonFnList = Object.keys(commonFn);
            let resFn = null;
            for (let i = 0; i < commonFnList.length; i++) {
                resFn = commonFn[commonFnList[i]].call(this);
                if (resFn && resFn.isOk) {
                    break;
                }
            }
            if (resFn && resFn.isOk) {
                let fields = this.$refs['modelForm'].fields;
                for (let i = 0; i < fields.length; i++) {
                    let parentVC = fields[i];
                    let firstErrorTab = null;
                    // while循环找出哪个tab和Collapse中报出的校验失败
                    while (!firstErrorTab) {
                        const vcName = parentVC.$options.name;
                        if (vcName === "ElTabPane") {
                            firstErrorTab = parentVC;
                            break;
                        }
                        parentVC = parentVC.$parent;
                    }
                    if (firstErrorTab.name === resFn.name) {
                        const tabs = firstErrorTab.$parent;
                        tabs.currentName = firstErrorTab.name;
                        this.tabClick(firstErrorTab);
                        break;
                    }
                }
            }
            return resFn
        },
        // 前端校验失败时候,tab和Collapse组件效果处理
        showFrontendErrors() {
            this.$nextTick(() => {
                let fields = this.$refs['modelForm'].fields;
                let parentVC = null;
                for (let i = 0; i < fields.length; i++) {
                    let fieldItem = fields[i];
                    if (fieldItem.validateState === 'error') {
                        parentVC = fieldItem;
                        break;
                    }
                }
                let firstErrorTab = null;
                let collapsePanel = null;
                // while循环找出哪个tab和Collapse中报出的校验失败
                while (true) {
                    const vcName = parentVC.$options.componentName;
                    // 没有Tabs的表单
                    if (vcName === "ElForm") {
                        break;
                    }
                    if (vcName === "ElTabPane") {
                        firstErrorTab = parentVC;
                        break;
                    }
                    if (vcName === "ElCollapseItem") {
                        collapsePanel = parentVC;
                    }
                    parentVC = parentVC.$parent;
                }
                if (firstErrorTab && firstErrorTab.name !== this.tabVal) {
                    const tabs = firstErrorTab.$parent;
                    tabs.currentName = firstErrorTab.name;
                    this.tabClick(firstErrorTab);
                }
                if (collapsePanel && collapsePanel.collapse.activeNames.indexOf(collapsePanel.name) < 0) {
                    collapsePanel.collapse.activeNames.push(collapsePanel.name)
                }
                setTimeout(() => {
                    let isError = document.querySelectorAll('.is-error');
                    isError[0].scrollIntoView({
                        block: 'center',
                        behavior: 'smooth'
                    })
                }, 0);
            })
        },
        // 后端校验
        showBackendErrors(fieldErrors) {
            // 清除之前的校验状态
            if (!this.$refs.modelForm) {
                return
            }
            const fields = this.$refs.modelForm.fields;
            console.log('backFileds', fields);
            return Utils.positioningErrorMsg(fieldErrors, fields);
        },
        // 暂存
        async handleStash() {
            if (this.validateSptInr()) {
                this.$store.commit('setLoadingStash', false);
                return;
            }
            const loading = this.loading('正在暂存数据');
            let params = {
                ...this.model,
                transName: this.trnName.toUpperCase(),
                liaccvg: this.model.liaccv === undefined ? null : this.model.liaccv.liaccvg,
                liaccv: this.model.liaccv === undefined ? null : this.model.liaccv,
                liaallg: this.model.liaall === undefined ? null : this.model.liaall.liaallg,
                liaall: this.model.liaall === undefined ? null : this.model.liaall,
                setmod: this.model.setmod === undefined ? null : this.model.setmod,
                setfog: this.model.setmod === undefined ? null : this.model.setmod.setfog,
                setfeg: this.model.setmod === undefined ? null : this.model.setmod.setfeg,
                setglg: this.model.setmod === undefined ? null : this.model.setmod.setglg,
                doceot: this.model.docpan === undefined ? null : this.model.docpan.doceot,
                limmod: this.model.limmod === undefined ? null : this.model.limmod,
                trndia: this.model.trndia === undefined ? null : this.model.trndia,
                dias: this.model.trndia === undefined ? null : this.model.trndia.dias,
                remark: this.model.remark === undefined ? null : this.model.remark,
                umdmod: this.model.umdmod === undefined ? null : this.model.umdmod,
                ypnmod: this.model.ypnmod === undefined ? null : this.model.ypnmod,
                spt: {
                    inr: this.$route.query.businessInr,
                },
            };
            if (params.umdmod && params.umdmod.buildParams) {
                delete params.umdmod.buildParams;
            }
            params = this.simplifyRequest(params);
            const res = await Api.post(`/${this.moduleRouter()}/${this.trnName}/txnHold`, params);
            if (res.respCode === SUCCESS) {
                this.$notify({
                    title: '成功',
                    message: '暂存成功',
                    type: 'success',
                });
                this.$store.commit('delTagsArry', this.$route.path);
                this.$router.back()
            }
            loading.close();
            this.$store.commit('setLoadingStash', false)
        },
        // 复核
        async handlePass(params) {
            const loading = this.loading();
            if (this.$store.state["infoEntrank"]) {
                params.infoEntrank = true;
            }
            if (this.$store.state["infoChkmsg"]) {
                params.infoChkmsg = true;
            }
            if (this.$store.state["confirm0958"]) {
                params.confirm0958 = true;
            }
            if (this.$store.state["confirmMainRw02"]) {
                params.confirmMainRw02 = true;
            }
            if (this.$store.state["confirmOthRw02"]) {
                params.confirmOthRw02 = true;
            }
            if (this.$store.state["confirmFinwar"]) {
                params.confirmFinwar = true;
            }
            if (this.$store.state["confirmBuyXrt"]) {
                params.confirmBuyXrt = true;
            }
            if (this.$store.state["confirmSellXrt"]) {
                params.confirmSellXrt = true;
            }
            const res = await Api.post(`/public/trnrel/relrow`, params);
            if (res.respCode === SUCCESS) {
                this.$notify({title: '成功', message: res.respMsg, type: 'success',});
                this.$store.commit('delTagsArry', this.$route.path);
                this.$router.back();
                this.clearResp();
            } else if (res.respCode.includes("confirm")) {
                let confirmMsg2 = res.data && res.data.confirmMsg ? res.data.confirmMsg : [];
                this.alertConfirm(confirmMsg2, params, res.respMsg, res.respCode);
            } else if (res.respCode.includes("info")) {
                let confirmMsg = res.data && res.data.confirmMsg ? res.data.confirmMsg : [];
                this.alertFormat(confirmMsg, params, res.respMsg, res.respCode);
            } else {
                this.$notify({title: "错误", message: res.respMsg, type: "error"});
                this.clearResp();
            }
            this.$store.commit('setLoadingPass', false);
            loading.close();
            // if (res.respCode === "CHECKECIF0958" && !res.data.confirm) {
            //     //ECIF0958交易校验不通过,不允许复核业务
            //     let confirmMsg = res.data.confirmMsg;
            //     const h = this.$createElement;
            //     this.$alert(
            //         h('div', [
            //             h('p', confirmMsg[0]),
            //             h('p', confirmMsg[1]),
            //             h('p', confirmMsg[2]),
            //             h('p', confirmMsg[3]),
            //             h('p', confirmMsg[4]),
            //             h('p', confirmMsg[5]),
            //             h('p', confirmMsg[6]),
            //             h('p', confirmMsg[7])
            //         ]),
            //         '提示', {
            //             confirmButtonText: '确定',
            //             type: 'warning',
            //         }).then(async () => {
            //         loading.close();
            //         this.$store.commit('setLoadingPass', false)
            //     })
            // } else if (res.respCode === "CHECKECIF0958" && res.data.confirm) {
            //     //ECIF0958交易校验通过,允许复核业务有提示
            //     let confirmMsg = res.data.confirmMsg;
            //     const h = this.$createElement;
            //     this.$confirm(
            //         h('div', [
            //             h('p', confirmMsg[0]),
            //             h('p', confirmMsg[1]),
            //             h('p', confirmMsg[2]),
            //             h('p', confirmMsg[3]),
            //             h('p', confirmMsg[4]),
            //             h('p', confirmMsg[5]),
            //             h('p', confirmMsg[6]),
            //             h('p', confirmMsg[7])
            //         ]),
            //         '提示', {
            //             confirmButtonText: '确定',
            //             cancelButtonText: '取消',
            //             type: 'warning',
            //         }).then(async () => {
            //         const loading = this.loading();
            //         params.ecif0958choice = "X";
            //         let ress = await Api.post(`/public/trnrel/relrow`, params);
            //         if (ress.respCode === SUCCESS) {
            //             this.$notify({
            //                 title: '成功',
            //                 message: ress.respMsg,
            //                 type: 'success',
            //             });
            //             loading.close();
            //             this.$store.commit('delTagsArry', this.$route.path);
            //             this.$router.back()
            //         } else if (ress.respCode === "CHECKRW02") {
            //             let confirmMsg = ress.data.confirmMsg;
            //             const h = this.$createElement;
            //             this.$confirm(
            //                 h('div', [
            //                     h('p', confirmMsg[0]),
            //                     h('p', confirmMsg[1]),
            //                     h('p', confirmMsg[2]),
            //                     h('p', confirmMsg[3]),
            //                     h('p', confirmMsg[4]),
            //                     h('p', confirmMsg[5]),
            //                     h('p', confirmMsg[6]),
            //                     h('p', confirmMsg[7])
            //                 ]),
            //                 '提示', {
            //                     confirmButtonText: '确定',
            //                     cancelButtonText: '取消',
            //                     type: 'warning',
            //                 }).then(async () => {
            //                 const loading = this.loading();
            //                 params.rw02choice = "X";
            //                 let resss = await Api.post(`/public/trnrel/relrow`, params);
            //                 if (resss.respCode === SUCCESS) {
            //                     this.$notify({
            //                         title: '成功',
            //                         message: resss.respMsg,
            //                         type: 'success',
            //                     });
            //                     loading.close();
            //                     this.$store.commit('delTagsArry', this.$route.path);
            //                     this.$router.back()
            //                 } else {
            //                     this.$notify({
            //                         title: "错误",
            //                         message: resss.respMsg,
            //                         type: "error"
            //                     });
            //                     loading.close();
            //                 }
            //             }).catch((e) => {
            //                 loading.close();
            //             });
            //             this.$store.commit('setLoadingPass', false)
            //         } else {
            //             this.$notify({
            //                 title: "错误",
            //                 message: ress.respMsg,
            //                 type: "error"
            //             });
            //             loading.close();
            //         }
            //     }).catch((e) => {
            //         loading.close();
            //     });
            //     this.$store.commit('setLoadingPass', false)
            // } else if (res.respCode === "CHECKRW02") {
            //     let confirmMsg = res.data.confirmMsg;
            //     const h = this.$createElement;
            //     this.$confirm(
            //         h('div', [
            //             h('p', confirmMsg[0]),
            //             h('p', confirmMsg[1]),
            //             h('p', confirmMsg[2]),
            //             h('p', confirmMsg[3]),
            //             h('p', confirmMsg[4]),
            //             h('p', confirmMsg[5]),
            //             h('p', confirmMsg[6]),
            //             h('p', confirmMsg[7])
            //         ]),
            //         '提示', {
            //             confirmButtonText: '确定',
            //             cancelButtonText: '取消',
            //             type: 'warning',
            //         }).then(async () => {
            //         const loading = this.loading();
            //         params.rw02choice = "X";
            //         let resss = await Api.post(`/public/trnrel/relrow`, params);
            //         if (resss.respCode === SUCCESS) {
            //             this.$notify({
            //                 title: '成功',
            //                 message: resss.respMsg,
            //                 type: 'success',
            //             });
            //             loading.close();
            //             this.$store.commit('delTagsArry', this.$route.path);
            //             this.$router.back()
            //         } else {
            //             this.$notify({
            //                 title: "错误",
            //                 message: resss.respMsg,
            //                 type: "error"
            //             });
            //             loading.close();
            //         }
            //     }).catch((e) => {
            //         loading.close();
            //     });
            //     this.$store.commit('setLoadingPass', false)
            // } else {
            //     this.$notify({
            //         title: "错误",
            //         message: res.respMsg,
            //         type: "error",
            //     });
            //     loading.close();
            //     this.$store.commit('setLoadingPass', false)
            // }
            // }
        },

        clearResp() {
            delete this.$store.state["infoEntrank"];
            delete this.$store.state["infoChkmsg"];
            delete this.$store.state["info0958"];
            delete this.$store.state["infoRW02"];
            delete this.$store.state["confirm0958"];
            delete this.$store.state["confirmMainRw02"];
            delete this.$store.state["confirmOthRw02"];
            delete this.$store.state["confirmFinwar"];
            delete this.$store.state["confirmBuyXrt"];
            delete this.$store.state["confirmSellXrt"];
        },
        alertConfirm(confirmMsg, params, respMsg, respCode) {
            const h = this.$createElement;
            this.$confirm(
                confirmMsg.length > 0 ? h('div', [
                    h('p', confirmMsg[0]),
                    h('p', confirmMsg[1]),
                    h('p', confirmMsg[2]),
                    h('p', confirmMsg[3]),
                    h('p', confirmMsg[4]),
                    h('p', confirmMsg[5]),
                    h('p', confirmMsg[6]),
                    h('p', confirmMsg[7])
                ]) : respMsg,
                '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning',
                }).then(async () => {
                this.$store.state[respCode] = true;
                this.handlePass(params);
            });
            this.clearResp();
        },

        alertFormat(confirmMsg, params, respMsg, respCode) {
            const h = this.$createElement;
            this.$alert(confirmMsg.length > 0 ?
                h('div', [
                    h('p', confirmMsg[0]),
                    h('p', confirmMsg[1]),
                    h('p', confirmMsg[2]),
                    h('p', confirmMsg[3]),
                    h('p', confirmMsg[4]),
                    h('p', confirmMsg[5]),
                    h('p', confirmMsg[6]),
                    h('p', confirmMsg[7])
                ]) : respMsg,
                '提示', {
                    confirmButtonText: '确定',
                    type: 'warning',
                }).then(async () => {
                if (respCode === "infoEntrank" || respCode === "infoChkmsg") {
                    this.$store.state[respCode] = true;
                    this.handlePass(params);
                }
                if (respCode === "info0958") {
                    //ECIF0958
                    this.clearResp();
                }
                if (respCode === "infoRW02") {
                    //RW02 预警命中  05 和 07 不允许release
                    this.clearResp();
                }
            });
        },
        // 打回
        async handleRefuse(params) {
            const loading = this.loading();
            const res = await Api.post(`/public/trnrel/reprow`, params);
            if (res.respCode === SUCCESS) {
                this.$notify({
                    title: '成功',
                    message: '打回成功',
                    type: 'success',
                });
                loading.close();
                this.$store.commit('delTagsArry', this.$route.path);
                this.$router.back()
            } else {
                if (res && res.respMsg !== "OK") {
                    this.$notify({
                        title: "错误",
                        message: res.respMsg,
                        type: "error",
                    });
                    loading.close();
                }
            }
            this.$store.commit('setLoadingRefuse', false)
        },
        // 检核 promise
        handleCheckPromise() {
            return new Promise((resolve, reject) => {
                // 前端检验
                this.$refs['modelForm'].validate(async (validStatic) => {
                    if (validStatic) {
                        // 额度等校验
                        let commonRule = this.commonComponentCheckCallBack();
                        if (commonRule && commonRule.isOk) {
                            return
                        }
                        const loading = this.loading('正在校验数据');
                        let params = {
                            ...this.model,
                            transName: this.trnName,
                            liaccvg: this.model.liaccv === undefined ? null : this.model.liaccv.liaccvg,
                            liaccv: this.model.liaccv === undefined ? null : this.model.liaccv,
                            liaallg: this.model.liaall === undefined ? null : this.model.liaall.liaallg,
                            liaall: this.model.liaall === undefined ? null : this.model.liaall,
                            setmod: this.model.setmod === undefined ? null : this.model.setmod,
                            setfog: this.model.setmod === undefined ? null : this.model.setmod.setfog,
                            setfeg: this.model.setmod === undefined ? null : this.model.setmod.setfeg,
                            setglg: this.model.setmod === undefined ? null : this.model.setmod.setglg,
                            doceot: this.model.docpan === undefined ? null : this.model.docpan.doceot,
                            limmod: this.model.limmod === undefined ? null : this.model.limmod,
                            trndia: this.model.trndia === undefined ? null : this.model.trndia,
                            dias: this.model.trndia === undefined ? null : this.model.trndia.dias,
                            umdmod: this.model.umdmod === undefined ? null : this.model.umdmod,
                            ypnmod: this.model.ypnmod === undefined ? null : this.model.ypnmod,
                        };
                        params = this.simplifyRequest(params);
                        const rtnmsg = await Api.post(`/${this.moduleRouter()}/${this.trnName}/checkAll`, params);

                        loading.close();
                        if (rtnmsg.respCode === SUCCESS) {
                            Utils.copyValueFromVoData(this.model, rtnmsg.data);
                            if (this.model.setmod) {
                                Utils.copyValueFromVoData(this.model.setmod, rtnmsg.data);
                                Utils.copyValueFromVoData(this.model.setmod, rtnmsg.data.setmod);
                            }
                            if (this.model.mtabut) {
                                Utils.copyValueFromVoData(this.model.mtabut, rtnmsg.data);
                            }
                            if (this.model.trnmod) {
                                Utils.copyValueFromVoData(this.model.trnmod, rtnmsg.data);
                                this.model.trnmod.doctreTableData1 = [];
                                this.model.trnmod.doctreTableData2 = rtnmsg.data.modifySet || []
                            }
                            if (this.model.liaall) {
                                Utils.copyValueFromVoData(this.model.liaall, rtnmsg.data);
                                Utils.copyValueFromVoData(this.model.liaall, rtnmsg.data.liaall);
                            }
                            if (this.model.liaccv) {
                                Utils.copyValueFromVoData(this.model.liaccv, rtnmsg.data);
                                Utils.copyValueFromVoData(this.model.liaccv, rtnmsg.data.liaccv);
                            }
                            if (this.model.docpan) {
                                Utils.copyValueFromVoData(this.model.docpan, rtnmsg.data);
                            }
                            if (this.model.limmod) {
                                if (this.trnName === 'GITZSQ' || this.trnName === 'NITZSQ') {
                                    //do nothing
                                } else {
                                    Utils.copyValueFromVoData(this.model.limmod, rtnmsg.data.limmod);
                                }
                            }
                            if (this.model.trndia) {
                                Utils.copyValueFromVoData(this.model.trndia, rtnmsg.data);
                                Utils.copyValueFromVoData(this.model.trndia, rtnmsg.data.trndia);
                            }
                            // 如果返回了统一名单,则将统一名单更新
                            if (this.model.umdmod && rtnmsg.data && rtnmsg.data.umdmod) {
                                Utils.copyValueFromVoData(this.model.umdmod, rtnmsg.data.umdmod);
                            }
                            this.$nextTick(
                                () => this.checkCallback(rtnmsg.data, -1).then(() => resolve())
                            )
                        }
                    } else {
                        // 前端校验失败
                        this.$notify({
                            title: '失败',
                            message: '校验失败',
                            type: 'error',
                        });
                        this.showFrontendErrors()
                    }
                })
            })
        },
        async handleTransExit() {
            if (this.$initParams && this.$initParams.params && this.trnName && !this.root) {
                const res = await Api.post(`/${this.$initParams.currentRouteModule}/${this.trnName}/exit`, this.$initParams.params);
                console.log(res);
            }
        },
        simplifyRequest(params) {
            let cloneParams = cloneDeep(params);
            if (cloneParams.liaccv) {
                delete cloneParams.liaccv.liaccvg;
                delete cloneParams.liaccv.buildParams;
            }
            if (cloneParams.liaall) {
                delete cloneParams.liaall.liaallg;
                delete cloneParams.liaall.buildParams;
            }
            if (cloneParams.setmod) {
                delete cloneParams.setmod.setfog;
                delete cloneParams.setmod.setfeg;
                delete cloneParams.setmod.setglg;
                delete cloneParams.setmod.buildParams;
                delete cloneParams.setmod.foreignRoleSet;
                delete cloneParams.setmod.roleSet;
                delete cloneParams.setmod.feeCodeSet;
            }
            if (cloneParams.trndia) {
                delete cloneParams.trndia.dias;
                delete cloneParams.trndia.buildParams;
            }
            return cloneParams;
        },
        validateSptInr() {
            let businessInr = this.$route.query.businessInr;
            let businessType = this.$route.query.businessType;
            if (businessType === 'SPT' && businessInr) {
                if (this.model.spt && this.model.spt.inr !== businessInr) {
                    console.log(businessInr + "|...|" + this.model.spt.inr);
                    this.$notify.error({
                        title: "错误",
                        message: "系统发现数据与界面存在不一致情况,请联系管理员登记问题!"
                    });
                    return true
                }
            }
            return false
        }
    },
    beforeDestroy() {
        this.handleTransExit()
    },
    created() {
        let trnNameRouter = this.trnNameRouter();
        if (trnNameRouter) {
            this.$sourceTrnName = this.trnName;
            this.trnName = trnNameRouter
        }
    }
}