diff --git a/vendor/antgoods/goods/src/models/ars/Category.php b/vendor/antgoods/goods/src/models/ars/Category.php index 6a50d3a..7dbc2a8 100644 --- a/vendor/antgoods/goods/src/models/ars/Category.php +++ b/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']); + } } diff --git a/vendor/antgoods/goods/src/models/searchs/AttributeSearch.php b/vendor/antgoods/goods/src/models/searchs/AttributeSearch.php index 2256a62..54e2c1d 100644 --- a/vendor/antgoods/goods/src/models/searchs/AttributeSearch.php +++ b/vendor/antgoods/goods/src/models/searchs/AttributeSearch.php @@ -52,10 +52,10 @@ class AttributeSearch extends Attribute 'width' => '2%', 'align' => 'center' ], - 'id', - 'name', - 'value', - 'sort_order', + 'id', + 'name', + 'value', + 'sort_order', [ 'class' => 'iron\grid\ActionColumn', 'align' => 'center', @@ -76,10 +76,10 @@ class AttributeSearch extends Attribute ]; } /** - * @param $params - * @return ActiveDataProvider - * 不分页的所有数据 - */ + * @param $params + * @return ActiveDataProvider + * 不分页的所有数据 + */ public function allData($params) { $query = Attribute::find(); diff --git a/vendor/antgoods/goods/src/models/searchs/CategorySearch.php b/vendor/antgoods/goods/src/models/searchs/CategorySearch.php index 47dd9cd..d8bedf6 100644 --- a/vendor/antgoods/goods/src/models/searchs/CategorySearch.php +++ b/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`. @@ -52,11 +53,38 @@ class CategorySearch extends Category 'width' => '2%', 'align' => 'center' ], - 'id', - 'name', + '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']) + : '
未设置
'; + + } + ], + 'sort_order', [ 'class' => 'iron\grid\ActionColumn', 'align' => 'center', + 'config' => [ + [ + 'name' => 'update', + 'icon' => 'pencil', + 'title' => '修改' + ], + [ + 'name' => 'delete', + 'icon' => 'trash', + 'title' => '删除', + 'contents' => '确定删除?' + ] + ], ], ]; }