approvedItem.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. <template>
  2. <!-- 左侧列表 -->
  3. <div class="flow-content">
  4. <!-- 搜索条件 -->
  5. <div class="search-box">
  6. <div class="search-segment" style="flex: 1 1 0%">
  7. <el-input v-model="processName" placeholder="流程名称">
  8. <template #append>
  9. <el-button icon="Search" @click.stop="initList" />
  10. </template>
  11. </el-input>
  12. </div>
  13. <div class="search-segment">
  14. <el-tooltip effect="dark" content="重置" placement="top">
  15. <el-button icon="Refresh" @click.stop="resetSearch('external')" />
  16. </el-tooltip>
  17. </div>
  18. <div class="search-segment">
  19. <EditPopover :visible="searchMoreVisible" placement="right" :width="320" :show-footer="false">
  20. <template #reference>
  21. <el-button icon="Filter" @click="searchMoreVisible = true" />
  22. </template>
  23. <div class="title">高级筛选</div>
  24. <el-scrollbar max-height="400px">
  25. <!-- 创建人 -->
  26. <el-input v-model="createBy" style="width: 240px; margin-bottom: 10px" placeholder="请输入创建人名称" />
  27. <!-- 流程状态 -->
  28. <el-select v-model="instanceState" placeholder="流程状态" style="margin-bottom: 10px; width: 240px">
  29. <el-option v-for="item in instanceStateOps" :key="item.value" :label="item.label" :value="item.value" />
  30. </el-select>
  31. <el-date-picker
  32. v-model="beginTime"
  33. style="width: 240px; margin-bottom: 10px"
  34. type="date"
  35. format="YYYY-MM-DD"
  36. value-format="YYYY-MM-DD"
  37. placeholder="开始时间"
  38. />
  39. <el-date-picker
  40. v-model="endTime"
  41. style="width: 240px; margin-bottom: 10px"
  42. type="date"
  43. format="YYYY-MM-DD"
  44. value-format="YYYY-MM-DD"
  45. placeholder="结束时间"
  46. />
  47. </el-scrollbar>
  48. <div class="footer">
  49. <el-button plain @click="searchReset">重置</el-button>
  50. <el-button type="primary" plain @click="searchSubmit">检索</el-button>
  51. </div>
  52. </EditPopover>
  53. </div>
  54. </div>
  55. <!-- 内容值 -->
  56. <div v-infinite-scroll="loadList" :infinite-scroll-disabled="disabledInfinite" class="flow-list-box">
  57. <div
  58. v-for="i in satelliteList"
  59. :key="i.instanceId"
  60. class="item-box"
  61. :class="[i.instanceId === taskProcessInfo.currentTaskRow.instanceId ? 'item-box-choosed' : '']"
  62. @click="getTaskDetail(i)"
  63. >
  64. <div class="flow-card-box flow-card-box-hoverable">
  65. <!--头部-->
  66. <div class="header">
  67. <el-text tag="b">{{ i.processName }}</el-text>
  68. <div>
  69. <el-text v-if="['pendingApproval', 'pendingClaim'].indexOf(props.currentTaskType) !== -1" style="margin-right: 15px">{{
  70. i.performType == 2 ? '会签' : i.performType == 3 ? '或签' : i.performType == 4 ? '票签' : ''
  71. }}</el-text>
  72. <el-tag v-if="currentTaskType === 'pendingApproval'">待审批</el-tag>
  73. <template v-else>
  74. <el-tag v-if="i.instanceState === 0">审批中</el-tag>
  75. <el-tag v-if="i.instanceState === 1" type="success">审批通过</el-tag>
  76. <el-tag v-if="i.instanceState === 2" type="danger">审批拒绝</el-tag>
  77. <el-tag v-if="i.instanceState === 3" type="warning">撤销审批</el-tag>
  78. <el-tag v-if="i.instanceState === 4" type="danger">超时结束</el-tag>
  79. <el-tag v-if="i.instanceState === 5" type="danger">强制终止</el-tag>
  80. </template>
  81. </div>
  82. </div>
  83. <!--操作类容-->
  84. <div class="summary-list">
  85. <template v-if="['myReceived', 'myApplication', 'approved'].indexOf(currentTaskType) !== -1">
  86. <div v-if="i.endTime" class="summary-item">
  87. <div class="label">结束时间:</div>
  88. <div class="value">{{ i.endTime }}</div>
  89. </div>
  90. <div v-if="i.duration" class="summary-item">
  91. <div class="label">处理耗时:</div>
  92. <div class="value">{{ format_milliseconds(i.duration) }}</div>
  93. </div>
  94. </template>
  95. <div v-if="i.currentNode !== 'complete'" class="summary-item">
  96. <div class="label">当前所在节点:</div>
  97. <div class="value">{{ i.currentNode }}</div>
  98. </div>
  99. </div>
  100. <!--底部-->
  101. <div class="footer">
  102. <!-- 头像 -->
  103. <div class="initiator">
  104. <FlowNodeAvatar :name="i.createBy" />
  105. </div>
  106. <!-- 时间 -->
  107. <div class="begin-time">提交于 {{ i.createTime }}</div>
  108. </div>
  109. </div>
  110. </div>
  111. <p v-if="false">加载中...</p>
  112. <p v-if="noMore">没有更多了</p>
  113. </div>
  114. </div>
  115. </template>
  116. <script setup>
  117. import useTaskProcessStore from '@/store/modules/taskProcess'
  118. import FlowNodeAvatar from '@/components/Flow/FlowNodeAvatar.vue'
  119. // import { Search, Filter, Refresh } from '@element-plus/icons-vue'
  120. import EditPopover from '@/components/EditPopover.vue'
  121. import { computed, onMounted, reactive, ref, watch } from 'vue'
  122. import { format_milliseconds } from '@/utils'
  123. import {
  124. processTaskPagePendingApprovalApi,
  125. processTaskPageMyApplicationApi,
  126. processTaskPagePendingClaimApi,
  127. processTaskPageApprovedApi,
  128. processTaskPageMyReceivedApi
  129. } from '@/api/flow/processTask'
  130. const props = defineProps({
  131. /**
  132. * pendingApproval 待审批
  133. * myApplication 我的申请
  134. * myReceived 我收到的
  135. * pendingClaim 认领任务
  136. * approved 已审批
  137. */
  138. currentTaskType: {
  139. type: String,
  140. default: ''
  141. }
  142. })
  143. /***
  144. * 待审批:发起人 流程分组 最小提交时间 最大提交时间
  145. * 我的申请:流程分组 流程状态 最小提交时间 最大提交时间 最小完成时间 最大完成时间
  146. * 我收到的:发起人 流程分组 流程状态 最小提交时间 最大提交时间 最小完成时间 最大完成时间
  147. * 已审批:发起人 流程分组 流程状态 最小提交时间 最大提交时间 最小完成时间 最大完成时间
  148. */
  149. const instanceStateOps = [
  150. {
  151. value: 0,
  152. label: '审批中'
  153. },
  154. {
  155. value: 1,
  156. label: '审批通过'
  157. },
  158. {
  159. value: 2,
  160. label: '审批拒绝'
  161. },
  162. {
  163. value: 3,
  164. label: '撤销审批'
  165. },
  166. {
  167. value: 4,
  168. label: '超时结束'
  169. },
  170. {
  171. value: 5,
  172. label: '强制终止'
  173. }
  174. ]
  175. const createId = ref(null) // 发起人
  176. const createBy = ref(null) // 创建人
  177. const instanceState = ref(null) // 流程状态
  178. const beginTime = ref(null) // 开始时间
  179. const endTime = ref(null) // 结束时间
  180. const searchMoreVisible = ref(false)
  181. // 重置
  182. const searchReset = () => {
  183. createBy.value = undefined
  184. instanceState.value = undefined
  185. beginTime.value = undefined
  186. endTime.value = undefined
  187. // searchMoreVisible.value = false
  188. }
  189. // 搜索条件更多
  190. const searchSubmit = () => {
  191. searchMoreVisible.value = false
  192. getPagedSatellites('clear')
  193. }
  194. // store值
  195. const taskProcessInfo = useTaskProcessStore()
  196. const processName = ref('') // 流程名称
  197. // 下拉滚动属性值 start
  198. const loading = ref(false) // loading
  199. const totalNumber = ref(0) // 总条数
  200. const totalPages = ref(0) // 总页数
  201. // 当前页码数和每页条数
  202. const condition = reactive({
  203. page: 1,
  204. pageSize: 10
  205. })
  206. const satelliteList = ref([]) // 列表数据
  207. // 下拉滚动属性值 end
  208. // 初始化
  209. const initList = () => {
  210. loading.value = false
  211. condition.page = 1
  212. satelliteList.value = []
  213. totalNumber.value = 0
  214. totalPages.value = 0
  215. taskProcessInfo.refresh = false
  216. loadList()
  217. }
  218. // 分页获取数据
  219. const loadList = () => {
  220. if (loading.value) return false
  221. loading.value = true
  222. getPagedSatellites()
  223. }
  224. // 获取分页数据
  225. const getPagedSatellites = async from => {
  226. try {
  227. let responseData = {}
  228. const { currentTaskType } = props
  229. const params = {
  230. ...condition,
  231. data: {
  232. processName: processName.value,
  233. createBy: createBy.value,
  234. instanceState: instanceState.value,
  235. beginTime: beginTime.value,
  236. endTime: endTime.value
  237. }
  238. }
  239. if (currentTaskType === 'pendingApproval') {
  240. responseData = await processTaskPagePendingApprovalApi(params)
  241. } else if (currentTaskType === 'myApplication') {
  242. responseData = await processTaskPageMyApplicationApi(params)
  243. } else if (currentTaskType === 'myReceived') {
  244. responseData = await processTaskPageMyReceivedApi(params)
  245. } else if (currentTaskType === 'pendingClaim') {
  246. responseData = await processTaskPagePendingClaimApi(params)
  247. } else if (currentTaskType === 'approved') {
  248. responseData = await processTaskPageApprovedApi(params)
  249. }
  250. const { records, total, pages } = responseData
  251. records.forEach(item => {
  252. // todo .. 这里将每个模块的不同值进行调整
  253. // 我收到、我申请 已审批 [结束时间 / 处理耗时 / 当前所在节点]
  254. // 待审批、认领 [会签/货签/票钱、当前所在节点]
  255. const flag1 = ['myReceived', 'myApplication', 'approved'].indexOf(props.currentTaskType) !== -1
  256. const flag2 = ['pendingApproval', 'pendingClaim'].indexOf(props.currentTaskType) !== -1
  257. item.currentNode = flag2 ? item.taskName : item.currentNode // 当前节点
  258. item.createTime = flag2 ? item.launchTime : item.createTime // 创建时间
  259. item.createBy = flag2 ? item.launchBy : item.createBy // 创建人
  260. satelliteList.value.push(item)
  261. })
  262. totalNumber.value = total
  263. totalPages.value = pages
  264. // if (from === 'clear') {
  265. // searchReset()
  266. // }
  267. loading.value = false
  268. if (condition.page > totalPages.value) {
  269. console.log('没有更多数据了')
  270. return
  271. }
  272. condition.page++
  273. } catch (e) {
  274. console.log(e)
  275. }
  276. }
  277. // 点击当前实例的具体
  278. const getTaskDetail = item => {
  279. taskProcessInfo.setCurrentTaskRow(item)
  280. }
  281. /**
  282. * 重置搜索
  283. * @param type external:重置输入框
  284. * clear: 重置内部的值
  285. */
  286. const resetSearch = type => {
  287. if (type === 'external') {
  288. processName.value = ''
  289. initList()
  290. }
  291. }
  292. onMounted(() => {
  293. taskProcessInfo.setCurrentTaskRow({})
  294. })
  295. /**
  296. * 监听同级子组件通知
  297. * 1、监听refresh的值变化,进行刷新
  298. */
  299. watch(
  300. () => taskProcessInfo.refresh,
  301. (nValue, oValue) => {
  302. if (nValue) {
  303. initList()
  304. }
  305. },
  306. { immediate: true }
  307. )
  308. const noMore = computed(() => satelliteList.value.length > totalNumber.value)
  309. const disabledInfinite = computed(() => noMore.value)
  310. </script>
  311. <style scoped lang="scss">
  312. .flow-content {
  313. width: 330px;
  314. min-width: 330px;
  315. height: 100%;
  316. overflow: hidden;
  317. background: var(--el-bg-color);
  318. border-radius: 6px;
  319. // 搜搜条件
  320. .search-box {
  321. display: flex;
  322. align-items: center;
  323. height: 56px;
  324. padding: 0 12px;
  325. .search-segment + .search-segment {
  326. margin-left: 4px;
  327. }
  328. //> .el-button {
  329. // padding: 0;
  330. // width: 32px;
  331. // background-color: var(--el-fill-color-light);
  332. //}
  333. }
  334. .flow-list-box {
  335. background-color: #fff;
  336. padding: 0 12px;
  337. height: calc(100vh - 192px);
  338. overflow: hidden auto;
  339. scroll-snap-type: y mandatory;
  340. will-change: scroll-position;
  341. .item-box {
  342. margin-bottom: 12px;
  343. &.item-box-choosed {
  344. .flow-card-box {
  345. border-color: var(--el-color-primary);
  346. }
  347. }
  348. }
  349. .flow-card-box {
  350. -webkit-user-select: none;
  351. user-select: none;
  352. border-radius: 6px;
  353. overflow: hidden;
  354. border: 1px solid #e9ebef;
  355. padding: 10px 12px;
  356. cursor: pointer;
  357. transition: box-shadow 0.2s cubic-bezier(0, 0, 1, 1);
  358. &.flow-card-box-hoverable {
  359. &:hover {
  360. box-shadow: 4px 4px 12px rgb(229, 230, 235);
  361. }
  362. }
  363. // 头部
  364. .header {
  365. display: flex;
  366. align-items: center;
  367. justify-content: space-between;
  368. }
  369. // 操作类容
  370. .summary-list {
  371. margin-top: 10px;
  372. .summary-item {
  373. display: flex;
  374. min-height: 20px;
  375. .label {
  376. color: #9ba5b3;
  377. overflow: hidden;
  378. white-space: nowrap;
  379. flex-shrink: 0;
  380. }
  381. .value {
  382. color: #232730;
  383. overflow: hidden;
  384. text-overflow: ellipsis;
  385. white-space: nowrap;
  386. }
  387. }
  388. }
  389. // 底部
  390. .footer {
  391. margin-top: 10px;
  392. display: flex;
  393. align-items: center;
  394. justify-content: space-between;
  395. font-size: 13px;
  396. .begin-time {
  397. color: var(--el-text-color-regular);
  398. }
  399. }
  400. }
  401. }
  402. }
  403. </style>