| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309 |
- <template>
- <div class="message">
- <div v-if="!show" class="page-container">
- <van-tabs v-model="query.type" @change="refreshData">
- <van-tab title="公告/通知" name="1"></van-tab>
- <van-tab title="业务提醒" name="2"></van-tab>
- <van-tab title="消息" name="3"></van-tab>
- </van-tabs>
- <div class="card-list">
- <Scroll
- ref="Scroll"
- @refresh="refreshData"
- @loadMore="getDataList"
- :pullup="pullup">
- <empty v-if="!dataList.length" />
- <card class="list-item" v-else v-for="(v,i) in dataList" :key="i">
- <van-cell :title="v.title" :label="v.content" @click="clickItem(v)">
- <template #right-icon>
- <i class="point-icon" :class="{'active':!v.isRead}" />
- </template>
- <template #label>
- <div class="cell-label">
- <p >{{v.content}}</p>
- </div>
- <p class="cell-time">{{v.publishTime}}</p>
- </template>
- </van-cell>
- </card>
- </Scroll>
- </div>
- </div>
- <!-- 消息详情 -->
- <div v-else class="message-detail">
- <van-nav-bar
- title="消息详情"
- left-arrow
- @click-left="onClickLeft"
- />
- <div class="detail-box" v-if="selected">
- <div class="msg-title">
- <p>{{selected.title}}</p>
- <p class="cell-time">{{selected.publishTime}}</p>
- </div>
- <div class="message-content">
- <div class="text-content">
- <p>{{selected.content}}</p>
- <div v-if="selected.fileList" class="file-box" >
- 附件:
- <div v-for="(v,i) in selected.fileList">
- <span style="color: #1989fa;" @click="preview(v)" :key="v.name">{{v.name}}</span>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script>
- import Scroll from '@/components/scroll/scroll'
- import {msgList, dataList, setRead, msgRead} from './api'
- import {mapGetters} from "vuex"
- export default {
- components: {
- Scroll,
- },
- data() {
- return {
- show:false,
- selected:null,
- dataList: [],
- query:{
- type:1,
- pageNum:1,
- pageSize:10,
- },
- pullup:true,
- message:null,
- total:0,
- };
- },
- computed:{
- ...mapGetters(['orgId','id','roleList'])
- },
- mounted(){
- this.getDataList();
- },
- methods:{
- preview(file){
- this.openFilePreview(file);
- },
- onClickLeft(){
- this.show = false;
- },
- clickItem(v){
- let queryMethod,data;
- if(this.query.type == 1){
- queryMethod = setRead;
- data = {
- announcementNotificationId:v.id,
- orgId:this.orgId,
- userId:this.id,
- }
- }else {
- queryMethod = msgRead;
- data = v.id
- }
- queryMethod(data).then(res=>{
- this.dataList.forEach(item=>{
- if(item.id === v.id){
- item.isRead = true;
- }
- })
- })
- this.selected = v;
- this.show = true;
- },
- refreshData(){
- this.pullup = true;
- this.query.pageNum = 1;
- this.total = 0;
- this.dataList = [];
- this.getDataList();
- },
- getDataList(){
- if( this.dataList.length !== 0 && this.dataList.length >= this.total) {
- this.pullup = false;
- this.$toast('已加载完毕');
- return;
- }
- let data = {};
- if(this.query.type == 1){
- data = {
- ...this.query,
- userId:this.id,
- orgId:this.orgId,
- tagRoleIds:this.roleList.map(v=>{return v.roleId}),
- }
- msgList(data).then(res=>{
- if(res.total === '0'){
- this.pullup = false;
- this.$toast('已加载完毕');
- return
- }
- this.total = res.total;
- if(this.dataList.length < res.total) {
- this.dataList = [...this.dataList,...res.rows] ;
- this.pullup = true;
- this.query.pageNum++;
- this.$refs.Scroll.refresh();
- }
- })
- return;
- }
- data = {
- ...this.query,
- userId:this.id,
- }
- dataList(data).then(res=>{
- if(res.total === '0'){
- this.pullup = false;
- this.$toast('已加载完毕');
- return
- }
- this.total = res.total;
- if(this.dataList.length < res.total) {
- this.dataList = [...this.dataList,...res.rows] ;
- this.pullup = true;
- this.query.pageNum++;
- this.$refs.Scroll.refresh();
- }
- })
- }
- }
- }
- </script>
- <style lang="scss">
- .message{
- //.van-empty{
- // background-color: #fff;
- //}
- .list-item{
- .van-cell{
- padding: 0;
- }
- }
- .van-tab{
- color: #ccc;
- }
- .van-tabs__nav{
- background-color: #008cd6;
- }
- .van-tab--active{
- color: #fff;
- }
- .van-cell-group{
- background-color: #fff;
- }
- .van-tabs__line{
- background-color: #fff;
- }
- }
- </style>
- <style lang="scss" scoped>
- .message{
- }
- .card-list{
- padding:0 20px 20px 20px;
- height: calc(100vh - 190px);
- overflow: auto;
- }
- .list-item{
- //margin-bottom: 20px;
- //&:last-child{
- // margin-bottom: 0;
- //}
- }
- .cell-label{
- width: 100%;
- padding: 10px;
- min-height: 50px;
- line-height: 36px;
- max-height: 250px;
- overflow: hidden;
- >p{
- word-break: break-word;
- display: -webkit-box;
- overflow: hidden;
- text-overflow: ellipsis;
- -webkit-line-clamp: 3;
- -webkit-box-orient: vertical;
- line-height: 40px;
- }
- }
- .cell-time{
- text-align: right;
- height: 30px;
- font-size: 24px;
- color:#aaa;
- }
- .point-icon{
- width: 20px;
- height: 20px;
- background-color:#ccc;
- border-radius: 50%;
- margin-top: 10px;
- display: none;
- &.active{
- display: block;
- background-color: #03a5ff;
- }
- }
- .message-detail{
- height: calc(100vh - 102px);
- }
- .detail-box{
- height: calc(100% - 90px);
- overflow: auto;
- background-color: #fff;
- }
- .msg-title{
- display: flex;
- flex-direction: column;
- box-sizing: border-box;
- width: 100%;
- padding: 2.666667vw 4.266667vw;
- overflow: hidden;
- color: #323233;
- font-size: 3.733333vw;
- line-height: 6.4vw;
- border-bottom: 1px solid #f5f5f5;
- }
- .message-content{
- width: 100%;
- padding:20px 30px 20px 30px;
- height: 100%;
- overflow: auto;
- .text-content{
- width: 100%;
- min-height: 40px;
- overflow: auto;
- >p{
- text-indent: 2em;
- word-break: break-word;
- white-space: pre-wrap;
- text-align: justify;
- width: 100%;
- color: #777;
- }
- }
- .file-box{
- width: 100%;
- min-height: 40px;
- padding: 20px 0;
- >div{
- line-height: 40px;
- height: 40px;
- padding-left: 20px;
- }
- }
- }
- </style>
|