Просмотр исходного кода

代码生成列表支持按时间排序

RuoYi 1 год назад
Родитель
Сommit
924e705dca
1 измененных файлов с 18 добавлено и 25 удалено
  1. 18 25
      ruoyi-ui/src/views/tool/gen/index.vue

+ 18 - 25
ruoyi-ui/src/views/tool/gen/index.vue

@@ -80,36 +80,18 @@
80
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
80
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
81
     </el-row>
81
     </el-row>
82
 
82
 
83
-    <el-table v-loading="loading" :data="tableList" @selection-change="handleSelectionChange">
83
+    <el-table ref="tables" v-loading="loading" :data="tableList" @selection-change="handleSelectionChange" :default-sort="defaultSort" @sort-change="handleSortChange">
84
       <el-table-column type="selection" align="center" width="55"></el-table-column>
84
       <el-table-column type="selection" align="center" width="55"></el-table-column>
85
       <el-table-column label="序号" type="index" width="50" align="center">
85
       <el-table-column label="序号" type="index" width="50" align="center">
86
         <template slot-scope="scope">
86
         <template slot-scope="scope">
87
           <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
87
           <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
88
         </template>
88
         </template>
89
       </el-table-column>
89
       </el-table-column>
90
-      <el-table-column
91
-        label="表名称"
92
-        align="center"
93
-        prop="tableName"
94
-        :show-overflow-tooltip="true"
95
-        width="120"
96
-      />
97
-      <el-table-column
98
-        label="表描述"
99
-        align="center"
100
-        prop="tableComment"
101
-        :show-overflow-tooltip="true"
102
-        width="120"
103
-      />
104
-      <el-table-column
105
-        label="实体"
106
-        align="center"
107
-        prop="className"
108
-        :show-overflow-tooltip="true"
109
-        width="120"
110
-      />
111
-      <el-table-column label="创建时间" align="center" prop="createTime" width="160" />
112
-      <el-table-column label="更新时间" align="center" prop="updateTime" width="160" />
90
+      <el-table-column label="表名称" align="center" prop="tableName" :show-overflow-tooltip="true" width="120" />
91
+      <el-table-column label="表描述" align="center" prop="tableComment" :show-overflow-tooltip="true" width="120" />
92
+      <el-table-column label="实体" align="center" prop="className" :show-overflow-tooltip="true" width="120" />
93
+      <el-table-column label="创建时间" align="center" prop="createTime" sortable="custom" :sort-orders="['descending', 'ascending']" width="160" />
94
+      <el-table-column label="更新时间" align="center" prop="updateTime" sortable="custom" :sort-orders="['descending', 'ascending']" width="160" />
113
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
95
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
114
         <template slot-scope="scope">
96
         <template slot-scope="scope">
115
           <el-button
97
           <el-button
@@ -212,6 +194,8 @@ export default {
212
       tableList: [],
194
       tableList: [],
213
       // 日期范围
195
       // 日期范围
214
       dateRange: "",
196
       dateRange: "",
197
+      // 默认排序
198
+      defaultSort: { prop: "createTime", order: "descending" },
215
       // 查询参数
199
       // 查询参数
216
       queryParams: {
200
       queryParams: {
217
         pageNum: 1,
201
         pageNum: 1,
@@ -229,6 +213,8 @@ export default {
229
     };
213
     };
230
   },
214
   },
231
   created() {
215
   created() {
216
+    this.queryParams.orderByColumn = this.defaultSort.prop;
217
+    this.queryParams.isAsc = this.defaultSort.order;
232
     this.getList();
218
     this.getList();
233
   },
219
   },
234
   activated() {
220
   activated() {
@@ -287,7 +273,8 @@ export default {
287
     resetQuery() {
273
     resetQuery() {
288
       this.dateRange = [];
274
       this.dateRange = [];
289
       this.resetForm("queryForm");
275
       this.resetForm("queryForm");
290
-      this.handleQuery();
276
+      this.queryParams.pageNum = 1;
277
+      this.$refs.tables.sort(this.defaultSort.prop, this.defaultSort.order)
291
     },
278
     },
292
     /** 预览按钮 */
279
     /** 预览按钮 */
293
     handlePreview(row) {
280
     handlePreview(row) {
@@ -315,6 +302,12 @@ export default {
315
       this.single = selection.length != 1;
302
       this.single = selection.length != 1;
316
       this.multiple = !selection.length;
303
       this.multiple = !selection.length;
317
     },
304
     },
305
+    /** 排序触发事件 */
306
+    handleSortChange(column, prop, order) {
307
+      this.queryParams.orderByColumn = column.prop;
308
+      this.queryParams.isAsc = column.order;
309
+      this.getList();
310
+    },
318
     /** 修改按钮操作 */
311
     /** 修改按钮操作 */
319
     handleEditTable(row) {
312
     handleEditTable(row) {
320
       const tableId = row.tableId || this.ids[0];
313
       const tableId = row.tableId || this.ids[0];