index.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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; ?></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. 'title',
  28. [
  29. 'label' => '参数标签',
  30. 'filter' => false, //不显示搜索框
  31. 'value' => function ($model) {
  32. $data = [];
  33. foreach ($model->value as $item) {
  34. $data[] = $item['title'];
  35. }
  36. return implode(',', $data);
  37. },
  38. ],
  39. [
  40. 'attribute' => 'sort',
  41. 'filter' => false, //不显示搜索框
  42. 'value' => function ($model) {
  43. return Html::sort($model->sort);
  44. },
  45. 'format' => 'raw',
  46. 'headerOptions' => ['class' => 'col-md-1'],
  47. ],
  48. [
  49. 'header' => "操作",
  50. 'class' => 'yii\grid\ActionColumn',
  51. 'template' => '{edit} {status} {delete}',
  52. 'buttons' => [
  53. 'edit' => function ($url, $model, $key) {
  54. return Html::edit(['edit', 'id' => $model->id]);
  55. },
  56. 'status' => function ($url, $model, $key) {
  57. return Html::status($model->status);
  58. },
  59. 'delete' => function ($url, $model, $key) {
  60. return Html::delete(['destroy', 'id' => $model->id]);
  61. },
  62. ],
  63. ],
  64. ],
  65. ]); ?>
  66. <!-- /.box-body -->
  67. </div>
  68. <!-- /.box -->
  69. </div>
  70. </div>
  71. </div>
粤ICP备19079148号