ny
昨天 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<script lang="ts" setup>
import { inject } from 'vue';
 
import { useGo } from '@jnpf/hooks';
import { useModal } from '@jnpf/ui/modal';
import { encryptByBase64, toDateText } from '@jnpf/utils';
 
import { readInfo as readMsgInfo } from '#/api/system/message';
import { getScheduleDetail } from '#/api/teamwork/schedule';
import Detail from '#/views/msgCenter/notice/Detail.vue';
import ScheduleDetail from '#/views/teamwork/schedule/Detail.vue';
 
defineProps({
  list: {
    default: () => [],
    type: Array as any,
  },
});
 
const emitter: any = inject('emitter');
 
const go = useGo();
const [registerDetail, { openModal: openDetailModal }] = useModal();
const [registerScheduleDetail, { openModal: openScheduleDetailModal }] = useModal();
 
function readInfo(item) {
  readMsgInfo(item.id).then((res) => {
    if (item.type == 4) {
      const bodyText = res.data.bodyText ? JSON.parse(res.data.bodyText) : {};
      if (bodyText.type == 3) return;
      getScheduleDetail(bodyText.groupId, bodyText.id).then(() => {
        openScheduleDetailModal(true, { id: bodyText.id, groupId: bodyText.groupId });
      });
    } else if (item.type == 2 && item.flowType == 2) {
      const bodyText = JSON.parse(res.data.bodyText);
      if (bodyText.type == 0) return;
      emitter.emit('openProfileModal', { activeKey: 'entrust', subActiveKey: bodyText.type });
    } else {
      if (item.type == 1 || item.type == 3) {
        openDetailModal(true, { id: item.id, type: 1 });
      } else {
        if (!res.data.bodyText) return;
        go(`/workFlowDetail?config=${encodeURIComponent(encryptByBase64(res.data.bodyText))}`);
      }
    }
  });
}
function handleMore() {
  go('/messageRecord');
}
function getClass(type) {
  if (type === 1) return 'item-type-system';
  if (type === 2) return 'item-type-flow';
  if (type === 4) return 'item-type-schedule';
  return 'item-type-notice';
}
</script>
<template>
  <div class="msg-pane dashboard-pane">
    <div class="dashboard-header">
      <div class="dashboard-header-title">消息</div>
      <div class="dashboard-header-more" @click="handleMore">更多<i class="icon-ym icon-ym-right"></i></div>
    </div>
    <div class="msg-list">
      <div class="msg-item" v-for="item in list" :key="item.id">
        <div class="item-type" :class="getClass(item.type)">{{ item.typeName }}</div>
        <div class="item-title" :title="item.title" @click="readInfo(item)">{{ item.title }}</div>
        <div class="item-user">{{ item.releaseUser }}</div>
        <div class="item-time">{{ toDateText(item.releaseTime) }}</div>
      </div>
      <jnpf-empty v-if="!list.length" />
    </div>
    <Detail @register="registerDetail" />
    <ScheduleDetail @register="registerScheduleDetail" />
  </div>
</template>