index.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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-paste"></i> 编辑</a>
  39. </li>
  40. {{# } }}
  41. <li>
  42. <a href="javascript:;" lay-event='warning'><i class="fa fa-warning"></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: '编号', sort: true,event:'id'},
  58. {field: 'user', title: '发送人'},
  59. {field: 'title', title: '通知标题'},
  60. {field: 'content', title: '通知内容'},
  61. {field: 'type', title: '消息类型',templet:'#type'},
  62. {field: 'is_send', title: '是否发送',templet:'#is_send'},
  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 index = $(that).parents('tr').data('index');
  75. $('.layui-nav-child').each(function (key) {
  76. if (key != index) {
  77. $(this).hide();
  78. }
  79. })
  80. if($(document).height() < offset.top+$(that).next('ul').height()){
  81. $(that).next('ul').css({
  82. 'padding': 10,
  83. 'top': offset.top-$(that).next('ul').height()-30,
  84. 'min-width': 'inherit',
  85. 'left': offset.left - $(that).width() / 2,
  86. 'position': 'fixed'
  87. }).toggle();
  88. }else{
  89. $(that).next('ul').css({
  90. 'padding': 10,
  91. 'top': offset.top + 30,
  92. 'min-width': 'inherit',
  93. 'left': offset.left - $(that).width() / 2,
  94. 'position': 'fixed'
  95. }).toggle();
  96. }
  97. }
  98. layList.tool(function (event,data,obj) {
  99. switch (event) {
  100. case 'send':
  101. var url =layList.U({c:'user.user_notice',a:'send',p:{id:data.id}});
  102. $eb.$swal('delete',function(){
  103. $eb.axios.get(url).then(function(res){
  104. if(res.status == 200 && res.data.code == 200) {
  105. $eb.$swal('success',res.data.msg);
  106. obj.update({is_send:1,send_time:'{:date("Y-m-d H:i:s",time())}'});
  107. }else
  108. return Promise.reject(res.data.msg || '发送失败')
  109. }).catch(function(err){
  110. $eb.$swal('error',err);
  111. });
  112. },{
  113. title:"您确定要发送这条信息吗",
  114. text:"发送后将无法修改通知信息,请谨慎操作!",
  115. confirm:"是的,我要发送!",
  116. cancel:"让我再考虑一下"
  117. })
  118. break;
  119. }
  120. })
  121. $('.btn-warning').on('click',function(){
  122. window.t = $(this);
  123. var _this = $(this),url =_this.data('url');
  124. $eb.$swal('delete',function(){
  125. $eb.axios.get(url).then(function(res){
  126. if(res.status == 200 && res.data.code == 200) {
  127. $eb.$swal('success',res.data.msg);
  128. _this.parents('tr').remove();
  129. }else
  130. return Promise.reject(res.data.msg || '删除失败')
  131. }).catch(function(err){
  132. $eb.$swal('error',err);
  133. });
  134. })
  135. });
  136. $('.btn-send').on('click',function(){
  137. var _this = $(this),url =_this.data('url');
  138. $eb.$swal('delete',function(){
  139. $eb.axios.get(url).then(function(res){
  140. if(res.status == 200 && res.data.code == 200) {
  141. $eb.$swal('success',res.data.msg);
  142. window.location.reload();
  143. }else
  144. return Promise.reject(res.data.msg || '发送失败')
  145. }).catch(function(err){
  146. $eb.$swal('error',err);
  147. });
  148. },{
  149. title:"您确定要发送这条信息吗",
  150. text:"发送后将无法修改通知信息,请谨慎操作!",
  151. confirm:"是的,我要发送!",
  152. cancel:"让我再考虑一下"
  153. })
  154. });
  155. $('.head_image').on('click',function (e) {
  156. var image = $(this).data('image');
  157. $eb.openImage(image);
  158. })
  159. </script>
  160. {/block}