Browse Source

我的消息

master
x_ying 2 years ago
parent
commit
67ec6f0040
  1. 23
      src/api/system/logs.js
  2. 9
      src/layout/components/Navbar.vue
  3. 11
      src/views/system/notifyManage/index.vue
  4. 17
      src/views/system/user/center.vue
  5. 105
      src/views/system/user/messageCenter/index.vue

23
src/api/system/logs.js

@ -61,12 +61,27 @@ export function noticeDel(data) {
export function getUserNotice(params) { export function getUserNotice(params) {
return request({ return request({
url: 'api/users/notice' + '?' + qs.stringify(params, { indices: false }), url: 'api/users/notice' + '?' + qs.stringify(params, { indices: false }),
method: 'get',
params
method: 'get'
}) })
} }
// 标记已读 // 标记已读
export function isread(data) {
return request({
url: 'api/users/isread',
method: 'put',
data
})
}
// 删除
export function userMsgDel(data) {
return request({
url: '/api/users/delnotice',
method: 'delete',
data
})
}
export default { export default {
warnRemark, warnRemark,
@ -75,5 +90,7 @@ export default {
getAllUser, getAllUser,
getAllDev, getAllDev,
noticeDel, noticeDel,
getUserNotice
getUserNotice,
isread,
userMsgDel
} }

9
src/layout/components/Navbar.vue

@ -118,7 +118,8 @@ export default {
return { return {
Avatar: Avatar, Avatar: Avatar,
defaultImg: 'this.src="' + require('@/assets/images/avatar.png') + '"', defaultImg: 'this.src="' + require('@/assets/images/avatar.png') + '"',
logoutVisible: false
logoutVisible: false,
readMsg: null
} }
}, },
computed: { computed: {
@ -147,12 +148,16 @@ export default {
} }
}, },
methods: { methods: {
//
getReadMsg() {
},
toggleSideBar() { toggleSideBar() {
this.$store.dispatch('app/toggleSideBar') this.$store.dispatch('app/toggleSideBar')
}, },
toAllMessage() { toAllMessage() {
// this.$router.push('/system/messageCenter') // this.$router.push('/system/messageCenter')
this.$router.push({ path: '/user/center', query: { activeIndex: 2 }})
this.$router.push({ path: '/user/center', query: { activeIndex: 1 }})
this.$refs.messageDrop.hide() this.$refs.messageDrop.hide()
}, },
// open() { // open() {

11
src/views/system/notifyManage/index.vue

@ -189,10 +189,6 @@ export default {
item.pushTo = null item.pushTo = null
item.pushVal = null item.pushVal = null
if (item.pushType === 2) { // if (item.pushType === 2) { //
// if (item.noticeDevices.length === this.devOptions.length - 1) {
// item.pushTo = ''
// item.pushVal = this.sendObjOptions.map(i => { return i.value })
// } else {
item.pushVal = item.noticeDevices.map(i => { return i.deviceInfoId }) item.pushVal = item.noticeDevices.map(i => { return i.deviceInfoId })
item.pushTo = item.noticeDevices.map(i => { item.pushTo = item.noticeDevices.map(i => {
let dev = null let dev = null
@ -203,13 +199,7 @@ export default {
}) })
return dev return dev
}) })
// }
} else if (item.pushType === 1) { // } else if (item.pushType === 1) { //
// pushArr = item.noticeDevices
// if (item.noticeUsers.length === this.userOptions.length - 1) {
// item.pushTo = ''
// item.pushVal = this.userOptions.map(i => { return i.value })
// } else {
item.pushVal = item.noticeUsers.map(i => { return i.userId }) item.pushVal = item.noticeUsers.map(i => { return i.userId })
item.pushTo = item.noticeUsers.map(i => { item.pushTo = item.noticeUsers.map(i => {
let user = null let user = null
@ -220,7 +210,6 @@ export default {
}) })
return user return user
}) })
// }
} }
// //
const arrTo = [] const arrTo = []

17
src/views/system/user/center.vue

