Browse Source

执法预告

dev-V1.10.2-temp
wangmingyong@163.com 3 months ago
parent
commit
fc8c573994
  1. 3
      zdxt-web-client/zdxt-efcode-enforcement-app/src/api/enforcement/notice.js
  2. 6
      zdxt-web-client/zdxt-efcode-enforcement-app/src/views/enforcement/enforce/enforcementChat.vue
  3. 5
      zdxt-web-client/zdxt-efcode-enterprise-app/src/api/enterprise/planNotice.js
  4. 111
      zdxt-web-client/zdxt-efcode-enterprise-app/src/views/enterprise/enforcement/enforcementChat.vue
  5. 30
      zdxt-web-client/zdxt-efcode-enterprise-app/src/views/enterprise/message/messageCenter.vue
  6. 2
      zdxt-web-client/zdxt-efcode-enterprise-app/vite-env/.env.enterprise-dev-wmy

3
zdxt-web-client/zdxt-efcode-enforcement-app/src/api/enforcement/notice.js

@ -30,4 +30,7 @@ export const getNoticeMessages = (noticeId, success, error) => _get(noticeBaseUr
// 新增留言
export const addNoticeMessage = (params, success, error) => _post(noticeBaseUrl + "/message", params, success, error);
// 标记留言已读
export const messageRead = (noticeId, success, error) => _get(noticeBaseUrl + "/messageRead", { noticeId }, success, error);
// endregion

6
zdxt-web-client/zdxt-efcode-enforcement-app/src/views/enforcement/enforce/enforcementChat.vue

@ -126,7 +126,7 @@ import { ref, nextTick, onMounted } from 'vue';
import { useRouter, useRoute } from 'vue-router';
import { showToast } from 'vant';
import 'vant/es/toast/style';
import { getNoticeMessages, addNoticeMessage } from '@/api/enforcement/notice';
import { getNoticeMessages, addNoticeMessage, messageRead } from '@/api/enforcement/notice';
const router = useRouter();
const route = useRoute();
@ -147,6 +147,7 @@ const loadMessageList = () => {
if (!noticeId) return;
getNoticeMessages(noticeId, (res) => {
if (res && res.code === 200 && res.data) {
const lastItem = res.data[res.data.length - 1];
messageList.value = res.data.map(item => ({
id: item.id,
sender: item.userName == useCommon.userName ? 'self' : 'other',
@ -156,6 +157,9 @@ const loadMessageList = () => {
isRecalled: item.isRecalled || false,
}));
nextTick(() => scrollToBottom());
if (lastItem && lastItem.id) {
messageRead(lastItem.id, () => {}, () => {});
}
}
}, () => {
showToast('加载消息失败');

5
zdxt-web-client/zdxt-efcode-enterprise-app/src/api/enterprise/planNotice.js

@ -14,6 +14,11 @@ export const getPlanNoticeMessageList = (params, success, error) => _get(enterpr
//执法预告消息列表(lawNotice)
export const getLawNoticeMessageList = (params, success, error) => _get(enterpriseAppBaseUrl +"/enterprise/lawNotice/message/list",params,success,error);
//执法预告发送消息
export const sendLawNoticeMessage = (params, success, error) => _post(enterpriseAppBaseUrl +"/enterprise/lawNotice/message",params,success,error);
//执法预告发送消息已读未读
export const sendLawNoticeMessageViewed = (params, success, error) => _get(enterpriseAppBaseUrl +"/enterprise/lawNotice/messageRead",params,success,error);
//执法预告新增留言
export const addPlanNoticeMessage = (params, success, error) => _post(enterpriseAppBaseUrl +"/planNotice/message",params,success,error);

111
zdxt-web-client/zdxt-efcode-enterprise-app/src/views/enterprise/enforcement/enforcementChat.vue

@ -77,7 +77,7 @@
</div>
<!-- 长按/右击菜单 -->
<div
<!-- <div
v-if="menuVisible"
class="menu-overlay"
@click="closeMenu"
@ -87,17 +87,17 @@
class="context-menu"
:style="{ top: menuPosition.y + 'px', left: menuPosition.x + 'px' }"
>
<!-- <div class="menu-item" @click.stop="onEdit">
<div class="menu-item" @click.stop="onEdit">
<van-icon name="edit" size="16" />
<span>编辑</span>
</div> -->
</div>
<div class="menu-divider"></div>
<div class="menu-item" @click.stop="onRecall">
<van-icon name="revoke" size="16" />
<span>撤回</span>
</div>
</div>
</div>
</div> -->
<!-- 底部输入区域 -->
<div class="chat-input-area">
@ -125,10 +125,11 @@
import { ref, nextTick, onMounted } from 'vue';
import { showToast } from 'vant';
import 'vant/es/toast/style';
import { getLawNoticeMessageList } from '@/api/enterprise/planNotice';
import { getLawNoticeMessageList, sendLawNoticeMessage, sendLawNoticeMessageViewed } from '@/api/enterprise/planNotice';
const router = useRouter();
const route = useRoute();
const { useCommon } = $globalStore;
// ========== 从路由参数获取信息 ==========
const noticeId = ref(route.query.id || '');
@ -154,14 +155,35 @@ const fetchMessageList = () => {
(res) => {
if (res.code === 200) {
const rows = res.rows || res.data?.rows || res.data?.list || res.data || [];
messageList.value = rows.map(item => ({
id: item.id || item.messageId,
sender: item.sender === 'self' || item.senderType === 1 || item.isSelf ? 'self' : 'other',
content: item.content || item.message || item.messageContent,
time: item.time || item.createTime || item.sendMessageTime || '',
avatar: item.sender === 'self' || item.senderType === 1 || item.isSelf ? selfAvatar : otherAvatar,
isRecalled: item.isRecalled || item.recallStatus || false,
}));
const currentUserName = useCommon.enterpriseName || '';
messageList.value = rows.map(item => {
const isSelf = item.userName == currentUserName;
return {
id: item.id,
sender: isSelf ? 'self' : 'other',
content: item.message,
time:item.createTime|| '',
avatar: isSelf ? selfAvatar : otherAvatar,
isRecalled: item.isRecalled || false,
};
});
// 取最后一条数据的id,调用已读接口
if (rows.length > 0) {
const lastMessageId = rows[rows.length - 1].id;
sendLawNoticeMessageViewed(
{ noticeId: lastMessageId },
(viewRes) => {
if (viewRes.code !== 200) {
console.warn('标记已读失败:', viewRes.msg);
}
},
() => {
console.warn('标记已读网络请求失败');
}
);
}
nextTick(() => {
scrollToBottom();
});
@ -332,39 +354,38 @@ const sendMessage = () => {
return;
}
const now = new Date();
const timeStr = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')} ${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}`;
messageList.value.push({
id: Date.now(),
sender: 'self',
content: text,
time: timeStr,
avatar: selfAvatar,
isRecalled: false,
});
inputMessage.value = '';
// 滚动到底部
nextTick(() => {
scrollToBottom();
// 调用接口发送消息
const params = {
noticeId: noticeId.value,
userId: String(useCommon.userId || ''),
userName: useCommon.enterpriseName || '企业',
message: text,
};
sendLawNoticeMessage(params, (res) => {
if (res.code === 200) {
const now = new Date();
const timeStr = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')} ${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}`;
messageList.value.push({
id: res.data?.id || Date.now(),
sender: 'self',
content: text,
time: timeStr,
avatar: selfAvatar,
isRecalled: false,
});
inputMessage.value = '';
// 滚动到底部
nextTick(() => {
scrollToBottom();
});
} else {
showToast(res.msg || '发送失败');
}
}, () => {
showToast('网络请求失败');
});
// 模拟对方回复
// setTimeout(() => {
// messageList.value.push({
// id: Date.now() + 1,
// sender: 'other',
// content: '收到,我们会尽快安排并与您确认具体时间。',
// time: timeStr,
// avatar: otherAvatar,
// isRecalled: false,
// });
// nextTick(() => {
// scrollToBottom();
// });
// }, 1500);
};
// ========== 滚动到底部 ==========

30
zdxt-web-client/zdxt-efcode-enterprise-app/src/views/enterprise/message/messageCenter.vue

@ -18,7 +18,11 @@
<div class="content-area">
<!-- Tab 切换 -->
<van-tabs v-model:active="activeTab" class="message-tabs" sticky swipeable>
<van-tab title="消息">
<van-tab>
<template #title>
<span>消息</span>
<span v-if="messageBadge > 0" class="tab-badge">{{ messageBadge > 99 ? '99+' : messageBadge }}</span>
</template>
<!-- 消息列表 -->
<van-pull-refresh v-model="messageRefreshing" @refresh="onMessageRefresh">
<van-list v-model:loading="messageLoading" :finished="messageFinished" finished-text="没有更多了"
@ -45,7 +49,11 @@
</van-pull-refresh>
</van-tab>
<van-tab title="待办">
<van-tab>
<template #title>
<span>待办</span>
<span v-if="todoBadge > 0" class="tab-badge">{{ todoBadge > 99 ? '99+' : todoBadge }}</span>
</template>
<!-- 待办列表 -->
<van-pull-refresh v-model="todoRefreshing" @refresh="onTodoRefresh">
<van-list v-model:loading="todoLoading" :finished="todoFinished" finished-text="没有更多了"
@ -109,6 +117,10 @@ const todoRefreshing = ref(false);
const todoPageNum = ref(1);
const todoPageSize = ref(10);
// ========== Tab 徽章数量 ==========
const messageBadge = computed(() => messageList.value.reduce((sum, item) => sum + (item.unreadCount || 0), 0));
const todoBadge = computed(() => todoList.value.reduce((sum, item) => sum + (item.unreadCount || 0), 0));
// ========== 消息统计数据 ==========
const messageStats = ref({
pffwCount: 0, // 涉企普法未读数量
@ -437,6 +449,20 @@ onMounted(() => {
border-radius: 2px;
}
.tab-badge {
display: inline-block;
min-width: 16px;
height: 16px;
padding: 0 4px;
margin-left: 4px;
background: #f44336;
border-radius: 8px;
color: #fff;
font-size: 10px;
line-height: 14px;
text-align: center;
}
:deep(.message-tabs .van-tabs__content) {
background: #fbfdff;
padding: 12px 16px;

2
zdxt-web-client/zdxt-efcode-enterprise-app/vite-env/.env.enterprise-dev-wmy

@ -1,7 +1,7 @@
# 企业端开发环境
VITE_PORT = 12001
# VITE_PROXY_TARGET = 'http://139.186.148.21:8080'
# VITE_PROXY_TARGET = 'http://172.16.21.213:8080'
VITE_PROXY_TARGET = 'http://172.16.21.213:8080'
VITE_BASE_URL = '/efcode20-ent-app/api'
VITE_CONTEXT_PATH = '/efcode20-ent-app/'
VITE_DEFAULT_LOGIN = '/enterprise/loginByPassword'

Loading…
Cancel
Save