index.php 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. use yii\grid\GridView;
  3. use yii\helpers\Html as BaseHtml;
  4. use common\helpers\Html;
  5. use common\helpers\ImageHelper;
  6. use common\helpers\DebrisHelper;
  7. use common\helpers\Url;
  8. use common\enums\AttachmentDriveEnum;
  9. use common\enums\AttachmentUploadTypeEnum;
  10. $this->title = '素材管理';
  11. $this->params['breadcrumbs'][] = $this->title;
  12. ?>
  13. <div class="row">
  14. <div class="col-sm-12">
  15. <div class="nav-tabs-custom">
  16. <ul class="nav nav-tabs">
  17. <?php foreach (AttachmentUploadTypeEnum::getMap() as $key => $value) { ?>
  18. <li class="<?php if ($type == $key) { ?>active<?php } ?>"><a href="<?= Url::to(['attachment/index', 'type' => $key])?>"><?= $value ?></a></li>
  19. <?php } ?>
  20. </ul>
  21. <div class="tab-content">
  22. <div class="tab-pane active">
  23. <div class="tab-pane active">
  24. <nav class="nav-tabs-child">
  25. <ul>
  26. <li class="selected"><a href="<?= Url::to(['attachment/index', 'type' => $type]) ?>">素材文件</a></li>
  27. <li><a href="<?= Url::to(['attachment-cate/index', 'type' => $type]) ?>">素材分组</a></li>
  28. </ul>
  29. </nav>
  30. <div class="box">
  31. <!-- /.box-header -->
  32. <div class="box-body table-responsive">
  33. <?= GridView::widget([
  34. 'dataProvider' => $dataProvider,
  35. 'filterModel' => $searchModel,
  36. // 重新定义分页样式
  37. 'tableOptions' => ['class' => 'table table-hover'],
  38. 'columns' => [
  39. [
  40. 'class' => 'yii\grid\SerialColumn',
  41. ],
  42. [
  43. 'attribute' => 'url',
  44. 'filter' => false, //不显示搜索框
  45. 'value' => function ($model) {
  46. if (($model['upload_type'] == 'images' || preg_match("/^image/", $model['specific_type'])) && $model['extension'] != 'psd') {
  47. return ImageHelper::fancyBox($model->url);
  48. }
  49. return BaseHtml::a('预览', $model->url, [
  50. 'target' => '_blank'
  51. ]);
  52. },
  53. 'format' => 'raw'
  54. ],
  55. [
  56. 'attribute' => 'drive',
  57. 'headerOptions' => ['class' => 'col-md-1'],
  58. 'filter' => Html::activeDropDownList($searchModel, 'drive', AttachmentDriveEnum::getMap(), [
  59. 'prompt' => '全部',
  60. 'class' => 'form-control'
  61. ]
  62. ),
  63. 'value' => function ($model) {
  64. return AttachmentDriveEnum::getValue($model->drive);
  65. },
  66. ],
  67. 'name',
  68. [
  69. 'attribute' => 'format_size',
  70. 'filter' => false, //不显示搜索框
  71. ],
  72. [
  73. 'attribute' => 'extension',
  74. 'headerOptions' => ['class' => 'col-md-1'],
  75. ],
  76. [
  77. 'attribute' => 'cate.title',
  78. 'label' => '素材分组',
  79. 'headerOptions' => ['class' => 'col-md-1'],
  80. 'filter' => Html::activeDropDownList($searchModel, 'cate_id', $cateMap, [
  81. 'prompt' => '全部',
  82. 'class' => 'form-control'
  83. ]
  84. ),
  85. 'value' => function ($model) {
  86. return $model->cate->title ?? '';
  87. },
  88. ],
  89. [
  90. 'label' => '位置信息',
  91. 'value' => function ($model) {
  92. $str = [];
  93. $str[] = DebrisHelper::analysisIp($model->ip);
  94. $str[] = $model->ip;
  95. return implode('</br>', $str);
  96. },
  97. 'format' => 'raw',
  98. ],
  99. [
  100. 'label' => '创建时间',
  101. 'attribute' => 'created_at',
  102. 'filter' => false, //不显示搜索框
  103. 'format' => ['date', 'php:Y-m-d H:i:s'],
  104. ],
  105. [
  106. 'header' => "操作",
  107. 'class' => 'yii\grid\ActionColumn',
  108. 'template' => '{update} {status} {delete}',
  109. 'buttons' => [
  110. 'update' => function ($url, $model, $key) {
  111. return Html::linkButton(['update', 'id' => $model->id, 'type' => $model->upload_type], '编辑', [
  112. 'data-toggle' => 'modal',
  113. 'data-target' => '#ajaxModal',
  114. ]);
  115. },
  116. 'status' => function ($url, $model, $key) {
  117. return Html::status($model->status);
  118. },
  119. 'delete' => function ($url, $model, $key) {
  120. return Html::delete(['destroy', 'id' => $model->id]);
  121. },
  122. ],
  123. ],
  124. ],
  125. ]); ?>
  126. <!-- /.box-body -->
  127. </div>
  128. <!-- /.box -->
  129. </div>
  130. </div>
  131. </div>
  132. </div>
  133. </div>
  134. </div>
  135. </div>
粤ICP备19079148号