PendingVerificationList.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <route lang="json5" type="page">
  2. {
  3. layout: 'default',
  4. style: {
  5. navigationBarTitleText: '记录校核',
  6. navigationStyle: 'custom',
  7. disableScroll: true,
  8. 'app-plus': {
  9. bounce: 'none',
  10. },
  11. },
  12. }
  13. </route>
  14. <template>
  15. <view class="verification-container">
  16. <!-- 导航栏 -->
  17. <NavBar title="记录校核" />
  18. <!-- 查询视图 -->
  19. <QueryView :query-type="queryType" @query-action="queryAction" />
  20. <!-- 列表 -->
  21. <scroll-view class="list-scroll" scroll-y @scrolltolower="loadMore">
  22. <view v-for="item in listData" :key="item.reportId" class="item-box">
  23. <Item
  24. :item="item"
  25. :report-do-list="reportDOList(item)"
  26. :operate-text="'校核'"
  27. @handle-operation="pushAction"
  28. />
  29. </view>
  30. <view v-if="loading" class="loading-text">加载中...</view>
  31. <view v-if="!hasMore && listData.length > 0" class="no-more-text">没有更多了</view>
  32. <view v-if="!loading && listData.length === 0" class="empty-text">
  33. <text>暂无数据</text>
  34. </view>
  35. </scroll-view>
  36. </view>
  37. </template>
  38. <script lang="ts" setup>
  39. import { ref, reactive, computed, onMounted, onUnmounted } from 'vue'
  40. import { useUserStore } from '@/store/user'
  41. import { getPendingVerificationListApi } from '@/api/pendingVerification'
  42. import QueryView from '@/pages/pendingVerification/components/query/QueryView.vue'
  43. import Item from '@/pages/pendingVerification/list/Item.vue'
  44. import NavBar from '@/components/NavBar/NavBar.vue'
  45. defineOptions({
  46. name: 'PendingVerificationList',
  47. })
  48. // 状态
  49. const listData = ref<any[]>([])
  50. const loading = ref(false)
  51. const hasMore = ref(true)
  52. const params = reactive({
  53. pageNo: 1,
  54. pageSize: 10,
  55. recheckStrIds: '',
  56. })
  57. const userStore = useUserStore()
  58. const userInfo = computed(() => userStore.userInfo)
  59. // 初始化参数
  60. params.recheckStrIds = userInfo.value?.id || ''
  61. const queryType = { value: '校核人', id: 'recheckStrIds' }
  62. // 获取列表数据
  63. const fetchList = async (refresh = false) => {
  64. if (loading.value) return
  65. params.pageNo = refresh ? 1 : params.pageNo + 1
  66. loading.value = true
  67. try {
  68. const result = await getPendingVerificationListApi(params)
  69. const newList = result?.data?.list || []
  70. if (refresh) {
  71. listData.value = newList
  72. } else {
  73. listData.value = [...listData.value, ...newList]
  74. }
  75. hasMore.value = newList.length >= params.pageSize
  76. } catch (error) {
  77. console.error('获取列表失败:', error)
  78. } finally {
  79. loading.value = false
  80. }
  81. }
  82. // 加载更多
  83. const loadMore = () => {
  84. if (!loading.value && hasMore.value) {
  85. fetchList(false)
  86. }
  87. }
  88. // 刷新列表
  89. const refreshList = () => {
  90. params.pageNo = 1
  91. fetchList(true)
  92. }
  93. // 查询动作
  94. const queryAction = (exParams: Record<string, any>) => {
  95. Object.assign(params, exParams)
  96. // 过滤空值
  97. Object.keys(params).forEach((key) => {
  98. if (params[key] === '' || params[key] === null || params[key] === undefined) {
  99. delete params[key]
  100. }
  101. })
  102. refreshList()
  103. }
  104. // 生成报告列表
  105. const reportDOList = (item: any) => {
  106. const recheckList = item.recheckList || []
  107. if (recheckList.length) {
  108. return recheckList
  109. }
  110. return [{
  111. id: item.id,
  112. reportId: item.reportId,
  113. reportName: item.reportName,
  114. reportType: item.reportType,
  115. image: item.image,
  116. video: item.video,
  117. attachment: item.attachment,
  118. }]
  119. }
  120. // 跳转操作
  121. const pushAction = (item: any, reportDOList: any, isBatch: boolean) => {
  122. if (!item.reportId) {
  123. return uni.showToast({ title: '没有报告', icon: 'error' })
  124. }
  125. uni.navigateTo({
  126. url: `/pages/pendingVerification/preViewReport/index?id=${item.id}&orderId=${item.orderId}&reportId=${item.reportId}&reportDOList=${encodeURIComponent(JSON.stringify(reportDOList))}&equipCode=${item.equipCode}&isBatch=${isBatch ? '1' : '0'}`,
  127. })
  128. }
  129. // 监听刷新事件
  130. const refreshListener = (data: any) => {
  131. refreshList()
  132. }
  133. onMounted(() => {
  134. refreshList()
  135. uni.$on('RefreshVerificationListApi', refreshListener)
  136. })
  137. onUnmounted(() => {
  138. uni.$off('RefreshVerificationListApi', refreshListener)
  139. })
  140. </script>
  141. <style lang="scss" scoped>
  142. .verification-container {
  143. display: flex;
  144. flex-direction: column;
  145. height: 100vh;
  146. background-color: #f5f5f5;
  147. }
  148. .navigate-view {
  149. display: flex;
  150. justify-content: center;
  151. align-items: center;
  152. height: 44px;
  153. background-color: #fff;
  154. border-bottom: 1px solid #eee;
  155. }
  156. .navigate-title {
  157. font-size: 17px;
  158. font-weight: 500;
  159. color: #333;
  160. }
  161. .list-scroll {
  162. flex: 1;
  163. overflow: hidden;
  164. }
  165. .loading-text,
  166. .no-more-text {
  167. text-align: center;
  168. padding: 15px;
  169. color: #999;
  170. font-size: 14px;
  171. }
  172. .empty-text {
  173. display: flex;
  174. flex-direction: column;
  175. align-items: center;
  176. justify-content: center;
  177. padding: 60px 0;
  178. color: #999;
  179. font-size: 14px;
  180. }
  181. .item-box {
  182. margin: 13px;
  183. background-color: #fff;
  184. border-radius: 5px;
  185. }
  186. </style>