| | |
| | | title="消息通知" |
| | | :visible.sync="drawer" |
| | | :direction="direction" |
| | | :before-close="handleClose" style="height: 100vh;"> |
| | | :before-close="handleClose" style="height: 100vh;z-index: 9999999;"> |
| | | <div class="head"> |
| | | <div class="head-search"> |
| | | <label>消息类型:</label> |
| | | <el-select v-model="type" placeholder="请选择" style="width: 150px;" size="small"> |
| | | <el-select v-model="type" placeholder="请选择" style="width: 150px;" size="small" @change="handleType"> |
| | | <el-option |
| | | v-for="item in options" |
| | | :key="item.value" |
| | |
| | | </el-option> |
| | | </el-select> |
| | | </div> |
| | | <el-dropdown style="margin-right: 20px;"> |
| | | <el-dropdown style="margin-right: 20px;" v-if="list.length>0" @command="handleDropdownAll"> |
| | | <span class="el-dropdown-link"> |
| | | <span class="more">···</span> |
| | | </span> |
| | | <el-dropdown-menu slot="dropdown"> |
| | | <el-dropdown-item> |
| | | <el-dropdown-item command="1"> |
| | | <i class="el-icon-check"></i> |
| | | <span>标记所有消息为已读</span> |
| | | </el-dropdown-item> |
| | | <el-dropdown-item> |
| | | <el-dropdown-item command="2"> |
| | | <i class="el-icon-delete"></i> |
| | | <span>删除所有已读消息</span> |
| | | </el-dropdown-item> |
| | | </el-dropdown-menu> |
| | | </el-dropdown> |
| | | </div> |
| | | <div class="notice-content"> |
| | | <div class="notice-content-item" v-for="(m,i) in list" :key="i"> |
| | | <div class="btns"> |
| | | <el-dropdown style="margin-right: 20px;" trigger="click" @command="handleDropdown"> |
| | | <span class="el-dropdown-link"> |
| | | <span class="more" style="line-height: 26px;display: inline-block;">···</span> |
| | | </span> |
| | | <el-dropdown-menu slot="dropdown"> |
| | | <el-dropdown-item v-for="(n,j) in dropdownList" :key="j" :command="n.value"> |
| | | {{ n.label }} |
| | | </el-dropdown-item> |
| | | </el-dropdown-menu> |
| | | </el-dropdown> |
| | | <i class="el-icon-close" style="cursor: pointer;"></i> |
| | | </div> |
| | | <div class="content"> |
| | | <img :src="`../../static/img/notice-${m.type}.svg`" alt="" style="width: 50px;margin-right: 18px;"> |
| | | <div class="content-info"> |
| | | <h4 style="font-weight: normal;margin-bottom: 4px;display: flex;align-items: center;justify-content: space-between;"> |
| | | <span>{{ m.title }}</span> |
| | | <span class="time" style="color: #999999;font-size: 12px;">{{ m.time }}</span> |
| | | </h4> |
| | | <p style="color: #999999;font-size: 14px;margin-bottom: 6px;" class="ellipsis-multiline">{{ m.content }}</p> |
| | | <el-tag type="danger" size="small" v-if="m.status==0&&m.type==2" style="margin-bottom: 4px;">已拒绝</el-tag> |
| | | <el-tag type="success" size="small" v-if="m.status==1&&m.type==2" style="margin-bottom: 4px;">已接收</el-tag> |
| | | <p style="font-size: 12px;color: #999999;display: flex;align-items: center;justify-content: space-between;"> |
| | | <span>发送人:{{m.sendUser}}</span> |
| | | <span>收件人:{{ m.getUser }}</span> |
| | | </p> |
| | | <div class="notice-content" v-loading="loading"> |
| | | <scroll-pagination @load="refresh" :finishLoding="finishLoding" :list="list"> |
| | | <div class="notice-content-item" v-for="(m,i) in list" :key="i"> |
| | | <div class="btns" v-if="m"> |
| | | <!-- v-if="m.messageType==2||m.messageType==3" --> |
| | | <el-dropdown style="margin-right: 20px;" trigger="click" @command="e=>handleDropdown(e,m)" v-if="false"> |
| | | <span class="el-dropdown-link"> |
| | | <span class="more" style="line-height: 26px;display: inline-block;">···</span> |
| | | </span> |
| | | <el-dropdown-menu slot="dropdown" v-if="m.messageType==2"> |
| | | <el-dropdown-item v-for="(n,j) in dropdownList0" :key="j" :command="n.value"> |
| | | {{ n.label }} |
| | | </el-dropdown-item> |
| | | </el-dropdown-menu> |
| | | <el-dropdown-menu slot="dropdown" v-if="m.messageType==3"> |
| | | <el-dropdown-item v-for="(n,j) in dropdownList1" :key="j" :command="n.value"> |
| | | {{ n.label }} |
| | | </el-dropdown-item> |
| | | </el-dropdown-menu> |
| | | </el-dropdown> |
| | | <i class="el-icon-close" style="cursor: pointer;" @click="handleDel(m)"></i> |
| | | </div> |
| | | <div class="content" @click="goNoticeDetail(m)" style="cursor: pointer;"> |
| | | <img :src="`../../static/img/notice-${m.messageType}.svg`" alt="" style="width: 50px;margin-right: 18px;"> |
| | | <div class="content-info"> |
| | | <h4 style="font-weight: normal;margin-bottom: 4px;display: flex;align-items: center;justify-content: space-between;"> |
| | | <span>{{ m.theme }}<el-tag :type="!m.viewStatus?'danger':'success'" size="small" v-if="m.messageType==1||m.messageType==2||m.messageType==3" style="margin-left: 8px;">{{ !m.viewStatus?'未处理':'已处理' }}</el-tag></span> |
| | | <span class="time" style="color: #999999;font-size: 12px;">{{ m.createTime }}</span> |
| | | </h4> |
| | | <p style="color: #999999;font-size: 14px;margin-bottom: 6px;" class="ellipsis-multiline">{{ m.content }}</p> |
| | | <p style="font-size: 12px;color: #999999;display: flex;align-items: center;justify-content: space-between;"> |
| | | <span>发送人:{{m.createUser}}</span> |
| | | <span>收件人:{{ m.consigneeUser }}</span> |
| | | </p> |
| | | </div> |
| | | </div> |
| | | <div class="new-notice" v-if="!m.viewStatus"> |
| | | <span>new</span> |
| | | </div> |
| | | </div> |
| | | <div class="new-notice" v-if="m.isRead==0"> |
| | | <span>new</span> |
| | | </div> |
| | | </div> |
| | | </scroll-pagination> |
| | | <div v-if="list.length<1&&!loading" style="color:#909399;font-size:14px;text-align: center;margin-top:200px" >暂无数据</div> |
| | | </div> |
| | | </el-drawer> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import ScrollPagination from '../components/tool/scroll-paging.vue' |
| | | export default { |
| | | components: { |
| | | ScrollPagination |
| | | }, |
| | | data(){ |
| | | return{ |
| | | drawer:false, |
| | | direction:'rtl', |
| | | options:[], |
| | | type:'0', |
| | | list:[ |
| | | dropdownList0:[ |
| | | { |
| | | type:1, |
| | | title:'标题', |
| | | content:'内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容', |
| | | time:'2019-08-07 15:34:26', |
| | | status:0,//消息状态:拒绝、接收 |
| | | isRead:0,//是否已读 |
| | | sendUser:'小明', |
| | | getUser:'李华', |
| | | }, |
| | | { |
| | | type:2, |
| | | title:'标题', |
| | | content:'内容', |
| | | time:'2019-08-07 15:34:26', |
| | | status:1,//消息状态:拒绝、接收 |
| | | isRead:1,//是否已读 |
| | | sendUser:'小明', |
| | | getUser:'李华', |
| | | }, |
| | | { |
| | | type:3, |
| | | title:'标题', |
| | | content:'内容', |
| | | time:'2019-08-07 15:34:26', |
| | | status:1,//消息状态:拒绝、接收 |
| | | isRead:0,//是否已读 |
| | | sendUser:'小明', |
| | | getUser:'李华', |
| | | }, |
| | | { |
| | | type:4, |
| | | title:'标题', |
| | | content:'内容', |
| | | time:'2019-08-07 15:34:26', |
| | | status:1,//消息状态:拒绝、接收 |
| | | isRead:0,//是否已读 |
| | | sendUser:'小明', |
| | | getUser:'李华', |
| | | }, |
| | | { |
| | | type:5, |
| | | title:'标题', |
| | | content:'内容', |
| | | time:'2019-08-07 15:34:26', |
| | | status:1,//消息状态:拒绝、接收 |
| | | isRead:0,//是否已读 |
| | | sendUser:'小明', |
| | | getUser:'李华', |
| | | }, |
| | | { |
| | | type:6, |
| | | title:'标题', |
| | | content:'内容', |
| | | time:'2019-08-07 15:34:26', |
| | | status:1,//消息状态:拒绝、接收 |
| | | isRead:1,//是否已读 |
| | | sendUser:'小明', |
| | | getUser:'李华', |
| | | }, |
| | | { |
| | | type:6, |
| | | title:'标题', |
| | | content:'内容', |
| | | time:'2019-08-07 15:34:26', |
| | | status:1,//消息状态:拒绝、接收 |
| | | isRead:1,//是否已读 |
| | | sendUser:'小明', |
| | | getUser:'李华', |
| | | }, |
| | | { |
| | | type:6, |
| | | title:'标题', |
| | | content:'内容', |
| | | time:'2019-08-07 15:34:26', |
| | | status:1,//消息状态:拒绝、接收 |
| | | isRead:1,//是否已读 |
| | | sendUser:'小明', |
| | | getUser:'李华', |
| | | }, |
| | | { |
| | | type:6, |
| | | title:'标题', |
| | | content:'内容', |
| | | time:'2019-08-07 15:34:26', |
| | | status:1,//消息状态:拒绝、接收 |
| | | isRead:1,//是否已读 |
| | | sendUser:'小明', |
| | | getUser:'李华', |
| | | }, |
| | | { |
| | | type:6, |
| | | title:'标题', |
| | | content:'内容', |
| | | time:'2019-08-07 15:34:26', |
| | | status:1,//消息状态:拒绝、接收 |
| | | isRead:1,//是否已读 |
| | | sendUser:'小明', |
| | | getUser:'李华', |
| | | }, |
| | | ], |
| | | dropdownList:[ |
| | | { |
| | | label:'拒绝', |
| | | label:'通过', |
| | | value:0 |
| | | }, |
| | | { |
| | | label:'接收', |
| | | label:'不通过', |
| | | value:1 |
| | | }, |
| | | { |
| | | label:'通过', |
| | | label:'查看更多', |
| | | value:4 |
| | | }, |
| | | ], |
| | | dropdownList1:[ |
| | | { |
| | | label:'批准', |
| | | value:2 |
| | | }, |
| | | { |
| | | label:'不通过', |
| | | label:'不批准', |
| | | value:3 |
| | | }, |
| | | { |
| | | label:'批准', |
| | | label:'查看更多', |
| | | value:4 |
| | | }, |
| | | { |
| | | label:'不批准', |
| | | value:5 |
| | | }, |
| | | { |
| | | label:'查看更多', |
| | | value:6 |
| | | }, |
| | | ] |
| | | ], |
| | | list:[], |
| | | currentPage:1, |
| | | pageSize: 8, // 一页7条 |
| | | total: null, |
| | | loading: true, // 组件loading的展示,默认为true |
| | | finishLoding: false, // 加载完成,显示已经没有更多了 |
| | | keyMap:{} |
| | | } |
| | | }, |
| | | mounted(){ |
| | | this.getTypeDicts(); |
| | | this.currentPage = 1; |
| | | this.keyMap = {}; |
| | | this.list = []; |
| | | this.refresh(); |
| | | }, |
| | | methods:{ |
| | | refresh(){ |
| | | const key = `_${this.currentPage}` |
| | | const value = this.keyMap[key] |
| | | // 如果value存在,表示缓存有值,那么阻止请求 |
| | | if(value) { |
| | | return |
| | | } |
| | | // value不存在,表示第一次请求,设置占位 |
| | | this.keyMap[key] = 'temp' |
| | | if(this.currentPage==1){ |
| | | this.loading = true |
| | | } |
| | | if(this.list.length==0){ |
| | | this.finishLoding = false |
| | | } |
| | | let type = this.type==0?null:this.type; |
| | | this.$axios.get(this.$api.informationNotification.page+'?size='+this.pageSize+'¤t='+this.currentPage+(type?'&messageType='+type:'')).then(res => { |
| | | if(res.code === 201){ |
| | | return |
| | | } |
| | | let list = res.data.records; |
| | | this.total = res.data.total; |
| | | if(list.length==0){ |
| | | this.finishLoding = true; |
| | | }else{ |
| | | if(list.length<this.pageSize){ |
| | | this.finishLoding = true; |
| | | } |
| | | this.list = this.list.concat(list) |
| | | if(this.total==this.list.length){ |
| | | this.finishLoding = true; |
| | | } |
| | | this.currentPage++ |
| | | } |
| | | this.loading = false |
| | | }) |
| | | }, |
| | | open(){ |
| | | this.drawer = true; |
| | | }, |
| | |
| | | this.options = data; |
| | | }) |
| | | }, |
| | | goNoticeDetail(){ |
| | | this.drawer = false; |
| | | this.$parent.addTab({ |
| | | v: "消息详情", |
| | | i: "el-icon-s-tools", |
| | | u: "notice-detail", |
| | | k:35, |
| | | p: "abcd" |
| | | },29); |
| | | goNoticeDetail(row){ |
| | | this.$axios.put(this.$api.informationNotification.triggerModificationStatusToRead+'/'+row.id).then(res => { |
| | | this.drawer = false; |
| | | row.num = Math.random(100); |
| | | this.$bus.$emit("change", JSON.stringify(row)); |
| | | this.$parent.addTab({ |
| | | v: "消息详情", |
| | | i: "el-icon-s-tools", |
| | | u: "notice-detail", |
| | | k:35, |
| | | p: "abcd" |
| | | },29); |
| | | this.list = []; |
| | | this.keyMap = {}; |
| | | this.currentPage = 1; |
| | | this.refresh(); |
| | | this.$emit('goNoticeDetail') |
| | | }) |
| | | }, |
| | | handleDropdown(e){ |
| | | handleDropdown(e,row){ |
| | | switch(e){ |
| | | case 0: |
| | | break; |
| | | case 6: |
| | | this.goNoticeDetail() |
| | | case 4: |
| | | this.goNoticeDetail(row) |
| | | break; |
| | | } |
| | | }, |
| | | handleDel(row){ |
| | | this.$confirm('是否删除当前数据?', "警告", { |
| | | confirmButtonText: "确定", |
| | | cancelButtonText: "取消", |
| | | type: "warning" |
| | | }).then(() => { |
| | | this.$axios.delete(this.$api.informationNotification.deleteDataBasedOnId+'?id='+row.id).then(res => { |
| | | if (res.code === 201) { |
| | | return |
| | | } |
| | | this.$message.success('删除成功') |
| | | this.list = []; |
| | | this.keyMap = {}; |
| | | this.currentPage = 1; |
| | | this.refresh() |
| | | }).catch(e => { |
| | | this.$message.error('删除失败') |
| | | }) |
| | | }).catch(() => {}) |
| | | }, |
| | | handleType(){ |
| | | this.list = []; |
| | | this.keyMap = {}; |
| | | this.currentPage = 1; |
| | | this.refresh(); |
| | | }, |
| | | handleDropdownAll(e){ |
| | | let type = false; |
| | | if(e==1){ |
| | | type = true; |
| | | } |
| | | this.$axios.put(this.$api.informationNotification.informationReadOrDelete+'/'+type).then(res => { |
| | | if(res.code===201){ |
| | | return |
| | | } |
| | | this.$message.success('操作成功') |
| | | this.list = []; |
| | | this.keyMap = {}; |
| | | this.currentPage = 1; |
| | | this.refresh(); |
| | | }) |
| | | } |
| | | } |
| | | }, |
| | | } |
| | | </script> |
| | | |