index.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. {extend name="public/container"}
  2. {block name="content"}
  3. <div class="layui-fluid">
  4. <div class="layui-row layui-col-space15" id="app">
  5. <div class="layui-col-md12">
  6. <div class="layui-card">
  7. <div class="layui-card-header">通知列表</div>
  8. <div class="layui-card-body">
  9. <div class="layui-btn-container">
  10. <button class="layui-btn layui-btn-sm" onclick="$eb.createModalFrame(this.innerText,'{:Url('create')}')">添加通知</button>
  11. </div>
  12. <table class="layui-hide" id="List" lay-filter="List"></table>
  13. <!--消息状态-->
  14. <script type="text/html" id="type">
  15. {{# if(d.type==1){ }}
  16. <p>系统消息</p>
  17. {{# }else if(d.type==2){ }}
  18. <p>用户通知</p>
  19. {{# } }}
  20. </script>
  21. <!--消息状态-->
  22. <script type="text/html" id="is_send">
  23. {{# if(d.is_send==1){ }}
  24. 状态:<span style="color:green;">已发送</span><br />
  25. 时间:{{d.send_time}}
  26. {{# }else{ }}
  27. 状态:<span style="color:red;">未发送</span> <a class="layui-btn layui-btn-xs layui-btn-normal" lay-event='send'>立即发送</a>
  28. {{# } }}
  29. </script>
  30. <script type="text/html" id="act">
  31. <button type="button" class="layui-btn layui-btn-xs" onclick="dropdown(this)">操作 <span class="caret"></span></button>
  32. <ul class="layui-nav-child layui-anim layui-anim-upbit">
  33. <li>
  34. <a href="javascript:;" onclick="window.location.href='{:Url('user')}?id={{d.id}}'"><i class="fa fa-user"></i> 用户信息</a>
  35. </li>
  36. {{# if(d.is_send==0){ }}
  37. <li>
  38. <a href="javascript:;" onclick="$eb.createModalFrame('编辑','{:Url('edit')}?id={{d.id}}')"><i class="fa fa-edit"></i> 编辑</a>
  39. </li>
  40. {{# } }}
  41. <li>
  42. <a href="javascript:;" lay-event='warning'><i class="fa fa-times"></i> 删除</a>
  43. </li>
  44. </ul>
  45. </script>
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. </div>
  51. <script src="{__ADMIN_PATH}js/layuiList.js"></script>
  52. {/block}
  53. {block name="script"}
  54. <script>
  55. layList.tableList('List',"{:Url('index')}",function (){
  56. return [
  57. {field: 'id', title: '编号',width:'6%', sort: true,event:'id',align:"center"},
  58. {field: 'user', title: '发送人',align:"center",width:'10%'},
  59. {field: 'title', title: '通知标题',align:"center",width:'10%'},
  60. {field: 'content', title: '通知内容',align:"center"},
  61. {field: 'type', title: '消息类型',templet:'#type',align:"center",width:'6%'},
  62. {field: 'is_send', title: '是否发送',templet:'#is_send',align:"center",width:'15%'},
  63. {field: 'right', title: '操作',align:'center',toolbar:'#act',width:'10%'},
  64. ];
  65. });
  66. //下拉框
  67. $(document).click(function (e) {
  68. $('.layui-nav-child').hide();
  69. })
  70. function dropdown(that){
  71. var oEvent = arguments.callee.caller.arguments[0] || event;
  72. oEvent.stopPropagation();
  73. var offset = $(that).offset();
  74. var top=offset.top-$(window).scrollTop();
  75. var index = $(that).parents('tr').data('index');
  76. $('.layui-nav-child').each(function (key) {
  77. if (key != index) {
  78. $(this).hide();
  79. }
  80. })
  81. if($(document).height() < top+$(that).next('ul').height()){
  82. $(that).next('ul').css({
  83. 'padding': 10,
  84. 'top': - ($(that).parents('td').height() / 2 + $(that).height() + $(that).next('ul').height()/2),
  85. 'min-width': 'inherit',
  86. 'position': 'absolute'
  87. }).toggle();
  88. }else{
  89. $(that).next('ul').css({
  90. 'padding': 10,
  91. 'top':$(that).parents('td').height() / 2 + $(that).height(),
  92. 'min-width': 'inherit',
  93. 'position': 'absolute'
  94. }).toggle();
  95. }
  96. }
  97. layList.tool(function (event,data,obj) {
  98. switch (event) {
  99. case 'send':
  100. var url =layList.U({c:'user.user_notice',a:'send',p:{id:data.id}});
  101. $eb.$swal('delete',function(){
  102. $eb.axios.get(url).then(function(res){
  103. if(res.status == 200 && res.data.code == 200) {
  104. $eb.$swal('success',res.data.msg);
  105. obj.update({is_send:1,send_time:'{:date("Y-m-d H:i:s",time())}'});
  106. }else
  107. return Promise.reject(res.data.msg || '发送失败')
  108. }).catch(function(err){
  109. $eb.$swal('error',err);
  110. });
  111. },{
  112. title:"您确定要发送这条信息吗",
  113. text:"发送后将无法修改通知信息,请谨慎操作!",
  114. confirm:"是的,我要发送!",
  115. cancel:"让我再考虑一下"
  116. })
  117. break;
  118. case 'warning':
  119. window.t = $(this);
  120. var _this = obj,url =layList.U({a:'delete',p:{id:data.id}});
  121. $eb.$swal('delete',function(){
  122. $eb.axios.get(url).then(function(res){
  123. if(res.status == 200 && res.data.code == 200) {
  124. $eb.$swal('success',res.data.msg);
  125. _this.del();
  126. }else
  127. return Promise.reject(res.data.msg || '删除失败')
  128. }).catch(function(err){
  129. $eb.$swal('error',err);
  130. });
  131. })
  132. break;
  133. }
  134. })
  135. $('.head_image').on('click',function (e) {
  136. var image = $(this).data('image');
  137. $eb.openImage(image);
  138. })
  139. </script>
  140. {/block}