Skip to content

Commit 546869e

Browse files
fullstackyangfullstackyang
authored andcommitted
Merge remote-tracking branch 'origin/master'
2 parents 7d1fae8 + 9b2d781 commit 546869e

File tree

23 files changed

+292
-77
lines changed

23 files changed

+292
-77
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "diboot-element-admin",
3-
"version": "2.5.0",
3+
"version": "2.6.0",
44
"description": "Diboot PC端前端框架(element-ui)",
55
"author": "www.diboot.com",
66
"license": "MIT",

src/components/MessageBell/index.vue

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<template>
2+
<el-popover v-model="visible" placement="bottom-end">
3+
<el-tabs v-model="activeKey" style="width: 390px">
4+
<el-tab-pane name="unreadMessage">
5+
<template slot="label">
6+
未读消息
7+
<el-badge class="custom-badge" :value="countMap.unreadMessage" :hidden="countMap.unreadMessage === 0" />
8+
</template>
9+
<MessageList
10+
ref="unreadMessage"
11+
:unread="true"
12+
@close="visible = false"
13+
@reset="$refs.allMessages && $refs.allMessages.refresh()"
14+
@total="value => $set(countMap, 'unreadMessage', value)"
15+
/>
16+
</el-tab-pane>
17+
<el-tab-pane name="allMessages" label="全部消息" lazy>
18+
<MessageList
19+
ref="allMessages"
20+
:unread="false"
21+
@reset="$refs.unreadMessage && $refs.unreadMessage.refresh()"
22+
@close="visible = false"
23+
/>
24+
</el-tab-pane>
25+
</el-tabs>
26+
<el-badge slot="reference" :value="sumCount" :hidden="sumCount === 0" class="custom-badge">
27+
<i class="el-icon-bell" style="font-size: 18px;" />
28+
</el-badge>
29+
</el-popover>
30+
</template>
31+
32+
<script>
33+
import MessageList from './list'
34+
35+
export default {
36+
name: 'MessageBell',
37+
components: { MessageList },
38+
data() {
39+
return {
40+
visible: false,
41+
activeKey: 'unreadMessage',
42+
countMap: {
43+
unreadMessage: 0
44+
}
45+
}
46+
},
47+
computed: {
48+
sumCount() {
49+
return Object.values(this.countMap).reduce((prev, next) => prev + next)
50+
}
51+
}
52+
}
53+
</script>
54+
55+
<style lang="scss" scoped>
56+
.custom-badge {
57+
/deep/.el-badge__content.is-fixed{
58+
top: 13px;
59+
}
60+
}
61+
</style>

