<!--
 * @Author: zwq
 * @Date: 2023-01-04 10:29:40
 * @LastEditors: zwq
 * @LastEditTime: 2023-01-05 15:50:27
 * @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 sysFilter from '@/filters/sys-filter'
const tableProps = [
  {
    prop: "creatorName",
    label: i18n.t("logOperation.creatorName"),
  },
  {
    prop: "operation",
    label: i18n.t("logOperation.operation"),
  },
  {
    prop: "requestUri",
    label: i18n.t("logOperation.requestUri"),
  },
  {
    prop: "requestMethod",
    label: i18n.t("logOperation.requestMethod"),
  },
  {
    prop: "requestParams",
    label: i18n.t("logOperation.requestParams"),
  },
  {
    prop: "requestTime",
    label: i18n.t("logOperation.requestTime"),
  },
  {
    prop: "status",
    label: i18n.t("logOperation.status"),
    filter: sysFilter('logStatus'),
  },
  {
    prop: "ip",
    label: i18n.t("logOperation.ip"),
  },
  {
    prop: "userAgent",
    label: i18n.t("logOperation.userAgent"),
  },
  {
    prop: "createDate",
    label: i18n.t("logOperation.createDate"),
  },
];
export default {
  mixins: [basicPage],
  data() {
    return {
      urlOptions: {
        getDataListURL: "/sys/log/operation/page",
        exportUrl: "/sys/log/operation/export",
      },
      tableProps,
      formConfig: [
        {
          type: "select",
          label: "状态",
          selectOptions: [
            { id: "0", name: i18n.t("logOperation.status0") },
            { id: "1", name: i18n.t("logOperation.status1") },
          ],
          param: "status",
          defaultSelect: "",
          onchange: true,
          width: 200,
        },
        {
          type: "button",
          btnName: "查询",
          name: "search",
          color: "primary",
        },
      ],
    };
  },
  components: {},
  methods:{
    //search-bar点击
    buttonClick(val) {
      switch (val.btnName) {
        case "search":
          this.listQuery.status = val.status;
          this.listQuery.page = 1;
          this.getDataList();
          break;
        case "add":
          this.addOrEditTitle = '新增'
          this.addOrUpdateVisible = true;
          this.addOrUpdateHandle()
          break;
        default:
          console.log(val)
       }
    },
  }
};
</script>
