import commonFunctions from '~/mixin/commonFunctions.js';
import Utils from "~/utils";
import Pts from '~/components/business/commonModel/Pts';
export default {
	mixins: [commonFunctions],
	methods: {
		calcName() {
			this.model.ncdgrp.rec.nam = this.model.ncdgrp.cbs.max.cur + " " + this.model.ncdgrp.cbs.max.amt + " " + this.model.ncdgrp.apl.pts.nam;
			this.model.ncdgrp.rec.nam = this.model.ncdgrp.rec.nam.slice(0, 40);
		},

	// BEN,ISS,ATB,AT2

		//初始化调用
		getRolList() {
			//------------docprbrolList-------------------
			let docprbrolList = []
			if (this.model.nidgrp.ben.pts.ptainr != "") {
				var benobj = new Object();
				benobj.label = "受益人(BEN)";
				benobj.value = this.model.nidgrp.ben.pts.rol;
				docprbrolList.push(benobj);
			}
			if (this.model.nidgrp.atb.pts.ptainr != "") {
				var atbobj = new Object();
				atbobj.label = "1st Adv. thr. Bank(ATB)";
				atbobj.value = this.model.nidgrp.atb.pts.rol;
				docprbrolList.push(atbobj);
			}
			if (this.model.nidgrp.at2.pts.ptainr != "") {
				var at2obj = new Object();
				at2obj.label = "1st Adv. thr. Bank(AT2)";
				at2obj.value = this.model.nidgrp.at2.pts.rol;
				docprbrolList.push(at2obj);
			}

			if (this.model.nidgrp.iss.pts.ptainr != ""&&this.model.nidgrp.rec.hndtyp=="OC") {
				var issobj = new Object();
				issobj.label = "转开行(ISS)";
				issobj.value = this.model.nidgrp.iss.pts.rol;
				docprbrolList.push(issobj);
			}
			var prbobj = new Object();
			prbobj.label = "交单行(PRB)";
			prbobj.value = "PRB";
			docprbrolList.push(prbobj);
			this.$set(this.codes, 'docprbrolList', docprbrolList)
			if(this.model.ncdgrp.rec.docprbrol ==""){
				if (this.model.nidgrp.iss.pts.ptainr != ""&&this.model.nidgrp.rec.hndtyp=="OC") {
					this.model.ncdgrp.rec.docprbrol = "ISS";
				}
				else if (this.model.nidgrp.adv.pts.ptainr != "") {
					this.model.ncdgrp.rec.docprbrol = "ADV";
				}
				else if (this.model.nidgrp.atb.pts.ptainr != "") {
					this.model.ncdgrp.rec.docprbrol = "ATB";
				}
				else if (this.model.nidgrp.ben.pts.ptainr != "") {
					this.model.ncdgrp.rec.docprbrol = "BEN";
				}
				this.calcPrb();
			}
			
			//------------payrolList-------------------
			//----BEN 、ATB、AT2、OWN 、ADV除外---
			let payrolList = []
			if (this.model.nidgrp.apl.pts.ptainr != "") {
				var aplobj = new Object();
				aplobj.label = "申请人(APL)";
				aplobj.value = this.model.nidgrp.apl.pts.rol;
				payrolList.push(aplobj);
			}
			if (this.model.nidgrp.iss.pts.ptainr != "") {
				var issobj = new Object();
				issobj.label = "反担保行(ISS)";
				issobj.value = this.model.nidgrp.iss.pts.rol;
				payrolList.push(issobj);
			}
			var othobj = new Object();
			othobj.label = "其他赔付人(OTH)";
			othobj.value = "OTH";
			payrolList.push(othobj);
			this.$set(this.codes, 'payrolList', payrolList)
			if(this.model.ncdgrp.rec.payrol ==""){
				if (this.model.nidgrp.iss.pts.ptainr != "") {
					this.model.ncdgrp.rec.payrol = "ISS";
				}
				else if (this.model.nidgrp.ada.pts.ptainr != "") {
					this.model.ncdgrp.rec.payrol = "ADA";
				}
				else if (this.model.nidgrp.apl.pts.ptainr != "") {
					this.model.ncdgrp.rec.payrol = "APL";
				}
				this.calcOth();
			}
			

		},	
		changeExtPay(){
			if(!this.model.extpay){
				this.model.ncdgrp.rec.newexpdat = "";
			}
			let hasModify = !this.model.modifySet || (this.model.modifySet && !this.model.modifySet.includes('nxtflg'))
			if(hasModify){
				if(this.model.extpay){
					this.model.nxtflg = 'FP';
				}else{
					this.model.nxtflg = 'SN';
				}
			}
		},
		ncdgrpBenRefBlur(){
			if(this.model.ncdgrp.rec.docprbrol == "BEN"){
				this.model.ncdgrp.prb.pts.ref=this.model.ncdgrp.ben.pts.ref;
			}
		},
		ncdgrpPrbRefBlur(){
			if(this.model.ncdgrp.rec.docprbrol == "BEN"){
				this.model.ncdgrp.ben.pts.ref=this.model.ncdgrp.prb.pts.ref;
			}
		},
	},
}
//你可以添加自动default处理