1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
| <template> <div class="app-container"> <el-form :inline="true" size="mini" class="filter-container"> <el-form-item> <el-input v-model="pageData.search" placeholder="请输入搜索内容..." size="mini"> <el-button slot="append" icon="el-icon-search" @click="onSearch" /> </el-input> </el-form-item> </el-form>
<el-table ref="singleTable" v-loading="isloading" :data="pageData.data" :border="true" :highlight-current-row="true" :size="'mini'" row-key="id" :header-cell-style="{background:'#f5f7fa'}" :height="`calc(100vh - ` + bottomOffset + `px)`" :default-sort="{prop: 'id', order: 'descending'}" element-loading-background="rgba(255, 255, 255, .85)" element-loading-text="拼命加载中..." element-loading-spinner="el-icon-loading" @sort-change="sortChange" > <template> <el-table-column type="index" label="序号" align="center" width="50" :resizable="false" /> <el-table-column prop="row" label="流水号" width="80" :show-overflow-tooltip="true" /> <el-table-column prop="id" label="用户编号" width="180" :sortable="'true'" :show-overflow-tooltip="true" /> <el-table-column prop="username" label="姓名" width="80" :show-overflow-tooltip="true" /> <el-table-column prop="date" label="日期" align="center" :sortable="'true'" width="120" :show-overflow-tooltip="true" /> <el-table-column prop="email" label="邮箱" width="200" :show-overflow-tooltip="true" /> <el-table-column prop="ip" label="ip" width="140" :show-overflow-tooltip="true" /> <el-table-column prop="status" label="状态" width="80" :show-overflow-tooltip="true" /> <el-table-column prop="desc" label="描述" min-width="300" :show-overflow-tooltip="true" />
<el-table-column label="操作" width="100" class-name="small-padding fixed-width" fixed="right" :resizable="false"> <template slot-scope="{row,$index}"> <router-link type="primary" to="/list-and-form/form" target="_blank"> <el-link type="primary" :underline="false" style="font-size:12px">编辑</el-link> </router-link> <span v-html="' '" /> <el-link type="primary" :underline="false" style="font-size:12px" @click="del(row,$index)">删除</el-link> <span v-html="' '" /> <router-link type="primary" to="/list-and-form/form" target="_blank"> <el-link type="primary" :underline="false" style="font-size:12px">详情</el-link> </router-link> </template> </el-table-column> </template> </el-table>
<el-pagination :pager-count="7" :layout="paginationInfo.layout" :page-sizes="paginationInfo.pageSizes" :background="paginationInfo.background" :hidden="paginationInfo.hidden" :disabled="paginationInfo.disabled" :page-size="pageData.limit" :current-page="pageData.page" :total="pageData.total" @size-change="handleSizeChange" @current-change="handleCurrentChange" /> </div> </template>
<script> import { getUserList } from '@/api/myUser' export default { name: 'List', data() { return { pageData: { search: '', orderByColumn: 'id', orderBy: 'descending', data: [], page: 1, limit: 20, total: 0 }, paginationInfo: { background: true, layout: 'total, ->, sizes, prev, pager, next, jumper, slot', pageSizes: [10, 20, 50, 100, 200], hidden: false, disabled: false }, bottomOffset: 185, isloading: false } }, updated() { this.initRefreshBtn() }, created() { this.getList() }, methods: { initRefreshBtn() { const rightFixedPatch = this.$refs.singleTable.$refs.rightFixedPatch rightFixedPatch.style.lineHeight = '47px' rightFixedPatch.style.textAlign = 'center' rightFixedPatch.style.cursor = 'pointer' rightFixedPatch.innerHTML = '<i class="el-icon-refresh" title="刷新"></i>' this.$nextTick(() => { rightFixedPatch.addEventListener('click', this.getList) }) }, sortChange(column) { this.pageData.orderByColumn = column.prop this.pageData.orderBy = column.order this.pageData.page = 1 this.getList() }, onSearch() { this.pageData.page = 1 this.getList() }, getList() { const me = this me.isloading = true me.paginationInfo.disabled = true
getUserList({ page: me.pageData.page, limit: me.pageData.limit, search: me.pageData.search, orderBy: me.pageData.orderBy, orderByColumn: me.pageData.orderByColumn }).then(function(response) { const data = response.data setTimeout(() => { me.pageData.total = data.total me.pageData.data = data.items
me.isloading = !true me.paginationInfo.disabled = !true }, 500) }) }, handleSizeChange(val) { this.pageData.limit = val this.getList() }, handleCurrentChange(val) { this.pageData.page = val this.getList() } } } </script>
<style> .filter-container{ height: 40px; } .filter-container .el-input { width: 280px !important; }
.el-pagination { padding: 15px 15px 0px 15px; } .el-pagination.hidden { display: none; }
.el-table__body { width: 100% !important; }
</style>
|