approvedItem.vue 13 KB

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