Browse Source

antgoods模块增加规格管理

wechat_public_accounts
linyaostalker 5 years ago
parent
commit
08b43dff7e
  1. 1
      backend/views/layouts/sidebar.php
  2. 12
      vendor/antgoods/goods/src/controllers/AttributeController.php
  3. 147
      vendor/antgoods/goods/src/models/searchs/AttributeSearch.php
  4. 2
      vendor/antgoods/goods/src/views/attribute/_form.php
  5. 2
      vendor/antgoods/goods/src/views/attribute/_search.php
  6. 2
      vendor/antgoods/goods/src/views/attribute/create.php
  7. 2
      vendor/antgoods/goods/src/views/attribute/index.php
  8. 2
      vendor/antgoods/goods/src/views/attribute/update.php
  9. 2
      vendor/antgoods/goods/src/views/attribute/view.php

1
backend/views/layouts/sidebar.php

@ -21,6 +21,7 @@ use iron\widgets\Menu;
] ]
], ],
['label' => '商品管理', 'url' => '#', 'icon' => 'far fa-archive', 'items' => [ ['label' => '商品管理', 'url' => '#', 'icon' => 'far fa-archive', 'items' => [
['label' => '规格管理', 'url' => ['/antgoods/attribute/index']],
['label' => '商品列表', 'url' => ['/antgoods/goods/index']], ['label' => '商品列表', 'url' => ['/antgoods/goods/index']],
['label' => '后台商品分类', 'url' => ['/antgoods/category/index']], ['label' => '后台商品分类', 'url' => ['/antgoods/category/index']],
['label' => '前端商品分类', 'url' => ['/antgoods/shopcategory/index']], ['label' => '前端商品分类', 'url' => ['/antgoods/shopcategory/index']],

backend/controllers/AttributeController.php → vendor/antgoods/goods/src/controllers/AttributeController.php

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

@ -0,0 +1,147 @@
<?php
namespace antgoods\goods\models\searchs;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use yii\helpers\ArrayHelper;
use antgoods\goods\models\ars\Attribute;
/**
* AttributeSearch represents the model behind the search form of `antgoods\goods\models\ars\Attribute`.
*/
class AttributeSearch extends Attribute
{
/**
* @return array
* 增加创建时间查询字段
*/
public function attributes()
{
return ArrayHelper::merge(['created_at_range'], parent::attributes());
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['id', 'type', 'sort_order', 'is_delete', 'created_at', 'updated_at'], 'integer'],
[['name', 'value'], 'safe'],
['created_at_range','safe'],
];
}
/**
* {@inheritdoc}
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* @return array
* 列格式
*/
public function columns()
{
return [
[
'class' => 'blobt\grid\CheckboxColumn',
'width' => '2%',
'align' => 'center'
],
'id',
'name',
'value',
'type',
'sort_order',
//'is_delete',
//'created_at',
//'updated_at',
[
'class' => 'iron\grid\ActionColumn',
'align' => 'center',
],
];
}
/**
* @param $params
* @return ActiveDataProvider
* 不分页的所有数据
*/
public function allData($params)
{
$query = Attribute::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => false,
'sort' => false
]);
$this->load($params);
return $this->filter($query, $dataProvider);
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Attribute::find();
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => [
'pageSizeLimit' => [1, 200]
],
'sort' => [
'defaultOrder' => [
'id' => SORT_DESC,
]
],
]);
$this->load($params);
return $this->filter($query, $dataProvider);
}
/**
* @param $query
* @param $dataProvider
* @return ActiveDataProvider
* 条件筛选
*/
private function filter($query, $dataProvider){
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
// grid filtering conditions
$query->andFilterWhere([
'id' => $this->id,
'type' => $this->type,
'sort_order' => $this->sort_order,
'is_delete' => $this->is_delete,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
]);
$query->andFilterWhere(['like', 'name', $this->name])
->andFilterWhere(['like', 'value', $this->value]);
if ($this->created_at_range) {
$arr = explode(' ~ ', $this->created_at_range);
$start = strtotime($arr[0]);
$end = strtotime($arr[1]) + 3600 * 24;
$query->andFilterWhere(['between', 'created_at', $start, $end]);
}
return $dataProvider;
}
}

backend/views/attribute/_form.php → vendor/antgoods/goods/src/views/attribute/_form.php

backend/views/attribute/_search.php → vendor/antgoods/goods/src/views/attribute/_search.php

backend/views/attribute/create.php → vendor/antgoods/goods/src/views/attribute/create.php

backend/views/attribute/index.php → vendor/antgoods/goods/src/views/attribute/index.php

backend/views/attribute/update.php → vendor/antgoods/goods/src/views/attribute/update.php

backend/views/attribute/view.php → vendor/antgoods/goods/src/views/attribute/view.php

Loading…
Cancel
Save