作者 RuoYi

日志列表支持排序操作

@@ -67,6 +67,15 @@ public class PageDomain @@ -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 }
@@ -2,11 +2,11 @@ @@ -2,11 +2,11 @@
2 <div class="sidebar-logo-container" :class="{'collapse':collapse}" :style="{ backgroundColor: sideTheme === 'theme-dark' ? variables.menuBg : variables.menuLightBg }"> 2 <div class="sidebar-logo-container" :class="{'collapse':collapse}" :style="{ backgroundColor: sideTheme === 'theme-dark' ? variables.menuBg : variables.menuLightBg }">
3 <transition name="sidebarLogoFade"> 3 <transition name="sidebarLogoFade">
4 <router-link v-if="collapse" key="collapse" class="sidebar-logo-link" to="/"> 4 <router-link v-if="collapse" key="collapse" class="sidebar-logo-link" to="/">
5 - <img v-if="logo" :src="logo" class="sidebar-logo"> 5 + <img v-if="logo" :src="logo" class="sidebar-logo" />
6 <h1 v-else class="sidebar-title" :style="{ color: sideTheme === 'theme-dark' ? variables.sidebarTitle : variables.sidebarLightTitle }">{{ title }} </h1> 6 <h1 v-else class="sidebar-title" :style="{ color: sideTheme === 'theme-dark' ? variables.sidebarTitle : variables.sidebarLightTitle }">{{ title }} </h1>
7 </router-link> 7 </router-link>
8 <router-link v-else key="expand" class="sidebar-logo-link" to="/"> 8 <router-link v-else key="expand" class="sidebar-logo-link" to="/">
9 - <img v-if="logo" :src="logo" class="sidebar-logo"> 9 + <img v-if="logo" :src="logo" class="sidebar-logo" />
10 <h1 class="sidebar-title" :style="{ color: sideTheme === 'theme-dark' ? variables.sidebarTitle : variables.sidebarLightTitle }">{{ title }} </h1> 10 <h1 class="sidebar-title" :style="{ color: sideTheme === 'theme-dark' ? variables.sidebarTitle : variables.sidebarLightTitle }">{{ title }} </h1>
11 </router-link> 11 </router-link>
12 </transition> 12 </transition>
@@ -91,17 +91,17 @@ @@ -91,17 +91,17 @@
91 <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> 91 <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
92 </el-row> 92 </el-row>
93 93
94 - <el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange"> 94 + <el-table ref="tables" v-loading="loading" :data="list" @selection-change="handleSelectionChange" :default-sort="defaultSort" @sort-change="handleSortChange">
95 <el-table-column type="selection" width="55" align="center" /> 95 <el-table-column type="selection" width="55" align="center" />
96 <el-table-column label="访问编号" align="center" prop="infoId" /> 96 <el-table-column label="访问编号" align="center" prop="infoId" />
97 - <el-table-column label="用户名称" align="center" prop="userName" /> 97 + <el-table-column label="用户名称" align="center" prop="userName" :show-overflow-tooltip="true" sortable="custom" :sort-orders="['descending', 'ascending']" />
98 <el-table-column label="登录地址" align="center" prop="ipaddr" width="130" :show-overflow-tooltip="true" /> 98 <el-table-column label="登录地址" align="center" prop="ipaddr" width="130" :show-overflow-tooltip="true" />
99 <el-table-column label="登录地点" align="center" prop="loginLocation" :show-overflow-tooltip="true" /> 99 <el-table-column label="登录地点" align="center" prop="loginLocation" :show-overflow-tooltip="true" />
100 - <el-table-column label="浏览器" align="center" prop="browser" /> 100 + <el-table-column label="浏览器" align="center" prop="browser" :show-overflow-tooltip="true" />
101 <el-table-column label="操作系统" align="center" prop="os" /> 101 <el-table-column label="操作系统" align="center" prop="os" />
102 <el-table-column label="登录状态" align="center" prop="status" :formatter="statusFormat" /> 102 <el-table-column label="登录状态" align="center" prop="status" :formatter="statusFormat" />
103 <el-table-column label="操作信息" align="center" prop="msg" /> 103 <el-table-column label="操作信息" align="center" prop="msg" />
104 - <el-table-column label="登录日期" align="center" prop="loginTime" width="180"> 104 + <el-table-column label="登录日期" align="center" prop="loginTime" sortable="custom" :sort-orders="['descending', 'ascending']" width="180">
105 <template slot-scope="scope"> 105 <template slot-scope="scope">
106 <span>{{ parseTime(scope.row.loginTime) }}</span> 106 <span>{{ parseTime(scope.row.loginTime) }}</span>
107 </template> 107 </template>
@@ -143,6 +143,8 @@ export default { @@ -143,6 +143,8 @@ export default {
143 statusOptions: [], 143 statusOptions: [],
144 // 日期范围 144 // 日期范围
145 dateRange: [], 145 dateRange: [],
  146 + // 默认排序
  147 + defaultSort: {prop: 'loginTime', order: 'descending'},
146 // 查询参数 148 // 查询参数
147 queryParams: { 149 queryParams: {
148 pageNum: 1, 150 pageNum: 1,
@@ -183,13 +185,20 @@ export default { @@ -183,13 +185,20 @@ export default {
183 resetQuery() { 185 resetQuery() {
184 this.dateRange = []; 186 this.dateRange = [];
185 this.resetForm("queryForm"); 187 this.resetForm("queryForm");
  188 + this.$refs.tables.sort(this.defaultSort.prop, this.defaultSort.order)
186 this.handleQuery(); 189 this.handleQuery();
187 }, 190 },
188 - // 多选框选中数据 191 + /** 多选框选中数据 */
189 handleSelectionChange(selection) { 192 handleSelectionChange(selection) {
190 this.ids = selection.map(item => item.infoId) 193 this.ids = selection.map(item => item.infoId)
191 this.multiple = !selection.length 194 this.multiple = !selection.length
192 }, 195 },
  196 + /** 排序触发事件 */
  197 + handleSortChange(column, prop, order) {
  198 + this.queryParams.orderByColumn = column.prop;
  199 + this.queryParams.isAsc = column.order;
  200 + this.getList();
  201 + },
193 /** 删除按钮操作 */ 202 /** 删除按钮操作 */
194 handleDelete(row) { 203 handleDelete(row) {
195 const infoIds = row.infoId || this.ids; 204 const infoIds = row.infoId || this.ids;
@@ -107,17 +107,17 @@ @@ -107,17 +107,17 @@
107 <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> 107 <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
108 </el-row> 108 </el-row>
109 109
110 - <el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange"> 110 + <el-table ref="tables" v-loading="loading" :data="list" @selection-change="handleSelectionChange" :default-sort="defaultSort" @sort-change="handleSortChange">
111 <el-table-column type="selection" width="55" align="center" /> 111 <el-table-column type="selection" width="55" align="center" />
112 <el-table-column label="日志编号" align="center" prop="operId" /> 112 <el-table-column label="日志编号" align="center" prop="operId" />
113 <el-table-column label="系统模块" align="center" prop="title" /> 113 <el-table-column label="系统模块" align="center" prop="title" />
114 <el-table-column label="操作类型" align="center" prop="businessType" :formatter="typeFormat" /> 114 <el-table-column label="操作类型" align="center" prop="businessType" :formatter="typeFormat" />
115 <el-table-column label="请求方式" align="center" prop="requestMethod" /> 115 <el-table-column label="请求方式" align="center" prop="requestMethod" />
116 - <el-table-column label="操作人员" align="center" prop="operName" />  
117 - <el-table-column label="主机" align="center" prop="operIp" width="130" :show-overflow-tooltip="true" /> 116 + <el-table-column label="操作人员" align="center" prop="operName" width="100" :show-overflow-tooltip="true" sortable="custom" :sort-orders="['descending', 'ascending']" />
  117 + <el-table-column label="操作地址" align="center" prop="operIp" width="130" :show-overflow-tooltip="true" />
118 <el-table-column label="操作地点" align="center" prop="operLocation" :show-overflow-tooltip="true" /> 118 <el-table-column label="操作地点" align="center" prop="operLocation" :show-overflow-tooltip="true" />
119 <el-table-column label="操作状态" align="center" prop="status" :formatter="statusFormat" /> 119 <el-table-column label="操作状态" align="center" prop="status" :formatter="statusFormat" />
120 - <el-table-column label="操作日期" align="center" prop="operTime" width="180"> 120 + <el-table-column label="操作日期" align="center" prop="operTime" sortable="custom" :sort-orders="['descending', 'ascending']" width="180">
121 <template slot-scope="scope"> 121 <template slot-scope="scope">
122 <span>{{ parseTime(scope.row.operTime) }}</span> 122 <span>{{ parseTime(scope.row.operTime) }}</span>
123 </template> 123 </template>
@@ -216,6 +216,8 @@ export default { @@ -216,6 +216,8 @@ export default {
216 statusOptions: [], 216 statusOptions: [],
217 // 日期范围 217 // 日期范围
218 dateRange: [], 218 dateRange: [],
  219 + // 默认排序
  220 + defaultSort: {prop: 'operTime', order: 'descending'},
219 // 表单参数 221 // 表单参数
220 form: {}, 222 form: {},
221 // 查询参数 223 // 查询参数
@@ -266,13 +268,20 @@ export default { @@ -266,13 +268,20 @@ export default {
266 resetQuery() { 268 resetQuery() {
267 this.dateRange = []; 269 this.dateRange = [];
268 this.resetForm("queryForm"); 270 this.resetForm("queryForm");
  271 + this.$refs.tables.sort(this.defaultSort.prop, this.defaultSort.order)
269 this.handleQuery(); 272 this.handleQuery();
270 }, 273 },
271 - // 多选框选中数据 274 + /** 多选框选中数据 */
272 handleSelectionChange(selection) { 275 handleSelectionChange(selection) {
273 this.ids = selection.map(item => item.operId) 276 this.ids = selection.map(item => item.operId)
274 this.multiple = !selection.length 277 this.multiple = !selection.length
275 }, 278 },
  279 + /** 排序触发事件 */
  280 + handleSortChange(column, prop, order) {
  281 + this.queryParams.orderByColumn = column.prop;
  282 + this.queryParams.isAsc = column.order;
  283 + this.getList();
  284 + },
276 /** 详细按钮操作 */ 285 /** 详细按钮操作 */
277 handleView(row) { 286 handleView(row) {
278 this.open = true; 287 this.open = true;