<!--
 * @Author: zwq
 * @Date: 2023-01-04 10:29:40
 * @LastEditors: zwq
 * @LastEditTime: 2023-01-05 15:29:06
 * @Description: 
-->
<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-sys__user">
      <search-bar :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick" />
      <base-table
        :table-props="tableProps"
        :page="listQuery.page"
        :limit="listQuery.limit"
        :table-data="tableData"
      />
      <pagination
        :limit.sync="listQuery.limit"
        :page.sync="listQuery.page"
        :total="listQuery.total"
        @pagination="getDataList"
      />
    </div>
  </el-card>
</template>

<script>
import basicPage from "@/mixins/basic-page";
import i18n from "@/i18n";
import Cookies from 'js-cookie'
import qs from 'qs'
const tableProps = [
  {
    prop: "requestUri",
    label: i18n.t("logError.requestUri"),
  },
  {
    prop: "requestMethod",
    label: i18n.t("logError.requestMethod"),
  },
  {
    prop: "requestParams",
    label: i18n.t("logError.requestParams"),
  },
  {
    prop: "ip",
    label: i18n.t("logError.ip"),
  },
  {
    prop: "userAgent",
    label: i18n.t("logError.userAgent"),
  },
  {
    prop: "createDate",
    label: i18n.t("logError.createDate"),
  },
];
export default {
  mixins: [basicPage],
  data() {
    return {
      urlOptions: {
        getDataListURL: "/sys/log/error/page",
        exportUrl: "/sys/log/error/export",
      },
      tableProps,
      formConfig: [
        {
          type: "button",
          btnName: "导出",
          name: "export",
          color: "primary",
        },
      ],
    };
  },
  components: {},
  methods:{
    //search-bar点击
    buttonClick(val) {
      switch (val.btnName) {
        case "export":
          this.exportHandle();
          break;
        default:
          console.log(val)
       }
    },
    // 导出
    exportHandle () {
      var params = qs.stringify({
        'token': Cookies.get('token')
      })
      window.location.href = `${window.SITE_CONFIG['apiURL']}${this.urlOptions.exportURL}?${params}`
    }
  }
};
</script>
