Newer
Older
baseResourceFront / src / views / strategy / listOperationLog.vue
yangqianqian on 6 Apr 2021 4 KB 按照新UI进行修改
<template>
  <app-container>
    <search-area :need-clear="false" :need-search-more="false" type="seperate" size="small" search-more-type="default" @search="fetchData" @clear="clearInput">
      <!--一般查询条件-->
      <search-item>
        <el-input v-model.trim="listQuery.operationType" size="small" placeholder="操作名称" clearable/>
      </search-item>
      <search-item>
        <el-date-picker
          v-model="timeRange"
          type="datetimerange"
          range-separator="至"
          value-format="yyyy-MM-dd HH:mm:ss"
          size="small"
          start-placeholder="开始时间"
          end-placeholder="结束时间"/>
      </search-item>
    </search-area>
    <normal-table
      :data="list"
      :head="tableOption.head"
      :query="listQuery"
      :total="total"
      :columns="columns"
      :list-loading="listLoading"
      :options="tableOption.options"
      :tools-option="tableOption.toolsOption"
      size="small"
      @selectionChange="handleSelectionChange"
      @change="changePage"/>
  </app-container>
</template>

<script>
import { getOperationLog } from '@/api/system/strategy'

export default {
  name: 'ListOperationLog',
  data() {
    return {
      listQuery: {
        operationType: '',
        startTime: '',
        endTime: '',
        offset: 1,
        limit: 20,
        sort: '',
        order: ''
      }, // 筛选条件
      timeRange: [], // 时间范围
      columns: [
        {
          text: '操作类型',
          value: 'operationType',
          align: 'center',
          width: 120
        },
        {
          text: '操作用户',
          value: 'operationUserName',
          align: 'center',
          width: 120
        },
        {
          text: '操作内容',
          value: 'operationContent',
          align: 'center'
        },
        {
          text: '操作时间',
          value: 'operationTime',
          align: 'center',
          width: 200
        }
      ],
      total: 0, // 数据总数
      list: [], // 报警列表
      listLoading: true, // 列表加载
      dialogFormVisible: '',
      tableOption: {
        head: {
          show: true, // 是否需要标题栏,
          text: '数据列表' // 标题名称
        },
        options: {
          needIndex: true, // 是否需要序号列
          needMultSelect: false
        },
        toolsOption: {
          selectColumns: false, // 是否需要筛选列
          refresh: false // 是否需要刷新按钮
        }
      } // 表格属性
    }
  },
  watch: {
    // 当时间范围变化时,填充listQuery时间
    timeRange(val) {
      if (val && val.length > 0) {
        this.listQuery.startTime = val[0]
        this.listQuery.endTime = val[1]
      } else {
        this.listQuery.startTime = ''
        this.listQuery.endTime = ''
      }
    }
  },
  created() {
    this.fetchData()// 获取数据
  },
  activated() {
    this.fetchData()
  },
  methods: {
    fetchData(isNowPage = true) {
      this.listLoading = true
      if (!isNowPage) { // 是否显示当前页,否则跳转第一页
        this.listQuery.offset = 1
      }
      getOperationLog(this.listQuery).then(response => {
        if (response.code === 200) {
          this.list = response.data.rows
          this.total = parseInt(response.data.total)
        } else {
          this.$message.error(response.message)
        }
        this.listLoading = false
      })
    },
    // 查询数据
    search() {
      this.fetchData(false)
    },
    // 序号计算
    indexMethod(index) {
      return this.listQuery.limit * (this.listQuery.offset - 1) + index + 1
    },
    // 改变页容量
    handleSizeChange(val) {
      this.listQuery.limit = val
      this.fetchData()
    },
    // 改变当前页
    handleCurrentChange(val) {
      this.listQuery.offset = val
      this.fetchData()
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  $tableTitleHeight:46px;
  .app-container{
    margin-bottom:20px
  }
  .table{
    margin-bottom: 20px;
  }
  .small-row-class{
    height: 15px;
  }
  .pagination-container{
    margin-bottom: 50px;
  }
  .table-title{
    background-color:rgba(243, 243, 243, 1);
    height: $tableTitleHeight;
    .title-header{
      line-height:$tableTitleHeight;
      color: #606266;
      font-size: 15px;
      i{
        margin-left: 5px;
        margin-right: 5px;
      }
    }
  }
  .edit_btns{
    .edit_btn{
      float:right;
      margin:7px 3px;//为了需要居中显示margin-top和bottom要用$tableTitleHeight减去按钮原高度除以2
    }
  }
</style>
<style rel="stylesheet/scss" lang="scss">
  .small-row-class td{
    padding:2px 0px;
  }
</style>