src/components/MessageBell/list.vue

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
<template>
2+
<div class="container">
3+
<div class="scroll" @scroll="scrollHandler">
4+
<el-card
5+
v-for="item in dataList"
6+
:key="item.id"
7+
shadow="hover"
8+
class="card"
9+
@click.native="markRead([item.id])"
10+
>
11+
<div slot="header" class="clearfix">
12+
<el-badge is-dot :hidden="item.status === 'READ'" />
13+
<strong>{{ item.title }}</strong>
14+
<span style="float: right; padding: 3px 0">
15+
{{ item.createTime }}
16+
</span>
17+
</div>
18+
<p>{{ item.content }}</p>
19+
<div v-if="item.businessType" style="color: #bbb; zoom: 0.9; text-align: end">{{ item.businessType }}</div>
20+
</el-card>
21+
<el-empty v-show="!dataList.length" description="暂无消息" />
22+
</div>
23+
<el-button type="primary" ghost :disabled="unreadIds.length === 0" style="width: 100%" @click="markRead(unreadIds)">
24+
全标记已读
25+
</el-button>
26+
</div>
27+
</template>
28+
29+
<script>
30+
import { dibootApi } from '@/utils/request'
31+
import _ from 'lodash'
32+
33+
export default {
34+
name: 'MessageList',
35+
props: {
36+
unread: {
37+
type: Boolean,
38+
default: false
39+
}
40+
},
41+
data() {
42+
return {
43+
baseApi: '/message',
44+
dataList: [],
45+
dataIds: [],
46+
total: 0,
47+
queryParam: {
48+
unread: this.unread,
49+
pageSize: 10,
50+
current: 1,
51+
total: 0
52+
},
53+
nextPageDebounce: _.debounce(this.nextPage, 1000, { leading: true, maxWait: 3000, trailing: false })
54+
}
55+
},
56+
computed: {
57+
unreadIds() {
58+
return this.dataList.filter(e => e.status !== 'READ').map(e => e.id)
59+
}
60+
},
61+
watch: {
62+
total(value) {
63+
this.$emit('total', this.total)
64+
}
65+
},
66+
created() {
67+
this.loadData()
68+
setInterval(() => {
69+
this.refresh()
70+
}, 300000)
71+
},
72+
methods: {
73+
nextPage() {
74+
if (this.total === this.dataList.length) return
75+
++this.queryParam.pageIndex
76+
this.loadData()
77+
},
78+
loadData(reset = false) {
79+
dibootApi.get(`${this.baseApi}/own`, this.queryParam).then(res => {
80+
if (res.code === 0) {
81+
if (reset) {
82+
this.dataList = res.data || []
83+
this.dataIds = this.dataList.map(e => e.id)
84+
} else {
85+
const list = (res.data || []).filter(e => !this.dataIds.includes(e.id))
86+
this.dataList.push(...list)
87+
this.dataIds.push(...list.map(e => e.id))
88+
}
89+
this.queryParam.pageIndex = Number(res.page.pageIndex || 1)
90+
this.total = res.page.totalCount ? Number(res.page.totalCount) : 0
91+
} else {
92+
console.error('获取消息列表失败', res.msg)
93+
}
94+
}).catch(err => {
95+
console.error('获取消息列表异常', err.msg || err.message)
96+
})
97+
},
98+
scrollHandler(e) {
99+
const element = e.path[0]
100+
if (element.scrollHeight - element.scrollTop < 350 + 10) this.nextPage()
101+
else if (element.scrollHeight - element.scrollTop < 350 * 2) this.nextPageDebounce()
102+
},
103+
refresh() {
104+
this.queryParam.pageIndex = 1
105+
this.loadData(true)
106+
},
107+
async markRead(ids) {
108+
if (ids.length === 1) {
109+
const find = this.dataList.find(e => e.id === ids[0])
110+
if (!find) return
111+
await this.handle(find.businessCode, find.extDataMap)
112+
if (find.status === 'READ') return
113+
if (!this.unread) this.$set(find, 'status', 'READ')
114+
}
115+
dibootApi.post(`${this.baseApi}/read`, ids).then(res => {
116+
if (res.code === 0) {
117+
if (ids.length > 1) this.refresh()
118+
this.total = Math.max(this.total - ids.length, 0)
119+
if (this.unread) {
120+
this.dataIds = this.dataIds.filter(id => !ids.includes(id))
121+
this.dataList = this.dataList.filter(e => !ids.includes(e.id))
122+
}
123+
this.$emit('reset')
124+
} else {
125+
this.$message.error(res.msg)
126+
}
127+
})
128+
},
129+
async handle(type, data) {
130+
// 分类处理
131+
// switch (type) {
132+
// default:
133+
// // this.$emit('close') // 关闭 popover
134+
// }
135+
}
136+
}
137+
}
138+
</script>
139+
140+
<style scoped lang="scss">
141+
.container {
142+
height: 399px;
143+
overflow-x: auto;
144+
145+
.scroll {
146+
height: 350px;
147+
overflow-y: auto;
148+
margin-bottom: 8px;
149+
150+
.card {
151+
margin-bottom: 16px;
152+
}
153+
}
154+
}
155+
</style>

src/components/diboot/components/excel/tableColumn.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
:label="column.title"
55
:show-overflow-tooltip="showOverflowTooltip"
66
min-width="100"
7-
align="center"
87
:formatter="formatter"
98
>
109
<table-column

src/layout/components/Navbar.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
<div class="right-menu">
88
<template v-if="device!=='mobile'">
9+
<message-bell style="height: 100%;vertical-align: text-bottom;" />
10+
911
<search id="header-search" class="right-menu-item" />
1012

