index.js 8.35 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
import Api from '~/service/Api';
import Utils from "~/utils";
import Pts from '~/components/business/commonModel/Pts';
import commonFunctions from '~/mixin/commonFunctions.js';
import buildFn from "../event/buildCommons.js";
import BigNumber from "bignumber.js";
import commonDepend from "~/mixin/commonDepend";

export default {
  mixins: [commonFunctions,buildFn,commonDepend],
  methods: {
    //获取信用证编号
    async onLetpButgetref(transName) {
      let params = {
        businessType: "LC",
        lettyp: "LC",
        transName:transName,
        ptainr: this.model.ledgrp.ben.pts.ptainr,
        ownref: this.model.ledgrp.rec.ownref,
      };
      const loading = this.loading();
      let res = await Api.post("/Lc/ref/led", params);
      loading.close();
      if (res.respCode == SUCCESS) {
        this.model.ledgrp.rec.ownref = res.data;
      } else {
        this.$message.error(res.respMsg);
      }
    },

    // 如果adv,con,iss,rmb,trb的值有变动,同时更新avb的值
    async bankChanged(){
      this.avbwthFlg();
    },


    // 如果a2b的值被清空,则清空cnfins的值
    async a2bBankChange(){
      if(this.model.ledgrp.a2b.pts.extkey==''){
        this.model.ledgrp.rec.cnfins = ''
      }
    },

    //指定银行
    async avbwthFlg() {


      switch (this.model.ledgrp.rec.avbwth) {
        // Advising bank,adv
        case "A":
          // Utils.copyValueFromVoData(this.model.ledgrp.avb.pts, this.model.ledgrp.adv.pts);
          let ptsptaList = Utils.formatPtspta(this.model.ledgrp, this.buildPtspta);

          let data = {
            ptsList:ptsptaList,
            avbwth: this.model.ledgrp.rec.avbwth,
          };
          const loading = this.loading();
          let res = await Api.post("/Lc/letopn/avbwth", data);
          loading.close();
          if (res.respCode === SUCCESS) {
            Utils.copyValueFromVoData(this.model.ledgrp.avb.pts, res.data.pts);
          }
          break;

          // Confirming Bank,con
        case "C":
          Utils.copyValueFromVoData(this.model.ledgrp.avb.pts, this.model.ledgrp.con.pts);
          break;

          // Issuing Bank,iss
        case "I":
          Utils.copyValueFromVoData(this.model.ledgrp.avb.pts, this.model.ledgrp.iss.pts);
          break;

          //Reimbursing Bank,rmb
        case "R":
          Utils.copyValueFromVoData(this.model.ledgrp.avb.pts, this.model.ledgrp.rmb.pts);
          break;

          //Specified Bank,
        case "S":
          this.model.ledgrp.avb.pts = new Pts().data;
          break;

          //Transferring Bank, trb
        case "T":
          Utils.copyValueFromVoData(this.model.ledgrp.avb.pts, this.model.ledgrp.trb.pts);
          break;

          //Any Bank, no role
        case "O":
          // if any bank is empty or is not modified, then default value is 'Any Bank'
          if(this.model.ledgrp.blk.avbwthtxt ===''||(this.model.ledgrp.blk.modifySet && !this.model.ledgrp.blk.modifySet.includes('avbwthtxt'))){
            this.model.ledgrp.blk.avbwthtxt = 'Any Bank';
          }

          break;
        default:
          this.model.ledgrp.avb.pts = new Pts().data;
          break;

      }

      // 如果avb被赋值的话,设置avb角色为AVB
      if(this.model.ledgrp.avb.pts.ptainr!==''){
        this.model.ledgrp.avb.pts.rol ="AVB";
      }


    },

    openAddAmount(val) {
      if (val === '' && !((new BigNumber(this.model.ledgrp.cbs.max2.amt).comparedTo(new BigNumber("0"))==0) && this.model.ledgrp.blk.addamtcov === '')) {
        this.$confirm('是否确定要删除此合同的附加金额?', '提示', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
          showClose: false
        }).then(() => {//yes的执行在这里写
          this.model.letp.addamtflg = ''

          this.model.ledgrp.cbs.max2.amt ='0.00';
          this.model.ledgrp.blk.addamtcov = '';
          this.customRemoveModify(this.model.ledgrp.blk,"addamtcov");
          this.$message({
                type: 'success',
                message: '删除成功!'
          });
        }).catch(() => {//No的功能在这里写
          this.model.letp.addamtflg = 'X'
          this.$message({
            type: 'info',
            message: '已取消'
          });
        });
      }
    },


    apprulChange(v) {
      if (v !== 'OTHR') {
        this.model.ledgrp.rec.apprultxt = ''
      }
    },

    async avbbyChange() {

      // mixdet为disable时,清除其内容
      if(this.model.ledgrp.rec.avbby != 'M'){
        this.model.ledgrp.blk.mixdet = '';
      }

      // draft at为disable时,清除draftat内容,同时清除drawee
      if(  this.model.ledgrp.rec.avbby == 'D' ||
          this.model.ledgrp.rec.avbby == 'M' ||
          this.model.ledgrp.rec.avbby == ''){
        this.model.ledgrp.blk.dftat = '';

        // 清除drawee的内容
        this.model.ledgrp.drw.pts = new Pts().data;
      }

      // defdet 为disable时,清除其内容
      if(this.model.ledgrp.rec.avbby != 'D' &&
          this.model.ledgrp.rec.avbby != 'N'){
        this.model.ledgrp.blk.defdet = '';
      }

      // by negotiate时,tenmaxday默认为空
      if(this.model.ledgrp.rec.avbby == 'N'){
        if(this.model.ledgrp.rec.tenmaxday === 0 || new BigNumber(this.model.ledgrp.rec.tenmaxday).comparedTo(0)===0){
          this.model.ledgrp.rec.tenmaxday='';
        }
      }else{
        if(this.model.ledgrp.rec.tenmaxday === '' || this.model.ledgrp.rec.tenmaxday === null){
          this.model.ledgrp.rec.tenmaxday=0;
        }
      }

      // by payment时,tenor day为disable,清空tenor day
      if(this.model.ledgrp.rec.avbby == 'P'){
        this.model.ledgrp.rec.tenmaxday=0;
      }
    },

    // 当iss改变时,如果stacty没有哦被修改过,则默认将iss所在地区的赋值给stacty字段
    changeStacty() {
      // ledgrp.rec.stacty not modified, when change iss, change the stacty.
      if (!(this.model.ledgrp.rec.modifySet != null && this.model.ledgrp.rec.modifySet.includes("stacty"))) {
        Api.post('/Lc/adr/getloccty', this.model.ledgrp.iss.pts.ptainr).then(res => {
          if (res.respCode == SUCCESS) {
            this.model.ledgrp.rec.stacty = res.data;
          }
        })
      }
      // 同时改变avb的值
      this.bankChanged();
    },

    nom1curChange(){
      this.changeBlkAddamtcov();
    },

    max2amtChange(){
      this.changeBlkAddamtcov();
      this.model.ledgrp.cbs.opn2.amt = this.model.ledgrp.cbs.max2.amt;
    },

    // 当max2 amt改变时,同时拼接addamtcov的值
    changeBlkAddamtcov(){

      // if addmatcov not modified, then automatic connect it.
      if(!this.model.ledgrp.blk.modifySet
          || !(this.model.ledgrp.blk.modifySet!=null&&this.model.ledgrp.blk.modifySet.includes("addamtcov"))){

        if(new BigNumber(this.model.ledgrp.cbs.max2.amt).comparedTo(new BigNumber("0"))>0){
          this.model.ledgrp.cbs.max2.cur = this.model.ledgrp.cbs.nom1.cur;

          let _currency = this.model.ledgrp.cbs.max2.cur;
          let _opn2amt =  this.model.ledgrp.cbs.max2.amt;
          if (_currency === "KRW" || _currency === "JPY") {
            _opn2amt = new BigNumber(_opn2amt).toFixed(0);
          }else {
            _opn2amt = new BigNumber(_opn2amt).toFixed(2);
          }
          this.model.ledgrp.blk.addamtcov = _currency + " " +_opn2amt;
        }
      }
    },

    nomtopChange(){
      let exp=/^\d+$/;
      if(!exp.test(this.model.ledgrp.rec.nomtop)){
        this.model.ledgrp.rec.nomtop = 0;
      }else{
        this.model.ledgrp.rec.nomtop = Number(this.model.ledgrp.rec.nomtop);
      }
      this.calculateMaxamt();
    },

    nomtonChange(){
      let exp=/^\d+$/;
      if(!exp.test(this.model.ledgrp.rec.nomton)){
        this.model.ledgrp.rec.nomton = 0;
      }else{
        this.model.ledgrp.rec.nomton = Number(this.model.ledgrp.rec.nomton);
      }
      //this.calculateMaxamt();
    },

    prepers18Change(){
      let exp=/^\d+$/;
      if(!exp.test(this.model.ledgrp.rec.prepers18)){
        this.model.ledgrp.rec.prepers18 = 0;
      }else{
        this.model.ledgrp.rec.prepers18 = Number(this.model.ledgrp.rec.prepers18);
      }
    },

    tenmaxdayChange(){
      let exp=/^\d+$/;
      if(!exp.test(this.model.ledgrp.rec.tenmaxday)){
        this.model.ledgrp.rec.tenmaxday = 0;
      }else{
        this.model.ledgrp.rec.tenmaxday = Number(this.model.ledgrp.rec.tenmaxday);
      }
    },

    
  },
};