This commit is contained in:
2020-02-18 10:15:02 +08:00
parent 5fb45fc57c
commit d4325e3016
18 changed files with 194 additions and 159 deletions

View File

@@ -7,11 +7,15 @@
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\common\controller\Admin;
namespace app\controller\admin;
use app\model\Category as CategoryM;
use app\model\Attribute;
use app\model\Module;
use app\controller\Admin;
/**
* @title 分类管理
* @title 栏目管理
* @description 分类管理
*/
class Category extends Admin {
@@ -22,26 +26,34 @@ class Category extends Admin {
}
/**
* @title 分类列表
* @title 栏目列表
*/
public function index($model_id = '') {
$map = array('status' => array('gt', -1));
if ($model_id) {
$map['model_id'] = $model_id;
public function index(CategoryM $category, Attribute $attr, Module $medule) {
$param = $this->request->param();
$map = [];
$map[] = ['status', '>', -1];
if (isset($param['model_id']) && $param['model_id']) {
$map[] = ['model_id', '=', $model_id];
}
$list = db('Category')->where($map)->order('sort asc,id asc')->column('*', 'id');
$list = $category->where($map)->order('sort asc,id asc')->select();
if (!empty($list)) {
$tree = new \com\Tree();
$list = $tree->toFormatTree($list);
$tree = new \sent\tree\Tree();
$list = $tree->toFormatTree($list->toArray());
}
$subsql = db('Attribute')->where('name', 'category_id')->fetchSql(true)->column('model_id');
$model_list = model('Model')->where('id IN ('. $subsql.')')->select();
// $subsql = $attr->where('name', 'category_id')->fetchSql(true)->column('model_id');
// $model_list = $medule->where('id IN ('. $subsql.')')->select();
$this->assign('tree', $list);
$this->assign('model_list', $model_list);
$this->assign('model_id', $model_id);
$this->setMeta('栏目列表');
$this->data = [
'tree' => $list,
'module_id' => isset($param['module_id']) ? $param['module_id'] : 0,
'model_list' => []
];
// $this->assign('tree', $list);
// $this->assign('model_list', $model_list);
// $this->assign('model_id', $model_id);
// $this->setMeta('栏目列表');
return $this->fetch();
}