Browse Source

修改后台商品分类列表字段

wechat_public_accounts
linyaostalker 5 years ago
parent
commit
d477d0fad5
  1. 6
      vendor/antgoods/goods/src/models/ars/Category.php
  2. 28
      vendor/antgoods/goods/src/models/searchs/CategorySearch.php

6
vendor/antgoods/goods/src/models/ars/Category.php

@ -4,6 +4,7 @@ namespace antgoods\goods\models\ars;
use Yii;
use yii\behaviors\TimestampBehavior;
use common\models\ars\File;
/**
* This is the model class for table "antgoods_category".
@ -106,4 +107,9 @@ class Category extends \yii\db\ActiveRecord
{
return $column = self::find()->select(['name'])->where(['is_delete' => self::IS_DELETE_NO])->indexBy('id')->column();
}
public function getIconFile()
{
return $this->hasOne(File::className(), ['id' => 'icon']);
}
}

28
vendor/antgoods/goods/src/models/searchs/CategorySearch.php

@ -6,6 +6,7 @@ use yii\base\Model;
use yii\data\ActiveDataProvider;
use yii\helpers\ArrayHelper;
use antgoods\goods\models\ars\Category;
use yii\bootstrap4\Html;
/**
* CategorySearch represents the model behind the search form of `antgoods\goods\models\ars\Category`.
@ -54,9 +55,36 @@ class CategorySearch extends Category
],
'id',
'name',
['attribute' => 'icon',
'contentOptions' => [
'align' => 'center',
],
'width'=>'10%',
'format' => 'raw',
'value' => function ($model) {
return $model->iconFile ?
Html::img(['/'.$model->iconFile->path], ['style' => 'width:80px'])
: '<div class="table_not_setting">未设置</div>';
}
],
'sort_order',
[
'class' => 'iron\grid\ActionColumn',
'align' => 'center',
'config' => [
[
'name' => 'update',
'icon' => 'pencil',
'title' => '修改'
],
[
'name' => 'delete',
'icon' => 'trash',
'title' => '删除',
'contents' => '确定删除?'
]
],
],
];
}

Loading…
Cancel
Save