index.vue 7.3 KB

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