Sfoglia il codice sorgente

日志列表支持排序操作

RuoYi 4 anni fa
parent
commit
df284ff6f5

+ 9 - 0
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/page/PageDomain.java

@@ -67,6 +67,15 @@ public class PageDomain
67
 
67
 
68
     public void setIsAsc(String isAsc)
68
     public void setIsAsc(String isAsc)
69
     {
69
     {
70
+        // 兼容前端排序类型
71
+        if ("ascending".equals(isAsc))
72
+        {
73
+            isAsc = "asc";
74
+        }
75
+        else if ("descending".equals(isAsc))
76
+        {
77
+            isAsc = "desc";
78
+        }
70
         this.isAsc = isAsc;
79
         this.isAsc = isAsc;
71
     }
80
     }
72
 }
81
 }

+ 13 - 4
ruoyi-ui/src/views/system/logininfor/index.vue

@@ -90,14 +90,14 @@
90
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
90
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
91
     </el-row>
91
     </el-row>
92
 
92
 
93
-    <el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange">
93
+    <el-table ref="tables" v-loading="loading" :data="list" @selection-change="handleSelectionChange" :default-sort="defaultSort" @sort-change="handleSortChange">
94
       <el-table-column type="selection" width="55" align="center" />
94
       <el-table-column type="selection" width="55" align="center" />
95
       <el-table-column label="访问编号" align="center" prop="infoId" />
95
       <el-table-column label="访问编号" align="center" prop="infoId" />
96
-      <el-table-column label="用户名称" align="center" prop="userName" />
96
+      <el-table-column label="用户名称" align="center" prop="userName" :show-overflow-tooltip="true" sortable="custom" :sort-orders="['descending', 'ascending']" />
97
       <el-table-column label="地址" align="center" prop="ipaddr" width="130" :show-overflow-tooltip="true" />
97
       <el-table-column label="地址" align="center" prop="ipaddr" width="130" :show-overflow-tooltip="true" />
98
       <el-table-column label="状态" align="center" prop="status" :formatter="statusFormat" />
98
       <el-table-column label="状态" align="center" prop="status" :formatter="statusFormat" />
99
       <el-table-column label="描述" align="center" prop="msg" />
99
       <el-table-column label="描述" align="center" prop="msg" />
100
-      <el-table-column label="访问时间" align="center" prop="accessTime" width="180">
100
+      <el-table-column label="访问时间" align="center" prop="accessTime" sortable="custom" :sort-orders="['descending', 'ascending']" width="180">
101
         <template slot-scope="scope">
101
         <template slot-scope="scope">
102
           <span>{{ parseTime(scope.row.accessTime) }}</span>
102
           <span>{{ parseTime(scope.row.accessTime) }}</span>
103
         </template>
103
         </template>
