From 090ad5323a613926565e13b7cda11b86dca73fde Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: 星期四, 17 六月 2021 12:30:43 +0800
Subject: [PATCH] 日志列表支持排序操作

---
 ruoyi-common/src/main/java/com/ruoyi/common/core/page/PageDomain.java |    9 +++++++++
 ruoyi-ui/src/layout/components/Sidebar/Logo.vue                       |    4 ++--
 ruoyi-ui/src/views/monitor/logininfor/index.vue                       |   19 ++++++++++++++-----
 ruoyi-ui/src/views/monitor/operlog/index.vue                          |   19 ++++++++++++++-----
 4 files changed, 39 insertions(+), 12 deletions(-)

diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/page/PageDomain.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/page/PageDomain.java
index 23f1f8b..119b385 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/core/page/PageDomain.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/page/PageDomain.java
@@ -67,6 +67,15 @@
 
     public void setIsAsc(String isAsc)
     {
+        // 鍏煎鍓嶇鎺掑簭绫诲瀷
+        if ("ascending".equals(isAsc))
+        {
+            isAsc = "asc";
+        }
+        else if ("descending".equals(isAsc))
+        {
+            isAsc = "desc";
+        }
         this.isAsc = isAsc;
     }
 }
diff --git a/ruoyi-ui/src/layout/components/Sidebar/Logo.vue b/ruoyi-ui/src/layout/components/Sidebar/Logo.vue
index afe5fcd..f3bf5d5 100644
--- a/ruoyi-ui/src/layout/components/Sidebar/Logo.vue
+++ b/ruoyi-ui/src/layout/components/Sidebar/Logo.vue
@@ -2,11 +2,11 @@
   <div class="sidebar-logo-container" :class="{'collapse':collapse}" :style="{ backgroundColor: sideTheme === 'theme-dark' ? variables.menuBg : variables.menuLightBg }">
     <transition name="sidebarLogoFade">
       <router-link v-if="collapse" key="collapse" class="sidebar-logo-link" to="/">
-        <img v-if="logo" :src="logo" class="sidebar-logo">
+        <img v-if="logo" :src="logo" class="sidebar-logo" />
         <h1 v-else class="sidebar-title" :style="{ color: sideTheme === 'theme-dark' ? variables.sidebarTitle : variables.sidebarLightTitle }">{{ title }} </h1>
       </router-link>
       <router-link v-else key="expand" class="sidebar-logo-link" to="/">
-        <img v-if="logo" :src="logo" class="sidebar-logo">
+        <img v-if="logo" :src="logo" class="sidebar-logo" />
         <h1 class="sidebar-title" :style="{ color: sideTheme === 'theme-dark' ? variables.sidebarTitle : variables.sidebarLightTitle }">{{ title }} </h1>
       </router-link>
     </transition>
diff --git a/ruoyi-ui/src/views/monitor/logininfor/index.vue b/ruoyi-ui/src/views/monitor/logininfor/index.vue
index c6b38c7..8b051b3 100644
--- a/ruoyi-ui/src/views/monitor/logininfor/index.vue
+++ b/ruoyi-ui/src/views/monitor/logininfor/index.vue
@@ -91,17 +91,17 @@
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
 
-    <el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange">
+    <el-table ref="tables" v-loading="loading" :data="list" @selection-change="handleSelectionChange" :default-sort="defaultSort" @sort-change="handleSortChange">
       <el-table-column type="selection" width="55" align="center" />
       <el-table-column label="璁块棶缂栧彿" align="center" prop="infoId" />
-      <el-table-column label="鐢ㄦ埛鍚嶇О" align="center" prop="userName" />
+      <el-table-column label="鐢ㄦ埛鍚嶇О" align="center" prop="userName" :show-overflow-tooltip="true" sortable="custom" :sort-orders="['descending', 'ascending']" />
       <el-table-column label="鐧诲綍鍦板潃" align="center" prop="ipaddr" width="130" :show-overflow-tooltip="true" />
       <el-table-column label="鐧诲綍鍦扮偣" align="center" prop="loginLocation" :show-overflow-tooltip="true" />
-      <el-table-column label="娴忚鍣�" align="center" prop="browser" />
+      <el-table-column label="娴忚鍣�" align="center" prop="browser" :show-overflow-tooltip="true" />
       <el-table-column label="鎿嶄綔绯荤粺" align="center" prop="os" />
       <el-table-column label="鐧诲綍鐘舵��" align="center" prop="status" :formatter="statusFormat" />
       <el-table-column label="鎿嶄綔淇℃伅" align="center" prop="msg" />
-      <el-table-column label="鐧诲綍鏃ユ湡" align="center" prop="loginTime" width="180">
+      <el-table-column label="鐧诲綍鏃ユ湡" align="center" prop="loginTime" sortable="custom" :sort-orders="['descending', 'ascending']" width="180">
         <template slot-scope="scope">
           <span>{{ parseTime(scope.row.loginTime) }}</span>
         </template>
