Commit bd233fd62fa3a2acf7f20b17b28747935585feb5
1 parent
fabddc51
代码生成列表支持按时间排序
Showing
3 changed files
with
20 additions
and
27 deletions
ruoyi-ui/src/views/monitor/logininfor/index.vue
ruoyi-ui/src/views/monitor/operlog/index.vue
ruoyi-ui/src/views/tool/gen/index.vue
... | ... | @@ -91,36 +91,18 @@ |
91 | 91 | <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> |
92 | 92 | </el-row> |
93 | 93 | |
94 | - <el-table v-loading="loading" :data="tableList" @selection-change="handleSelectionChange"> | |
94 | + <el-table ref="tables" v-loading="loading" :data="tableList" @selection-change="handleSelectionChange" :default-sort="defaultSort" @sort-change="handleSortChange"> | |
95 | 95 | <el-table-column type="selection" align="center" width="55"></el-table-column> |
96 | 96 | <el-table-column label="序号" type="index" width="50" align="center"> |
97 | 97 | <template slot-scope="scope"> |
98 | 98 | <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span> |
99 | 99 | </template> |
100 | 100 | </el-table-column> |
101 | - <el-table-column | |
102 | - label="表名称" | |
103 | - align="center" | |
104 | - prop="tableName" | |
105 | - :show-overflow-tooltip="true" | |
106 | - width="120" | |
107 | - /> | |
108 | - <el-table-column | |
109 | - label="表描述" | |
110 | - align="center" | |
111 | - prop="tableComment" | |
112 | - :show-overflow-tooltip="true" | |
113 | - width="120" | |
114 | - /> | |
115 | - <el-table-column | |
116 | - label="实体" | |
117 | - align="center" | |
118 | - prop="className" | |
119 | - :show-overflow-tooltip="true" | |
120 | - width="120" | |
121 | - /> | |
122 | - <el-table-column label="创建时间" align="center" prop="createTime" width="160" /> | |
123 | - <el-table-column label="更新时间" align="center" prop="updateTime" width="160" /> | |
101 | + <el-table-column label="表名称" align="center" prop="tableName" :show-overflow-tooltip="true" width="120" /> | |
102 | + <el-table-column label="表描述" align="center" prop="tableComment" :show-overflow-tooltip="true" width="120" /> | |
103 | + <el-table-column label="实体" align="center" prop="className" :show-overflow-tooltip="true" width="120" /> | |
104 | + <el-table-column label="创建时间" align="center" prop="createTime" sortable="custom" :sort-orders="['descending', 'ascending']" width="160" /> | |
105 | + <el-table-column label="更新时间" align="center" prop="updateTime" sortable="custom" :sort-orders="['descending', 'ascending']" width="160" /> | |
124 | 106 | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
125 | 107 | <template slot-scope="scope"> |
126 | 108 | <el-button |
... | ... | @@ -225,6 +207,8 @@ export default { |
225 | 207 | tableList: [], |
226 | 208 | // 日期范围 |
227 | 209 | dateRange: "", |
210 | + // 默认排序 | |
211 | + defaultSort: { prop: "createTime", order: "descending" }, | |
228 | 212 | // 查询参数 |
229 | 213 | queryParams: { |
230 | 214 | pageNum: 1, |
... | ... | @@ -242,6 +226,8 @@ export default { |
242 | 226 | }; |
243 | 227 | }, |
244 | 228 | created() { |
229 | + this.queryParams.orderByColumn = this.defaultSort.prop; | |
230 | + this.queryParams.isAsc = this.defaultSort.order; | |
245 | 231 | this.getList(); |
246 | 232 | }, |
247 | 233 | activated() { |
... | ... | @@ -304,7 +290,8 @@ export default { |
304 | 290 | resetQuery() { |
305 | 291 | this.dateRange = []; |
306 | 292 | this.resetForm("queryForm"); |
307 | - this.handleQuery(); | |
293 | + this.queryParams.pageNum = 1; | |
294 | + this.$refs.tables.sort(this.defaultSort.prop, this.defaultSort.order) | |
308 | 295 | }, |
309 | 296 | /** 预览按钮 */ |
310 | 297 | handlePreview(row) { |
... | ... | @@ -332,6 +319,12 @@ export default { |
332 | 319 | this.single = selection.length != 1; |
333 | 320 | this.multiple = !selection.length; |
334 | 321 | }, |
322 | + /** 排序触发事件 */ | |
323 | + handleSortChange(column, prop, order) { | |
324 | + this.queryParams.orderByColumn = column.prop; | |
325 | + this.queryParams.isAsc = column.order; | |
326 | + this.getList(); | |
327 | + }, | |
335 | 328 | /** 修改按钮操作 */ |
336 | 329 | handleEditTable(row) { |
337 | 330 | const tableId = row.tableId || this.ids[0]; |
... | ... |