1113
<error-log class="errLog-container right-menu-item hover-effect" />
@@ -56,9 +58,11 @@ import ErrorLog from '@/components/ErrorLog'
5658
import Screenfull from '@/components/Screenfull'
5759
import SizeSelect from '@/components/SizeSelect'
5860
import Search from '@/components/HeaderSearch'
61+
import MessageBell from '@/components/MessageBell'
5962
6063
export default {
6164
components: {
65+
MessageBell,
6266
Breadcrumb,
6367
Hamburger,
6468
ErrorLog,

src/store/modules/user.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ const actions = {
9090

9191
// user logout
9292
logout({ commit, state }) {
93-
ssoLogout()
9493
return new Promise((resolve) => {
9594
const reset = () => {
9695
commit('SET_TOKEN', '')
9796
removeToken()
9897
resetRouter()
98+
ssoLogout()
9999
resolve()
100100
}
101101

src/utils/request.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ const BASE_URL = process.env.VUE_APP_BASE_API
1717
// create an axios instance
1818
const service = axios.create({
1919
baseURL: BASE_URL, // url = base url + request url
20-
withCredentials: true, // send cookies when cross-domain requests
2120
timeout: 30000 // request timeout
2221
})
2322

@@ -142,8 +141,7 @@ const dibootApi = {
142141
headers: {
143142
'X-Requested-With': 'XMLHttpRequest',
144143
'Content-Type': 'application/json;charset=UTF-8'
145-
},
146-
withCredentials: true
144+
}
147145
})
148146
},
149147
/** *
@@ -175,8 +173,7 @@ const dibootApi = {
175173
headers: {
176174
'X-Requested-With': 'XMLHttpRequest',
177175
'Content-Type': 'application/json;charset=UTF-8'
178-
},
179-
withCredentials: true
176+
}
180177
})
181178
},
182179
/**
@@ -195,8 +192,7 @@ const dibootApi = {
195192
headers: {
196193
'X-Requested-With': 'XMLHttpRequest',
197194
'Content-Type': 'application/json;charset=UTF-8'
198-
},
199-
withCredentials: true
195+
}
200196
})
201197
}
202198
}

src/views/account/Setting.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export default {
6262
}
6363
},
6464
async mounted() {
65+
this.attachMore()
6566
await this.getCurrentUserInfo()
6667
},
6768
methods: {

src/views/orgStructure/org/list.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,32 +50,32 @@
5050
row-key="id"
5151
@sort-change="appendSorterParam"
5252
>
53-
<el-table-column align="center" label="简称">
53+
<el-table-column label="简称">
5454
<template slot-scope="scope">
5555
<span>{{ scope.row.shortName }}</span>
5656
</template>
5757
</el-table-column>
58-
<el-table-column align="center" label="全称">
58+
<el-table-column label="全称">
5959
<template slot-scope="scope">
6060
<span>{{ scope.row.name }}</span>
6161
</template>
6262
</el-table-column>
63-
<el-table-column align="center" label="编码">
63+
<el-table-column label="编码">
6464
<template slot-scope="scope">
6565
<span>{{ scope.row.code }}</span>
6666
</template>
6767
</el-table-column>
68-
<el-table-column align="center" label="类型">
68+
<el-table-column label="类型">
6969
<template slot-scope="scope">
7070
<span>{{ scope.row.typeLabel }}</span>
7171
</template>
7272
</el-table-column>
73-
<el-table-column align="center" label="负责人">
73+
<el-table-column label="负责人">
7474
<template slot-scope="scope">
7575
<span>{{ scope.row.managerName }}</span>
7676
</template>
7777
</el-table-column>
78-
<el-table-column label="操作" align="center" width="230" class-name="small-padding fixed-width">
78+
<el-table-column label="操作" width="230" class-name="small-padding fixed-width">
7979
<template slot-scope="{row}">
8080
<el-button
8181
v-permission="['detail']"

src/views/orgStructure/orgUser/userList.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,17 @@
129129
{{ scope.row.genderLabel }}
130130
</template>
131131
</el-table-column>
132-
<el-table-column label="电话" align="center">
132+
<el-table-column label="电话">
133133
<template slot-scope="scope">
134134
<span>{{ scope.row.mobilePhone }}</span>
135135
</template>
136136
</el-table-column>
137-
<el-table-column label="邮箱" align="center">
137+
<el-table-column label="邮箱">
138138
<template slot-scope="scope">
139139
<span>{{ scope.row.email }}</span>
140140
</template>
141141
</el-table-column>
142-
<el-table-column label="操作" align="center" width="230" class-name="small-padding fixed-width">
142+
<el-table-column label="操作" width="230" class-name="small-padding fixed-width">
143143
<template slot-scope="{row}">
144144
<el-button
145145
v-permission="['detail']"

0 commit comments

Comments
 (0)