index.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. use yii\grid\GridView;
  3. use yii\helpers\Html;
  4. use common\models\Category;
  5. /* @var $this yii\web\View */
  6. /* @var $searchModel backend\models\search\ArticleSearch */
  7. /* @var $dataProvider yii\data\ActiveDataProvider */
  8. $this->title = '人才';
  9. $this->params['breadcrumbs'][] = $this->title;
  10. ?>
  11. <?php $this->beginBlock('content-header') ?>
  12. <?= $this->title . ' ' . Html::a('新增人才', ['create'], ['class' => 'btn btn-success']) ?>
  13. <?php $this->endBlock() ?>
  14. <div class="article-index">
  15. <div class="box box-success">
  16. <div class="box-body"><?php echo $this->render('_search', ['model' => $searchModel]); ?></div>
  17. </div>
  18. <div class="box box-success">
  19. <div class="box-body">
  20. <?= GridView::widget([
  21. 'id' => 'article-grid',
  22. 'dataProvider' => $dataProvider,
  23. 'columns' => [
  24. 'id',
  25. 'category',
  26. // 'sort',
  27. [
  28. 'attribute' => 'title',
  29. 'value' => function($model) {
  30. return Html::a($model->title, Yii::$app->config->get('SITE_URL') . '/' . $model->id . '.html', ['target' => '_blank', 'no-iframe' => '1']);
  31. },
  32. 'format' => 'raw',
  33. // 'enableSorting' => false
  34. ],
  35. [
  36. 'attribute' => 'module',
  37. 'value' => function($model) {
  38. return array_get(\common\models\ArticleModule::getTypeEnum(), $model->module);
  39. },
  40. 'enableSorting' => false
  41. ],
  42. 'description',
  43. 'city',
  44. 'address',
  45. 'tel',
  46. 'company',
  47. 'chain',
  48. [
  49. 'label' => '标签',
  50. 'value' => function ($model) {
  51. $html = '';
  52. foreach ($model->tags as $tag) {
  53. $html .= ' <span class="label label-' . $tag->level . '">' . $tag->name . '</span>';
  54. }
  55. return $html;
  56. },
  57. 'format' => 'raw'
  58. ],
  59. 'trueView',
  60. [
  61. 'class' => 'backend\widgets\grid\SwitcherColumn',
  62. 'attribute' => 'is_top'
  63. ],
  64. [
  65. 'class' => 'backend\widgets\grid\SwitcherColumn',
  66. 'attribute' => 'status'
  67. ],
  68. // 'user_id:admin',
  69. [
  70. 'class' => 'common\helpers\DiyActionColumn',
  71. 'template' => '{update} {delete}'
  72. ],
  73. ],
  74. ]); ?>
  75. </div>
  76. </div>
  77. </div>