view.php 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <?php
  2. use common\models\Master;
  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\Master */
  10. $this->title = $model->name;
  11. $this->params['breadcrumbs'][] = ['label' => Yii::t('common', 'Masters'), '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' => Master::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. <?= DetailView::widget([
  33. 'model' => $model,
  34. 'attributes' => [
  35. 'id',
  36. [
  37. 'attribute' => 'cover',
  38. 'format' => 'raw',
  39. 'value' => function ($model) {
  40. $images = [ // images at popup window of prettyPhoto galary
  41. 1 => [
  42. 'src' => $model->cover,
  43. 'title' => '',
  44. ],
  45. ];
  46. return $model->cover ? LightBoxWidget::widget([
  47. 'id' => 'cover', // id of plugin should be unique at page
  48. 'class' => 'galary', // class of plugin to define style
  49. 'height' => '100px', // height of image visible in widget
  50. 'width' => '100px', // width of image visible in widget
  51. 'images' => $images,
  52. ]) : null;
  53. }
  54. ],
  55. [
  56. 'attribute' => 'banner',
  57. 'format' => 'raw',
  58. 'value' => function ($model) {
  59. $images = [];
  60. foreach ($model->banner as $index => $banner) {
  61. $images[$index] = ['src' => $banner, 'title' => ''];
  62. }
  63. return $model->banner ? LightBoxWidget::widget([
  64. 'id' => 'banner', // id of plugin should be unique at page
  65. 'class' => 'galary', // class of plugin to define style
  66. 'height' => '100px', // height of image visible in widget
  67. 'width' => '100px', // width of image visible in widget
  68. 'images' => $images,
  69. ]) : null;
  70. }
  71. ],
  72. [
  73. 'attribute' => 'picture',
  74. 'format' => 'raw',
  75. 'value' => function ($model) {
  76. $images = [];
  77. foreach ($model->picture as $index => $picture) {
  78. $images[$index] = ['src' => $picture, 'title' => ''];
  79. }
  80. return $model->picture ? LightBoxWidget::widget([
  81. 'id' => 'picture', // id of plugin should be unique at page
  82. 'class' => 'galary', // class of plugin to define style
  83. 'height' => '100px', // height of image visible in widget
  84. 'width' => '100px', // width of image visible in widget
  85. 'images' => $images,
  86. ]) : null;
  87. }
  88. ],
  89. [
  90. 'attribute' => 'vid',
  91. 'format' => 'raw',
  92. 'value' => function ($model){
  93. return '<iframe frameborder="0" src="https://v.qq.com/txp/iframe/player.html?vid='.$model->vid.'" allowFullScreen="true"></iframe>';
  94. }
  95. ],
  96. 'name',
  97. 'desc',
  98. [
  99. 'attribute' => 'province',
  100. 'format' => 'raw',
  101. 'value' => function ($model) {
  102. return \common\models\Region::getNameById($model->province);
  103. },
  104. ],
  105. [
  106. 'attribute' => 'city',
  107. 'format' => 'raw',
  108. 'value' => function ($model) {
  109. return \common\models\Region::getNameById($model->city);
  110. },
  111. ],
  112. [
  113. 'attribute' => 'area',
  114. 'format' => 'raw',
  115. 'value' => function ($model) {
  116. return \common\models\Region::getNameById($model->area);
  117. },
  118. ],
  119. 'address',
  120. 'fields',
  121. 'works',
  122. 'tel',
  123. 'created_at:datetime',
  124. 'updated_at:datetime',
  125. [
  126. 'attribute' => 'status',
  127. 'value' => function ($model) {
  128. return Master::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>