msgMixin.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import { getDicts } from '@/api/dict';
  2. import { del, readMsg, readAllMsg } from '@/api/msg/sysMsg'
  3. import bus from '@/assets/js/event.js'
  4. export default {
  5. data () {
  6. return {
  7. }
  8. },
  9. mounted () {
  10. },
  11. methods: {
  12. markedRead: function() {
  13. if (this.checkedKeys.length == 0) {
  14. msg('请先勾选至少一条消息,才可进行此操作。');
  15. return;
  16. }
  17. readMsg(this.checkedKeys.join(",")).then(res => {
  18. alert(res.msg);
  19. bus.$emit('readMsgAfter', {
  20. curObj: this
  21. });
  22. this.checkedKeys = [];
  23. });
  24. },
  25. markedAllRead: function(msgType) {
  26. readAllMsg(msgType).then(res => {
  27. alert(res.msg);
  28. bus.$emit('readMsgAfter', {
  29. curObj: this,
  30. msgType: msgType,
  31. });
  32. });
  33. },
  34. switchModal: function() {
  35. this.$emit('switch-modal');
  36. },
  37. readMsg: function(msg) {
  38. if (!msg || !msg.id || !this.msgRecordMap[msg.id]) {
  39. return;
  40. }
  41. if (this.msgRecordMap[msg.id][0].readStatus != 'y') {
  42. readMsg(msg.id).then(res => {
  43. bus.$emit('readMsgAfter', {
  44. curObj: this,
  45. msgType: msg.msgTypeDict,
  46. });
  47. });
  48. }
  49. if (msg.url) {
  50. this.toView(msg.url, {
  51. id: msg.businessid
  52. });
  53. } else {
  54. var content = "wwww";
  55. layer.open({
  56. type: 1
  57. ,title: false //不显示标题栏
  58. ,closeBtn: true
  59. ,area: ['auto', 'auto']
  60. ,shade: 0.8
  61. ,id: 'LAY_layuipro' //设定一个id,防止重复弹出
  62. ,resize: false
  63. // ,btn: ['关闭']
  64. ,btnAlign: 'c'
  65. ,moveType: 1 //拖拽模式,0或者1
  66. ,content: content
  67. ,yes: function(layero){
  68. readPersonnelMsgAfter(msg.id);
  69. layer.closeAll();
  70. },
  71. cancel: function(){
  72. }
  73. });
  74. }
  75. },
  76. }
  77. }