<template> <el-dialog :title="title" :visible.sync="dialogFormVisible" append-to-body > <div class="table"> <el-table v-loading="listLoading" :data="list" border > <el-table-column :index="indexMethod" align="center" type="index" /> <el-table-column v-for="column in columns" :key="column.value" :label="column.text" :width="column.width" :min-width="column.minwidth" :align="column.align" 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="[5,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> </el-dialog> </template> <script> import { getInspectionList } from '@/api/marker' export default { name: 'ListInspection', data() { return { dialogFormVisible: false, // 对话框是否显示 title: '', list: [], listQuery: { markerId: '', offset: 1, limit: 10, sort: 'id', order: 'asc' }, total: 0, // 数据总数 columns: [ { text: '巡检人员', value: 'username', align: 'center' }, { text: '巡检时间', value: 'logtime', align: 'center' } ], listLoading: false } }, methods: { initDialog: function(dialogFormVisible, markerId) { this.dialogFormVisible = dialogFormVisible this.title = '巡检记录列表(' + markerId + ')' this.listQuery.markerId = markerId this.fetchData() }, fetchData() { this.listLoading = true getInspectionList(this.listQuery).then(response => { this.list = response.data.rows this.total = parseInt(response.data.total) this.listLoading = false // console.log(this.list) }) }, 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> .table { margin-bottom: 20px; } </style>