index.js 6.27 KB
Newer Older
WH 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
import Api from '~/service/Api';
import Utils from '~/utils';
import commonFunctions from '~/mixin/commonFunctions.js';
import buildFn from './buildCommons.js';
import setmod from '~/components/business/setmod/event';
import glentry from '~/components/business/glentry/event';
import engp from '~/components/business/engp/event';
import docpan from '~/components/business/docpan/event';
import ccvpan from '~/components/business/ccvpan/event';
import limitbody from '~/components/business/limitbody/event';
import doctre from '~/components/business/doctre/event';
export default {
  mixins: [commonFunctions],
  methods: {
    ...setmod,
    ...glentry,
    ...engp,
    ...docpan,
    ...ccvpan,
    ...limitbody,
    ...doctre,
    async init () {
      const params = {
        spt: JSON.parse(localStorage.getItem('row_' + this.trnName)),
        trnmod:{
          trn:JSON.parse(localStorage.getItem('review_'+this.trnName))
        }
      }
      if ( typeof(this.$route.query.inr) == 'string' ){
        params.spt = null
        params.trnmod.trn =null
      }
      const res = await Api.post('/service/letrsv/init', {
        ...params,
        transName: this.trnName,
        userId: window.sessionStorage.userId || 'ZL',
panziyi committed
37 38 39 40 41
        ledgrp:{
          rec:{
            inr: this.$route.query.inr
          }
        },
WH committed
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
      });
      // loading.close();
      if (!res.data) {
        return
      }
      this.copyValueFromVoData(this.model, res.data)
      this.copyValueFromVoData(this.model.setmod.setfeg, res.data.setfeg)
      this.copyValueFromVoData(this.model.setmod.setfog, res.data.setfog)
      this.copyValueFromVoData(this.model.setmod.setglg, res.data.setglg)
    },
    // 兼容处理在前端model中定义了字段,后端返回的数据中不存在字段的问题
    copyValueFromVoData (model, data) {
      let keysList = Object.keys(model)
      keysList.map((key) => {
        if (data[key]) {
          if (Utils.typeOf(model[key]) === 'Object') {
            this.copyValueFromVoData(model[key], data[key])
          } else {
            this.$set(model, key, data[key])
          }
        }
      })
    },
    async tabClick(tab) {
      if (this.isInDisplay) {
        return;
      }
      let name = tab.name;
      switch (name) {
        case 'setmod':
          let setfegRequest = buildFn.buildSetfeg(this.model, this.trnName);
          // 此处利用回调是为了等setfeg的接口调用完成后才去获取setglg参数,由于setglg参数依赖于setfeg函数的返回值
          this.processSetpan(setfegRequest, () => {
            return buildFn.buildSetglg(this.model, this.trnName);
          });
          break;
        case 'ccvpan':
          let ccvpanRequest = buildFn.buildCcvpan(this.model, this.trnName);
          this.processLiaccv(ccvpanRequest);
          break;
        case 'engp':
          let engpRequest = buildFn.buildEngp(this.model, this.trnName);
          this.processLiaall(engpRequest);
          break;
        // case 'setpan':
        //   let setfegRequest = buildFn.buildSetfeg(this.model, this.trnName);
        //   // 此处利用回调是为了等setfeg的接口调用完成后才去获取setglg参数,由于setglg参数依赖于setfeg函数的返回值
        //   this.processSetpan(setfegRequest, () => {
        //     return buildFn.buildSetglg(this.model, this.trnName);
        //   });
        //   break;
        case 'docpan':
          let docpanRequest = buildFn.buildDocpan(this.model, this.trnName);
          this.processTrndoc(docpanRequest);
          break;
        case 'glepan':
          let glentryRequest = buildFn.buildGlentry(this.model, this.trnName);
          this.processGlentry(glentryRequest);
          break;
        case 'limitbody':
          let limitbodyRequest = buildFn.buildLimitbody(
            this.model,
            this.trnName
          );
          this.processLimitbody(limitbodyRequest);
          break;
        case 'doctre':
          let doctreRequest = buildFn.buildDoctre(this.model, this.trnName);
          this.processDoctre(doctreRequest);
          break;
        default:
          return;
      }
    },
    // 获取弹框表格数据
    async queryGridEtyPromptDialogData(type, ptytyp) {
      let params = {
        userId: window.sessionStorage.userId || 'ZL',
        ptytyp: ptytyp,
        extkey: this.model.ledgrp[type.toLowerCase()].pts.extkey,
      };
      let res = await Api.post('/service/ptspta/list', params);
      if (res.respCode == SUCCESS) {
        this.root.$refs['etyDialog'].show = true;
        this.root.promptData.data = res.data.ptaInfos;
        this.root.promptData.type = type;
      }
    },
    // 选中gitopn弹框表格的行数据
    async selectGridEtyPromptData(row) {
      let params = {
        ...row,
      };
      let res = await Api.post('/service/ptspta/fetch', params);
      if (res.respCode == SUCCESS) {
        this.$set(this.model.ledgrp, row.role.toLowerCase(), res.data);
      }
    },
    //获取信用证编号
    async onLitpButgetref() {
      let params = {
闫泽浩 committed
143 144 145
        ptainr: this.model.ledgrp.ben.pts.ptainr,
        businessType: 'RS',
        tbl: 'RS',
WH committed
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
      };
      const loading = this.loading();
      let res = await Api.post('/service/letrsv/getOwnRef', params);
      if (res.respCode == SUCCESS) {
        loading.close();
        this.model.ledgrp.rec.ownref = res.data;
      }
    },
    //指定银行
    async avbwthFlg() {
      let ptsList = []
      ptsList.push(this.model.ledgrp.adv)
      ptsList.push(this.model.ledgrp.a2b)
      ptsList.push(this.model.ledgrp.iss)
      let params = {
        avbwth: this.model.ledgrp.rec.avbwth,
        ptsList
      };
      let res = await Api.post('/service/letrsv/avbwthflg', params);
      if (res.respCode == SUCCESS) {
        this.model.ledgrp.avb.pts.extkey=res.data.pts.extkey;
        this.model.ledgrp.avb.pts.adrblk=res.data.pts.adrblk;
      }
    },
    //最大金额
    async cbsmax() {
      let params = {
        nom1cur: this.model.ledgrp.cbs.nom1.cur,
        nom1amt: this.model.ledgrp.cbs.nom1.amt,
        nomtop:  this.model.ledgrp.rec.nomtop
      };
      let res = await Api.post('/service/letrsv/cbsmax', params);
      if (res.respCode == SUCCESS) {
        this.model.ledgrp.cbs.max.cur = res.data.maxcur;
        this.model.ledgrp.cbs.max.amt = res.data.maxamt;
      }
    },
    
  },
};