@@ -137,6 +137,8 @@ export default {
137
       statusOptions: [],
137
       statusOptions: [],
138
       // 日期范围
138
       // 日期范围
139
       dateRange: [],
139
       dateRange: [],
140
+      // 默认排序
141
+      defaultSort: {prop: 'loginTime', order: 'descending'},
140
       // 查询参数
142
       // 查询参数
141
       queryParams: {
143
       queryParams: {
142
         pageNum: 1,
144
         pageNum: 1,
@@ -177,13 +179,20 @@ export default {
177
     resetQuery() {
179
     resetQuery() {
178
       this.dateRange = [];
180
       this.dateRange = [];
179
       this.resetForm("queryForm");
181
       this.resetForm("queryForm");
182
+      this.$refs.tables.sort(this.defaultSort.prop, this.defaultSort.order)
180
       this.handleQuery();
183
       this.handleQuery();
181
     },
184
     },
182
-    // 多选框选中数据
185
+    /** 多选框选中数据 */
183
     handleSelectionChange(selection) {
186
     handleSelectionChange(selection) {
184
       this.ids = selection.map(item => item.infoId)
187
       this.ids = selection.map(item => item.infoId)
185
       this.multiple = !selection.length
188
       this.multiple = !selection.length
186
     },
189
     },
190
+    /** 排序触发事件 */
191
+    handleSortChange(column, prop, order) {
192
+      this.queryParams.orderByColumn = column.prop;
193
+      this.queryParams.isAsc = column.order;
194
+      this.getList();
195
+    },
187
     /** 删除按钮操作 */
196
     /** 删除按钮操作 */
188
     handleDelete(row) {
197
     handleDelete(row) {
189
       const infoIds = row.infoId || this.ids;
198
       const infoIds = row.infoId || this.ids;

+ 13 - 4
ruoyi-ui/src/views/system/operlog/index.vue

@@ -106,16 +106,16 @@
106
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
106
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
107
     </el-row>
107
     </el-row>
108
 
108
 
109
-    <el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange">
109
+    <el-table ref="tables" v-loading="loading" :data="list" @selection-change="handleSelectionChange" :default-sort="defaultSort" @sort-change="handleSortChange">
110
       <el-table-column type="selection" width="55" align="center" />
110
       <el-table-column type="selection" width="55" align="center" />
111
       <el-table-column label="日志编号" align="center" prop="operId" />
111
       <el-table-column label="日志编号" align="center" prop="operId" />
112
       <el-table-column label="系统模块" align="center" prop="title" />
112
       <el-table-column label="系统模块" align="center" prop="title" />
113
       <el-table-column label="操作类型" align="center" prop="businessType" :formatter="typeFormat" />
113
       <el-table-column label="操作类型" align="center" prop="businessType" :formatter="typeFormat" />
114
       <el-table-column label="请求方式" align="center" prop="requestMethod" />
114
       <el-table-column label="请求方式" align="center" prop="requestMethod" />
115
-      <el-table-column label="操作人员" align="center" prop="operName" />
115
+      <el-table-column label="操作人员" align="center" prop="operName" :show-overflow-tooltip="true" sortable="custom" :sort-orders="['descending', 'ascending']" width="100"/>
116
       <el-table-column label="主机" align="center" prop="operIp" width="130" :show-overflow-tooltip="true" />
116
       <el-table-column label="主机" align="center" prop="operIp" width="130" :show-overflow-tooltip="true" />
117
       <el-table-column label="操作状态" align="center" prop="status" :formatter="statusFormat" />
117
       <el-table-column label="操作状态" align="center" prop="status" :formatter="statusFormat" />
118
-      <el-table-column label="操作日期" align="center" prop="operTime" width="180">
118
+      <el-table-column label="操作日期" align="center" prop="operTime" sortable="custom" :sort-orders="['descending', 'ascending']" width="180">
119
         <template slot-scope="scope">
119
         <template slot-scope="scope">
120
           <span>{{ parseTime(scope.row.operTime) }}</span>
120
           <span>{{ parseTime(scope.row.operTime) }}</span>
121
         </template>
121
         </template>
@@ -212,6 +212,8 @@ export default {
212
       statusOptions: [],
212
       statusOptions: [],
213
       // 日期范围
213
       // 日期范围
214
       dateRange: [],
214
       dateRange: [],
215
+      // 默认排序
216
+      defaultSort: {prop: 'operTime', order: 'descending'},
215
       // 表单参数
217
       // 表单参数
216
       form: {},
218
       form: {},
217
       // 查询参数
219
       // 查询参数
@@ -262,13 +264,20 @@ export default {
262
     resetQuery() {
264
     resetQuery() {
263
       this.dateRange = [];
265
       this.dateRange = [];
264
       this.resetForm("queryForm");
266
       this.resetForm("queryForm");
267
+      this.$refs.tables.sort(this.defaultSort.prop, this.defaultSort.order)
265
       this.handleQuery();
268
       this.handleQuery();
266
     },
269
     },
267
-    // 多选框选中数据
270
+    /** 多选框选中数据 */
268
     handleSelectionChange(selection) {
271
     handleSelectionChange(selection) {
269
       this.ids = selection.map(item => item.operId)
272
       this.ids = selection.map(item => item.operId)
270
       this.multiple = !selection.length
273
       this.multiple = !selection.length
271
     },
274
     },
275
+    /** 排序触发事件 */
276
+    handleSortChange(column, prop, order) {
277
+      this.queryParams.orderByColumn = column.prop;
278
+      this.queryParams.isAsc = column.order;
279
+      this.getList();
280
+    },
272
     /** 详细按钮操作 */
281
     /** 详细按钮操作 */
273
     handleView(row) {
282
     handleView(row) {
274
       this.open = true;
283
       this.open = true;