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) {
return request({
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 {
warnRemark,
@ -75,5 +90,7 @@ export default {
getAllUser,
getAllDev,
noticeDel,
getUserNotice
getUserNotice,
isread,
userMsgDel
}

9
src/layout/components/Navbar.vue

@ -118,7 +118,8 @@ export default {
return {
Avatar: Avatar,
defaultImg: 'this.src="' + require('@/assets/images/avatar.png') + '"',
logoutVisible: false
logoutVisible: false,
readMsg: null
}
},
computed: {
@ -147,12 +148,16 @@ export default {
}
},
methods: {
//
getReadMsg() {
},
toggleSideBar() {
this.$store.dispatch('app/toggleSideBar')
},
toAllMessage() {
// 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()
},
// open() {

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

@ -189,10 +189,6 @@ export default {
item.pushTo = null
item.pushVal = null
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.pushTo = item.noticeDevices.map(i => {
let dev = null
@ -203,13 +199,7 @@ export default {
})
return dev
})
// }
} 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.pushTo = item.noticeUsers.map(i => {
let user = null
@ -220,7 +210,6 @@ export default {
})
return user
})
// }
}
//
const arrTo = []

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

@ -38,8 +38,8 @@
<div class="user-right-content">
<ul class="tab-nav">
<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 -->
<span class="tab-right-img" />
</ul>
@ -64,8 +64,12 @@
</el-form-item>
</el-form>
</div>
<!-- 操作日志 -->
<!-- 我的消息 -->
<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-column prop="description" label="行为" />
<el-table-column prop="requestIp" label="IP" />
@ -97,10 +101,7 @@
@current-change="pageChange"
/>
</div>
<!-- 我的消息 -->
<div v-if="activeIndex == 2" class="tab-item">
<messageCenter />
</div>
</div></el-col>
</el-row>
<updateEmail ref="email" :email="user.email" />
@ -176,7 +177,7 @@ export default {
},
handleClick(index) {
this.activeIndex = index
if (this.activeIndex === 1) {
if (this.activeIndex === 2) {
this.init()
}
},

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

@ -1,23 +1,15 @@
<template>
<div>
<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="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 class="app-container container-wrap">
<span class="right-top-line" />
<span class="left-bottom-line" /> -->
<!--表格渲染-->
<!-- :cell-class-name="cell"
@selection-change="selectionChangeHandler"
-->
<el-table
ref="table"
v-loading="isLoading"
:data="tableData"
style="width: 100%;"
:row-class-name="cell"
@ -40,7 +32,6 @@
</template>
</el-table-column>
</el-table>
<!-- <pagination /> -->
<el-pagination
:page-size.sync="page.size"
:total="page.total"
@ -50,34 +41,23 @@
@size-change="sizeChangeHandler($event)"
@current-change="pageChangeHandler"
/>
<!-- </div> -->
</div>
</template>
<script>
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 pagination from '@crud/Pagination'
// import rrOperation from '@crud/RR.operation'
export default {
name: 'MessageCenter',
components: { DateRangePicker
// pagination, rrOperation
},
components: { DateRangePicker },
mixins: [presenter(), crud(), header()],
cruds() {
return CRUD({
url: 'api/users/notice',
sort: ['createTime,desc'],
optShow: {
// add: false,
// edit: false,
// del: false,
// download: false
}
optShow: {}
})
},
data() {
@ -91,7 +71,8 @@ export default {
total: 0,
size: 10,
page: 1
}
},
isLoading: false
}
},
created() {
@ -99,7 +80,7 @@ export default {
},
methods: {
getTableData() {
// this.tableData = data1.rows
this.isLoading = true
getUserNotice(this.getParams()).then(res => {
console.log(res, 'list')
this.page.total = res.totalElements
@ -109,8 +90,8 @@ export default {
item.isRead = item.noticeUsers[0].isRead
})
this.tableData = table
this.isLoading = false
})
// console.log(this.crud, 'crud')
},
getParams() {
const params = {
@ -119,9 +100,69 @@ export default {
createTime: this.query.createTime,
sort: 'createTime,desc'
}
console.log(params, '--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) {
// this.$refs.table.clearSelection()
this.$refs.table.toggleRowSelection(row) //

Loading…
Cancel
Save