Browse Source

工程实验申请单通知开关

master
han\hanst 2 weeks ago
parent
commit
824b10feb3
  1. 75
      src/components/ApprovalNotificationManager.vue
  2. 4
      src/store/modules/user.js
  3. 10
      src/views/main.vue
  4. 2
      src/views/modules/erf/expApplyList.vue

75
src/components/ApprovalNotificationManager.vue

@ -64,11 +64,25 @@ export default {
return this.$store.state.user.site
},
/**
* 工程实验消息通知标志'Y'=启用通知, 'N'=禁用通知
*/
erfMsgFlag() {
return this.$store.state.user.erfMsgFlag
},
/**
* 是否已登录
*/
isLoggedIn() {
return this.currentUserId && this.currentUserId !== 0
},
/**
* 是否需要显示通知已登录且erfMsgFlag='Y'
*/
shouldShowNotification() {
return this.isLoggedIn && this.erfMsgFlag === 'Y'
}
},
@ -77,7 +91,7 @@ export default {
* 监听用户登录状态变化
*/
isLoggedIn(newVal, oldVal) {
console.log(`[审批通知] 登录状态变化: ${oldVal} -> ${newVal}, 已初始化: ${this.isInitialized}`)
console.log(`[审批通知] 登录状态变化: ${oldVal} -> ${newVal}, erfMsgFlag: ${this.erfMsgFlag}, 已初始化: ${this.isInitialized}`)
//
if (oldVal === newVal) {
@ -86,28 +100,59 @@ export default {
}
if (newVal && !this.isInitialized) {
console.log('[审批通知] 用户已登录(watch触发),初始化通知系统')
// mounted
// erfMsgFlag
if (this.erfMsgFlag === 'Y') {
console.log('[审批通知] 用户已登录且启用通知(watch触发),初始化通知系统')
// mounted
this.$nextTick(() => {
if (!this.isInitialized && this.shouldShowNotification) {
this.initializeNotificationSystem()
}
})
} else {
console.log('[审批通知] 用户已登录但未启用通知功能(erfMsgFlag=N),等待erfMsgFlag变化')
}
} else if (!newVal && this.isInitialized) {
console.log('[审批通知] 用户已登出,停止通知系统')
this.stopNotificationSystem()
}
},
/**
* 监听 erfMsgFlag 变化
*/
erfMsgFlag(newVal, oldVal) {
console.log(`[审批通知] erfMsgFlag变化: ${oldVal} -> ${newVal}, 登录状态: ${this.isLoggedIn}, 已初始化: ${this.isInitialized}`)
if (newVal === 'Y' && this.shouldShowNotification && !this.isInitialized) {
// erfMsgFlag 'Y'
console.log('[审批通知] erfMsgFlag启用且用户已登录,初始化通知系统')
this.$nextTick(() => {
if (!this.isInitialized) {
if (!this.isInitialized && this.shouldShowNotification) {
this.initializeNotificationSystem()
}
})
} else if (!newVal && this.isInitialized) {
console.log('[审批通知] 用户已登出,停止通知系统')
} else if (newVal === 'Y' && !this.isLoggedIn) {
// erfMsgFlag 'Y'
console.log('[审批通知] erfMsgFlag启用但用户未登录,等待登录')
} else if (newVal === 'N' && this.isInitialized) {
// erfMsgFlag 'N'
console.log('[审批通知] erfMsgFlag禁用,停止通知系统')
this.stopNotificationSystem()
}
}
},
mounted() {
console.log(`[审批通知] 组件挂载, 登录状态: ${this.isLoggedIn}, 已初始化: ${this.isInitialized}`)
//
console.log(`[审批通知] 组件挂载, 登录状态: ${this.isLoggedIn}, erfMsgFlag: ${this.erfMsgFlag}, 已初始化: ${this.isInitialized}`)
//
// 使
this.$nextTick(() => {
if (this.isLoggedIn && !this.isInitialized) {
if (this.shouldShowNotification && !this.isInitialized) {
console.log('[审批通知] 组件挂载时初始化通知系统')
this.initializeNotificationSystem()
} else if (!this.shouldShowNotification) {
console.log(`[审批通知] 用户未启用通知功能(erfMsgFlag=${this.erfMsgFlag}),不初始化`)
}
})
},
@ -123,6 +168,12 @@ export default {
* 初始化通知系统
*/
initializeNotificationSystem() {
//
if (!this.shouldShowNotification) {
console.log(`[审批通知] 用户未启用通知功能(erfMsgFlag=${this.erfMsgFlag}),跳过初始化`)
return
}
//
if (this.isInitialized) {
console.log('[审批通知] 系统已初始化,跳过重复初始化')
@ -254,6 +305,12 @@ export default {
* @param {boolean} isFirstCheck - 是否首次检查
*/
checkPendingApprovals(isFirstCheck = false) {
//
if (!this.shouldShowNotification) {
console.log(`[审批通知] 用户未启用通知功能(erfMsgFlag=${this.erfMsgFlag}),跳过检查`)
return
}
if (!this.isLoggedIn) {
console.log('[审批通知] 用户未登录,跳过检查')
return

4
src/store/modules/user.js

@ -9,6 +9,7 @@ export default {
userDev: false,
multiLanguage: '',
authControl: '',
erfMsgFlag: 'N', // 工程实验消息通知标志:'Y'=启用通知, 'N'=禁用通知
// favoriteFlag: false,
},
mutations: {
@ -32,6 +33,9 @@ export default {
},
updateAuthControl (state,authControl){
state.authControl = authControl
},
updateErfMsgFlag (state, erfMsgFlag) {
state.erfMsgFlag = erfMsgFlag
}
}
}

10
src/views/main.vue

@ -96,6 +96,14 @@
this.$store.commit('user/updateUserDisplay', val)
}
},
erfMsgFlag: {
get() {
return this.$store.state.user.erfMsgFlag
},
set(val) {
this.$store.commit('user/updateErfMsgFlag', val)
}
},
},
created() {
this.getUserInfo()
@ -126,6 +134,8 @@
this.languageDefault = data.user.languageDefault
this.site = data.user.site
this.userDisplay = data.user.userDisplay
// 'Y'=, 'N'=
this.erfMsgFlag = data.user.erfMsgFlag || 'N'
}
})
},

2
src/views/modules/erf/expApplyList.vue

@ -79,7 +79,7 @@
</el-form-item>
<el-form-item label=" " style="margin-top: -11px">
<el-button @click="openCreateDialog()" type="success" plain class="add-btn">新增申请单</el-button>
<el-button @click="openCreateDialog()" type="success" v-if="isAuth('erf:apply:add')" plain class="add-btn">新增申请单</el-button>
<el-button
@click="deleteApplyFromToolbar()"
:disabled="!currentRow.applyNo || currentRow.status !== '草稿'"

Loading…
Cancel
Save