default.js 12.5 KB
Newer Older
fukai committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345
import commonFunctions from '~/mixin/commonFunctions.js';
import commonDepend from "~/mixin/commonDepend"
import moment from 'moment';
import BigNumber from "bignumber.js";
import Api from "~/service/Api";

export default {
	mixins: [commonFunctions, commonDepend],
	methods: {
		YPTDefault(){
			if(this.model.spt && this.model.spt.channel=='YPT'){
				if (this.model.didgrp.rec.shppar=="Y") {
					this.model.didgrp.rec.shppar="ALWD";
				}
				if (this.model.didgrp.rec.shppar=="N") {
					this.model.didgrp.rec.shppar="NALW";
				}
				//转运key值变化
				if (this.model.didgrp.rec.shptrs=="Y") {
					this.model.didgrp.rec.shptrs="ALWD";
				}
				if (this.model.didgrp.rec.shptrs=="N") {
					this.model.didgrp.rec.shptrs="NALW";
				}
				if(this.model.ifMoreApl!='Y'){
					this.getAplInfo()
				}
				if(this.model.didgrp.blk.lcrgod!=""){
					this.customAddModify(this.model.didgrp.blk, 'lcrgod');
				}
				if(this.model.ifMoreApl=='Y'){
					this.$refs["modelForm"].validateField([`didgrp.apl.pts.extkey`]);
				}
			}
		},
		async sptBenDefault(){
			if(this.model.spt && this.model.spt.channel=='YPT'&&this.model.didgrp.ben.pts.cnnam!=""){
				let data = {
					adrelc: this.model.didgrp.ben.pts.cnadr,
					flg: false,
					language:"CN",
					namelc:this.model.didgrp.ben.pts.cnnam,
					rol:'ben',
					ptainr:""
				}
				let ress = await Api.post('/Domlc/ptspta/ptsTmpAdrAddAuto', data);
				if (ress.respCode === SUCCESS) {
					if(ress.data){
						this.model.didgrp.ben.cnnam = ress.data.pts.cnnam
						this.model.didgrp.ben.cnadr = ress.data.pts.cnadr
						this.model.didgrp.ben.pts.extkey = ress.data.extkey
						this.model.didgrp.ben.pts.rol = 'BEN'
						this.model.didgrp.ben.pts.ptainr = ress.data.pts.ptainr
						this.model.didgrp.ben.pts.ptyinr = ress.data.pts.ptyinr
						this.model.didgrp.ben.ptytyp = ress.data.ptytyp
						this.$set(this.codes, 'bendisabled', true);
						this.getBenInfo()
					}
				}
			}
		},
		userEsxtkeyDefault(){
			if (this.model.didgrp.rec.ownusr == "") {
				this.model.didgrp.rec.ownusr = window.sessionStorage.userName
			}
		},
		msgtypDefault() {
			if (this.model.didgrp.rec.elcflg == "Y") {
				this.model.ditp.msgtyp = "elcs.101.001.02"
			}
			else {
				this.model.ditp.msgtyp = ""
			}
		},
		// 将数字金额转换为大写金额
		smallToBig() {
			var money = this.model.didgrp.cbs.nom1.amt;
			if(isNaN(new BigNumber(money)) ){
				return
			}
			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.ditp.amt = "";
				return;
			}

			if (new BigNumber(money) == 0) {
				chineseStr = cnNums[0] + cnIntLast + cnInteger;
				this.model.ditp.amt = "人民币" + chineseStr;
				return;
			}
			//转换为字符串
			integerNum = money.substr(0, money.length - 3);
			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.ditp.amt = "人民币" + chineseStr;
			this.defaultMaxamt();
		},
		defaultMaxamt() {
			if(this.model.didgrp.cbs.max.amt==""){
				this.model.didgrp.cbs.max.amt=0;
			}
			if(this.model.didgrp.cbs.nom1.amt==""){
				this.model.didgrp.cbs.nom1.amt=0;
			}
			if(isNaN(new BigNumber(this.model.didgrp.cbs.nom1.amt))||isNaN(new BigNumber(this.model.didgrp.rec.nomtop))){
				return
			}
			this.model.didgrp.cbs.max.amt = new BigNumber(this.model.didgrp.cbs.nom1.amt).multipliedBy(new BigNumber(1).plus(new BigNumber(this.model.didgrp.rec.nomtop).dividedBy(100))).toFormat(2).replace(/,/g, "");
			this.model.didgrp.cbs.opn1.amt = this.model.didgrp.cbs.max.amt;
		},
		preperDefault() {
			if((this.$route.query.businessInr&&this.$route.query.businessType=='TRN')||this.isInDisplay){
				return;
			}
			if(this.model.spt&&this.model.spt.channel=="YPT"){
				return;
			}
			if (this.model.didgrp.blk.preperflg != "X") {
				let days;
				if (this.model.didgrp.rec.expdat == "" || this.model.didgrp.rec.expdat == null || this.model.didgrp.rec.shpdat == "" || this.model.didgrp.rec.shpdat == null) {
					days = "15";
				}
				else {
					days = moment(this.model.didgrp.rec.expdat).diff(moment(this.model.didgrp.rec.shpdat), 'days')
				}
				switch (this.model.didgrp.rec.mytype) {
					case "H":
					case "":
						this.model.didgrp.blk.preper = "货物装运日后" + days + "天";
						break;
					case "F":
						this.model.didgrp.blk.preper = "服务提供日后" + days + "天"
						break;
					case "3":
						this.model.didgrp.blk.preper = "货物/服务提供日后" + days + "天"
						break;
				}
			}
			this.adlcndDefault();
		},
		lcrdocDefault() {
			let CR = "\n";
			if((this.$route.query.businessInr&&this.$route.query.businessType=='TRN')||this.isInDisplay){
				return true;
			}
			if (this.model.didgrp.blk.modifySet && this.model.didgrp.blk.modifySet.includes('lcrdoc')) {
				return;
			}
			else if(this.model.spt&&this.model.spt.channel=="YPT"){
				return;

			}
			else {
				if (this.model.didgrp.rec.elcflg == 'Y') {
					switch (this.model.didgrp.rec.mytype) {
						case "H":
						case "":
							this.model.didgrp.blk.lcrdoc = "1.税务部门统一监制的原始正本发票(包括发票联和抵扣联)。" + CR + "2.申请人出具的货物收据正本一份,显示收货人为开证申请人。"
							break;
						case "F":
							this.model.didgrp.blk.lcrdoc = "1.税务部门统一监制的原始正本发票(包括发票联和抵扣联)。" + CR + "2.申请人出具的劳务确认书正本一份。";
							break;
						case "3":
							this.model.didgrp.blk.lcrdoc = "1.税务部门统一监制的原始正本发票(包括发票联和抵扣联)。" + CR + "2.申请人出具的货物收据/劳务确认书正本一份。";
							break;
						default:
							this.model.didgrp.blk.lcrdoc = "1.税务部门统一监制的原始正本发票(包括发票联和抵扣联)。" + CR + "2.申请人出具的货物收据/劳务确认书正本一份。";
							break;
					}
				}
				else {
					if (this.model.didgrp.rec.mytype == "H" || this.model.didgrp.rec.mytype == "") {
						this.model.didgrp.blk.lcrdoc = "1.税务部门统一监制的原始正本发票(包括发票联和抵扣联)。" + CR + "2.申请人出具的货物收据正本一份,显示收货人为开证申请人。";
					}
					else {
						this.model.didgrp.blk.lcrdoc = "1.税务部门统一监制的原始正本发票(包括发票联和抵扣联)。" + CR + "2.申请人出具的劳务确认书正本一份。";
					}
				}
			}
		},
		adlcndDefault() {
			let nomton;
			let nomtop;
			let txt = "";
			let CR = "\n";
			if((this.$route.query.businessInr&&this.$route.query.businessType=='TRN')||this.isInDisplay){
				return true;
			}
			if(this.model.spt&&this.model.spt.channel=="YPT"){
				return;
			}
			else if (this.model.didgrp.blk.modifySet && this.model.didgrp.blk.modifySet.includes('adlcnd')) {
				return;
			}
			else {
				if (this.model.didgrp.rec.nomton != 0) {
					nomton = new BigNumber(this.model.didgrp.rec.nomton).toFormat(2)
				}
				if (this.model.didgrp.rec.nomtop != 0) {
					nomtop = new BigNumber(this.model.didgrp.rec.nomtop).toFormat(2)
				}
				switch (this.model.didgrp.rec.mytype) {
					case "H":
					case "":
						txt = "";
						if (this.model.didgrp.rec.nomton == 0 && this.model.didgrp.rec.nomtop == 0) {
							txt = txt + "2.货物数量及信用证金额无浮动范围。"
						}
						else {
							if (this.model.didgrp.rec.nomton != 0 && this.model.didgrp.rec.nomtop != 0) {
								txt = txt + "2.货物数量及信用证金额均可有上浮" + nomtop + "%和下浮" + nomton + "%的浮动范围。"
							}
							else {
								if (this.model.didgrp.rec.nomton != 0) {
									txt = txt + "2.货物数量及信用证金额均可有下浮" + nomton + "%的浮动范围。"
								}
								else {
									txt = txt + "2.货物数量及信用证金额均可有上浮" + nomtop + "%的浮动范围。"
								}
							}
						}
						break;
					case "F":
						txt = "";
						if (this.model.didgrp.rec.nomton == 0 && this.model.didgrp.rec.nomtop == 0) {
							txt = txt + "2.服务数量及信用证金额无浮动范围。"
						}
						else {
							if (this.model.didgrp.rec.nomton != 0 && this.model.didgrp.rec.nomtop != 0) {
								txt = txt + "2.服务数量及信用证金额均可有上浮" + nomtop + "%和下浮" + nomton + "%的浮动范围。"
							}
							else {
								if (this.model.didgrp.rec.nomton != 0) {
									txt = txt + "2.服务数量及信用证金额均可有下浮" + nomton + "%的浮动范围。"
								}
								else {
									txt = txt + "2.服务数量及信用证金额均可有上浮" + nomtop + "%的浮动范围。"
								}
							}
						}
						break;
					case "3":
						txt = "";
						if (this.model.didgrp.rec.nomton == 0 && this.model.didgrp.rec.nomtop == 0) {
							txt = txt + "2.货物/服务数量及信用证金额无浮动范围。"
						}
						else {
							if (this.model.didgrp.rec.nomton != 0 && this.model.didgrp.rec.nomtop != 0) {
								txt = txt + "2.货物/服务数量及信用证金额均可有上浮" + nomtop + "%和下浮" + nomton + "%的浮动范围。"
							}
							else {
								if (this.model.didgrp.rec.nomton != 0) {
									txt = txt + "2.货物/服务数量及信用证金额均可有下浮" + nomton + "%的浮动范围。"
								}
								else {
									txt = txt + "2.货物/服务数量及信用证金额均可有上浮" + nomtop + "%的浮动范围。"
								}
							}
						}
						break;
					default:
						txt = "";
						if (this.model.didgrp.rec.nomton == 0 && this.model.didgrp.rec.nomtop == 0) {
							txt = txt + "2.货物数量及信用证金额无浮动范围。"
						}
						else {
							if (this.model.didgrp.rec.nomton != 0 && this.model.didgrp.rec.nomtop != 0) {
								txt = txt + "2.货物数量及信用证金额均可有上浮" + nomtop + "%和下浮" + nomton + "%的浮动范围。"
							}
							else {
								if (this.model.didgrp.rec.nomton != 0) {
									txt = txt + "2.货物数量及信用证金额均可有下浮" + nomton + "%的浮动范围。"
								}
								else {
									txt = txt + "2.货物数量及信用证金额均可有上浮" + nomtop + "%的浮动范围。"
								}
							}
						}
						break;
				}
			}
			this.model.didgrp.blk.adlcnd = "1.单据必须自" + this.model.didgrp.blk.preper + "内提交,但不能晚于信用证有效期;" + CR + txt + CR + "3.开证行以外的所有银行费用由受益人承担。" + CR + "4.发票出具日期早于信用证开立日期不接受。" + CR + "5.增值税专用发票必须是原始正本,影印件、传真件不接受,即使注明正本字样。" + CR + "6.交单行或议付行(如有)应注明此次交单是在正本信用证项下进行并已在信用证正本背面批注交单情况。" + CR + "7.此证不允许保兑。" + CR + "8.其他。"
		},
		stametDefault(){
			if(this.model.didgrp.blk.stamet==""){
				this.model.didgrp.blk.stamet="本信用证为依据《国内信用证结算办法》开立的不可撤销国内信用证"
			}
		},
		benDisabled(){
			if(this.model.didgrp.ben.ptytyp=="F"){
				this.$set(this.codes, 'bendisabled', true);
			}
		}
	},
}