import Api from '~/service/Api';
import commonFunctions from '~/mixin/commonFunctions.js';
import buildFn from './buildCommons.js';
export default {
	mixins: [commonFunctions, buildFn],
	methods: {

		// 业务信息=》基本信息=》保函编号-----获取保函编号
		queryOwnref() {
			let params = this.model.gidgrp.rec
			if (!this.model.gidgrp.ben.pts.ptainr) {
				return
			}
			let ptainr = this.model.gidgrp.ben.pts.ptainr;
			const loading = this.loading();
			let trnName = this.root.trnName.toUpperCase()
			Api.post(`/business/ref/gid?ptaInr=${ptainr}&trnName=${trnName}`, params).then(res => {
                loading.close();
				if (res.respCode == SUCCESS) {
					this.model.gidgrp.rec.ownref = res.data;
				} else {
					this.$message.error(res.respMsg);
				}
			}).catch(() => {
				loading.close();
			});
		},

		//申报2122报文
		query2122() {
			let trnName = this.root ? this.root.trnName : this.trnName
			if (this.model.rmbbop.rmb2122.rmbflg == '1') {
				let rmbbop = this.buildRobbop(this.model, trnName);
				Api.post('/business/rmbbopgid/rmbbop2122Cal', rmbbop).then(res => {
					if (res.respCode == SUCCESS) {
            this.model.rmbbop.rmb2122 = res.data.rmb2122;
            this.model.rmbbop.rmb2122.recgrp.ads.opertype = '1';
					}
				});
			}
		},
	// 	changeRmbflg() {
	// 		if (this.model.gidgrp.cbs.max.cur == "CNY") {
	// 			if (this.model.gidgrp.rec.cmtflg == "X") {
	// 				this.model.rmbbop.rmb2122.rmbflg = "1";
	// 			}else {
	// 				this.model.rmbbop.rmb2122.rmbflg = "2";
	// 			}
	// 		} else {
	// 			this.model.rmbbop.rmb2122.rmbflg = "2";
	// 		}
	// },
    handleChangeDelto() {
      if (this.model.gidgrp.rec.delto === 'BENE') {
          this.model.gidgrp.blk.deltoadr = this.model.gidgrp.ben.pts.adrblk
      }
      if (this.model.gidgrp.rec.delto === 'APPL') {
          this.model.gidgrp.blk.deltoadr = this.model.gidgrp.apl.pts.adrblk
      }
      if (this.model.gidgrp.rec.delto === 'OTHR') {
          this.model.gidgrp.blk.deltoadr = ""
      }
  },
	//设置通知行change事件
	setIssBankChange(){
		//赋值opbnk
		if(this.model.zmqflg === "X" && this.model.gidgrp.iss.pts.extkey !== "")
			this.model.gidgrp.rec.oppbnk = this.model.gidgrp.iss.pts.extkey.slice(0, 11);
	},
Covgodsrvmodflg(){
  if(!this.model.gitp.covgodsrvmodflg){
    this.model.gidgrp.blk.covgodsrv=""
  }
}
	}
}