approvedItem.vue 12 KB

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