WorkInstructionAuditList.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. <NavBar title="操作指导书批准" />
  17. <RadioFilterBar
  18. v-model="rightType"
  19. :options="rightTypeList"
  20. type="radio"
  21. @change="handleRightRefresh"
  22. />
  23. <scroll-view class="list-scroll" scroll-y @scrolltolower="loadMore">
  24. <view v-for="item in listData" :key="item.id" class="item-box">
  25. <Item :item="item" :operate-text="'批准'" @handle-operation="pushAction(item)" />
  26. </view>
  27. <view v-if="loading" class="loading-text">加载中...</view>
  28. <view v-if="!hasMore && listData.length > 0" class="no-more-text">没有更多了</view>
  29. <view v-if="!loading && listData.length === 0" class="empty-text">
  30. <text>暂无数据</text>
  31. </view>
  32. </scroll-view>
  33. </view>
  34. </template>
  35. <script lang="ts" setup>
  36. import { ref, reactive, computed } from 'vue'
  37. import { useUserStore } from '@/store/user'
  38. import { useConfigStore } from '@/store/config'
  39. import Item from '@/pages/workInstructionAudit/components/Item.vue'
  40. import NavBar from '@/components/NavBar/NavBar.vue'
  41. import RadioFilterBar from '@/components/RadioFilterBar/RadioFilterBar.vue'
  42. import { requestFunc, TaskOrderFuncName } from '@/api/ApiRouter/taskOrder'
  43. import { onShow } from '@dcloudio/uni-app'
  44. defineOptions({ name: 'WorkInstructionAuditList' })
  45. const listData = ref<any[]>([])
  46. const loading = ref(false)
  47. const hasMore = ref(true)
  48. const params = reactive({
  49. pageNo: 1,
  50. pageSize: 10,
  51. reportType: 700,
  52. bpmUserId: '',
  53. status: '100',
  54. })
  55. const userStore = useUserStore()
  56. const userInfo = computed(() => userStore.userInfo)
  57. params.bpmUserId = userInfo.value?.id || ''
  58. const equipType = useConfigStore().getEquipType()
  59. const rightType = ref('100')
  60. const rightTypeList = [
  61. // { value: '全部', id: '' },
  62. { value: '已通过', id: '200' },
  63. { value: '审核中', id: '100' },
  64. { value: '已拒绝', id: '300' },
  65. ]
  66. const fetchList = async (refresh = false) => {
  67. if (loading.value) return
  68. if (params.status && params.status !== '100') {
  69. params.bpmUserId = null
  70. params.approverId = userInfo.value?.id
  71. } else if (params.status && params.status === '100') {
  72. params.bpmUserId = userInfo.value?.id || ''
  73. params.approverId = ''
  74. } else if (!params.status) {
  75. params.bpmUserId = userInfo.value?.id || ''
  76. params.approverId = null
  77. params.status = null
  78. }
  79. params.pageNo = refresh ? 1 : params.pageNo + 1
  80. loading.value = true
  81. try {
  82. const result: any = await requestFunc(TaskOrderFuncName.MajorIssuesAuditList, equipType, params)
  83. const newList = result?.data?.list || []
  84. if (refresh) {
  85. listData.value = newList
  86. } else {
  87. listData.value = [...listData.value, ...newList]
  88. }
  89. hasMore.value = newList.length >= params.pageSize
  90. } catch (error) {
  91. console.error('获取列表失败:', error)
  92. } finally {
  93. loading.value = false
  94. }
  95. }
  96. const loadMore = () => {
  97. if (!loading.value && hasMore.value) fetchList(false)
  98. }
  99. const refreshList = () => {
  100. params.pageNo = 1
  101. fetchList(true)
  102. }
  103. const handleRightRefresh = (value: string | number | boolean) => {
  104. rightType.value = value as string
  105. params.status = rightType.value
  106. refreshList()
  107. }
  108. const pushAction = (item: any) => {
  109. uni.navigateTo({
  110. url: `/pages/workInstructionAudit/preViewReport/index?id=${item.id}&reportName=${item.reportName}&templateId=${item.templateId}`,
  111. })
  112. }
  113. const refreshListener = () => refreshList()
  114. onShow(() => {
  115. refreshList()
  116. uni.$on('onRefresh', refreshListener)
  117. })
  118. </script>
  119. <style lang="scss" scoped>
  120. .audit-container {
  121. display: flex;
  122. flex-direction: column;
  123. height: 100vh;
  124. background-color: #f5f5f5;
  125. }
  126. .list-scroll {
  127. flex: 1;
  128. overflow: hidden;
  129. }
  130. .loading-text,
  131. .no-more-text {
  132. padding: 15px;
  133. font-size: 14px;
  134. color: #999;
  135. text-align: center;
  136. }
  137. .empty-text {
  138. display: flex;
  139. flex-direction: column;
  140. align-items: center;
  141. justify-content: center;
  142. padding: 60px 0;
  143. font-size: 14px;
  144. color: #999;
  145. }
  146. .item-box {
  147. margin: 13px;
  148. background-color: #fff;
  149. border-radius: 5px;
  150. }
  151. </style>