Newer
Older
dcms_front / src / components / CaseCommon / caseList.vue
yangqianqian on 28 Dec 2020 3 KB leaflet地图
<template>
  <div>
    <div class="table-container">
      <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 ref="table" :data="caseList" class="table" border highlight-current-row @row-click="showDetail">
        <el-table-column :index="indexMethod" align="center" type="index" />
        <el-table-column v-for="column in tableColumns" :key="column.value" :label="column.text" :width="column.width" align="center" show-overflow-tooltip>
          <template slot-scope="scope">
            <span :class="column.class">{{ scope.row[column.value] }}</span>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <!--分页-->
    <div class="pagination-container">
      <el-pagination
        :current-page="listQuery.offset"
        :page-sizes="[10,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>
export default {
  name: 'CaseList',
  props: {
    caseList: {
      type: Array,
      default() {
        return []
      }
    },
    listQuery: {
      type: Object,
      default() {
        return {
          offset: 1,
          limit: 10,
          sort: 'caseid',
          order: 'desc',
          queryCondition: {}
        }
      }
    },
    tableColumns: {
      type: Array,
      default() {
        return [
          {
            text: '案卷编号',
            value: 'caseid'
          },
          {
            text: '节点名称',
            value: 'caseStateName'
          },
          {
            text: '信息来源',
            value: 'sourceName'
          },
          {
            text: '案卷类别',
            value: 'eorcName'
          },
          {
            text: '所剩时间',
            value: 'remainingTime'
          },
          {
            text: '案卷描述',
            value: 'description'
          }
        ]
      }
    },
    total: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
    }
  },
  methods: {
    indexMethod(index) {
      return this.listQuery.limit * (this.listQuery.offset - 1) + index + 1
    },
    // 改变页容量
    handleSizeChange(val) {
      this.listQuery.limit = val
      this.$emit('changeQuery', this.listQuery)
    },
    // 改变当前页
    handleCurrentChange(val) {
      this.listQuery.offset = val
      this.$emit('changeQuery', this.listQuery)
    },
    showDetail(row, column, event) {
      this.$refs.table.setCurrentRow(row)
      const tabPane = {
        title: '案卷详情',
        name: 'case' + row.caseid,
        // content: 'EditTab',
        closable: true,
        index: row.id
      }
      // console.log('tabPane', tabPane)
      this.$emit('addDetail', tabPane, row)
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  $tableTitleHeight:46px;
  .table-container{
    margin: 20px;
    // margin-top: 50px;
  }
  .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;
      }
    }
  }
  .table-container >>> td {
    padding-top: 12px;
    padding-bottom: 12px;
  }
  .edit_btns{
    .edit_btn{
      float:right;
      margin:7px 3px;//为了需要居中显示margin-top和bottom要用$tableTitleHeight减去按钮原高度除以2
    }
  }

</style>