You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
3.5 KiB

  1. <?php
  2. use antgoods\models\ars\Goods;
  3. use yii\bootstrap4\Html;
  4. use yii\widgets\DetailView;
  5. use common\models\ars\File;
  6. /* @var $this yii\web\View */
  7. /* @var $model antgoods\models\ars\Goods */
  8. $this->title = $model->name;
  9. $this->params['breadcrumbs'][] = ['label' => '商品管理', 'url' => ['index']];
  10. $this->params['breadcrumbs'][] = $this->title;
  11. \yii\web\YiiAsset::register($this);
  12. ?>
  13. <div class="goods-view">
  14. <p>
  15. <?= Html::a('返回列表', ['index'], ['class' => 'btn btn-success']) ?>
  16. </p>
  17. <?= DetailView::widget([
  18. 'model' => $model,
  19. 'attributes' => [
  20. 'id',
  21. 'name',
  22. 'sn',
  23. [
  24. 'attribute' => 'cat_id',
  25. 'width' => '10%',
  26. 'value' => function ($model) {
  27. return $model->category ? $model->category->name : '';
  28. },
  29. ],
  30. [
  31. 'attribute' => 'shop_cat_id',
  32. 'width' => '10%',
  33. 'value' => function ($model) {
  34. return $model->shopCategory ? $model->shopCategory->name : '';
  35. },
  36. ],
  37. [
  38. 'attribute' => 'brand_id',
  39. 'width' => '10%',
  40. 'value' => function ($model) {
  41. return $model->brand ? $model->brand->name : '';
  42. },
  43. ],
  44. 'code',
  45. [
  46. 'attribute' => 'supplier_id',
  47. 'width' => '10%',
  48. 'value' => function ($model) {
  49. return $model->supplier ? $model->supplier->name : '';
  50. },
  51. ],
  52. 'weight',
  53. 'length',
  54. 'width',
  55. 'height',
  56. 'diameter',
  57. 'unit',
  58. [
  59. 'attribute' => 'stock',
  60. 'width' => '5%',
  61. 'value' => function ($model) {
  62. if ($model->stock == -1) {
  63. return '未开启';
  64. } else {
  65. return $model->stock;
  66. }
  67. },
  68. ],
  69. 'market_price',
  70. 'price',
  71. 'brief',
  72. ['attribute' => 'image',
  73. 'format' => 'raw',
  74. 'value' => function ($model) {
  75. return $model->image ?
  76. Html::img(['/'.$model->imageFile->path], ['style' => 'width:80px'])
  77. : '<div class="table_not_setting">未设置</div>';
  78. }
  79. ],
  80. [
  81. 'label' => '详情图',
  82. 'format' => 'raw',
  83. 'value' => function ($model) {
  84. $image = '';
  85. $imgs = File::findAll(['own_id' => $model->id, 'own_type' => File::OWN_TYPE_GOODS_DETAILS, 'is_delete' => File::IS_DELETE_NO]);
  86. foreach ($imgs as $img) {
  87. $image .= Html::img(['/'.$img->path], ['style' => 'width:150px']);
  88. }
  89. return $image;
  90. }
  91. ],
  92. ['attribute' => 'is_sale',
  93. 'width' => '5%',
  94. 'value' =>
  95. function ($model) {
  96. return $model->is_sale ? Goods::$isSale[$model->is_sale] : '未设置';
  97. },
  98. ],
  99. 'sort_order',
  100. 'created_at:datetime',
  101. 'updated_at:datetime',
  102. ],
  103. ]) ?>
  104. </div>