index.js 6.86 KB
Newer Older
xionglin committed
1 2 3 4 5 6 7 8
import Api from '~/service/Api';
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';
9 10
import limitbody from '~/components/business/limitbody/event';
import doctre from '~/components/business/doctre/event';
xionglin committed
11
import Utils from "~/utils"
12

xionglin committed
13 14 15 16 17 18 19 20
export default {
  mixins: [commonFunctions],
  methods: {
    ...setmod,
    ...glentry,
    ...engp,
    ...docpan,
    ...ccvpan,
21 22
    ...limitbody,
    ...doctre,
xionglin committed
23
    async init () {
24
      const params = {
WH committed
25
        spt: JSON.parse(localStorage.getItem('row_' + this.trnName)),
WH committed
26 27
        trn:JSON.parse(localStorage.getItem('review_'+this.trnName)),
        trninr: this.$route.query.trninr,
28
      }
xionglin committed
29
      const res = await Api.post('/service/litcan/init', {
30
        ...params,
xionglin committed
31 32
        transName: this.trnName,
        userId: window.sessionStorage.userId || 'ZL',
33 34
        lidgrp:{
          rec:{
35
            inr:this.$route.query.inr
36 37
          }
        }
38
        
xionglin committed
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
      });
      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) {
62 63 64
      if (this.isInDisplay) {
        return;
      }
xionglin committed
65 66 67 68 69 70 71 72 73 74
      let name = tab.name;
      switch (name) {
        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;
75
        case 'setmod':
xionglin committed
76 77 78 79 80 81 82 83 84 85 86 87 88 89
          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;
90
        case 'limitbody':
91
          let limitbodyRequest = buildFn.buildLimitbody(this.model, this.trnName);
92 93 94 95 96 97
          this.processLimitbody(limitbodyRequest);
          break;
        case 'doctre':
          let doctreRequest = buildFn.buildDoctre(this.model, this.trnName);
          this.processDoctre(doctreRequest);
          break;
98
          
xionglin committed
99 100 101 102
        default:
          return;
      }
    },
103 104
    // 点击获取按钮拉取当前key字段下的表单数据
    queryFormData(key) {
xionglin committed
105 106 107
      console.log(key);
    },
    // 业务信息=》基本信息=》保函编号-----获取保函编号
WH committed
108 109 110 111 112 113 114 115 116 117 118 119 120
    // async queryOwnref() {
    //   let params = {
    //     ptainr: this.model.gidgrp.apl.pts.ptainr,
    //     businessType: 'LG',
    //     tbl: 'LG',
    //   };
    //   const loading = this.loading();
    //   let res = await Api.post('/service/litcan/getOwnRef', params);
    //   if (res.respCode == SUCCESS) {
    //     loading.close();
    //     this.model.gidgrp.rec.ownref = res.data;
    //   }
    // },
121
    // 获取litcan弹框表格数据
xionglin committed
122 123 124 125
    async queryGridEtyPromptDialogData(type, ptytyp) {
      let params = {
        userId: window.sessionStorage.userId || 'ZL',
        ptytyp: ptytyp,
WH committed
126
        extkey: this.model.lidgrp[type.toLowerCase()].pts.extkey,
xionglin committed
127 128 129 130 131 132 133 134
      };
      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;
      }
    },
135
    // 选中litcan弹框表格的行数据
xionglin committed
136 137 138 139 140 141
    async selectGridEtyPromptData(row) {
      let params = {
        ...row,
      };
      let res = await Api.post('/service/ptspta/fetch', params);
      if (res.respCode == SUCCESS) {
WH committed
142
        this.$set(this.model.lidgrp, row.role.toLowerCase(), res.data);
xionglin committed
143 144 145 146 147 148 149
      }
    },
    // 业务信息=》基本信息=》支出目的
    purposChange(key, value) {
      this.handleChangeForm(key, value);
    },
    // 初始化保函开立类型码表下拉列表
WH committed
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
    // async queryHndtypCodeTableList(trnName) {
    //   let params = {
    //     gitp: {
    //       swiftflg: this.model.gitp.swiftflg,
    //     },
    //     gidgrp: {
    //       rec: {
    //         purpos: this.model.gidgrp.rec.purpos,
    //       },
    //     },
    //     transName: trnName.toUpperCase(),
    //   };
    //   let res = await Api.post('/service/litcan/initHndtyp', params);
    //   if (res.respCode == SUCCESS) {
    //     this.$set(this.codes, 'voHndtyp', res.data);
    //   }
    // },
xionglin committed
167
    // 是否SWIFT格式修改--联动保函开立类型
WH committed
168 169 170
    // handleChangeSwiftflg() {
    //   this.queryHndtypCodeTableList(this.root.trnName);
    // },
xionglin committed
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
    // 支出目的修改--联动保函开立类型
    handleChangePurpos() {
      this.queryHndtypCodeTableList(this.root.trnName);
    },
    buildLiaccv () {
      let params = {
        ...buildFn.buildCommonData(this.model, this.trnName),
        liaccvg: this.model.liaccv.liaccvg,
        oldamt: this.model.liaccv.oldamt,
        chgamt: this.model.liaccv.chgamt,
        concur: this.model.liaccv.concur,
      };
      
      return params
    },
    // 公共组件setmod处理方式改变触发联动
    changeSetmodModel (emitParams) {
      let reqParams = {}
      switch (emitParams.code) {
        case 'processMethods':
          reqParams = buildFn.buildSetglg(this.model, this.trnName);
          this.calcPayDetail(reqParams)
          break
        case 'changeDsp':
          let index = emitParams.index;
          let setglgRequest = buildFn.buildSetglg(this.model, this.trnName);
          setglgRequest.setglg = {setgll:  emitParams.list};
          this.setgllAccts(setglgRequest, index);
          break
        default:
          return
      }
    }
204 205
  },
};