index.php 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. use yii\grid\GridView;
  3. use common\helpers\Url;
  4. use common\helpers\Html;
  5. $this->title = '单页管理';
  6. $this->params['breadcrumbs'][] = $this->title;
  7. ?>
  8. <div class="row">
  9. <div class="col-12">
  10. <div class="box">
  11. <div class="box-header">
  12. <h3 class="box-title"><?= $this->title; ?></h3>
  13. <div class="box-tools">
  14. <?= Html::create(['edit']); ?>
  15. </div>
  16. </div>
  17. <!-- /.box-header -->
  18. <div class="box-body table-responsive">
  19. <?= GridView::widget([
  20. 'dataProvider' => $dataProvider,
  21. 'filterModel' => $searchModel,
  22. //重新定义分页样式
  23. 'tableOptions' => ['class' => 'table table-hover'],
  24. 'columns' => [
  25. [
  26. 'class' => 'yii\grid\SerialColumn',
  27. 'visible' => false, // 不显示#
  28. ],
  29. 'id',
  30. 'title',
  31. 'view',
  32. [
  33. 'attribute' => 'sort',
  34. 'filter' => false, //不显示搜索框
  35. 'value' => function ($model) {
  36. return Html::sort($model->sort);
  37. },
  38. 'format' => 'raw',
  39. 'headerOptions' => ['class' => 'col-md-1'],
  40. ],
  41. [
  42. 'label'=> '创建时间',
  43. 'attribute' => 'created_at',
  44. 'filter' => false, //不显示搜索框
  45. 'format' => ['date', 'php:Y-m-d H:i:s'],
  46. ],
  47. [
  48. 'header' => "操作",
  49. 'class' => 'yii\grid\ActionColumn',
  50. 'template'=> '{edit} {preview} {status} {delete}',
  51. 'buttons' => [
  52. 'edit' => function ($url, $model, $key) {
  53. return Html::edit(['edit', 'id' => $model->id]);
  54. },
  55. 'preview' => function ($url, $model, $key) {
  56. return Html::a('预览', Url::toFront(['single/view', 'single_id' => $model->id]), [
  57. 'class' => "btn btn-white btn-sm",
  58. 'target' => '_blank',
  59. ]);
  60. },
  61. 'status' => function ($url, $model, $key) {
  62. return Html::status($model->status);
  63. },
  64. 'delete' => function ($url, $model, $key) {
  65. return Html::delete(['delete', 'id' => $model->id]);
  66. },
  67. ],
  68. ],
  69. ],
  70. ]); ?>
  71. <!-- /.box-body -->
  72. </div>
  73. <!-- /.box -->
  74. </div>
  75. </div>
  76. </div>
粤ICP备19079148号