index.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. use yii\grid\GridView;
  3. use common\helpers\Url;
  4. use common\helpers\Html;
  5. use common\enums\WhetherEnum;
  6. use common\enums\ExtendConfigNameEnum;
  7. $this->title = $title;
  8. $this->params['breadcrumbs'][] = ['label' => $this->title];
  9. ?>
  10. <div class="row">
  11. <div class="col-12 col-xs-12">
  12. <div class="box">
  13. <div class="box-header">
  14. <h3 class="box-title">
  15. <?= $this->title; ?>
  16. </h3>
  17. <div class="box-tools">
  18. <div class="btn-group">
  19. <button type="button" class="btn btn-white" data-toggle="dropdown" aria-expanded="false">立即创建</button>
  20. <button type="button" class="btn btn-white dropdown-toggle dropdown-icon" data-toggle="dropdown" aria-expanded="false">
  21. <span class="sr-only">切换下拉</span>
  22. </button>
  23. <div class="dropdown-menu dropdown-menu-right text-center" role="menu" style="">
  24. <?php foreach ($nameMap as $key => $item){ ?>
  25. <a class="dropdown-item p-xs" href="<?= Url::to(['edit', 'name' => $key])?>"><?= $item ?></a>
  26. <?php } ?>
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. <div class="box-body table-responsive">
  32. <?= GridView::widget([
  33. 'dataProvider' => $dataProvider,
  34. 'filterModel' => $searchModel,
  35. //重新定义分页样式
  36. 'tableOptions' => ['class' => 'table table-hover'],
  37. 'columns' => [
  38. [
  39. 'class' => 'yii\grid\SerialColumn',
  40. ],
  41. 'title',
  42. [
  43. 'attribute' => 'name',
  44. 'label' => '标识',
  45. 'headerOptions' => ['class' => 'col-md-1'],
  46. 'filter' => Html::activeDropDownList($searchModel, 'name', $nameMap, [
  47. 'prompt' => '全部',
  48. 'class' => 'form-control'
  49. ]
  50. ),
  51. 'value' => function ($model, $key, $index, $column){
  52. return ExtendConfigNameEnum::getValue($model->name);
  53. }
  54. ],
  55. [
  56. 'attribute' => 'extend',
  57. 'label' => '自动打印',
  58. 'format' => 'raw',
  59. 'headerOptions' => ['class' => 'col-md-1'],
  60. 'filter' => Html::activeDropDownList($searchModel, 'extend', WhetherEnum::getMap(), [
  61. 'prompt' => '全部',
  62. 'class' => 'form-control'
  63. ]
  64. ),
  65. 'value' => function ($model, $key, $index, $column){
  66. return WhetherEnum::html($model->extend);
  67. }
  68. ],
  69. [
  70. 'attribute' => 'sort',
  71. 'format' => 'raw',
  72. 'headerOptions' => ['class' => 'col-md-1'],
  73. 'value' => function ($model, $key, $index, $column){
  74. return Html::sort($model->sort);
  75. }
  76. ],
  77. [
  78. 'label' => '创建时间',
  79. 'attribute' => 'created_at',
  80. 'filter' => false, //不显示搜索框
  81. 'format' => ['date', 'php:Y-m-d H:i:s'],
  82. ],
  83. [
  84. 'header' => "操作",
  85. 'class' => 'yii\grid\ActionColumn',
  86. 'template' => '{edit} {status} {delete}',
  87. 'buttons' => [
  88. 'edit' => function ($url, $model, $key) {
  89. return Html::edit(['edit', 'id' => $model->id, 'name' => $model->name]);
  90. },
  91. 'status' => function ($url, $model, $key) {
  92. return Html::status($model->status);
  93. },
  94. 'delete' => function ($url, $model, $key) {
  95. return Html::delete(['destroy', 'id' => $model->id]);
  96. },
  97. ],
  98. ],
  99. ],
  100. ]); ?>
  101. </div>
  102. </div>
  103. </div>
粤ICP备19079148号