default.js 3.47 KB
import commonFunctions from '~/mixin/commonFunctions.js';
import commonDepend from "~/mixin/commonDepend";
import BigNumber from "bignumber.js";
export default {
	mixins: [commonFunctions, commonDepend],
	methods: {

		// default newnomtop, newnomton
		// 当暂存再加载时,由于会重新从数据库加载,但是并没有走init初始化逻辑,所以有些值比较混乱,需要在前端重新执行default逻辑
		nomSpcInit() {
			this.model.swiadd.newnomtop = this.model.oldledgrp.rec.nomtop;
			this.model.swiadd.newnomton = this.model.oldledgrp.rec.nomton;
			// TD界面上没有nomspc的位置,无需初始化
			//this.model.swiadd.nomspc = this.model.oldledgrp.rec.nomspc;
		},


		//Amep页面
		// Amended Amount(修改金额,swiadd.ameAmt)更新的时候,同时更新New Amount( 新的信用证金额,swiadd.newamt)
		changeSwiaddAmeamt() {
			if (this.model.swiadd.ameAmt === '') {
				this.model.swiadd.ameAmt = 0;
			}
			// oldledgrp.cbs.nom1.amt + swiadd.ameamt, 保留两位小数
			this.model.swiadd.newamt = new BigNumber(this.model.oldledgrp.cbs.nom1.amt).plus(new BigNumber(this.model.swiadd.ameamt)).toFixed(2)
			this.maxamt();
			this.opn1Amt();
			this.engamt();
			this.defaultNom1Amt2000();
			this.defaultMaxamt950();
		},

		maxamt(){
			// 计算 新的最大金额(New Maximum Amount,letamep.maxamt),保留2位小数
			// letamep.maxamt= this.model.swiadd.newamt*(1+this.model.ledgrp.rec.nomtop/100)

				if(this.model.swiadd.newamt===''){
					this.model.swiadd.newamt = 0;
				}
				if(this.model.swiadd.newnomtop===''){
					this.model.swiadd.newnomtop = 0;
				}
				this.model.letamep.maxamt = new BigNumber(this.model.swiadd.newamt)
					.multipliedBy(new BigNumber(1).plus(new BigNumber(this.model.swiadd.newnomtop).dividedBy(new BigNumber(100))))
					.toFixed(2);
		},

		engamt() {

			// 计算 修改的最大金额(Amended Maximum Amount,letamep.engamt),保留2位小数
			// letamep.maxamt- oldledgrp.cbs.max.amt
				this.model.letamep.engamt = new BigNumber(this.model.letamep.maxamt).minus(new BigNumber(this.model.oldledgrp.cbs.max.amt))
					.toFixed(2);

		},

		opn1Amt(){

			this.model.ledgrp.cbs.opn1.amt = new BigNumber(this.model.oldledgrp.cbs.opn1.amt).plus(this.model.letamep.maxamt).minus(this.model.oldledgrp.cbs.max.amt)
				.toFixed(2);
		},

		// nom1的值,总是等于newamt
		defaultNom1Amt2000(){
			if(new BigNumber(this.model.swiadd.newamt).comparedTo(this.model.ledgrp.cbs.nom1.amt)!=0){
				this.model.ledgrp.cbs.nom1.amt = this.model.swiadd.newamt;
			}
		},


		// cbs.max.amt,总是等于 nom1*(1+nomtop/100)
		defaultMaxamt950(){
			if(this.model.ledgrp.rec.nomtop==null || this.model.ledgrp.rec.nomtop===''){
				this.model.ledgrp.rec.nomtop = 0;
			}

			if(this.model.ledgrp.rec.nomtop==null || this.model.ledgrp.rec.nomtop===''){
				this.model.ledgrp.rec.nomtop = 0;
			}
			let _maxamt =new BigNumber(this.model.ledgrp.cbs.nom1.amt).multipliedBy(new BigNumber(1).plus(new BigNumber(this.model.ledgrp.rec.nomtop).dividedBy(new BigNumber(100))) ) ;
			let _currency = this.model.ledgrp.cbs.max.cur;
			// 如果是 韩元或者日元,小数位不保留,其它保留两位小数
			// TD上,nom1:611.23,tolerance-top:2,maxamt 623.4546,letnot最后是623.46,letopn 最后是623.45,暂时以letopn为准
			if (_currency === "KRW" || _currency === "JPY") {
				_maxamt = _maxamt.toFixed(0);
			}else {
				_maxamt = _maxamt.toFixed(2);
			}
			this.model.ledgrp.cbs.max.amt = _maxamt;

		},

	},
}