index.js 8.89 KB
import Api from "~/service/Api"
import commonFunctions from "~/mixin/commonFunctions.js";
import commonDepend from "~/mixin/commonDepend.js";

export default {
  mixins: [commonFunctions, commonDepend],
  methods: {

    toDbablc() {
      this.routerPush({
        path: "/business/dbablc",
      });
    },

    toDbiblc(row) {
      this.routerPush({
        path: "/business/dbiblc",
        query: { inr: row.inr }
      });
    },
    toCicsel() {
      this.routerPush({
        path: "/business/cicsel",
      });
    },
    toEntatr() {
      this.routerPush({
        path: "/business/entatr",
      });
    },

    //融资申请
    bankApply(data) {
      return Api.post(`/Financing/wgbsel/bankApply`, data);
    },
    //融资校验
    check(data) {
      return Api.post(`/Financing/wgbsel/check`, data);
    },
    //上链重试
    retry(data) {
      return Api.post(`/Financing/wgbsel/retry`, data);
    },

    async init() {
      let rtnmsg = await Api.post('/Financing/wgbsel/init');
      if (rtnmsg.respCode == SUCCESS) {
        this.bchlist = rtnmsg.data.bchlist;
        this.wrkbchlist = rtnmsg.data.wrkbchlist;
        this.model.bchcod = rtnmsg.data.bchcod;
        this.model.ownbchcod = rtnmsg.data.ownbchcod;
      } else {
        this.$notify.error({ title: '错误', message: '服务请求失败!' });
      }
    },

    async handleSearch() {
      if (new Date(this.model.credatsta).getTime() > new Date(this.model.credatend).getTime()) {
        this.$notify.error({ title: '错误', message: '创建开始日期应小于结束日期!' });
        return
      }
      if (new Date(this.model.credatend).getTime() > new Date().getTime()) {
        this.$notify.error({ title: '错误', message: '创建结束日期不应大于当前日期!' });
        return
      }
      if (new Date(this.model.credatend).getTime() - new Date(this.model.credatsta).getTime() > 365 * 24 * 60 * 60 * 1000 * 1) {
        this.$notify.error({ title: '错误', message: '创建日期时间跨度不应超过1年!' });
        return
      }
      this.load = true;
      let params = {
        ...this.model,
        pageNumber: this.pagination.pageIndex,
        pageSize: this.pagination.pageSize,
      };
      delete params.markSet
      delete params.modifySet
      let rtnmsg = await Api.post('/Financing/wgbsel/queryFin', params);
      if (rtnmsg.respCode == SUCCESS) {
        this.tableData = [],
          this.tableData = rtnmsg.data.list;
        this.pagination.total = rtnmsg.data.total;
        this.load = false;
      } else {
        this.$notify.error({ title: '错误', message: '服务请求失败!' });
      }
    },

    async handleReset() {
      this.model = {}
    },

    // 处理
    async handler(row) {
      this.handleModel = row;
      this.trnUrl = 'Financing';
      this.inifrm = 'wgbsel';
      this.initdialog = true;
    },

    async handleClick(btn, row) {
      if (btn.code == 'dbeblc') {
        this.routerPush({
          path: "/business/" + btn.code.toLowerCase(),
          query: { inr: row.inr, pntinr: row.pntinr }
        });
        this.initdialog = false;
      } else if (btn.code == 'dbdblc') {
        this.initdialog = false;
        this.deldialogfig = true;
        this.deldialog = row;
      } else if (btn.code == 'logsrc') {
        this.initdialog = false;
        this.logdialogfig = true;
        this.load = true;
        let params = {
          fininr: row.inr,
          pageNumber: this.pagination.pageIndex,
          pageSize: this.pagination.pageSize,
        };
        const loading = this.loading('正在查询日志');
        let rtnmsg = await Api.post('/Financing/wgbsel/queryLogres', params);
        if (rtnmsg.respCode == SUCCESS) {
          loading.close();
          this.logresLst = [],
            this.logresLst = rtnmsg.data.list;
          this.pagination.total = rtnmsg.data.total;
          this.load = false;
        } else {
          this.$notify.error({ title: '错误', message: '服务请求失败!' });
        }
        loading.close();
      } else {
        let params = {
          recgrp: {
            rec: {
              inr: row.inr
            }
          }
        };
        switch (btn.code) {
          case "finapl":
            const loading1 = this.loading('正在调用融资申请接口');
            let rtnmsg1 = await this.bankApply(params);
            if (rtnmsg1.respCode == SUCCESS) {
              loading1.close();
              if (rtnmsg1.data.result) {
                this.model.recgrp.rec = rtnmsg1.data.fin;
                this.model.recgrp.fsa = rtnmsg1.data.fsa;
                this.$alert('接口调用成功!', '提示', {
                  confirmButtonText: "确认",
                  callback: action => {
                    if (action == 'confirm') {
                      this.initdialog = false;
                      this.queryDetail();
                    }
                  }
                })
              } else {
                this.$notify.error({ title: '错误', message: rtnmsg1.data.fsa.hinmsg });
              }
            } else {
              this.$notify.error({ title: '错误', message: '服务请求失败!' });
            }
            loading1.close();
            break;
          case "finchk":
            const loading2 = this.loading('正在调用融资核验接口');
            let rtnmsg2 = await this.check(params);
            if (rtnmsg2.respCode == SUCCESS) {
              loading2.close();
              if (rtnmsg2.data.result) {
                this.model.recgrp.rec = rtnmsg2.data.fin;
                this.model.recgrp.fsa = rtnmsg2.data.fsa;
                this.$alert('接口调用成功!', '提示', {
                  confirmButtonText: "确认",
                  callback: action => {
                    if (action == 'confirm') {
                      this.initdialog = false;
                      this.queryDetail();
                    }
                  }
                })
              } else {
                this.$notify.error({ title: '错误', message: rtnmsg2.data.fsa.hinmsg });
              }
            } else {
              this.$notify.error({ title: '错误', message: '服务请求失败!' });
            }
            loading2.close();
            break;
          case "retry":
            const loading3 = this.loading('正在调用上链重试接口');
            let rtnmsg3 = await this.retry(params);
            if (rtnmsg3.respCode == SUCCESS) {
              loading3.close();
              if (rtnmsg3.data.result) {
                this.model.recgrp.rec = rtnmsg3.data.fin;
                this.model.recgrp.fsa = rtnmsg3.data.fsa;
                this.$alert('接口调用成功!', '提示', {
                  confirmButtonText: "确认",
                  callback: action => {
                    if (action == 'confirm') {
                      this.initdialog = false;
                      this.queryDetail();
                    }
                  }
                })
              } else {
                this.$notify.error({ title: '错误', message: rtnmsg3.data.fsa.hinmsg });
              }
            } else {
              this.$notify.error({ title: '错误', message: '服务请求失败!' });
            }
            loading3.close();
            break;
          case "rfuacp":
            this.rfudialog = true;
            break;
          case "loaund":
            this.unddialog = true;
            break;
        }

      }
    },

    wait(ms) {
      return new Promise(resolve => setTimeout(resolve, ms));
    },

    //详情查询
    async queryDetail() {
      const loading = this.loading('正在调用详情查询接口');
      await this.wait(5000);
      Api.post(`/Financing/wgbsel/queryDetail`, this.model).then(res => {
        if (res.respCode == SUCCESS) {
          this.model.recgrp = res.data.blcgrp;
          this.model.recpan = res.data.blcp;
          loading.close();
        } else {
          this.$notify.error({ title: '错误', message: res.respMsg });
        }
        loading.close();
      });
      await this.handleSearch();
    },

    async getdbCode(codeType, uil, codeNam) {
      let params = {
        codeType: codeType,
        uil: uil ? uil : 'EN'
      }
      let rtnmsg = await Api.post("/manager/dic/listDicInfo", params)
      if (rtnmsg.respCode === SUCCESS) {
        let curList = rtnmsg.data.map(item => ({
          value: item.codeValue,
          label: item.codeName
        }));
        this.dbCodes[codeNam] = curList
      }
    },

    getBchcodlist(data) {
      return Api.post(`/Financing/wgbsel/getBchcodelist`, data);
    },

    // pageSize改变
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.pagination.pageIndex = 1;
      this.pagination.pageSize = val;
      this.handleSearch();
    },
    // 页码改变
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.pagination.pageIndex = val;
      this.handleSearch();
    },
  },
}