index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <template>
  2. <div class="ibps-mr-5">
  3. <el-tooltip
  4. :content="tooltipContent"
  5. effect="dark"
  6. placement="bottom"
  7. >
  8. <el-button
  9. class="ibps-ml-0 ibps-mr btn-text can-hover"
  10. type="text"
  11. @click="clickMore"
  12. >
  13. <el-badge
  14. :max="9999"
  15. :value="messageCount"
  16. >
  17. <ibps-icon
  18. name="bell-o"
  19. size="16"
  20. />
  21. </el-badge>
  22. </el-button>
  23. </el-tooltip>
  24. <!-- <el-popover
  25. v-else
  26. v-model="popShow"
  27. placement="bottom-end"
  28. width="350"
  29. trigger="manual"
  30. popper-class="header-message-popper"
  31. >
  32. <el-button
  33. slot="reference"
  34. class="ibps-ml-0 ibps-mr btn-text can-hover"
  35. type="text"
  36. @click="openPop"
  37. >
  38. <el-badge
  39. :max="9999"
  40. :value="messageCount"
  41. >
  42. <ibps-icon
  43. name="bell-o"
  44. size="16"
  45. />
  46. </el-badge>
  47. </el-button>
  48. <el-card body-style="padding:0;">
  49. <div
  50. slot="header"
  51. style="font-size: 20px; font-weight: 600"
  52. >
  53. {{ $t('layout.header-aside.header-message.message-count', { messageCount: messageCount }) }}
  54. </div>
  55. <div style="height: 250px">
  56. <el-scrollbar
  57. style="height: 100%; width: 100%"
  58. wrap-class="ibps-scrollbar-wrapper "
  59. >
  60. <ibps-list class="ibps-p-10">
  61. <ibps-list-item
  62. v-for="(message, index) in messageList"
  63. :key="index"
  64. @click.native="handelInteriorClick(message)"
  65. >
  66. <ibps-list-item-meta
  67. :title="message.subject"
  68. :description="message.ownerName"
  69. >
  70. <el-avatar
  71. slot="avatar"
  72. :icon="message.messageType === 'bulletin' ? 'ibps-icon-bullhorn' : 'ibps-icon-user'"
  73. shape="circle"
  74. style="background-color: #87d068"
  75. />
  76. </ibps-list-item-meta>
  77. <div slot="extra">
  78. {{ message.createTime | formatRelativeTime({ year: 'yyyy-MM-dd' }) }}
  79. </div>
  80. </ibps-list-item>
  81. </ibps-list>
  82. </el-scrollbar>
  83. </div>
  84. <div class="message-more">
  85. <el-link
  86. type="primary"
  87. @click="clickMore"
  88. >{{ $t('layout.header-aside.header-message.viewmore') }}</el-link>
  89. </div>
  90. </el-card>
  91. </el-popover> -->
  92. <!-- 消息明细 -->
  93. <inner-detail-dialog
  94. :id="editId"
  95. :sub-id="subId"
  96. :visible="dialogFormVisible"
  97. :type="type"
  98. :table-id="tableId"
  99. :table-name="tableName"
  100. :title="$t('layout.header-aside.header-message.details')"
  101. inside
  102. readonly
  103. @callback="loadData"
  104. @close="closeDialog"
  105. />
  106. </div>
  107. </template>
  108. <script>
  109. import { getMsgList, queryReceivePageList } from '@/api/platform/message/innerMessage'
  110. import InnerDetailDialog from '@/views/platform/message/inner/detail/dialog'
  111. import Watermark from './watermark/watermark-cont.js'
  112. import Bus from '@/utils/EventBus'
  113. export default {
  114. components: {
  115. InnerDetailDialog
  116. },
  117. data () {
  118. return {
  119. editId: '',
  120. subId: '',
  121. type: '',
  122. tableId: '',
  123. tableName: '',
  124. dialogFormVisible: false,
  125. isControl: true,
  126. messageList: [],
  127. messageCount: 0,
  128. infoMessage: '',
  129. countNumber: 0,
  130. popShow: false,
  131. readonly: true
  132. }
  133. },
  134. computed: {
  135. tooltipContent () {
  136. return this.messageCount === 0 ? this.$t('layout.header-aside.header-message.empty') : '系统消息'
  137. }
  138. },
  139. mounted () {
  140. // 轮询弹窗任务提醒
  141. // setTimeout(() => {
  142. // this.isControl=true
  143. // this.loadData()
  144. // }, 1000)
  145. const { licence = {} } = this.$store.getters
  146. const { isTrialVersion, notAfter, needRemind, customerInfo } = licence
  147. const now = Date.now()
  148. if (isTrialVersion) {
  149. // 超出试用期限后登出
  150. if (now > notAfter) {
  151. this.$store.dispatch('ibps/account/logout', {
  152. vm: this
  153. })
  154. return
  155. }
  156. if (needRemind) {
  157. this.$confirm('系统试用期即将结束,请联系开发方购买永久版或申请新的试用许可证!', '提示', {
  158. type: 'warning',
  159. showCancelButton: false,
  160. showClose: false,
  161. closeOnClickModal: false
  162. })
  163. }
  164. const limitDate = new Date(notAfter).toLocaleDateString('zh-CN')
  165. const temp = customerInfo && customerInfo.length >= 12 ? customerInfo : `${customerInfo}试用版本`
  166. Watermark.set(`${temp}`, `试用日期截止至${limitDate}`)
  167. }
  168. this.loadData()
  169. Bus.$on('getMessageCount', count => {
  170. if (count === null) {
  171. return
  172. }
  173. this.messageCount = count
  174. })
  175. },
  176. beforeDestroy () {
  177. Watermark.set('', '')
  178. this.isControl = false
  179. },
  180. methods: {
  181. // 加载数据
  182. loadData () {
  183. getMsgList({
  184. parameters: [
  185. // { key: 'Q^subject^SL', value: '提醒' },
  186. // { key: 'Q^messageType^SL', value: 'system' }
  187. ],
  188. requestPage: { limit: 5, pageNo: 1, totalCount: 0 },
  189. sorts: []
  190. }).then((response) => {
  191. const data = response.data
  192. this.messageList = data.dataResult
  193. this.messageCount = data.pageResult ? data.pageResult.totalCount : 0
  194. this.countNumber = data.pageResult.totalCount
  195. // if (this.countNumber == 0) {
  196. // // if(response.data.pageResult.totalCount>0){
  197. // // this.$message.warning('您有'+response.data.pageResult.totalCount+'条未处理的 [ 待审批 / 被驳回任务消息 ],请及时处理!!!')
  198. // // }
  199. // } else if (this.countNumber < data.pageResult.totalCount) {
  200. // // 如果上次记录数量低于本次 进行提醒,准备待办
  201. // const _this = this
  202. // const h = this.$createElement
  203. // const num = data.pageResult.totalCount - this.countNumber
  204. // this.infoMessage = this.$notify({
  205. // title: '您有新的待办任务产生!',
  206. // message: h('p', null, [
  207. // h('span', null, '任务内容: ' + data.dataResult[0].subject),
  208. // h('br'),
  209. // h('span', null, '生成时间: '),
  210. // h('span', { style: 'color: #FF8C00;font-size:12px;' }, data.dataResult[0].createTime),
  211. // h('br'),
  212. // h('el-button', {
  213. // attrs: {
  214. // size: 'mini',
  215. // type: 'primary',
  216. // plain: true
  217. // },
  218. // on: {
  219. // click: () => {
  220. // _this.cancelInfo()
  221. // }
  222. // }
  223. // }, '进入办理'),
  224. // h('el-button', {
  225. // attrs: {
  226. // size: 'mini',
  227. // plain: true
  228. // },
  229. // on: {
  230. // click: () => {
  231. // _this.$notify.closeAll()
  232. // } // 路由加载之后,调用关闭消息弹窗的方法
  233. // }
  234. // }, '忽略全部')
  235. // ]),
  236. // type: 'warning',
  237. // duration: 0
  238. // })
  239. // }
  240. // if (this.countNumber == 0) {
  241. // this.countNumber = data.pageResult.totalCount
  242. // // setInterval(() => {
  243. // // if(this.isControl && response.message == "获取收到的内部消息列表成功!"){
  244. // // this.loadData()
  245. // // }
  246. // // }, 60000)
  247. // } else {
  248. // this.countNumber = data.pageResult.totalCount
  249. // }
  250. }).catch(() => {
  251. this.isControl = false
  252. })
  253. },
  254. cancelInfo () {
  255. this.$router.push('/officeDesk/pendingItems')
  256. this.$notify.closeAll()
  257. },
  258. handelInteriorClick (message) {
  259. this.subId = message.subId
  260. this.editId = message.id
  261. this.dialogFormVisible = true
  262. // this.type = message.tableName ? message.tableName : ''
  263. this.tableName = message.tableName ? message.tableName : ''
  264. this.tableId = message.tableId ? message.tableId : ''
  265. this.readonly = !!message.tableName
  266. },
  267. openPop () {
  268. this.popShow = !this.popShow
  269. if (this.popShow) {
  270. this.loadData()
  271. }
  272. },
  273. clickMore () {
  274. // 更多消息
  275. this.popShow = !this.popShow
  276. this.$router.push('/message')
  277. },
  278. closeDialog (visible) {
  279. this.dialogFormVisible = visible
  280. this.loadData()
  281. }
  282. }
  283. }
  284. </script>
  285. <style lang="scss">
  286. .header-message-popper {
  287. padding: 0 !important;
  288. .message-more {
  289. padding: 15px 0;
  290. text-align: center;
  291. border-top: 1px solid #ebeef5;
  292. }
  293. }
  294. </style>