吉安感知网项目-前端
shuishen
2026-02-03 89380e6260a75d1d3b94de687ebcc2f50d50659d
uniapps/work-app/src/pages/work/index.vue
@@ -2,22 +2,27 @@
  <div class="eventTickets" :style="{ paddingTop: topMargin + 'px' }">
    <div class="searchTop">
      <up-search placeholder="请输入关键字搜索"  :animation="true"  v-model="listParams.keyword" :show-action="false"></up-search>
      <up-search placeholder="请输入关键字搜索"  :animation="true"  v-model="listParams.keyword" :show-action="false" @search="handleSearch" @clear="handleClear"></up-search>
    </div>
    <div class="listBox">
      <div class="tabs-container">
        <up-tabs :list="tabList" @click="handleClick"></up-tabs>
      </div>
      <scroll-view class="eventBox" scroll-y :lower-threshold="80" @scrolltolower="loadMore">
<!-- @scrolltolower="loadMore" -->
      <scroll-view class="eventBox" scroll-y :lower-threshold="80" >
        <div class="eventList">
          <div class="eventItem"  v-for="(item,index) in dataList" :key="index">
            <img :src="item.photo_url" alt="" @click="detailHandle(item)" />
            <img :src="item.eventImageUrl" alt="" @click="detailHandle(item)" />
            <div class="informationDisplay">
              <!--              <div class="itemTitle">{{item.event_name}}</div>-->
              <div class="itemContent">{{formatDate(item.create_time) }}</div>
              <div class="itemContent">{{formatDate(item.createTime) }}</div>
            </div>
          </div>
        </div>
        <!-- 暂无数据提示 -->
        <div class="noData" v-if="!loading && dataList.length === 0">
          <text>暂无数据</text>
        </div>
        <!-- 加载提示 -->
@@ -35,7 +40,7 @@
<script setup>
import { useUserStore } from '@/store/index.js'
import {getList,getstatusCount} from '/src/api/work/index.js'
import {getGdList,getstatusCount} from '/src/api/work/index.js'
import dayjs from 'dayjs';
import { getStatusBarHeight } from '@/utils/common';
const userStore = useUserStore()
@@ -49,15 +54,17 @@
    name: '全部工单',
    key: 'all',
    badge: {
      value: 2
      value: 0,
      showZero: true
    },
    status: null
  },
  {
    name: '我的工单',
    key: 'myTickets',
    badge: {
      value: 1
      value: 0,
      showZero: true
    }
  }
@@ -67,7 +74,7 @@
  return dayjs(dateString).format('MM/DD HH:mm');
};
const listParams = ref({
  status: null,
  current: 1,
  size: 12,
  source: 1,
@@ -82,58 +89,54 @@
  const params = {
    current: listParams.value.current,
    size: listParams.value.size,
    source: 1,
    status:listParams.value.status,
    event_name:listParams.value.keyword,
    user_id:currentTab.value=== 'myTickets' ?userInfo.user_id : undefined
    keyword:listParams.value.keyword,
    onlyMine:currentTab.value=== 'myTickets' ? 1 : 0
  }
  getList(params).then(res => {
  getGdList(params).then(res => {
    const response = res.data.data
    const records = response.records || []
    dataList.value = response
    // 根据当前页码决定是替换还是追加数据
    if (listParams.value.current === 1) {
      dataList.value = records
    } else {
      dataList.value = [...dataList.value, ...records]
    }
    // if (listParams.value.current === 1) {
    //   dataList.value = response
    // } else {
    //   dataList.value = [...dataList.value, ...response]
    // }
    // 判断是否还有更多数据
    if (records.length < listParams.value.size || response.current >= response.pages) {
      hasMore.value = false
    } else {
      hasMore.value = true
    }
    // // 判断是否还有更多数据
    // if (response.length < listParams.value.size || response.current >= response.pages) {
    //   hasMore.value = false
    // } else {
    //   hasMore.value = true
    // }
  }).finally(() => {
    loading.value = false
  })
}
const getstatusCountData=()=>{
  const params={
    keyword:listParams.value.keyword,
  }
   getstatusCount(params).then(res=>{
      const response = res.data.data
       const {  totalCount,myCount } = response
      tabList.value.forEach(tab=>{
         if(tab.key === 'all'){
        tab.badge.value = (totalCount || 0).toString()
        tab.badge.showZero = true
         }else if(tab.key === 'myTickets'){
            tab.badge.value = (myCount || 0).toString()
        tab.badge.showZero = true
         }
      })
// const getstatusCountData=()=>{
//    getstatusCount().then(res=>{
//       const response = res.data.data
//        const { statusCount, totalCount, userCount } = response
//       tabList.value.forEach(tab=>{
//
//          if(tab.key === 'all'){
//             tab.badge.value = totalCount || 0
//
//          }else if(tab.key === 'myTickets'){
//             tab.badge.value = userCount || 0
//          }else{
//             tab.badge.value=statusCount[String(tab.status)] || 0
//          }
//       })
//
//    })
// }
   })
}
const handleClick = (item) => {
  currentTab.value = item.key
  listParams.value.status = item.status
  listParams.value.current = 1
  hasMore.value = true
  dataList.value = []
@@ -147,8 +150,26 @@
const detailHandle = (val) => {
  uni.navigateTo({
    url: `/subPackages/workDetail/index?eventNum=${val.event_num}`,
    url: `/subPackages/workDetail/index?id=${val.id}`,
  })
}
// 搜索功能
const handleSearch = () => {
  listParams.value.current = 1
  hasMore.value = true
  dataList.value = []
  getDataList()
  getstatusCountData()
}
// 清除搜索
const handleClear = () => {
  listParams.value.keyword = ''
  listParams.value.current = 1
  hasMore.value = true
  dataList.value = []
  getDataList()
  getstatusCountData()
}
const topMargin = getStatusBarHeight()
onShow(() => {
@@ -156,6 +177,7 @@
  hasMore.value = true
  dataList.value = []
  getDataList()
  getstatusCountData()
})
</script>
@@ -175,6 +197,14 @@
    padding-right: 24rpx;
    width: 100%;
    height: 108rpx;
    :deep(){
      .u-search__content{
        background: #fff !important;
      }
      .u-search__content__input{
        background: #fff !important;
      }
    }
  }
  :deep(){
@@ -184,7 +214,7 @@
    }
    .u-badge {
      background-color: #1d6fe9 !important;
      margin-top: -17px !important;
      margin-top: -14px !important;
      margin-left: -5px !important;
    }
  }
@@ -279,5 +309,15 @@
    color: #999;
    width: 100%;
  }
  .noData {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 300rpx;
    font-size: 28rpx;
    color: #999;
    width: 100%;
  }
}
</style>