approvedItem.vue 9.6 KB

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