|
@@ -47,6 +47,7 @@
|
|
<script setup>
|
|
<script setup>
|
|
import { nextTick, onMounted, ref, watch } from 'vue'
|
|
import { nextTick, onMounted, ref, watch } from 'vue'
|
|
import { useAppStore } from '~src/store'
|
|
import { useAppStore } from '~src/store'
|
|
|
|
+import { getToken } from '~src/api/auth'
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
import { initButtons } from '~sto/app'
|
|
import { initButtons } from '~sto/app'
|
|
import { isNullES } from 'js-fast-way'
|
|
import { isNullES } from 'js-fast-way'
|
|
@@ -134,12 +135,19 @@ const msgCount = ref({
|
|
})
|
|
})
|
|
|
|
|
|
//项目合同段的ID
|
|
//项目合同段的ID
|
|
-let times
|
|
|
|
|
|
+let times = ref()
|
|
const cascaderSend = async ({ projectId, contractId }) => {
|
|
const cascaderSend = async ({ projectId, contractId }) => {
|
|
- if (isNullES(contractId)) clearInterval(times)
|
|
|
|
|
|
+ //合同段id为空,清空定时器
|
|
|
|
+ if (isNullES(contractId)) {
|
|
|
|
+ if (!isNullES(times.value)) clearInterval(times.value)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ //先获取一次
|
|
await getUnreadMessage({ projectId, contractId })
|
|
await getUnreadMessage({ projectId, contractId })
|
|
- if (!isNullES(times)) clearInterval(times)
|
|
|
|
- times = setInterval(async () => {
|
|
|
|
|
|
+ //切换项目合同段时,先清空轮询
|
|
|
|
+ if (!isNullES(times.value)) clearInterval(times.value)
|
|
|
|
+ //定时轮询获取数据
|
|
|
|
+ times.value = setInterval(async () => {
|
|
await getUnreadMessage({ projectId, contractId })
|
|
await getUnreadMessage({ projectId, contractId })
|
|
}, 10000)
|
|
}, 10000)
|
|
}
|
|
}
|
|
@@ -147,6 +155,12 @@ const cascaderSend = async ({ projectId, contractId }) => {
|
|
//获取未读消息数量
|
|
//获取未读消息数量
|
|
const taskCount = ref(0)
|
|
const taskCount = ref(0)
|
|
const getUnreadMessage = async ({ projectId, contractId }) => {
|
|
const getUnreadMessage = async ({ projectId, contractId }) => {
|
|
|
|
+ //如果退出登录了,清空轮询
|
|
|
|
+ if (isNullES(getToken())) {
|
|
|
|
+ if (!isNullES(times.value)) clearInterval(times.value)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ //获取数据
|
|
const { data } = await messageApi.getUnreadMessage({
|
|
const { data } = await messageApi.getUnreadMessage({
|
|
projectId, contractId,
|
|
projectId, contractId,
|
|
})
|
|
})
|