@ -38,8 +38,8 @@
<div class="user-right-content"> <div class="user-right-content">
<ul class="tab-nav"> <ul class="tab-nav">
<li :class="{'active-tab-nav': activeIndex == 0}" @click="handleClick(0)">用户资料<i /></li> <li :class="{'active-tab-nav': activeIndex == 0}" @click="handleClick(0)">用户资料<i /></li>
<li :class="{'active-tab-nav': activeIndex == 1}" @click="handleClick(1)">操作日志<i /></li>
<li :class="{'active-tab-nav': activeIndex == 2}" @click="handleClick(2)">我的消息<i /></li>
<li :class="{'active-tab-nav': activeIndex == 1}" @click="handleClick(1)">我的消息<i /></li>
<li :class="{'active-tab-nav': activeIndex == 2}" @click="handleClick(2)">操作日志<i /></li>
<!-- 最右侧装饰img --> <!-- 最右侧装饰img -->
<span class="tab-right-img" /> <span class="tab-right-img" />
</ul> </ul>
@ -64,8 +64,12 @@
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
<!-- 操作日志 -->
<!-- 我的消息 -->
<div v-if="activeIndex == 1" class="tab-item"> <div v-if="activeIndex == 1" class="tab-item">
<messageCenter />
</div>
<!-- 操作日志 -->
<div v-if="activeIndex == 2" class="tab-item">
<el-table v-loading="loading" :data="data" style="width: 100%;"> <el-table v-loading="loading" :data="data" style="width: 100%;">
<el-table-column prop="description" label="行为" /> <el-table-column prop="description" label="行为" />
<el-table-column prop="requestIp" label="IP" /> <el-table-column prop="requestIp" label="IP" />
@ -97,10 +101,7 @@
@current-change="pageChange" @current-change="pageChange"
/> />
</div> </div>
<!-- 我的消息 -->
<div v-if="activeIndex == 2" class="tab-item">
<messageCenter />
</div>
</div></el-col> </div></el-col>
</el-row> </el-row>
<updateEmail ref="email" :email="user.email" /> <updateEmail ref="email" :email="user.email" />
@ -176,7 +177,7 @@ export default {
}, },
handleClick(index) { handleClick(index) {
this.activeIndex = index this.activeIndex = index
if (this.activeIndex === 1) {
if (this.activeIndex === 2) {
this.init() this.init()
} }
}, },

105
src/views/system/user/messageCenter/index.vue

