1.提交缺失的东西
This commit is contained in:
@ -18,7 +18,7 @@ namespace app\adminapi\lists;
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\Goods;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* Goods列表
|
||||
@ -54,7 +54,7 @@ class GoodsLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return Goods::where($this->searchWhere)
|
||||
$data = Goods::where($this->searchWhere)
|
||||
->field(['id', 'name', 'code', 'first_category_id', 'second_category_id',
|
||||
'third_category_id', 'brand_id', 'supplier_id', 'status', 'image',
|
||||
'video', 'poster', 'remark', 'content', 'sort',
|
||||
@ -71,8 +71,28 @@ class GoodsLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
$goods_category_list = Db::name('goods_category')->where(['del'=>0])->column('name','id');
|
||||
foreach($data as $item){
|
||||
$item['cat_name'] = self::getCateName($goods_category_list, $item);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
public static function getCateName($cates, $item)
|
||||
{
|
||||
if(isset($cates[$item['third_category_id']])) {
|
||||
return $cates[$item['third_category_id']];
|
||||
}
|
||||
|
||||
if(isset($cates[$item['second_category_id']])) {
|
||||
return $cates[$item['second_category_id']];
|
||||
}
|
||||
|
||||
if(isset($cates[$item['first_category_id']])) {
|
||||
return $cates[$item['first_category_id']];
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取数量
|
||||
|
||||
Reference in New Issue
Block a user