Newer
Older
baseResourceFront / src / views / rule / listRule.vue
<template>
  <div class="app-container">
    <!--查询结果Table显示-->
    <div>
      <el-row class="table-title">
        <el-col :span="6"><div class="title-header"><i class="el-icon-menu"/>数据列表</div></el-col>
      </el-row>
      <el-table v-loading="listLoading" :data="list" class="table" border @selection-change="handleSelectionChange">
        <el-table-column :index="indexMethod" align="center" type="index" label="序号" width="55"/>
        <el-table-column v-for="column in columns" :key="column.value" :label="column.text" :width="column.width" :align="column.align" show-overflow-tooltip>
          <template slot-scope="scope">
            <span v-if="column.type!='Button'" :class="column.class">{{ scope.row[column.value] }}</span>
            <el-button v-if="column.type=='Button'" type="text" @click="showWellDetail(scope.row)">{{ scope.row[column.value] }}</el-button>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" width="160">
          <template slot-scope="scope">
            <el-button type="text" @click="print(scope.row)">打印</el-button>
            <el-button type="text" @click="download(scope.row)">下载</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <!--分页-->
    <div class="pagination-container">
      <el-pagination
        v-show="total>listQuery.limit"
        :current-page="listQuery.offset"
        :page-sizes="[20,30,50]"
        :page-size="listQuery.limit"
        :total="total"
        align="center"
        layout="total, sizes, prev, pager, next"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"/>
    </div>
  </div>
</template>

<script>
import { getRuleList } from '@/api/system/rule'
// import DownloadTemplate from '@/components/DownloadTemplate'

export default {
  name: 'ListRule',
  components: { },
  data() {
    return {
      listQuery: {
        keywords: '',
        deviceType: '',
        isOnline: '',
        offset: 1,
        limit: 20,
        sort: 'id',
        order: 'asc'
      }, // 筛选条件
      columns: [
        {
          text: '规章制度名称',
          value: 'filename',
          align: 'center'
        },
        {
          text: '上传时间',
          value: 'uptime',
          align: 'center'
        }
      ], // 显示列
      multipleSelection: [], // 多选选中项
      list: [], // 列表数据
      total: 0, // 数据总数
      deptTreeList: null, // 组织树列表数据
      fileList: [],
      listLoading: true, // 加载动画
      fullscreenLoading: false, // 全屏加载动画
      editShow: false, // 是否显示编辑框
      detailShow: false, // 是否显示编辑框
      filename: 'device_template.xlsx',
      wellShow: false
    }
  },
  mounted() {
    this.fetchData(false)
  },
  methods: {
    // 编辑设备信息
    print(row) {
      this.dialogFormVisible = true
      this.editShow = true
      this.$refs.editdevice.initDialog('update', this.dialogFormVisible, row.id)
    },
    download(row) {
      this.$refs.editdevice.initDialog('detail', true, row.id)
    },
    // 获取设备数据
    fetchData(isNowPage = true) {
      this.listLoading = true
      getRuleList().then(response => {
        this.list = response.data.rows
        this.total = parseInt(response.data.total)
        this.listLoading = false
      })
    },
    showWellDetail(row) {
      this.wellShow = true
      this.$refs.wellInfo.initDialog(row.wellId)
    },
    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()
    },
    // 多选触发方法
    handleSelectionChange(val) {
      this.multipleSelection = val
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  $tableTitleHeight:46px;
  .table{
    margin-bottom: 20px;
  }
  .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>