From 91b0174402dc5c993a3fc506d89bae7ba1e0ce99 Mon Sep 17 00:00:00 2001 From: licp <lichunping@guanfang.com.cn> Date: 星期二, 23 四月 2024 18:04:52 +0800 Subject: [PATCH] 完成消息列表接口对接 --- src/view/notice.vue | 335 ++++++++++++++++++++++++++++++------------------------- 1 files changed, 185 insertions(+), 150 deletions(-) diff --git a/src/view/notice.vue b/src/view/notice.vue index dac79a8..691e041 100644 --- a/src/view/notice.vue +++ b/src/view/notice.vue @@ -4,11 +4,11 @@ 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" @@ -17,56 +17,74 @@ </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" @scroll="scrollFn" v-loading="loading"> <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"> + <div class="btns" v-if="m"> + <el-dropdown style="margin-right: 20px;" trigger="click" @command="e=>handleDropdown(e,m)" v-if="m.messageType==2||m.messageType==3"> <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"> + <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;"></i> + <i class="el-icon-close" style="cursor: pointer;" @click="handleDel(m)"></i> </div> <div class="content"> - <img :src="`../../static/img/notice-${m.type}.svg`" alt="" style="width: 50px;margin-right: 18px;"> + <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.title }}</span> - <span class="time" style="color: #999999;font-size: 12px;">{{ m.time }}</span> + <span>{{ m.theme }}<el-tag :type="!m.messageStatus?'danger':'success'" size="small" v-if="m.messageType==1||m.messageType==2||m.messageType==3" style="margin-left: 8px;">{{ !m.messageStatus?'鏈鐞�':'宸插鐞�' }}</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> - <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="color: #999999;font-size: 14px;margin-bottom: 6px;cursor: pointer;" class="ellipsis-multiline" @click="goNoticeDetail(m)">{{ m.content }}</p> <p style="font-size: 12px;color: #999999;display: flex;align-items: center;justify-content: space-between;"> - <span>鍙戦�佷汉锛歿{m.sendUser}}</span> - <span>鏀朵欢浜猴細{{ m.getUser }}</span> + <span>鍙戦�佷汉锛歿{m.createUser}}</span> + <span>鏀朵欢浜猴細{{ m.consigneeUser }}</span> </p> </div> </div> - <div class="new-notice" v-if="m.isRead==0"> + <div class="new-notice" v-if="!m.viewStatus"> <span>new</span> </div> + </div> + <div v-if="list.length<1&&!loading&&!isLoding" style="color:#909399;font-size:14px;text-align: center;margin-top:200px" >鏆傛棤鏁版嵁</div> + <div v-if="list.length>0"> + <el-button + v-if="isLoding" + type="text" + style="display: flex; margin: 0 auto; color: #909399" + ><i class="el-icon-loading" style="font-size:20px"></i + ></el-button> + <el-button + type="text" + v-if="finishLoding" + style="display: flex; margin: 0 auto; color: #909399" + >宸茬粡娌℃湁鏇村鍟</el-button + > </div> </div> </el-drawer> @@ -74,6 +92,7 @@ </template> <script> + export default { data(){ return{ @@ -81,144 +100,81 @@ direction:'rtl', options:[], type:'0', - list:[ + 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 - }, - ] + ], + currentPage:1, + pageSize: 16, // 涓�椤�16鏉� + total: null, + loading: false, // 缁勪欢loading鐨勫睍绀�,榛樿涓簍rue + isLoding: false, // 鍔犺浇涓紝loading鍥炬爣,榛樿涓簍rue + finishLoding: false // 鍔犺浇瀹屾垚锛屾樉绀哄凡缁忔病鏈夋洿澶氫簡 } }, mounted(){ this.getTypeDicts(); + this.currentPage = 1; + this.list = []; + this.refresh(); }, methods:{ + refresh(){ + if(this.currentPage>1){ + this.isLoding = true + }else{ + this.loading = true + } + if(this.list.length==0){ + window.addEventListener("scroll", this.throttle(this.scrollFn, 20000)); + } + 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.loading = false + this.isLoding = false; + }) + }, open(){ this.drawer = true; }, @@ -233,26 +189,105 @@ 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; + this.$parent.addTab({ + v: "娑堟伅璇︽儏", + i: "el-icon-s-tools", + u: "notice-detail", + k:35, + p: "abcd" + },29); + this.list = []; + this.currentPage = 1; + this.refresh(); + }) }, - 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.currentPage = 1; + this.refresh() + }).catch(e => { + this.$message.error('鍒犻櫎澶辫触') + }) + }).catch(() => {}) + }, + // 婊氬姩瑙﹀簳鍔犺浇 + scrollFn() { + let clientHeight = document.documentElement.clientHeight - 18; //鍙鍖哄煙 + let scrollHeight = document.body.scrollHeight; // 婊氬姩鏂囨。楂樺害 + let scrollTop = parseInt(document.documentElement.scrollTop); // 宸叉粴鍔ㄧ殑楂樺害 + let height = 300; + if ( + scrollTop + clientHeight >= scrollHeight - height && + scrollHeight != 0 + ) { + if (!this.finishLoding&&this.currentPage*this.pageSize<this.total) { + this.currentPage = this.currentPage + 1; + this.refresh(); + } + } else { + return false; + } + }, + throttle(fn, wait) { + // 灏佽鍑芥暟杩涜鑺傛祦 + var timer = null; + return function () { + var context = this; + var args = arguments; + if (!timer) { + timer = setTimeout(function () { + fn.apply(context, args); + timer = null; + }, wait); + } + }; + }, + handleType(){ + this.list = []; + 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.currentPage = 1; + this.refresh(); + }) } - } + }, + destroyed() { + window.removeEventListener("scroll", this.throttle(), false); + }, } </script> -- Gitblit v1.9.3