12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <?php
- use yii\grid\GridView;
- use yii\helpers\Html;
- /* @var $this yii\web\View */
- /* @var $dataProvider yii\data\ActiveDataProvider */
- $this->title = '分类';
- $this->params['breadcrumbs'][] = $this->title;
- ?>
- <?php $this->beginBlock('content-header') ?>
- <?= $this->title . ' ' . Html::a('新建分类', ['create'], ['class' => 'btn btn-primary ']) ?>
- <?php $this->endBlock() ?>
- <div class="box box-primary">
- <div class="box-body">
- <?= \backend\widgets\grid\TreeGrid::widget([
- 'dataProvider' => $dataProvider,
- 'keyColumnName' => 'id',
- 'parentColumnName' => 'pid',
- 'parentRootValue' => 0, //first parentId value
- 'pluginOptions' => [
- 'initialState' => 'expanded',
- ],
- 'columns' => [
- 'title',
- 'id',
- [
- 'attribute' => 'type',
- 'value' => function ($model) {
- return $model->getTypeEnum()[$model->type];
- }
- ],
- // 'slug',
- // 'article',
- [
- 'attribute' => 'module',
- 'value' => function ($model) {
- return $model->renderModule();
- }
- ],
- [
- 'class' => 'backend\widgets\grid\PositionColumn',
- 'attribute' => 'sort'
- ],
- [
- 'class' => 'backend\widgets\grid\SwitcherColumn',
- 'attribute' => 'status'
- ],
- [
- 'class' => 'yii\grid\ActionColumn',
- 'template' => '{create} {view} {update} {delete}',
- 'buttons' => [
- 'create' => function ($url, $model, $key) {
- //一级分类添加子分类
- if ($model->type == 0 and $model->pid == 0) {
- return Html::a('<i class="fa fa-plus"></i>', ['create', 'id' => $model->id], ['class' => 'btn btn-xs btn-default', 'data-toggle' => 'tooltip', 'title' => '添加子分类']);
- }
- //二级分类添加产业链
- if ($model->type == 0 and $model->pid != 0) {
- return Html::a('<i class="fa fa-plus"></i>', ['create', 'id' => $model->id], ['class' => 'btn btn-xs btn-default', 'data-toggle' => 'tooltip', 'title' => '添加产业链']);
- }
- }
- ]
- ],
- ],
- ]); ?>
- </div>
- </div>
|