1- <!--
2- TODO: Vue3 mapGetters 简化用法
3- -->
41<template >
52 <div class =" log" >
63 <sticky-top >
74 <div class =" log-header" >
85 <div class =" header-left" ><p class =" title" >日志信息</p ></div >
96 <div class =" header-right" v-permission =" '搜索日志'" >
10- <lin-search @query =" onQueryChange" ref =" searchKeywordDOM " />
7+ <lin-search @query =" onQueryChange" ref =" searchKeywordDom " />
118 <el-dropdown
129 size =" medium"
1310 style =" margin : 0 10px ;"
1411 @command =" handleCommand"
1512 v-permission =" '查询日志记录的用户'"
1613 >
17- <el-button size = " medium " >
14+ <el-button >
1815 {{ searchUser ? searchUser : '全部人员' }} <i class =" el-icon-arrow-down el-icon--right" ></i >
1916 </el-button >
20- <el- dropdown-menu >
21- <template v-slot : dropdown >
17+ <template # dropdown >
18+ <el- dropdown-menu >
2219 <el-dropdown-item :command =" ['全部人员']" >全部人员</el-dropdown-item >
2320 <el-dropdown-item
2421 icon =" el-icon-user-solid"
2724 :command =" [user]"
2825 >{{ user }}
2926 </el-dropdown-item >
30- </template >
31- </el-dropdown-menu >
27+ </el-dropdown-menu >
28+ </template >
3229 </el-dropdown >
33- <lin-date-picker @dateChange =" handleDateChange" ref =" searchDateDOM " class =" date" > </lin-date-picker >
30+ <lin-date-picker @dateChange =" handleDateChange" ref =" searchDateDom " class =" date" > </lin-date-picker >
3431 </div >
3532 </div >
3633 <el-divider v-if =" !keyword" ></el-divider >
5754 </section >
5855 </article >
5956
60- <div v-if =" logs?.length" >
61- <el-divider ></el-divider >
62- <div class =" more" :class =" { nothing: finished }" >
63- <i v-if =" more" class =" iconfont icon-loading" ></i >
64- <div v-show =" !more && !finished" @click =" nextPage" >
65- <span >查看更多</span > <i class =" iconfont icon-gengduo" style =" font-size :14px " ></i >
66- </div >
67- <div v-if =" finished" >
68- <span >{{ totalCount === 0 ? '暂无数据' : '没有更多数据了' }}</span >
57+ <div v-if =" totalCount > count" >
58+ <div v-if =" logs?.length" >
59+ <el-divider ></el-divider >
60+ <div class =" more" :class =" { nothing: finished }" >
61+ <i v-if =" more" class =" iconfont icon-loading" ></i >
62+ <div v-show =" !more && !finished" @click =" nextPage" >
63+ <span >查看更多</span > <i class =" iconfont icon-gengduo" style =" font-size :14px " ></i >
64+ </div >
65+ <div v-if =" finished" >
66+ <span >{{ totalCount === 0 ? '暂无数据' : '没有更多数据了' }}</span >
67+ </div >
6968 </div >
7069 </div >
70+ <div class =" nothing" v-else >暂无日志信息</div >
7171 </div >
72- <div class =" nothing" v-else >暂无日志信息</div >
7372 </div >
7473 </div >
7574</template >
@@ -88,17 +87,20 @@ export default {
8887 LinSearch,
8988 LinDatePicker,
9089 },
91- setup (props , ctx ) {
90+ setup () {
9291 // originally data properties
9392 const store = useStore ()
94- const permissions = computed (() => store .getters .permissions )
9593 const user = computed (() => store .getters .user )
94+ const permissions = computed (() => store .getters .permissions )
9695
97- const loading = ref (false )
98- const users = ref ([])
96+ const count = 10
9997 const logs = ref ([])
98+ const users = ref ([])
99+ const loading = ref (false )
100100 const isSearch = ref (false )
101101 const finished = ref (false )
102+ const searchDateDom = ref ()
103+ const searchKeywordDom = ref ()
102104
103105 /**
104106 * Part 1
@@ -110,7 +112,7 @@ export default {
110112 if (user .value .admin || permissions .value .includes (' 查询日志记录的用户' )) {
111113 users .value = await logModel .getLoggedUsers ({})
112114 }
113- const res = await logModel .getLogs ({ page: 0 })
115+ const res = await logModel .getLogs ({ page: 0 , count })
114116 logs .value = res .items
115117 loading .value = false
116118 } catch (err) {
@@ -145,14 +147,12 @@ export default {
145147 }
146148 // 条件检索
147149 const searchPage = async () => {
148- if (! search .searchUser && ! search .searchKeyword && ! search .searchDate .length ) {
149- return
150- }
151- search .totalCount = 0
152150 logs .value = []
153151 loading .value = true
152+ search .totalCount = 0
154153 finished .value = false
155154 const name = search .searchUser === ' 全部人员' ? ' ' : search .searchUser
155+
156156 const res = await logModel .searchLogs ({
157157 page: 0 , // 初始化
158158 keyword: search .searchKeyword ,
@@ -194,7 +194,7 @@ export default {
194194 if (search .searchDate .length ) {
195195 search .keyword = ` ${ search .searchUser } ${ search .searchDate [0 ]} 至${ search .searchDate [1 ]} `
196196 }
197- ctx . refs . searchKeywordDOM .clear ()
197+ searchKeywordDom . value .clear ()
198198 }
199199 searchPage ()
200200 },
@@ -237,7 +237,7 @@ export default {
237237 if (search .searchKeyword ) {
238238 search .keyword = ` ${ search .searchUser } ${ search .searchKeyword } `
239239 }
240- ctx . refs . searchDateDOM .clear ()
240+ searchDateDom . value .clear ()
241241 }
242242 searchPage ()
243243 },
@@ -295,22 +295,25 @@ export default {
295295 users,
296296 logs,
297297 more,
298+ count,
298299 loading,
299300 finished,
300301 backInit,
301302 nextPage,
302303 isSearch,
303304 onQueryChange,
304305 handleCommand,
306+ searchDateDom,
305307 handleDateChange,
308+ searchKeywordDom,
306309 ... toRefs (search),
307310 }
308311 },
309312}
310313< / script>
311314
312315< style lang= " scss" scoped>
313- .log >>> .el - button {
316+ .log / deep / .el - button {
314317 padding- top: 10px ;
315318 padding- bottom: 10px ;
316319}
0 commit comments