index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <template>
  2. <view class="index_container">
  3. <uni-nav-bar dark :border="false" :fixed="true" title="宇光同行">
  4. </uni-nav-bar>
  5. <uni-collapse>
  6. <uni-collapse-item title-border="show" :border="true" :show-animation="true" :open="false">
  7. <template v-slot:title>
  8. <uni-section title="待办" type="line" titleFontSize="1.3rem">
  9. <template v-slot:right>
  10. <uni-badge :text="unProcessNum" style="margin-left: -10px;" v-if="unProcessNum>0"></uni-badge>
  11. </template>
  12. </uni-section>
  13. </template>
  14. <view class="process_container">
  15. <view class="process_list">
  16. <process-list :list="processes" @clickSegment="getProcessData" @clickItem="handleToProcessDetail" @scrollToBottom="getProcessPage" :current="0" :pSize="5" :pageNo="1" contentHeight="69.5vh"></process-list>
  17. </view>
  18. </view>
  19. </uni-collapse-item>
  20. </uni-collapse>
  21. <!-- 公告列表 -->
  22. <message-list :list="notices" @clickSegment="getNoticeData" @clickItem="handleToNoticeDetail"
  23. @scrollToBottom="getNoticePage" :pSize="5" :pageNo="1" :anime="true" :open="false"
  24. title="公告"></message-list>
  25. <!-- 消息列表 -->
  26. <message-list :unReadNum="unReadNum" :list="messages" @clickSegment="getMessageData" @clickItem="handleToMessageDetail"
  27. @scrollToBottom="getMessagePage" :defaultCurrent="1" :pSize="5" :pageNo="1" :anime="true" :open="true"
  28. :segments="{ '全部': '', '未读': '0', '已读': '1' }" title="消息"></message-list>
  29. <!-- AI咨询按钮 -->
  30. <view class="fab_button">
  31. <uni-fab :pattern="{ icon: 'headphones' }" :popMenu="false" horizontal="right"
  32. @fabClick="clickFabButton"></uni-fab>
  33. </view>
  34. </view>
  35. </template>
  36. <script setup lang="ts">
  37. import { onMounted, ref } from 'vue';
  38. import { onLoad } from '@dcloudio/uni-app'
  39. import { getMessageList, getNoticeList ,getUnReadMessageNum} from '@/api/message.js';
  40. import { getUserProcess,getUnProcessNum } from '@/api/process';
  41. import $tab from '@/plugins/tab.js';
  42. import $modal from '@/plugins/modal.js';
  43. import processList from '@/components/ygoa/processList.vue'
  44. import messageList from '@/components/ygoa/messageList.vue'
  45. import { useUserStore } from '@/store/user.js'
  46. const userStore = useUserStore()
  47. onLoad((options) => {
  48. // 是否跳转打卡页
  49. if (options.to == 'clockIn') toClockIn()
  50. })
  51. onMounted(()=>{
  52. showTarBarBadge();
  53. })
  54. // 跳转打卡页
  55. function toClockIn() {
  56. // 确认是否跳转打卡页
  57. $modal.confirm('当前未打卡,是否前往打卡').then(() => {
  58. $tab.navigateTo('/pages/mine/clockIn/clockIn')
  59. })
  60. }
  61. // 待办列表
  62. const processes = ref([])
  63. // 获取待办消息列表数据
  64. function getProcessData({ pSize, pageNo }, callback) {
  65. const params = {
  66. staffId: userStore.user.useId,
  67. page: pageNo,
  68. pageNum: pSize,
  69. modelId: "",
  70. control: 1
  71. }
  72. getUserProcess(params).then(({ returnParams }) => {
  73. if (returnParams == undefined) {
  74. processes.value = []
  75. return
  76. }
  77. processes.value = returnParams.list
  78. callback(returnParams.list, returnParams.total, pageNo)
  79. });
  80. }
  81. // 分页获取待办消息列表数据
  82. function getProcessPage({ pSize, pageNo }, callback) {
  83. const params = {
  84. staffId: userStore.user.useId,
  85. page: pageNo,
  86. pageNum: pSize,
  87. modelId: "",
  88. control: 1
  89. }
  90. getUserProcess(params).then(({ returnParams }) => {
  91. processes.value.push(...returnParams.list)
  92. callback(returnParams.list, returnParams.total, pageNo)
  93. });
  94. }
  95. // 点击待办消息列表项
  96. function handleToProcessDetail({ insId, insName }) {
  97. $tab.navigateTo('/pages/process/detail/index?insId=' + insId + '&insName=' + insName)
  98. }
  99. // 公告列表
  100. const notices = ref([])
  101. // 获取公告列表数据
  102. function getNoticeData({ pSize, pageNo }, callback) {
  103. const params = {
  104. notice_title: "",
  105. p: pageNo,
  106. pSize,
  107. userId: userStore.user.useId,
  108. unitId: userStore.user.unitId,
  109. }
  110. getNoticeList(params).then(({ returnParams }) => {
  111. notices.value = returnParams.noticelist.list
  112. // 通知子组件加载完成
  113. callback(returnParams.noticelist.list, returnParams.total, pageNo)
  114. })
  115. }
  116. // 分页获取公告数据
  117. function getNoticePage({ pSize, pageNo }, callback) {
  118. const params = {
  119. notice_title: "",
  120. p: pageNo,
  121. pSize,
  122. userId: userStore.user.useId,
  123. unitId: userStore.user.unitId,
  124. }
  125. getNoticeList(params).then(({ returnParams }) => {
  126. // 更新数据
  127. notices.value.push(...returnParams.noticelist.list)
  128. // 通知子组件加载完成
  129. callback(returnParams.noticelist.list, returnParams.total, pageNo)
  130. })
  131. }
  132. // 点击公告列表项
  133. function handleToNoticeDetail(notice) {
  134. $tab.navigateTo('/pages/message/detail/index?noticeId=' + notice.id)
  135. }
  136. // 消息列表
  137. const messages = ref([])
  138. // 获取消息列表数据
  139. function getMessageData({ pSize, pageNo, type, segmentValue }, callback) {
  140. const params = {
  141. currentUser: userStore.user.useId,
  142. isRead: segmentValue,
  143. pSize: pSize,
  144. type: type,
  145. p: pageNo,
  146. }
  147. getMessageList(params).then(({ returnParams }) => {
  148. returnParams.list.forEach(item => {
  149. if('(流程提醒)您有一个流程' == item.title.substring(0, 12)) {
  150. item.title = '(流程提醒)' + item.title.slice(12)
  151. }
  152. // return item
  153. })
  154. messages.value = returnParams.list;
  155. // 通知子组件加载完成
  156. callback(returnParams.list, returnParams.total, pageNo)
  157. })
  158. }
  159. // 分页获取消息数据
  160. function getMessagePage({ pSize, pageNo, type, segmentValue }, callback) {
  161. const params = {
  162. currentUser: userStore.user.useId,
  163. isRead: segmentValue,
  164. pSize: pSize,
  165. type: type,
  166. p: pageNo,
  167. }
  168. getMessageList(params).then(({ returnParams }) => {
  169. returnParams.list.forEach(item => {
  170. if('(流程提醒)您有一个流程' == item.title.substring(0, 12)) {
  171. item.title = '(流程提醒)' + item.title.slice(12)
  172. }
  173. // return item
  174. })
  175. // 更新数据
  176. messages.value.push(...returnParams.list)
  177. // 通知子组件加载完成
  178. callback(returnParams.list, returnParams.total, pageNo)
  179. })
  180. }
  181. // 点击消息列表项
  182. function handleToMessageDetail({ messageid, universalid}) {
  183. $tab.navigateTo('/pages/message/detail/index?messageId=' + messageid + '&universalId=' + universalid)
  184. }
  185. // AI咨询按钮
  186. function clickFabButton() {
  187. console.log('clickFabButton');
  188. $tab.navigateTo('/pages/message/chat/index')
  189. }
  190. //待办流程数
  191. const unProcessNum = ref(0)
  192. //未读消息数
  193. const unReadNum=ref(0)
  194. //待阅消息数+待办流程数(用于tarbar导航栏)
  195. const unReadMsgNum=ref(0)
  196. function showTarBarBadge(){
  197. getUnProcessNum(userStore.user.useId,"").then(res=>{
  198. unProcessNum.value=parseInt(res.returnParams.total, 10);
  199. getUnReadMessageNum(userStore.user.useId).then(res=>{
  200. unReadNum.value=parseInt(res.returnParams, 10);
  201. unReadMsgNum.value=unReadNum.value+unProcessNum.value;
  202. if(unReadMsgNum.value==0){
  203. uni.removeTabBarBadge({
  204. index:0
  205. })
  206. }else{
  207. uni.setTabBarBadge({
  208. index: 0,
  209. text: String(unReadMsgNum.value)
  210. })
  211. }
  212. })
  213. })
  214. }
  215. </script>
  216. <style lang="scss">
  217. @import "@/static/font/ygoa/iconfont.css";
  218. .text {
  219. text-align: center;
  220. font-size: 26rpx;
  221. margin-top: 10rpx;
  222. }
  223. ::v-deep .uni-section-header__content {
  224. max-width: 3rem;
  225. }
  226. </style>