Search.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <script setup name="ReportSearch">
  2. import {setHightLightText} from '@/hooks/common'
  3. import {ref,reactive} from 'vue'
  4. import apiReport from '@/api/report'
  5. import { showToast } from 'vant'
  6. import moment from 'moment'
  7. import { useRouter } from 'vue-router'
  8. console.log('搜索页setup');
  9. const router=useRouter()
  10. const reportTypes = [
  11. { label: '我的研报',key:'3' },
  12. { label: '共享研报',key:'2' },
  13. { label: '公共研报',key:'1' },
  14. ]
  15. const keyword=ref('')
  16. const listState = reactive({
  17. listType: '3',
  18. list:[],
  19. page:1,
  20. pageSize:20,
  21. finished:false,
  22. loading:false
  23. })
  24. async function getList(){
  25. const res=await apiReport.getList({
  26. CurrentIndex:listState.page,
  27. PageSize:listState.pageSize,
  28. KeyWord:keyword.value,
  29. FilterReportType: listState.listType
  30. })
  31. if(res.Ret===200){
  32. listState.loading=false
  33. if(!res.Data){
  34. listState.finished=true
  35. return
  36. }
  37. listState.finished=res.Data.Paging.IsEnd
  38. const arr=res.Data.List||[]
  39. listState.list=[...listState.list,...arr]
  40. }
  41. }
  42. function onLoad(){
  43. console.log('onload');
  44. listState.page++
  45. getList()
  46. }
  47. function handleSearch(){
  48. if(!keyword.value){
  49. showToast('请输入关键词')
  50. return
  51. }
  52. listState.page=1
  53. listState.list=[]
  54. listState.finished=false
  55. getList()
  56. }
  57. function goDetail(item){
  58. router.push({
  59. path:"/report/preview",
  60. query:{
  61. id:item.Id
  62. }
  63. })
  64. }
  65. </script>
  66. <template>
  67. <div class="report-search-page">
  68. <div class="search-box">
  69. <van-search
  70. shape="round"
  71. placeholder="请输入报告标题或创建人"
  72. v-model="keyword"
  73. @search="handleSearch"
  74. />
  75. <div class="report-type">
  76. <van-tabs
  77. v-model:active="listState.listType"
  78. title-active-color="#0052D9"
  79. title-inactive-color="#333"
  80. @change="handleSearch"
  81. >
  82. <van-tab
  83. :title="tab.label"
  84. v-for="tab in reportTypes"
  85. :key="tab.key"
  86. :name="tab.key"
  87. ></van-tab>
  88. </van-tabs>
  89. </div>
  90. </div>
  91. <img v-if="listState.list.length==0&&listState.finished&&keyword" class="list-empty-img" src="https://hzstatic.hzinsights.com/static/ETA_mobile/empty_img.png" alt="">
  92. <template v-if="keyword">
  93. <van-list
  94. v-model:loading="listState.loading"
  95. :finished="listState.finished"
  96. :finished-text="listState.list.length>0?'没有更多了':'暂无报告'"
  97. :immediate-check="false"
  98. @load="onLoad"
  99. >
  100. <ul class="list-wrap">
  101. <li
  102. v-for="item in listState.list"
  103. :key="item.Id"
  104. class="item"
  105. @click="goDetail(item)"
  106. >
  107. <h2 v-html="setHightLightText(item.Title,keyword)" :class="['van-ellipsis title',item.Title.startsWith('【')?'inline-title':'']"></h2>
  108. <p class="van-multi-ellipsis--l2 des">{{item.Abstract}}</p>
  109. <div class="bot-info">
  110. <div>
  111. <span style="margin-right:10px">{{moment(item.ModifyTime).format('YYYY-MM-DD HH:mm:ss')}}</span>
  112. <span>(第{{item.Stage}}期)</span>
  113. </div>
  114. <div>{{item.ClassifyNameFirst}}</div>
  115. </div>
  116. </li>
  117. </ul>
  118. </van-list>
  119. </template>
  120. </div>
  121. </template>
  122. <style lang="scss" scoped>
  123. .list-wrap{
  124. padding: 30px 34px;
  125. .item{
  126. padding: 20px;
  127. margin-bottom: 20px;
  128. border: 1px solid $border-color;
  129. box-shadow: 0px 3px 12px rgba(52, 75, 120, 0.08);
  130. border-radius: 8px;
  131. .title{
  132. font-size: 32px;
  133. line-height: 44px;
  134. margin: 0;
  135. }
  136. .inline-title{
  137. margin-left: -14px;
  138. }
  139. .des{
  140. margin-top: 10px;
  141. margin-bottom: 20px;
  142. font-size: 28px;
  143. color: $font-grey;
  144. min-height: 60px;
  145. }
  146. .bot-info{
  147. display: flex;
  148. justify-content: space-between;
  149. color: $font-grey;
  150. font-size: 28px;
  151. .active-status{
  152. color: $font-success;
  153. }
  154. }
  155. }
  156. }
  157. .report-search-page{
  158. .search-box{
  159. position: sticky;
  160. top: 0;
  161. z-index: 99;
  162. background-color: #fff;
  163. }
  164. }
  165. @media screen and (min-width:$media-width){
  166. .list-wrap{
  167. padding: 30px;
  168. .item{
  169. padding: 20px;
  170. margin-bottom: 20px;
  171. border-radius: 4px;
  172. .title{
  173. font-size: 16px;
  174. line-height: 22px;
  175. }
  176. .inline-title{
  177. margin-left: -14px;
  178. }
  179. .des{
  180. margin-top: 5px;
  181. margin-bottom: 10px;
  182. font-size: 14px;
  183. min-height: 30px;
  184. }
  185. .bot-info{
  186. font-size: 14px;
  187. }
  188. }
  189. }
  190. .report-search-page{
  191. .search-box{
  192. top: 60px;
  193. }
  194. }
  195. }
  196. </style>