index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. <template>
  2. <page-meta root-font-size="system" />
  3. <view class="index_container">
  4. <uni-nav-bar dark :border="false" :fixed="true" :title="config.companyName">
  5. </uni-nav-bar>
  6. <!-- 待办消息列表 -->
  7. <uni-collapse :accordion="true">
  8. <uni-collapse-item title-border="show" :border="true" :show-animation="true"
  9. :open="unProcessNum > 0 || false">
  10. <template v-slot:title>
  11. <uni-section title="待办" type="line" titleFontSize="1.3rem">
  12. <template v-slot:right>
  13. <uni-badge :text="unProcessNum" class="unReadBadge" v-if="unProcessNum > 0"></uni-badge>
  14. </template>
  15. </uni-section>
  16. </template>
  17. <view class="process_container">
  18. <view class="process_list">
  19. <process-list ref="processListRef" @clickSegment="getProcessData"
  20. @clickItem="handleToProcessDetail" @scrollToBottom="getProcessPage" :current="0" :pSize="5"
  21. :pageNo="1" contentHeight="63.5vh"></process-list>
  22. </view>
  23. </view>
  24. </uni-collapse-item>
  25. <!-- 公告列表 -->
  26. <uni-collapse-item title-border="show" :border="true" :show-animation="true"
  27. :open="unReadMsgNum > 0 || false">
  28. <template v-slot:title>
  29. <uni-section title="公告" type="line" titleFontSize="1.3rem">
  30. </uni-section>
  31. </template>
  32. <view class="notice_list">
  33. <message-list @clickSegment="getNoticeData" @clickItem="handleToNoticeDetail"
  34. @scrollToBottom="getNoticePage" :pSize="5" :pageNo="1" :anime="true"
  35. :open="false"></message-list>
  36. </view>
  37. </uni-collapse-item>
  38. <!-- 消息列表 -->
  39. <uni-collapse-item title-border="show" :border="true" :show-animation="true"
  40. :open="unReadMsgNum > 0 || false">
  41. <template v-slot:title>
  42. <uni-section title="消息" type="line" titleFontSize="1.3rem">
  43. <template v-slot:right>
  44. <uni-badge :text="unReadMsgNum"
  45. v-if="unReadMsgNum !== undefined && unReadMsgNum > 0"></uni-badge>
  46. <button @click.stop="setAllMsgRead" class="read_button" v-if="unReadMsgNum !== undefined" :disabled="unReadMsgNum === 0">一键阅读</button>
  47. </template>
  48. </uni-section>
  49. </template>
  50. <view class="message_list">
  51. <message-list ref="msgListRef" @clickSegment="getMessageData" @clickItem="handleToMessageDetail"
  52. @scrollToBottom="getMessagePage" :defaultCurrent="1" :pSize="5" :pageNo="1"
  53. :segments="{ '全部': '', '未读': '0', '已读': '1' }"></message-list>
  54. </view>
  55. </uni-collapse-item>
  56. </uni-collapse>
  57. <!-- 跳转打卡页按钮 -->
  58. <view class="fab_button">
  59. <view v-if="config.companyCode !== 'yz'" class="toClockInBtn">
  60. <uni-fab :pattern="{ icon: 'map-pin-ellipse' }" :popMenu="false" horizontal="right"
  61. @fabClick="toClockInBtn"></uni-fab>
  62. </view>
  63. <!-- AI咨询按钮 -->
  64. <view class="toAiBtn">
  65. <uni-fab :pattern="{ buttonText: 'headphones' }" :popMenu="false" horizontal="right" @fabClick="clickFabButton"></uni-fab>
  66. </view>
  67. </view>
  68. </view>
  69. </template>
  70. <script setup lang="ts">
  71. import { onBeforeMount, onMounted, onUpdated, ref } from 'vue';
  72. import { onLoad, onShow } from '@dcloudio/uni-app'
  73. import { getMessageList, getNoticeList, getUnReadMessageNum, setMsgIsRead } from '@/api/message.js';
  74. import { getUserProcess, getUnProcessNum, getTacheInfo } from '@/api/process';
  75. import $tab from '@/plugins/tab.js';
  76. import $modal from '@/plugins/modal.js';
  77. import processList from '@/components/ygoa/processList.vue'
  78. import messageList from '@/components/ygoa/messageList.vue'
  79. import { useUserStore } from '@/store/user.js'
  80. import { getLoginInfo } from '@/utils/auth';
  81. import config from '@/config';
  82. const userStore = useUserStore()
  83. const processListRef = ref(null)
  84. onMounted(() => {
  85. uni.$on('showTabBarBadge', showTabBarBadge)
  86. uni.$on('ReloadProcessData', () => {
  87. new Promise((resolve, reject) => {
  88. processListRef.value.onClickItem()
  89. })
  90. })
  91. })
  92. onLoad((options) => {
  93. // 是否跳转打卡页
  94. if (options.to == 'clockIn' && config.companyCode !== 'yz'){
  95. toClockIn()
  96. }else if(options.noticeId){
  97. $tab.navigateTo('/pages/message/detail/index?noticeId=' + options.noticeId)
  98. }
  99. })
  100. onShow(() => {
  101. showTabBarBadge();
  102. })
  103. onBeforeMount(() => {
  104. uni.removeTabBarBadge({
  105. index: 0
  106. })
  107. })
  108. // 跳转打卡页
  109. function toClockIn() {
  110. // 确认是否跳转打卡页
  111. $modal.confirm('当前未打卡,是否前往打卡').then(() => {
  112. $tab.navigateTo('/pages/mine/clockIn/clockIn')
  113. }).catch(() => { })
  114. }
  115. //子组件
  116. const msgListRef = ref(null)
  117. // 获取待办消息列表数据
  118. function getProcessData({ pSize, pageNo }, callback) {
  119. const params = {
  120. staffId: userStore.user.useId,
  121. page: pageNo,
  122. pageNum: pSize,
  123. modelId: "",
  124. control: 1
  125. }
  126. getUserProcess(params).then(({ returnParams }) => {
  127. callback(returnParams.list, returnParams.total, pageNo)
  128. });
  129. }
  130. // 分页获取待办消息列表数据
  131. function getProcessPage({ pSize, pageNo }, callback) {
  132. const params = {
  133. staffId: userStore.user.useId,
  134. page: pageNo,
  135. pageNum: pSize,
  136. modelId: "",
  137. control: 1
  138. }
  139. getUserProcess(params).then(({ returnParams }) => {
  140. callback(returnParams.list, returnParams.total, pageNo)
  141. });
  142. }
  143. // 点击待办消息列表项
  144. function handleToProcessDetail({ insId, tinsId, insName, control, modelId }) {
  145. if (control == '0' && modelId) {
  146. if(modelId == '200001' || modelId == '200002' || modelId == '200003'){
  147. // 跳转到通用审批页面
  148. let url = '/pages/process/common/detail?insId=' + insId + '&insName=' + insName + '&control=' + control + '&modelId=' + modelId
  149. if (tinsId) { // 排除抄送流程的 tinsId
  150. url = url + '&tinsId=' + tinsId
  151. }
  152. $tab.navigateTo(url)
  153. return
  154. }else{
  155. $tab.navigateTo('/pages/process/detail/index?insId=' + insId + '&tinsId=' + tinsId + '&insName=' + insName + '&control=' + control)
  156. }
  157. }else{
  158. $tab.navigateTo('/pages/process/detail/index?insId=' + insId + '&tinsId=' + tinsId + '&insName=' + insName + '&control=' + control)
  159. }
  160. }
  161. // 获取公告列表数据
  162. function getNoticeData({ pSize, pageNo }, callback) {
  163. const params = {
  164. notice_title: "",
  165. p: pageNo,
  166. pSize,
  167. userId: userStore.user.useId,
  168. unitId: userStore.user.unitId,
  169. }
  170. getNoticeList(params).then(({ returnParams }) => {
  171. // 通知子组件加载完成
  172. callback(returnParams.noticelist.list, returnParams.total, pageNo)
  173. })
  174. }
  175. // 分页获取公告数据
  176. function getNoticePage({ pSize, pageNo }, callback) {
  177. const params = {
  178. notice_title: "",
  179. p: pageNo,
  180. pSize,
  181. userId: userStore.user.useId,
  182. unitId: userStore.user.unitId,
  183. }
  184. getNoticeList(params).then(({ returnParams }) => {
  185. // 通知子组件加载完成
  186. callback(returnParams.noticelist.list, returnParams.total, pageNo)
  187. })
  188. }
  189. // 点击公告列表项
  190. function handleToNoticeDetail(notice) {
  191. $tab.navigateTo('/pages/message/detail/index?noticeId=' + notice.id)
  192. }
  193. // 消息列表
  194. // const messages = ref([])
  195. // 获取消息列表数据
  196. const msgPoint = ref(0)
  197. function getMessageData({ pSize, pageNo, type, segmentValue }, callback) {
  198. const flag = msgPoint.value = new Date().getTime()
  199. const params = {
  200. currentUser: userStore.user.useId,
  201. isRead: segmentValue,
  202. pSize: pSize,
  203. type: type,
  204. p: pageNo,
  205. }
  206. getMessageList(params).then(({ returnParams }) => {
  207. returnParams.list.forEach(item => {
  208. if ('(流程提醒)您有一个流程' == item.title.substring(0, 12)) {
  209. item.title = '(流程提醒)' + item.title.slice(12)
  210. }
  211. })
  212. // 通知子组件加载完成
  213. if (flag == msgPoint.value) {
  214. callback(returnParams.list, returnParams.total, pageNo)
  215. }
  216. })
  217. }
  218. // 分页获取消息数据
  219. function getMessagePage({ pSize, pageNo, type, segmentValue }, callback) {
  220. const params = {
  221. currentUser: userStore.user.useId,
  222. isRead: segmentValue,
  223. pSize: pSize,
  224. type: type,
  225. p: pageNo,
  226. }
  227. getMessageList(params).then(({ returnParams }) => {
  228. returnParams.list.forEach(item => {
  229. if ('(流程提醒)您有一个流程' == item.title.substring(0, 12)) {
  230. item.title = '(流程提醒)' + item.title.slice(12)
  231. }
  232. // return item
  233. })
  234. // 通知子组件加载完成
  235. callback(returnParams.list, returnParams.total, pageNo)
  236. })
  237. }
  238. //点击消息列表项
  239. function handleToMessageDetail({ messageid, universalid, jump_id, title }) {
  240. // 设置消息已读
  241. setMsgIsRead(universalid + ',').then((res) => {
  242. if (Number.isInteger(res)) {
  243. msgListRef.value.reload();//调用子组件刷新数据
  244. } else {
  245. $modal.confirm('登录状态失效,您可以继续留在该页面,或者重新登录?').then(res => {
  246. const loginInfo = getLoginInfo();
  247. userStore.LogOut().then(res => {
  248. uni.setStorageSync('loginInfo', loginInfo)
  249. $tab.reLaunch('/pages/login?type=autoLogin')
  250. })
  251. }).catch(() => { })
  252. }
  253. })
  254. //debugger
  255. if(jump_id) {
  256. try {
  257. // 解析jump_id JSON字符串
  258. // const jumpInfo = JSON.parse(jump_id);
  259. const { modelId, insId, tinsId, opType, insName } = jump_id;
  260. if (opType === 'process') {
  261. getTacheInfo(tinsId).then(({returnParams}) => {
  262. if(returnParams.oldTacheStatus == 1) {
  263. //跳到流程办理页面
  264. if(modelId == '200001' || modelId == '200002' || modelId == '200003'){
  265. let url = '/pages/process/common/detail?insId=' + insId + '&insName=' + insName + '&control=0&modelId=' + modelId
  266. if (tinsId) {
  267. url = url + '&tinsId=' + tinsId
  268. }
  269. $tab.navigateTo(url)
  270. }else{
  271. $tab.navigateTo('/pages/process/detail/index?insId=' + insId + '&tinsId=' + tinsId + '&insName=' + insName + '&control=1')
  272. }
  273. } else {
  274. //跳到流程到流程查看页面
  275. if(modelId == '200001' || modelId == '200002' || modelId == '200003'){
  276. let url = '/pages/process/common/detail?insId=' + insId + '&insName=' + insName + '&control=0&modelId=' + modelId
  277. $tab.navigateTo(url)
  278. }else{
  279. $tab.navigateTo('/pages/process/detail/index?insId=' + insId + '&insName=' + insName + '&control=0')
  280. }
  281. }
  282. })
  283. } else if (opType === 'view') {
  284. //跳到流程到流程查看页面
  285. if(modelId == '200001' || modelId == '200002' || modelId == '200003'){
  286. let url = '/pages/process/common/detail?insId=' + insId + '&insName=' + insName + '&control=0&modelId=' + modelId
  287. $tab.navigateTo(url)
  288. }else{
  289. $tab.navigateTo('/pages/process/detail/index?insId=' + insId + '&insName=' + insName + '&control=0')
  290. }
  291. } else {
  292. // 未知操作类型,跳转到消息详情页
  293. $tab.navigateTo('/pages/message/detail/index?messageId=' + messageid + '&universalId=' + universalid)
  294. }
  295. } catch (error) {
  296. console.error('jump_id解析失败:', error);
  297. // 解析失败,跳转到消息详情页
  298. $tab.navigateTo('/pages/message/detail/index?messageId=' + messageid + '&universalId=' + universalid)
  299. }
  300. } else {
  301. // jump_id为空,跳转到消息详情页
  302. $tab.navigateTo('/pages/message/detail/index?messageId=' + messageid + '&universalId=' + universalid)
  303. }
  304. }
  305. // AI咨询按钮
  306. function clickFabButton() {
  307. // console.log('clickFabButton');
  308. $tab.navigateTo('/pages/message/chat/index')
  309. }
  310. //跳转打卡页
  311. function toClockInBtn() {
  312. $tab.navigateTo('/pages/mine/clockIn/clockIn')
  313. }
  314. //待办流程数
  315. const unProcessNum = ref(0)
  316. //未读消息数
  317. const unReadMsgNum = ref(0)
  318. //待阅消息数+待办流程数(用于tarbar导航栏)
  319. const unReadNum = ref(0)
  320. function showTabBarBadge() {
  321. getUnProcessNum(userStore.user.useId, "").then(res => {
  322. if ("failed" == res.returnMsg) {
  323. $modal.showToast('待办流程数获取失败')
  324. return
  325. } else {
  326. unProcessNum.value = parseInt(res.returnParams?.total || 0, 10);
  327. }
  328. getUnReadMessageNum(userStore.user.useId).then(res => {
  329. unReadMsgNum.value = parseInt(res.returnParams ?? 0, 10);
  330. unReadNum.value = unReadMsgNum.value + unProcessNum.value;
  331. setThisTabBarBadge(0,unReadNum.value)
  332. setThisTabBarBadge(1,unProcessNum.value)
  333. })
  334. })
  335. }
  336. // 提取通用 badge 设置逻辑
  337. function setThisTabBarBadge(index, count) {
  338. if (count <= 0) {
  339. uni.removeTabBarBadge({ index });
  340. } else {
  341. uni.setTabBarBadge({
  342. index,
  343. text: count > 99 ? "99+" : String(count)
  344. });
  345. }
  346. }
  347. // 设置所有消息已读
  348. function setAllMsgRead() {
  349. $modal.confirm('是否全部已读').then(res => {
  350. if (res) {
  351. const params = {
  352. currentUser: userStore.user.useId,
  353. isRead: "0",
  354. pSize: unReadMsgNum.value,
  355. type: "",
  356. p: 1,
  357. }
  358. getMessageList(params).then(({ returnParams }) => {
  359. const unReadMsgIds = returnParams.ids === "" ? "" : returnParams.ids + ",";
  360. setMsgIsRead(unReadMsgIds).then((res) => {
  361. if (Number.isInteger(res)) {
  362. switch (res) {
  363. case -1:
  364. $modal.msgError('操作失败')
  365. break
  366. case -2:
  367. case 0:
  368. $modal.msg('不存在未读消息')
  369. msgListRef.value.reload();// 调用子组件刷新数据
  370. showTabBarBadge()
  371. break
  372. default:
  373. $modal.msgSuccess('操作成功')
  374. //刷新页面
  375. msgListRef.value.reload();// 调用子组件刷新数据
  376. showTabBarBadge()
  377. }
  378. } else {
  379. $modal.confirm('登录状态失效,您可以继续留在该页面,或者重新登录?').then(res => {
  380. userStore.LogOut().then(res => {
  381. uni.reLaunch({ url: '/pages/login?type=autoLogin' })
  382. })
  383. }).catch(() => { })
  384. }
  385. })
  386. })
  387. }
  388. }).catch(() => { })
  389. }
  390. </script>
  391. <style lang="scss" scoped>
  392. // @import "@/static/font/ygoa/iconfont.css";
  393. ::v-deep .uni-badge {
  394. height: calc(1.5rem + 0px) !important;
  395. min-width: calc(1.5rem + 0px) !important;
  396. line-height: calc(1.375rem + 0px) !important;
  397. font-size: calc(1.125rem + 0px) !important;
  398. }
  399. ::v-deep .process_container {
  400. .process_list {
  401. .process_contant {
  402. font-size: calc(14px + .5*(1rem - 16px));
  403. }
  404. .flow_step_section {
  405. .uni-section .uni-section-header {
  406. padding: 5px 10px;
  407. }
  408. }
  409. .flow_step_container {
  410. min-height: 60px;
  411. margin: 10px 15px;
  412. .u-steps {
  413. .u-steps-item {
  414. padding-bottom: 11px;
  415. .u-text__value--content {
  416. font-size: calc(13px + .5*(1rem - 16px)) !important;
  417. }
  418. .u-text__value--main {
  419. font-size: calc(13px + .5*(1rem - 16px)) !important;
  420. font-weight: 500 !important;
  421. }
  422. .u-text__value--tips {
  423. font-size: calc(12px + .5*(1rem - 16px)) !important;
  424. }
  425. .redcontent {
  426. .u-text__value--content {
  427. color: #ff4500;
  428. }
  429. }
  430. .active_step_circle {
  431. width: 20px;
  432. height: 20px;
  433. box-sizing: border-box;
  434. flex-shrink: 0;
  435. border-radius: 100px;
  436. border-width: 1px;
  437. border-color: #A78BFA;
  438. background-color: #A78BFA;
  439. border-style: solid;
  440. display: flex;
  441. flex-direction: row;
  442. align-items: center;
  443. justify-content: center;
  444. transition: background-color .3s;
  445. .active_step_text {
  446. color: #fff;
  447. font-size: 11px;
  448. display: flex;
  449. flex-direction: row;
  450. align-items: center;
  451. justify-content: center;
  452. text-align: center;
  453. line-height: 11px;
  454. }
  455. }
  456. }
  457. .u-steps-item view:last-of-type {
  458. margin-top: 0 !important;
  459. }
  460. }
  461. }
  462. }
  463. }
  464. ::v-deep .notice_list {
  465. .msg_list_container {
  466. .zp-l-text-rpx {
  467. font-size: calc(30rpx + .5*(1rem - 16px));
  468. }
  469. }
  470. }
  471. .read_button {
  472. position: absolute;
  473. top: calc(12px + .5 * (1rem - 16px));
  474. right: 3.125rem;
  475. height: calc(1.75rem + 0px);
  476. line-height: 1.75rem;
  477. font-size: calc(0.875rem + 0px);
  478. background-color: #007aff;
  479. color: #fff;
  480. }
  481. .read_button[disabled] {
  482. background-color: #f5f5f5;
  483. color: #666;
  484. opacity: 0.5;
  485. }
  486. ::v-deep .message_list {
  487. .msg_list_container {
  488. .segmented_control_container {
  489. .segmented-control__text {
  490. font-size: calc(14px + .5*(1rem - 16px));
  491. }
  492. }
  493. .zp-paging-container-content {
  494. .zp-l-text-rpx {
  495. font-size: calc(30rpx + .5*(1rem - 16px));
  496. }
  497. }
  498. }
  499. }
  500. ::v-deep .fab_button {
  501. .toClockInBtn {
  502. .uni-fab__circle--rightBottom {
  503. bottom: 100px;
  504. }
  505. }
  506. .toAiBtn {
  507. uni-icons {
  508. text {
  509. font-family: 'ygoa_work_icon' !important;
  510. }
  511. text:before {
  512. content: "\e660" !important;
  513. }
  514. }
  515. }
  516. .uni-fab__circle {
  517. width: calc(55px + .5*(1rem - 16px)) !important;
  518. height: calc(55px + .5*(1rem - 16px)) !important;
  519. .uni-icons {
  520. font-size: calc(32px + .5*(1rem - 16px)) !important;
  521. }
  522. }
  523. }
  524. </style>