approvedItem.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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="input3" placeholder="流程名称">
  8. <template #append>
  9. <el-button :icon="Search" />
  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" />
  16. </el-tooltip>
  17. </div>
  18. <div class="search-segment">
  19. <el-button :icon="Filter" />
  20. </div>
  21. </div>
  22. <!-- 内容值 -->
  23. <div v-infinite-scroll="load" :infinite-scroll-disabled="disabledInfinite" class="flow-list-box">
  24. <div
  25. v-for="i in satelliteList"
  26. :key="i.taskId"
  27. class="item-box"
  28. :class="[i.taskId === taskProcessInfo.currentTaskRow.taskId ? 'item-box-choosed' : '']"
  29. @click="getTaskDetail(i)"
  30. >
  31. <div class="flow-card-box flow-card-box-hoverable">
  32. <!--头部-->
  33. <div class="header">
  34. <el-text tag="b">{{ i.processName }}</el-text>
  35. <el-tag type="primary">待审核</el-tag>
  36. </div>
  37. <!--操作类容-->
  38. <div class="summary-list"></div>
  39. <!--底部-->
  40. <div class="footer">
  41. <!-- 头像 -->
  42. <div class="initiator">
  43. <FlowNodeAvatar id="1" />
  44. </div>
  45. <!-- 时间 -->
  46. <div class="begin-time">提交于 {{ i.createTime }}</div>
  47. </div>
  48. </div>
  49. </div>
  50. <p v-if="loading">加载中...</p>
  51. <p v-if="noMore">没有更多了</p>
  52. </div>
  53. </div>
  54. </template>
  55. <script setup>
  56. import useTaskProcessStore from '@/store/modules/taskProcess'
  57. import FlowNodeAvatar from '@/components/Flow/FlowNodeAvatar.vue'
  58. import { Search, Filter, Refresh } from '@element-plus/icons-vue'
  59. import { computed, onMounted, reactive, ref, watch } from 'vue'
  60. import { processTaskPagePendingApprovalApi } from '@/api/flow/processTask'
  61. // store值
  62. const taskProcessInfo = useTaskProcessStore()
  63. const input3 = ref('')
  64. // 下拉滚动属性值 start
  65. const loading = ref(false) // loading
  66. const totalNumber = ref(0) // 总条数
  67. const totalPages = ref(0) // 总页数
  68. // 当前页码数和每页条数
  69. const condition = reactive({
  70. page: 1,
  71. pageSize: 10
  72. })
  73. const satelliteList = ref([]) // 列表数据
  74. // 下拉滚动属性值 end
  75. // 初始化
  76. const init = () => {
  77. loading.value = false
  78. condition.page = 1
  79. satelliteList.value = []
  80. totalNumber.value = 0
  81. totalPages.value = 0
  82. taskProcessInfo.refresh = false
  83. taskProcessInfo.setCurrentTaskRow({})
  84. }
  85. // 分页获取数据
  86. const load = () => {
  87. loading.value = true
  88. getPagedSatellites()
  89. }
  90. // 获取分页数据
  91. const getPagedSatellites = async () => {
  92. try {
  93. const { records, total, pages } = await processTaskPagePendingApprovalApi(condition)
  94. records.forEach(item => {
  95. satelliteList.value.push(item)
  96. })
  97. totalNumber.value = total
  98. totalPages.value = pages
  99. loading.value = false
  100. if (condition.page > totalPages.value) {
  101. console.log('没有更多数据了')
  102. return
  103. }
  104. condition.page++
  105. } catch (e) {
  106. console.log(e)
  107. }
  108. }
  109. // 点击当前实例的具体
  110. const getTaskDetail = item => {
  111. taskProcessInfo.setCurrentTaskRow(item)
  112. }
  113. onMounted(() => {
  114. init()
  115. })
  116. /**
  117. * 监听同级子组件通知
  118. * 1、监听refresh的值变化,进行刷新
  119. */
  120. watch(
  121. () => taskProcessInfo.refresh,
  122. (nValue, oValue) => {
  123. if (nValue) {
  124. init()
  125. }
  126. },
  127. { immediate: true }
  128. )
  129. const noMore = computed(() => satelliteList.value.length > totalNumber.value)
  130. const disabledInfinite = computed(() => noMore.value)
  131. </script>
  132. <style scoped lang="scss">
  133. .flow-content {
  134. width: 330px;
  135. min-width: 330px;
  136. height: 100%;
  137. overflow: hidden;
  138. background: var(--el-bg-color);
  139. border-radius: 6px;
  140. // 搜搜条件
  141. .search-box {
  142. display: flex;
  143. align-items: center;
  144. height: 56px;
  145. padding: 0 12px;
  146. .search-segment + .search-segment {
  147. margin-left: 4px;
  148. }
  149. //> .el-button {
  150. // padding: 0;
  151. // width: 32px;
  152. // background-color: var(--el-fill-color-light);
  153. //}
  154. }
  155. .flow-list-box {
  156. background-color: #fff;
  157. padding: 0 12px;
  158. height: calc(100vh - 161px);
  159. overflow: hidden auto;
  160. scroll-snap-type: y mandatory;
  161. will-change: scroll-position;
  162. .item-box {
  163. margin-bottom: 12px;
  164. &.item-box-choosed {
  165. .flow-card-box {
  166. border-color: var(--el-color-primary);
  167. }
  168. }
  169. }
  170. .flow-card-box {
  171. -webkit-user-select: none;
  172. user-select: none;
  173. border-radius: 6px;
  174. overflow: hidden;
  175. border: 1px solid #e9ebef;
  176. padding: 10px 12px;
  177. cursor: pointer;
  178. transition: box-shadow 0.2s cubic-bezier(0, 0, 1, 1);
  179. &.flow-card-box-hoverable {
  180. &:hover {
  181. box-shadow: 4px 4px 12px rgb(229, 230, 235);
  182. }
  183. }
  184. // 头部
  185. .header {
  186. display: flex;
  187. align-items: center;
  188. justify-content: space-between;
  189. }
  190. // 操作类容
  191. .summary-list {
  192. margin-top: 10px;
  193. }
  194. // 底部
  195. .footer {
  196. margin-top: 10px;
  197. display: flex;
  198. align-items: center;
  199. justify-content: space-between;
  200. font-size: 13px;
  201. .begin-time {
  202. color: var(--el-text-color-regular);
  203. }
  204. }
  205. }
  206. }
  207. }
  208. </style>