Browse Source

消息优化

master
陈裕财 4 years ago
parent
commit
542aee413b
  1. 31
      src/api/cpd.js
  2. 94
      src/components/NoticeMsgBar/index.vue
  3. 16
      src/store/modules/noticeMsg.js
  4. 12
      src/views/myWork/message/index.scss
  5. 67
      src/views/myWork/message/index.vue
  6. 113
      src/views/myWork/message/notifyMsg.vue

31
src/api/cpd.js

@ -2,36 +2,11 @@ import axios from '@/utils/request'
import config from '@/common/config'
let base = config.getMallmBasePath();
let base = config.getSysBasePath();
//export const getNoticeMsg = params => { return axios.get(`${base}/mallm/cpd/index/toHandleOrdersCount`, { params: params }); };
export const getNoticeMsg = params => {
if(process.env.CONTEXT=='mallm'){
return axios.get(`${base}/mallm/cpd/index/toHandleOrdersCount`, { params: params });
}else{
return new Promise((resolve, reject) => {
var res={
data:{
tips:{
isOk:true,
msg:'请求成功'
},
data:{
toPayNum:0,
toSendNum:0,
toReceNum:0,
toApprovaNum:0,
hadApprovaNum:0,
hadFinishNum:0,
hadCloseNum:0,
hadCancelNum:0,
totalNum:0,
}
}
}
resolve(res)
})
}
export const getNoticeMsg = params => {
return axios.get(`${base}/sys/notifyMsg/list`, { params: params });
};

94
src/components/NoticeMsgBar/index.vue

@ -17,12 +17,10 @@
</el-dropdown-menu>
</el-dropdown>
-->
<div trigger="hover" class="avatar-container" @command="handleNoticeMsgClick">
<div class="avatar-wrapper" @click="goToMsgCenter">
<i class="el-icon-bell"></i>
<span>消息中心</span>
</div>
</div>
<div class="notify-box" >
<el-link @click="goToMsgCenter"><el-badge :value="unreadMsgCount"><i class="el-icon-bell"></i>消息中心</el-badge></el-link>
</div>
</template>
<script>
@ -33,41 +31,25 @@ export default {
computed: {
noticeMsg() {
return this.$store.getters.noticeMsg
},
unreadMsgCount(){
var msgs=this.$store.getters.noticeMsg
if(!msgs){
return 0;
}
return msgs.filter(k=>k.hadRead!='1').length;
}
},
data(){
return {
load:{list:false},
commandLinks:[
{command:'toPay',path:'/mallm/OrderCenter/orders/OrdersMng',query:null,params:null},
{command:'toSend',path:'/mallm/OrderCenter/orders/OrdersDeliver',query:null,params:null},
{command:'toRece',path:'/mallm/OrderCenter/orders/OrdersReceiptConfirm',query:null,params:null},
{command:'hadFinish',path:'/mallm/OrderCenter/orders/OrdersMng',query:null,params:null},
{command:'hadCancel',path:'/mallm/OrderCenter/orders/OrdersMng',query:null,params:null},
{command:'toApprova',path:'/mallm/OrderCenter/orders/OrdersMngBizFlow',query:null,params:null},
{command:'hadApprova',path:'/mallm/OrderCenter/orders/OrdersMngBizFlow',query:null,params:null},
{command:'hadclose',path:'/mallm/OrderCenter/orders/OrdersMng',query:null,params:null},
]
load:{list:false},
}
},
methods: {
goToMsgCenter(){
this.$router.push("/my/work/message");
},
doGetNoticeMsg(){
this.load.list=true;
getNoticeMsg({}).then(res=>{
this.load.list=false;
var tips = res.data.tips;
if(tips.isOk){
this.$message.success("刷新数据成功")
this.$store.dispatch("setNoticeMsg",res.data.data)
}else{
this.$message.error(tips.msg)
}
})
},
goToMsgCenter(){
this.$router.push({path:"/my/work/message"});
},
doGetNoticeMsgNoTips(){
this.load.list=true;
getNoticeMsg({}).then(res=>{
@ -79,29 +61,7 @@ export default {
this.$message.error(tips.msg)
}
})
},
handleNoticeMsgClick(command) {
if(command=='doGetNoticeMsg'){
this.doGetNoticeMsg();
}else{
if(this.commandLinks.some(c=>c.command==command)){
var link=this.commandLinks.find(c=>c.command==command)
if(link==null || !link.path){
return;
}
this.$store.dispatch("FindRouter",link.path).then(res=>{
if(res==null){
this.$message.error("该链接已不存在或者您无权限访问")
return
}else{
this.$router.push({path:res.fullPath,query:res.query,params:res.params});
}
})
}else{
}
}
}
},
},
mounted(){
this.doGetNoticeMsgNoTips()
@ -110,23 +70,9 @@ export default {
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.avatar-container {
height: 50px;
.avatar-wrapper {
cursor: pointer;
position: relative;
font-size: 16px;
.user-avatar {
height: 30px;
border-radius: 10px;
}
.el-icon-caret-bottom {
position: absolute;
right: -20px;
top: 25px;
font-size: 12px;
}
}
.notify-box {
margin-top:0px;
margin-right:10px;
}
</style>

16
src/store/modules/noticeMsg.js

@ -1,16 +1,8 @@
const noticeMsg = {
state: {
noticeMsg:{
toPayNum:0,
toSendNum:0,
toReceNum:0,
toApprovaNum:0,
hadApprovaNum:0,
hadFinishNum:0,
hadCloseNum:0,
hadCancelNum:0,
totalNum:0,
},
noticeMsg:[
/**{id:'消息编号 主键',sendUserid:'操作人id',sendUsername:'操作人名字',operTime:'操作时间',objType:'对象类型:项目-1/任务-2/产品-3/需求-4/bug-5/迭代-6/团队-7',msg:'备注-完整描述',gloNo:'全局根踪号,用于跟踪日志',branchId:'机构编号',ip:'ip地址',bizId:'业务主键编号',pbizId:'对象上级编号,项目时填项目编号,任务时填项目编号,产品时填产品编号,需求时填产品编号,bug时填产品编号,迭代时填产品编号',bizName:'对象名称',toUserid:'接收用户编号',toUsername:'接收用户名称',hadRead:'是否已读'} */
],
},
@ -36,6 +28,6 @@ const noticeMsg = {
var noticeMsgLocal=localStorage.getItem("noticeMsg");
if(noticeMsgLocal){
noticeMsg.state.noticeMsg=Object.assign( noticeMsg.state.noticeMsg,JSON.parse(noticeMsgLocal))
noticeMsg.state.noticeMsg=JSON.parse(noticeMsgLocal)
}
export default noticeMsg

12
src/views/myWork/message/index.scss

@ -1,8 +1,8 @@
.message_card {
font-size: 24px;
font-size: 18px;
font-weight: bold;
color: #303030;
line-height: 54px;
line-height: 30px;
.message_type {
cursor: pointer;
margin-right: 58px;
@ -31,8 +31,9 @@
background: #fff;
overflow: auto;
cursor: pointer;
padding: 20px;
padding: 10px;
.message_content_box {
padding:10px;
.title {
font-size: 18px;
font-weight: bold;
@ -41,6 +42,7 @@
position: relative;
}
.title::after {
content: "";
position: absolute;
@ -69,4 +71,8 @@
opacity: 0.43;
}
}
.message_content>.message_content_box:hover{
background-color: #eee;
}
}

67
src/views/myWork/message/index.vue

@ -2,10 +2,7 @@
<div class="m_container">
<div class="m_content">
<div class="message_card">
<span :class="{'message_type_active' : currentType == 1}" class="message_type" @click="currentType = 1">聊天消息</span>
<span :class="{'message_type_active' : currentType == 2}" class="message_type" @click="currentType = 2">客服消息</span>
<span :class="{'message_type_active' : currentType == 3}" class="message_type " @click="currentType = 3">审批流消息</span>
<span :class="{'message_type_active' : currentType == 4}" class="message_type " @click="currentType = 4">任务消息</span>
<span :class="{'message_type_active' : currentType == 4}" class="message_type " @click="currentType = 4">站内消息</span>
<span :class="{'message_type_active' : currentType == 5}" class="message_type " @click="currentType = 5">内部公告</span>
<span :class="{'message_type_active' : currentType == 6}" class="message_type " @click="currentType = 6">平台公告</span>
</div>
@ -14,13 +11,10 @@
</div>
<div class="message_content" v-if="currentType == 2">
<group-im :msg-class="'CSS'" key="css"></group-im>
</div>
<div class="message_content" v-if="currentType == 3">
<prichat-im :msg-class="'4'" :key="4"></prichat-im>
</div>
</div>
<div class="message_content" v-if="currentType == 4">
<prichat-im :msg-class="'5'" :key="5"></prichat-im>
<notify-msg :msg-class="'4'" :key="4"></notify-msg>
</div>
<div class="message_content" v-if="currentType == 5">
@ -40,68 +34,23 @@ import {listArchive} from '@/api/mdp/arc/archive'
import archive from "./archive"
import prichatIm from "./prichatIm"
import groupIm from "./groupIm"
import notifyMsg from "./notifyMsg"
export default {
components:{
archive,prichatIm,groupIm
archive,prichatIm,groupIm,notifyMsg,
},
data() {
return {
currentType: 1,
messageData: [
{
type: '审批消息',
time: '2022-04-26 12:00:00',
text: '李孝基发起申请领用办公电脑,因工作要求,自己没有电脑所以申请使用公司现有的huaWei办公电脑'
},
{
type: '系统消息',
time: '2022-04-26 12:00:00',
text: '李孝基发起申请领用办公电脑,因工作要求,自己没有电脑所以申请使用公司现有的huaWei办公电脑'
},
{
type: '审批消息',
time: '2022-04-26 12:00:00',
text: '李孝基发起申请领用办公电脑,因工作要求,自己没有电脑所以申请使用公司现有的huaWei办公电脑'
},
{
type: '审批消息',
time: '2022-04-26 12:00:00',
text: '李孝基发起申请领用办公电脑,因工作要求,自己没有电脑所以申请使用公司现有的huaWei办公电脑'
},
{
type: '审批消息',
time: '2022-04-26 12:00:00',
text: '李孝基发起申请领用办公电脑,因工作要求,自己没有电脑所以申请使用公司现有的huaWei办公电脑'
},
{
type: '审批消息',
time: '2022-04-26 12:00:00',
text: '李孝基发起申请领用办公电脑,因工作要求,自己没有电脑所以申请使用公司现有的huaWei办公电脑'
},
],
arcArchives:[],
currentType: 4,
}
},
methods:{
searcArchives(){
var params={archiveType:'3'}
listArchive({}).then(res=>{
this.arcArchives=res.data.data;
})
},
goToArchive(item){
var curlDomain=window.location.protocol+"//"+window.location.host; // https://mp.csdn.net
window.open(curlDomain+"/api/"+process.env.VERSION+"/arc/arc/archive/showArchive?id="+item.id)
}
methods:{
},
mounted() {
this.searcArchives();
mounted() {
}
}

113
src/views/myWork/message/notifyMsg.vue

@ -0,0 +1,113 @@
<template>
<div class="m_container">
<div class="message_content" v-if="notifyMsgs.length>0">
<div class="message_content_box" v-for="(item, index) in notifyMsgs" :key="index" @click="goToImPrichatMessage(item)">
<p class="title">{{item.sendUsername}}</p>
<p class="date">{{item.opTime}}</p>
<span class="text">{{item.msg}}</span>
<div class="line"></div>
</div>
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page.sync="pageInfo.pageNum"
:page-size="pageInfo.pageSize"
layout="total, prev, pager, next"
:total="pageInfo.total">
</el-pagination>
</div>
<div class="message_content_box" v-else>暂无消息</div>
</div>
</template>
<script>
import {
getNoticeMsg
} from '@/api/cpd'
import { mapGetters } from 'vuex'
export default {
props:['msgClass'],
computed: {
...mapGetters(['userInfo']),
},
data() {
return {
notifyMsgs:[],
pageInfo:{//
total:0,//0>0
pageSize:10,//
count:false,//
pageNum:1,//1
orderFields:['op_time'],// ['sex','student_id']
orderDirs:['desc']// asc,desc ['asc','desc']
},
}
},
methods:{
handleSizeChange(pageSize) {
this.pageInfo.pageSize=pageSize;
this.getNoticeMsg();
},
handleCurrentChange(pageNum) {
this.pageInfo.pageNum = pageNum;
this.getNoticeMsg();
},
searchNoticeMsg(){
this.pageInfo.count=true;
this.getNoticeMsg();
},
getNoticeMsg(){
let params = {
pageSize: this.pageInfo.pageSize,
pageNum: this.pageInfo.pageNum,
total: this.pageInfo.total,
count:this.pageInfo.count
};
if(this.pageInfo.orderFields!=null && this.pageInfo.orderFields.length>0){
let orderBys=[];
for(var i=0;i<this.pageInfo.orderFields.length;i++){
orderBys.push(this.pageInfo.orderFields[i]+" "+this.pageInfo.orderDirs[i])
}
params.orderBy= orderBys.join(",")
}
params.toUserid=this.userInfo.userid
params.msgClass=this.msgClass||''
getNoticeMsg(params).then(res=>{
this.notifyMsgs=res.data.data;
this.pageInfo.total=res.data.total
this.pageInfo.count=false;
})
},
goToImPrichatMessage(item){
var curlDomain=window.location.protocol+"//"+window.location.host; // https://mp.csdn.net
if(item.msgClass=='0'){
window.open(curlDomain+"/im/"+process.env.VERSION+"/#/prichat?groupId="+item.groupId)
}else if(item.msgClass=='4'){
this.$router.push('/mdp/workflow/ru/task/TaskListAssigneeToMe')
}else if(item.msgClass=='5'){
if(process.env.CONTEXT=='xm'){
this.$router.push('/xm/core/xmTask/XmMyTaskCenter')
}else{
window.open(curlDomain+"/xm/"+process.env.VERSION+"/#/xm/core/xmTask/XmMyTaskCenter")
}
}
}
},
mounted() {
this.searchNoticeMsg();
}
}
</script>
<style lang="scss" scoped>
@import '../common.scss';
@import './index.scss';
</style>
Loading…
Cancel
Save