index.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. use yii\grid\GridView;
  3. use common\helpers\Html;
  4. $this->title = '广告图';
  5. $this->params['breadcrumbs'][] = $this->title;
  6. ?>
  7. <div class="row">
  8. <div class="col-12 col-xs-12">
  9. <div class="box">
  10. <div class="box-header">
  11. <h3 class="box-title"><?= $this->title; ?> <small>默认使用有效期内的第一个图片,如果都是无效则使用默认图片</small></h3>
  12. <div class="box-tools">
  13. <?= Html::create(['edit']); ?>
  14. </div>
  15. </div>
  16. <!-- /.box-header -->
  17. <div class="box-body table-responsive">
  18. <?= GridView::widget([
  19. 'dataProvider' => $dataProvider,
  20. 'filterModel' => $searchModel,
  21. //重新定义分页样式
  22. 'tableOptions' => ['class' => 'table table-hover'],
  23. 'columns' => [
  24. [
  25. 'class' => 'yii\grid\SerialColumn',
  26. ],
  27. 'name',
  28. [
  29. 'attribute' => '有效时间',
  30. 'filter' => false, //不显示搜索框
  31. 'value' => function ($model) {
  32. $str = [];
  33. $str[] = '开始:' . Yii::$app->formatter->asDatetime($model->start_time);
  34. $str[] = '结束:' . Yii::$app->formatter->asDatetime($model->end_time);
  35. return implode('<br>', $str);
  36. },
  37. 'format' => 'raw',
  38. ],
  39. [
  40. 'attribute' => '状态',
  41. 'filter' => false, //不显示搜索框
  42. 'value' => function ($model) {
  43. return Html::timeStatus($model->start_time, $model->end_time);
  44. },
  45. 'format' => 'raw',
  46. ],
  47. [
  48. 'attribute' => 'sort',
  49. 'filter' => false, //不显示搜索框
  50. 'value' => function ($model) {
  51. return Html::sort($model->sort);
  52. },
  53. 'format' => 'raw',
  54. 'headerOptions' => ['class' => 'col-md-1'],
  55. ],
  56. [
  57. 'header' => "操作",
  58. 'class' => 'yii\grid\ActionColumn',
  59. 'template' => '{edit} {status} {delete}',
  60. 'buttons' => [
  61. 'edit' => function ($url, $model, $key) {
  62. return Html::edit(['edit', 'id' => $model->id]);
  63. },
  64. 'status' => function ($url, $model, $key) {
  65. return Html::status($model->status);
  66. },
  67. 'delete' => function ($url, $model, $key) {
  68. return Html::delete(['destroy', 'id' => $model->id]);
  69. },
  70. ],
  71. ],
  72. ],
  73. ]); ?>
  74. <!-- /.box-body -->
  75. </div>
  76. <!-- /.box -->
  77. </div>
  78. </div>
  79. </div>
粤ICP备19079148号