index.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. <template>
  2. <view class="task-audit">
  3. <view class="search">
  4. <view class="top-search">
  5. <view class="search-input">
  6. <uv-input
  7. v-model="searchParams.planName"
  8. :customStyle="customStyle"
  9. clearable
  10. shape="circle"
  11. placeholder="请输入"
  12. prefixIcon="search"
  13. prefixIconStyle="font-size: 22px;color: #6eb657"
  14. ></uv-input>
  15. </view>
  16. <view class="search-button" @click="searchFn">搜索</view>
  17. <uv-icon name="plus-circle" color="#6eb657" size="24" />
  18. </view>
  19. </view>
  20. <view class="checkbox">
  21. <checkbox-group @change="checkboxAllChange">
  22. <label>
  23. <checkbox :checked="checkedAll" style="transform: scale(0.8)" color="#6eb657" />全选
  24. </label>
  25. </checkbox-group>
  26. </view>
  27. <view class="list" v-if="hasInfo">
  28. <view class="list-content" v-for="item in listArr" :key="item.id">
  29. <checkbox-group @change="checkboxChange(item)">
  30. <checkbox :checked="item.checked" style="transform: scale(0.8)" color="#6eb657" />
  31. </checkbox-group>
  32. <view class="item" @click="onDetail(item)">
  33. <view class="top">
  34. <view class="top-l">
  35. <image src="@/static/images/icon/review.png" class="image" />
  36. <text>{{ item.lookintoDate }}</text>
  37. </view>
  38. <view class="top-r">
  39. <text></text>
  40. <view class="status">{{ item?.checkState?.displayInfo }}</view>
  41. </view>
  42. </view>
  43. <view class="content">
  44. <view class="title">
  45. <view class="task-name">{{ item.taskTypeName || 'abcd' }}</view>
  46. <view class="score">+{{ item.score }}积分</view>
  47. </view>
  48. <view class="num"> 任务编号:{{ item.taskNumber }} </view>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="btn">
  53. <view class="cancel" @click="reviewFn('4')">拒绝</view>
  54. <view class="confirm" @click="reviewFn('3')">通过</view>
  55. </view>
  56. </view>
  57. <noData v-else />
  58. </view>
  59. </template>
  60. <script setup lang="ts">
  61. import { reactive, ref } from 'vue'
  62. import { onShow, onLoad, onReachBottom } from '@dcloudio/uni-app'
  63. import {
  64. getListApi,
  65. getTaskListPageApi,
  66. batchApprovalTaskApi,
  67. reportBatchApprovalTaskApi
  68. } from '@/service/modules/taskAudit'
  69. import { useLoginStore } from '@/store/login'
  70. import noData from '@/components/noData/index.vue'
  71. import { useReview } from '@/store/review'
  72. const loginStore = useLoginStore()
  73. let userInfo: any = loginStore.currentUserInfo
  74. const roles: number[] = userInfo.roles
  75. const reviewStore = useReview()
  76. const currentId = ref()
  77. const taskStatus = ref()
  78. const checkedAll = ref(false)
  79. const checkboxAllChange = () => {
  80. checkedAll.value = !checkedAll.value
  81. listArr.value.forEach((item) => (item.checked = checkedAll.value))
  82. }
  83. const currentScoreId = ref()
  84. const currentPage = ref()
  85. onLoad((e) => {
  86. currentId.value = e?.id
  87. currentPage.value = e?.page
  88. let text = ''
  89. if (e?.page === '1') {
  90. taskStatus.value = e?.taskStatus
  91. searchParams.value.taskStatus = e?.taskStatus
  92. searchParams.value.scorePackageId = e?.id
  93. text = e?.taskStatus ? '任务审核' : '任务详情'
  94. } else if (e?.page === '2') {
  95. taskListPageParams.isApprovalPage = e?.type == 'approval' ? '1' : '0'
  96. taskListPageParams.id = e?.id
  97. text = e?.type == 'approval' ? '任务审核' : '任务详情'
  98. }
  99. uni.setNavigationBarTitle({
  100. title: text
  101. })
  102. })
  103. onShow(() => {
  104. searchParams.value.current = 1
  105. listArr.value = []
  106. getList()
  107. })
  108. const customStyle = {
  109. backgroundColor: '#f6f6f6'
  110. }
  111. class Params {
  112. taskStatus = ''
  113. scorePackageId = ''
  114. planName = ''
  115. total = -1
  116. current = 1
  117. size = 10
  118. }
  119. const searchParams = ref(new Params())
  120. const taskListPageParams = reactive({
  121. isApprovalPage: '',
  122. id: '',
  123. current: 1,
  124. size: 10
  125. })
  126. const checkboxChange = (item: any) => {
  127. item.checked = !item.checked
  128. }
  129. const searchFn = () => {
  130. listArr.value = []
  131. searchParams.value.current = 1
  132. getList()
  133. }
  134. const hasInfo = ref(true)
  135. const listArr = ref<any[]>([])
  136. const getList = async () => {
  137. uni.showLoading()
  138. let res
  139. if (currentPage.value === '1') {
  140. res = await getListApi(searchParams.value)
  141. } else if (currentPage.value === '2') {
  142. res = await getTaskListPageApi(taskListPageParams)
  143. }
  144. res.data.records.forEach((item: any) => {
  145. item.checked = false
  146. })
  147. listArr.value = listArr.value.concat(res.data.records)
  148. searchParams.value.total = res.data.total
  149. hasInfo.value = !!listArr.value.length
  150. uni.hideLoading()
  151. }
  152. const onDetail = (row: any) => {
  153. const info = JSON.stringify(row)
  154. reviewStore.setCurrentInfo(info)
  155. if (currentPage.value === '1') {
  156. const show = !!searchParams.value.taskStatus
  157. uni.navigateTo({
  158. url: `/pages-sub-service-mangement/taskAuditDetail/index?id=${row.id}&type=1&show=${show}`
  159. })
  160. } else if (currentPage.value === '2') {
  161. const show = taskListPageParams.isApprovalPage === '1'
  162. uni.navigateTo({
  163. url: `/pages-sub-service-mangement/taskAuditDetail/index?id=${row.id}&type=2&reportId=${currentId.value}&show=${show}`
  164. })
  165. }
  166. }
  167. onReachBottom(() => {
  168. if (listArr.value.length === searchParams.value.total) return
  169. if (currentPage.value === '1') {
  170. searchParams.value.current++
  171. } else if (currentPage.value === '2') {
  172. taskListPageParams.current++
  173. }
  174. getList()
  175. })
  176. const reviewFn = async (status: string) => {
  177. const arr = listArr.value.filter((item) => item.checked)
  178. if (!arr.length) {
  179. return uni.showToast({
  180. title: '请先选择数据',
  181. icon: 'none'
  182. })
  183. }
  184. const taskIdToNodeIdMap: any = {}
  185. const idArr = arr.map((item) => item.id)
  186. const ids = idArr.join(',')
  187. arr.forEach((item) => {
  188. if (currentPage.value === '1') {
  189. taskIdToNodeIdMap[item.id] = item.checkState.curNodeId
  190. } else if (currentPage.value === '2') {
  191. taskIdToNodeIdMap[item.id] = item.checkState.nextNodeId
  192. if (roles.includes(42)) {
  193. taskIdToNodeIdMap[item.id] = 8
  194. }
  195. // 40 商务组
  196. if (roles.includes(40)) {
  197. taskIdToNodeIdMap[item.id] = 9
  198. }
  199. }
  200. })
  201. let res
  202. if (currentPage.value === '1') {
  203. let obj = {
  204. id: ids,
  205. taskIdToNodeIdMap: taskIdToNodeIdMap,
  206. taskStatus: status
  207. }
  208. res = await batchApprovalTaskApi(obj)
  209. } else if (currentPage.value === '2') {
  210. let obj = {
  211. reportId: currentId.value,
  212. id: ids,
  213. taskIds: ids,
  214. taskIdToNodeIdMap: taskIdToNodeIdMap,
  215. approvalOpinion: status == '3' ? '1' : '2'
  216. }
  217. res = await reportBatchApprovalTaskApi(obj)
  218. }
  219. if (res.data) {
  220. uni.showToast({
  221. title: '审核成功',
  222. icon: 'none'
  223. })
  224. }
  225. setTimeout(() => {
  226. listArr.value = []
  227. searchParams.value.current = 1
  228. getList()
  229. }, 1000)
  230. }
  231. </script>
  232. <style lang="scss" scoped>
  233. .task-audit {
  234. padding: 24rpx 30rpx;
  235. .search {
  236. position: fixed;
  237. width: 750rpx;
  238. padding: 0 30rpx;
  239. top: 0;
  240. height: 60rpx;
  241. background-color: #fff;
  242. z-index: 99;
  243. .top-search {
  244. display: flex;
  245. align-items: center;
  246. .search-input {
  247. width: 540rpx;
  248. height: 70rpx;
  249. }
  250. .search-button {
  251. color: #6eb657;
  252. font-size: 30rpx;
  253. margin: 0 10px;
  254. font-weight: 400;
  255. }
  256. }
  257. }
  258. .checkbox {
  259. margin-top: 80rpx;
  260. }
  261. .list {
  262. margin-bottom: 120rpx;
  263. padding-bottom: 60rpx;
  264. .list-content {
  265. display: flex;
  266. align-items: center;
  267. margin-top: 20rpx;
  268. }
  269. .item {
  270. flex: 1;
  271. box-shadow: 0px 4rpx 4rpx 0px rgba(0, 0, 0, 0.05);
  272. margin-bottom: 20rpx;
  273. border-radius: 16rpx;
  274. .top {
  275. padding: 0 30rpx;
  276. box-sizing: border-box;
  277. height: 100rpx;
  278. background-color: #6eb657;
  279. border-top-left-radius: 16rpx;
  280. border-top-right-radius: 16rpx;
  281. display: flex;
  282. align-items: center;
  283. justify-content: space-between;
  284. .top-l {
  285. display: flex;
  286. align-items: center;
  287. .image {
  288. width: 28rpx;
  289. height: 28rpx;
  290. }
  291. text {
  292. font-size: 26rpx;
  293. color: #fff;
  294. line-height: 36rpx;
  295. margin-left: 20rpx;
  296. }
  297. }
  298. .top-r {
  299. display: flex;
  300. align-items: center;
  301. text {
  302. display: block;
  303. width: 10rpx;
  304. height: 10rpx;
  305. background-color: #fff;
  306. border-radius: 50%;
  307. margin-right: 10rpx;
  308. }
  309. .status {
  310. color: #fff;
  311. font-size: 28rpx;
  312. line-height: 40rpx;
  313. }
  314. }
  315. }
  316. .content {
  317. background-color: #fff;
  318. padding: 30rpx;
  319. box-sizing: border-box;
  320. .title {
  321. display: flex;
  322. justify-content: space-between;
  323. margin-bottom: 20rpx;
  324. align-items: center;
  325. .task-name {
  326. font-size: 32rpx;
  327. line-height: 45rpx;
  328. color: #313131;
  329. }
  330. .score {
  331. font-size: 28rpx;
  332. color: #72b25b;
  333. }
  334. }
  335. .num {
  336. font-weight: 400;
  337. font-size: 22rpx;
  338. line-height: 32rpx;
  339. color: #999999;
  340. }
  341. }
  342. }
  343. }
  344. }
  345. .btn {
  346. display: flex;
  347. padding: 20rpx 30rpx;
  348. box-sizing: border-box;
  349. justify-content: space-between;
  350. position: fixed;
  351. background-color: #fff;
  352. bottom: 0;
  353. width: 700rpx;
  354. height: 120rpx;
  355. view {
  356. font-weight: 400;
  357. box-sizing: border-box;
  358. font-size: 32rpx;
  359. line-height: 45rpx;
  360. border-radius: 8rpx;
  361. height: 72rpx;
  362. width: 290rpx;
  363. display: flex;
  364. align-items: center;
  365. justify-content: center;
  366. }
  367. .cancel {
  368. border: 2rpx solid #c7c7c7;
  369. color: #111;
  370. }
  371. .confirm {
  372. background-color: #6eb657;
  373. color: #ffffff;
  374. }
  375. }
  376. </style>