index.vue 6.6 KB

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