刘光辉
9 小时以前 0dfe84494048ce27ba8449831782128412d3eb13
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<script lang="ts" setup>
import { inject, ref } from 'vue';
 
import { useGo } from '@jnpf/hooks';
import { useModal } from '@jnpf/ui/modal';
import { encryptByBase64, toDateText } from '@jnpf/utils';
 
import { getConfigData } from '#/api/onlineDev/visualDev';
import { readInfo as readMsgInfo } from '#/api/system/message';
import { getScheduleDetail } from '#/api/teamwork/schedule';
import Form from '#/views/common/dynamicModel/list/Form.vue';
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 formRef = ref<any>(null);
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 (item.type == 5) {
        const bodyText: any = res.data.bodyText ? JSON.parse(res.data.bodyText) : {};
        const formTemplateId = bodyText.formTemplateId || '';
        const formDataId = bodyText.formDataId || '';
        if (!formTemplateId || !formDataId) return;
        getConfigData(formTemplateId).then((res) => {
          if (res.code !== 200 || !res.data) return;
          const formConf = JSON.parse(res.data.formData);
          formConf.popupType = 'general';
          formConf.hasConfirmAndAddBtn = false;
          const data = {
            id: formDataId,
            modelId: formTemplateId,
            menuId: '',
            formConf,
            useFormPermission: false,
            showMoreBtn: false,
            title: res.data.fullName,
          };
          formRef.value?.init(data);
        });
      } 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';
  if (type === 5) return 'item-type-form';
  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>
    <Form ref="formRef" />
    <Detail @register="registerDetail" />
    <ScheduleDetail @register="registerScheduleDetail" />
  </div>
</template>