index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. <template>
  2. <hc-sys id="app-sys" class="h-100vh hc-task-page" :isNavBar="false">
  3. <view id="hc-task-nav-bar" class="hc-task-nav-bar">
  4. <view class="task-nav-bar">
  5. <view class="segmented-bar">
  6. <template v-for="item in taskTypeData">
  7. <view class="task-tab-item"
  8. :class="item.key === taskType?'task-cur':''"
  9. @click="taskTypeChange(item)"
  10. >{{item.name}}</view>
  11. </template>
  12. </view>
  13. <view class="more-bar" v-if="taskType === 1 && taskList.length > 0" @click="moreBarClick">
  14. <text class="i-ri-more-2-fill icon"/>
  15. </view>
  16. </view>
  17. <view class="controls-bar-box">
  18. <view class="controls-bar">
  19. <view class="left">
  20. <text class="i-ri-filter-fill icon" :class="isControlsFilter?'cur':''" @click="dateFilterClick"/>
  21. <text class="i-ri-filter-off-fill icon" @click="dateFilterClear"/>
  22. </view>
  23. <view class="right">
  24. <text class="i-ri-sort-desc icon" :class="searchForm.ordType === 1?'cur':''" @click="changeOrdType(1)"/>
  25. <text class="i-ri-sort-asc icon" :class="searchForm.ordType === 2?'cur':''" @click="changeOrdType(2)"/>
  26. </view>
  27. </view>
  28. <view class="controls-filter" v-if="isControlsFilter">
  29. <view class="search-form-date">
  30. <picker class="search-date-input" mode="date" :value="searchForm.startTimeValue" @change="startDateChange">
  31. <view class="content">
  32. <view class="text">{{searchForm.startTimeValue??'点此选择开始日期'}}</view>
  33. <text class="i-ri-close-circle-line icon" v-if="searchForm.startTimeValue" @click.stop="startDateClear"/>
  34. </view>
  35. </picker>
  36. </view>
  37. <view class="search-form-date">
  38. <picker class="search-date-input" mode="date" :value="searchForm.endTimeValue" @change="endDateChange">
  39. <view class="content">
  40. <view class="text">{{searchForm.endTimeValue??'点此选择结束日期'}}</view>
  41. <text class="i-ri-close-circle-line icon" v-if="searchForm.endTimeValue" @click.stop="endDateClear"/>
  42. </view>
  43. </picker>
  44. </view>
  45. <button class="search-form-btn" type="primary" size="mini" @click="searchClick">查询</button>
  46. </view>
  47. </view>
  48. </view>
  49. <!--下拉刷新区域-->
  50. <z-paging ref="pageRef" :style="pagingStyle" v-model="taskList" @query="getTaskList">
  51. <uni-card v-for="item in taskList" padding="0" :class="item.check?'is-check':''" @click="taskItemClick(item)">
  52. <view class="py-3 text-30 text-black">{{item.taskName}}</view>
  53. <view slot="actions" class="card-actions no-border">
  54. <view class="card-actions-item">
  55. <view class="item-icon-check" v-if="showCheck">
  56. <uni-icons type="checkbox-filled" size="26" color="#ee5b20" v-if="item.check"/>
  57. <uni-icons type="checkbox" size="26" color="#9a9a9a" v-else/>
  58. </view>
  59. <text>{{item.startTime}}提交的申请</text>
  60. </view>
  61. <view class="card-actions-item" v-if="taskType === 1">
  62. <uni-icons type="calendar" size="18" color="#EE5B20"/>
  63. <text class="card-actions-item-text" style="color: #EE5B20;">审批</text>
  64. </view>
  65. <view class="card-actions-item" v-else>
  66. <text class="card-actions-item-text">{{item.taskStatusName}}</text>
  67. </view>
  68. </view>
  69. </uni-card>
  70. </z-paging>
  71. <!--底部操作区域 -->
  72. <view id="hc-bottom-bar" class="hc-bottom-bar"/>
  73. <view id="hc-bottom-btn-bar" class="hc-bottom-btn-bar">
  74. <view class="show-check-tabbars" v-if="showCheck">
  75. <view class="check-bar">
  76. <view class="check-box" @click="allCheckClick">
  77. <text class="text">全选</text>
  78. <uni-icons type="checkbox-filled" size="26" color="#ee5b20" v-if="isAllCheck"/>
  79. <uni-icons type="checkbox" size="26" color="#9a9a9a" v-else/>
  80. </view>
  81. <view class="text-box">
  82. <text class="text">共勾选</text>
  83. <text class="text" style="color: #ee5b20;">{{itemCheckIndex}}</text>
  84. <text class="text">条任务</text>
  85. </view>
  86. </view>
  87. <view class="btn-bar">
  88. <button class="check-btn" size="mini" @click="batchApproval">批量审批</button>
  89. <button class="check-btn" size="mini" @click="cancelTaskClick">批量废除</button>
  90. <button class="check-btn cancel" size="mini" @click="cancelCheckClick">取消操作</button>
  91. </view>
  92. </view>
  93. </view>
  94. </hc-sys>
  95. </template>
  96. <script setup>
  97. import {getCurrentInstance, ref} from "vue";
  98. import mainApi from '~api/tasks/data';
  99. import {onShow, onReady} from '@dcloudio/uni-app'
  100. import {errorToast, querySelect, successToast} from "@/utils/tools";
  101. import {arrToKey, getArrValue, getObjValue} from "js-fast-way";
  102. import {useAppStore} from "@/store";
  103. //初始变量
  104. const store = useAppStore()
  105. const projectId = ref(store.projectId);
  106. const contractId = ref(store.contractId);
  107. const instance = getCurrentInstance().proxy
  108. const isNodes = ref(false)
  109. const pageRef = ref(null)
  110. onReady(() => {
  111. setPagingStyle()
  112. isNodes.value = true
  113. })
  114. onShow(() => {
  115. projectId.value = store.projectId
  116. contractId.value = store.contractId
  117. if (isNodes.value) {
  118. searchClick()
  119. }
  120. })
  121. //内容区域
  122. const pagingStyle = ref({
  123. position: 'relative',
  124. width: '100%',
  125. bottom: 0,
  126. })
  127. const setPagingStyle = async () => {
  128. const {height: appHeight} = await querySelect(instance, 'app-sys')
  129. const {height: navHeight} = await querySelect(instance, 'hc-task-nav-bar')
  130. const {height: bottomHeight} = await querySelect(instance, 'hc-bottom-bar')
  131. const {height: bottomBtnHeight} = await querySelect(instance, 'hc-bottom-btn-bar')
  132. // #ifdef H5
  133. let content = navHeight + bottomHeight + bottomBtnHeight
  134. pagingStyle.value.height = (appHeight - content) + 'px'
  135. // #endif
  136. // #ifdef APP-PLUS
  137. const {screenHeight, safeArea} = uni.getWindowInfo()
  138. content = navHeight + (screenHeight - safeArea.bottom) + bottomBtnHeight
  139. pagingStyle.value.height = (screenHeight - content) + 'px'
  140. // #endif
  141. }
  142. //顶部类型切换
  143. const taskType = ref(1)
  144. const taskTypeData = [
  145. {key: 1, name: '我的审批'},
  146. {key: 2, name: '已办结的'},
  147. {key: 3, name: '我发起的'}
  148. ]
  149. const taskTypeChange = ({key}) => {
  150. taskType.value = key
  151. searchClick()
  152. }
  153. //批量操作
  154. const showCheck = ref(false)
  155. const moreBarClick = () => {
  156. showCheck.value = !showCheck.value
  157. setPagingStyle()
  158. }
  159. //日期选择器弹出框
  160. const isControlsFilter = ref(false)
  161. const dateFilterClick = () => {
  162. isControlsFilter.value = !isControlsFilter.value
  163. setPagingStyle()
  164. }
  165. const dateFilterClear = () => {
  166. isControlsFilter.value = false
  167. searchForm.value.startTimeValue = null
  168. searchForm.value.endTimeValue = null
  169. setPagingStyle()
  170. searchClick()
  171. }
  172. //开启日期选择完毕
  173. const startDateChange = (e) => {
  174. const val = e.detail.value, endTime = searchForm.value.endTimeValue
  175. if (endTime && val && val > endTime) {
  176. errorToast('开始日期不能大于结束日期', 2000)
  177. return false
  178. } else {
  179. searchForm.value.startTimeValue = val
  180. }
  181. }
  182. const startDateClear = () => {
  183. searchForm.value.startTimeValue = null
  184. }
  185. //结束日期选择完毕
  186. const endDateChange = (e) => {
  187. const val = e.detail.value, startTime = searchForm.value.startTimeValue
  188. if (startTime && val && val < startTime) {
  189. errorToast('结束日期不能小于开始日期', 2000)
  190. return false
  191. } else {
  192. searchForm.value.endTimeValue = val
  193. }
  194. }
  195. const endDateClear = () => {
  196. searchForm.value.endTimeValue = null
  197. }
  198. //条件搜索
  199. const searchClick = () => {
  200. pageRef.value?.reload()
  201. }
  202. //排序切换
  203. const changeOrdType = (type) => {
  204. searchForm.value.ordType = type
  205. searchClick()
  206. }
  207. //搜索表单
  208. const searchForm = ref({
  209. startTimeValue: null, endTimeValue: null, ordType: 1
  210. })
  211. //获取任务列表数据
  212. const taskList = ref([])
  213. const getTaskList = async (pageNo, pageSize) => {
  214. uni.showLoading({title: '获取数据中...', mask: true});
  215. const { data } = await mainApi.queryTaskPageList({
  216. ...searchForm.value,
  217. projectIdValue: projectId.value,
  218. currentContractId: contractId.value,
  219. contractIdValue: contractId.value,
  220. selectedType: taskType.value,
  221. batchValue: '',
  222. queryValue: '',
  223. statusValue: '',
  224. typeValue: '',
  225. current: pageNo,
  226. size: pageSize,
  227. })
  228. const res = getObjValue(data)
  229. uni.hideLoading();
  230. isNodes.value = true
  231. pageRef.value?.complete(getArrValue(res?.records));
  232. if (isAllCheck.value) {
  233. isAllCheck.value = itemCheckIndex.value === taskList.value.length
  234. }
  235. }
  236. //任务被点击
  237. const itemCheckIndex = ref(0)
  238. const taskItemClick = (item) => {
  239. if (showCheck.value) {
  240. const check = !item.check, list = taskList.value
  241. if (check) {
  242. itemCheckIndex.value++
  243. } else {
  244. itemCheckIndex.value--
  245. }
  246. item.check = check
  247. isAllCheck.value = list.length === itemCheckIndex.value
  248. } else {
  249. toTaskDetail([item])
  250. }
  251. }
  252. //全选
  253. const isAllCheck = ref(false)
  254. const allCheckClick = () => {
  255. uni.showLoading({title: '处理中...', mask: true});
  256. const list = taskList.value, isCheck = !isAllCheck.value
  257. for (let i = 0; i < list.length; i++) {
  258. list[i].check = isCheck;
  259. }
  260. itemCheckIndex.value = isCheck ? list.length : 0
  261. isAllCheck.value = isCheck
  262. uni.hideLoading();
  263. }
  264. //取消操作
  265. const cancelCheckClick = () => {
  266. const list = taskList.value
  267. for (let i = 0; i < list.length; i++) {
  268. list[i].check = false;
  269. }
  270. itemCheckIndex.value = 0
  271. showCheck.value = false
  272. setPagingStyle()
  273. }
  274. //批量审批
  275. const batchApproval = () => {
  276. let rows = taskList.value.filter((item) => {
  277. return item.check
  278. })
  279. if (rows.length <= 0) {
  280. errorToast('请选择需要审批的任务')
  281. return false
  282. }
  283. //路由跳转
  284. toTaskDetail(rows)
  285. }
  286. //跳转任务详情
  287. const toTaskDetail = (rows) => {
  288. const node = encodeURIComponent(JSON.stringify({
  289. rows: rows,
  290. isTask: taskType.value === 1
  291. }))
  292. uni.navigateTo({
  293. url: '/pages/task/detail?node=' + node,
  294. events: {
  295. finish: () => {
  296. searchClick();
  297. }
  298. }
  299. });
  300. }
  301. //批量废除
  302. const popupRef = ref(null)
  303. const argument = ref('')
  304. const cancelTaskList = ref([])
  305. const cancelTaskClick = () => {
  306. cancelTaskList.value = []
  307. let rows = taskList.value.filter((item) => {
  308. return item.check
  309. })
  310. if (rows.length <= 0) {
  311. errorToast('请选择需要废除的任务')
  312. return false
  313. }
  314. cancelTaskList.value = rows
  315. argument.value = ''
  316. popupRef.value?.open()
  317. }
  318. //确认废除
  319. const confirmRepeal = () => {
  320. if (!argument.value) {
  321. errorToast('请先填写废除理由')
  322. return false
  323. }
  324. batchCompleteApprovalTaskApi(cancelTaskList.value)
  325. }
  326. //批量废除接口
  327. const batchCompleteApprovalTaskApi = async (rows) => {
  328. uni.showLoading({title: '批量废除中...', mask: true});
  329. let taskIds = arrToKey(rows, 'taskId', ',')
  330. let approvalType = arrToKey(rows, 'approvalType', ',')
  331. let formDataId = arrToKey(rows, 'formDataId', ',')
  332. let parallelProcessInstanceIds = arrToKey(rows, 'parallelProcessInstanceId', ',')
  333. const {error, code, msg} = await mainApi.batchCompleteApprovalTask({
  334. flag: 'NO',
  335. comment: argument.value,
  336. taskIds: taskIds,
  337. approvalType: approvalType,
  338. formDataId: formDataId,
  339. parallelProcessInstanceIds: parallelProcessInstanceIds,
  340. })
  341. uni.hideLoading();
  342. if (!error && code === 200) {
  343. successToast('废除成功')
  344. cancelClick()
  345. searchClick()
  346. } else {
  347. errorToast(`废除失败:${msg}`)
  348. }
  349. }
  350. //取消废除
  351. const cancelClick = () => {
  352. popupRef.value?.close()
  353. argument.value = ''
  354. }
  355. </script>
  356. <style lang="scss" scoped>
  357. page {
  358. background: #EFEFF4;
  359. height: 100%;
  360. }
  361. </style>
  362. <style lang="scss">
  363. @import "@/style/task/index.scss";
  364. </style>