Browse Source

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

wechat_public_accounts
linyaostalker 5 years ago
parent
commit
d477d0fad5
  1. 6
      vendor/antgoods/goods/src/models/ars/Category.php
  2. 16
      vendor/antgoods/goods/src/models/searchs/AttributeSearch.php
  3. 32
      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;
use yii\behaviors\TimestampBehavior; use yii\behaviors\TimestampBehavior;
use common\models\ars\File;
/** /**
* This is the model class for table "antgoods_category". * 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(); 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']);
}
} }

16
vendor/antgoods/goods/src/models/searchs/AttributeSearch.php

@ -52,10 +52,10 @@ class AttributeSearch extends Attribute
'width' => '2%', 'width' => '2%',
'align' => 'center' 'align' => 'center'
], ],
'id',
'name',
'value',
'sort_order',
'id',
'name',
'value',
'sort_order',
[ [
'class' => 'iron\grid\ActionColumn', 'class' => 'iron\grid\ActionColumn',
'align' => 'center', 'align' => 'center',
@ -76,10 +76,10 @@ class AttributeSearch extends Attribute
]; ];
} }
/** /**
* @param $params
* @return ActiveDataProvider
* 不分页的所有数据
*/
* @param $params
* @return ActiveDataProvider
* 不分页的所有数据
*/
public function allData($params) public function allData($params)
{ {
$query = Attribute::find(); $query = Attribute::find();

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

@ -6,6 +6,7 @@ use yii\base\Model;
use yii\data\ActiveDataProvider; use yii\data\ActiveDataProvider;
use yii\helpers\ArrayHelper; use yii\helpers\ArrayHelper;
use antgoods\goods\models\ars\Category; use antgoods\goods\models\ars\Category;
use yii\bootstrap4\Html;
/** /**
* CategorySearch represents the model behind the search form of `antgoods\goods\models\ars\Category`. * CategorySearch represents the model behind the search form of `antgoods\goods\models\ars\Category`.
@ -52,11 +53,38 @@ class CategorySearch extends Category
'width' => '2%', 'width' => '2%',
'align' => 'center' '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'])
: '<div class="table_not_setting">未设置</div>';
}
],
'sort_order',
[ [
'class' => 'iron\grid\ActionColumn', 'class' => 'iron\grid\ActionColumn',
'align' => 'center', 'align' => 'center',
'config' => [
[
'name' => 'update',
'icon' => 'pencil',
'title' => '修改'
],
[
'name' => 'delete',
'icon' => 'trash',
'title' => '删除',
'contents' => '确定删除?'
]
],
], ],
]; ];
} }

Loading…
Cancel
Save