| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 |
- <template>
- <view class="index_container">
- <uni-nav-bar dark :border="false" :fixed="true" title="宇光同行">
- </uni-nav-bar>
- <uni-collapse>
- <uni-collapse-item title-border="show" :border="true" :show-animation="true" :open="false">
- <template v-slot:title>
- <uni-section title="待办" type="line" titleFontSize="1.3rem">
- <template v-slot:right>
- <uni-badge :text="unProcessNum" style="margin-left: -10px;"
- v-if="unProcessNum>0"></uni-badge>
- </template>
- </uni-section>
- </template>
- <view class="process_container">
- <view class="process_list">
- <process-list :list="processes" @clickSegment="getProcessData"
- @clickItem="handleToProcessDetail" @scrollToBottom="getProcessPage" :current="0" :pSize="5"
- :pageNo="1" contentHeight="69.5vh"></process-list>
- </view>
- </view>
- </uni-collapse-item>
- </uni-collapse>
- <!-- 公告列表 -->
- <message-list :list="notices" @clickSegment="getNoticeData" @clickItem="handleToNoticeDetail"
- @scrollToBottom="getNoticePage" :pSize="5" :pageNo="1" :anime="true" :open="false"
- title="公告"></message-list>
- <!-- 消息列表 -->
- <message-list @readMsg="setMsgRead" :unReadNum="unReadNum" :list="messages" @clickSegment="getMessageData"
- @clickItem="handleToMessageDetail" @scrollToBottom="getMessagePage" :defaultCurrent="1" :pSize="5"
- :pageNo="1" :anime="true" :open="true" :segments="{ '全部': '', '未读': '0', '已读': '1' }"
- title="消息"></message-list>
- <!-- AI咨询按钮 -->
- <view class="fab_button">
- <uni-fab :pattern="{ icon: 'headphones' }" :popMenu="false" horizontal="right"
- @fabClick="clickFabButton"></uni-fab>
- </view>
- </view>
- </template>
- <script setup lang="ts">
- import { onMounted, ref } from 'vue';
- import { onLoad } from '@dcloudio/uni-app'
- import { getMessageList, getNoticeList, getUnReadMessageNum, setMsgIsRead } from '@/api/message.js';
- import { getUserProcess, getUnProcessNum } from '@/api/process';
- import $tab from '@/plugins/tab.js';
- import $modal from '@/plugins/modal.js';
- import processList from '@/components/ygoa/processList.vue'
- import messageList from '@/components/ygoa/messageList.vue'
- import { useUserStore } from '@/store/user.js'
- const userStore = useUserStore()
- onLoad((options) => {
- // 是否跳转打卡页
- if (options.to == 'clockIn') toClockIn()
- })
- onMounted(() => {
- showTarBarBadge();
- })
- // 跳转打卡页
- function toClockIn() {
- // 确认是否跳转打卡页
- $modal.confirm('当前未打卡,是否前往打卡').then(() => {
- $tab.navigateTo('/pages/mine/clockIn/clockIn')
- })
- }
- //所有未读消息的ids
- const unReadMsgIds = ref('')
- //设置消息已读
- function setMsgRead() {
- setMsgIsRead(unReadMsgIds.value).then((res) => {
- if (Number.isInteger(res)) {
- switch (res) {
- case -1:
- $modal.msgError('操作失败')
- break
- case -2:
- $modal.msg('不存在未读消息')
- break
- default:
- $modal.msgSuccess('操作成功')
- //刷新页面
- setTimeout(() => {
- $tab.reLaunch('/pages/message/index')
- }, 1000)
- }
- } else {
- $modal.msgError('jssesionid失效,请重新登录')
- }
- })
- }
- // 待办列表
- const processes = ref([])
- // 获取待办消息列表数据
- function getProcessData({ pSize, pageNo }, callback) {
- const params = {
- staffId: userStore.user.useId,
- page: pageNo,
- pageNum: pSize,
- modelId: "",
- control: 1
- }
- getUserProcess(params).then(({ returnParams }) => {
- if (returnParams == undefined) {
- processes.value = []
- return
- }
- processes.value = returnParams.list;
- callback(returnParams.list, returnParams.total, pageNo)
- });
- }
- // 分页获取待办消息列表数据
- function getProcessPage({ pSize, pageNo }, callback) {
- const params = {
- staffId: userStore.user.useId,
- page: pageNo,
- pageNum: pSize,
- modelId: "",
- control: 1
- }
- getUserProcess(params).then(({ returnParams }) => {
- processes.value.push(...returnParams.list)
- callback(returnParams.list, returnParams.total, pageNo)
- });
- }
- // 点击待办消息列表项
- function handleToProcessDetail({ insId, insName }) {
- $tab.navigateTo('/pages/process/detail/index?insId=' + insId + '&insName=' + insName)
- }
- // 公告列表
- const notices = ref([])
- // 获取公告列表数据
- function getNoticeData({ pSize, pageNo }, callback) {
- const params = {
- notice_title: "",
- p: pageNo,
- pSize,
- userId: userStore.user.useId,
- unitId: userStore.user.unitId,
- }
- getNoticeList(params).then(({ returnParams }) => {
- notices.value = returnParams.noticelist.list
- // 通知子组件加载完成
- callback(returnParams.noticelist.list, returnParams.total, pageNo)
- })
- }
- // 分页获取公告数据
- function getNoticePage({ pSize, pageNo }, callback) {
- const params = {
- notice_title: "",
- p: pageNo,
- pSize,
- userId: userStore.user.useId,
- unitId: userStore.user.unitId,
- }
- getNoticeList(params).then(({ returnParams }) => {
- // 更新数据
- notices.value.push(...returnParams.noticelist.list)
- // 通知子组件加载完成
- callback(returnParams.noticelist.list, returnParams.total, pageNo)
- })
- }
- // 点击公告列表项
- function handleToNoticeDetail(notice) {
- $tab.navigateTo('/pages/message/detail/index?noticeId=' + notice.id)
- }
- // 消息列表
- const messages = ref([])
- // 获取消息列表数据
- function getMessageData({ pSize, pageNo, type, segmentValue }, callback) {
- const params = {
- currentUser: userStore.user.useId,
- isRead: segmentValue,
- pSize: pSize,
- type: type,
- p: pageNo,
- }
- getMessageList(params).then(({ returnParams }) => {
- returnParams.list.forEach(item => {
- if ('(流程提醒)您有一个流程' == item.title.substring(0, 12)) {
- item.title = '(流程提醒)' + item.title.slice(12)
- }
- // return item
- })
- messages.value = returnParams.list;
- unReadMsgIds.value = returnParams.ids === "" ? "" : returnParams.ids + ",";
- // 通知子组件加载完成
- callback(returnParams.list, returnParams.total, pageNo)
- })
- }
- // 分页获取消息数据
- function getMessagePage({ pSize, pageNo, type, segmentValue }, callback) {
- const params = {
- currentUser: userStore.user.useId,
- isRead: segmentValue,
- pSize: pSize,
- type: type,
- p: pageNo,
- }
- getMessageList(params).then(({ returnParams }) => {
- returnParams.list.forEach(item => {
- if ('(流程提醒)您有一个流程' == item.title.substring(0, 12)) {
- item.title = '(流程提醒)' + item.title.slice(12)
- }
- // return item
- })
- // 更新数据
- messages.value.push(...returnParams.list)
- // 通知子组件加载完成
- callback(returnParams.list, returnParams.total, pageNo)
- })
- }
- // 点击消息列表项
- function handleToMessageDetail({ messageid, universalid }) {
- $tab.navigateTo('/pages/message/detail/index?messageId=' + messageid + '&universalId=' + universalid)
- }
- // AI咨询按钮
- function clickFabButton() {
- console.log('clickFabButton');
- $tab.navigateTo('/pages/message/chat/index')
- }
- //待办流程数
- const unProcessNum = ref(0)
- //未读消息数
- const unReadNum = ref(0)
- //待阅消息数+待办流程数(用于tarbar导航栏)
- const unReadMsgNum = ref(0)
- function showTarBarBadge() {
- getUnProcessNum(userStore.user.useId, "").then(res => {
- if ("failed" == res.returnMsg) {
- $modal.msgError('待办流程数获取失败')
- return
- } else {
- unProcessNum.value = parseInt(res.returnParams.total, 10);
- }
- getUnReadMessageNum(userStore.user.useId).then(res => {
- unReadNum.value = parseInt(res.returnParams, 10);
- unReadMsgNum.value = unReadNum.value + unProcessNum.value;
- if (unReadMsgNum.value == 0) {
- uni.removeTabBarBadge({
- index: 0
- })
- } else {
- uni.setTabBarBadge({
- index: 0,
- text: unReadMsgNum.value > 99 ? '99+' : String(unReadMsgNum.value)
- })
- }
- })
- })
- }
- </script>
- <style lang="scss">
- @import "@/static/font/ygoa/iconfont.css";
- .text {
- text-align: center;
- font-size: 26rpx;
- margin-top: 10rpx;
- }
- ::v-deep .uni-section-header__content {
- max-width: 3rem;
- }
- </style>
|