InspectionPlanAuditList.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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="audit-container">
  16. <!-- 导航栏 -->
  17. <NavBar title="检验方案审核" />
  18. <!-- 筛选栏 -->
  19. <RadioFilterBar
  20. v-model="rightType"
  21. :options="rightTypeList"
  22. type="radio"
  23. @change="handleRightRefresh"
  24. />
  25. <!-- 列表 -->
  26. <scroll-view class="list-scroll" scroll-y @scrolltolower="loadMore">
  27. <view v-for="item in listData" :key="item.id" class="item-box">
  28. <Item :item="item" :operate-text="'审核'" @handle-operation="pushAction(item)" />
  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 } from 'vue'
  40. import { useUserStore } from '@/store/user'
  41. import { useConfigStore } from '@/store/config'
  42. import Item from '@/pages/inspectionPlanAudit/components/Item.vue'
  43. import NavBar from '@/components/NavBar/NavBar.vue'
  44. import RadioFilterBar from '@/components/RadioFilterBar/RadioFilterBar.vue'
  45. import { requestFunc, TaskOrderFuncName } from '@/api/ApiRouter/taskOrder'
  46. import { onShow } from '@dcloudio/uni-app'
  47. defineOptions({
  48. name: 'InspectionPlanAuditList',
  49. })
  50. // 状态
  51. const listData = ref<any[]>([])
  52. const loading = ref(false)
  53. const hasMore = ref(true)
  54. const params = reactive({
  55. pageNo: 1,
  56. pageSize: 10,
  57. reportType: 600,
  58. status: '100',
  59. bpmUserId: '',
  60. approverId: '',
  61. })
  62. const userStore = useUserStore()
  63. const userInfo = computed(() => userStore.userInfo)
  64. const equipType = useConfigStore().getEquipType()
  65. // 初始化参数
  66. params.bpmUserId = userInfo.value?.id || ''
  67. const rightType = ref('100')
  68. const rightTypeList = [
  69. // { value: '全部', id: '' },
  70. { value: '审核中', id: '100' },
  71. { value: '已通过', id: '200' },
  72. { value: '已拒绝', id: '300' },
  73. ]
  74. // 获取列表数据
  75. const fetchList = async (refresh = false) => {
  76. if (loading.value) return
  77. if (params.status && params.status !== '100') {
  78. // 非审核中,查找当前用户审核审批流程结束后的数据
  79. params.bpmUserId = null
  80. params.approverId = userInfo.value?.id
  81. } else if (params.status && params.status === '100') {
  82. // 审核中,查找需要当前用户审核审批的数据
  83. params.bpmUserId = userInfo.value?.id || ''
  84. params.approverId = ''
  85. } else if (!params.status) {
  86. // 全部,包括需要当前用户审核审批、已处理的数据,但是这部分后端没有处理好,先把全部去掉了
  87. params.bpmUserId = userInfo.value?.id || ''
  88. params.approverId = null
  89. params.status = null
  90. }
  91. params.pageNo = refresh ? 1 : params.pageNo + 1
  92. loading.value = true
  93. try {
  94. const result: any = await requestFunc(TaskOrderFuncName.MajorIssuesAuditList, equipType, params)
  95. const newList = result?.data?.list || []
  96. if (refresh) {
  97. listData.value = newList
  98. } else {
  99. listData.value = [...listData.value, ...newList]
  100. }
  101. hasMore.value = newList.length >= params.pageSize
  102. } catch (error) {
  103. console.error('获取列表失败:', error)
  104. } finally {
  105. loading.value = false
  106. }
  107. }
  108. // 加载更多
  109. const loadMore = () => {
  110. if (!loading.value && hasMore.value) {
  111. fetchList(false)
  112. }
  113. }
  114. // 刷新列表
  115. const refreshList = () => {
  116. params.pageNo = 1
  117. fetchList(true)
  118. }
  119. // 筛选刷新
  120. const handleRightRefresh = (value: string | number | boolean) => {
  121. rightType.value = value as string
  122. params.status = rightType.value
  123. refreshList()
  124. }
  125. // 跳转操作
  126. const pushAction = (item: any) => {
  127. const isAuditStage = item.approvalId == null ? 1 : 0
  128. uni.navigateTo({
  129. url: `/pages/inspectionPlanAudit/preViewReport/index?id=${item.id}&reportName=${item.reportName}&templateId=${item.templateId}&isAuditStage=${isAuditStage}&manualUrl=${encodeURIComponent(item.manualUrl)}`,
  130. })
  131. }
  132. // 监听刷新事件
  133. const refreshListener = () => {
  134. refreshList()
  135. }
  136. onShow(() => {
  137. refreshList()
  138. uni.$on('onRefresh', refreshListener)
  139. })
  140. </script>
  141. <style lang="scss" scoped>
  142. .audit-container {
  143. display: flex;
  144. flex-direction: column;
  145. height: 100vh;
  146. background-color: #f5f5f5;
  147. }
  148. .list-scroll {
  149. flex: 1;
  150. overflow: hidden;
  151. }
  152. .loading-text,
  153. .no-more-text {
  154. padding: 15px;
  155. font-size: 14px;
  156. color: #999;
  157. text-align: center;
  158. }
  159. .empty-text {
  160. display: flex;
  161. flex-direction: column;
  162. align-items: center;
  163. justify-content: center;
  164. padding: 60px 0;
  165. font-size: 14px;
  166. color: #999;
  167. }
  168. .item-box {
  169. margin: 13px;
  170. background-color: #fff;
  171. border-radius: 5px;
  172. }
  173. </style>