import Api from '~/service/Api';
import commonFunctions from '~/mixin/commonFunctions.js';
import Utils from "~/utils/index";
import BigNumber from 'bignumber.js';
import Pub from '../../../../components/business/commonModel/index.js';
export default {
  mixins: [commonFunctions],
  methods: {
    // 获取业务编号
    async getOwnref() {
      if (this.model.jsdgrp.apl.pts.ptainr == "") {
        this.$notify.warning({
          title: '提示',
          message: '请先选择申请人!'
        });
        return;
      }
      if (this.model.jsdgrp.rec.shfobz == "0" && this.model.jsdgrp.rec.maimpz == '') {
        this.$notify.warning({
          title: '提示',
          message: '请先选择买卖品种!'
        });
        return;
      }
      let params = {
        ownref: this.model.jsdgrp.rec.ownref,
        ptainr: this.model.jsdgrp.apl.pts.ptainr,
        shfobz: this.model.jsdgrp.rec.shfobz,
        maimpz: this.model.jsdgrp.rec.maimpz,
      }
      const loading = this.loading();
      let res = await Api.post(`/${this.moduleRouter()}/jstopn/getRef`, params);
      loading.close();
      if (res.respCode === SUCCESS) {
        this.model.jsdgrp.rec.ownref = res.data;
      } else {
        this.$message.error(res.respMsg);
      }
    },
    // 校验金额最大值
    async checkMaxAmt() {
      if (this.model.jsdgrp.rec.maimpz == "") {
        return;
      }
      if (this.model.jsdgrp.rec.maimpz != "4" && this.model.jsdgrp.rec.maimpz != "5") {
        return;
      }
      if (this.model.jsdgrp.rec.pngcfx == "") {
        return;
      }
      if (this.model.jsdgrp.rec.pngcfx == '0' && (this.model.jsdgrp.cbs.max1.cur == "" || new BigNumber(this.model.jsdgrp.cbs.max1.amt).isZero())) {
        return;
      }
      if (this.model.jsdgrp.rec.pngcfx == '1' && (this.model.jsdgrp.cbs.max2.cur == "" || new BigNumber(this.model.jsdgrp.cbs.max2.amt).isZero())) {
        return;
      }
      let curTemp = '';
      let amtTemp = 0;
      if (this.model.jsdgrp.rec.pngcfx == '0') {
        curTemp = this.model.jsdgrp.cbs.max1.cur;
        amtTemp = this.model.jsdgrp.cbs.max1.amt;
      }
      if (this.model.jsdgrp.rec.pngcfx == '1') {
        curTemp = this.model.jsdgrp.cbs.max2.cur;
        amtTemp = this.model.jsdgrp.cbs.max2.amt;
      }

      let params = {
        // 买卖品种 4-结汇 5-售汇
        maimpz: this.model.jsdgrp.rec.maimpz,
        // 买卖方向 0-买入 1-卖出
        pngcfx: this.model.jsdgrp.rec.pngcfx,
        cur: curTemp,
        amt: amtTemp,
        shfobz: this.model.jsdgrp.rec.shfobz,
      }
      const loading = this.loading();
      let res = await Api.post(`/${this.moduleRouter()}/jstopn/checkMaxAmt`, params);
      loading.close();
      if (res.respCode === SUCCESS) {
        if (res.data != 'ALLOW') {
          this.$notify.error({
            title: '提示',
            message: res.data
          });
          return;
        }
      }
    },
    // 校验账号
    async checkAccount(accountTemp) {
      if (this.model.jsdgrp.apl.pts.ptainr == "") {
        this.$notify.warning({
          title: '提示',
          message: '请先选择申请人!'
        });
        return;
      }
      let params = {
        account: accountTemp,
        ptainr: this.model.jsdgrp.apl.pts.ptainr,
      }
      const loading = this.loading();
      let res = await Api.post(`/${this.moduleRouter()}/jstopn/checkAccount`, params);
      loading.close();
      if (res.respCode === SUCCESS) {
        return res.data;
      } else {
        this.$message.error(res.respMsg);
      }
    },

    // 事件 -- 大小额标志
    shfobzChange() {
      if (this.model.jsdgrp.rec.shfobz == '0') {
        this.model.jsdgrp.rec.khwtxz = '1';
      } else {
        this.model.jsdgrp.rec.khwtxz = '';
        this.model.jsdgrp.cbs.max1.amt = '0';
        this.model.jsdgrp.cbs.max2.amt = '0';
        // 大额时清空费用账务信息
        this.model.setmod = new Pub().data.Setmod;
      }
      this.model.jsdgrp.rec.ownref = '';
    },
    // 事件 -- 买卖品种
    maimpzChange() {
      if (this.model.jsdgrp.rec.maimpz == '4') {
        // 结汇
        this.model.jsdgrp.cbs.max1.cur = '';
        this.model.jsdgrp.cbs.max2.cur = 'CNY';
        this.model.jsdgrp.rec.pngcfx = '0';
      } else if (this.model.jsdgrp.rec.maimpz == '5') {
        // 售汇
        this.model.jsdgrp.cbs.max1.cur = 'CNY';
        this.model.jsdgrp.cbs.max2.cur = '';
        this.model.jsdgrp.rec.pngcfx = '1';
      } else {
        this.model.jsdgrp.cbs.max1.cur = '';
        this.model.jsdgrp.cbs.max2.cur = '';
        this.model.jsdgrp.rec.pngcfx = '';
      }
      this.clearRzActInfo();
      this.clearCzActInfo();
      if (this.model.jsdgrp.rec.shfobz == '0') {
        this.model.jsdgrp.rec.ownref = '';
        this.calAmt();
        this.getPtyRate();
      }
      if (this.model.jsdgrp.rec.shfobz == '1' && this.model.jsdgrp.rec.khwtxz == '2') {
        this.calAmt();
      }
      this.rzhtypChange();
      this.czhtypChange();
      this.clearOldData();
    },
    // 事件 -- 买卖方向
    pngcfxChange() {
      if (this.model.jsdgrp.rec.pngcfx == '0') {
        this.model.jsdgrp.cbs.max2.amt = new BigNumber(0);
      }
      if (this.model.jsdgrp.rec.pngcfx == '1') {
        this.model.jsdgrp.cbs.max1.amt = new BigNumber(0);
      }
      this.setMaxCurAndAmt();
      if (this.model.jsdgrp.rec.shfobz == '0') {
        this.getRelRate();
        this.calAmt();
      }
      if (this.model.jsdgrp.rec.shfobz == '1' && this.model.jsdgrp.rec.khwtxz == '2') {
        this.calAmt();
      }
    },
    // 事件 -- 银行买入金额币种
    max1CurChange() {
      this.setMaxCurAndAmt();
      // this.checkMaxAmt();
      this.clearRzActInfo();
      if (this.model.jsdgrp.rec.shfobz == '0') {
        this.getPtyRate();
        this.getRelRate();
        this.calAmt();
      }
      if (this.model.jsdgrp.rec.shfobz == '1' && this.model.jsdgrp.rec.khwtxz == '2') {
        this.calAmt();
      }
      this.rzhtypChange();
      this.czhtypChange();
    },
    // 事件 -- 银行买入金额
    max1AmtBlur() {
      this.setMaxCurAndAmt();
      // this.checkMaxAmt();
      if (this.model.jsdgrp.rec.shfobz == '0') {
        this.calAmt();
      }
      if (this.model.jsdgrp.rec.shfobz == '1' && this.model.jsdgrp.rec.khwtxz == '2') {
        this.calAmt();
      }
    },
    // 事件 -- 银行卖出金额币种
    max2CurChange() {
      this.setMaxCurAndAmt();
      // this.checkMaxAmt();
      this.clearCzActInfo();
      if (this.model.jsdgrp.rec.shfobz == '0') {
        this.getPtyRate();
        this.getRelRate();
        this.calAmt();
      }
      if (this.model.jsdgrp.rec.shfobz == '1' && this.model.jsdgrp.rec.khwtxz == '2') {
        this.calAmt();
      }
      this.rzhtypChange();
      this.czhtypChange();
    },
    // 事件 -- 银行卖出金额
    max2AmtBlur() {
      this.setMaxCurAndAmt();
      // this.checkMaxAmt();
      if (this.model.jsdgrp.rec.shfobz == '0') {
        this.calAmt();
      }
      if (this.model.jsdgrp.rec.shfobz == '1' && this.model.jsdgrp.rec.khwtxz == '2') {
        this.calAmt();
      }
    },
    // 事件 -- 客户选择
    khwtxzChange() {
      // KHWTXZ 客户选择 ==> 1:接受时价、2:输入最小获利期望
      if (this.model.jsdgrp.rec.shfobz == '0') {
        this.getRelRate();
      }
      if (this.model.jsdgrp.rec.shfobz == '1' && this.model.jsdgrp.rec.khwtxz == '1') {
        this.model.jsdgrp.rec.weithl = '0';
        this.model.jsdgrp.rec.jqmrhl = '0';
      }
    },
    // 事件 -- 委托汇率
    weithlBlur() {
      this.model.jsdgrp.blk.weithl = this.model.jsdgrp.rec.weithl;
      if (this.model.jsdgrp.rec.shfobz == '0') {
        this.calAmt();
      }
      if (this.model.jsdgrp.rec.shfobz == '1' && this.model.jsdgrp.rec.khwtxz == '2') {
        this.calAmt();
      }
    },
    // 事件 -- 申请人
    async aplChange() {
      let params = {
        ptainr: this.model.jsdgrp.apl.pts.ptainr,
        ptyinr: this.model.jsdgrp.apl.pts.ptyinr,
      }
      const loading = this.loading();
      let res = await Api.post(`/${this.moduleRouter()}/jstopn/getWrkBranch`, params);
      loading.close();
      if (res.respCode === SUCCESS) {
        this.model.jsdgrp.rec.ruzhjg = res.data.ruzhjg;
        this.model.jsdgrp.rec.dianhh = res.data.dianhh;
        this.model.jsdgrp.rec.dfkhlb = res.data.dfkhlb;
        if (this.model.jsdgrp.rec.maimpz == '4') {
          this.model.jsdgrp.rec.yohulx = res.data.buytyp;
          this.model.jsdgrp.rec.zdngll = res.data.buyrat;
        }
        if (this.model.jsdgrp.rec.maimpz == '5') {
          this.model.jsdgrp.rec.yohulx = res.data.seltyp;
          this.model.jsdgrp.rec.zdngll = res.data.selrat;
        }
        if (this.model.jsdgrp.rec.dfkhlb == '01') {
          this.$notify.warning("请确认,该客户是否为我行");
        }
        if (this.model.jsdgrp.rec.yohulx == '0') {
          this.model.jsdgrp.rec.zdngll = '0';
        }
      }
      this.clearRzActInfo();
      this.clearCzActInfo();
      this.rzhtypChange();
      this.czhtypChange();
    },
    // 事件 -- 获取客户优惠汇率
    async getPtyRate() {
      if (this.model.jsdgrp.apl.pts.ptainr == '') {
        return;
      }
      if (this.model.jsdgrp.apl.pts.ptyinr == '') {
        return;
      }
      var curTemp = '';
      if (this.model.jsdgrp.rec.maimpz == '4') {
        curTemp = this.model.jsdgrp.cbs.max1.cur;
      }
      if (this.model.jsdgrp.rec.maimpz == '5') {
        curTemp = this.model.jsdgrp.cbs.max2.cur;
      }
      if (curTemp == '') {
        return;
      }
      let params = {
        ptainr: this.model.jsdgrp.apl.pts.ptainr,
        ptyinr: this.model.jsdgrp.apl.pts.ptyinr,
        cur: curTemp,
      }
      const loading = this.loading();
      let res = await Api.post(`/${this.moduleRouter()}/jstopn/getWrkBranch`, params);
      loading.close();
      if (res.respCode === SUCCESS) {
        if (this.model.jsdgrp.rec.maimpz == '4') {
          this.model.jsdgrp.rec.yohulx = res.data.buytyp;
          this.model.jsdgrp.rec.zdngll = res.data.buyrat;
        }
        if (this.model.jsdgrp.rec.maimpz == '5') {
          this.model.jsdgrp.rec.yohulx = res.data.seltyp;
          this.model.jsdgrp.rec.zdngll = res.data.selrat;
        }
        if (this.model.jsdgrp.rec.yohulx == '0') {
          this.model.jsdgrp.rec.zdngll = '0';
        }
        this.getRelRate();
      }
    },
    // 事件 -- 入账账号校验
    async zha1zhChange() {
      var result = await this.checkAccount(this.model.jsdgrp.rec.zha1zh);
      var txt = "【" + this.model.jsdgrp.rec.zha1zh + "】账户性质为待核查账户,请确认是否符合相关规定,是否使用此账户?";
      if ("Y" == result.dhcflg) {
        this.$confirm(txt, '提示', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
          showClose: false
        }).then(() => { //yes的执行在这里写
          this.model.verifyFlag = "X";
          return;
        }).catch(() => { //No的功能在这里写
          this.model.jsdgrp.rec.zha1zh = '';
          this.$message({
            type: 'info',
            message: '请重新选择账户'
          });
        });
      } else {
        // 售汇时,校验入账账号的账户性质是否为结汇待支付账户
        if (this.model.jsdgrp.rec.maimpz == '5') {
          var txt2 = "【" + this.model.jsdgrp.rec.zha1zh + "】账户性质为结汇待支付账户,请确认是否符合相关规定,是否使用此账户?";
          if ("Y" == result.jhdflg) {
            this.$confirm(txt2, '提示', {
              confirmButtonText: '是',
              cancelButtonText: '否',
              type: 'warning',
              showClose: false
            }).then(() => { //yes的执行在这里写
              return;
            }).catch(() => { //No的功能在这里写
              this.model.jsdgrp.rec.zha1zh = '';
              this.$message({
                type: 'info',
                message: '请重新选择账户'
              });
            });
          }
        }
      }
      this.model.verifyFlag = "";
    },
    // 事件 -- 获取入账账号列表
    async rzhtypChange() {
      if (this.model.jsdgrp.apl.pts.ptyinr == '') {
        return;
      }
      if (this.model.jsdgrp.rec.rzhtyp == '') {
        return;
      }
      if (this.model.jsdgrp.cbs.max1.cur == '') {
        return;
      }
      if (this.model.jsdgrp.apl.pts.ptainr == '') {
        return;
      }
      let params = {
        ptyinr: this.model.jsdgrp.apl.pts.ptyinr,
        trmtyp: this.model.jsdgrp.rec.rzhtyp,
        cur: this.model.jsdgrp.cbs.max1.cur,
        ptainr: this.model.jsdgrp.apl.pts.ptainr,
      }
      const loading = this.loading();
      let res = await Api.post(`/${this.moduleRouter()}/jstopn/getAccList`, params);
      loading.close();
      if (res.respCode === SUCCESS) {
        this.zha1zhList = res.data;
      }
    },
    // 事件 -- 出账账号校验
    async zhanghChange() {
      var result = await this.checkAccount(this.model.jsdgrp.rec.zhangh);
      var txt = "【" + this.model.jsdgrp.rec.zhangh + "】账户性质为待核查账户,请确认是否符合相关规定,是否使用此账户?";
      if ("Y" == result.dhcflg) {
        this.$confirm(txt, '提示', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
          showClose: false
        }).then(() => { //yes的执行在这里写

        }).catch(() => { //No的功能在这里写
          this.model.jsdgrp.rec.zhangh = '';
          this.$message({
            type: 'info',
            message: '请重新选择账户'
          });
        });
      }
    },
    // 事件 -- 获取出账账号列表
    async czhtypChange() {
      if (this.model.jsdgrp.apl.pts.ptyinr == '') {
        return;
      }
      if (this.model.jsdgrp.rec.czhtyp == '') {
        return;
      }
      if (this.model.jsdgrp.cbs.max2.cur == '') {
        return;
      }
      if (this.model.jsdgrp.apl.pts.ptainr == '') {
        return;
      }
      let params = {
        ptyinr: this.model.jsdgrp.apl.pts.ptyinr,
        trmtyp: this.model.jsdgrp.rec.czhtyp,
        cur: this.model.jsdgrp.cbs.max2.cur,
        ptainr: this.model.jsdgrp.apl.pts.ptainr,
      }
      const loading = this.loading();
      let res = await Api.post(`/${this.moduleRouter()}/jstopn/getAccList`, params);
      loading.close();
      if (res.respCode === SUCCESS) {
        this.zhanghList = res.data;
      }
    },
    // 事件 -- 获取账号具体信息
    async getCoreAccountInfo(actVal, curVal) {
      if (actVal === '') {
        this.$alert('请先获取账号!', '提示', {
          confirmButtonText: '确定'
        });
        return;
      }
      let request = {
        account: actVal
      }
      let loading = this.loading('正在获取详情信息中...');
      let rtnmsg = await Api.post(`/${this.moduleRouter()}/jstopn/getCoreAccountCode`, request);
      if (rtnmsg.respCode === SUCCESS) {
        if (rtnmsg.data.errorMsg !== '' && rtnmsg.data.errorMsg !== null) {
          this.$alert(rtnmsg.data.errorMsg, '提示', {
            confirmButtonText: '确定'
          });
        } else {
          var acccode = rtnmsg.data.acctCode;
          var zhuzwm = rtnmsg.data.zhuzwm;
          var wjzhxz = rtnmsg.data.wjzhxz;
          var accountBalance = rtnmsg.data.acctBalance;
          this.$alert('账号:' + actVal + '<br/>户名为:' + zhuzwm + '<br/>账号性质为:' + wjzhxz + '<br/>账户科目号为:' + acccode + '<br/>账户余额为:' + curVal + this.moneyFormat(accountBalance, curVal) + '<br/>账户状态为:' + rtnmsg.data.jiluzt, '提示', {
            confirmButtonText: '确定',
            dangerouslyUseHTMLString: true
          });
        }
      }
      loading.close();
    },
    // 事件 -- 结售汇统计代码
    async waitjmChange() {
      let dirTemp = "I";
      if (this.model.jsdgrp.rec.maimpz == '4') {
        dirTemp = 'I';
      }
      if (this.model.jsdgrp.rec.maimpz == '5') {
        dirTemp = 'O';
      }
      let params = {
        dir: dirTemp,
        waitjm: this.model.jsdgrp.rec.waitjm,
      }
      const loading = this.loading();
      let res = await Api.post(`/${this.moduleRouter()}/jstopn/getBopcodListByWaitjm`, params);
      loading.close();
      if (res.respCode === SUCCESS) {
        // 码表 - 国际收支申报交易编码
        this.model.gjszcdList = res.data;
      }
      this.model.jsdgrp.rec.txcode = '';
      this.model.jsdgrp.rec.regno = '';
    },
    // 获取交易成交汇率
    async getRate() {
      if (this.model.jsdgrp.rec.maimpz == "") {
        return;
      }
      if (this.model.jsdgrp.cbs.max1.cur == "") {
        return;
      }
      if (this.model.jsdgrp.cbs.max2.cur == "") {
        return;
      }
      if (this.model.jsdgrp.rec.khwtxz == '2' || this.model.jsdgrp.rec.khwtxz == '') {
        return;
      }
      let fromCur = '';
      let toCur = '';
      // 结汇
      if (this.model.jsdgrp.rec.maimpz == '4') {
        fromCur = this.model.jsdgrp.cbs.max1.cur;
        toCur = this.model.jsdgrp.cbs.max2.cur;
      }
      // 售汇
      if (this.model.jsdgrp.rec.maimpz == '5') {
        fromCur = this.model.jsdgrp.cbs.max2.cur;
        toCur = this.model.jsdgrp.cbs.max1.cur;
      }
      let params = {
        fromCur: fromCur,
        toCur: toCur,
        ptainr: this.model.jsdgrp.apl.pts.ptainr,
        ptyinr: this.model.jsdgrp.apl.pts.ptyinr,
        maimpz: this.model.jsdgrp.rec.maimpz,
      }
      const loading = this.loading();
      let res = await Api.post(`/${this.moduleRouter()}/jstopn/getRate`, params);
      loading.close();
      if (res.respCode === SUCCESS) {
        this.model.jsdgrp.rec.weithl = res.data;
        this.model.jsdgrp.blk.weithl = res.data;
        this.calAmt();
      } else {
        this.$notify.error(res.respMsg);
      }
    },
    // 获取当前牌价及交易成交汇率
    async getRelRate() {
      if (this.model.jsdgrp.rec.maimpz == "") {
        return;
      }
      if (this.model.jsdgrp.cbs.max1.cur == "") {
        return;
      }
      if (this.model.jsdgrp.cbs.max2.cur == "") {
        return;
      }
      if (this.model.jsdgrp.rec.khwtxz == '2' || this.model.jsdgrp.rec.khwtxz == '') {
        return;
      }
      let fromCur = '';
      let toCur = '';
      // 结汇
      if (this.model.jsdgrp.rec.maimpz == '4') {
        fromCur = this.model.jsdgrp.cbs.max1.cur;
        toCur = this.model.jsdgrp.cbs.max2.cur;
      }
      // 售汇
      if (this.model.jsdgrp.rec.maimpz == '5') {
        fromCur = this.model.jsdgrp.cbs.max2.cur;
        toCur = this.model.jsdgrp.cbs.max1.cur;
      }
      let params = {
        fromCur: fromCur,
        toCur: toCur,
        ptainr: this.model.jsdgrp.apl.pts.ptainr,
        ptyinr: this.model.jsdgrp.apl.pts.ptyinr,
        maimpz: this.model.jsdgrp.rec.maimpz,
        seltyp: this.model.jsdgrp.rec.yohulx,
        buytyp: this.model.jsdgrp.rec.yohulx,
        selrat: this.model.jsdgrp.rec.zdngll,
        buyrat: this.model.jsdgrp.rec.zdngll,
        yohflg: '1',
      }
      const loading = this.loading();
      let res = await Api.post(`/${this.moduleRouter()}/jstopn/getRelRate`, params);
      loading.close();
      if (res.respCode === SUCCESS) {
        this.model.jsdgrp.rec.weithl = res.data.weithl;
        this.model.jsdgrp.blk.weithl = res.data.weithl;
        this.model.jsdgrp.rec.jqmrhl = res.data.jqmrhl;
        this.calAmt();
      } else {
        this.$notify.error(res.respMsg);
      }
    },
    // 根据汇率计算金额
    async calAmt() {
      // 买入
      if (this.model.jsdgrp.rec.pngcfx == '0') {
        if (new BigNumber(this.model.jsdgrp.cbs.max1.amt).isZero()) {
          this.model.jsdgrp.cbs.max2.amt = 0;
          return;
        }
      }
      // 卖出
      if (this.model.jsdgrp.rec.pngcfx == '1') {
        if (new BigNumber(this.model.jsdgrp.cbs.max2.amt).isZero()) {
          this.model.jsdgrp.cbs.max1.amt = 0;
          return;
        }
      }
      if (this.model.jsdgrp.cbs.max1.cur == '') {
        return;
      }
      if (this.model.jsdgrp.cbs.max2.cur == '') {
        return;
      }
      let fromCur = '';
      let toCur = '';
      let amt = new BigNumber(0);
      // 结汇
      if (this.model.jsdgrp.rec.maimpz == '4') {
        // 买入
        if (this.model.jsdgrp.rec.pngcfx == '0') {
          fromCur = this.model.jsdgrp.cbs.max1.cur;
          toCur = this.model.jsdgrp.cbs.max2.cur;
          amt = this.model.jsdgrp.cbs.max1.amt;
        }
        // 卖出
        if (this.model.jsdgrp.rec.pngcfx == '1') {
          fromCur = this.model.jsdgrp.cbs.max2.cur;
          toCur = this.model.jsdgrp.cbs.max1.cur;
          amt = this.model.jsdgrp.cbs.max2.amt;
        }
      }
      // 售汇
      if (this.model.jsdgrp.rec.maimpz == '5') {
        // 买入
        if (this.model.jsdgrp.rec.pngcfx == '0') {
          fromCur = this.model.jsdgrp.cbs.max2.cur;
          toCur = this.model.jsdgrp.cbs.max1.cur;
          amt = this.model.jsdgrp.cbs.max1.amt;
        }
        // 卖出
        if (this.model.jsdgrp.rec.pngcfx == '1') {
          fromCur = this.model.jsdgrp.cbs.max1.cur;
          toCur = this.model.jsdgrp.cbs.max2.cur;
          amt = this.model.jsdgrp.cbs.max2.amt;
        }
      }

      var rateTemp = '';
      if (this.model.jsdgrp.rec.shfobz == '0') {
        if (this.model.jsdgrp.rec.jqmrhl == null || this.model.jsdgrp.rec.jqmrhl == '' ||
          new BigNumber(this.model.jsdgrp.rec.jqmrhl).isZero()) {
          return;
        }
        rateTemp = this.model.jsdgrp.rec.jqmrhl;
      }
      if (this.model.jsdgrp.rec.shfobz == '1') {
        if (this.model.jsdgrp.rec.weithl == null || this.model.jsdgrp.rec.weithl == '' ||
          new BigNumber(this.model.jsdgrp.rec.weithl).isZero()) {
          return;
        }
        rateTemp = this.model.jsdgrp.rec.weithl;
      }
      if (rateTemp == '') {
        return;
      }
      let params = {
        fromCur: fromCur,
        toCur: toCur,
        amt: amt,
        rate: rateTemp,
        ptainr: this.model.jsdgrp.apl.pts.ptainr,
        maimpz: this.model.jsdgrp.rec.maimpz,
        pngcfx: this.model.jsdgrp.rec.pngcfx,
        khwtxz: this.model.jsdgrp.rec.khwtxz,
      }
      const loading = this.loading();
      let res = await Api.post(`/${this.moduleRouter()}/jstopn/calAmt`, params);
      loading.close();
      if (res.respCode === SUCCESS) {
        if (this.model.jsdgrp.rec.pngcfx == '0') {
          this.model.jsdgrp.cbs.max2.amt = res.data;
        }
        if (this.model.jsdgrp.rec.pngcfx == '1') {
          this.model.jsdgrp.cbs.max1.amt = res.data;
        }
      }
    },
    yohulxChange() {
      this.model.jsdgrp.rec.zdngll = '0';
      if (this.model.jsdgrp.rec.shfobz == '0') {
        this.getRelRate();
      }
    },
    zdngllBlur() {
      if (this.model.jsdgrp.rec.shfobz == '0') {
        this.getRelRate();

      }
    },
    // 事件 -- 结售汇性质
    waitypChange() {
      // 结汇
      if (this.model.jsdgrp.rec.maimpz == '4') {
        if (this.model.jsdgrp.rec.waityp == '1') {
          // 码表 - 结售汇统计代码 
          this.waitjmFilterKey = ['110'];
        }
        if (this.model.jsdgrp.rec.waityp == '2') {
          // 码表 - 结售汇统计代码 
          this.waitjmFilterKey = ['121', '122', '123', '124', '125', '126'];
        }
        if (this.model.jsdgrp.rec.waityp == '3') {
          // 码表 - 结售汇统计代码 
          this.waitjmFilterKey = ['131', '132', '133'];
        }
        if (this.model.jsdgrp.rec.waityp == '5') {
          // 码表 - 结售汇统计代码 
          this.waitjmFilterKey = ['210'];
        }
        if (this.model.jsdgrp.rec.waityp == '6') {
          // 码表 - 结售汇统计代码 
          this.waitjmFilterKey = ['220', '221', '222', '223'];
        }
        if (this.model.jsdgrp.rec.waityp == '7') {
          // 码表 - 结售汇统计代码 
          this.waitjmFilterKey = ['231', '232'];
        }
        if (this.model.jsdgrp.rec.waityp == '8') {
          // 码表 - 结售汇统计代码 
          this.waitjmFilterKey = ['241', '242', '250'];
        }
        if (this.model.jsdgrp.rec.waityp == '9') {
          // 码表 - 结售汇统计代码 
          this.waitjmFilterKey = ['240', '260', '261', '262', '270'];
        }
      }
      // 售汇
      if (this.model.jsdgrp.rec.maimpz == '5') {
        if (this.model.jsdgrp.rec.waityp == '1') {
          // 码表 - 结售汇统计代码 
          this.waitjmFilterKey = ['310'];
        }
        if (this.model.jsdgrp.rec.waityp == '2') {
          // 码表 - 结售汇统计代码 
          this.waitjmFilterKey = ['321', '322', '323', '324', '325', '326'];
        }
        if (this.model.jsdgrp.rec.waityp == '3') {
          // 码表 - 结售汇统计代码 
          this.waitjmFilterKey = ['331', '332', '333'];
        }
        if (this.model.jsdgrp.rec.waityp == '5') {
          // 码表 - 结售汇统计代码 
          this.waitjmFilterKey = ['410'];
        }
        if (this.model.jsdgrp.rec.waityp == '6') {
          // 码表 - 结售汇统计代码 
          this.waitjmFilterKey = ['420', '421', '422', '423'];
        }
        if (this.model.jsdgrp.rec.waityp == '7') {
          // 码表 - 结售汇统计代码 
          this.waitjmFilterKey = ['431', '432'];
        }
        if (this.model.jsdgrp.rec.waityp == '8') {
          // 码表 - 结售汇统计代码 
          this.waitjmFilterKey = ['441', '442', '450'];
        }
        if (this.model.jsdgrp.rec.waityp == '9') {
          // 码表 - 结售汇统计代码 
          this.waitjmFilterKey = ['440', '460', '461', '462', '470'];
        }
      }
      this.model.jsdgrp.rec.waitjm = '';
      this.model.jsdgrp.rec.txcode = '';
      this.model.jsdgrp.rec.regno = '';
    },

    txcodeChange() {
      if ((this.model.jsdgrp.rec.waitjm == '131' && this.model.jsdgrp.rec.txcode == '321000') ||
        (this.model.jsdgrp.rec.waitjm == '331' && this.model.jsdgrp.rec.txcode == '321000')) {
        this.regnoRequired = 'Y';
        this.model.jsdgrp.rec.regno = 'N/A';
      } else if ((this.model.jsdgrp.rec.waitjm == '123' && this.model.jsdgrp.rec.txcode == '226000') ||
        (this.model.jsdgrp.rec.waitjm == '132' && this.model.jsdgrp.rec.txcode != '922010') ||
        (this.model.jsdgrp.rec.waitjm == '250' && this.model.jsdgrp.rec.txcode == '924030') ||
        (this.model.jsdgrp.rec.waitjm == '240' && this.model.jsdgrp.rec.txcode != '929040') ||
        this.model.jsdgrp.rec.waitjm == '210' || this.model.jsdgrp.rec.waitjm == '220' || this.model.jsdgrp.rec.waitjm == '221' ||
        this.model.jsdgrp.rec.waitjm == '222' || this.model.jsdgrp.rec.waitjm == '223' || this.model.jsdgrp.rec.waitjm == '231' ||
        this.model.jsdgrp.rec.waitjm == '232' || this.model.jsdgrp.rec.waitjm == '241') {
        this.regnoRequired = 'Y';
        this.$notify.warning("请填写外汇局批件号或备案表号或业务编号或N/A,如遇问题请咨询银行工作人员。");
      } else if ((this.model.jsdgrp.rec.waitjm == '323' && this.model.jsdgrp.rec.txcode == '226000') ||
        (this.model.jsdgrp.rec.waitjm == '450' && this.model.jsdgrp.rec.txcode == '924030') ||
        (this.model.jsdgrp.rec.waitjm == '440' && this.model.jsdgrp.rec.txcode != '929040') ||
        this.model.jsdgrp.rec.waitjm == '332' || this.model.jsdgrp.rec.waitjm == '410' || this.model.jsdgrp.rec.waitjm == '420' ||
        this.model.jsdgrp.rec.waitjm == '422' || this.model.jsdgrp.rec.waitjm == '421' || this.model.jsdgrp.rec.waitjm == '423' ||
        this.model.jsdgrp.rec.waitjm == '431' || this.model.jsdgrp.rec.waitjm == '432' || this.model.jsdgrp.rec.waitjm == '441') {
        this.regnoRequired = 'Y';
        this.$notify.warning("请填写外汇局批件号或备案表号或业务编号或N/A,如遇问题请咨询银行工作人员。");
      } else {
        this.regnoRequired = '';
        this.model.jsdgrp.rec.regno = '';
      }
    },

    // 格式化数据
    formatLabel(item) {
      return item.cod + ' - ' + item.txt
    },

    // max.cur max.amt
    setMaxCurAndAmt() {
      if (this.model.jsdgrp.rec.pngcfx == '0') {
        this.model.jsdgrp.cbs.max.cur = this.model.jsdgrp.cbs.max1.cur;
        this.model.jsdgrp.cbs.max.amt = this.model.jsdgrp.cbs.max1.amt;
      }
      if (this.model.jsdgrp.rec.pngcfx == '1') {
        this.model.jsdgrp.cbs.max.cur = this.model.jsdgrp.cbs.max2.cur;
        this.model.jsdgrp.cbs.max.amt = this.model.jsdgrp.cbs.max2.amt;
      }
    },
    // 清空(入账)账号、账号类型
    clearRzActInfo() {
      this.model.jsdgrp.rec.rzhtyp = 'LO';
      this.model.jsdgrp.rec.zha1zh = '';
      this.model.verifyFlag = '';
    },
    // 清空(出账)账号、账号类型
    clearCzActInfo() {
      this.model.jsdgrp.rec.czhtyp = 'LO';
      this.model.jsdgrp.rec.zhangh = '';
    },
    // 禁用对方客户类别字段
    dfkhlbDisabled() {
      var tempList = ['01', '02', '03', '04', '05', '06'];
      var index = tempList.indexOf(this.model.jsdgrp.rec.dfkhlb);
      return index != -1 && this.model.jsdgrp.apl.pts.ptyinr != '';
    },
    // 切换买卖品种时,清空数据
    clearOldData() {
      this.model.jsdgrp.cbs.max1.amt = 0;
      this.model.jsdgrp.cbs.max2.amt = 0;
      this.model.jsdgrp.rec.waityp = '';
      this.model.jsdgrp.rec.waitjm = '';
      this.model.jsdgrp.rec.txcode = '';
      this.model.jsdgrp.rec.regno = '';
      this.model.jsdgrp.appbt = '';
    },

  }
}