opt: 字典增加缓存

This commit is contained in:
2025-02-07 16:24:24 +08:00
parent 3ed2f2da5e
commit 6c21c3eb40
8 changed files with 66 additions and 26 deletions

View File

@@ -1,5 +1,5 @@
import Vue from 'vue'
import { get as getDictDetail } from '@/views/system/dict/dictDetail'
import { getDictDetails as getDictDetail } from '@/views/system/dict/dictDetail'
export default class Dict {
constructor(dict) {

View File

@@ -49,4 +49,12 @@ export function edit(data) {
})
}
export default { get, add, edit, del, getDictMap }
export function getDictDetails(data) {
return request({
url: 'api/dict/dictDetail/post',
method: 'post',
data
})
}
export default { get, add, edit, del, getDictMap, getDictDetails }

View File

@@ -1,36 +1,37 @@
<template>
<el-popover
v-model="visible"
placement="top-end"
width="900"
trigger="manual"
v-model="visible">
>
点击信息标识已读
<div style="margin: 5px" v-loading="loading">
<el-tabs v-model="activeName" @tab-click="handleClick" >
<el-tab-pane :label="d.label" :name="d.value" v-for="d in dict.notice_type" :key="d.id" >
<el-empty v-if="notReadMsgList && notReadMsgList[d.value-1] && notReadMsgList[d.value-1].length === 0" description="暂无信息" ></el-empty>
<div v-loading="loading" style="margin: 5px">
<el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane v-for="d in dict.notice_type" :key="d.id" :label="d.label" :name="d.value">
<el-empty v-if="notReadMsgList && notReadMsgList[d.value-1] && notReadMsgList[d.value-1].length === 0" description="暂无信息" />
<div v-for="o in notReadMsgList[d.value-1]" :key="o.notice_id">
<a href="javascript:" @click="showMessage(o)">
<el-row @click="showMessage">
<el-col :span="2">
<el-tag type="danger">{{ dict.label.notice_type[o.notice_type] }}</el-tag>
</el-col>
<el-col :span="15" style="font-weight: bolder">{{o.notice_title}}</el-col>
<el-col :span="7" style="color: #cccccc">{{o.create_time}}</el-col>
<el-col :span="15" style="font-weight: bolder">{{ o.notice_title }}</el-col>
<el-col :span="7" style="color: #cccccc">{{ o.create_time }}</el-col>
</el-row>
<el-divider ></el-divider>
<el-divider />
</a>
</div>
</el-tab-pane>
</el-tabs>
<div style="text-align: right">
<el-button type="text" @click="visible = !visible">取消</el-button>
<el-button type="text" @click="toSiteMessage" >查看更多>></el-button>
<el-button type="text" @click="toSiteMessage">查看更多>></el-button>
</div>
</div>
<span slot="reference" @click="fetchNotice">
<el-badge :value="notReadMsgCount" :hidden="notReadMsgCount==0">
<el-icon class="el-icon-bell" style="font-size: 22px;"></el-icon>
<el-icon class="el-icon-bell" style="font-size: 22px;" />
</el-badge>
</span>
</el-popover>
@@ -57,6 +58,15 @@ export default {
beforeMount() {
this.getMessage()
},
mounted() {
this.getMessage()
this.receivedCount()
this.initStageData()
this.$bus.on(NOTICE_MESSAGE_UPDATE, this.receivedCount) // 监听事件
},
destroyed() {
this.$bus.off(NOTICE_MESSAGE_UPDATE)
},
methods: {
/**
* 打开列表页
@@ -94,7 +104,7 @@ export default {
},
// 定时获取消息数量
initStageData() {
// todo: 定时器
// 定时器
this.timer = setInterval(() => {
console.log('定时器启动')
this.receivedCount()
@@ -125,15 +135,6 @@ export default {
// console.log(this.dict.notice_type)
// console.log(tab, event)
}
},
mounted() {
this.getMessage()
this.receivedCount()
this.initStageData()
this.$bus.on(NOTICE_MESSAGE_UPDATE, this.receivedCount) // 监听事件
},
destroyed() {
this.$bus.off(NOTICE_MESSAGE_UPDATE)
}
}
</script>