<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>
|