msg.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <div class="msg">
  3. <div class="msg-title">通知消息
  4. <el-button round size="small" @click="setAllRead()">全部已读</el-button>
  5. </div>
  6. <div class="msg-type">
  7. <div class="msg-type-item" v-for="(item, index) in msgType" @click="getMsgList(item.msgType)">
  8. <el-badge :value="item.total" :max="99" :hidden="item.total==0" class="item" >
  9. <el-button round size="small">{{item.msgTypeName}}</el-button>
  10. </el-badge>
  11. </div>
  12. </div>
  13. <div class="mst-list">
  14. <el-timeline >
  15. <el-timeline-item :timestamp="item.createTime" placement="top" v-for="(item, index) in list">
  16. <el-card>
  17. <h4>{{item.title}}</h4>
  18. <p>{{item.content}}</p>
  19. <div><el-button type="text" v-if="item.isRead==0 && item.type==2" @click="toUrl('/prescribeAudit/Index',item)">前往处方审核</el-button></div>
  20. <div><el-button type="text" v-if="item.isRead==0 && item.type==1 && item.title.includes('药师拒方')" @click="toUrl('/order/refuse',item)">前往拒方开方</el-button></div>
  21. <div><el-button type="text" v-if="item.isRead==0 && item.type==1 && item.title.includes('用户信息采集开方')" @click="setRead(item)">前往用户处方开方</el-button></div>
  22. <div><el-button type="text" v-if="item.isRead==0 && item.type==3" @click="setRead(item)">前往信息采集建议</el-button></div>
  23. <div><el-button type="text" v-if="item.isRead==0" @click="setRead(item)">标记为已读</el-button></div>
  24. </el-card>
  25. </el-timeline-item>
  26. </el-timeline>
  27. <div v-if="isMore" class="more" @click="loadMore()"><el-button type="text">加载更多</el-button></div>
  28. </div>
  29. </div>
  30. </template>
  31. <script>
  32. import { getMsg, getMsgList, getMsgCount, setRead } from "@/api/doctorMsg";
  33. export default {
  34. name: "msg",
  35. components: { },
  36. data() {
  37. return {
  38. isMore:false,
  39. currentTypeId:undefined,
  40. msgType:[],
  41. // 遮罩层
  42. loading: true,
  43. // 选中数组
  44. ids: [],
  45. // 非单个禁用
  46. single: true,
  47. // 非多个禁用
  48. multiple: true,
  49. // 显示搜索条件
  50. showSearch: true,
  51. // 总条数
  52. total: 0,
  53. // 产品表格数据
  54. list: [],
  55. queryParams: {
  56. pageNum: 1,
  57. pageSize: 10,
  58. },
  59. };
  60. },
  61. created() {
  62. this.getMsg();
  63. },
  64. mounted() {
  65. },
  66. methods: {
  67. toUrl(url,item){
  68. this.setRead(item)
  69. this.$router.push(url)
  70. this.$emit("close")
  71. },
  72. loadMore () {
  73. this.queryParams.pageNum += 1;
  74. this.getList();
  75. },
  76. getMsg(){
  77. getMsg().then(response => {
  78. this.msgType = response.counts;
  79. if(this.currentTypeId==undefined){
  80. this.currentTypeId=this.msgType[0].msgType;
  81. }
  82. this.list =[];
  83. this.getList();
  84. });
  85. },
  86. setAllRead(){
  87. setAllRead().then(response => {
  88. this.getMsg();
  89. //更新父组件的数量
  90. this.$emit('update-count');
  91. });
  92. },
  93. setRead(row){
  94. row.isRead=1;
  95. setRead(row).then(response => {
  96. this.getMsg();
  97. //更新父组件的数量
  98. this.$emit('update-count');
  99. });
  100. },
  101. getMsgList(typeId){
  102. this.currentTypeId=typeId;
  103. this.queryParams.pageNum=1;
  104. this.list =[];
  105. this.getList();
  106. },
  107. getList() {
  108. this.loading = true;
  109. this.queryParams.type=this.currentTypeId;
  110. getMsgList(this.queryParams).then(response => {
  111. this.list=this.list.concat( response.data.list);
  112. this.total = response.data.total;
  113. this.loading = false;
  114. this.isMore=response.data.hasNextPage;
  115. });
  116. },
  117. getMsgType() {
  118. getMsg().then(response => {
  119. this.msgType = response.counts;
  120. });
  121. },
  122. }
  123. };
  124. </script>
  125. <style scoped>
  126. .msg{
  127. padding:15px;
  128. }
  129. .dialog-footer{
  130. margin-top: 30px;
  131. float: right;
  132. }
  133. .msg-type{
  134. display: flex;
  135. flex-direction: row;
  136. flex-wrap: wrap;
  137. }
  138. .msg-type-item {
  139. margin: 10px;
  140. }
  141. .mst-list{
  142. margin: 10px 0px;
  143. }
  144. </style>
  145. <style >
  146. .el-drawer__header{
  147. margin-bottom: 10px;
  148. }
  149. .more{
  150. text-align: center;
  151. font-size: 14px;
  152. color: #909399;
  153. }
  154. .msg-title{
  155. margin: 10px 10px 20px 10px;
  156. font-size: 16px;
  157. }
  158. </style>