index.js 3.14 KB
import Api from '~/service/Api';
import commonFunctions from '~/mixin/commonFunctions.js';
import buildFn from './buildCommons.js';
import moment from 'moment';
import BigNumber from 'bignumber.js';

export default {
  mixins: [commonFunctions],
  methods: {
    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
      }
    },
    changeDocamt() {
      if (this.model.bodgrp.rec.focflg) {
        this.model.setmod.redamt = this.model.setmod.docamt
      }
      if (new BigNumber(this.model.setmod.docamt).comparedTo(new BigNumber(this.model.bodgrp.cbs.max.amt)) >= 0) {
        this.model.clsflg = 'X'
        this.model.bodgrp.rec.docsta = 'E';
        this.model.bodgrp.rec.clsdat = moment(new Date()).format("YYYY-MM-DD");
      } else {
        this.model.clsflg = ''
        this.model.bodgrp.rec.clsdat = ""
        if (this.model.bodgrp.rec.predat) {
          this.model.bodgrp.rec.docsta = 'A';
        }
        if (this.model.bodgrp.rec.opndat) {
          this.model.bodgrp.rec.docsta = 'B';
        }
        if (this.model.bodgrp.rec.focflg) {
          this.model.bodgrp.rec.docsta = 'D';
        }
      }
    },
    changeFocflg() {
      if (this.model.bodgrp.rec.focflg) {
        this.model.setmod.redamt = this.model.setmod.docamt;
        if (!this.model.clsflg == 'X') {
          this.model.bodgrp.rec.docsta = 'D';
        } else {
          this.model.bodgrp.rec.docsta = 'E';
        }
      } else {
        this.model.setmod.redamt = 0;
        if (this.model.bodgrp.rec.predat) {
          this.model.bodgrp.rec.docsta = 'A';
        }
        if (this.model.bodgrp.rec.opndat) {
          this.model.bodgrp.rec.docsta = 'B';
        }
        if (this.model.clsflg == 'X') {
          this.model.bodgrp.rec.docsta = 'E';
        }
      }
    },
    changeClsdat() {
      if (this.model.clsflg == 'X') {
        this.model.bodgrp.rec.clsdat = moment(new Date()).format('yyyy-MM-DD')
        this.model.bodgrp.rec.docsta = 'E';
      } else {
        this.model.bodgrp.rec.clsdat = '';
        if (this.model.bodgrp.rec.predat) {
          this.model.bodgrp.rec.docsta = 'A';
        }
        if (this.model.bodgrp.rec.opndat) {
          this.model.bodgrp.rec.docsta = 'B';
        }
        if (this.model.bodgrp.rec.focflg) {
          this.model.bodgrp.rec.docsta = 'D';
        }
      }
    },
  },
};