index.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. use common\helpers\Url;
  3. use common\helpers\Html;
  4. use jianyan\treegrid\TreeGrid;
  5. $this->title = '角色管理';
  6. $this->params['breadcrumbs'][] = ['label' => $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. <?php if (Yii::$app->services->rbacAuth->isSuperAdmin()) { ?>
  15. <?= Html::create(['edit', 'merchant_id' => $merchant_id]); ?>
  16. <?php } ?>
  17. </div>
  18. </div>
  19. <div class="box-body table-responsive">
  20. <?= TreeGrid::widget([
  21. 'dataProvider' => $dataProvider,
  22. 'keyColumnName' => 'id',
  23. 'parentColumnName' => 'pid',
  24. 'parentRootValue' => $role['id'] ?? 0, // first parentId value
  25. 'pluginOptions' => [
  26. // 'initialState' => 'collapsed',
  27. ],
  28. 'options' => ['class' => 'table table-hover'],
  29. 'columns' => [
  30. [
  31. 'attribute' => 'title',
  32. 'label' => '角色名称',
  33. 'format' => 'raw',
  34. 'value' => function ($model, $key, $index, $column) use ($merchant_id) {
  35. $str = Html::tag('span', $model['title'], [
  36. 'class' => 'm-l-sm',
  37. ]);
  38. $str .= Html::a(' <i class="iconfont iconplus-circle"></i>',
  39. ['edit', 'pid' => $model['id'], 'merchant_id' => $merchant_id]);
  40. return $str;
  41. },
  42. ],
  43. [
  44. 'attribute' => 'sort',
  45. 'label' => '排序',
  46. 'format' => 'raw',
  47. 'headerOptions' => ['class' => 'col-md-1'],
  48. 'value' => function ($model, $key, $index, $column) {
  49. return Html::sort($model['sort']);
  50. },
  51. ],
  52. [
  53. 'header' => "操作",
  54. 'class' => 'yii\grid\ActionColumn',
  55. 'template' => '{edit} {status} {delete}',
  56. 'buttons' => [
  57. 'edit' => function ($url, $model, $key) use ($merchant_id, $roleIds) {
  58. if (in_array($model['id'], $roleIds)) {
  59. return '';
  60. }
  61. return Html::edit(['edit', 'id' => $model['id'], 'merchant_id' => $merchant_id]);
  62. },
  63. 'status' => function ($url, $model, $key) use ($merchant_id, $roleIds) {
  64. if (in_array($model['id'], $roleIds)) {
  65. return false;
  66. }
  67. return Html::status($model['status']);
  68. },
  69. 'delete' => function ($url, $model, $key) use ($merchant_id, $roleIds) {
  70. if (in_array($model['id'], $roleIds)) {
  71. return false;
  72. }
  73. return Html::delete(['delete', 'id' => $model['id'], 'merchant_id' => $merchant_id]);
  74. },
  75. ],
  76. ],
  77. ],
  78. ]); ?>
  79. </div>
  80. </div>
  81. </div>
  82. </div>
粤ICP备19079148号