@ -1,23 +1,15 @@
<template> <template>
<div> <div>
<div class="head-container"> <div class="head-container">
<el-button icon="el-icon-delete" :disabled="!(selections.length)" size="mini">删除</el-button>
<el-button class="iconfont icon-biaojiyidu-fanbai" :disabled="!(selections.length)" size="mini">标记已读</el-button>
<el-button class="iconfont icon-biaojiyidu-fanbai" size="mini">全部标记已读</el-button>
<el-button icon="el-icon-delete" :disabled="!(selections.length)" size="mini" @click="handleDel">删除</el-button>
<el-button class="iconfont icon-biaojiyidu-fanbai" :disabled="!(selections.length)" size="mini" @click="handleRead">标记已读</el-button>
<el-button class="iconfont icon-biaojiyidu-fanbai" size="mini" @click="handleAllRead">全部标记已读</el-button>
<date-range-picker v-model="query.createTime" class="date-item" /> <date-range-picker v-model="query.createTime" class="date-item" />
<!-- <date-range-picker v-model="createTime" class="date-item" /> -->
<!-- <rrOperation /> -->
<button @click="getTableData">搜索</button>
<el-button icon="el-icon-search" size="mini" style="background:#3A99FD;margin-left: -10px;" @click="getTableData">搜索</el-button>
</div> </div>
<!-- <div class="app-container container-wrap">
<span class="right-top-line" />
<span class="left-bottom-line" /> -->
<!--表格渲染-->
<!-- :cell-class-name="cell"
@selection-change="selectionChangeHandler"
-->
<el-table <el-table
ref="table" ref="table"
v-loading="isLoading"
:data="tableData" :data="tableData"
style="width: 100%;" style="width: 100%;"
:row-class-name="cell" :row-class-name="cell"
@ -40,7 +32,6 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<!-- <pagination /> -->
<el-pagination <el-pagination
:page-size.sync="page.size" :page-size.sync="page.size"
:total="page.total" :total="page.total"
@ -50,34 +41,23 @@
@size-change="sizeChangeHandler($event)" @size-change="sizeChangeHandler($event)"
@current-change="pageChangeHandler" @current-change="pageChangeHandler"
/> />
<!-- </div> -->
</div> </div>
</template> </template>
<script> <script>
import DateRangePicker from '@/components/DateRangePicker' import DateRangePicker from '@/components/DateRangePicker'
// import data1 from './data1.json'
import { getUserNotice } from '@/api/system/logs'
import { getUserNotice, isread, userMsgDel } from '@/api/system/logs'
import CRUD, { presenter, header, crud } from '@crud/crud' import CRUD, { presenter, header, crud } from '@crud/crud'
// import pagination from '@crud/Pagination'
// import rrOperation from '@crud/RR.operation'
export default { export default {
name: 'MessageCenter', name: 'MessageCenter',
components: { DateRangePicker
// pagination, rrOperation
},
components: { DateRangePicker },
mixins: [presenter(), crud(), header()], mixins: [presenter(), crud(), header()],
cruds() { cruds() {
return CRUD({ return CRUD({
url: 'api/users/notice', url: 'api/users/notice',
sort: ['createTime,desc'], sort: ['createTime,desc'],
optShow: {
// add: false,
// edit: false,
// del: false,
// download: false
}
optShow: {}
}) })
}, },
data() { data() {
@ -91,7 +71,8 @@ export default {
total: 0, total: 0,
size: 10, size: 10,
page: 1 page: 1
}
},
isLoading: false
} }
}, },
created() { created() {
@ -99,7 +80,7 @@ export default {
}, },
methods: { methods: {
getTableData() { getTableData() {
// this.tableData = data1.rows
this.isLoading = true
getUserNotice(this.getParams()).then(res => { getUserNotice(this.getParams()).then(res => {
console.log(res, 'list') console.log(res, 'list')
this.page.total = res.totalElements this.page.total = res.totalElements
@ -109,8 +90,8 @@ export default {
item.isRead = item.noticeUsers[0].isRead item.isRead = item.noticeUsers[0].isRead
}) })
this.tableData = table this.tableData = table
this.isLoading = false
}) })
// console.log(this.crud, 'crud')
}, },
getParams() { getParams() {
const params = { const params = {
@ -119,9 +100,69 @@ export default {
createTime: this.query.createTime, createTime: this.query.createTime,
sort: 'createTime,desc' sort: 'createTime,desc'
} }
console.log(params, '--params')
return params return params
}, },
getUserMsgId(list) {
const ids = []
list.forEach(item => {
item.noticeUsers.forEach(i => {
ids.push(i.id)
})
})
return ids
},
//
handleRead() {
isread(this.getUserMsgId(this.selections)).then(res => {
if (res) {
this.getTableData()
}
})
},
//
async handleAllRead() {
const params = {
page: 0,
size: 10,
// createTime: [],
sort: 'createTime,desc'
}
const list = []
const allList = await this.getAllNoRead(params, list)
isread(this.getUserMsgId(allList)).then(res => {
if (res) {
this.getTableData()
}
})
},
//
async getAllNoRead(params, list) {
const allList = await getUserNotice(params).then(res => {
list = list.concat(res.content)
if ((list.length) < res.totalElements) {
params.page++
return this.getAllNoRead(params, list)
} else {
return list
}
})
return allList
},
//
handleDel() {
userMsgDel(this.getUserMsgId(this.selections)).then(res => {
console.log(res, '删除')
if (res) {
this.getTableData()
this.$message({
message: '删除成功',
type: 'success'
})
} else {
this.$message.error('删除失败')
}
})
},
clickRowHandler(row) { clickRowHandler(row) {
// this.$refs.table.clearSelection() // this.$refs.table.clearSelection()
this.$refs.table.toggleRowSelection(row) // this.$refs.table.toggleRowSelection(row) //

Loading…
Cancel
Save