dashboard.js 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. 'use strict';
  2. /**
  3. * 待办页js
  4. *
  5. * @author EllisRan.
  6. * @date 2019/3/19
  7. * @version
  8. */
  9. $(document).ready(() => {
  10. // $('a[href="#view-msg"]').on('click', function () {
  11. // const id = $(this).attr('msg-id');
  12. // const msgInfo = _.find(msgList,{ id: parseInt(id) });
  13. // $('#title').html(msgInfo.title);
  14. // $('#creator').html(msgInfo.creator);
  15. // $('#release_time').html(moment(msgInfo.release_time*1000).format('YYYY-MM-DD'));
  16. // $('#content').html(msgInfo.content);
  17. // $('#user_permission').html('');
  18. // if (userMsgPermission && parseInt(uid) === msgInfo.create_uid ) {
  19. // const permissionHtml = '<a href="/dashboard/msg/add/' + msgInfo.id +'" class="btn btn-sm btn-outline-primary">编辑</a>';
  20. // $('#user_permission').html(permissionHtml);
  21. // }
  22. // });
  23. $('.list-group-item a').on('click', function () {
  24. const id = $(this).attr('msg-id');
  25. const msgInfo = _.find(msgList, {id: parseInt(id)});
  26. $('.msg-height-list li').removeClass('list-waring');
  27. $(this).parents('.list-group-item').addClass('list-waring');
  28. $('#title').html(msgInfo.title);
  29. $('#release_time').html(moment(msgInfo.release_time * 1000).format('YYYY-MM-DD'));
  30. $('#content').html(msgInfo.content);
  31. $('#user_permission').html('');
  32. if (type && parseInt(type) === 1) {
  33. $('#creator').html(msgInfo.creator);
  34. $('#view-msg .modal-title').text('项目通知');
  35. if (userMsgPermission && parseInt(uid) === msgInfo.create_uid) {
  36. const permissionHtml = '<a href="/dashboard/msg/add/' + msgInfo.id + '" class="btn btn-sm btn-outline-primary">编辑</a>';
  37. $('#user_permission').html(permissionHtml);
  38. }
  39. } else {
  40. $('#creator').html('');
  41. $('#view-msg .modal-title').text('系统通知');
  42. }
  43. setFiles(msgInfo.files);
  44. });
  45. $('.system-msg').on('click', function () {
  46. const id = $(this).attr('msg-id');
  47. const msgInfo = _.find(sysMsgList, {id: parseInt(id)});
  48. $('#title').html(msgInfo.title);
  49. $('#creator').html('');
  50. $('#release_time').html(moment(msgInfo.release_time * 1000).format('YYYY-MM-DD'));
  51. $('#content').html(msgInfo.content);
  52. $('#view-msg .modal-title').text('系统通知');
  53. $('#user_permission').html('');
  54. setFiles(msgInfo.files);
  55. });
  56. function setFiles(files) {
  57. $('#files-list').html('');
  58. if (files && files.length > 0) {
  59. let html = '<h5>附件</h5>';
  60. for (const file of files) {
  61. html += `<a href="${file.viewpath ? file.viewpath : '/wap/message/download/file/' + file.id}" target="_blank">
  62. <div class="card my-1" style="cursor: pointer">
  63. <div class="card-body"><i class="fa fa-file"></i> ${file.filename}<span class="pull-right text-secondary">${file.filesize}</span></div>
  64. </div>
  65. </a>`;
  66. }
  67. $('#files-list').html(html);
  68. }
  69. }
  70. // $('#notice').on('click', 'li a', function() {
  71. // const id = $(this).data('id')
  72. // postData(window.location.pathname + '/push', {id}, function() {
  73. // return
  74. // })
  75. // })
  76. });