permissions.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?php
  2. /**
  3. * Author: lf
  4. * Blog: https://blog.feehi.com
  5. * Email: job@feehi.com
  6. * Created at: 2017-09-12 11:50
  7. */
  8. /**
  9. * @var $this yii\web\View
  10. * @var $dataProvider yii\data\ArrayDataProvider
  11. * @var $searchModel \backend\models\search\RBACPermissionSearch
  12. */
  13. use backend\grid\GridView;
  14. use backend\grid\SortColumn;
  15. use backend\widgets\Bar;
  16. use yii\helpers\Html;
  17. use yii\helpers\Url;
  18. use backend\grid\CheckboxColumn;
  19. use backend\grid\ActionColumn;
  20. $this->title = "Permissions";
  21. $this->params['breadcrumbs'][] = Yii::t('app', 'Permissions');
  22. ?>
  23. <div class="row">
  24. <div class="col-sm-12">
  25. <div class="ibox">
  26. <?= $this->render('/widgets/_ibox-title') ?>
  27. <div class="ibox-content">
  28. <?= Bar::widget([
  29. 'buttons' => [
  30. 'create' => function () {
  31. return Html::a('<i class="fa fa-plus"></i> ' . Yii::t('app', 'Create'), Url::to(['permission-create']), [
  32. 'title' => Yii::t('app', 'Create'),
  33. 'data-pjax' => '0',
  34. 'class' => 'btn btn-white btn-sm',
  35. ]);
  36. },
  37. 'delete' => function () {
  38. return Html::a('<i class="fa fa-trash-o"></i> ' . Yii::t('app', 'Delete'), Url::to(['permission-delete']), [
  39. 'title' => Yii::t('app', 'Delete'),
  40. 'data-pjax' => '0',
  41. 'param-sign' => 'name',//批量操作时,设置post数据的key名,默认为id
  42. 'data-confirm' => Yii::t('app', 'Really to delete?'),
  43. 'class' => 'btn btn-white btn-sm multi-operate',
  44. ]);
  45. }
  46. ],
  47. 'template' => '{refresh} {create} {delete}'
  48. ]) ?>
  49. <?= GridView::widget([
  50. 'dataProvider' => $dataProvider,
  51. 'filterModel' => $searchModel,
  52. 'columns' => [
  53. [
  54. 'class' => CheckboxColumn::className(),
  55. 'checkboxOptions' => function ($model, $key, $index, $column) {
  56. return ['value' => $model->name];
  57. },
  58. ],
  59. [
  60. 'attribute' => 'group',
  61. 'label' => Yii::t("app", "Group"),
  62. ],
  63. [
  64. 'attribute' => 'category',
  65. 'label' => Yii::t("app", "Category"),
  66. ],
  67. [
  68. 'attribute' => 'route',
  69. 'label' => Yii::t("app", "Route"),
  70. ],
  71. [
  72. 'attribute' => 'method',
  73. 'filter' => [
  74. 'GET' => 'GET',
  75. 'POST' => 'POST',
  76. ],
  77. 'label' => Yii::t("app", "HTTP Method"),
  78. ],
  79. [
  80. 'attribute' => 'description',
  81. 'label' => Yii::t("app", "Description"),
  82. ],
  83. [
  84. 'class' => SortColumn::className(),
  85. 'primaryKey' => function($model){
  86. return ["name" => $model['name']];
  87. },
  88. 'action' => Url::to(['permission-sort']),
  89. 'label' => Yii::t("app", "Sort"),
  90. ],
  91. [
  92. 'class' => ActionColumn::className(),
  93. 'width' => '190px',
  94. 'buttons' => [
  95. 'view-layer' => function($url, $model, $key){
  96. return Html::a('<i class="fa fa-folder"></i> ', 'javascript:void(0)', [
  97. 'title' => Yii::t('yii', 'View'),
  98. 'onclick' => "viewLayer('" . Url::to(['permission-view-layer', 'name' => $model->name]) . "',$(this))",
  99. 'data-pjax' => '0',
  100. 'class' => 'btn',
  101. 'url' => Url::to(['permission-view-layer', 'name' => $model->name]),
  102. ]);
  103. },
  104. 'update' => function ($url, $model, $key) {
  105. return Html::a('<i class="fa fa-edit" aria-hidden="true"></i> ', Url::to([
  106. 'permission-update',
  107. 'name' => $model->name
  108. ]), [
  109. 'title' => Yii::t('app', 'Update'),
  110. 'data-pjax' => '0',
  111. 'class' => 'btn J_menuItem',
  112. ]);
  113. },
  114. 'delete' => function ($url, $model) {
  115. return Html::a('<i class="fa fa-trash-o"></i> ', Url::to(['permission-delete', 'name'=>$model->name]), [
  116. 'title' => Yii::t('app', 'Delete'),
  117. 'data-pjax' => '0',
  118. 'data-confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),
  119. 'class' => 'btn',
  120. ]);
  121. },
  122. ],
  123. 'template' => '{view-layer} {update} {delete}',
  124. ]
  125. ]
  126. ]) ?>
  127. </div>
  128. </div>
  129. </div>
  130. </div>