|
|
@ -30,6 +30,10 @@ class GoodsNewController extends AdminController |
|
|
$categoryList = CategoryModel::getArray([['parent_id','>',0]],['选择分类'=>0]); |
|
|
$categoryList = CategoryModel::getArray([['parent_id','>',0]],['选择分类'=>0]); |
|
|
// 店铺
|
|
|
// 店铺
|
|
|
$storeList = StoreModel::getStoreArray(); |
|
|
$storeList = StoreModel::getStoreArray(); |
|
|
|
|
|
// 商品类目
|
|
|
|
|
|
$goodsCategoryList = GoodsCategoryModel::getArray([],['选择类目'=>0]); |
|
|
|
|
|
//市场
|
|
|
|
|
|
$marketList = MarketModel::getMarketArray(); |
|
|
|
|
|
|
|
|
$grid->id->sortable(); |
|
|
$grid->id->sortable(); |
|
|
$grid->cover_img_url->image('',50); |
|
|
$grid->cover_img_url->image('',50); |
|
|
@ -44,22 +48,27 @@ class GoodsNewController extends AdminController |
|
|
return empty($store) ? '' : $store->name; |
|
|
return empty($store) ? '' : $store->name; |
|
|
}); |
|
|
}); |
|
|
$grid->category_id->select($categoryList); |
|
|
$grid->category_id->select($categoryList); |
|
|
|
|
|
// ->load('goods_category_id', '/api/goods_category_list')
|
|
|
// ->display(function ($categoryId){
|
|
|
// ->display(function ($categoryId){
|
|
|
// $item = CategoryModel::getInfo($categoryId,'title');
|
|
|
// $item = CategoryModel::getInfo($categoryId,'title');
|
|
|
// return empty($item) ? '选择分类' : $item->title;
|
|
|
// return empty($item) ? '选择分类' : $item->title;
|
|
|
// });
|
|
|
// });
|
|
|
$grid->goods_category_id->display(function ($goodsCategoryId){ |
|
|
|
|
|
$item = GoodsCategoryModel::getInfo($goodsCategoryId,'title'); |
|
|
|
|
|
return empty($item) ? '' : $item->title; |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
$grid->goods_category_id->select($goodsCategoryList); |
|
|
|
|
|
// ->display(function ($goodsCategoryId){
|
|
|
|
|
|
// $item = GoodsCategoryModel::getInfo($goodsCategoryId,'title');
|
|
|
|
|
|
// return empty($item) ? '' : $item->title;
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
$grid->sort->sortable(); |
|
|
$grid->sort->sortable(); |
|
|
$grid->on_sale->switch(); |
|
|
$grid->on_sale->switch(); |
|
|
|
|
|
|
|
|
$grid->actions([new GoodsNewCopy()]); |
|
|
$grid->actions([new GoodsNewCopy()]); |
|
|
$grid->filter(function (Grid\Filter $filter) use($storeList){ |
|
|
|
|
|
|
|
|
$grid->filter(function (Grid\Filter $filter) use($storeList, $categoryList, $goodsCategoryList, $marketList){ |
|
|
$filter->like('name'); |
|
|
$filter->like('name'); |
|
|
$filter->equal('store_id')->select($storeList); |
|
|
$filter->equal('store_id')->select($storeList); |
|
|
|
|
|
$filter->equal('category_id')->select($categoryList); |
|
|
|
|
|
$filter->equal('goods_category_id')->select($goodsCategoryList); |
|
|
|
|
|
$filter->equal('market_id')->select($marketList); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
$grid->model()->orderBy('category_id', 'asc'); |
|
|
$grid->model()->orderBy('category_id', 'asc'); |
|
|
@ -208,10 +217,10 @@ class GoodsNewController extends AdminController |
|
|
}); |
|
|
}); |
|
|
$form->switch('on_sale') |
|
|
$form->switch('on_sale') |
|
|
->customFormat(function ($v) { |
|
|
->customFormat(function ($v) { |
|
|
return $v == '上架' ? 1 : 0; |
|
|
|
|
|
|
|
|
return $v == 1 ? 1 : 0; |
|
|
}) |
|
|
}) |
|
|
->saving(function ($v) { |
|
|
->saving(function ($v) { |
|
|
return $v; |
|
|
|
|
|
|
|
|
return $v == 1 ? 1 : 0; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
$form->disableResetButton(); |
|
|
$form->disableResetButton(); |
|
|
|