import commonFunctions from '~/mixin/commonFunctions.js';
import Api from '~/service/Api';
import moment from 'moment';
import commonDepend from "~/mixin/commonDepend";

export default {
	mixins: [commonFunctions, commonDepend],
	methods: {
		// nidgrp.cbs.max.cur
		// "nidgrp.cbs.max.amt"
		// nidgrp.rec.stacty
		// nidgrp.apl.pts.nam
		// 保函币种和金额--nidgrp.cbs.max.cur
		// 对于来报来报来说,需要先获取角色的详细信息
		async dealStaPtsptaInfo(){
			if(this.model.spt && this.model.spt.sta && this.model.spt.sta !='CMB' && this.model.spt.sta !='BLK'  && this.model.nidgrp.rec.beyzd6!='Y'){
				if (this.model.nitp.tempOwnref === '') {
					this.model.nitp.tempOwnref = this.model.nidgrp.rec.ownref;
				}
				// 如果是云平台来报,解析bdb角色信息
				if(this.model.nidgrp.rec.fromflg && (this.model.nidgrp.rec.fromflg == 'Y' || this.model.nidgrp.rec.fromflg == 'E')){
					let adrelc;
					let namelc;
					let language;
					if(this.model.nidgrp.rec.giduil){
						language = this.model.nidgrp.rec.giduil
					}else{
            language = 'CN'
					}
					if(language == 'CN'){
						if(this.model.nidgrp.bdb && this.model.nidgrp.bdb.pts && this.model.nidgrp.bdb.pts.cnnam){
							namelc = this.model.nidgrp.bdb.pts.cnnam
						}else{
							namelc = ''
						}
						if(this.model.nidgrp.bdb && this.model.nidgrp.bdb.pts && this.model.nidgrp.bdb.pts.cnadr){
							adrelc = this.model.nidgrp.bdb.pts.cnadr
						}else{
							adrelc = ''
						}
					}else{
						if(this.model.nidgrp.bdb && this.model.nidgrp.bdb.pts && this.model.nidgrp.bdb.pts.ennam){
							namelc = this.model.nidgrp.bdb.pts.ennam
						}else{
							namelc = ''
						}
						if(this.model.nidgrp.bdb && this.model.nidgrp.bdb.pts && this.model.nidgrp.bdb.pts.enadr){
							adrelc = this.model.nidgrp.bdb.pts.enadr
						}else{
							adrelc = ''
						}
					}
            let data = {
							adrelc: adrelc,
							flg: false,
							language:language,
							namelc:namelc,
							rol:'bdb',
							typflg:'C'
						};
						let ress = await Api.post('/business/ptspta/ptsTmpAdrAddAuto', data);
						if (ress.respCode === SUCCESS) {
							if(ress.data){
									this.model.nidgrp.bdb.name = ress.data.nam;
									this.model.nidgrp.bdb.nam = ress.data.nam;
									this.model.nidgrp.bdb.ptyinr = ress.data.ptyinr;
									this.model.nidgrp.bdb.ptainr = ress.data.ptainr;
									this.model.nidgrp.bdb.extkey =ress.data.extkey;
									this.model.nidgrp.bdb.rol = 'BDB';
									this.model.nidgrp.bdb.pts.extkey = ress.data.extkey;
									this.model.nidgrp.bdb.pts.rol = 'BDB';
									this.model.nidgrp.bdb.pts.ptainr = ress.data.ptainr;
									this.model.nidgrp.bdb.pts.ptyinr = ress.data.ptyinr;
									this.model.nidgrp.bdb.pts.cnnam = ress.data.namelc;
									this.model.nidgrp.bdb.pts.cnadr = ress.data.adrelc;
									this.model.nidgrp.bdb.pts.ennam = ress.data.namelc;
									this.model.nidgrp.bdb.pts.enadr = ress.data.adrelc
								}
						}
						if(this.model.nidgrp.adv && !this.model.nidgrp.adv.ptainr){
						// e结算或者云平台对通知行进行赋值操作
						let databic = {
							extkey: this.model.nidgrp.adv.pts.extkey,
							rol: 'adv'
						};
						let resbic = await Api.post('/business/nitopnRule/getDataByBicCode', databic);
						if (resbic.respCode === SUCCESS) {
							if(resbic.data){
									this.model.nidgrp.adv.nam = resbic.data.data.nam;
									this.model.nidgrp.adv.ptyinr = resbic.data.data.ptyinr;
									this.model.nidgrp.adv.ptainr = resbic.data.data.ptainr;
									this.model.nidgrp.adv.extkey =resbic.data.data.objkey;
									this.model.nidgrp.adv.rol = 'ADV';
									this.model.nidgrp.adv.pts.extkey = resbic.data.data.objkey;
									this.model.nidgrp.adv.pts.rol = 'ADV';
									this.model.nidgrp.adv.pts.ptainr = resbic.data.data.ptainr;
									this.model.nidgrp.adv.pts.ptyinr = resbic.data.data.ptyinr;
									this.model.nidgrp.adv.pts.ptytyp = resbic.data.data.ptytyp;
									this.model.nidgrp.adv.pts.nam = resbic.data.data.nam;
									if(this.model.nidgrp.rec.giduil && this.model.nidgrp.rec.giduil == 'CN'){
										this.model.nidgrp.adv.pts.adrblk = resbic.data.data.cnnamadr
									}else{
										this.model.nidgrp.adv.pts.adrblk = resbic.data.data.ennamadr
									}
								}
							}
					}
		   	}
				let extkey;
				if(this.model.nidgrp.rec.hndtyp !='OT'){
					extkey = this.model.nidgrp.apl.pts.extkey
				}else{
					extkey = this.model.nidgrp.ben.pts.extkey
				}
				let data = {
					extkey: extkey,
					deptNo: JSON.parse(sessionStorage.getItem('currentOrg')).departmentNumber,
					gartyp: this.model.nidgrp.rec.gartyp
				};
				let res = await Api.post('/business/nitopnRule/getStaPtsptaInfo', data);
				if (res.respCode === SUCCESS) {
					if(res.data && res.data.data){
						if(this.model.nidgrp.rec.hndtyp !='OT'){
							if(this.model.nidgrp.rec.giduil && this.model.nidgrp.rec.giduil == 'CN'){
								this.model.nidgrp.apl.name = res.data.data.nam1;
								this.model.nidgrp.apl.nam = res.data.data.nam1;
								this.model.nidgrp.apl.pts.nam = res.data.data.nam1
							}else{
								this.model.nidgrp.apl.name = res.data.data.nam;
								this.model.nidgrp.apl.nam = res.data.data.nam;
								this.model.nidgrp.apl.pts.nam = res.data.data.nam
							}
							this.model.nidgrp.apl.ptyinr = res.data.data.ptyinr;
							this.model.nidgrp.apl.ptainr = res.data.data.ptainr;
							this.model.nidgrp.apl.extkey =res.data.data.objkey;
							this.model.nidgrp.apl.rol = 'APL';
							this.model.nidgrp.apl.pts.extkey = res.data.data.objkey;
							this.model.nidgrp.apl.pts.rol = 'APL';
							this.model.nidgrp.apl.pts.ptainr = res.data.data.ptainr;
							this.model.nidgrp.apl.pts.ptyinr = res.data.data.ptyinr;
							this.model.nidgrp.apl.pts.ptynam1 = res.data.data.ptynam1;
							this.model.nidgrp.apl.pts.cnnam = res.data.data.cnnam;
							this.model.nidgrp.apl.pts.cnadr = res.data.data.cnadr;
							this.model.nidgrp.apl.pts.ennam = res.data.data.ennam;
							this.model.nidgrp.apl.pts.enadr = res.data.data.enadr
						}else{
							if(this.model.nidgrp.rec.giduil && this.model.nidgrp.rec.giduil == 'CN'){
								this.model.nidgrp.ben.name = res.data.data.nam1;
							  this.model.nidgrp.ben.nam = res.data.data.nam1;
								this.model.nidgrp.ben.pts.nam = res.data.data.nam1
							}else{
								this.model.nidgrp.ben.name = res.data.data.nam;
							  this.model.nidgrp.ben.nam = res.data.data.nam;
								this.model.nidgrp.ben.pts.nam = res.data.data.nam
							}
							this.model.nidgrp.ben.ptyinr = res.data.data.ptyinr;
							this.model.nidgrp.ben.ptainr = res.data.data.ptainr;
							this.model.nidgrp.ben.extkey = res.data.data.objkey;
							this.model.nidgrp.ben.rol = 'BEN';
							this.model.nidgrp.ben.pts.extkey = res.data.data.objkey;
							this.model.nidgrp.ben.pts.rol = 'BEN';
							this.model.nidgrp.ben.pts.ptainr = res.data.data.ptainr;
							this.model.nidgrp.ben.pts.ptyinr = res.data.data.ptyinr;
							this.model.nidgrp.ben.pts.ptynam1 = res.data.data.ptynam1;
							this.model.nidgrp.ben.pts.cnnam = res.data.data.cnnam;
							this.model.nidgrp.ben.pts.cnadr = res.data.data.cnadr;
							this.model.nidgrp.ben.pts.ennam = res.data.data.ennam;
							this.model.nidgrp.ben.pts.enadr = res.data.data.enadr
						}
					}
					
				}
			}
		},

			async loadData() {
				let params = {
					trninr: this.model.nidgrp.rec.beyzd5,
				};
				const loading = this.loading();
				const rtnmsg = await Api.post("/business/nitopnRule/getImgList", params);
				if (rtnmsg.respCode == SUCCESS) {
					this.$set(this.codes, 'imgdata', rtnmsg.data.imgList);
					this.$set(this.codes, 'imgvpbsdata', rtnmsg.data.imgvpbsList);
				}
				loading.close();
			},

			loadFdbFormatText(){
				if(!(this.model.nidgrp.rec.hndtyp == 'OC' && this.model.nidgrp.rec.beyzd3 == 'Y')){
					return
				}
				const loading = this.loading();
				Api.post(`/business/nitopnRule/getBeginAndEndData`).then(res => {
					loading.close();
					if (res.respCode === SUCCESS) {
						if(res.data){
							this.model.nitp.indirectswiaddc = res.data.beginGtx.gidtxt;
							this.$set(this.codes, 'indirectswiaddinr', res.data.beginGtx.inr);
							this.$set(this.codes, 'endtxt', res.data.endGtx.gidtxt);
							this.$set(this.codes, 'endinr', res.data.endGtx.inr);
						}
					}
				}).catch(() => {
					loading.close();
				});
			},

				// 如果是swift来报,pruposin是ISCO是,默认给开立方式赋值转开
				async setHndtypFromSwift(){
					if(this.model.nidgrp.rec.purposin && this.model.nidgrp.rec.purposin == 'ISCO'){
							 this.model.nidgrp.rec.hndtyp = 'OT';
							 // 给反担保行赋值
							 if(!(this.model.nidgrp.iss && this.model.nidgrp.iss.pts && this.model.nidgrp.iss.pts.ptainr)){
									 return
							 }
							 let data = {
								inr: this.model.nidgrp.iss.pts.ptainr,
								rol: 'iss'
							};
							let res = await Api.post('/business/ptspta/queryptsptainfo', data);
							if (res.respCode === SUCCESS) {
								if(res.data){
										this.model.nidgrp.iss.nam = res.data.nam;
										this.model.nidgrp.iss.ptyinr = res.data.ptyinr;
										this.model.nidgrp.iss.ptainr = res.data.ptainr;
										this.model.nidgrp.iss.extkey =res.data.objkey;
										this.model.nidgrp.iss.rol = 'ISS';
										this.model.nidgrp.iss.pts.extkey = res.data.objkey;
										this.model.nidgrp.iss.pts.rol = 'ISS';
										this.model.nidgrp.iss.pts.ptainr = res.data.ptainr;
										this.model.nidgrp.iss.pts.ptyinr = res.data.ptyinr;
										this.model.nidgrp.iss.pts.ptytyp = res.data.ptytyp;
										this.model.nidgrp.iss.pts.nam = res.data.nam;
										this.model.nidgrp.iss.pts.adrblk = res.data.ennamadr
									}
						}
					}
				},

		handleChangeFingua(e) {
			this.model.nidgrp.cbs.opn1.cur = this.model.nidgrp.cbs.max.cur;
			if (e === undefined) {
				return
			}
			if (this.model.nidgrp.rec.fingua != "Y") {
				this.model.nidgrp.rec.cfaguatyp = "";
				if(!(this.model.nidgrp.rec.hndtyp == 'OT' && this.model.nidgrp.cbs.max.cur == 'CNY')) {
          this.model.rmbbop.rmb2122.rmbflg = "2";
        }
        this.model.cfagit.cfaflg = "";
        this.model.cfagit.basflg = "";
        this.model.cfagit.dclflg = "";
			}
			if (this.model.nidgrp.cbs.max.cur == "CNY") {
				if (this.model.nidgrp.rec.fingua == "Y") {
					if(!(this.model.nidgrp.rec.hndtyp == 'OT' && this.model.nidgrp.cbs.max.cur == 'CNY')) {
            this.model.nidgrp.rec.cmtflg = "X";
          }
					// this.model.cfagit.cfaflg = "";
          // this.model.cfagit.basflg = "";
          // this.model.cfagit.dclflg = "";
				} else {
					if(!(this.model.nidgrp.rec.hndtyp == 'OT' && this.model.nidgrp.cbs.max.cur == 'CNY')) {
            this.model.nidgrp.rec.cmtflg = '';
          }
					this.model.nidgrp.rec.cfaguatyp = '';
				}
				this.defaultVouflgN1000(true);
			}else{
				if(!(this.model.nidgrp.rec.hndtyp == 'OT' && this.model.nidgrp.cbs.max.cur == 'CNY')) {
          this.model.nidgrp.rec.cmtflg = '';
        }
			}
			if (this.model.nidgrp.cbs.max.cur == "CNY") {
				if (this.model.nidgrp.rec.fingua == "Y") {
					if(this.model.nidgrp.rec.hndtyp != 'OT') {
            this.model.rmbbop.rmb2122.rmbflg = "1";
          }
				} else {
					if(this.model.nidgrp.rec.hndtyp != 'OT') {
            this.model.rmbbop.rmb2122.rmbflg = "2";
          }
				}
			} else if (this.model.nidgrp.cbs.max.cur != "CNY" && this.model.nidgrp.cbs.max.cur != "") {
				if (this.model.nidgrp.rec.fingua == "Y" && this.model.nidgrp.rec.cfaguatyp.slice(0, 2) == "11") {
					this.model.rmbbop.rmb2122.rmbflg = "1";
				} else {
					this.model.rmbbop.rmb2122.rmbflg = "2";
				}
			} else {
				this.model.rmbbop.rmb2122.rmbflg = "2";
      }
      if(this.model.cfagit) {
        this.model.cfagit.recgrp.bas.guarantype = this.model.nidgrp.rec.cfaguatyp;
      }
			this.calcName()
		},
		calcName() {
			if (this.model.nidgrp.cbs.max.amt == '') {
				this.model.nidgrp.cbs.max.amt = 0
			}
			this.model.nidgrp.cbs.opn1.amt = this.model.nidgrp.cbs.max.amt;
			let model = this.model;
			this.model.nidgrp.rec.nam = model.nidgrp.cbs.max.cur + " " +
				model.nidgrp.cbs.max.amt + " " +
				(model.nidgrp.rec.stacty || "") + "." +
				model.nidgrp.apl.pts.nam
		},
		changeCheckedStatus(e) {
			if (e === undefined) {
				return
			}
			if(this.model.nidgrp.rec.fingua == 'N'){
				// 2024/06版本受益人国别默认值只与是否对外担保有关
				this.model.nidgrp.rec.countrycod = 'CHN'
			}else{
				this.model.nidgrp.rec.countrycod = ''
			}
			if (this.model.nidgrp.rec.fingua == 'Y') {
				if(this.model.nidgrp.cbs.max.cur && this.model.nidgrp.cbs.max.cur == "CNY"){
					if(!(this.model.nidgrp.rec.hndtyp == 'OT' && this.model.nidgrp.cbs.max.cur == 'CNY')) {
            this.model.nidgrp.rec.cmtflg = 'X';
          }
				}else{
					if(!(this.model.nidgrp.rec.hndtyp == 'OT' && this.model.nidgrp.cbs.max.cur == 'CNY')) {
            this.model.nidgrp.rec.cmtflg = '';
          }
				}
			} else {
				if(!(this.model.nidgrp.rec.hndtyp == 'OT' && this.model.nidgrp.cbs.max.cur == 'CNY')) {
          this.model.nidgrp.rec.cmtflg = '';
        }
				this.model.nidgrp.rec.cfaguatyp = '';
			}

			if (this.model.nidgrp.cbs.max.cur == "CNY" && this.model.nidgrp.rec.fingua == 'Y') {
				this.model.cnybop.vouflg = '1';
				this.model.rmbbop.rmb2122.rmbflg = '1';
			} else {
				this.model.cnybop.vouflg = '2';
				this.model.rmbbop.rmb2122.rmbflg = '2';
			}
		},

		changeLinkData(e){
			if (e === undefined) {
				return
			}
			if(this.model.nidgrp.cbs.max.cur != "CNY" && this.model.nidgrp.rec.fingua == 'Y'){
        if((this.model.nidgrp.rec.cfaguatyp=='1101'
						|| this.model.nidgrp.rec.cfaguatyp=='1102' || this.model.nidgrp.rec.cfaguatyp=='1103' || this.model.nidgrp.rec.cfaguatyp=='1104'
						|| this.model.nidgrp.rec.cfaguatyp=='1105' || this.model.nidgrp.rec.cfaguatyp=='1106')){
							this.model.rmbbop.rmb2122.rmbflg = '1';
			}else{
				this.model.rmbbop.rmb2122.rmbflg = '2';
			}
		}
	},

		changeBlkApprultxtDate(e) {
			if (e === undefined) {
				return
			}
			if (this.model.nidgrp.blk.apprul != 'OTHR') {
				this.model.nidgrp.blk.apprultxt = ''
			}
		},
		clearData(e) {
			if (e === undefined) {
				return
			}
			if (this.model.nidgrp.rec.fenlishi == '') {
				this.$set(this.codes, 'judgeFlg', true);
				this.model.nidgrp.bdb.pts.enadr = "";
				this.model.nidgrp.bdb.pts.ennam = "";
				this.model.nidgrp.bdb.pts.cnadr = "";
				this.model.nidgrp.bdb.pts.cnnam = "";
				this.model.nidgrp.bdb.pts.extkey = "";
				this.model.nidgrp.bdb.pts.inr = "";
        this.model.nidgrp.rec.grtjuscod = "";
        this.root.$refs.modelForm.clearValidate('nidgrp.bdb.pts.cnnam');
			}else{
				this.$set(this.codes, 'judgeFlg', false);
			}
		},

		updateLinkData(e) {
			if (e === undefined) {
				return
			}
			if (this.model.nidgrp.rec.hndtyp == 'OC') {
				this.model.nidgrp.rec.liaflg = 'X';
			} else {
				this.model.nidgrp.rec.liaflg = '';
			}
			this.changeHndtyp(e);
		},
		changeValues() {
			let isHasModify = this.model.nidgrp.modifySet;
			if ((!isHasModify || (isHasModify && !isHasModify.includes('grtjuscod'))) && this.model.nidgrp.rec.grtjuscod == '' && this.model.warcreditcode != '' && this.model.nidgrp.rec.othersno == 'E0000003') {
				this.model.nidgrp.rec.grtjuscod = this.model.warcreditcode;
			} else {
				// this.model.nidgrp.rec.grtjuscod = '';
			}
		},
		//获取当前用户机构是否自贸区
		getZmqflg(){
			let _this = this;
			if (_this.model.nidgrp.rec.oppbnk !== "" && _this.model.nidgrp.rec.oppbnk !== undefined)//如果对手行有信息就设置X
				_this.model.zmqflg = "X";
			else
				_this.model.zmqflg = JSON.parse(window.sessionStorage.accbch).zmqflg;
			//赋值opbnk
			if(this.model.zmqflg === "X" && this.model.nidgrp.adv.pts.extkey !== "")
				this.model.nidgrp.rec.oppbnk = this.model.nidgrp.adv.pts.extkey.slice(0, 11);
		},
		// 数据采集标志--"cfagit.cfaflg"
		// onCfaflg() {
		// 	switch (this.model.cfagit.cfaflg) {
		// 		case "1":
		// 			this.model.cfagit.basflg = 'X';
		// 			this.model.cfagit.dclflg = 'X';
		// 			 if (!this.model.cfagit.ownextkey) {
		// 			   this.model.cfagit.ownextkey = this.codes.ownExtkeyList[0].branch;
		// 			 }
		// 			break;
		// 		case "2":
		// 			this.model.cfagit.basflg = 'X';
		// 			this.model.cfagit.dclflg = '';
		// 			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.cfaflg == "1") {
		// 		// this.queryCfap();
		// 	} else if (this.model.cfagit.cfaflg == "4" || this.model.cfagit.cfaflg == "") {
		// 		this.model.cfagit.ownextkey = "";
		// 	}
		// },
		// 无限额保函--nidgrp.rec.expflg 或者 nidgrp.rec.hndtyp
		changeExpflgOrHndtyp(e) {
			if (e === undefined) {
				return
			}
			if (this.model.nidgrp.rec.expflg == "X" && this.model.nidgrp.rec.hndtyp == "OC") {
				this.model.nidgrp.rec.liaflg = "X";
			}

			if (this.model.nidgrp.rec.hndtyp == 'OT') {
				this.model.nidgrp.rec.fingua = "N"
				// 修改校验规则nidgrp.rec.cxmflg
			} else {
				this.model.nidgrp.rec.fingua = ""
				// 修改校验规则nidgrp.rec.cxmflg
			}

			if (this.model.nidgrp.rec.hndtyp != 'OT' || this.model.nidgrp.rec.gartyp == 'F') {
				this.model.nidgrp.rec.iscrotra = ''
			}
		},
		clearExpdatValues() {
			let businessType = this.$route.query.businessType;
			if(!businessType){
				if(this.model.nidgrp.rec.hndtyp && this.model.nidgrp.rec.hndtyp != 'OC'){
					if (this.model.nidgrp.rec.expflg == 'X') {
						this.model.addbcb.bccls1 = 'Y'
					}
					if (this.model.nidgrp.rec.expflg == '') {
						this.model.addbcb.bccls1 = 'N'
					}
				}
				if(this.model.nidgrp.rec.hndtyp && this.model.nidgrp.rec.hndtyp == 'OC'){
					if (this.model.nidgrp.rec.liaflg == 'X') {
						this.model.addbcb.bccls1 = 'Y'
					}
					if (this.model.nidgrp.rec.liaflg == '') {
						this.model.addbcb.bccls1 = 'N'
					}
				}
			}
			if (this.model.nidgrp.rec.expflg == 'X') {
				this.model.nidgrp.rec.expdat = "";
				if(this.model.nidgrp.rec.hndtyp == 'OC'){
          this.model.nidgrp.rec.liaflg = "X";
          this.model.nidgrp.rec.liadat = "";
				}
			}else{
				if(this.model.nidgrp.rec.hndtyp == 'OC'){
					this.model.nidgrp.rec.liaflg = ""
				}
			}
				
		},

		compareData(e) {
			if(this.model.nidgrp.rec.hndtyp && this.model.nidgrp.rec.hndtyp == 'OC'){
				this.model.addbcb.expdat = this.model.nidgrp.rec.liadat
			}else{
			  this.model.addbcb.expdat = this.model.nidgrp.rec.expdat
			}
			if(e){
				if (moment(this.model.nidgrp.rec.expdat).diff(moment(this.model.nidgrp.rec.opndat), 'hours') < 0) {
					this.$nextTick(() => {
						this.root.$refs['modelForm'].validateField(['nidgrp.rec.expdat']);
					})
				}
				if (moment(this.model.nidgrp.rec.expdat).diff(moment(this.model.nidgrp.rec.liadat), 'hours') > 0) {
					this.$nextTick(() => {
						this.root.$refs['modelForm'].validateField(['nidgrp.rec.liadat']);
					})
				}
			}
		//	if(e == undefined && !this.model.nidgrp.rec.expdat){
		//		this.model.nidgrp.rec.expdat = this.model.nidgrp.rec.opndat
		//	}
		//	this.model.addbcb.expdat = this.model.nidgrp.rec.expdat
		//	if(!this.isInDisplay){
		//		this.model.nidgrp.rec.needcuscomopn =''
		//	}
	//		if (this.model.nidgrp.rec.hndtyp == 'OC' && this.model.nidgrp.rec.liaflg == "") {
	//			this.model.nidgrp.rec.liadat = moment(this.model.nidgrp.rec.expdat).add(14, 'day').format('YYYY-MM-DD')
	//		}
		},
		setOtherData(e) {
			if(this.model.nidgrp.rec.hndtyp && this.model.nidgrp.rec.hndtyp == 'OL'){
				this.model.nidgrp.rec.liaflg = '';
				this.model.nidgrp.rec.liadat = ''
			}
			if(e == undefined && !this.model.nidgrp.rec.inudat){
				this.model.nidgrp.rec.inudat = moment(new Date()).format('YYYY-MM-DD');
			 }
			this.model.nidgrp.rec.inudat = moment(new Date()).format('YYYY-MM-DD');
			this.model.nidgrp.rec.orddat = moment(this.model.nidgrp.rec.opndat).format('YYYY-MM-DD');
		},
	//	clearInudatData(){
	//		if(this.model.nidgrp.rec.segtyp == ''){
	//			this.model.nidgrp.rec.inudat = '';
	//		}else{
	//			this.model.nidgrp.rec.inudat = moment(new Date()).format('YYYY-MM-DD');
	//		}
	//	},
		compareDataAfterData(e) {
			if (e === undefined) {
				return
			}
			if (moment(this.model.nidgrp.rec.inudat).diff(moment(this.model.nidgrp.rec.opndat), 'days') < 0) {
				this.$confirm('保函生效日期不得早于保函开立日期', '提示', {
					type: 'warning',
				});
				this.model.nidgrp.rec.inudat = moment(new Date()).format('YYYY-MM-DD');
			}
			if (moment(this.model.nidgrp.rec.inudat).diff(moment(new Date()), 'days') > 30) {
				this.$confirm('保函生效日已超过30天,请再次确认输入日期是否合理', '提示', {
					type: 'warning',
				});
			}
		},
		defaultVouflgN1000(e) {
			if (e === undefined) {
				return
			}
			//--暂时只有保函开立交易用--
			//2017-4人行 要求2122对保函开立交易开放外币申报
			if (this.model.nidgrp.cbs.max.cur == "CNY") {
				if (this.model.nidgrp.rec.cmtflg != "") {
          if(this.model.nidgrp.rec.hndtyp == 'OT') {
            this.model.rmbbop.rmb2122.rmbflg = "1"
          }
					this.model.cnybop.vouflg = "1"
				} else {
          if(this.model.nidgrp.rec.hndtyp == 'OT') {
            this.model.rmbbop.rmb2122.rmbflg = "2"
          }
					this.model.cnybop.vouflg = "2"
				}
			}
			else {
				if (this.model.nidgrp.rec.fingua == "Y") {
					this.model.cnybop.vouflg = "1"
				} else {
					this.model.cnybop.vouflg = "2"
				}
			}
		},
		clearLiadatData(e) {
			if (e === undefined) {
				return
			}
			if(this.model.nidgrp.rec.hndtyp && this.model.nidgrp.rec.hndtyp == 'OC'){
				if (this.model.nidgrp.rec.liaflg == 'X') {
					this.model.addbcb.bccls1 = 'Y'
				}
				if (this.model.nidgrp.rec.liaflg == '') {
					this.model.addbcb.bccls1 = 'N'
				}
			}
			if (this.model.nidgrp.rec.liaflg == "X") {
				this.model.nidgrp.rec.liadat = ''
			} 
		//	else {
		//		if (this.model.nidgrp.rec.expdat) {
		//			this.model.nidgrp.rec.liadat = moment(this.model.nidgrp.rec.expdat).add(14, 'day').format('YYYY-MM-DD')
		//		}
		//	}
		},

		// 受益人调用方法
		async getBilvvvDatas(e) {
			if(e && (e.rowData.ptaobjkey !=this.codes.judgementTypes) && this.model.nidgrp.rec.hndtyp && this.model.nidgrp.rec.hndtyp == 'OT'){
				this.model.nidgrp.rec.ownref = ""
			}
			if (this.model.nidgrp.apl.pts.extkey != '' || this.model.nidgrp.ben.pts.extkey != '') {
				let datas = {
					transName: 'NITOPN',
					hndtyp: this.model.nidgrp.rec.hndtyp,
					apl: this.model.nidgrp.apl.pts.ptainr,
					ben: this.model.nidgrp.ben.pts.ptainr
				};
				let resc = await Api.post('/business/nitopnRule/getExcepCustomer', datas);
				if (resc.respCode === SUCCESS) {
					this.$set(this.codes, 'excepData', resc.data);
				}
			}
			if(e){
			this.$set(this.codes, 'judgementTypes', e.rowData.ptaobjkey);
			if(this.model.nidgrp.rec.gartyp && this.model.nidgrp.rec.gartyp == 'F' && this.model.nidgrp.rec.segtyp && this.model.nidgrp.rec.segtyp == '01'
			&& (this.model.nidgrp.ben && this.model.nidgrp.ben.pts.extkey && this.model.nidgrp.ben.pts.extkey!='2216' && this.model.nidgrp.ben.pts.extkey!='2218' && this.model.nidgrp.ben.pts.extkey!='2246' && this.model.nidgrp.ben.pts.extkey!='2249')){
				this.$alert(`输入的受益人不在"2216","2218","2246","2249"之中,请确保输入的受益人支持上海自贸区海关保函!`, '错误', {
					confirmButtonText: '确定',
					callback: action=>{
           // 清空受益人信息
						  this.model.nidgrp.ben.ptyinr = '';
							this.model.nidgrp.ben.ptainr = '';
							this.model.nidgrp.ben.extkey = '';
							this.model.nidgrp.ben.pts.extkey = '';
							this.model.nidgrp.ben.pts.ptainr = '';
							this.model.nidgrp.ben.pts.ptyinr = '';
							this.model.nidgrp.ben.pts.ptynam1 = '';
							this.model.nidgrp.ben.pts.cnnam = '';
							this.model.nidgrp.ben.pts.cnadr = '';
							this.model.nidgrp.ben.pts.ennam = '';
							this.model.nidgrp.ben.pts.enadr = ''
					}
        });

			}
			}
		},

		// 申请人调用方法
		async getBilvvvData(e) {
			if(e && (e.rowData.ptaobjkey !=this.codes.judgementType) && this.model.nidgrp.rec.hndtyp && (this.model.nidgrp.rec.hndtyp == 'OL' || this.model.nidgrp.rec.hndtyp == 'OC')){
				this.model.nidgrp.rec.ownref = ""
			}
			if (this.model.nidgrp.apl.pts.extkey != '' || this.model.nidgrp.ben.pts.extkey != '') {
				let datas = {
					transName: 'NITPOP',
					hndtyp: this.model.nidgrp.rec.hndtyp,
					apl: this.model.nidgrp.apl.pts.ptainr,
					ben: this.model.nidgrp.ben.pts.ptainr
				};
				let resc = await Api.post('/business/nitopnRule/getExcepCustomer', datas);
				if (resc.respCode === SUCCESS) {
					this.$set(this.codes, 'excepData', resc.data);
				}
				let data = {
					hndtyp: this.model.nidgrp.rec.hndtyp,
					aplExtkey: this.model.nidgrp.apl.pts.extkey
				};
				let res = await Api.post('/business/nitopnRule/havePermissionToEdit', data);
				if (res.respCode === SUCCESS) {
					this.$set(this.codes, 'permissionToEdit', res.data);
				}
			}
			if(e){
			this.$set(this.codes, 'judgementType', e.rowData.ptaobjkey);
			}
		},

		clearDeleteData(e) {
			if (e === undefined) {
				return
			}
			if (this.model.nidgrp.apl.pts.extkey == "") {
				this.model.nidgrp.apl.pts.nam = "";
				this.model.nidgrp.apl.pts.adrblk = "";
				this.model.nidgrp.apl.pts.ptainr = "";
				if(this.model.nidgrp.rec.hndtyp == 'OL' || this.model.nidgrp.rec.hndtyp == 'OC'){
					this.model.nidgrp.rec.ownref = ""
					}
			}
			if (this.model.nidgrp.ctr.pts.extkey == "") {
				this.model.nidgrp.ctr.pts.nam = "";
				this.model.nidgrp.ctr.pts.adrblk = ""
			}
			if (this.model.nidgrp.bdb.pts.extkey == "") {
				this.model.nidgrp.bdb.pts.nam = "";
				this.model.nidgrp.bdb.pts.adrblk = ""
			}
			if (this.model.nidgrp.ben.pts.extkey == "") {
				this.model.nidgrp.ben.pts.nam = "";
				this.model.nidgrp.ben.pts.adrblk = "";
				if(this.model.nidgrp.rec.hndtyp == 'OT'){
					this.model.nidgrp.rec.ownref = ""
				}
			}
			if (this.model.nidgrp.iss.pts.extkey == "") {
				this.model.nidgrp.iss.pts.nam = "";
				this.model.nidgrp.iss.pts.adrblk = ""
			}
			if (this.model.nidgrp.adv.pts.extkey == "") {
				this.model.nidgrp.adv.pts.nam = "";
				this.model.nidgrp.adv.pts.adrblk = ""
			}
			this.$set(this.codes, 'permissionToEdit', '');
		},

		// 保函种类--nidgrp.rec.gartyp
		async changeGartyp(e) {
      this.updateOwnref();
			let m24infcpy;
			let m22amecnt;
			let msgtyp;
			let othersno;
			if(this.model.swiadd && this.model.swiadd.m24infcpy){
				m24infcpy = this.model.swiadd.m24infcpy
			}else{
				m24infcpy =''
			}
			if(this.model.swiadd && this.model.swiadd.m22amecnt){
				m22amecnt = this.model.swiadd.m22amecnt
			}else{
				m22amecnt =''
			}
			if(this.$route.query.msgtyp){
				msgtyp = this.$route.query.msgtyp
			}else{
				msgtyp = ''
			}
			if(this.model.nidgrp.rec && this.model.nidgrp.rec.othersno){
				othersno = this.model.nidgrp.rec.othersno
			}else{
				othersno =''
			}
			if(e && this.model.nidgrp.blk.modifySet){
        this.model.nidgrp.blk.modifySet = this.model.nidgrp.blk.modifySet.filter(key=>key!='gidtxt')
      }
      if(!e && !this.model.nidgrp.rec.gtxinr && this.model.nidgrp.blk.modifySet && this.model.nidgrp.blk.modifySet.includes('gidtxt')){
        //初始化时,如保函文本是修改过的,且并没有报函文本模板inr,则不要再变化了 
        return
      }
      
			let data = {
				gartyp: this.model.nidgrp.rec.gartyp,
				hndtyp: this.model.nidgrp.rec.hndtyp,
				gtxinr: this.model.nidgrp.rec.gtxinr,
				giduil: this.model.nidgrp.rec.giduil,
				segtyp: this.model.nidgrp.rec.segtyp,
				objextkey: JSON.parse(sessionStorage.getItem('currentOrg')).departmentNumber,
				trntyp: 'GNBH',
				fromflg: this.model.nidgrp.rec.fromflg,
				m24infcpy: m24infcpy,
				m22amecnt: m22amecnt,
				objinr: this.model.trnmod.swiadd.objinr || "",
				msgtyp: msgtyp,
				gidtxt: this.model.nidgrp.blk.gidtxt,
				othersno: othersno
			};
			const loading = this.loading();
			let res = await Api.post('/business/gitopn/defaultGidgrpRecGtxinrN1000FromGtx', data);
			loading.close();
			if (res.respCode === SUCCESS) {
				if (res.data && res.data.length > 0) {
					if (!this.isInDisplay) {
						// 判断当前gtxinr是否在下拉列表中存在,如果存在就不需要在默认赋值为第一项
							let hasCurGtxinr = res.data.some((item) =>{
								return item.value === this.model.nidgrp.rec.gtxinr
							});
							if (!hasCurGtxinr) {
								this.model.nidgrp.rec.gtxinr = res.data[0].value;
								this.model.nitp.lettername = res.data[0].label.split('-')[0];
								if (e !== undefined || !this.model.nidgrp.blk.gtxgidtxt) {
									this.model.nidgrp.blk.gtxgidtxt = res.data[0].atxtxt;
									this.model.nidgrp.blk.gidtxt = res.data[0].atxtxt
								}
								// 备份字段
								this.$set(this.codes, 'gtxgidtxtMark', res.data[0].atxtxt);
								this.getConfigData(this.model.nidgrp.rec.gtxinr)
							}
							// 针对来报而言,查询密文模板
							if(this.model.nidgrp.rec.gtxinr && !this.model.nidgrp.blk.gidtxtmw && this.model.nidgrp.rec.othersno && (this.model.nidgrp.rec.othersno =='E0000009'
              || this.model.nidgrp.rec.othersno =='E0000016' || this.model.nidgrp.rec.othersno =='E0000017' || this.model.nidgrp.rec.othersno =='E0000020'
              || this.model.nidgrp.rec.othersno == 'E0000024')){
								let datas = {
									gtxinr: this.model.nidgrp.rec.gtxinr,
								};
								const loading = this.loading();
								let mres = await Api.post('/business/nitopnRule/getMiwenData', datas);
								loading.close();
								if (mres.respCode === SUCCESS) {
									if (mres.data && mres.data.data) {
										this.model.nidgrp.rec.gtxinrmw = mres.data.data.inr;
										this.model.nidgrp.blk.gtxgidtxtmw = mres.data.data.gidtxt
									}
								}
							}
					}
				}else{
					this.model.nidgrp.rec.gtxinr = "";
					this.model.nitp.lettername = "";
					if (e !== undefined || !this.model.nidgrp.blk.gtxgidtxt) {
						this.model.nidgrp.blk.gtxgidtxt = "";
						if(!(msgtyp && msgtyp==='760')){
							this.model.nidgrp.blk.gidtxt = ''
							}
					}
					// 备份字段
					this.$set(this.codes, 'gtxgidtxtMark', '');
					this.getConfigData(this.model.nidgrp.rec.gtxinr)
				}
				this.$set(this.codes, 'atxinrList', res.data);
			}
		},
		async changeGiduil(e) {
			if (e === undefined) {
				return
			}
			this.model.nidgrp.rec.gtxinr = '';
			// 保函文本语言发生修改,调用事件
			if (!this.model.nidgrp.rec.giduil1) {
				this.$confirm('是否确定要更换保函语种?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning',
				}).then(async () => {
					if(this.model.nidgrp.rec.hndtyp == 'OC'){
						this.getindirectswiadd();
					}
					let m24infcpy;
					let m22amecnt;
					let msgtyp;
					let othersno;
					if(this.model.swiadd && this.model.swiadd.m24infcpy){
						m24infcpy = this.model.swiadd.m24infcpy
					}else{
						m24infcpy =''	
					}
					if(this.model.swiadd && this.model.swiadd.m22amecnt){
						m22amecnt = this.model.swiadd.m22amecnt
					}else{
						m22amecnt =''
					}
					if(this.model.nidgrp.rec && this.model.nidgrp.rec.othersno){
						othersno = this.model.nidgrp.rec.othersno
					}else{
						othersno =''
					}
					if(this.$route.query.msgtyp){
						msgtyp = this.$route.query.msgtyp
					}else{
						msgtyp = ''
					}
					let data = {
						gartyp: this.model.nidgrp.rec.gartyp,
						hndtyp: this.model.nidgrp.rec.hndtyp,
						gtxinr: this.model.nidgrp.rec.gtxinr,
						giduil: this.model.nidgrp.rec.giduil,
						segtyp: this.model.nidgrp.rec.segtyp,
						objextkey: JSON.parse(sessionStorage.getItem('currentOrg')).departmentNumber,
						trntyp: 'GNBH',
						fromflg: this.model.nidgrp.rec.fromflg,
						m24infcpy: m24infcpy,
						m22amecnt: m22amecnt,
						objinr: this.model.trnmod.swiadd.objinr || "",
						msgtyp: msgtyp,
						gidtxt: this.model.nidgrp.blk.gidtxt,
						othersno: othersno
					};
					const loading = this.loading();
					let res = await Api.post('/business/gitopn/defaultGidgrpRecGtxinrN1000FromGtx', data);
					loading.close();
					if (res.respCode === SUCCESS) {
						this.$set(this.codes, 'atxinrList', res.data);
						if (res.data.length>0){
							this.model.nidgrp.rec.gtxinr=res.data[0].value;
							this.changeAtxinr(this.model.nidgrp.rec.gtxinr)
						}
					}
				}).catch(() => {
					this.model.nidgrp.rec.giduil = this.model.nidgrp.rec.giduil;
					if(this.model.nidgrp.rec.hndtyp == 'OC'){
						this.getindirectswiadd();
					}
				})
			}
		},
		changeAtxinr(e) {
			if (!e) {
				return
			}
			this.model.nidgrp.blk.gtxgidtxt = "";
      this.model.nidgrp.blk.gidtxt = "";
      if(this.model.nidgrp.blk.modifySet){
        this.model.nidgrp.blk.modifySet = this.model.nidgrp.blk.modifySet.filter(key=>key!='gidtxt')
      }
			for (let item of this.codes.atxinrList) {
				if (e === item.value) {
					this.model.nitp.lettername = item.label.split('-')[0];
					this.model.nidgrp.blk.gtxgidtxt = item.atxtxt;
					this.model.nidgrp.blk.gidtxt = item.atxtxt;
					// 备份字段
					this.$set(this.codes, 'gtxgidtxtMark', item.atxtxt)
				}
			}
			this.getConfigData()
		},
		async getConfigData() {
			if (!this.model.nidgrp.rec.gtxinr) {
				return;
			}
			let params = {
				objinr: this.model.nidgrp.rec.gtxinr,
				objtyp: 'gtx'
			};
			const loading = this.loading();
			let res = await Api.post("/manager/gtxUse/listGidTmplVar", params);
			if (res.respCode == SUCCESS) {
				let list = [];
				res.data.map((item) => {
					if (item.showflg === 'Y') {
						list.push(item);
						if (this.model.textTempData && !this.model.textTempData[`#${item.cod}`]) {
							this.$set(this.model.textTempData, `#${item.cod}`, '')
						}
					}
				});
				this.$set(this.codes, 'frameList', list)
			} else {
				this.$notify.error({ title: "错误", message: "服务请求失败!" });
			}
			loading.close();
		},
		// 获取文本语言
		async getGidUil() {
			let data = {
				dbcode: 'uiltxt',
				valueList: 'CN,EN'
			};
			const loading = this.loading();
			let res = await Api.post('/business/nitopnRule/getCodeTableExplame', data);
			loading.close();
			if (res.respCode === SUCCESS) {
				this.$set(this.codes, 'giduilList', res.data);
			}
		},

		setApplyInfo(){
			// 给统一名单页面赋值 交易对手名称
			// if (this.model.nidgrp.rec.hndtyp == 'OT') {
			// 	if (this.model.nidgrp.apl && this.model.nidgrp.apl.pts) {
			// 		this.model.umdmod.bennam = this.model.nidgrp.apl.pts.nam
			// 	}
			// }
			// if (this.model.nidgrp.rec.hndtyp != 'OT') {
			// 	if (this.model.nidgrp.ben && this.model.nidgrp.ben.pts) {
			// 		this.model.umdmod.bennam = this.model.nidgrp.ben.pts.nam
			// 	}
			// }
		},
		// 获取记账机构下拉列表
		async queryOrgList() {
			const loading = this.loading();
			let res = await Api.post('/business/userinfo/user/getAccBchList');
			loading.close();
			if (res.respCode === SUCCESS) {
				let markOrgList = res.data;
				let tempData = {};
				if (markOrgList && markOrgList.length > 0) {
					this.model.nidgrp.rec.bchkeyinr = markOrgList[0].inr;
					tempData = markOrgList[0]
				}
				let isHasModify = this.model.nidgrp.modifySet;
				if (!isHasModify || (isHasModify && !isHasModify.includes('dbyhmc'))) {
					if(this.model.nidgrp.rec.dbyhmc == undefined || this.model.nidgrp.rec.dbyhmc == ''){
						this.model.nidgrp.rec.dbyhmc = tempData.bchname;
					}
				}
				if (!isHasModify || (isHasModify && !isHasModify.includes('dbyhdz'))) {
					this.model.nidgrp.rec.dbyhdz = tempData.adr;
				}
				if (!isHasModify || (isHasModify && !isHasModify.includes('dbyhdh'))) {
					this.model.nidgrp.rec.dbyhdh = tempData.tel;
				}
				this.$set(this.codes, 'markOrgList', markOrgList)
			}
    },
    // 获取客户经理信息
     async getResponsibleUser() {
       const loading = this.loading();
       let res = await Api.post('/business/nitopnRule/getResponseiblePeople');
       loading.close();
       if (res.respCode === SUCCESS) {
		 		if(this.model.nitp.usr.extkey == undefined || this.model.nitp.usr.extkey == ''){
		 		this.model.nitp.usr.extkey = res.data;
		 		}
		// 		let isHasModify = this.model.nidgrp.modifySet;
		// 		if (!isHasModify || (isHasModify && !isHasModify.includes('nidgrp.rec.dbyhdz'))) {
		// 			this.model.nidgrp.rec.dbyhdz = this.markOrgList[0].adr;
		// 		}
		// 		if (!isHasModify || (isHasModify && !isHasModify.includes('nidgrp.rec.dbyhdh'))) {
		// 			this.model.nidgrp.rec.dbyhdh = this.markOrgList[0].tel;
		// 		}
		 	}
		 },

		// 获取数据采集标志数据
		async getCfaflgData() {
			let data = {
				dbcode: 'cfaflg',
				transName: 'NITOPN'
			};
			const loading = this.loading();
			let res = await Api.post('/business/nitopnRule/getCodeTableByCondition', data);
			loading.close();
			if (res.respCode === SUCCESS) {
				this.markOrgList = res.data;
			}
		},

		// 获取开立方式
		async getHndtypData() {
			let data = {
				dbcode: 'hndtyp',
				transName: 'NITOPN'
			};
			const loading = this.loading();
			let res = await Api.post('/business/nitopnRule/getHndtypData', data);
			loading.close();
			if (res.respCode === SUCCESS) {
				this.$set(this.codes, 'hndtypList', res.data)
			}
		},
		//获取上收标识
		async getSdhflg() {
			let data = {
				trninr: this.$route.query.businessInr,
				type: this.$route.query.businessType
			};
			const loading = this.loading();
			let res = await Api.post('/business/nitopnRule/getSndflgData',data);
			loading.close();
			if (res.respCode === SUCCESS) {
				this.$set(this.codes, 'sndflgJudgement', res.data);
			}
		},

			// 获取可以盖章的银行信息
			async getGaiZhangBranchInfo() {
				const loading = this.loading();
				let res = await Api.post('/business/nitopnRule/getGaiZhangBranchInfo');
				loading.close();
				if (res.respCode === SUCCESS) {
					this.$set(this.codes,'bchlistVo',res.data)
				}
			},

		// 需用户确认有条件显示
		async judgementNeedCustomerButtonShow() {
			let trninr;
			if(this.$route.query.businessInr){
				trninr = this.$route.query.businessInr
			}else{
				trninr = ''
			}
			let type;
			if(this.$route.query.businessType){
				type = this.$route.query.businessType
			}else{
				type = ''
			}
			let data = {
				extkey: JSON.parse(sessionStorage.getItem('currentOrg')).departmentNumber,
				trninr: trninr,
				type: type
			};
			const loading = this.loading();
			let res = await Api.post('/business/nitopnRule/judgementNeedCustomerButtonShow', data);
			loading.close();
			if (res.respCode === SUCCESS) {
				this.$set(this.codes, 'buttonShow', res.data);
			}
		},

		// 获取地区机构号
		async getOwnExtkeyCondition() {
			const loading = this.loading();
			let res = await Api.post('/business/nitopnRule/getOwnExtkeyCondition');
			loading.close();
			if (res.respCode === SUCCESS) {
				this.$set(this.codes, 'ownExtkeyList', res.data);
			}
    },
    
	  // 获取反担保保函附加条款
	  async getindirectswiadd() {
			if(!(this.model.nidgrp.rec && this.model.nidgrp.rec.hndtyp == 'OC')){
				return
    	}
			let giduil;
			if(!this.model.nidgrp.rec.giduil){
				giduil = ''
			}else{
        giduil = this.model.nidgrp.rec.giduil
			}
			let params = {
				giduil: giduil
			};
	  	const loading = this.loading();
	  	let res = await Api.post('/business/nitopnRule/getInDirectSwiAdd',params);
	  	loading.close();
	  	if (res.respCode === SUCCESS) {
				if(res.data){
						this.model.nitp.indirectswiaddc = res.data.gidtxt;
						this.$set(this.codes, 'indirectswiaddinr', res.data.inr);
				}
	  	}
	  },
		//开立方式
		changeHndtyp(e) {
			if (e === undefined) {
				return
			}
			if(this.model.nidgrp.rec.hndtyp == 'OL'){
				if(this.model.nidgrp.rec.fingua == 'N'){
					this.model.nidgrp.rec.countrycod = 'CHN'
				}else{
					this.model.nidgrp.rec.countrycod = ''
				}
			}
			if(e && e!='OC'){
				this.model.nitp.indirectswiadd = '';
        this.model.nitp.indirectswiaddc = '';
			}
			let beforeData;
			if((e == 'OT' && this.codes.beforeHndtyp !=undefined && (this.codes.beforeHndtyp !='OT'))
			|| (e != 'OT' && this.codes.beforeHndtyp !=undefined && (this.codes.beforeHndtyp =='OT'))){
				beforeData = this.codes.beforeHndtyp;
				this.$confirm('是否切换开立方式?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning',
				}).then(() => {
					if(this.model.nidgrp.rec.hndtyp == 'OL' && this.model.nidgrp.rec.fingua == 'N'){
						this.model.nidgrp.rec.countrycod = 'CHN'
					}else{
						this.model.nidgrp.rec.countrycod = ''
          }
          if(this.model.rmbbop && this.model.rmbbop.rmb2122) {
            if(this.model.nidgrp.rec.fingua == 'Y' && this.model.nidgrp.rec.hndtyp != 'OT' && this.model.nidgrp.cbs.max.cur == 'CNY') {
              this.model.nidgrp.rec.cmtflg = 'X'
            } else {
              this.model.nidgrp.rec.cmtflg = ''
            }
            this.model.rmbbop.rmb2122.rmbflg = '2';
          }
						this.model.nidgrp.rec.ownref = "";
						this.model.nidgrp.rec.fenlishi = '';
						this.model.nidgrp.apl.pts.ref = "";
						this.model.nidgrp.apl.pts.extkey = "";
						this.model.nidgrp.apl.pts.nam = "";
						this.model.nidgrp.apl.pts.adrblk = "";
						this.model.nidgrp.apl.pts.ptainr = "";
						this.model.nidgrp.ben.pts.ref = "";
						this.model.nidgrp.ben.pts.extkey = "";
						this.model.nidgrp.ben.pts.nam = "";
						this.model.nidgrp.ben.pts.adrblk = "";
						this.model.nidgrp.apl.pts.cnadr = "";
						this.model.nidgrp.apl.pts.cnnam = "";
						this.model.nidgrp.apl.pts.enadr = "";
						this.model.nidgrp.ben.pts.ptainr = "";
						this.model.nidgrp.apl.pts.ennam = "";
						this.model.nidgrp.ben.pts.cnadr = "";
						this.model.nidgrp.ben.pts.cnnam = "";
						this.model.nidgrp.ben.pts.enadr = "";
						this.model.nidgrp.ben.pts.ennam = "";
						this.$set(this.codes, 'permissionToEdit', '');
					if (this.model.nidgrp.rec.hndtyp != 'OC') {
						this.model.nidgrp.rec.liadat = '';
						this.model.nidgrp.rec.liaflg = '';
						this.model.nidgrp.ctr.pts.adrblk = '';
						this.model.nidgrp.ctr.pts.extkey = ''
					} else {
						//获取反担保保函附加条款
						this.getindirectswiadd();
				//		if (this.model.nidgrp.rec.expdat) {
				//			this.model.nidgrp.rec.liadat = moment(this.model.nidgrp.rec.expdat).add(14, 'day').format('YYYY-MM-DD')
				//		}
					}
					let currentOrg = JSON.parse(sessionStorage.getItem("currentOrg")).level;
					if (this.model.nidgrp.rec.hndtyp == 'OC' && currentOrg == '1') {
						this.getPtsptaInfo(e)
					}
				}).catch(() => {
					this.model.nidgrp.rec.hndtyp = beforeData;
					if (this.model.nidgrp.rec.hndtyp != 'OC') {
						this.model.nidgrp.rec.liadat = '';
						this.model.nidgrp.rec.liaflg = '';
						this.model.nidgrp.ctr.pts.adrblk = '';
						this.model.nidgrp.ctr.pts.extkey = ''
					} else {
						//获取反担保保函附加条款
						this.getindirectswiadd();
			//			if (this.model.nidgrp.rec.expdat) {
			//				this.model.nidgrp.rec.liadat = moment(this.model.nidgrp.rec.expdat).add(14, 'day').format('YYYY-MM-DD')
			//			}
					}
					let currentOrg = JSON.parse(sessionStorage.getItem("currentOrg")).level;
					if (this.model.nidgrp.rec.hndtyp == 'OC' && currentOrg == '1') {
						this.getPtsptaInfo(e)
          }
					this.$set(this.codes, 'beforeHndtyp', beforeData);
				})
			}else{
				if (this.model.nidgrp.rec.hndtyp != 'OC') {
					this.model.nidgrp.rec.liadat = '';
					this.model.nidgrp.rec.liaflg = '';
					this.model.nidgrp.ctr.pts.adrblk = '';
					this.model.nidgrp.ctr.pts.extkey = ''
				} else {
					//获取反担保保函附加条款
					this.getindirectswiadd();
			//		if (this.model.nidgrp.rec.expdat) {
			//			this.model.nidgrp.rec.liadat = moment(this.model.nidgrp.rec.expdat).add(14, 'day').format('YYYY-MM-DD')
			//		}
				}
				let currentOrg = JSON.parse(sessionStorage.getItem("currentOrg")).level;
				if (this.model.nidgrp.rec.hndtyp == 'OC' && currentOrg == '1') {
					this.getPtsptaInfo(e)
				}
      }
      this.$set(this.codes, 'beforeHndtyp', e);
		},
		async getPtsptaInfo(e) {
			if (e === undefined) {
				return
			}
			let data = {
				bchbranch: JSON.parse(sessionStorage.getItem("currentOrg")).departmentNumber
			};
			let res = await Api.post('/business/ptspta/getPtsptaInfo', data);
			if (res.respCode === SUCCESS) {
				this.model.nidgrp.ctr.pts.extkey = res.data.ptaobjkey;
				this.model.nidgrp.ctr.pts.adrblk = res.data.cnnamadr;
				this.model.nidgrp.ctr.pts.rol = 'CTR';
				this.model.nidgrp.ctr.pts.ptainr = res.data.ptainr
			}
		},

		async loadBopCtyList() {
			const loading = this.loading();
			let res = await Api.post('/business/gitopn/loadBopCtyList');
			loading.close();
			if (res.respCode === SUCCESS) {
				this.model.bopCtyList = res.data;
			}
		},

		// 获取币种
		async getCurtxtFromStb() {
			let data = {
				dbcode: 'curtxt',
				uil: 'EN',
				transName: 'NITOPN'
			};
			const loading = this.loading();
			let res = await Api.post('/business/nitopnRule/getCurTxtFromStb', data);
			loading.close();
			if (res.respCode === SUCCESS) {
				this.$set(this.codes, 'curtxtList', res.data);
			}
    },
    //暂存开立日期更新
    // setSptOpnDate(){
    //   if(!this.$route.query.type && this.$route.query.businessType==='SPT'){
    //     this.model.nidgrp.rec.opndat = moment(new Date()).format('YYYY-MM-DD');
    //   }
    // },
	},
}