修复后台模块
This commit is contained in:
@@ -9,14 +9,21 @@
|
||||
|
||||
namespace app\controller\admin;
|
||||
|
||||
use think\facade\Db;
|
||||
use app\model\Model;
|
||||
use app\model\Attribute;
|
||||
|
||||
/**
|
||||
* @title 内容管理
|
||||
*/
|
||||
class Content extends Base {
|
||||
|
||||
public $modelInfo = [];
|
||||
|
||||
public function initialize() {
|
||||
parent::initialize();
|
||||
$this->getContentMenu();
|
||||
$this->modelInfo = Model::where('name', $this->request->param('name'))->find()->append(['grid_list'])->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -28,27 +35,25 @@ class Content extends Base {
|
||||
if ($this->modelInfo['list_grid'] == '') {
|
||||
return $this->error("列表定义不正确!", url('admin/model/edit', array('id' => $this->modelInfo['id'])));
|
||||
}
|
||||
$grid_list = get_grid_list($this->modelInfo['list_grid']);
|
||||
$order = "id desc";
|
||||
$map = $this->buildMap();
|
||||
$field = array_filter($grid_list['fields']);
|
||||
$map = [];
|
||||
|
||||
$list = $this->model->where($map)->order($order)->paginate($this->modelInfo['list_row'], false, array(
|
||||
$list = Db::name($this->modelInfo['name'])->where($map)->order($order)->paginate($this->modelInfo['list_row'], false, array(
|
||||
'query' => $this->request->param(),
|
||||
));
|
||||
|
||||
$data = array(
|
||||
'grid' => $grid_list,
|
||||
$this->data = array(
|
||||
'grid' => $this->modelInfo['grid_list'],
|
||||
'list' => $list,
|
||||
'page' => $list->render(),
|
||||
'model_name' => $this->modelInfo['name'],
|
||||
'model_id' => $this->modelInfo['id']
|
||||
);
|
||||
if ($this->modelInfo['template_list']) {
|
||||
$template = 'content/' . $this->modelInfo['template_list'];
|
||||
$template = 'admin/content/' . $this->modelInfo['template_list'];
|
||||
} else {
|
||||
$template = 'content/index';
|
||||
$template = 'admin/content/index';
|
||||
}
|
||||
$this->assign($data);
|
||||
$this->setMeta($this->modelInfo['title'] . "列表");
|
||||
return $this->fetch($template);
|
||||
}
|
||||
|
||||
@@ -60,27 +65,25 @@ class Content extends Base {
|
||||
if ($this->request->isPost()) {
|
||||
$result = $this->model->save($this->request->param());
|
||||
if ($result) {
|
||||
//记录行为
|
||||
action_log('add_content', 'content', $result, session('auth_user.uid'));
|
||||
return $this->success("添加成功!", url('admin/content/index', array('model_id' => $this->modelInfo['id'])));
|
||||
} else {
|
||||
return $this->error($this->model->getError(), url('admin/content/add', array('model_id' => $this->modelInfo['id'])));
|
||||
}
|
||||
} else {
|
||||
$info = array(
|
||||
$info = [
|
||||
'model_name' => $this->modelInfo['name'],
|
||||
'model_id' => $this->modelInfo['id'],
|
||||
);
|
||||
$data = array(
|
||||
];
|
||||
$this->data = [
|
||||
'info' => $info,
|
||||
'fieldGroup' => $this->getField($this->modelInfo),
|
||||
);
|
||||
];
|
||||
|
||||
if ($this->modelInfo['template_add']) {
|
||||
$template = 'content/' . $this->modelInfo['template_add'];
|
||||
} else {
|
||||
$template = 'public/edit';
|
||||
}
|
||||
$this->assign($data);
|
||||
$this->setMeta("添加" . $this->modelInfo['title']);
|
||||
return $this->fetch($template);
|
||||
}
|
||||
}
|
||||
@@ -190,7 +193,7 @@ class Content extends Base {
|
||||
}
|
||||
|
||||
//获得数组的第一条数组
|
||||
$rows = model('Attribute')->getFieldlist($map, 'id');
|
||||
$rows = Attribute::getFieldlist($map, 'id');
|
||||
if (!empty($rows)) {
|
||||
foreach ($rows as $key => $value) {
|
||||
$list[$value['group_id']][] = $value;
|
||||
|
||||
Reference in New Issue
Block a user