index.js 9.67 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
import Api from '~/service/Api';
import commonFunctions from '~/mixin/commonFunctions.js';
import Utils from "~/utils/index";
import Pts from "~/components/business/commonModel/Pts.js";
import { cloneDeep } from "lodash";
import moment from "moment";
import BigNumber from 'bignumber.js';
export default {
  mixins: [commonFunctions],
  methods: {
    avbbyDefault() {
			switch (this.model.ltdgrp.rec.avbby)
			{
				case "P":
					this.model.ltdgrp.rec.tenmaxday = "0";
					this.model.ltdgrp.blk.mixdet = "";
					this.model.ltdgrp.blk.defdet = "";
					break;
				case "M":
					this.model.ltdgrp.blk.dftat = "";
          this.model.ltdgrp.blk.defdet = "";
          this.model.ltdgrp.drw.pts = new Pts().data;
          this.model.ltdgrp.drw.ptytyp = "";
					break;
				case "N":
					break;
				case "D":
					this.model.ltdgrp.blk.mixdet = "";
          this.model.ltdgrp.blk.dftat = "";
          this.model.ltdgrp.drw.pts = new Pts().data;
          this.model.ltdgrp.drw.ptytyp = "";
					break;
				case "A":
					this.model.ltdgrp.blk.mixdet = "";
					this.model.ltdgrp.blk.defdet = "";
					break;
      }
      if(this.model.ltdgrp.rec.avbby != 'A' && this.model.ltdgrp.rec.avbby != 'N' && this.model.ltdgrp.rec.avbby != 'P'){
        this.drwdisabled = true
      }else{
        if(!!this.model.ltdgrp.drw.pts.extkey){
          this.drwdisabled = true
        }
      }
		},
    async buttxmsel() {
      let params = {}
      let res = await Api.post("/Lc/lttame/buttxmsel", params);
      if (res.respCode === SUCCESS) {
        res.data
      }
    },

    // 获取码表
    async getdbCode(codeType, uil, codeNam) {
      let params = {
        codeType: codeType,
        uil: uil ? uil : "EN",
      };
      let rtnmsg = await Api.post("/manager/dic/listDicInfo", params);
      if (rtnmsg.respCode === SUCCESS) {
        let curList = rtnmsg.data.map((item) => ({
          value: item.codeValue,
          label: item.codeName,
        }));
        this.dbCodes[codeNam] = curList;
      }
    },

    // 正则匹配特殊字符替换,例如将'[',替换成'\['这样的话就不会作为正则表达式的转义字符处理了
    specialCharactersProcess(inputStr) {
      let specialCharacterArr = ["[", "]", "\\", "$", ".", "|", "?", "*", "+", "(", ")", "{", "}"];
      let processedStr = "";
      let index;
      for (index = 0; index < inputStr.length; index++) {
        let indexChar = inputStr.charAt(index);
        // 包含特殊字符
        if (specialCharacterArr.indexOf(indexChar) != -1) {
          processedStr += "\\" + indexChar;
        } else {
          processedStr += indexChar;
        }
      }
      return processedStr;
    },

    getCodeTableValue(value, codenam) {
      const codeobj = this.dbCodes[codenam].find((obj) => obj.value === value);
      return codeobj ? codeobj.label : value;
    },

    onAvbwthChange() {
      // 2.填充字段
      // 先将原有数据清空
      this.model.ltdgrp.avt.pts = new Pts().data;
      this.model.ltdgrp.avt.ptainr = "";
      this.model.ltdgrp.avt.ptyinr = "";
      this.model.ltdgrp.avt.adrblk = "";
      this.model.ltdgrp.avt.nam = "";
      this.model.ltdgrp.avt.extkey = "";
      this.model.ltdgrp.avt.ptytyp = "";
      this.model.ltdgrp.avt.cnnam = "";
      this.model.ltdgrp.avt.cnadr = "";
      this.model.ltdgrp.avt.ennam = "";
      this.model.ltdgrp.avt.enadr = "";
      this.model.ltdgrp.avt.ref = "";
      this.model.ltdgrp.avt.cnnamadr = "";
      this.model.ltdgrp.avt.ennamadr = "";
      let ptsList = [];
			ptsList.push(this.model.ltdgrp.adt);
			ptsList.push(this.model.ltdgrp.con);
			ptsList.push(this.model.ltdgrp.rmt);
			ptsList.push(this.model.lttp.own);
      let rol = "";
      if ("A" == this.model.ltdgrp.rec.avbwth) {
        rol = "ADT";
      } else if ("C" == this.model.ltdgrp.rec.avbwth) {
        rol = "OWN";
      } else if ("R" == this.model.ltdgrp.rec.avbwth) {
        rol = "RMT";
      } else if ("I" == this.model.ltdgrp.rec.avbwth) {
        rol = "OWN";
      }
      let res = ptsList.find((item) => item.pts.rol == rol);
      if (res != null && res != "") {
        let newRes = cloneDeep(res);
        this.model.ltdgrp.avt = newRes;
        this.model.ltdgrp.avt.pts.rol = "AVT";
      }
      // 1.控制是否可输入
      let val = this.model.ltdgrp.rec.avbwth;
      //Issuing Bank
      if ((val == "I" || val == "C") && this.model.ltdgrp.avt.pts.extkey !='' ) {
        this.avbDisabled = true;
        // this.disabledExtkey = false;
      } else if (val == "A" && this.model.ltdgrp.avt.pts.extkey !='' ) {
        //Advising Bank
        //Confirming Bank
        this.avbDisabled = true;
        // this.disabledExtkey = true;
      } else if (val == "O" && (this.model.ltdgrp.blk.avbwthtxt == null || this.model.ltdgrp.blk.avbwthtxt == "")){
          let value = this.getCodeTableValue("O", "avbwth");
          this.model.ltdgrp.blk.avbwthtxt = value;
      }else{
        this.avbDisabled = false;
        // this.disabledExtkey = false;
      }
    },

    addamtflg(){
      if(!this.model.swiadd.addamtflg){
        if(this.model.swiadd.addamt || this.model.swiadd.addamtcov){
          var max2amt= this.model.swiadd.addamt
          var addamtcov= this.model.swiadd.addamtcov
          this.$confirm("Do you really want to delete the additional amount of this contract?", "提示", {
            confirmButtonText: "YES",
            cancelButtonText: "NO",
            type: "warning",
          }).then(() => {
            this.model.swiadd.addamt = ""
            this.model.swiadd.addamtcov = ""
            this.model.lttp.aamp.aammod.addamtflg = ""
            this.model.ltdgrp.cbs.max2.amt = "0.00"
          }).catch(() => {
            this.model.swiadd.addamt = max2amt
            this.model.swiadd.addamtcov = addamtcov
            this.model.swiadd.addamtflg = "X"
          });
        }
      }
      if(!!this.model.swiadd.addamtflg ){
        this.model.lttp.aamp.aammod.addamtflg = "X"
      }
    },

    cnfinsDefault() {
			if (!this.model.ltdgrp.adt.pts.adrblk)
			{
				// let modifyList = this.model.ltdgrp.rec.modifySet;
				// if (!(modifyList && modifyList.includes("cnfins")) )
				// {
					if (this.model.ledgrp.rec.cnfsta == "Y")
					{
						this.model.ltdgrp.rec.cnfins = "W";
					}else{
						this.model.ltdgrp.rec.cnfins = "";
					}
				// }
			} 
    },

    changeAmeamt(){
      this.model.swiadd.newamt =new BigNumber(this.model.swiadd.ameamt).plus(
          new BigNumber(this.model.oldltdgrp.cbs.nom1.amt));
      this.model.ltdgrp.cbs.nom1.amt = this.model.swiadd.newamt;
      this.model.lttamep.maxamt = new BigNumber(this.model.swiadd.newamt).multipliedBy(
        new BigNumber(this.model.swiadd.newnomtop).dividedBy(100).plus(1));
      this.model.ltdgrp.cbs.max.amt = this.model.lttamep.maxamt;
      this.model.lttamep.engamt = new BigNumber(this.model.lttamep.maxamt).minus(
        new BigNumber(this.model.oldltdgrp.cbs.max.amt))
    },
    changeNewamt(){
      this.model.swiadd.ameamt =new BigNumber(this.model.swiadd.newamt).minus(
          new BigNumber(this.model.oldltdgrp.cbs.nom1.amt));
      this.model.lttamep.maxamt = new BigNumber(this.model.swiadd.newamt).multipliedBy(
        new BigNumber(this.model.swiadd.newnomtop).dividedBy(100).plus(1));
      this.model.ltdgrp.cbs.max.amt = this.model.lttamep.maxamt;
      this.model.lttamep.engamt = new BigNumber(this.model.lttamep.maxamt).minus(
        new BigNumber(this.model.oldltdgrp.cbs.max.amt))
    },
    changeNewnomtop() {
      this.model.ltdgrp.rec.nomtop = this.model.swiadd.newnomtop;
      this.model.lttamep.maxamt = new BigNumber(this.model.swiadd.newamt).multipliedBy(
        new BigNumber(this.model.swiadd.newnomtop).dividedBy(100).plus(1))
      this.model.ltdgrp.cbs.max.amt = this.model.lttamep.maxamt;
      this.model.lttamep.engamt = new BigNumber(this.model.lttamep.maxamt).minus(
        new BigNumber(this.model.oldltdgrp.cbs.max.amt))
    },
    onSwiaddNewnomtonChange() {
      this.model.ltdgrp.rec.nomton = this.model.swiadd.newnomton;
    },
    changeNewshipmentdate(){
      this.model.ltdgrp.rec.shpdat = this.model.swiadd.newshpdat
    },
    changeSwiaddPrepers18(){
      this.model.ltdgrp.rec.prepers18= this.model.swiadd.prepers18
    },
    changeSwiaddPrepertxts18(){
     this.model.ltdgrp.rec.prepertxts18 = this.model.swiadd.prepertxts18
    },
    changeSwiaddNewexpdat(){
     this.model.ltdgrp.rec.expdat = this.model.swiadd.newexpdat
    },
    initIncomingData() {
      this.changeAmeamt()
      this.changeNewamt()
      this.changeNewnomtop()
      this.onSwiaddNewnomtonChange()
      this.changeNewshipmentdate()
      this.changeSwiaddPrepers18()
      this.changeSwiaddPrepertxts18()
      this.changeSwiaddNewexpdat()
    },

    changeAddamt() {
      if (this.model.swiadd.addamtflg ) {
        this.model.ltdgrp.cbs.max2.amt = this.model.swiadd.addamt
        if(this.model.swiadd.modifySet != null && !this.model.swiadd.modifySet.includes("addamtcov") && this.model.swiadd.addamt != 0){
          this.model.swiadd.addamtcov = this.model.ltdgrp.cbs.max2.cur + " " + this.model.swiadd.addamt;
          this.model.ltdgrp.blk.addamtcov = this.model.swiadd.addamtcov
          this.model.swiadd.modifySet.push("addamtcov")
          return this.model.swiadd.addamtcov;
        }
      } else {
        this.model.swiadd.addamt = "0.00";
        this.model.ltdgrp.cbs.max2.amt = "0.00";
        this.model.ltdgrp.blk.addamtcov = "";
      }
    }, 
    changeSwiaddAddamtcov(){
      this.model.ltdgrp.blk.addamtcov = this.model.swiadd.addamtcov
    },

    onApprulChange() {
      if (this.model.ltdgrp.rec.apprul != "OTHR") {
        this.model.ltdgrp.rec.apprultxt = "";
      }
    },

    trnchatoChange(){
      if(this.model.swiadd.trnchato != 'OTHR'){
        this.model.swiadd.trnfeetxt = ""
      }
    }

  }
}