import moment from 'moment';
export default {
  methods: {
		defaultFunc () {
			// 根据max2的值是否大于0判断是否勾选附加金额字段
			let oldMax2Amt = this.model.gidgrp.cbs.max2.amt
			if (oldMax2Amt && Number(oldMax2Amt) > 0) {
				this.model.gitp0.gitp0s20 = 'X'
      }
      if(this.model.gidgrp.rec.expdat!='' && moment(new Date()).diff(moment(this.model.gidgrp.rec.expdat), 'days') < 0){
        this.$alert('保函注销日期早于保函到期日!', '提示',{
          conirmButtnText: '确定',
          type: 'warning'
        })
      }
		},
    //gidgrp.rec.purcan
    changePurcan() {
      if (this.model.gidgrp.rec.purcan === '') {
        this.model.gidgrp.rec.purcan = 'VE';
      }
      //切换注销原因后清空新保函编号
      if (this.model.gidgrp.rec.purcan !== 'RN') {
        this.model.newref = ""
      }
      if (this.model.gidgrp.rec.purcan != "RR") {
        this.model.gidgrp.rec.clsdat = new Date();
      } else {
				// 主动注销选取RR,减少金额默认是保函余额
				if(!this.model.spt || this.model.spt.sta != 'INC'){
					this.model.gidgrp.rec.redamt = this.model.gidgrp.cbs.opn1.amt
				}
        if (this.model.gidgrp.rec.redamt === this.model.gidgrp.cbs.opn1.amt) {
          this.model.gidgrp.rec.clsdat = new Date();
        } else {
          this.model.gidgrp.rec.clsdat = "";
        }
      }
      // if (this.model.spt.sta == "INC") {
      //   this.model.gidgrp.rec.purcan = "RR";
      // }

      //前端币种默认赋初值
      //国外扣费币种
      if (this.model.gidgrp.rec.redcur === "") {
        this.model.gidgrp.rec.redcur = this.model.gidgrp.cbs.opn1.cur;
      }
      //未偿付币种
      if (this.model.gidgrp.rec.outcur === "") {
        this.model.gidgrp.rec.outcur = this.model.gidgrp.cbs.opn1.cur;
      }
      //收费金额
      if (this.model.swiadd.chacur === "") {
        this.model.swiadd.chacur = this.model.gidgrp.cbs.opn1.cur;
      }
    },
  }
}