default.js 6.12 KB
import commonFunctions from '~/mixin/commonFunctions.js';
import commonDepend from "~/mixin/commonDepend";
import BigNumber from "bignumber.js";
export default {
	mixins: [commonFunctions, commonDepend],
	methods: {
    // expdatChange(){
		// 	if(this.model.swiadd.newexpdat!=this.model.olddedgrp.rec.expdat){
    //     this.model.dedgrp.rec.expdat = this.model.swiadd.newexpdat
		// 		this.customAddModify(this.model.dedgrp.rec, 'expdat');
    //   }
    // },
    // shpdatChange(){
		// 	if(this.model.swiadd.newshpdat!=this.model.olddedgrp.rec.shpdat){
    //     this.model.dedgrp.rec.shpdat = this.model.swiadd.newshpdat
		// 		this.customAddModify(this.model.dedgrp.rec, 'shpdat');
    //   }
    // },
    defaultNewnomtopame(){
      if (this.model.spt && this.model.spt.channel == 'ELC') {
      }else{
      this.model.swiadd.newnomtopame =this.model.olddedgrp.rec.nomtop;
      this.model.swiadd.newnomtoname = this.model.olddedgrp.rec.nomton
      }
    },
    defaultNewAmt(){
      if (this.model.spt && this.model.spt.channel == 'ELC' && Number(this.model.swiadd.newamt)) {
      }else{
        this.model.swiadd.newamt = new BigNumber(this.model.olddedgrp.cbs.nom1.amt).plus(new BigNumber(this.model.swiadd.ameamt));
        this.model.dedgrp.cbs.nom1.amt = this.model.swiadd.newamt;
        this.defaultEngamtAndNewMaxmat();
        this.smallToBig();
      }
    },
    defaultOrimsgtyp(){
      if (this.model.spt && this.model.spt.channel == 'ELC') {
        if(this.model.swiadd.orimsgtyp=='elcs.103.001.02'){
          this.model.swiadd.orimsgtyp = "A03";
        }
      }
    },
    formatTableData() {
			let list = this.model.rejamersnhis.rows || []
			let resList = []
			if (list) {
				list.map((item, ind) => {
					let tempItem = item.split("\t")
					resList.push({
						'修改次数': ind+1,
						'拒绝修改标志': tempItem[0],
						'拒绝修改理由': tempItem[1],
					})
				})
			}
			this.$set(this.codes, 'tableData', resList)
    },
    		// 将数字金额转换为大写金额
		smallToBig() {
			var money = this.model.dedgrp.cbs.nom1.amt;
			var cnNums = new Array("零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"); //汉字的数字
			var cnIntRadice = new Array("", "拾", "佰", "仟"); //基本单位
			var cnIntUnits = new Array("", "万", "亿", "兆"); //对应整数部分扩展单位
			var cnDecUnits = new Array("角", "分", "毫", "厘"); //对应小数部分单位
			var cnInteger = "整"; //整数金额时后面跟的字符
			var cnIntLast = "元"; //整数完以后的单位
			var integerNum; //金额整数部分
			var decimalNum; //金额小数部分
			//输出的中文金额字符串
			var chineseStr = "";
			var parts; //分离金额后用的数组,预定义
			if (money == "") {
				this.model.detp.upamt = "";
				return;
			}

			money = parseFloat(money);
			if (money == 0) {
				chineseStr = cnNums[0] + cnIntLast + cnInteger;
				this.model.detp.upamt = "人民币" + chineseStr;
				return;
			}

			//四舍五入保留两位小数,转换为字符串
			money = Math.round(money * 100).toString();
			integerNum = money.substr(0, money.length - 2);
			decimalNum = money.substr(money.length - 2);
			//获取整型部分转换
			if (parseInt(integerNum, 10) > 0) {
				var zeroCount = 0;
				var IntLen = integerNum.length;
				for (var i = 0; i < IntLen; i++) {
					var n = integerNum.substr(i, 1);
					var p = IntLen - i - 1;
					var q = p / 4;
					var m = p % 4;
					if (n == "0") {
						zeroCount++;
					} else {
						if (zeroCount > 0) {
							chineseStr += cnNums[0];
						}
						//归零
						zeroCount = 0;
						chineseStr += cnNums[parseInt(n)] + cnIntRadice[m];
					}
					if (m == 0 && zeroCount < 4) {
						chineseStr += cnIntUnits[q];
					}
				}
				chineseStr += cnIntLast;
			}
			//小数部分
			if (decimalNum != "") {
				var decLen = decimalNum.length;
				for (var i = 0; i < decLen; i++) {
					var n = decimalNum.substr(i, 1);
					if (n != "0") {
						chineseStr += cnNums[Number(n)] + cnDecUnits[i];
					}
				}
			}
			if (chineseStr == "") {
				chineseStr += cnNums[0] + cnIntLast + cnInteger;
			} else if (decimalNum == "" || /^0*$/.test(decimalNum)) {
				chineseStr += cnInteger;
			}
			this.model.detp.upamt = "人民币" + chineseStr;
		},

		newAmtChange(){
      this.model.swiadd.ameamt = new BigNumber(this.model.swiadd.newamt).minus(new BigNumber(this.model.olddedgrp.cbs.nom1.amt));
      this.model.dedgrp.cbs.nom1.amt = this.model.swiadd.newamt;
      if(new BigNumber(this.model.swiadd.ameamt).comparedTo(new BigNumber(0))!=0){
				this.customAddModify(this.model.swiadd, 'ameamt');
				this.customAddModify(this.model.swiadd, 'newamt');
      }
      if(new BigNumber(this.model.olddedgrp.cbs.nom1.amt).comparedTo(new BigNumber(this.model.dedgrp.cbs.nom1.amt))!=0){
				this.customAddModify(this.model.dedgrp.cbs.nom1, 'amt');
      }
      this.defaultEngamtAndNewMaxmat();
      this.smallToBig();
		},
		newnomtopameChange(){
      if(this.model.swiadd.newnomtopame!=this.model.olddedgrp.rec.nomtop){
				this.customAddModify(this.model.dedgrp.rec, 'nomtop');
			}
			this.defaultEngamtAndNewMaxmat();
    },
    newnomtonameChange(){
			if(this.model.swiadd.newnomtoname!=this.model.olddedgrp.rec.nomton){
				this.customAddModify(this.model.dedgrp.rec, 'nomton');
			}
		},
		defaultEngamtAndNewMaxmat() {
			this.model.detamep.maxamt = new BigNumber(this.model.swiadd.newamt).multipliedBy(new BigNumber(1).plus(new BigNumber(this.model.swiadd.newnomtopame).dividedBy(100))).toFormat(2).replace(/,/g, "");
			this.model.detamep.engamt =  new BigNumber(this.model.detamep.maxamt).minus(new BigNumber(this.model.olddedgrp.cbs.max.amt));
			this.model.dedgrp.cbs.max.amt = this.model.detamep.maxamt;
			this.model.dedgrp.cbs.opn1.amt =  new BigNumber(this.model.olddedgrp.cbs.opn1.amt).plus(new BigNumber(this.model.detamep.engamt));
			if(new BigNumber(this.model.dedgrp.cbs.max.amt).comparedTo(this.model.olddedgrp.cbs.max.amt)!=0){
				this.customAddModify(this.model.dedgrp.cbs.max, 'amt');
			}
			if(new BigNumber(this.model.dedgrp.cbs.nom1.amt).comparedTo(this.model.olddedgrp.cbs.nom1.amt)!=0){
				this.customAddModify(this.model.dedgrp.cbs.nom1, 'amt');
			}
		},
	},
}