|
|
@@ -38,11 +38,29 @@ class FaultTypeLists extends BaseAdminDataLists implements ListsSearchInterface
|
|
|
public function setSearch(): array
|
|
|
{
|
|
|
return [
|
|
|
- '=' => ['name', 'pid', 'sort', 'level', 'status'],
|
|
|
-
|
|
|
+ '=' => ['pid', 'sort', 'level', 'goods_category_id'],
|
|
|
];
|
|
|
}
|
|
|
|
|
|
+ public function queryWhere()
|
|
|
+ {
|
|
|
+ $where = [];
|
|
|
+ if (isset($this->params['status']) && $this->params['status'] != '') {
|
|
|
+ $where[] = ['a.status', '=', $this->params['status']];
|
|
|
+ }
|
|
|
+ if (!empty($this->params['name'])) {
|
|
|
+ $where[] = ['a.name', 'like', '%' . $this->params['name'] . '%'];
|
|
|
+ }
|
|
|
+ if (!empty($this->params['category_name'])) {
|
|
|
+ $where[] = ['b.name', 'like', '%' . $this->params['category_name'] . '%'];
|
|
|
+ }
|
|
|
+ if (!empty($this->params['category_type'])) {
|
|
|
+ $where[] = ['a.category_type', '=', $this->params['category_type']];
|
|
|
+ }
|
|
|
+ $where[] = ['a.pid', '=', 0];
|
|
|
+ return $where;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* @notes 获取列表
|
|
|
@@ -55,15 +73,20 @@ class FaultTypeLists extends BaseAdminDataLists implements ListsSearchInterface
|
|
|
*/
|
|
|
public function lists(): array
|
|
|
{
|
|
|
- return FaultType::where($this->searchWhere)
|
|
|
- ->field(['id', 'name', 'pid', 'sort', 'level', 'status'])
|
|
|
+ $lists = FaultType::alias("a")
|
|
|
+ ->with(['children'])
|
|
|
+ ->leftJoin("goods_category b", "a.goods_category_id = b.id")
|
|
|
+ ->where($this->searchWhere)
|
|
|
+ ->where($this->queryWhere())
|
|
|
+ ->field("a.*,b.name as category_name")
|
|
|
->limit($this->limitOffset, $this->limitLength)
|
|
|
- ->order(['id' => 'desc'])
|
|
|
+ ->append(['status_desc'])
|
|
|
+ ->order(['a.sort' => 'desc', 'a.id' => 'desc'])
|
|
|
->select()
|
|
|
->toArray();
|
|
|
+ return $lists;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* @notes 获取数量
|
|
|
* @return int
|
|
|
@@ -72,7 +95,11 @@ class FaultTypeLists extends BaseAdminDataLists implements ListsSearchInterface
|
|
|
*/
|
|
|
public function count(): int
|
|
|
{
|
|
|
- return FaultType::where($this->searchWhere)->count();
|
|
|
+ return FaultType::alias("a")
|
|
|
+ ->where($this->searchWhere)
|
|
|
+ ->where($this->queryWhere())
|
|
|
+ ->leftJoin("goods_category b", "a.goods_category_id = b.id")
|
|
|
+ ->count();
|
|
|
}
|
|
|
|
|
|
}
|