index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <template>
  2. <div class="message">
  3. <div v-if="!show" class="page-container">
  4. <van-tabs v-model="query.type" @change="refreshData">
  5. <van-tab title="公告/通知" name="1"></van-tab>
  6. <van-tab title="业务提醒" name="2"></van-tab>
  7. <van-tab title="消息" name="3"></van-tab>
  8. </van-tabs>
  9. <div class="card-list">
  10. <Scroll
  11. ref="Scroll"
  12. @refresh="refreshData"
  13. @loadMore="getDataList"
  14. :pullup="pullup">
  15. <empty v-if="!dataList.length" />
  16. <card class="list-item" v-else v-for="(v,i) in dataList" :key="i">
  17. <van-cell :title="v.title" :label="v.content" @click="clickItem(v)">
  18. <template #right-icon>
  19. <i class="point-icon" :class="{'active':!v.isRead}" />
  20. </template>
  21. <template #label>
  22. <div class="cell-label">
  23. <p class="text-style">{{v.content}}</p>
  24. </div>
  25. <p class="cell-time">{{v.publishTime}}</p>
  26. </template>
  27. </van-cell>
  28. </card>
  29. </Scroll>
  30. </div>
  31. </div>
  32. <!-- 消息详情 -->
  33. <div v-else class="message-detail">
  34. <van-nav-bar
  35. title="消息详情"
  36. left-arrow
  37. @click-left="onClickLeft"
  38. />
  39. <div class="detail-box" v-if="selected">
  40. <div class="msg-title">
  41. <p>{{selected.title}}</p>
  42. <p class="cell-time">{{selected.publishTime}}</p>
  43. </div>
  44. <div class="message-content">
  45. <div class="text-content">
  46. <p>{{selected.content}}</p>
  47. <div v-if="selected.fileList" class="file-box" >
  48. 附件:
  49. <div v-for="(v,i) in selected.fileList">
  50. <van-icon color="#1989fa" name="guide-o" />
  51. <span style="color: #1989fa;" @click="preview(v)" :key="v.name">{{v.name}}</span>
  52. </div>
  53. </div>
  54. </div>
  55. </div>
  56. </div>
  57. </div>
  58. </div>
  59. </template>
  60. <script>
  61. import Scroll from '@/components/scroll/scroll'
  62. import {msgList, dataList, setRead, msgRead} from './api'
  63. import {mapGetters} from "vuex"
  64. export default {
  65. components: {
  66. Scroll,
  67. },
  68. data() {
  69. return {
  70. show:false,
  71. selected:null,
  72. dataList: [],
  73. query:{
  74. type:1,
  75. pageNum:1,
  76. pageSize:10,
  77. },
  78. pullup:true,
  79. message:null,
  80. total:0,
  81. };
  82. },
  83. computed:{
  84. ...mapGetters(['orgId','id','roleList'])
  85. },
  86. mounted(){
  87. this.getDataList();
  88. },
  89. methods:{
  90. preview(file){
  91. this.openFilePreview(file);
  92. },
  93. onClickLeft(){
  94. this.show = false;
  95. },
  96. clickItem(v){
  97. let queryMethod,data;
  98. if(this.query.type == 1){
  99. queryMethod = setRead;
  100. data = {
  101. announcementNotificationId:v.id,
  102. orgId:this.orgId,
  103. userId:this.id,
  104. }
  105. }else {
  106. queryMethod = msgRead;
  107. data = v.id
  108. }
  109. queryMethod(data).then(res=>{
  110. this.dataList.forEach(item=>{
  111. if(item.id === v.id){
  112. item.isRead = true;
  113. }
  114. })
  115. })
  116. this.selected = v;
  117. this.show = true;
  118. },
  119. refreshData(){
  120. this.pullup = true;
  121. this.query.pageNum = 1;
  122. this.total = 0;
  123. this.dataList = [];
  124. this.getDataList();
  125. },
  126. getDataList(){
  127. if( this.dataList.length !== 0 && this.dataList.length >= this.total) {
  128. this.pullup = false;
  129. this.$toast('已加载完毕');
  130. return;
  131. }
  132. let data = {};
  133. if(this.query.type == 1){
  134. data = {
  135. ...this.query,
  136. userId:this.id,
  137. orgId:this.orgId,
  138. tagRoleIds:this.roleList.map(v=>{return v.roleId}),
  139. }
  140. msgList(data).then(res=>{
  141. if(res.total === '0'){
  142. this.pullup = false;
  143. this.$toast('已加载完毕');
  144. return
  145. }
  146. this.total = res.total;
  147. if(this.dataList.length < res.total) {
  148. this.dataList = [...this.dataList,...res.rows] ;
  149. this.pullup = true;
  150. this.query.pageNum++;
  151. this.$refs.Scroll.refresh();
  152. }
  153. })
  154. return;
  155. }
  156. data = {
  157. ...this.query,
  158. userId:this.id,
  159. }
  160. dataList(data).then(res=>{
  161. if(res.total === '0'){
  162. this.pullup = false;
  163. this.$toast('已加载完毕');
  164. return
  165. }
  166. this.total = res.total;
  167. if(this.dataList.length < res.total) {
  168. this.dataList = [...this.dataList,...res.rows] ;
  169. this.pullup = true;
  170. this.query.pageNum++;
  171. this.$refs.Scroll.refresh();
  172. }
  173. })
  174. }
  175. }
  176. }
  177. </script>
  178. <style lang="scss">
  179. .message{
  180. //.van-empty{
  181. // background-color: #fff;
  182. //}
  183. .list-item{
  184. .van-cell{
  185. padding: 0;
  186. }
  187. }
  188. .van-tab{
  189. color: #ccc;
  190. }
  191. .van-tabs__nav{
  192. background-color: #008cd6;
  193. }
  194. .van-tab--active{
  195. color: #fff;
  196. }
  197. .van-cell-group{
  198. background-color: #fff;
  199. }
  200. .van-tabs__line{
  201. background-color: #fff;
  202. }
  203. }
  204. </style>
  205. <style lang="scss" scoped>
  206. .message{
  207. }
  208. .card-list{
  209. padding:0 20px 20px 20px;
  210. height: calc(100vh - 190px);
  211. overflow: auto;
  212. }
  213. .list-item{
  214. //margin-bottom: 20px;
  215. //&:last-child{
  216. // margin-bottom: 0;
  217. //}
  218. }
  219. .cell-label{
  220. width: 100%;
  221. padding: 10px;
  222. min-height: 50px;
  223. line-height: 36px;
  224. max-height: 250px;
  225. overflow: hidden;
  226. >p{
  227. word-break: break-word;
  228. display: -webkit-box;
  229. overflow: hidden;
  230. text-overflow: ellipsis;
  231. -webkit-line-clamp: 3;
  232. -webkit-box-orient: vertical;
  233. line-height: 40px;
  234. }
  235. }
  236. .cell-time{
  237. text-align: right;
  238. height: 30px;
  239. font-size: 24px;
  240. color:#aaa;
  241. }
  242. .point-icon{
  243. width: 20px;
  244. height: 20px;
  245. background-color:#ccc;
  246. border-radius: 50%;
  247. margin-top: 10px;
  248. display: none;
  249. &.active{
  250. display: block;
  251. background-color: #03a5ff;
  252. }
  253. }
  254. .message-detail{
  255. height: calc(100vh - 102px);
  256. }
  257. .detail-box{
  258. height: calc(100% - 90px);
  259. overflow: auto;
  260. background-color: #fff;
  261. }
  262. .msg-title{
  263. display: flex;
  264. flex-direction: column;
  265. box-sizing: border-box;
  266. width: 100%;
  267. padding: 2.666667vw 4.266667vw;
  268. overflow: hidden;
  269. color: #323233;
  270. font-size: 3.733333vw;
  271. line-height: 6.4vw;
  272. border-bottom: 1px solid #f5f5f5;
  273. }
  274. .message-content{
  275. width: 100%;
  276. padding:20px 30px 20px 30px;
  277. height: 100%;
  278. overflow: auto;
  279. .text-content{
  280. width: 100%;
  281. min-height: 40px;
  282. overflow: auto;
  283. >p{
  284. text-indent: 2em;
  285. word-break: break-word;
  286. white-space: pre-wrap;
  287. text-align: justify;
  288. width: 100%;
  289. color: #777;
  290. }
  291. }
  292. .file-box{
  293. width: 100%;
  294. min-height: 40px;
  295. padding: 20px 0;
  296. >div{
  297. line-height: 32px;
  298. padding-left: 20px;
  299. margin: 10px 0;
  300. }
  301. }
  302. }
  303. </style>