index.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. use common\models\Master;
  3. use yii\helpers\Html;
  4. use yii\grid\GridView;
  5. use yii\helpers\Url;
  6. /* @var $this yii\web\View */
  7. /* @var $searchModel backend\models\search\MasterSearch */
  8. /* @var $dataProvider yii\data\ActiveDataProvider */
  9. $this->title = Yii::t('common', 'Masters');
  10. $this->params['breadcrumbs'][] = $this->title;
  11. ?>
  12. <?php $this->beginBlock('content-header') ?>
  13. <?= $this->title . ' ' . Html::a(Yii::t('common', 'Create Master'), ['create'], ['class' => 'btn btn-success']) ?>
  14. <?php $this->endBlock() ?>
  15. <?php echo $this->render('_search', ['model' => $searchModel]); ?>
  16. <div class="box box-success">
  17. <div class="box-body">
  18. <?= GridView::widget([
  19. 'dataProvider' => $dataProvider,
  20. //'filterModel' => $searchModel,
  21. 'columns' => [
  22. 'id',
  23. 'name',
  24. 'desc',
  25. [
  26. 'attribute' => 'province',
  27. 'format' => 'raw',
  28. 'value' => function ($model) {
  29. return \common\models\Region::getNameById($model->province);
  30. },
  31. ],
  32. [
  33. 'attribute' => 'city',
  34. 'format' => 'raw',
  35. 'value' => function ($model) {
  36. return \common\models\Region::getNameById($model->city);
  37. },
  38. ],
  39. [
  40. 'attribute' => 'area',
  41. 'format' => 'raw',
  42. 'value' => function ($model) {
  43. return \common\models\Region::getNameById($model->area);
  44. },
  45. ],
  46. // 'address',
  47. 'fields',
  48. 'works',
  49. 'tel',
  50. 'created_at:datetime',
  51. 'updated_at:datetime',
  52. [
  53. 'attribute' => 'status',
  54. 'value' => function ($model) {
  55. return Master::getStatusList($model->status);
  56. },
  57. ],
  58. ['class' => 'common\helpers\DiyActionColumn',
  59. 'template' => '{goods} {view} {update} {delete}',
  60. 'buttons' => [
  61. 'goods' => function ($url, $model, $key) {
  62. return Html::a('商品设置', Url::to(['/goods-index/create', 'entity' => Master::className(),'entity_id'=>$model->id,'origin'=>Yii::$app->request->url]), [
  63. 'class' => 'btn btn-success btn-xs',
  64. 'title'=>Yii::t('common', 'Create Goods Index'),
  65. 'target'=>'_blank'
  66. ]);
  67. },
  68. 'view' => function ($url, $model, $key) {
  69. return Html::a('查看', Url::to(['/master/view', 'id' => $model->id]), [
  70. 'class' => 'btn btn-success btn-xs',
  71. 'title'=>$model->name.'详情',
  72. 'target'=>'_blank'
  73. ]);
  74. },
  75. ]
  76. ],
  77. ],
  78. ]); ?>
  79. </div>
  80. </div>