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