index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <!--
  2. * @Description: 自定义右下角弹出的消息
  3. * @Author: Rockery
  4. * @Date: 2021-12-14 11:50:13
  5. * @LastEditors: Rockery
  6. * @LastEditTime: 2022-01-21 11:47:26
  7. * @FilePath: \party_construct_web\src\components\BottomRightNotification\index.vue
  8. * @Copyright: Copyright (c) 2016~2021 Rockery(1113269755@qq.com)
  9. -->
  10. <template>
  11. <div class="rocbrnotify">
  12. <slot></slot>
  13. </div>
  14. </template>
  15. <script>
  16. import { getWaitHandleList } from "@/api/home";
  17. export default {
  18. name: 'Bottomrightnotification',
  19. data() {
  20. return {
  21. rocBrNotifyObj: null,
  22. intervalTimer: null
  23. };
  24. },
  25. created() {
  26. // this.initData();
  27. },
  28. mounted() {
  29. this.intervalTimer = setInterval(() => {
  30. this.getWaitHandleListData();
  31. }, 120000);
  32. },
  33. destroyed() {
  34. this.intervalTimer && clearInterval(this.intervalTimer);
  35. },
  36. methods: {
  37. /** 初始化数据 */
  38. initData() {
  39. this.getWaitHandleListData();
  40. },
  41. getWaitHandleListData() {
  42. getWaitHandleList().then(
  43. resp => {
  44. if (resp.code === 200 && resp.data > 0) {
  45. this.openMessageTips(
  46. {
  47. messageId: `ROCBRNOTIFY-${new Date().getTime()}`,
  48. content: `您当前有 ${resp.data} 条数据将超出处理时间,请尽快安排处理`
  49. }
  50. );
  51. }
  52. }
  53. );
  54. },
  55. /**
  56. * 打开一个新的通知
  57. */
  58. openMessageTips(message) {
  59. let _this = this;
  60. this.handleCloseBtnClick();
  61. // 组织通知数据
  62. let notify = this.$notify({
  63. position: 'bottom-right',
  64. showClose: false,
  65. dangerouslyUseHTMLString: true,
  66. customClass: 'rocbrnotify-dialog',
  67. message: this.$createElement(
  68. 'div',
  69. {
  70. class: {
  71. 'rocbrnotify-dialog-container': true
  72. }
  73. },
  74. [
  75. this.$createElement(
  76. 'div',
  77. {
  78. class: {
  79. 'rocbrnotify-dialog-title': true
  80. }
  81. },
  82. '待处理通知'
  83. ),
  84. this.$createElement(
  85. 'div',
  86. {
  87. class: {
  88. 'rocbrnotify-dialog-content': true
  89. }
  90. },
  91. [this.$createElement('span', null, message.content)]
  92. ),
  93. this.$createElement(
  94. 'div',
  95. {
  96. class: {
  97. 'rocbrnotify-dialog-btngroup': true
  98. }
  99. },
  100. [
  101. this.$createElement(
  102. 'el-button',
  103. {
  104. attrs: {
  105. type: 'rocpartyprimarybtn'
  106. },
  107. on: {
  108. click: this.handleViewBtnClick
  109. }
  110. },
  111. "查看"
  112. ),
  113. this.$createElement(
  114. 'el-button',
  115. {
  116. attrs: {
  117. type: 'rocpartyprimaryplainbtn'
  118. },
  119. on: {
  120. click: this.handleCloseBtnClick
  121. }
  122. },
  123. "好的"
  124. )
  125. ]
  126. )
  127. ]
  128. ),
  129. duration: 20000
  130. });
  131. this.rocBrNotifyObj = notify;
  132. },
  133. /**
  134. * 右下角弹出的消息的查看事件
  135. */
  136. handleViewBtnClick() {
  137. this.handleCloseBtnClick();
  138. this.$router.replace({
  139. path: '/redirect/index'
  140. });
  141. },
  142. /**
  143. * 右下角弹出的消息的好的事件
  144. */
  145. handleCloseBtnClick() {
  146. this.rocBrNotifyObj && this.rocBrNotifyObj.close();
  147. this.rocBrNotifyObj = null;
  148. }
  149. }
  150. }
  151. </script>
  152. <style lang="scss">
  153. .rocbrnotify-dialog {
  154. &-title {
  155. text-align: center;
  156. font-size: 24px;
  157. font-weight: 700;
  158. color: #333333;
  159. }
  160. &-content {
  161. margin-top: 20px;
  162. width: 100%;
  163. font-size: 16px;
  164. font-weight: 400;
  165. color: #333333;
  166. opacity: 0.8;
  167. }
  168. &-btngroup {
  169. margin-top: 30px;
  170. display: flex;
  171. align-items: center;
  172. justify-content: center;
  173. &-viewbtn {
  174. display: flex;
  175. align-items: center;
  176. justify-content: center;
  177. width: 60px;
  178. height: 32px;
  179. background: rgba(255, 17, 17, 1);
  180. border: none;
  181. border-radius: 4px;
  182. font-weight: 400;
  183. font-size: 14px;
  184. color: #ffffff;
  185. line-height: 22px;
  186. opacity: 0.9;
  187. cursor: pointer;
  188. &:hover {
  189. background: rgb(253, 96, 96);
  190. }
  191. }
  192. &-closebtn {
  193. display: flex;
  194. align-items: center;
  195. justify-content: center;
  196. margin-left: 15px;
  197. width: 60px;
  198. height: 32px;
  199. background: #ffffff;
  200. box-sizing: border-box;
  201. border-width: 1px;
  202. border-style: solid;
  203. border-color: rgba(255, 17, 17, 1);
  204. border-radius: 4px;
  205. font-weight: 400;
  206. font-size: 14px;
  207. color: #ff1111;
  208. line-height: 22px;
  209. opacity: 0.8;
  210. cursor: pointer;
  211. &:hover {
  212. background: #f8f8f8;
  213. }
  214. }
  215. }
  216. }
  217. </style>