notice.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2017/3/17 0017
  6. * Time: 上午 10:52
  7. */
  8. use yii\helpers\Url;
  9. use yii\widgets\LinkPager;
  10. ?>
  11. <style>
  12. .color{
  13. color: red;
  14. }
  15. </style>
  16. <div class="row">
  17. <div class="col-sm-12">
  18. <div class="ibox float-e-margins">
  19. <div class="ibox-content">
  20. <div class="row">
  21. <div class="col-sm-5 m-b-xs">
  22. <a class="btn btn-sm btn-primary addhotsearch" href="<?=Url::toRoute(['webconfig/addnotice'])?>"> 新增公告</a>
  23. </div>
  24. </div>
  25. <div class="table-responsive">
  26. <table class="table table-striped">
  27. <thead>
  28. <tr>
  29. <th>ID</th>
  30. <th>标题</th>
  31. <th>发布时间</th>
  32. <th>结束时间</th>
  33. <th>操作</th>
  34. </tr>
  35. </thead>
  36. <tbody>
  37. <form id="checkForm" method="post">
  38. <?php if(!empty($datas)):?>
  39. <?php $i=0; foreach($datas as $data):?>
  40. <tr class="hotsearch_<?=$data->id?>">
  41. <td><?php $i++;echo $i;?></td>
  42. <td class="keyword">
  43. <?php $information = empty($data->information)?'':$data->information?>
  44. <?=empty( $information->title)?'': $information->title?>
  45. </td>
  46. <td><?=date('Y-m-d :H:i:s',$data->release_time)?></td>
  47. <td><?=date('Y-m-d :H:i:s',$data->over_time)?></td>
  48. <td>
  49. <a href="<?=Url::toRoute(['webconfig/addnotice','id'=>$data->id])?>" class="btn btn-sm btn-primary edit_advert">修改</a>
  50. <a class="btn btn-sm btn-danger del_advert"data="<?= $data->id?>">删除</a>
  51. </td>
  52. </tr>
  53. <?php endforeach;?>
  54. <?php endif?>
  55. <input type="hidden" name="_csrf-backend" value="<?=Yii::$app->request->csrfToken;?>" />
  56. <input type="hidden" value="" name="key" class="shelves-key">
  57. </form>
  58. </tbody>
  59. </table>
  60. </div>
  61. </div>
  62. </div>
  63. </div>
  64. </div>
  65. <script>
  66. $('.table-responsive').on('click','.del_advert',function(){
  67. var id = $(this).attr('data');
  68. var text = $(this);
  69. swal({
  70. title: "确定删除该公告?",
  71. type: "warning",
  72. showCancelButton: true,
  73. confirmButtonColor: "#DD6B55",
  74. confirmButtonText: "确定",
  75. cancelButtonText: "取消",
  76. closeOnConfirm: true,
  77. closeOnCancel: true },
  78. function(isConfirm){
  79. if (isConfirm) {
  80. $.ajax({
  81. url:'<?=Url::toRoute(['webconfig/del_notice']);?>',
  82. type:'POST',
  83. dataType:'json',
  84. data:{id:id,'_csrf-backend':'<?=Yii::$app->request->csrfToken;?>'},
  85. success:function(data){
  86. if(data.sign==1){
  87. text.parents('tr').remove();
  88. }else{
  89. swal("", data.msg, "error");
  90. }
  91. }
  92. })
  93. }
  94. });
  95. })
  96. </script>