index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <z-paging class="page" ref="paging" v-model="dataList" @query="loadData">
  3. <template #top>
  4. <uni-row style="padding-top: 8px">
  5. <uni-badge v-for="(item, index) of tabs" :key="index" absolute="rightTop" :offset="[0, 4]"
  6. :text="index === 2 ? unreadMessageCount : 0" style="margin-right: 20px">
  7. <text :class="index === currentTab ? 'tab-selected' : 'tab-normal'" @click="onTabChanged(index)">
  8. {{ item }}
  9. </text>
  10. </uni-badge>
  11. </uni-row>
  12. </template>
  13. <view class="list">
  14. <template v-if="currentTab === 0">
  15. <view v-for="(item, index) of dataList">
  16. <view class="todo-item flex-row align-center" @click="navigateToDetail(item)">
  17. <view style="flex: 1">
  18. <view class="flex-row align-center msg-title justify-between">
  19. <view class="flex-row align-center">
  20. <view class="dot" />
  21. <view>{{ item.processInstance?.name }}</view>
  22. </view>
  23. <view class="msg-content">
  24. {{ item.createTime ? dayjs(item.createTime).format('YYYY-MM-DD HH:mm') : '' }}
  25. </view>
  26. </view>
  27. <view class="msg-content" style="margin-top: 5px">{{ $t('message.id') + ' ' + item.id }}
  28. </view>
  29. </view>
  30. </view>
  31. <view v-if="index !== dataList.length - 1" class="todo-divider" />
  32. </view>
  33. </template>
  34. <template v-else-if="currentTab === 1">
  35. <view v-for="(item, index) of dataList">
  36. <view class="todo-item flex-row align-center" @click="navigateToDetail(item)">
  37. <view style="flex: 1">
  38. <view class="flex-row align-center msg-title justify-between">
  39. <view style="margin-left: -8px">【{{ getStatusName(item.status) }}】</view>
  40. <view class="msg-content">
  41. {{ dayjs(item.startTime).format('YYYY-MM-DD HH:mm') }}
  42. </view>
  43. </view>
  44. <view class="msg-content" style="margin-top: 5px">
  45. {{ item.id + getApprovalUser(item) + getStatusName(item.status) }}
  46. </view>
  47. </view>
  48. </view>
  49. <view v-if="index !== dataList.length - 1" class="todo-divider" />
  50. </view>
  51. </template>
  52. <template v-else-if="currentTab === 2">
  53. <view v-for="(item, index) of dataList" class="flex-col" @click="navigate(item)">
  54. <view class="sys-msg-item flex-row" style="justify-content: center">
  55. <image src="~@/static/message/system-message-logo.png"
  56. style="width: 20px; height: 20px; margin-top: 5px" />
  57. <div class="flex-col" style="flex: 1; margin-left: 10px">
  58. <text class="msg-title">系统消息</text>
  59. <text class="msg-content">{{ item.templateContent }}</text>
  60. </div>
  61. <text class="msg-content"
  62. style="margin-top: 10px">{{ item.createTime ? dayjs(item.createTime).format('YYYY-MM-DD HH:mm') : '' }}</text>
  63. </view>
  64. <view v-if="index !== dataList.length - 1" class="divider" />
  65. </view>
  66. </template>
  67. </view>
  68. </z-paging>
  69. </template>
  70. <script setup>
  71. import {
  72. getCurrentInstance, nextTick,
  73. onMounted,
  74. ref
  75. } from "vue"
  76. import {
  77. getMessageList, markReadMessage
  78. } from "@/api/message"
  79. import {
  80. getTodoList,
  81. getApprovalList
  82. } from '@/api/task'
  83. import dayjs from "dayjs";
  84. import {
  85. useDataDictStore
  86. } from "@/store/modules/dataDict";
  87. import { messageNavigate } from "@/utils/navigate";
  88. const { appContext } = getCurrentInstance();
  89. const t = appContext.config.globalProperties.$t;
  90. const currentTab = ref(0)
  91. const tabs = [t('message.tab1'), t('message.tab2'), t('message.tab3')]
  92. const onTabChanged = (index) => {
  93. currentTab.value = index
  94. paging.value.reload()
  95. }
  96. const paging = ref(null)
  97. const dataList = ref([])
  98. const unreadMessageCount = ref(0)
  99. const loadData = async (pageNo, pageSize) => {
  100. try {
  101. const params = {
  102. pageNo,
  103. pageSize
  104. }
  105. let response;
  106. if (currentTab.value === 0) {
  107. response = await getTodoList(params)
  108. } else if (currentTab.value === 1) {
  109. response = await getApprovalList(params)
  110. } else {
  111. response = await getMessageList(params)
  112. }
  113. unreadMessageCount.value = response.data.length
  114. paging.value.complete(response.data.list)
  115. } catch (e) {
  116. console.log(e)
  117. paging.value.complete(false)
  118. }
  119. }
  120. const navigateToDetail = (item) => {
  121. if (currentTab.value === 0) {
  122. uni.navigateTo({
  123. url: `/pages/message/detail/index?id=${item.id}&processInstanceId=${item.processInstanceId}`
  124. })
  125. } else {
  126. uni.navigateTo({
  127. url: `/pages/message/detail/index?processInstanceId=${item.id}`
  128. })
  129. }
  130. }
  131. // 根据 businessType 和 businessId 进行跳转
  132. const navigate = (item) => {
  133. markReadMessage(item.id)
  134. messageNavigate({
  135. ...item.templateParams,
  136. id: item.templateParams.businessId,
  137. type: item.templateParams.businessType,
  138. })
  139. }
  140. /**
  141. * 获取当前审批人
  142. * @param item
  143. * @returns {string}
  144. */
  145. const getApprovalUser = (item) => {
  146. if (item && item.tasks && item.tasks.length > 0 && item.tasks[0].assigneeUser) {
  147. return item.tasks[0].assigneeUser.nickname
  148. } else {
  149. return ''
  150. }
  151. }
  152. const statusList = ref([]) // 审批状态列表
  153. const getStatusName = (status) => {
  154. for (const item of statusList.value) {
  155. if (Number.parseInt(item.value) === Number.parseInt(status)) {
  156. return item.label
  157. }
  158. }
  159. }
  160. const { getDataDictList } = useDataDictStore()
  161. onMounted(() => {
  162. statusList.value = getDataDictList('bpm_process_instance_status')
  163. uni.$once('update', () => nextTick(() => paging.value.reload()))
  164. })
  165. </script>
  166. <style scoped lang="scss">
  167. .page {
  168. box-sizing: border-box;
  169. padding: 10px !important;
  170. }
  171. .root {
  172. width: 100%;
  173. height: 100%;
  174. position: relative;
  175. box-sizing: border-box;
  176. overflow: hidden;
  177. }
  178. .tab-selected {
  179. color: #333333;
  180. font-size: 18px;
  181. font-weight: bold;
  182. }
  183. .tab-normal {
  184. color: #666666;
  185. font-size: 14px;
  186. }
  187. .list {
  188. margin-top: 10px;
  189. background-color: white;
  190. border-radius: 6px;
  191. }
  192. .msg-title {
  193. color: #333333;
  194. font-size: 14px;
  195. font-weight: 500;
  196. }
  197. .msg-content {
  198. color: #999999;
  199. font-size: 12px;
  200. }
  201. .sys-msg-item {
  202. padding: 19px 20px 14px 15px;
  203. }
  204. .divider {
  205. margin: 0 19px 0 45px;
  206. height: 0.5px;
  207. background-color: #CACCCF;
  208. }
  209. .dot {
  210. width: 3px;
  211. height: 3px;
  212. border-radius: 2px;
  213. background-color: #FF3B36;
  214. margin-right: 6px;
  215. }
  216. .todo-item {
  217. padding: 20px;
  218. width: 100%;
  219. height: auto;
  220. box-sizing: border-box;
  221. }
  222. .todo-divider {
  223. margin: 0 20px;
  224. border-bottom: 0.5px solid #CACCCF;
  225. }
  226. </style>