123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- <script setup name="ReportSearch">
- import {setHightLightText} from '@/hooks/common'
- import {ref,reactive} from 'vue'
- import apiReport from '@/api/report'
- import { showToast } from 'vant'
- import moment from 'moment'
- import { useRouter } from 'vue-router'
- console.log('搜索页setup');
- const router=useRouter()
- const reportTypes = [
- { label: '我的研报',key:'3' },
- { label: '共享研报',key:'2' },
- { label: '公共研报',key:'1' },
- ]
- const keyword=ref('')
- const listState = reactive({
- listType: '3',
- list:[],
- page:1,
- pageSize:20,
- finished:false,
- loading:false
- })
- async function getList(){
- const res=await apiReport.getList({
- CurrentIndex:listState.page,
- PageSize:listState.pageSize,
- KeyWord:keyword.value,
- FilterReportType: listState.listType
- })
- if(res.Ret===200){
- listState.loading=false
- if(!res.Data){
- listState.finished=true
- return
- }
-
- listState.finished=res.Data.Paging.IsEnd
- const arr=res.Data.List||[]
- listState.list=[...listState.list,...arr]
- }
- }
- function onLoad(){
- console.log('onload');
- listState.page++
- getList()
- }
- function handleSearch(){
- if(!keyword.value){
- showToast('请输入关键词')
- return
- }
- listState.page=1
- listState.list=[]
- listState.finished=false
- getList()
- }
- function goDetail(item){
- router.push({
- path:"/report/preview",
- query:{
- id:item.Id
- }
- })
- }
- </script>
- <template>
- <div class="report-search-page">
- <div class="search-box">
- <van-search
- shape="round"
- placeholder="请输入报告标题或创建人"
- v-model="keyword"
- @search="handleSearch"
- />
- <div class="report-type">
- <van-tabs
- v-model:active="listState.listType"
- title-active-color="#0052D9"
- title-inactive-color="#333"
- @change="handleSearch"
- >
- <van-tab
- :title="tab.label"
- v-for="tab in reportTypes"
- :key="tab.key"
- :name="tab.key"
- ></van-tab>
- </van-tabs>
- </div>
- </div>
-
- <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="">
- <template v-if="keyword">
- <van-list
- v-model:loading="listState.loading"
- :finished="listState.finished"
- :finished-text="listState.list.length>0?'没有更多了':'暂无报告'"
- :immediate-check="false"
- @load="onLoad"
- >
- <ul class="list-wrap">
- <li
- v-for="item in listState.list"
- :key="item.Id"
- class="item"
- @click="goDetail(item)"
- >
- <h2 v-html="setHightLightText(item.Title,keyword)" :class="['van-ellipsis title',item.Title.startsWith('【')?'inline-title':'']"></h2>
- <p class="van-multi-ellipsis--l2 des">{{item.Abstract}}</p>
- <div class="bot-info">
- <div>
- <span style="margin-right:10px">{{moment(item.ModifyTime).format('YYYY-MM-DD HH:mm:ss')}}</span>
- <span>(第{{item.Stage}}期)</span>
- </div>
- <div>{{item.ClassifyNameFirst}}</div>
- </div>
- </li>
- </ul>
- </van-list>
- </template>
- </div>
- </template>
- <style lang="scss" scoped>
- .list-wrap{
- padding: 30px 34px;
- .item{
- padding: 20px;
- margin-bottom: 20px;
- border: 1px solid $border-color;
- box-shadow: 0px 3px 12px rgba(52, 75, 120, 0.08);
- border-radius: 8px;
- .title{
- font-size: 32px;
- line-height: 44px;
- margin: 0;
- }
- .inline-title{
- margin-left: -14px;
- }
- .des{
- margin-top: 10px;
- margin-bottom: 20px;
- font-size: 28px;
- color: $font-grey;
- min-height: 60px;
- }
- .bot-info{
- display: flex;
- justify-content: space-between;
- color: $font-grey;
- font-size: 28px;
- .active-status{
- color: $font-success;
- }
- }
- }
- }
- .report-search-page{
- .search-box{
- position: sticky;
- top: 0;
- z-index: 99;
- background-color: #fff;
- }
- }
- @media screen and (min-width:$media-width){
- .list-wrap{
- padding: 30px;
- .item{
- padding: 20px;
- margin-bottom: 20px;
- border-radius: 4px;
- .title{
- font-size: 16px;
- line-height: 22px;
- }
- .inline-title{
- margin-left: -14px;
- }
- .des{
- margin-top: 5px;
- margin-bottom: 10px;
- font-size: 14px;
- min-height: 30px;
- }
- .bot-info{
- font-size: 14px;
- }
- }
- }
- .report-search-page{
- .search-box{
- top: 60px;
- }
- }
- }
- </style>
|