index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <view class="quick-audit-card">
  3. <view v-for="(item, index) in list" :key="index" class="card-list" v-show="item.show">
  4. <CardList :item="item" :index="index" :taskList="taskListArr" @reviewFn="reviewFn" />
  5. <uv-divider text="分割线" textColor="#6eb657" lineColor="#6eb657"></uv-divider>
  6. </view>
  7. </view>
  8. </template>
  9. <script setup lang="ts">
  10. import { onShow, onLoad, onReachBottom } from '@dcloudio/uni-app'
  11. import { reactive, ref } from 'vue'
  12. import {
  13. getListApi,
  14. getPackageTaskTypeApi,
  15. batchApprovalTask,
  16. wmreportBatchApprovalTask,
  17. wmreportFetchListApi
  18. } from '@/service/modules/quickAuditCard'
  19. import { useLoginStore } from '@/store/login'
  20. import CardList from './components/cardList.vue'
  21. const loginStore = useLoginStore()
  22. let userInfo: any = loginStore.currentUserInfo
  23. const roles: number[] = userInfo?.roles || []
  24. const type = ref('')
  25. const id = ref('')
  26. onLoad((e) => {
  27. type.value = e?.type
  28. id.value = e?.id
  29. getTaskListArr()
  30. getList()
  31. })
  32. const taskListArr = ref<any[]>([])
  33. const getTaskListArr = async () => {
  34. const res = await getPackageTaskTypeApi()
  35. taskListArr.value = res.data
  36. }
  37. let list = ref<any[]>([])
  38. const getList = async () => {
  39. let res
  40. if (type.value === '1') {
  41. res = await getListApi({
  42. packageId: id.value
  43. })
  44. } else if (type.value === '2') {
  45. res = await wmreportFetchListApi({
  46. id: id.value
  47. })
  48. }
  49. if (res.code === 0) {
  50. list.value = res.data
  51. }
  52. // 针对图片处理
  53. list.value.forEach((item) => {
  54. if (item.config && item.config.length != 0) {
  55. item.config.forEach((iten: any) => {
  56. iten.taskFiledType = iten.taskFiledType.trim()
  57. if (iten.taskFiledType == 'img') {
  58. getImgList(item.wmTaskContent[iten.taskFiledKey], iten)
  59. }
  60. })
  61. }
  62. item.show = true
  63. })
  64. }
  65. const getImgList = (urlStr: any, item: any) => {
  66. if (item.taskFiledType != 'img') return ''
  67. if (!urlStr) return ''
  68. let uArr = urlStr.split(',')
  69. if (!uArr) return ''
  70. let imgList: any[] = []
  71. let previewList: any[] = []
  72. uArr.forEach((uItem: any) => {
  73. let type = '无 '
  74. if (uItem.includes(';1')) {
  75. type = '拍照'
  76. uItem = uItem.replace(';1', '')
  77. }
  78. if (uItem.includes(';2')) {
  79. type = '相册'
  80. uItem = uItem.replace(';2', '')
  81. }
  82. imgList.push({
  83. type,
  84. url: import.meta.env.VITE_APP_URL + uItem
  85. })
  86. previewList.push(import.meta.env.VITE_APP_URL + uItem)
  87. })
  88. item.imgList = imgList
  89. item.previewList = previewList
  90. return ''
  91. }
  92. // type 0 拒绝 1 通过
  93. const reviewFn = async (result: number, index: number) => {
  94. const item = list.value[index]
  95. let res
  96. if (type.value === '1') {
  97. const obj = {
  98. id: item.id,
  99. taskStatus: result == 0 ? 4 : 3,
  100. taskIdToNodeIdMap: {
  101. [item.id]: item.taskInfo.checkState.curNodeId
  102. }
  103. }
  104. res = await batchApprovalTask(obj)
  105. } else if (type.value === '2') {
  106. const approvalOpinion = result == 1 ? 1 : 2
  107. let nodeId = item.taskInfo.checkState.nextNodeId
  108. if (roles.includes(42)) {
  109. nodeId = 8
  110. }
  111. // 40 商务组
  112. if (roles.includes(40)) {
  113. nodeId = 9
  114. }
  115. let obj = {
  116. reportId: id.value,
  117. taskIds: id,
  118. taskIdToNodeIdMap: {
  119. [item.id]: nodeId
  120. },
  121. approvalOpinion: approvalOpinion
  122. }
  123. res = await wmreportBatchApprovalTask(obj)
  124. }
  125. if (res.code == 0) {
  126. list.value[index].show = false
  127. }
  128. }
  129. </script>
  130. <style lang="scss" scoped>
  131. .quick-audit-card {
  132. background-color: #f8f8f8;
  133. .card-list {
  134. margin-bottom: 20rpx;
  135. padding-bottom: 20rpx;
  136. background-color: #fff;
  137. }
  138. }
  139. </style>