view.php 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <?php
  2. use common\models\Space;
  3. use slavkovrn\lightbox\LightBoxWidget;
  4. use yii\grid\GridView;
  5. use yii\helpers\Html;
  6. use yii\helpers\Url;
  7. use yii\widgets\DetailView;
  8. /* @var $this yii\web\View */
  9. /* @var $model common\models\Space */
  10. $this->title = $model->name;
  11. $this->params['breadcrumbs'][] = ['label' => Yii::t('common', 'Spaces'), 'url' => ['index']];
  12. $this->params['breadcrumbs'][] = $this->title;
  13. ?>
  14. <p>
  15. <?= Html::a(Yii::t('common', '更新空间信息'), ['update', 'id' => $model->id], ['class' => 'btn btn-success']) ?>
  16. <?= Html::a(Yii::t('common', 'Create Goods Index'), ['/goods-index/create','entity' => Space::className(),'entity_id'=>$model->id,'origin'=>Yii::$app->request->url], ['class' => 'btn btn-success', 'title' => Yii::t('common', 'Create Goods Index'), 'target' => '_blank']) ?>
  17. <?= Html::a(Yii::t('common', '删除空间'), ['delete', 'id' => $model->id], [
  18. 'class' => 'btn btn-danger',
  19. 'data' => [
  20. 'confirm' => Yii::t('common', 'Are you sure you want to delete this item?'),
  21. 'method' => 'post',
  22. ],
  23. ]) ?>
  24. </p>
  25. <div class="nav-tabs-custom">
  26. <ul class="nav nav-tabs">
  27. <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true">空间信息</a></li>
  28. <li><a href="#tab_2" data-toggle="tab" aria-expanded="true">关联商品</a></li>
  29. </ul>
  30. <div class="tab-content">
  31. <div class="tab-pane active" id="tab_1">
  32. <!-- 空间详情信息-->
  33. <?= DetailView::widget([
  34. 'model' => $model,
  35. 'attributes' => [
  36. 'id',
  37. [
  38. 'attribute' => 'cover',
  39. 'format' => 'raw',
  40. 'value' => function ($model){
  41. $images = [ // images at popup window of prettyPhoto galary
  42. 1 => [
  43. 'src' => $model->cover,
  44. 'title' => '',
  45. ],
  46. ];
  47. return $model->cover ? LightBoxWidget::widget([
  48. 'id' =>'cover', // id of plugin should be unique at page
  49. 'class' =>'galary', // class of plugin to define style
  50. 'height' =>'100px', // height of image visible in widget
  51. 'width' =>'100px', // width of image visible in widget
  52. 'images' => $images,
  53. ]) : null;
  54. }
  55. ],
  56. [
  57. 'attribute' => 'banner',
  58. 'format' => 'raw',
  59. 'value' => function ($model){
  60. $images = [];
  61. foreach ($model->banner as $index=>$banner) {
  62. $images[$index] = ['src'=>$banner, 'title'=>''];
  63. }
  64. return $model->banner ? LightBoxWidget::widget([
  65. 'id' =>'banner', // id of plugin should be unique at page
  66. 'class' =>'galary', // class of plugin to define style
  67. 'height' =>'100px', // height of image visible in widget
  68. 'width' =>'100px', // width of image visible in widget
  69. 'images' => $images,
  70. ]) : null;
  71. }
  72. ],
  73. [
  74. 'attribute' => 'picture',
  75. 'format' => 'raw',
  76. 'value' => function ($model){
  77. $images = [];
  78. foreach ($model->picture as $index=>$picture) {
  79. $images[$index] = ['src'=>$picture, 'title'=>''];
  80. }
  81. return $model->picture ? LightBoxWidget::widget([
  82. 'id' =>'picture', // id of plugin should be unique at page
  83. 'class' =>'galary', // class of plugin to define style
  84. 'height' =>'100px', // height of image visible in widget
  85. 'width' =>'100px', // width of image visible in widget
  86. 'images' => $images,
  87. ]) : null;
  88. }
  89. ],
  90. [
  91. 'attribute' => 'vid',
  92. 'format' => 'raw',
  93. 'value' => function ($model){
  94. return '<iframe frameborder="0" src="https://v.qq.com/txp/iframe/player.html?vid='.$model->vid.'" allowFullScreen="true"></iframe>';
  95. }
  96. ],
  97. 'name',
  98. 'desc',
  99. [
  100. 'attribute' => 'province',
  101. 'format' => 'raw',
  102. 'value' => function ($model) {
  103. return \common\models\Region::getNameById($model->province);
  104. },
  105. ],
  106. [
  107. 'attribute' => 'city',
  108. 'format' => 'raw',
  109. 'value' => function ($model) {
  110. return \common\models\Region::getNameById($model->city);
  111. },
  112. ],
  113. [
  114. 'attribute' => 'area',
  115. 'format' => 'raw',
  116. 'value' => function ($model) {
  117. return \common\models\Region::getNameById($model->area);
  118. },
  119. ],
  120. 'address',
  121. 'contacts',
  122. 'tel',
  123. 'created_at:datetime',
  124. 'updated_at:datetime',
  125. [
  126. 'attribute' => 'status',
  127. 'value' => function ($model) {
  128. return Space::getStatusList($model->status);
  129. },
  130. ],
  131. ],
  132. ]) ?>
  133. </div>
  134. <!-- 管理商品列表管理-->
  135. <div class="tab-pane " id="tab_2">
  136. <?= GridView::widget([
  137. 'dataProvider' => $index['data'],
  138. //'filterModel' => $searchModel,
  139. 'columns' => [
  140. 'id',
  141. 'goods_id',
  142. 'entity',
  143. 'entity_id',
  144. 'attribute',
  145. [
  146. 'class' => 'common\helpers\DiyActionColumn',
  147. 'template' => '{update} {delete}',
  148. 'buttons' => [
  149. 'update' => function ($url, $model, $key) {
  150. return Html::a(Yii::t('yii', 'Update'), Url::to(['/goods-index/update', 'id' => $model->id,'origin'=>Yii::$app->request->url]), [
  151. 'class' => 'btn btn-success btn-xs',
  152. 'title' => Yii::t('common', 'Update Goods Index'),
  153. 'target' => '_blank'
  154. ]);
  155. },
  156. 'delete' => function ($url, $model, $key) {
  157. return Html::a('删除', Url::to(['/goods-index/delete', 'id' => $model->id,'origin'=>Yii::$app->request->url]), [
  158. 'class' => 'btn btn-success btn-xs',
  159. 'title' => Yii::t('common', '删除关联商品'),
  160. 'data-confirm' => Yii::t('yii', 'Are you sure you want to delete this item?'),
  161. 'data-method' => 'post',
  162. ]);
  163. },
  164. ],
  165. ],
  166. ],
  167. ]); ?>
  168. </div>
  169. </div>
  170. </div>