index.js 4.28 KB
Newer Older
zenghuan committed
1
import Api from "~/service/Api";
李少勇 committed
2
import getSubtyp from '~/page/Frontend/Rcvsel/event/getSubtyp.js';
李少勇 committed
3
import exportExcel from '~/page/Frontend/Rcvsel/event/exportExcel.js';
zenghuan committed
4
import moment from "moment";
李少勇 committed
5 6
import Oftsel from '../model';
import Utils from "~/utils";
李少勇 committed
7 8

export default {
李少勇 committed
9
  mixins: [getSubtyp, exportExcel],
niewei committed
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  methods: {
    async handleSearch () {
      let rsptims = this.model.oftp.rel.rsptims;
      if (!rsptims || rsptims === "") {
        this.$notify.error({
          title: this.$t("financing.错误"),
          message: this.$t("financing.查询开始日期必输!"),
        });
        return;
      }
      let rsptime = this.model.oftp.rel.rsptime;
      if (!rsptime || rsptime === "") {
        this.$notify.error({
          title: this.$t("financing.错误"),
          message: this.$t("financing.查询结束日期必输!"),
        });
        return;
      }

      this.load = true;
      // TODO rewrite url
      let rtnmsg = await Api.post("/frontend/oftsel/query", {
        ...this.model.oftp.rel,
        pageNum: this.pagination.pageNum,
        pageSize: this.pagination.pageSize,
35 36
        rsptims: rsptims ? moment(rsptims).format("YYYY-MM-DD") + ' 00:00:00' : "",
        rsptime: moment(rsptime).format("YYYY-MM-DD") + ' 23:59:59',
niewei committed
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
      });
      if (rtnmsg.respCode == SUCCESS) {
        this.load = false;
        this.stmData.data = [];
        const { list } = rtnmsg.data;
        this.stmData.data = list;
        this.pagination = {
          pageNum: rtnmsg.data.pageNum || 1,
          pageSize: rtnmsg.data.pageSize || 10,
          total: parseInt(rtnmsg.data.total),
        };
      } else {
        this.$notify.error({
          title: this.$t("financing.错误"),
          message: this.$t("financing.服务请求失败!"),
        });
      }
      this.load = false;
    },
    async handleReset () {
李少勇 committed
57 58 59
      let resetModel = new Oftsel().data
      Utils.copyValueFromVoData(this.model, resetModel);
      this.handleSearch();
niewei committed
60
    },
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
    async dbClickRow (row) {
      let rtnmsg = await Api.post("/frontend/oftsel/storeDate", {
        inr: row.inr
      });
      if (rtnmsg.respCode == SUCCESS) {
        this.routerPush({
          path: '/business/batdis',
          query: {
            inr: rtnmsg.data.dotinr,
            traname1: rtnmsg.data.traname1
          }
        })
      }
      // this.routerPush({
      //   path: '/business/batdis',
      //   query: {
      //     inr: '0000000000001594'
      //   }
      // })

李少勇 committed
81
    },
niewei committed
82 83 84 85 86 87 88 89 90 91
    // pageSize改变
    handleSizeChange (val) {
      this.pagination.pageNum = 1;
      this.pagination.pageSize = val;
      this.handleSearch();
    },
    // 页码改变
    handleCurrentChange (val) {
      this.pagination.pageNum = val;
      this.handleSearch();
zenghuan committed
92
    },
niewei committed
93 94
    handleSelectionChange (val) {
      this.multipleSelection = val;
niewei committed
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
    },
    async handleExportClick () {
      // const loading = this.loading();
      let rsptims = this.model.oftp.rel.rsptims;
      let rsptime = this.model.oftp.rel.rsptime;
      let params = {
        ...this.model.oftp.rel,
        rsptims: rsptims ? moment(rsptims).format("YYYY-MM-DD") + ' 00:00:00' : "",
        rsptime: moment(rsptime).format("YYYY-MM-DD") + ' 23:59:59',
        pageNumber: this.pagination.pageIndex,
        pageSize: this.pagination.pageSize,
      };
      let res = await Api.post("/frontend/oftsel/exportExcel", params);
      if (res.respCode == SUCCESS) {
        console.log(res.data)
        let name = moment(new Date()).format('yyyy-MM-DD HH:mm:ss');

        Utils.exportToExcel(res.data, "已关联报文查询_" + name + ".xlsx", "已关联报文查询");
      }
      // loading.close();
    },
李少勇 committed
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
    exportToExcel() {
      let codeKeysMap = {
        typ: 'kpasta',
        sta: 'zfqsta',
        area: 'stacd1',
        offsta: 'offsta',
        multimsg: 'chncod',
        chk: 'chncod',
        kpatyp: 'chncod',
      };
      let rsptims = this.model.oftp.rel.rsptims;
      let rsptime = this.model.oftp.rel.rsptime;
      let params = {
        ...this.model.oftp.rel,
        rsptims: rsptims ? moment(rsptims).format("YYYY-MM-DD") + ' 00:00:00' : "",
        rsptime: moment(rsptime).format("YYYY-MM-DD") + ' 23:59:59',
      }
      this.exportExcel(this.stmData.columns, '/frontend/oftsel/exportExcel', params, codeKeysMap, '已关联报文查询');
    }
niewei committed
135
  },
zenghuan committed
136
};