no commit message
This commit is contained in:
@@ -146,3 +146,21 @@ export async function getUnreturnedPriceCount (params) {
|
||||
const res = await post('admin/Pending/getUnreturnedPriceCount', params)
|
||||
return res
|
||||
}
|
||||
|
||||
// 获取预估制作数量(status=9)
|
||||
export async function getEstimatePendingCount (params) {
|
||||
const res = await post('admin/Pending/getEstimatePendingCount', params)
|
||||
return res
|
||||
}
|
||||
|
||||
// 获取查勘跟进中数量(当前登录人)
|
||||
export async function getSurveyFollowCount (params) {
|
||||
const res = await post('admin/Survey/surveyFollowCount', params)
|
||||
return res
|
||||
}
|
||||
|
||||
// 获取报告制作数量统计
|
||||
export async function getReportProduceCount (params) {
|
||||
const res = await post('admin/ReportManage/getReportProduceCount', params)
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
{{ replacePhrases(menuItem.title, replaceRule1) }}
|
||||
</div>
|
||||
<div v-if="isHuiJiaMenu(menuItem) && unreturnedCount >= 1" class="push-value-badge">{{ unreturnedCount }}</div>
|
||||
<div v-if="isEstimateMenu(menuItem) && estimateCounts.total > 0" class="push-value-badge">{{ estimateCounts.total }}</div>
|
||||
<div v-if="isSurveyMenu(menuItem) && surveyFollowCount > 0" class="push-value-badge">{{ surveyFollowCount }}</div>
|
||||
<div v-if="isReportMenu(menuItem) && reportProduceCounts.total > 0" class="push-value-badge">{{ reportProduceCounts.total }}</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-menu-item>
|
||||
@@ -29,6 +32,7 @@
|
||||
import "@/styles/globalSetting.less";
|
||||
import { EventBus } from '@/libs/eventBus'
|
||||
import socket from '@/libs/socket'
|
||||
import { getSurveyFollowCount, getUnreturnedPriceCount, getEstimatePendingCount, getReportProduceCount } from '@/api/businessManage/inquiry'
|
||||
export default {
|
||||
name: 'NxIconMenu',
|
||||
props: {
|
||||
@@ -45,6 +49,20 @@
|
||||
return {
|
||||
activeMenu: '1-4-1',
|
||||
unreturnedCount: 0,
|
||||
estimateCounts: {
|
||||
pending: 0,
|
||||
secondReview: 0,
|
||||
thirdReview: 0,
|
||||
sign: 0,
|
||||
total: 0
|
||||
},
|
||||
surveyFollowCount: 0,
|
||||
reportProduceCounts: {
|
||||
pending: 0,
|
||||
secondReview: 0,
|
||||
thirdReview: 0,
|
||||
total: 0
|
||||
},
|
||||
replaceRule1:[
|
||||
['询价项目','询价'],
|
||||
['回价项目','回价'],
|
||||
@@ -72,25 +90,179 @@
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
// 监听EventBus事件
|
||||
// 调试:打印左侧菜单数据
|
||||
console.log('=== 左侧图标菜单调试 ===')
|
||||
console.log('menuData:', this.menuData)
|
||||
console.log('estimateCounts初始值:', this.estimateCounts)
|
||||
|
||||
// 主动获取所有数量,避免时序问题导致的红点不显示
|
||||
this.fetchUnreturnedCount()
|
||||
this.fetchEstimateCount()
|
||||
this.fetchSurveyFollowCount()
|
||||
this.fetchReportCount()
|
||||
|
||||
// 监听EventBus事件 - 未回价数量
|
||||
this.eventBusCallback = (count) => {
|
||||
console.log('=== 未回价EventBus事件 ===', count)
|
||||
this.$set(this, 'unreturnedCount', count)
|
||||
}
|
||||
this.socketCallback = (data) => {
|
||||
if (data && data.count !== undefined) {
|
||||
console.log('=== 未回价WebSocket事件 ===', data)
|
||||
if (data && data.refresh) {
|
||||
// 收到刷新事件,主动获取数据
|
||||
this.fetchUnreturnedCount()
|
||||
} else if (data && data.count !== undefined) {
|
||||
this.$set(this, 'unreturnedCount', data.count)
|
||||
}
|
||||
}
|
||||
EventBus.$on('updateUnreturnedCount', this.eventBusCallback)
|
||||
socket.on('updateUnreturnedCount', this.socketCallback)
|
||||
|
||||
// 监听EventBus事件 - 预估制作数量
|
||||
this.estimateEventBusCallback = (counts) => {
|
||||
console.log('=== 预估EventBus事件 ===', counts)
|
||||
this.$set(this, 'estimateCounts', counts)
|
||||
}
|
||||
this.estimateSocketCallback = (data) => {
|
||||
console.log('=== 预估WebSocket事件 ===', data)
|
||||
if (data && data.refresh) {
|
||||
// 收到刷新事件,主动获取数据
|
||||
this.fetchEstimateCount()
|
||||
} else if (data && data.pending !== undefined) {
|
||||
this.$set(this, 'estimateCounts', data)
|
||||
}
|
||||
}
|
||||
EventBus.$on('updateEstimatePendingCount', this.estimateEventBusCallback)
|
||||
socket.on('updateEstimatePendingCount', this.estimateSocketCallback)
|
||||
|
||||
// 监听EventBus事件 - 查勘跟进中数量
|
||||
this.surveyEventBusCallback = (count) => {
|
||||
this.$set(this, 'surveyFollowCount', count)
|
||||
}
|
||||
this.surveySocketCallback = (data) => {
|
||||
console.log('=== 查勘WebSocket事件 ===', data)
|
||||
if (data && data.refresh) {
|
||||
// 收到刷新事件,主动重新获取查勘数量
|
||||
console.log('收到查勘刷新事件,主动获取查勘数量')
|
||||
this.fetchSurveyFollowCount()
|
||||
} else if (data && data.count !== undefined) {
|
||||
// 直接更新数量(兼容旧的推送格式)
|
||||
console.log('收到查勘数量更新:', data.count)
|
||||
this.$set(this, 'surveyFollowCount', data.count)
|
||||
}
|
||||
}
|
||||
EventBus.$on('updateSurveyFollowCount', this.surveyEventBusCallback)
|
||||
socket.on('updateSurveyFollowCount', this.surveySocketCallback)
|
||||
|
||||
// 监听EventBus事件 - 报告制作数量
|
||||
this.reportEventBusCallback = (counts) => {
|
||||
console.log('=== 报告EventBus事件 ===', counts)
|
||||
this.$set(this, 'reportProduceCounts', counts)
|
||||
}
|
||||
this.reportSocketCallback = (data) => {
|
||||
console.log('=== 报告WebSocket事件 ===', data)
|
||||
if (data && data.refresh) {
|
||||
// 收到刷新事件,主动获取数据
|
||||
this.fetchReportCount()
|
||||
} else if (data && data.counts !== undefined) {
|
||||
this.$set(this, 'reportProduceCounts', data.counts)
|
||||
}
|
||||
}
|
||||
EventBus.$on('updateReportProduceCount', this.reportEventBusCallback)
|
||||
socket.on('updateReportProduceCount', this.reportSocketCallback)
|
||||
},
|
||||
beforeDestroy() {
|
||||
EventBus.$off('updateUnreturnedCount', this.eventBusCallback)
|
||||
socket.off('updateUnreturnedCount', this.socketCallback)
|
||||
EventBus.$off('updateEstimatePendingCount', this.estimateEventBusCallback)
|
||||
socket.off('updateEstimatePendingCount', this.estimateSocketCallback)
|
||||
EventBus.$off('updateSurveyFollowCount', this.surveyEventBusCallback)
|
||||
socket.off('updateSurveyFollowCount', this.surveySocketCallback)
|
||||
EventBus.$off('updateReportProduceCount', this.reportEventBusCallback)
|
||||
socket.off('updateReportProduceCount', this.reportSocketCallback)
|
||||
},
|
||||
methods: {
|
||||
// 主动获取未回价数量
|
||||
async fetchUnreturnedCount() {
|
||||
try {
|
||||
console.log('开始获取未回价数量...')
|
||||
const res = await getUnreturnedPriceCount()
|
||||
console.log('未回价数量接口返回:', res)
|
||||
if (res && res.code === 1 && res.data) {
|
||||
console.log('未回价数量获取成功:', res.data.count)
|
||||
this.$set(this, 'unreturnedCount', res.data.count)
|
||||
} else {
|
||||
console.log('未回价数量获取失败,响应格式不正确')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取未回价数量失败:', error)
|
||||
}
|
||||
},
|
||||
// 主动获取预估制作数量
|
||||
async fetchEstimateCount() {
|
||||
try {
|
||||
console.log('开始获取预估制作数量...')
|
||||
const res = await getEstimatePendingCount()
|
||||
console.log('预估制作数量接口返回:', res)
|
||||
if (res && res.code === 1 && res.data) {
|
||||
console.log('预估制作数量获取成功:', res.data)
|
||||
this.$set(this, 'estimateCounts', res.data)
|
||||
} else {
|
||||
console.log('预估制作数量获取失败,响应格式不正确')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取预估制作数量失败:', error)
|
||||
}
|
||||
},
|
||||
// 主动获取查勘跟进中数量
|
||||
async fetchSurveyFollowCount() {
|
||||
try {
|
||||
console.log('开始获取查勘跟进中数量...')
|
||||
const res = await getSurveyFollowCount()
|
||||
console.log('查勘跟进中数量接口返回:', res)
|
||||
if (res && res.code === 1 && res.data) {
|
||||
console.log('查勘跟进中数量获取成功:', res.data.count)
|
||||
this.$set(this, 'surveyFollowCount', res.data.count)
|
||||
} else {
|
||||
console.log('查勘跟进中数量获取失败,响应格式不正确')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取查勘跟进中数量失败:', error)
|
||||
}
|
||||
},
|
||||
// 主动获取报告制作数量
|
||||
async fetchReportCount() {
|
||||
try {
|
||||
console.log('===== 开始获取报告制作数量 =====')
|
||||
const res = await getReportProduceCount()
|
||||
console.log('报告制作数量接口返回:', JSON.stringify(res, null, 2))
|
||||
if (res && res.code === 1 && res.data) {
|
||||
const data = res.data
|
||||
console.log('===== 报告制作数量统计 =====')
|
||||
console.log('待制作数量:', data.pending)
|
||||
console.log('二审待制作数量:', data.secondReview)
|
||||
console.log('三审待制作数量:', data.thirdReview)
|
||||
console.log('总数:', data.total)
|
||||
console.log('============================')
|
||||
this.$set(this, 'reportProduceCounts', data)
|
||||
} else {
|
||||
console.log('报告制作数量获取失败,响应格式不正确')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取报告制作数量失败:', error)
|
||||
}
|
||||
},
|
||||
isHuiJiaMenu(menuItem) {
|
||||
return menuItem.title === '回价项目' || menuItem.routerName === 'priceReturn'
|
||||
return menuItem.title === '回价项目' || menuItem.title === '回价' || menuItem.routerName === 'priceReturn'
|
||||
},
|
||||
isEstimateMenu(menuItem) {
|
||||
return menuItem.title === '预估项目' || menuItem.routerName === 'estimate' || menuItem.name === 'estimate'
|
||||
},
|
||||
isSurveyMenu(menuItem) {
|
||||
return menuItem.title === '查勘' || menuItem.title === '查勘项目' || menuItem.routerName === 'survey' || menuItem.name === 'survey'
|
||||
},
|
||||
isReportMenu(menuItem) {
|
||||
return menuItem.title === '报告' || menuItem.routerName === 'report' || menuItem.name === 'report'
|
||||
},
|
||||
handleSelect(key, item , externalInfo ) {
|
||||
this.$emit('menu-select', key, item.routerName, externalInfo);
|
||||
|
||||
@@ -5,10 +5,22 @@
|
||||
<el-submenu style="height: 100%;" v-if="item.children && item.children.length > 0" :index="item.routerName" >
|
||||
<template slot="title">
|
||||
{{ item.title }}
|
||||
<!-- 一级菜单【回价】显示无数量红点 -->
|
||||
<span v-if="isHuiJiaMenu && unreturnedCount >= 1" class="push-dot-badge"></span>
|
||||
<!-- 二级菜单【未回价】显示带数量红点 -->
|
||||
<span v-else-if="isUnreturnedPriceMenu && unreturnedCount > 0" class="push-value-badge">{{ unreturnedCount }}</span>
|
||||
<!-- 一级菜单【回价项目】显示未回价数量 -->
|
||||
<!-- <span v-if="isHuiJiaMenu && unreturnedCount > 0" class="push-value-badge">{{ unreturnedCount }}</span> -->
|
||||
<!-- 二级菜单【未回价】显示未回价数量 -->
|
||||
<span v-if="isUnreturnedPriceMenu && unreturnedCount > 0" class="push-value-badge">{{ unreturnedCount }}</span>
|
||||
<!-- 一级菜单【预估】显示预估总数 -->
|
||||
<!-- <span v-if="isEstimateMenu && estimateCounts.total > 0" class="push-value-badge">{{ estimateCounts.total }}</span> -->
|
||||
<!-- 二级菜单【预估单】显示预估总数 -->
|
||||
<span v-if="isEstimatePendingMenu && estimateCounts.total > 0" class="push-value-badge">{{ estimateCounts.total }}</span>
|
||||
<!-- 一级菜单【查勘项目】显示查勘跟进中数量 -->
|
||||
<!-- <span v-if="isSurveyMenu && surveyFollowCount > 0" class="push-value-badge">{{ surveyFollowCount }}</span> -->
|
||||
<!-- 二级菜单【查勘列表】显示查勘跟进中数量 -->
|
||||
<span v-if="isSurveyListMenu && surveyFollowCount > 0" class="push-value-badge">{{ surveyFollowCount }}</span>
|
||||
<!-- 一级菜单【报告项目】显示报告总数 -->
|
||||
<!-- <span v-if="isReportMenu && reportProduceCounts.total > 0" class="push-value-badge">{{ reportProduceCounts.total }}</span> -->
|
||||
<!-- 二级菜单【报告制作】显示报告总数 -->
|
||||
<span v-if="isReportProduceMenu && reportProduceCounts.total > 0" class="push-value-badge">{{ reportProduceCounts.total }}</span>
|
||||
</template>
|
||||
<!-- 递归调用MenuItem组件 -->
|
||||
<menu-item v-for="(child, index) in item.children" :key="index" :item="child" class="menu-custom"></menu-item>
|
||||
@@ -16,10 +28,25 @@
|
||||
|
||||
<!-- 如果没有子菜单,则渲染菜单项 -->
|
||||
<el-menu-item v-else :index="item.routerName" class="menu-custom">
|
||||
<!-- <i class="el-icon-document"></i> -->
|
||||
{{ item.title }}
|
||||
<!-- 三级菜单【未回价列表】显示带数量红点 -->
|
||||
<!-- 三级菜单【未回价列表】显示未回价数量 -->
|
||||
<span v-if="isUnreturnedPriceListMenu && unreturnedCount > 0" class="push-value-badge">{{ unreturnedCount }}</span>
|
||||
<!-- 三级菜单【待制作】(预估)显示预估待制作数量 -->
|
||||
<span v-if="isEstimatePendingListMenu && estimateCounts.pending > 0" class="push-value-badge">{{ estimateCounts.pending }}</span>
|
||||
<!-- 三级菜单【二审待制作】(预估)显示预估二审数量 -->
|
||||
<span v-if="isSecondReviewListMenu && estimateCounts.secondReview > 0" class="push-value-badge">{{ estimateCounts.secondReview }}</span>
|
||||
<!-- 三级菜单【三审待制作】(预估)显示预估三审数量 -->
|
||||
<span v-if="isThirdReviewListMenu && estimateCounts.thirdReview > 0" class="push-value-badge">{{ estimateCounts.thirdReview }}</span>
|
||||
<!-- 三级菜单【待签章】(预估)显示预估待签章数量 -->
|
||||
<span v-if="isSignListMenu && estimateCounts.sign > 0" class="push-value-badge">{{ estimateCounts.sign }}</span>
|
||||
<!-- 三级菜单【跟进中】(查勘)显示查勘跟进中数量 -->
|
||||
<span v-if="isSurveyFollowMenu && surveyFollowCount > 0" class="push-value-badge">{{ surveyFollowCount }}</span>
|
||||
<!-- 三级菜单【待制作】(报告)显示报告待制作数量 -->
|
||||
<span v-if="isReportPendingMenu && reportProduceCounts.pending > 0" class="push-value-badge">{{ reportProduceCounts.pending }}</span>
|
||||
<!-- 三级菜单【二审待制作】(报告)显示报告二审待制作数量 -->
|
||||
<span v-if="isReportSecondReviewMenu && reportProduceCounts.secondReview > 0" class="push-value-badge">{{ reportProduceCounts.secondReview }}</span>
|
||||
<!-- 三级菜单【三审待制作】(报告)显示报告三审待制作数量 -->
|
||||
<span v-if="isReportThirdReviewMenu && reportProduceCounts.thirdReview > 0" class="push-value-badge">{{ reportProduceCounts.thirdReview }}</span>
|
||||
</el-menu-item>
|
||||
</div>
|
||||
</template>
|
||||
@@ -28,6 +55,8 @@
|
||||
import "@/styles/globalSetting.less";
|
||||
import { EventBus } from '@/libs/eventBus'
|
||||
import socket from '@/libs/socket'
|
||||
import { post } from '@/libs/request'
|
||||
import { getEstimatePendingCount, getSurveyFollowCount, getReportProduceCount } from '@/api/businessManage/inquiry'
|
||||
export default {
|
||||
name: 'MenuItem',
|
||||
props: {
|
||||
@@ -35,28 +64,144 @@
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
unreturnedCount: 0
|
||||
unreturnedCount: 0,
|
||||
estimateCounts: {
|
||||
pending: 0,
|
||||
secondReview: 0,
|
||||
thirdReview: 0,
|
||||
sign: 0,
|
||||
total: 0
|
||||
},
|
||||
surveyFollowCount: 0,
|
||||
reportProduceCounts: {
|
||||
pending: 0,
|
||||
secondReview: 0,
|
||||
thirdReview: 0,
|
||||
total: 0
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
// ==================== 回价项目 ====================
|
||||
// 判断是否是一级菜单【回价项目】
|
||||
isHuiJiaMenu() {
|
||||
const isMatch = this.item.title === '回价项目' || this.item.routerName === 'priceReturn'
|
||||
return isMatch
|
||||
return this.item.routerName === 'priceReturn' || this.item.title === '回价项目'
|
||||
},
|
||||
// 判断是否是二级菜单【未回价】
|
||||
isUnreturnedPriceMenu() {
|
||||
const isMatch = this.item.path === '/priceReturn/unreturnedPrice' || this.item.title === '未回价' || this.item.routerName === 'unreturnedPrice'
|
||||
return isMatch
|
||||
return this.item.routerName === 'unreturnedPrice' || this.item.title === '未回价'
|
||||
},
|
||||
// 判断是否是三级菜单【未回价列表】
|
||||
// 判断是否是三级菜单【未回价列表】- 使用routerName唯一标识
|
||||
isUnreturnedPriceListMenu() {
|
||||
const isMatch = this.item.title === '未回价列表'
|
||||
return isMatch
|
||||
return this.item.routerName && this.item.routerName.includes('unreturnedPrice') ||
|
||||
this.item.title === '未回价列表'
|
||||
},
|
||||
|
||||
// ==================== 预估项目 ====================
|
||||
// 判断是否是一级菜单【预估】- 只有当不是预估单时才匹配
|
||||
isEstimateMenu() {
|
||||
return (this.item.routerName === 'estimate' || this.item.title === '预估') &&
|
||||
!this.isEstimatePendingMenu
|
||||
},
|
||||
// 判断是否是二级菜单【预估单】
|
||||
isEstimatePendingMenu() {
|
||||
return this.item.routerName === 'estimateMake-estimate' || this.item.title === '预估单'
|
||||
},
|
||||
// 判断是否是三级菜单【待制作】(预估)-使用routerName区分,避免与报告制作下的待制作混淆
|
||||
isEstimatePendingListMenu() {
|
||||
return this.item.routerName === 'estimateMake-estimateWaitMakeList' ||
|
||||
this.item.routerName && this.item.routerName.includes('estimateWaitMakeList')
|
||||
},
|
||||
// 判断是否是三级菜单【二审待制作】(预估)-使用routerName区分
|
||||
isSecondReviewListMenu() {
|
||||
return this.item.routerName === 'estimateMake-estimateWaitMakeApprovalList' ||
|
||||
this.item.routerName && this.item.routerName.includes('estimateWaitMakeApprovalList')
|
||||
},
|
||||
// 判断是否是三级菜单【三审待制作】(预估)-使用routerName区分
|
||||
isThirdReviewListMenu() {
|
||||
return this.item.routerName === 'estimateMake-estimateWaitMakeApprovalThirdList' ||
|
||||
this.item.routerName && this.item.routerName.includes('estimateWaitMakeApprovalThirdList')
|
||||
},
|
||||
// 判断是否是三级菜单【待签章】(预估)
|
||||
isSignListMenu() {
|
||||
return this.item.routerName === 'estimateMake-estimateWaitSignSignList' ||
|
||||
this.item.routerName && this.item.routerName.includes('estimateWaitSignSignList') ||
|
||||
this.item.title === '待签章'
|
||||
},
|
||||
|
||||
// ==================== 查勘项目 ====================
|
||||
// 判断是否是一级菜单【查勘项目】
|
||||
isSurveyMenu() {
|
||||
return this.item.routerName === 'surveyManage-surveyManage' ||
|
||||
this.item.routerName === 'survey' ||
|
||||
this.item.title === '查勘项目' ||
|
||||
this.item.title === '查勘'
|
||||
},
|
||||
// 判断是否是二级菜单【查勘列表】
|
||||
isSurveyListMenu() {
|
||||
return this.item.routerName && this.item.routerName.startsWith('surveyManage-') ||
|
||||
this.item.title === '查勘列表'
|
||||
},
|
||||
// 判断是否是三级菜单【跟进中】(查勘)-使用routerName确保是查勘模块下的
|
||||
isSurveyFollowMenu() {
|
||||
return this.item.routerName === 'surveyManage-surveyWaitFollowList' ||
|
||||
(this.item.title === '跟进中' && this.item.routerName && this.item.routerName.includes('survey'))
|
||||
},
|
||||
|
||||
// ==================== 报告项目 ====================
|
||||
// 判断是否是一级菜单【报告项目】
|
||||
// isReportMenu() {
|
||||
// return this.item.routerName === 'report' ||
|
||||
// this.item.title === '报告项目' ||
|
||||
// this.item.title === '报告制作'
|
||||
// },
|
||||
// 判断是否是二级菜单【报告制作】
|
||||
isReportProduceMenu() {
|
||||
return this.item.routerName && this.item.routerName.startsWith('report-') ||
|
||||
this.item.title === '报告制作'
|
||||
},
|
||||
// 判断是否是三级菜单【待制作】(报告)-使用routerName区分,避免与预估单下的待制作混淆
|
||||
isReportPendingMenu() {
|
||||
return this.item.routerName === 'waitMake'
|
||||
},
|
||||
// 判断是否是三级菜单【二审待制作】(报告)-使用routerName区分
|
||||
isReportSecondReviewMenu() {
|
||||
return this.item.routerName === 'waitApproval'
|
||||
},
|
||||
// 判断是否是三级菜单【三审待制作】(报告)-使用routerName区分
|
||||
isReportThirdReviewMenu() {
|
||||
return this.item.routerName === 'waitApprovalThird'
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
console.log('菜单组件mounted - item:', this.item)
|
||||
// 获取所有数据,确保每个菜单项都能显示正确的数值
|
||||
// 回价相关菜单
|
||||
// if (this.isHuiJiaMenu || this.isUnreturnedPriceMenu || this.isUnreturnedPriceListMenu) {
|
||||
this.fetchUnreturnedCount()
|
||||
// }
|
||||
// 预估相关菜单 - 包含预估模块下的所有菜单
|
||||
// if (this.isEstimateMenu || this.isEstimatePendingMenu || this.isEstimatePendingListMenu || this.isSecondReviewListMenu || this.isThirdReviewListMenu || this.isSignListMenu ||
|
||||
// this.item.title === '预估' || this.item.title === '预估单' ||
|
||||
// (this.item.title === '待制作' && this.item.parentName === '预估单') ||
|
||||
// (this.item.title && this.item.title.includes('二审') && this.item.parentName === '预估单') ||
|
||||
// (this.item.title && this.item.title.includes('三审') && this.item.parentName === '预估单') ||
|
||||
// this.item.title === '待签章') {
|
||||
this.fetchEstimateCount()
|
||||
// }
|
||||
// 查勘相关菜单 - 包含查勘模块下的所有菜单
|
||||
// if (this.isSurveyMenu || this.isSurveyListMenu || this.isSurveyFollowMenu ||
|
||||
// this.item.title === '查勘项目' || this.item.title === '查勘' ||
|
||||
// this.item.title === '查勘列表' || this.item.title === '跟进中') {
|
||||
this.fetchSurveyFollowCount()
|
||||
// }
|
||||
// 报告相关菜单 - 包含报告模块下的所有菜单
|
||||
// if (this.isReportMenu || this.isReportProduceMenu || this.isReportPendingMenu || this.isReportSecondReviewMenu || this.isReportThirdReviewMenu ||
|
||||
// this.item.title === '报告项目' || this.item.title === '报告制作' ||
|
||||
// (this.item.title === '待制作' && this.item.parentName === '报告制作') ||
|
||||
// (this.item.title && this.item.title.includes('二审') && this.item.parentName === '报告制作') ||
|
||||
// (this.item.title && this.item.title.includes('三审') && this.item.parentName === '报告制作')) {
|
||||
this.fetchReportCount()
|
||||
// }
|
||||
|
||||
// 保存回调引用用于销毁时移除
|
||||
this.eventBusCallback = (count) => {
|
||||
@@ -65,23 +210,135 @@
|
||||
}
|
||||
|
||||
this.socketCallback = (data) => {
|
||||
if (data && data.count !== undefined) {
|
||||
// 使用Vue.set确保响应式更新
|
||||
if (data && data.refresh) {
|
||||
// 收到刷新事件,只有回价相关菜单才主动获取数据
|
||||
if (this.isHuiJiaMenu || this.isUnreturnedPriceMenu || this.isUnreturnedPriceListMenu) {
|
||||
this.fetchUnreturnedCount()
|
||||
}
|
||||
} else if (data && data.count !== undefined) {
|
||||
this.$set(this, 'unreturnedCount', data.count)
|
||||
console.log('WebSocket收到未回价数量更新:', data.count, '当前item:', this.item.name || this.item.title)
|
||||
}
|
||||
}
|
||||
|
||||
// 监听EventBus事件(页面初始化时)
|
||||
EventBus.$on('updateUnreturnedCount', this.eventBusCallback)
|
||||
// 预估制作数量回调
|
||||
this.estimateEventBusCallback = (counts) => {
|
||||
this.$set(this, 'estimateCounts', counts)
|
||||
}
|
||||
|
||||
// 监听WebSocket推送的未回价数量更新
|
||||
this.estimateSocketCallback = (data) => {
|
||||
if (data && data.refresh) {
|
||||
// 收到刷新事件,只有预估相关菜单才主动获取数据
|
||||
if (this.isEstimateMenu || this.isEstimatePendingMenu || this.isEstimatePendingListMenu || this.isSecondReviewListMenu || this.isThirdReviewListMenu || this.isSignListMenu) {
|
||||
this.fetchEstimateCount()
|
||||
}
|
||||
} else if (data && data.pending !== undefined) {
|
||||
this.$set(this, 'estimateCounts', data)
|
||||
console.log('WebSocket收到预估制作数量更新:', data, '当前item:', this.item.name || this.item.title)
|
||||
}
|
||||
}
|
||||
|
||||
// 查勘跟进中数量回调
|
||||
this.surveyEventBusCallback = (count) => {
|
||||
this.$set(this, 'surveyFollowCount', count)
|
||||
}
|
||||
|
||||
this.surveySocketCallback = (data) => {
|
||||
if (data && data.refresh) {
|
||||
// 收到刷新事件,只有查勘相关菜单才主动获取数据
|
||||
if (this.isSurveyMenu || this.isSurveyListMenu || this.isSurveyFollowMenu) {
|
||||
this.fetchSurveyFollowCount()
|
||||
}
|
||||
} else if (data && data.count !== undefined) {
|
||||
this.$set(this, 'surveyFollowCount', data.count)
|
||||
console.log('WebSocket收到查勘跟进中数量更新:', data.count, '当前item:', this.item.name || this.item.title)
|
||||
}
|
||||
}
|
||||
|
||||
// 报告制作数量回调
|
||||
this.reportEventBusCallback = (counts) => {
|
||||
this.$set(this, 'reportProduceCounts', counts)
|
||||
}
|
||||
|
||||
this.reportSocketCallback = (data) => {
|
||||
if (data && data.refresh) {
|
||||
// 收到刷新事件,只有报告相关菜单才主动获取数据
|
||||
if (this.isReportMenu || this.isReportProduceMenu || this.isReportPendingMenu || this.isReportSecondReviewMenu || this.isReportThirdReviewMenu) {
|
||||
this.fetchReportCount()
|
||||
}
|
||||
} else if (data && data.pending !== undefined) {
|
||||
this.$set(this, 'reportProduceCounts', data)
|
||||
}
|
||||
}
|
||||
|
||||
// 监听EventBus事件
|
||||
EventBus.$on('updateUnreturnedCount', this.eventBusCallback)
|
||||
EventBus.$on('updateEstimatePendingCount', this.estimateEventBusCallback)
|
||||
EventBus.$on('updateSurveyFollowCount', this.surveyEventBusCallback)
|
||||
EventBus.$on('updateReportProduceCount', this.reportEventBusCallback)
|
||||
|
||||
// 监听WebSocket事件
|
||||
socket.on('updateUnreturnedCount', this.socketCallback)
|
||||
socket.on('updateEstimatePendingCount', this.estimateSocketCallback)
|
||||
socket.on('updateSurveyFollowCount', this.surveySocketCallback)
|
||||
socket.on('updateReportProduceCount', this.reportSocketCallback)
|
||||
},
|
||||
beforeDestroy() {
|
||||
// 移除监听
|
||||
EventBus.$off('updateUnreturnedCount', this.eventBusCallback)
|
||||
socket.off('updateUnreturnedCount', this.socketCallback)
|
||||
EventBus.$off('updateEstimatePendingCount', this.estimateEventBusCallback)
|
||||
socket.off('updateEstimatePendingCount', this.estimateSocketCallback)
|
||||
EventBus.$off('updateSurveyFollowCount', this.surveyEventBusCallback)
|
||||
socket.off('updateSurveyFollowCount', this.surveySocketCallback)
|
||||
EventBus.$off('updateReportProduceCount', this.reportEventBusCallback)
|
||||
socket.off('updateReportProduceCount', this.reportSocketCallback)
|
||||
},
|
||||
methods: {
|
||||
async fetchUnreturnedCount() {
|
||||
try {
|
||||
const res = await post('admin/Pending/getUnreturnedPriceCount')
|
||||
if (res && res.code === 1 && res.data) {
|
||||
this.$set(this, 'unreturnedCount', res.data.count)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取未回价数量失败:', error)
|
||||
}
|
||||
},
|
||||
async fetchEstimateCount() {
|
||||
try {
|
||||
const res = await getEstimatePendingCount()
|
||||
if (res && res.code === 1 && res.data) {
|
||||
this.$set(this, 'estimateCounts', res.data)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取预估数量失败:', error)
|
||||
}
|
||||
},
|
||||
async fetchSurveyFollowCount() {
|
||||
try {
|
||||
const res = await getSurveyFollowCount()
|
||||
if (res && res.code === 1 && res.data) {
|
||||
this.$set(this, 'surveyFollowCount', res.data.count)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取查勘跟进中数量失败:', error)
|
||||
}
|
||||
},
|
||||
async fetchReportCount() {
|
||||
try {
|
||||
console.log('===== nxMenu 获取报告制作数量 =====')
|
||||
const res = await getReportProduceCount()
|
||||
console.log('报告制作数量接口返回:', JSON.stringify(res, null, 2))
|
||||
if (res && res.code === 1 && res.data) {
|
||||
const data = res.data
|
||||
console.log('待制作:', data.pending, '二审:', data.secondReview, '三审:', data.thirdReview, '总数:', data.total)
|
||||
this.$set(this, 'reportProduceCounts', data)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取报告制作数量失败:', error)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -117,4 +374,4 @@
|
||||
margin-left: 8px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
42
pgweb/src/libs/estimatePending.js
Normal file
42
pgweb/src/libs/estimatePending.js
Normal file
@@ -0,0 +1,42 @@
|
||||
import { EventBus } from './eventBus'
|
||||
import { getEstimatePendingCount } from '@/api/businessManage/inquiry'
|
||||
|
||||
/**
|
||||
* 获取并更新所有预估状态数量
|
||||
* 调用API获取最新数量,并通过EventBus广播给所有监听者
|
||||
*/
|
||||
export const fetchAndUpdateEstimatePendingCount = async () => {
|
||||
console.log('fetchAndUpdateEstimatePendingCount: 开始获取预估状态数量...')
|
||||
try {
|
||||
const response = await getEstimatePendingCount()
|
||||
console.log('fetchAndUpdateEstimatePendingCount: 接口返回完整数据:', response)
|
||||
if (response && response.code === 1) {
|
||||
const data = response.data || {}
|
||||
const pending = data.pending || 0
|
||||
const secondReview = data.secondReview || 0
|
||||
const thirdReview = data.thirdReview || 0
|
||||
const sign = data.sign || 0
|
||||
const total = data.total || 0
|
||||
|
||||
console.log('fetchAndUpdateEstimatePendingCount: 获取到预估状态数量:', { pending, secondReview, thirdReview, sign, total })
|
||||
console.log('fetchAndUpdateEstimatePendingCount: 调试数据:', data.debug || '无')
|
||||
|
||||
// 通过事件总线传递数量给菜单组件
|
||||
EventBus.$emit('updateEstimatePendingCount', {
|
||||
pending,
|
||||
secondReview,
|
||||
thirdReview,
|
||||
sign,
|
||||
total
|
||||
})
|
||||
|
||||
return { pending, secondReview, thirdReview, sign, total }
|
||||
} else {
|
||||
console.warn('fetchAndUpdateEstimatePendingCount: 接口返回异常:', response)
|
||||
return { pending: 0, secondReview: 0, thirdReview: 0, sign: 0, total: 0 }
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('fetchAndUpdateEstimatePendingCount: 获取预估状态数量失败:', error)
|
||||
return { pending: 0, secondReview: 0, thirdReview: 0, sign: 0, total: 0 }
|
||||
}
|
||||
}
|
||||
@@ -19,10 +19,14 @@ const socket = io(process.env.VUE_APP_SOCKET_URL, {
|
||||
// 添加连接状态监听
|
||||
socket.on('connect', () => {
|
||||
console.log('WebSocket已成功连接到服务器:', process.env.VUE_APP_SOCKET_URL)
|
||||
// 连接成功后启动定时轮询
|
||||
startPolling()
|
||||
})
|
||||
|
||||
socket.on('disconnect', (reason) => {
|
||||
console.log('WebSocket连接断开,原因:', reason)
|
||||
// 断开连接后停止定时轮询
|
||||
stopPolling()
|
||||
})
|
||||
|
||||
socket.on('connect_error', (error) => {
|
||||
@@ -33,6 +37,30 @@ socket.on('connect_timeout', () => {
|
||||
console.error('WebSocket连接超时')
|
||||
})
|
||||
|
||||
// 定时轮询定时器
|
||||
let pollingTimer = null
|
||||
|
||||
// 启动定时轮询(每10秒)
|
||||
function startPolling() {
|
||||
if (pollingTimer) {
|
||||
clearInterval(pollingTimer)
|
||||
}
|
||||
pollingTimer = setInterval(() => {
|
||||
// 触发刷新事件,让客户端主动获取最新数据
|
||||
socket.emit('refreshAllCounts')
|
||||
}, 10000) // 每10秒刷新一次
|
||||
console.log('定时轮询已启动,每5秒刷新一次')
|
||||
}
|
||||
|
||||
// 停止定时轮询
|
||||
function stopPolling() {
|
||||
if (pollingTimer) {
|
||||
clearInterval(pollingTimer)
|
||||
pollingTimer = null
|
||||
}
|
||||
console.log('定时轮询已停止')
|
||||
}
|
||||
|
||||
// 连接方法
|
||||
export const connectSocket = () => {
|
||||
console.log('尝试启动WebSocket连接...')
|
||||
|
||||
@@ -7,6 +7,7 @@ import * as localStore from 'store'
|
||||
import store from '@/store'
|
||||
import { connectSocket } from '@/libs/socket'
|
||||
import { fetchAndUpdateUnreturnedPriceCount } from '@/libs/unreturnedPrice'
|
||||
import { fetchAndUpdateEstimatePendingCount } from '@/libs/estimatePending'
|
||||
|
||||
Vue.use(Router)
|
||||
let routers = routes
|
||||
@@ -33,11 +34,13 @@ router.beforeEach((to, from, next) => {
|
||||
iView.LoadingBar.start()
|
||||
const token = getToken()
|
||||
|
||||
// 如果用户已登录,确保WebSocket连接已建立并获取最新未回价数量
|
||||
// 如果用户已登录,确保WebSocket连接已建立并获取最新数量
|
||||
if (token && to.name !== LOGIN_PAGE_NAME) {
|
||||
connectSocket()
|
||||
// 每次刷新页面都获取最新的未回价数量
|
||||
fetchAndUpdateUnreturnedPriceCount()
|
||||
// 获取预估制作数量
|
||||
fetchAndUpdateEstimatePendingCount()
|
||||
}
|
||||
|
||||
if (!token && to.name !== LOGIN_PAGE_NAME) {
|
||||
|
||||
@@ -675,6 +675,9 @@ import{
|
||||
getReportObjTypeList
|
||||
} from '@/api/report.js'
|
||||
|
||||
import { EventBus } from '@/libs/eventBus'
|
||||
import { getSurveyFollowCount } from '@/api/businessManage/inquiry'
|
||||
|
||||
import {
|
||||
reqBankList,
|
||||
getProduct,
|
||||
@@ -2390,11 +2393,26 @@ export default {
|
||||
|
||||
// init data
|
||||
this.initData()
|
||||
|
||||
// 刷新查勘跟进中数量
|
||||
this.refreshSurveyFollowCount()
|
||||
} else {
|
||||
this.$Message.error(res.msg)
|
||||
}
|
||||
})
|
||||
},
|
||||
// 刷新查勘跟进中数量
|
||||
async refreshSurveyFollowCount() {
|
||||
try {
|
||||
const res = await getSurveyFollowCount()
|
||||
if (res && res.code === 1 && res.data) {
|
||||
const count = res.data.count || 0
|
||||
EventBus.$emit('updateSurveyFollowCount', count)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('刷新查勘跟进中数量失败:', error)
|
||||
}
|
||||
},
|
||||
onCancelRejPress () {
|
||||
this.rejectModal = false
|
||||
this.$refs['rejFormRef'].resetFields()
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
import homePage from './components/message'
|
||||
import { connectSocket } from '@/libs/socket'
|
||||
import { EventBus } from '@/libs/eventBus'
|
||||
import { getUnreturnedPriceCount } from '@/api/businessManage/inquiry'
|
||||
import { getUnreturnedPriceCount, getEstimatePendingCount, getSurveyFollowCount } from '@/api/businessManage/inquiry'
|
||||
export default {
|
||||
components: { homePage },
|
||||
mounted() {
|
||||
@@ -35,6 +35,10 @@ export default {
|
||||
|
||||
// 获取未回价数量
|
||||
this.getUnreturnedPriceCountData()
|
||||
// 获取预估制作数量
|
||||
this.getEstimatePendingCountData()
|
||||
// 获取查勘跟进中数量
|
||||
this.getSurveyFollowCountData()
|
||||
},
|
||||
methods: {
|
||||
// 获取未回价数量
|
||||
@@ -50,6 +54,41 @@ export default {
|
||||
} catch (error) {
|
||||
console.error('获取未回价数量失败:', error)
|
||||
}
|
||||
},
|
||||
// 获取预估制作数量
|
||||
async getEstimatePendingCountData() {
|
||||
try {
|
||||
const response = await getEstimatePendingCount()
|
||||
if (response && response.code === 1) {
|
||||
const data = response.data || {}
|
||||
const counts = {
|
||||
pending: data.pending || 0,
|
||||
secondReview: data.secondReview || 0,
|
||||
thirdReview: data.thirdReview || 0,
|
||||
sign: data.sign || 0,
|
||||
total: data.total || 0
|
||||
}
|
||||
console.log('预估制作数量:', counts)
|
||||
// 通过事件总线传递数量给菜单组件
|
||||
EventBus.$emit('updateEstimatePendingCount', counts)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取预估制作数量失败:', error)
|
||||
}
|
||||
},
|
||||
// 获取查勘跟进中数量
|
||||
async getSurveyFollowCountData() {
|
||||
try {
|
||||
const response = await getSurveyFollowCount()
|
||||
if (response && response.code === 1) {
|
||||
const count = response.data.count || 0
|
||||
console.log('查勘跟进中数量:', count)
|
||||
// 通过事件总线传递数量给菜单组件
|
||||
EventBus.$emit('updateSurveyFollowCount', count)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取查勘跟进中数量失败:', error)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,8 +160,10 @@ import {
|
||||
reqBankList,
|
||||
getProduct,
|
||||
consultFiles,
|
||||
getSurveyFollowCount
|
||||
} from '@/api/businessManage/inquiry'
|
||||
import { reqDistrict } from '@/api/basicData'
|
||||
import { EventBus } from '@/libs/eventBus'
|
||||
import search from '@/mixins/search'
|
||||
import { getRole } from '@/api/surveyManage'
|
||||
import { getNowFormatDate } from '@/libs/tools'
|
||||
@@ -1783,11 +1785,26 @@ export default {
|
||||
|
||||
// init data
|
||||
this.initData()
|
||||
|
||||
// 刷新查勘跟进中数量
|
||||
this.refreshSurveyFollowCount()
|
||||
} else {
|
||||
this.$Message.error(res.msg)
|
||||
}
|
||||
})
|
||||
},
|
||||
// 刷新查勘跟进中数量
|
||||
async refreshSurveyFollowCount() {
|
||||
try {
|
||||
const res = await getSurveyFollowCount()
|
||||
if (res && res.code === 1 && res.data) {
|
||||
const count = res.data.count || 0
|
||||
EventBus.$emit('updateSurveyFollowCount', count)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('刷新查勘跟进中数量失败:', error)
|
||||
}
|
||||
},
|
||||
onCancelRejPress () {
|
||||
this.rejectModal = false
|
||||
this.$refs['rejFormRef'].resetFields()
|
||||
|
||||
Reference in New Issue
Block a user