@@ -143,6 +143,8 @@
       statusOptions: [],
       // 鏃ユ湡鑼冨洿
       dateRange: [],
+      // 榛樿鎺掑簭
+      defaultSort: {prop: 'loginTime', order: 'descending'},
       // 鏌ヨ鍙傛暟
       queryParams: {
         pageNum: 1,
@@ -183,13 +185,20 @@
     resetQuery() {
       this.dateRange = [];
       this.resetForm("queryForm");
+      this.$refs.tables.sort(this.defaultSort.prop, this.defaultSort.order)
       this.handleQuery();
     },
-    // 澶氶�夋閫変腑鏁版嵁
+    /** 澶氶�夋閫変腑鏁版嵁 */
     handleSelectionChange(selection) {
       this.ids = selection.map(item => item.infoId)
       this.multiple = !selection.length
     },
+    /** 鎺掑簭瑙﹀彂浜嬩欢 */
+    handleSortChange(column, prop, order) {
+      this.queryParams.orderByColumn = column.prop;
+      this.queryParams.isAsc = column.order;
+      this.getList();
+    },
     /** 鍒犻櫎鎸夐挳鎿嶄綔 */
     handleDelete(row) {
       const infoIds = row.infoId || this.ids;
diff --git a/ruoyi-ui/src/views/monitor/operlog/index.vue b/ruoyi-ui/src/views/monitor/operlog/index.vue
index 7909c85..64158e6 100644
--- a/ruoyi-ui/src/views/monitor/operlog/index.vue
+++ b/ruoyi-ui/src/views/monitor/operlog/index.vue
@@ -107,17 +107,17 @@
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
 
-    <el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange">
+    <el-table ref="tables" v-loading="loading" :data="list" @selection-change="handleSelectionChange" :default-sort="defaultSort" @sort-change="handleSortChange">
       <el-table-column type="selection" width="55" align="center" />
       <el-table-column label="鏃ュ織缂栧彿" align="center" prop="operId" />
       <el-table-column label="绯荤粺妯″潡" align="center" prop="title" />
       <el-table-column label="鎿嶄綔绫诲瀷" align="center" prop="businessType" :formatter="typeFormat" />
       <el-table-column label="璇锋眰鏂瑰紡" align="center" prop="requestMethod" />
-      <el-table-column label="鎿嶄綔浜哄憳" align="center" prop="operName" />
-      <el-table-column label="涓绘満" align="center" prop="operIp" width="130" :show-overflow-tooltip="true" />
+      <el-table-column label="鎿嶄綔浜哄憳" align="center" prop="operName" width="100" :show-overflow-tooltip="true" sortable="custom" :sort-orders="['descending', 'ascending']" />
+      <el-table-column label="鎿嶄綔鍦板潃" align="center" prop="operIp" width="130" :show-overflow-tooltip="true" />
       <el-table-column label="鎿嶄綔鍦扮偣" align="center" prop="operLocation" :show-overflow-tooltip="true" />
       <el-table-column label="鎿嶄綔鐘舵��" align="center" prop="status" :formatter="statusFormat" />
-      <el-table-column label="鎿嶄綔鏃ユ湡" align="center" prop="operTime" width="180">
+      <el-table-column label="鎿嶄綔鏃ユ湡" align="center" prop="operTime" sortable="custom" :sort-orders="['descending', 'ascending']" width="180">
         <template slot-scope="scope">
           <span>{{ parseTime(scope.row.operTime) }}</span>
         </template>
@@ -216,6 +216,8 @@
       statusOptions: [],
       // 鏃ユ湡鑼冨洿
       dateRange: [],
+      // 榛樿鎺掑簭
+      defaultSort: {prop: 'operTime', order: 'descending'},
       // 琛ㄥ崟鍙傛暟
       form: {},
       // 鏌ヨ鍙傛暟
@@ -266,13 +268,20 @@
     resetQuery() {
       this.dateRange = [];
       this.resetForm("queryForm");
+      this.$refs.tables.sort(this.defaultSort.prop, this.defaultSort.order)
       this.handleQuery();
     },
-    // 澶氶�夋閫変腑鏁版嵁
+    /** 澶氶�夋閫変腑鏁版嵁 */
     handleSelectionChange(selection) {
       this.ids = selection.map(item => item.operId)
       this.multiple = !selection.length
     },
+    /** 鎺掑簭瑙﹀彂浜嬩欢 */
+    handleSortChange(column, prop, order) {
+      this.queryParams.orderByColumn = column.prop;
+      this.queryParams.isAsc = column.order;
+      this.getList();
+    },
     /** 璇︾粏鎸夐挳鎿嶄綔 */
     handleView(row) {
       this.open = true;

--
Gitblit v1.9.3