index.vue 3.34 KB
<template>
  <div class="system-container">
    <div class="container">
      <search-form
        class="searchTop border-shadow"
        :formModel="searchForm"
        :formList="worklogFormList"
      >
        <slot name="form-slot">
          <el-button
            type="primary"
            :size="btn_size"
            icon="el-icon-search"
            :id="tableParams.btnId"
          >搜索</el-button>
          <el-button
            type="primary"
            :size="btn_size"
            icon="el-icon-refresh"
            @click="refresh"
          >重置</el-button>
        </slot>
      </search-form>
      <div class="table-btn">
        <el-button
          type="primary"
          :size="btn_size"
          @click="exportTable"
        >导出</el-button>
      </div>
      <basic-table
        ref="worklogTable"
        :tableParams="tableParams"
        :getListApi="getListApi"
        :beforeSearchFn="beforeSearchFn"
        :searchForm="searchDataForm"
        :hasNum="false"
      >
      </basic-table>
    </div>
  </div>
</template>

<script>
import store from '@/store';
import { WORKLOG_API } from '@/config/config'
import { getWorkLogList, exportWorkLog } from 'services/worklog';
export default {
  data() {
    return {
      WORKLOGSTATUS: this.$Constants.WORKLOG_STATUS,
      searchForm: {},
      searchDataForm: {},
      worklogFormList: [
        {
          type: 'daterange',
          prop: 'daterange',
          pickerOptions: {
            disabledDate(time) {
              return time.getTime() > Date.now() || time.getTime() < new Date('2017-12-31').getTime()
            }
          }
        }
      ],
      tableParams: {
        // mutiSelectName: 'worklog',
        // mutiSelectUniqueKey: 'id',
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'list',
        tableColumns: [
          {
            label: '日志编号',
            prop: 'id'
          }, {
            label: '系统菜单',
            prop: 'module'
          }, {
            label: '操作类型',
            prop: 'action'
          }, {
            label: '操作账号',
            prop: 'operatorName'
          }, {
            label: '所属组织',
            prop: 'belongOrg'
          }, {
            label: '主机IP',
            prop: 'ip',
          }, {
            label: '操作状态',
            prop: 'result',
            // addHtml: 'status'
          }, {
            label: '创建时间',
            prop: 'createdDate'
          }
        ]
      },
      getListApi: getWorkLogList
    }
  },
  methods: {
    refresh() {
      this.searchForm = {}
      this.searchDataForm = {}
    },
    beforeSearchFn() {
      return new Promise((resolve, reject) => {
        if (this.searchForm.daterange) {
          this.searchDataForm.sDate = this.searchForm.daterange[0]
          this.searchDataForm.eDate = this.searchForm.daterange[1]
        } else {
          if (this.searchDataForm.sDate) delete this.searchDataForm.sDate && delete this.searchDataForm.eDate
        }
        resolve()
      })
    },
    // 导出列表
    exportTable() {
      const params = this.$refs.worklogTable.page
      this.$Common.exportExcel({
        url: store.state.baseURL + WORKLOG_API.WORKLOG_EXPORT,
        data: params,
        method: 'GET',
        fileName: '操作日志.xlsx'
      })
    }
  }
}
</script>