index.js 17.1 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 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536
import Api from '~/service/Api';
import commonFunctions from '~/mixin/commonFunctions.js';
import BigNumber from 'bignumber.js';
import Pts from '../../../../components/business/commonModel/Pts.js';
import Pub from '../../../../components/business/commonModel/index.js';
export default {
  mixins: [commonFunctions],
  methods: {
    // 获取业务编号
    async getOwnref() {
      if (this.model.cpdgrp.cptrou == "") {
        this.$notify.warning({
          title: '提示',
          message: '请先选择邮路!'
        });
        return;
      }
      if (this.model.cpdgrp.orc.pts.ptainr == "") {
        this.$notify.warning({
          title: '提示',
          message: '请先选择汇款人!'
        });
        return;
      }
      let params = {
        ownref: this.model.cpdgrp.rec.ownref,
        ptainr: this.model.cpdgrp.orc.pts.ptainr,
      }
      const loading = this.loading();
      let res = await Api.post(`/${this.moduleRouter()}/cptopn/getRef`, params);
      loading.close();
      if (res.respCode === SUCCESS) {
        this.model.cpdgrp.rec.ownref = res.data;
        if (this.model.cpdgrp.rec.cptrou == 'SWIFT' && this.model.cpdgrp.rec.swftyp == '200') {
          this.root.isComputed = '';
          this.buildSetmod();
        }
        if (this.model.cpdgrp.rec.cptrou == 'CIPS' && this.model.cpdgrp.rec.swftyp != '') {
          this.defaultCommetN1000();
        }
      } else {
        this.$message.error(res.respMsg);
        return;
      }
    },

    // 设置CIPS附言字段
    async defaultCommetN1000() {
      const loading = this.loading();
      let res = await Api.post(`/${this.moduleRouter()}/cptopn/defaultCommetN1000`, this.model);
      loading.close();
      if (res.respCode === SUCCESS) {
        this.model.cptp.commet = res.data;
      }
    },

    // CIPS设置汇款人组织机构代码字段
    async getJuscod() {
      if(this.model.cpdgrp.orc.pts.ptyinr == ''){
        return;
      }
      if(this.model.cpdgrp.orc.pts.ptainr == ''){
        return;
      }
      const loading = this.loading();
      let params = {
        ptyinr: this.model.cpdgrp.orc.pts.ptyinr,
        ptainr: this.model.cpdgrp.orc.pts.ptainr,
      }
      let res = await Api.post(`/${this.moduleRouter()}/cptopn/getJuscod`, params);
      loading.close();
      if (res.respCode === SUCCESS) {
        this.model.fkrzhj = res.data.juscod;
        this.model.cptp.draweecountcode = res.data.loccty;
        if(!this.model.cptp.draweecountcode){
          this.$notify.error("汇款人常驻国家/地区代码为空,请先在静态参数中维护!");
        }
      }
    },


    // 模拟调用试算费用账务
    buildSetmod() {
      if (this.root.isComputed == 'Y') {
        return;
      }
      if (this.model.cpdgrp.cbs.nom1.cur == '') {
        return;
      }
      if (this.model.cpdgrp.cbs.nom1.amt == '' || this.model.cpdgrp.cbs.nom1.amt == 0) {
        return;
      }
      if (this.model.cpdgrp.orc.pts.ptainr == '') {
        return;
      }
      if (this.model.cpdgrp.pye.pts.ptainr == '') {
        return;
      }
      this.root.initSetmod(this.root.buildCommonData(this.model, "cptopn"));
      this.root.isComputed = 'Y';
    },

    // 事件 -- 清算路径
    cptrouChange() {
      this.model.cpdgrp.rec.swftyp = "";
      this.clearFields();
      this.initFields();
      if (this.model.cpdgrp.rec.cptrou == 'HNHZ') {
        this.activeNames = ["route", 'orcpye','opnp1','routeinfo','otherinfo'];
      }
    },

    // 事件 -- 报文类型
    swftypChange() {
      // 公共
      this.clearFields();
      this.initFields();
      if (this.model.cpdgrp.rec.swftyp != '') {
        this.activeNames = ["route", 'orcpye','opnp1','routeinfo','otherinfo'];
      } else {
        this.activeNames = ["route"];
      }

      // SWIFT
      if (this.model.cpdgrp.rec.cptrou == 'SWIFT') {
        if (this.model.cpdgrp.rec.swftyp == "200") {
          this.model.cptp.sin202 = 'Y';
        } else {
          this.model.cptp.sin202 = '';
        }
        this.setF36();
        this.setQsfysd();
      }

      // CIPS
      if (this.model.cpdgrp.rec.cptrou == 'CIPS') {
        if (this.model.cpdgrp.rec.swftyp == "CIU") {
          this.title = "CIPS111报文信息";
        }
        if (this.model.cpdgrp.rec.swftyp == "CIV") {
          this.title = "CIPS112报文信息";
        }
        if (this.model.cpdgrp.rec.swftyp == "CIVCOV") {
          this.title = "CIPS112COV报文信息";
        }
        this.defaultCommetN1000();
      }

      // JNWB
      if (this.model.cpdgrp.rec.cptrou == 'JNWB') {
        if (this.model.cpdgrp.rec.swftyp == '111') {
          this.model.attp.ywlxdm = "A100";
          this.model.attp.bustyp = '';
        }
        if (this.model.cpdgrp.rec.swftyp == '112') {
          this.model.attp.ywlxdm = "A200";
          this.model.attp.bustyp = '09110';
        }
        this.model.attp.acctyp = '';
      }

      // HNHZ
      if (this.model.cpdgrp.rec.cptrou == 'HNHZ') {

      }


    },

    clearFields() {
      // 基础信息
      this.model.cpdgrp.cbs.nom1.amt = new BigNumber(0);
      this.model.cpdgrp.cbs.max.amt = new BigNumber(0);
      this.model.cpdgrp.rec.curf33b = '';
      this.model.cpdgrp.rec.amtf33b = new BigNumber(0);
      this.model.cpdgrp.rec.f36 = new BigNumber(0);
      this.model.cpdgrp.rec.cur71f = '';
      this.model.cpdgrp.rec.amt71f = new BigNumber(0);
      this.model.cpdgrp.rec.ischktyp = '';
      this.model.cptp.fwtgyh = '';
      this.model.cpdgrp.rec.paytype = '';
      this.model.cpdgrp.rec.prechkdat = '';
      this.model.trtcre.crefinflg = '';
      this.model.dftcre.dfflag = '';
      this.model.cpdgrp.rec.tsnflg = '';
      this.model.cptp.qsfysd = '';
      this.model.cpdgrp.rec.orcact = '';
      this.model.cpdgrp.rec.pyeact = '';
      // 收/汇款人信息
      this.model.cpdgrp.orc.pts = new Pts().data;
      this.model.cpdgrp.pye.pts = new Pts().data;
      // cptp
      this.model.cptp.orcnam = '';
      this.model.cptp.orcadr = '';
      this.model.cptp.pyenam = '';
      this.model.cptp.pyeadr = '';
      // attp
      this.model.attp.orcnam = '';
      this.model.attp.orcnamfxps = '';
      this.model.attp.orcadr = '';
      this.model.attp.orcadrfxps = '';
      this.model.attp.pyenam = '';
      this.model.attp.pyenamfxps = '';
      this.model.attp.pyeadr = '';
      this.model.attp.pyeadrfxps = '';
      // 控制字段
      this.root.isComputed = '';
      this.title = '';
      // 其它组件模型
      this.model.setmod = new Pub().data.Setmod;
      // 等值人民币
      this.model.cnyamt = new BigNumber(0);
    },

    initFields() {
      // 缺陷ID:287344 让置为空
      this.model.cpdgrp.rec.trntyp = ""; // 0 - 货物贸易  ==>  01 货物贸易
      this.model.cpdgrp.rec.paytype = '0'; // 0 - 电汇
      this.model.cpdgrp.rec.ischktyp = 'N';// N-否 是否需要核验
      if (this.model.cpdgrp.rec.cptrou == 'SWIFT') {
        this.model.cpdgrp.cbs.nom1.cur = "USD";
        this.model.cpdgrp.cbs.max.cur = "USD";
        this.model.cpdgrp.cbs.nom1.amt = new BigNumber(0);
        this.model.cpdgrp.cbs.max.amt = new BigNumber(0);
        this.model.cpdgrp.rec.detchgcod = "OUR";
        this.model.cptp.payuil = "EN";
        if (this.model.cpdgrp.rec.swftyp == '103' || this.model.cpdgrp.rec.swftyp == '202') {
          this.model.cpdgrp.rec.f23b = "CRED"
        } else {
          this.model.cpdgrp.rec.f23b = ""
        }
      }
      if (this.model.cpdgrp.rec.cptrou == 'CIPS') {
        this.model.cpdgrp.cbs.nom1.cur = "CNY";
        this.model.cpdgrp.cbs.max.cur = "CNY";
        this.model.cpdgrp.cbs.nom1.amt = new BigNumber(0);
        this.model.cpdgrp.cbs.max.amt = new BigNumber(0);
        this.model.cpdgrp.rec.detchgcod = "SHAR";
        this.model.cptp.payuil = "EN";
      }
      if (this.model.cpdgrp.rec.cptrou == 'JNWB') {
        this.model.cpdgrp.cbs.nom1.cur = "USD";
        this.model.cpdgrp.cbs.max.cur = "USD";
        this.model.cpdgrp.cbs.nom1.amt = new BigNumber(0);
        this.model.cpdgrp.cbs.max.amt = new BigNumber(0);
        this.model.cpdgrp.rec.detchgcod = "OUR";
        this.model.attp.payuil = 'CN';
        this.model.attp.opndat = new Date();
        this.model.cpdgrp.rec.valdat = new Date();
      }
      if (this.model.cpdgrp.rec.cptrou == 'HNHZ') {
        this.model.cpdgrp.cbs.nom1.cur = "USD";
        this.model.cpdgrp.cbs.max.cur = "USD";
        this.model.cpdgrp.cbs.nom1.amt = new BigNumber(0);
        this.model.cpdgrp.cbs.max.amt = new BigNumber(0);
        this.model.attp.payuil = 'CN';
        this.model.attp.opndat = new Date();
        this.model.cpdgrp.rec.valdat = new Date();
      }

    },

    // SWIFT邮路事件

    // 事件 -- 等值人民币计算
    async calEqCnyAmt() {
      if (this.model.cpdgrp.cbs.nom1.cur == "") {
        this.$notify.warning({
          title: '提示',
          message: '请选择汇款币种!'
        });
        return;
      }
      // 勾选 录入人民币计算外币
      if(this.model.calflg == "Y"){
        if (this.model.cnyamt == "") {
          this.$notify.warning({
            title: '提示',
            message: '请输入等值人民币金额!'
          });
          return;
        }
      }
      const loading = this.loading();
      let res = await Api.post(`/${this.moduleRouter()}/cptopn/calAmt`, this.model);
      loading.close();
      if (res.respCode === SUCCESS) {
        console.log("计算金额为:"+res.data);
        if(this.model.calflg == "Y"){
          this.model.cpdgrp.cbs.nom1.amt = res.data;
          this.model.cpdgrp.cbs.max.amt = res.data;
          if(this.model.cpdgrp.cbs.nom1.amt != '' && this.model.cpdgrp.cbs.nom1.amt != 0){
            this.buildSetmod();
          }
        }
      }
    },

    // 事件 -- 等值人民币输入框
    cnyamtBlur(){
      this.calEqCnyAmt();
    },

    // 事件 -- 等值人民币勾选框
    calflgChange(){
      this.model.cpdgrp.cbs.nom1.amt = 0;
      this.model.cpdgrp.cbs.max.amt = 0;
      this.model.cnyamt = 0;
    },

    // 事件 -- 汇款金额币种
    nom1CurSwftChange() {
      this.model.cpdgrp.cbs.max.cur = this.model.cpdgrp.cbs.nom1.cur;
      this.model.cpdgrp.rec.feecur = this.model.cpdgrp.cbs.nom1.cur;
      this.setF36();
      this.buildSetmod();
    },
    // 事件 -- 汇款金额
    nom1AmtSwftBlur() {
      this.model.cpdgrp.cbs.max.cur = this.model.cpdgrp.cbs.nom1.cur;
      this.model.cpdgrp.cbs.max.amt = this.model.cpdgrp.cbs.nom1.amt;
      this.buildSetmod();
    },
    // 事件 -- 是否需要核验
    ischktypSwftChange() {
      if (this.model.cpdgrp.rec.ischktyp != 'Y') {
        this.model.cpdgrp.rec.prechkdat = null;
      }
    },
    // 事件 -- 清算费用锁定服务
    async qsfysdSwftChange() {
      if (this.model.cptp.qsfysd == '1') {
        const loading = this.loading();
        let res = await Api.post(`/${this.moduleRouter()}/cptopn/getFwtgyh`, this.model);
        loading.close();
        if (res.respCode === SUCCESS) {
          this.model.fwtgyhSet = res.data;
          if (this.model.fwtgyhSet.length > 0) {
            this.model.cptp.fwtgyh = this.model.fwtgyhSet[0].value;
          }
        }
      } else {
        this.model.cptp.fwtgyh = "";
      }
    },
    // 事件 -- 汇款人
    orcSwftChange() {
      this.model.cpdgrp.rec.nam = this.model.cpdgrp.orc.pts.nam;
      this.model.lastorcact = this.model.cpdgrp.rec.orcact;
      this.buildSetmod();
    },
    // 事件 -- 收款人
    pyeSwftChange() {
      this.model.cptp.pyenam = this.model.cpdgrp.pye.pts.nam;
      this.buildSetmod();
    },
    // 事件 -- 收款人常驻国家/地区代码
    payeecountcodeSwftChange() {
      if (this.model.cptp.payeecountcode != '') {
        this.model.cpdgrp.rec.pyectycod = this.model.cptp.payeecountcode;
      }
    },
    f36Disabled() {
      if ((this.model.cpdgrp.rec.swftyp == '103' || this.model.cpdgrp.rec.swftyp == '202') && this.model.cpdgrp.rec.curf33b != '' &&
        this.model.cpdgrp.rec.curf33b == this.model.cpdgrp.cbs.nom1.cur) {
        return true;
      }
      if ((this.model.cpdgrp.rec.swftyp == '103' || this.model.cpdgrp.rec.swftyp == '202') && (this.model.cpdgrp.rec.detchgcod == 'SHA' ||
          this.model.cpdgrp.rec.detchgcod == 'OUR')) {
        return true;
      }
      return false;
    },
    setF36() {
      if ((this.model.cpdgrp.rec.swftyp == '103' || this.model.cpdgrp.rec.swftyp == '202') && this.model.cpdgrp.rec.curf33b != '' &&
        this.model.cpdgrp.rec.curf33b == this.model.cpdgrp.cbs.nom1.cur) {
        this.model.cpdgrp.rec.f36 = new BigNumber(0);
      }
    },
    setQsfysd() {
      if (this.model.cpdgrp.rec.swftyp == '103') {
        this.model.cptp.qsfysd = "0";
      } else {
        this.model.cptp.qsfysd = "";
      }
    },


    // CIPS邮路事件

    // 事件 -- 汇款金额币种
    nom1CurCipsChange() {
      this.model.cpdgrp.cbs.max.cur = this.model.cpdgrp.cbs.nom1.cur;
      this.model.cpdgrp.rec.feecur = this.model.cpdgrp.cbs.nom1.cur;
      this.buildSetmod();
    },
    // 事件 -- 汇款金额
    nom1AmtCipsBlur() {
      this.model.cpdgrp.cbs.max.cur = this.model.cpdgrp.cbs.nom1.cur;
      this.model.cpdgrp.cbs.max.amt = this.model.cpdgrp.cbs.nom1.amt;
      this.buildSetmod();
    },
    // 事件 -- 汇款人
    orcCipsChange() {
      this.getJuscod();
      this.buildSetmod();
    },
    // 事件 -- 收款人
    pyeCipsChange() {
      this.buildSetmod();
    },
    // 事件 -- 费用承担方
    detchgcodCipsChange() {
    },
    // 事件 -- 是否需要核验
    ischktypCipsChange() {
      if (this.model.cpdgrp.rec.ischktyp != 'Y') {
        this.model.cpdgrp.rec.prechkdat = null;
      }
    },
    // 事件 -- 电汇凭证
    flgCipsChange() {
      this.defaultCommetN1000();
    },

    // JNWB邮路事件
    // 事件 -- 汇款金额币种
    nom1CurJnwbChange() {
      this.model.cpdgrp.cbs.max.cur = this.model.cpdgrp.cbs.nom1.cur;
      this.model.cpdgrp.rec.feecur = this.model.cpdgrp.cbs.nom1.cur;
      this.buildSetmod();
    },
    // 事件 -- 汇款金额
    nom1AmtJnwbBlur() {
      this.model.cpdgrp.cbs.max.cur = this.model.cpdgrp.cbs.nom1.cur;
      this.model.cpdgrp.cbs.max.amt = this.model.cpdgrp.cbs.nom1.amt;
      this.buildSetmod();
    },

    // 事件 -- 是否需要核验
    ischktypJnwbChange() {
      if (this.model.cpdgrp.rec.ischktyp != 'Y') {
        this.model.cpdgrp.rec.prechkdat = null;
      }
    },

    // 事件 -- 收款人常驻国家/地区代码
    paycountcodeJnwbChange() {
      if (this.model.attp.paycountcode != '') {
        this.model.cpdgrp.rec.pyectycod = this.model.attp.paycountcode;
      }
    },


    // 事件 -- 汇款人
    orcJnwbChange() {
      this.setOrcNamAndAdr();
      this.buildSetmod();
    },

    // 事件 -- 收款人
    pyeJnwbChange() {
      this.setPyeNamAndAdr();
      this.buildSetmod();
    },

    // 事件 -- 汇款语种
    payuilJnwbChange() {
      this.setOrcNamAndAdr();
      this.setPyeNamAndAdr();
    },

    setOrcNamAndAdr() {
      if (this.model.attp.payuil == 'CN') {
        this.model.attp.orcnamfxps = this.model.cpdgrp.orc.pts.cnnam;
        this.model.attp.orcnam = this.model.cpdgrp.orc.pts.cnnam;
        this.model.attp.orcadrfxps = this.model.cpdgrp.orc.pts.cnadr;
        this.model.attp.orcadr = this.model.cpdgrp.orc.pts.cnadr;
      } else {
        this.model.attp.orcnamfxps = this.model.cpdgrp.orc.pts.ennam;
        this.model.attp.orcnam = this.model.cpdgrp.orc.pts.ennam;
        this.model.attp.orcadrfxps = this.model.cpdgrp.orc.pts.enadr;
        this.model.attp.orcadr = this.model.cpdgrp.orc.pts.enadr;
      }
    },

    setPyeNamAndAdr() {
      if (this.model.attp.payuil == 'CN') {
        this.model.attp.pyenamfxps = this.model.cpdgrp.pye.pts.cnnam;
        this.model.attp.pyenam = this.model.cpdgrp.pye.pts.cnnam;
        this.model.attp.pyeadrfxps = this.model.cpdgrp.pye.pts.cnadr;
        this.model.attp.pyeadr = this.model.cpdgrp.pye.pts.cnadr;
      } else {
        this.model.attp.pyenamfxps = this.model.cpdgrp.pye.pts.ennam;
        this.model.attp.pyenam = this.model.cpdgrp.pye.pts.ennam;
        this.model.attp.pyeadrfxps = this.model.cpdgrp.pye.pts.enadr;
        this.model.attp.pyeadr = this.model.cpdgrp.pye.pts.enadr;
      }
    },

    // HNHZ邮路事件

    // 事件 -- 汇款金额币种
    nom1CurHnhzChange() {
      this.model.cpdgrp.cbs.max.cur = this.model.cpdgrp.cbs.nom1.cur;
      this.model.cpdgrp.rec.feecur = this.model.cpdgrp.cbs.nom1.cur;
    },
    // 事件 -- 汇款金额
    nom1AmtHnhzBlur() {
      this.model.cpdgrp.cbs.max.cur = this.model.cpdgrp.cbs.nom1.cur;
      this.model.cpdgrp.cbs.max.amt = this.model.cpdgrp.cbs.nom1.amt;
    },
    // 事件 -- 是否需要核验
    ischktypHnhzChange() {
      if (this.model.cpdgrp.rec.ischktyp != 'Y') {
        this.model.cpdgrp.rec.prechkdat = null;
      }
    },
    // 事件 -- 收款人常驻国家/地区代码
    payeecountcodeHnhzChange() {
      if (this.model.attp.paycountcode != '') {
        this.model.cpdgrp.rec.pyectycod = this.model.attp.paycountcode;
      }
    },
    opndatChange(){
      if(this.model.attp.opndat){
        this.model.attp.valdat = this.model.attp.opndat;
        this.model.cpdgrp.rec.valdat = this.model.attp.opndat;
      } else {
        this.model.attp.valdat = new Date();
        this.model.cpdgrp.rec.valdat = new Date();
      }
    }

  }
}