import Api from '~/service/Api';
import commonFunctions from '~/mixin/commonFunctions.js';
import buildFn from './buildCommons.js';
import Utils from '~/utils';
import moment from 'moment';
import index2 from "./index2";

export default {
	mixins: [commonFunctions, buildFn, index2],
	methods: {
		// //申报2122报文
		async query2122() {
			let trnName = this.root ? this.root.trnName : this.trnName
			if (this.model.rmbbop.rmb2122.rmbflg == '1') {
				let rmbbop = this.buildRobbop(this.model, trnName);
        let opertype = "2";
        let rtnmsg = await Api.post('/business/rmbbopgid/rmbbop2122Cal', rmbbop);
        if (rtnmsg.respCode == SUCCESS) {
          Utils.copyValueFromVoData(this.model.rmbbop.rmb2122,rtnmsg.data.rmb2122);
          this.model.rmbbop.rmb2122.recgrp.ads.opertype = opertype;
        }
			}
		},
		changenPlateflg() {
			if (this.model.gitamep.plateflg == 'X') {
				this.model.swiadd.amestatxt = this.codes.amestatxt;
				this.rulePlateflgN1000()
				this.$set(this.codes, 'amestatxt', this.model.swiadd.ameblk);
			} else {
				this.$set(this.codes, 'amestatxt', this.model.swiadd.ameblk);
        		this.model.swiadd.ameblk = '';
			}
		},
		rulePlateflgN1000() {
			let data = this.model;
			Api.post(`/business/gitameRule/rulePlateflgN1000`, data).then(res => {
				this.model.swiadd.ameblk = res.data.ameblk;
			})
    },
    amenbrChange(){
      if(this.model.swiadd.amenbr!=''&&this.model.gitamep.plateflg === 'X'){
				this.model.swiadd.amestatxt = this.model.swiadd.ameblk
        this.rulePlateflgN1000()
      }
    },
    amedatChange(){
      if (this.model.gitamep.plateflg === 'X') {
				this.model.swiadd.amestatxt = this.model.swiadd.ameblk
        this.rulePlateflgN1000()
      }
    },
		addamtflgChange() {
			if (this.model.swiadd.addamtflg == "") {
				this.model.swiadd.addamtcovs20 = "";
        this.model.swiadd.addamt = "0.00";
        this.model.swiadd.addameamt = "0.00";
        this.changeSwiaddaddAmeamt();
			}
		},
		addamtChange() {
			if (this.addamtcovs20Flg != "X" && this.model.swiadd.addamt != "" && this.model.swiadd.addamt != "0.00") {
				this.model.swiadd.addamtcovs20 = this.model.swiadd.addcur + " " + this.model.swiadd.addamt;
			}
		},
		addamtcovs20Change() {
			this.addamtcovs20Flg = "X";
    },
    handleChangeExpflg() {
      this.model.swiadd.newexpdat = '';
      if (this.model.swiadd.newexpflg === "X" && this.model.gidgrp.rec.hndtyp === "OC") {
        this.model.swiadd.newliaflg = "X";
	  }
	  //759 赋值给model.swiadd.exptyp
	  if(this.model.oldgidgrp.rec.legfrm == 'DEPU'){
        if (this.model.swiadd.newexpflg === "X") {
          this.model.swiadd.exptyp="COND";
        }
        else{
			if(this.model.swiadd.newexpdat !=null&&this.model.swiadd.newexpdat !== ''){
				this.model.swiadd.exptyp="COND";
			}
			else{
				this.model.swiadd.exptyp="";
			}
        }
	  }
    },

		async defaultList(e) {
			if (!e.includes('ameps20')) {
				return
			}
			this.getPurposameData();
			this.getRamrolData();
		},
		changeReqcan() {
			if (this.model.swiadd.reqcan == "X") {
				this.model.gitamep.ametxt = "Cancellation of the counter undertaking requested."
			} else {
				this.model.gitamep.ametxt = "";
			}
		},
		handleChangeFingua() {

		},
		defaultVouflgN1000() {

		},

		onCfaflg(e) {
			if (e == undefined) {
				return;
			}
			switch (this.model.cfagit.cfaflg) {

				case "1":
					this.model.cfagit.basflg = 'X';
					this.model.cfagit.dclflg = 'X';
					// if (!this.model.cfagit.ownextkey) {
					//   this.ownextkey = this.codes.ownextkey1;
					//   this.model.cfagit.ownextkey = this.codes.ownextkey1[0].value;
					//   // this.ownextkey= getValues('cfagit.ownextkey','ownextkey1');
					// }
					break;
				case "2":
					if (this.model.cfagit.recgrp.bas != null) {
						if (this.model.cfagit.recgrp.bas.exguarancode != null && this.model.cfagit.recgrp.bas.exguarancode != '') {
							this.model.cfagit.basflg = 'X';
							if (this.model.swiadd.ameamt > 0) {
                this.model.cfagit.dclflg = 'X';
                this.model.cfagit.recgrp.dcl[0].acp = "X";
							} else {
                this.model.cfagit.dclflg = '';
                this.model.cfagit.recgrp.dcl[0].acp = "";
							}
						}
					}
					// this.model.cfagit.ownextkey = '';
					break;
				case "3":
					this.model.cfagit.basflg = '';
					this.model.cfagit.dclflg = 'X';
					break;
				case "5":
					this.model.cfagit.vrfflg = 'X';
					this.model.cfagit.dclflg = 'X';
					break;
				default:
					this.model.cfagit.basflg = '';
					this.model.cfagit.vrfflg = '';
					this.model.cfagit.dclflg = '';
					if (this.model.cfagit.recgrp.bas != null) {
						if (this.model.cfagit.recgrp.bas.exguarancode != null && this.model.cfagit.recgrp.bas.exguarancode != '') {
							this.model.cfagit.recgrp.bas.actiontype = "A";
              this.model.cfagit.recgrp.bas.guaranamount = this.model.swiadd.newamt;
						}
					}
					this.model.cfagit.cfatyp = "A";
					// this.model.cfagit.ownextkey = '';
			}
		},
    defaultChangeCfaflg() {
      if(this.isInDisplay){
        return;
      }
      if(this.model.gidgrp.rec.fingua == "Y") {
        if(this.model.cfagit.recgrp.dcl == null || this.model.cfagit.recgrp.dcl.length == 0) {
          var a = [{
            exguarancode: "",
            actiontype: "",
            wabachandate: "",
            basere: "",
            remark: "",
            actiondesc: "",
            acp: "",
          }];
          this.model.cfagit.recgrp.dcl = a;
        }
        //直开日期逻辑
        if(this.model.oldgidgrp.rec.purpos == 'ISSU') {
        //修改新业务逻辑
          if(this.model.swiadd.ameamt > 0) {
            if(this.model.rmbbop.rmb2122.recgrp.ads.levyno != null && this.model.rmbbop.rmb2122.recgrp.ads.levyno != '') {
              this.model.rmbbop.rmb2122.recgrp.ads.opertype = "2";
              this.model.rmbbop.rmb2122.rmbflg = "1";
            }
            if(this.model.cfagit.recgrp.bas.exguarancode != null && this.model.cfagit.recgrp.bas.exguarancode != '') {
              this.model.cfagit.cfaflg = "2";
              this.model.cfagit.basflg = "X";
              this.model.cfagit.dclflg = "X";
              this.model.cfagit.cfatyp = "M";
            }
          } else if(this.model.swiadd.ameamt == 0) {
            if(this.model.rmbbop.rmb2122.recgrp.ads.levyno != null && this.model.rmbbop.rmb2122.recgrp.ads.levyno != '') {
              if(this.model.rmbbop.rmb2122.benchange == '1') {
                if(this.model.swiadd.newexpdat != "" && (this.model.oldgidgrp.rec.expdat == "" || this.model.oldgidgrp.rec.expdat == null)) {
                  this.model.rmbbop.rmb2122.rmbflg = "2";
                } else if(this.model.oldgidgrp.rec.expdat != "" && this.model.swiadd.newexpdat != "" && this.model.swiadd.newexpdat < this.model.oldgidgrp.rec.expdat){
                  this.model.rmbbop.rmb2122.rmbflg = "2";
                } else {
                  this.model.rmbbop.rmb2122.recgrp.ads.opertype = "2";
                  this.model.rmbbop.rmb2122.rmbflg = "1";
                }
              } else {
                if(this.model.oldgidgrp.rec.expdat != "" && this.model.swiadd.exptyp != "" && this.model.swiadd.exptyp != "FIXD" && (this.model.swiadd.newexpdat == null || this.model.swiadd.newexpdat == "")) {
                  this.model.rmbbop.rmb2122.recgrp.ads.opertype = "2";
                  this.model.rmbbop.rmb2122.rmbflg = "1";
                } else if(this.model.oldgidgrp.rec.expdat != "" && this.model.swiadd.newexpdat != "" && this.model.swiadd.newexpdat > this.model.oldgidgrp.rec.expdat){
                  this.model.rmbbop.rmb2122.recgrp.ads.opertype = "2";
                  this.model.rmbbop.rmb2122.rmbflg = "1";
                } else {
                  this.model.rmbbop.rmb2122.rmbflg = "2";
                }
              }
            }
            if(this.model.cfagit.recgrp.bas.exguarancode != null && this.model.cfagit.recgrp.bas.exguarancode != '') {
              this.model.cfagit.dclflg = "";
              this.model.cfagit.recgrp.dcl[0].acp = "";
              if(this.model.cfagit.benchange == '1') {
                if(this.model.swiadd.newexpdat != "" && (this.model.oldgidgrp.rec.expdat == "" || this.model.oldgidgrp.rec.expdat == null)) {
                  this.model.cfagit.basflg = "";
                  this.model.cfagit.cfatyp = "";
                  this.model.cfagit.cfaflg = "4";
                } else if(this.model.oldgidgrp.rec.expdat != "" && this.model.swiadd.newexpdat != "" && this.model.swiadd.newexpdat < this.model.oldgidgrp.rec.expdat){
                  this.model.cfagit.basflg = "";
                  this.model.cfagit.cfatyp = "";
                  this.model.cfagit.cfaflg = "4";
                } else {
                  this.model.cfagit.basflg = "X";
                  this.model.cfagit.cfaflg = "2";
                  this.model.cfagit.cfatyp = "M";
                }
              } else {
                if(this.model.oldgidgrp.rec.expdat != "" && this.model.swiadd.exptyp != "" && this.model.swiadd.exptyp != "FIXD" && (this.model.swiadd.newexpdat == null || this.model.swiadd.newexpdat == "")) {
                  this.model.cfagit.basflg = "X";
                  this.model.cfagit.cfaflg = "2";
                  this.model.cfagit.cfatyp = "M";
                } else if(this.model.oldgidgrp.rec.expdat != "" && this.model.swiadd.newexpdat != "" && this.model.swiadd.newexpdat > this.model.oldgidgrp.rec.expdat){
                  this.model.cfagit.cfatyp = "M";
                  this.model.cfagit.cfaflg = "2";
                  this.model.cfagit.basflg = "X";
                } else {
                  this.model.cfagit.basflg = "";
                  this.model.cfagit.cfatyp = "";
                  this.model.cfagit.cfaflg = "4";
                }
              }
            }
          } else if(this.model.swiadd.ameamt < 0) {
            if(this.model.rmbbop.rmb2122.recgrp.ads.levyno != null && this.model.rmbbop.rmb2122.recgrp.ads.levyno != '') {
              this.model.rmbbop.rmb2122.rmbflg = "2";
            }
            if(this.model.cfagit.recgrp.bas.exguarancode != null && this.model.cfagit.recgrp.bas.exguarancode != '') {
              this.model.cfagit.dclflg = "";
              this.model.cfagit.recgrp.dcl[0].acp = "";
              this.model.cfagit.basflg = "";
              this.model.cfagit.cfatyp = "";
              this.model.cfagit.cfaflg = "4";
            }
          } else {
            if(this.model.rmbbop.rmb2122.recgrp.ads.levyno != null && this.model.rmbbop.rmb2122.recgrp.ads.levyno != '') {
              this.model.rmbbop.rmb2122.rmbflg = "2";
            }
            if(this.model.cfagit.recgrp.bas.exguarancode != null && this.model.cfagit.recgrp.bas.exguarancode != '') {
              this.model.cfagit.cfaflg = "4";
              this.model.cfagit.basflg = "";
              this.model.cfagit.dclflg = "";
              this.model.cfagit.recgrp.dcl[0].acp = "";
              this.model.cfagit.cfatyp = "";
            }
          }
        } 
        //反担保和反反担保日期对比逻辑
        else if(this.model.oldgidgrp.rec.purpos == 'ISCO' || this.model.oldgidgrp.rec.purpos == 'ICCO') {
          if(this.model.swiadd.ameamt > 0) {
            if(this.model.rmbbop.rmb2122.recgrp.ads.levyno != null && this.model.rmbbop.rmb2122.recgrp.ads.levyno != '') {
              this.model.rmbbop.rmb2122.recgrp.ads.opertype = "2";
              this.model.rmbbop.rmb2122.rmbflg = "1";
            }
            if(this.model.cfagit.recgrp.bas.exguarancode != null && this.model.cfagit.recgrp.bas.exguarancode != '') {
              this.model.cfagit.cfaflg = "2";
              this.model.cfagit.basflg = "X";
              this.model.cfagit.dclflg = "X";
              this.model.cfagit.cfatyp = "M";
            }
          } else if(this.model.swiadd.ameamt == 0) {
            if(this.model.rmbbop.rmb2122.recgrp.ads.levyno != null && this.model.rmbbop.rmb2122.recgrp.ads.levyno != '') {
              if(this.model.rmbbop.rmb2122.becchange == '1') {
                if(this.model.swiadd.newliadat != "" && (this.model.oldgidgrp.rec.liadat == "" || this.model.oldgidgrp.rec.liadat == null)) {
                  this.model.rmbbop.rmb2122.rmbflg = "2";
                } else if(this.model.oldgidgrp.rec.liadat != "" && this.model.swiadd.newliadat != "" && this.model.swiadd.newliadat < this.model.oldgidgrp.rec.liadat){
                  this.model.rmbbop.rmb2122.rmbflg = "2";
                } else {
                  this.model.rmbbop.rmb2122.recgrp.ads.opertype = "2";
                  this.model.rmbbop.rmb2122.rmbflg = "1";
                }
              } else {
                if(this.model.oldgidgrp.rec.liadat != "" && this.model.swiadd.liatypc != "" && this.model.swiadd.liatypc != "FIXD" && (this.model.swiadd.newliadat == null || this.model.swiadd.newliadat == "")) {
                  this.model.rmbbop.rmb2122.recgrp.ads.opertype = "2";
                  this.model.rmbbop.rmb2122.rmbflg = "1";
                } else if(this.model.oldgidgrp.rec.liadat != "" && this.model.swiadd.newliadat != "" && this.model.swiadd.newliadat > this.model.oldgidgrp.rec.liadat){
                  this.model.rmbbop.rmb2122.recgrp.ads.opertype = "2";
                  this.model.rmbbop.rmb2122.rmbflg = "1";
                } else {
                  this.model.rmbbop.rmb2122.rmbflg = "2";
                }
              }
            }
            if(this.model.cfagit.recgrp.bas.exguarancode != null && this.model.cfagit.recgrp.bas.exguarancode != '') {
              this.model.cfagit.dclflg = "";
              this.model.cfagit.recgrp.dcl[0].acp = "";
              if(this.model.cfagit.becchange == '1') {
                if(this.model.swiadd.newliadat != "" && (this.model.oldgidgrp.rec.liadat == "" || this.model.oldgidgrp.rec.liadat == null)) {
                  this.model.cfagit.basflg = "";
                  this.model.cfagit.cfatyp = "";
                  this.model.cfagit.cfaflg = "4";
                } else if(this.model.oldgidgrp.rec.liadat != "" && this.model.swiadd.newliadat != "" && this.model.swiadd.newliadat < this.model.oldgidgrp.rec.liadat){
                  this.model.cfagit.basflg = "";
                  this.model.cfagit.cfatyp = "";
                  this.model.cfagit.cfaflg = "4";
                } else {
                  this.model.cfagit.basflg = "X";
                  this.model.cfagit.cfaflg = "2";
                  this.model.cfagit.cfatyp = "M";
                }
              } else {
                if(this.model.oldgidgrp.rec.liadat != "" && this.model.swiadd.liatypc != "" && this.model.swiadd.liatypc != "FIXD" && (this.model.swiadd.newliadat == null || this.model.swiadd.newliadat == "")) {
                  this.model.cfagit.basflg = "X";
                  this.model.cfagit.cfaflg = "2";
                  this.model.cfagit.cfatyp = "M";
                } else if(this.model.oldgidgrp.rec.liadat != "" && this.model.swiadd.newliadat != "" && this.model.swiadd.newliadat > this.model.oldgidgrp.rec.liadat){
                  this.model.cfagit.cfatyp = "M";
                  this.model.cfagit.cfaflg = "2";
                  this.model.cfagit.basflg = "X";
                } else {
                  this.model.cfagit.basflg = "";
                  this.model.cfagit.cfatyp = "";
                  this.model.cfagit.cfaflg = "4";
                }
              }
            }
          } else if(this.model.swiadd.ameamt < 0) {
            if(this.model.rmbbop.rmb2122.recgrp.ads.levyno != null && this.model.rmbbop.rmb2122.recgrp.ads.levyno != '') {
              this.model.rmbbop.rmb2122.rmbflg = "2";
            }
            if(this.model.cfagit.recgrp.bas.exguarancode != null && this.model.cfagit.recgrp.bas.exguarancode != '') {
              this.model.cfagit.dclflg = "";
              this.model.cfagit.recgrp.dcl[0].acp = "";
              this.model.cfagit.basflg = "";
              this.model.cfagit.cfatyp = "";
              this.model.cfagit.cfaflg = "4";
            }
          } else {
            if(this.model.rmbbop.rmb2122.recgrp.ads.levyno != null && this.model.rmbbop.rmb2122.recgrp.ads.levyno != '') {
              this.model.rmbbop.rmb2122.rmbflg = "2";
            }
            if(this.model.cfagit.recgrp.bas.exguarancode != null && this.model.cfagit.recgrp.bas.exguarancode != '') {
              this.model.cfagit.cfaflg = "4";
              this.model.cfagit.basflg = "";
              this.model.cfagit.dclflg = "";
              this.model.cfagit.recgrp.dcl[0].acp = "";
              this.model.cfagit.cfatyp = "";
            }
          }
        }
      }
    },
		exptxtChange() {
			//赋值给model.gidgrp.blk.exptxt
			// if (this.model.swiadd.exptxt != '') {
			// 	this.model.gidgrp.blk.exptxt = this.model.swiadd.exptxt;
			// } else {
			// 	this.model.gidgrp.blk.exptxt = this.model.oldgidgrp.blk.exptxt;
			// }
		},
		queryCfap() {
			let trnName = this.root ? this.root.trnName : this.trnName;
			if (this.model.cfagit.cfaflg == '2') {
				const cfatyp = "M";
        let cfap = this.buildCfap(this.model, trnName);
        if(cfap.recgrp.dcl == null || cfap.recgrp.dcl.length == 0) {
          var a = [{
            exguarancode: "",
            actiontype: "",
            wabachandate: "",
            basere: "",
            remark: "",
            actiondesc: "",
            acp: "",
          }];
          cfap.recgrp.dcl = a;
        }
				Api.post('/business/gid/cfaMapping', cfap).then(rtnmsg => {
					if (rtnmsg.respCode == SUCCESS) {
						// if(rtnmsg.data.recgrp.bas.guaranamount != null && rtnmsg.data.recgrp.bas.guaranamount != "") {
						//   this.model.cfagit.recgrp.bas.guaranamount = rtnmsg.data.recgrp.bas.guaranamount;
						// }
						if (rtnmsg.data.recgrp.bas.bencountrycode != null && rtnmsg.data.recgrp.bas.bencountrycode != "") {
							this.model.cfagit.recgrp.bas.bencountrycode = rtnmsg.data.recgrp.bas.bencountrycode;
						}
						// if(rtnmsg.data.maturity != null) {
						//   this.model.cfagit.recgrp.bas.maturity = rtnmsg.data.recgrp.bas.maturity;
						// }
						if (this.model.swiadd.ameamt > 0) {
							this.model.cfagit.recgrp.bas.guaranamount = this.model.swiadd.newamt;
						} else {
							this.model.cfagit.recgrp.bas.guaranamount = this.model.oldgidgrp.cbs.max.amt;
						}
						if (this.model.oldgidgrp.rec.expdat != "" && this.model.swiadd.newexpdat != "" && this.model.swiadd.newexpdat > this.model.oldgidgrp.rec.expdat) {
							this.model.cfagit.recgrp.bas.maturity = this.model.swiadd.newexpdat;
						} else if (this.model.swiadd.newexpdat == "" && this.model.swiadd.newexpflg == "X") {
							this.model.cfagit.recgrp.bas.maturity = moment(this.model.cfagit.recgrp.bas.contractdate).add(20, "years").format("YYYY-MM-DD");
						} else if (this.model.oldgidgrp.rec.expdat == "" && this.model.swiadd.newexpdat != "") {
							this.model.cfagit.recgrp.bas.maturity = this.model.swiadd.newexpdat;
						}
						this.model.cfagit.cfatyp = cfatyp;
						this.model.cfagit.recgrp.bas.actiontype = "C";
						this.model.cfagit.recgrp.bas.acp = "X";
						if (this.model.cfagit.recgrp.dcl[0] != null) {
							Utils.copyValueFromVoData(this.model.cfagit.recgrp.dcl[0], rtnmsg.data.recgrp.dcl[0]);
						}
						this.model.cfagit.recgrp.dcl[0].actiontype = "A";
						if (this.model.swiadd.ameamt > 0) {
							this.model.cfagit.recgrp.dcl[0].acp = "X";
						} else {
							this.model.cfagit.recgrp.dcl[0].acp = "";
						}
					}
				});
			}
		},
		changeExptyp() {
			this.root.$refs.modelForm.clearValidate('swiadd.newexpdat')
      if (this.model.swiadd.exptyp == "") {
        this.model.swiadd.newexpdat = "";
        this.model.swiadd.exptxt = "";
        this.model.swiadd.newexpflg = "";
      }
			if (this.model.swiadd.exptyp == 'FIXD') {
        this.model.swiadd.exptxt = "";
        this.model.swiadd.newexpflg = "";
			}
			if (this.model.swiadd.exptyp == "OPEN") {
				this.model.swiadd.newexpdat = "";
        this.model.swiadd.exptxt = "";
        this.model.swiadd.newexpflg = "X";
      }
      if(this.model.swiadd.exptyp == 'COND') {
        this.model.swiadd.newexpdat = "";
        this.model.swiadd.newexpflg = "X";
      } 
			//赋值给model.gidgrp.rec.exptyp
			// if (this.model.swiadd.exptyp != '') {
			// 	this.model.gidgrp.rec.exptyp = this.model.swiadd.exptyp;
			// } else {
			// 	this.model.gidgrp.rec.exptyp = this.model.oldgidgrp.rec.exptyp;
      // }
      this.defaultChangeCfaflg();
		},
		changeLiatypc() {
			this.root.$refs.modelForm.clearValidate('swiadd.newliadat')	
			if (this.model.swiadd.liatypc == 'FIXD') {
        this.model.swiadd.liatxtc = "";
        this.model.swiadd.newliaflg = "";
			}
			if (this.model.swiadd.liatypc == "OPEN") {
				this.model.swiadd.newliadat = "";
        this.model.swiadd.liatxtc = "";
        this.model.swiadd.newliaflg = "X";
      }
      if (this.model.swiadd.liatypc == "COND") {
				this.model.swiadd.newliadat = "";
        this.model.swiadd.newliaflg = "X";
      }
      if (this.model.swiadd.liatypc == "") {
        this.model.swiadd.newliadat = "";
        this.model.swiadd.newliaflg = "";
        this.model.swiadd.liatxtc = "";
      }
      this.defaultChangeCfaflg();
			//赋值给model.gidgrp.rec.liatypc
			// if (this.model.swiadd.liatypc != '') {
			// 	this.model.gidgrp.rec.liatypc = this.model.swiadd.liatypc;
			// } else {
			// 	this.model.gidgrp.rec.liatypc = this.model.oldgidgrp.rec.liatypc;
			// }
		},
		newliadatChange() {
      if(this.model.swiadd.liatypc=="COND"){
        if(this.model.swiadd.newliadat==null || this.model.swiadd.newliadat==""){
          this.model.swiadd.newliaflg = "X"
        }else{
          this.model.swiadd.newliaflg = ""
        }
      }
      this.defaultChangeCfaflg();
		},
		liatxtcChange() {
			//赋值给model.gidgrp.blk.liatxtc
			// if (this.model.swiadd.liatxtc != '') {
			// 	this.model.gidgrp.blk.liatxtc = this.model.swiadd.liatxtc;
			// } else {
			// 	this.model.gidgrp.blk.liatxtc = this.model.oldgidgrp.blk.liatxtc;
			// }
    },
    handleChangeLiaflg() {
      this.model.swiadd.newliadat = '';
      this.defaultChangeCfaflg();
    },
		changeAmemsgdonglg() {
			if (this.model.swiadd.amemsgdonflg == '') {
				this.model.gitamep.ramrol = ''
			}
		},
		copyValueToCountrycod (val) {
      if (this.model.cfagit) {
        this.model.cfagit.recgrp.bas.bencountrycode = val;
        if (this.model.cfagit.recgrp.bas.modifySet) {
          if (!this.model.cfagit.recgrp.bas.modifySet.includes("bencountrycode")) {
            this.model.cfagit.recgrp.bas.modifySet.push("bencountrycode");
          }
        } else {
          this.model.cfagit.recgrp.bas.modifySet = ["bencountrycode"];
        }
      }
      if (this.model.rmbbop.rmb2122) {
        this.model.rmbbop.rmb2122.recgrp.ads.voucheecountrycode = val;
      }
    },
		handleChangeCtr() {
			if (this.model.gitp.ctrflg == "") {
				let pts = new Pts().data;
				Utils.copyValueFromVO(this.model.gidgrp.ctr.pts, pts);
			}
		},
		changeGartypc() {
			let _this = this
			if (_this.model.gidgrp.rec.gartyp == "1") {
				_this.model.gidgrp.rec.gtxinrc = "<NILTXT>";
			} else {
				_this.model.gidgrp.rec.gtxinrc = "";
			}
			_this.handleChangeGartypc();
		},
		handleChangeIssc() {
			if (this.model.gidgrp.iss && this.model.gidgrp.iss.pts && this.model.gidgrp.iss.pts.extkey) {
				Utils.copyValueFromVoData(this.model.gidgrp.bec, this.model.gidgrp.iss);
			}
		},
		handleChangeDeltoc() {
			if (this.model.gidgrp.rec.deltoc == 'BENE') {
				this.model.gidgrp.blk.deltoadrc = this.model.gidgrp.ben.pts.nam + '\n' + this.model.gidgrp.ben.pts.adrblk
			}
			if (this.model.gidgrp.rec.deltoc == 'OTHR') {
				this.model.gidgrp.blk.deltoadrc = ""
			}
		},
		changeApprulc() {
			if (this.model.gidgrp.blk.apprulc != 'OTHR') {
				this.model.gidgrp.blk.apprultxtc = '';
			}
		},
		// preInput 原ovwp1面板
		changePurposin() {
			this.model.gidgrp.rec.purpos = "";
			this.model.gidgrp.rec.legfrm = '';
			if (this.model.gidgrp.rec.purposin === "ISCO") {
				this.model.gidgrp.rec.purpos = "ISSU";
				this.model.gidgrp.rec.hndtyp = "OT"
			}
			if (this.model.gidgrp.rec.purposin === "ICCO") {
				this.model.gidgrp.rec.purpos = "ISCO";
				this.model.gidgrp.rec.hndtyp = "OT"
			}
		},
		changeInc760() {
			if (this.model.gitp.inc760 !== "X") {
        this.model.gidgrp.rec.purposin = "";
        this.model.swiadd.purposamein = '';
				this.changePurposin()
			}
		},
    changeSwiaddaddAmeamt() {
			let addameamt = this.model.swiadd.addameamt ? this.model.swiadd.addameamt : 0
			let oldMax2Amt = this.model.oldgidgrp.cbs.max2.amt ? this.model.oldgidgrp.cbs.max2.amt : 0
      this.model.swiadd.addnewamt = Number(oldMax2Amt) + Number(addameamt)
      this.model.gidgrp.cbs.max2.amt = this.model.swiadd.addnewamt
      this.model.gidgrp.cbs.max2.cur = this.model.swiadd.addamecur
      if (this.model.swiadd.addamtflg != "" && this.model.swiadd.addnewamt != 0) {
        this.model.swiadd.addamtcovs20 = this.model.swiadd.addcur + this.model.swiadd.addnewamt;
        this.model.gidgrp.blk.addamtcovs20 =this.model.swiadd.addamtcovs20;
			}
		},
		apprulChange(val){
			if(val !== 'OTHR'){
				this.model.gidgrp.blk.apprultxt = ''
			}
			this.seqBSynToSeqB();
		},

		// model.gidgrp.rec.jurlaws20
		changeJurlaws20() {
			if (this.model.gidgrp.rec.jurlaws20 === "GB") {
					this.model.gidgrp.rec.jurlaw = "GB"
			} else if (this.model.gidgrp.rec.jurlaws20 === "CN") {
					this.model.gidgrp.rec.jurlaw = "CN"
			} else if (this.model.gidgrp.rec.jurlaws20 === "HK") {
					this.model.gidgrp.rec.jurlaw = "HK"
			} else if (this.model.gidgrp.rec.jurlaws20 === "") {
					this.model.gidgrp.rec.jurlaw = ""
			}
			this.seqBSynToSeqB();
		},

		changeOpndat(){
			this.model.gidgrp.rec.orddat = this.model.gidgrp.rec.opndat
    },
    // 获取地区机构号
    async getOwnExtkeyCondition1() {
      let body = {ownExtKey: ""};
      if(this.model.cfagit.ownextkey) {
        body.ownExtKey = this.model.cfagit.ownextkey;
      }
      let res = await Api.post('/business/bch/getBranchListByownExtKey', body);
      if (res.respCode === SUCCESS) {
          this.ownExtkeyList = res.data;
      }
		},
		handleChangeLiadat () {
      if (this.model.gidgrp.rec.liatypc == "COND") {
        if (this.model.gidgrp.rec.liadat == null || this.model.gidgrp.rec.liadat == "") {
          this.model.gidgrp.rec.liaflg = "X"
        } else {
          this.model.gidgrp.rec.liaflg = ""
        }
      }
		},
		handleChangeExpdat () {
      if (this.model.gidgrp.rec.exptyp == "COND") {
        if (this.model.gidgrp.rec.expdat == null || this.model.gidgrp.rec.expdat == "") {
          this.model.gidgrp.rec.expflg = "X"
        } else {
          this.model.gidgrp.rec.expflg = ""
        }
      }
		},
		handleChangeBen () {
      if (this.model.gidgrp.rec.hndtyp == 'OT') {
        this.model.gidgrp.rec.ownref = "";
      }
      this.defaultGidgrpRecSndtoN950();
      if (this.model.gitamep.plateflg === 'X') {
				this.model.swiadd.amestatxt = this.model.swiadd.ameblk
        this.rulePlateflgN1000()
      }
      this.changeBenCfaRmbflg();
		},
		defaultGidgrpRecSndtoN950 () {
      if (this.model.gidgrp.rec.purpos === 'ISCO' || this.model.gidgrp.rec.purpos === 'ICCO') {
        Utils.copyValueFromVO(this.model.gidgrp.apc, this.model.gidgrp.apl);
        this.model.gidgrp.apc.pts.rol = "APC";
      }
      if (this.model.gidgrp.rec.purpos === 'ISCO') {
        Utils.copyValueFromVO(this.model.gidgrp.iss, this.model.gidgrp.ben);
        this.model.gidgrp.apc.pts.rol = "APC";
        this.model.gidgrp.iss.pts.rol = "ISS";
      }
      if (this.model.gidgrp.ben && this.model.gidgrp.ben.pts && this.model.gidgrp.ben.pts.ennam && this.model.gidgrp.ben.pts.enadr) {
        this.model.gidgrp.benadrlin = this.model.gidgrp.ben.pts.ennam.replace(/[\n]/g, ",") + "," + this.model.gidgrp.ben.pts.enadr.replace(/[\n]/g, ",");
      }
      this.handleSndto();
		},
		handleSndto () {
      if (this.model.gidgrp.atb && this.model.gidgrp.atb.pts && this.model.gidgrp.atb.pts.extkey) {
        this.model.gidgrp.rec.sndto = "ATB";
      } else if (this.model.gidgrp.rec.purpos === "ISCO" || this.model.gidgrp.rec.purpos === "ICCO") {
        if (this.model.gidgrp.ben && this.model.gidgrp.ben.pts && this.model.gidgrp.ben.pts.extkey) {
          this.model.gidgrp.rec.sndto = "BEN";
        } else if (this.model.gidgrp.iss && this.model.gidgrp.iss.pts && this.model.gidgrp.iss.pts.extkey) {
          this.model.gidgrp.rec.sndto = "ISS";
        } else {
          this.model.gidgrp.rec.sndto = "";
        }
      } else {
        this.model.gidgrp.rec.sndto = "";
      }
		},
		changeAtxinr (e) {
      if (e === undefined || this.isInDisplay) {
        return
      }
      this.model.gidgrp.blk.gidtxt = "";
      if (this.model.gidgrp.blk.modifySet) {
        this.model.gidgrp.blk.modifySet = this.model.gidgrp.blk.modifySet.filter(key => key != 'gidtxt')
      }
      for (let item of this.model.atxinrList) {
        if (e === item.value) {
          this.model.gidgrp.blk.gtxgidtxt = item.atxtxt;
          this.model.gidgrp.blk.gidtxt = item.atxtxt;
          // 备份字段
          this.$set(this.codes, 'gtxgidtxtMark', item.atxtxt)
        }
      }
      this.getConfigData(this.model.gidgrp.rec.atxinr).then(() => {
        if (!this.isInDisplay) {
          this.root.templateToText('gidtxtp')
        }
      })
    },
    changeBenCfaRmbflg() {
      //直开保函变更受益人控制报送
      if(this.model.oldgidgrp.rec.purpos == 'ISSU') {
        if(this.model.gidgrp.rec.fingua == "Y") {
          this.model.rmbbop.rmb2122.benchange = "1";
          //直开非融资类 修改受益人申报
          let cfaguatype = this.model.gidgrp.rec.cfaguatyp;
          if(cfaguatype.slice(0,2) == '12') {
            this.model.cfagit.benchange = "1";
          }
        }
      }
      this.defaultChangeCfaflg();
    },
    changeBecCfaRmbflg() {
      //反担保和反反担保保函变更受益人控制报送
      if(this.model.oldgidgrp.rec.purpos == 'ISCO' || this.model.oldgidgrp.rec.purpos == 'ICCO') {
        if(this.model.gidgrp.rec.fingua == "Y") {
          this.model.rmbbop.rmb2122.becchange = "1";
          this.model.cfagit.becchange = "1";
        }
      }
      this.defaultChangeCfaflg();
    },
  },
}