index.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. <div class="panel panel-default">
  12. <div class="panel-heading">
  13. <h3 class="panel-title"><?=$name ?></h3>
  14. </div>
  15. <div class="panel-body">
  16. <form id="search_form" action="<?=Url::toRoute(['share/index']);?>" method="get">
  17. <div class="row">
  18. <div class="form-group">
  19. <div class="col-sm-3 ">
  20. <select class=" form-control inline" name="role">
  21. <option value="">--选择角色--</option>
  22. <option <?= $search['role']==\common\models\User::USER_ROLE_COMMON?"selected":"" ?> value="<?= \common\models\User::USER_ROLE_COMMON ?>">业主</option>
  23. <option <?= $search['role']==\common\models\User::USER_ROLE_DECORATE?"selected":"" ?> value="<?= \common\models\User::USER_ROLE_DECORATE ?>">装修公司</option>
  24. <option <?= $search['role']==\common\models\User::USER_ROLE_MATER?"selected":"" ?> value="<?= \common\models\User::USER_ROLE_MATER ?>">建材商</option>
  25. </select>
  26. </div>
  27. <div class="col-sm-6">
  28. <input placeholder="开始日期" value="<?= $search['start']?>" name="start" class="form-control layer-date" id="start">
  29. <input placeholder="结束日期" value="<?= $search['end']?>" name="end" class="form-control layer-date" id="end">
  30. </div>
  31. <div class="col-sm-3">
  32. <div class="input-group">
  33. <button id="search_button" type="submit" class="btn btn-sm btn-primary search-button"> 搜索</button>
  34. </div>
  35. </div>
  36. </div>
  37. </div>
  38. </form>
  39. </div>
  40. <table class="table">
  41. <tr>
  42. <th>角色</th>
  43. <th>姓名</th>
  44. <th>电话</th>
  45. <th>创建时间</th>
  46. <th>操作</th>
  47. </tr>
  48. <?php foreach ($models as $vo):?>
  49. <tr >
  50. <td>
  51. <?php if($vo->role ==\common\models\User::USER_ROLE_COMMON): ?>
  52. <?= "业主" ?>
  53. <?php elseif ($vo->role==\common\models\User::USER_ROLE_DECORATE): ?>
  54. <?= "装修公司" ?>
  55. <?php elseif ($vo->role==\common\models\User::USER_ROLE_MATER): ?>
  56. <?= "建材商" ?>
  57. <?php endif; ?>
  58. </td>
  59. <td><?=$vo->name;?></td>
  60. <td><?= $vo->tel ?></td>
  61. <td><?=date('Y-m-d H:i',$vo->c_time);?></td>
  62. <td>
  63. <a data-id="<?=$vo->id?>" class="btn btn-danger" href="javascript:void(0);" ><i class="fa fa-trash"></i> 删除</a>
  64. </td>
  65. </tr>
  66. <?php endforeach;?>
  67. </table>
  68. </div>
  69. <?=LinkPager::widget(['pagination' => $pages]); ?>
  70. <script type="text/javascript">
  71. var start = {
  72. elem: "#start",
  73. //format: "YYYY/MM/DD hh:mm:ss",
  74. //min: laydate.now(),
  75. max: "<?=date('Y-m-d')?>",
  76. //istime: true,
  77. istoday: false,
  78. choose: function(datas) {
  79. //console.log(datas);
  80. //end.min = datas;
  81. //end.start = datas;
  82. }
  83. };
  84. var end = {
  85. elem: "#end",
  86. //format: "YYYY/MM/DD hh:mm:ss",
  87. //min: laydate.now(),
  88. max: "<?=date('Y-m-d')?>",
  89. //istime: true,
  90. istoday: false,
  91. choose: function(datas) {
  92. // start.max = datas;
  93. }
  94. };
  95. laydate(start);
  96. laydate(end);
  97. $('.btn-danger').on('click',function(){
  98. var id = $(this).attr('data-id');
  99. var text = $(this);
  100. swal({
  101. title: "确定删除该记录?",
  102. type: "warning",
  103. showCancelButton: true,
  104. confirmButtonColor: "#DD6B55",
  105. confirmButtonText: "确定",
  106. cancelButtonText: "取消",
  107. closeOnConfirm: true,
  108. closeOnCancel: true },
  109. function(isConfirm){
  110. if (isConfirm) {
  111. $.ajax({
  112. url:'<?=Url::toRoute(['share/del']);?>',
  113. type:'POST',
  114. dataType:'json',
  115. data:{id:id,'<?=Yii::$app->request->csrfParam;?>':'<?=Yii::$app->request->csrfToken;?>'},
  116. success:function(data){
  117. if(data.sign==1){
  118. text.parents('tr').remove();
  119. toastr.success("", data.msg);
  120. }else{
  121. swal("", data.msg, "error");
  122. }
  123. }
  124. })
  125. }
  126. });
  127. });
  128. </script>