title = '分类';
$this->params['breadcrumbs'][] = $this->title;
?>
beginBlock('content-header') ?>
= $this->title . ' ' . Html::a('新建分类', ['create'], ['class' => 'btn btn-primary ']) ?>
endBlock() ?>
= \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('', ['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('', ['create', 'id' => $model->id], ['class' => 'btn btn-xs btn-default', 'data-toggle' => 'tooltip', 'title' => '添加产业链']);
}
}
]
],
],
]); ?>