完善用户中心内容模块
This commit is contained in:
@@ -34,12 +34,17 @@ class Content extends Base {
|
|||||||
* @author molong <ycgpp@126.com>
|
* @author molong <ycgpp@126.com>
|
||||||
*/
|
*/
|
||||||
public function index() {
|
public function index() {
|
||||||
|
$param = $this->request->param();
|
||||||
if ($this->modelInfo['list_grid'] == '') {
|
if ($this->modelInfo['list_grid'] == '') {
|
||||||
return $this->error("列表定义不正确!", url('/admin/model/edit', array('id' => $this->modelInfo['id'])));
|
return $this->error("列表定义不正确!", url('/admin/model/edit', array('id' => $this->modelInfo['id'])));
|
||||||
}
|
}
|
||||||
$order = "id desc";
|
$order = "id desc";
|
||||||
$map = [];
|
$map = [];
|
||||||
|
|
||||||
|
if (isset($param['keyword']) && $param['keyword'] != '') {
|
||||||
|
$map[] = ['title', 'LIKE', '%'.$param['keyword'].'%'];
|
||||||
|
}
|
||||||
|
|
||||||
$list = $this->model->where($map)->order($order)->paginate($this->modelInfo['list_row'], false, array(
|
$list = $this->model->where($map)->order($order)->paginate($this->modelInfo['list_row'], false, array(
|
||||||
'query' => $this->request->param(),
|
'query' => $this->request->param(),
|
||||||
));
|
));
|
||||||
@@ -50,7 +55,8 @@ class Content extends Base {
|
|||||||
'page' => $list->render(),
|
'page' => $list->render(),
|
||||||
'model_name' => $this->modelInfo['name'],
|
'model_name' => $this->modelInfo['name'],
|
||||||
'model_id' => $this->modelInfo['id'],
|
'model_id' => $this->modelInfo['id'],
|
||||||
'meta_title' => $this->modelInfo['title'].'列表'
|
'meta_title' => $this->modelInfo['title'].'列表',
|
||||||
|
'param' => $param
|
||||||
);
|
);
|
||||||
if ($this->modelInfo['template_list']) {
|
if ($this->modelInfo['template_list']) {
|
||||||
$template = 'admin/content/' . $this->modelInfo['template_list'];
|
$template = 'admin/content/' . $this->modelInfo['template_list'];
|
||||||
|
|||||||
@@ -31,12 +31,16 @@ class Content extends Base {
|
|||||||
* @return [type] [description]
|
* @return [type] [description]
|
||||||
*/
|
*/
|
||||||
public function index() {
|
public function index() {
|
||||||
|
$param = $this->request->param();
|
||||||
if ($this->modelInfo['list_grid'] == '') {
|
if ($this->modelInfo['list_grid'] == '') {
|
||||||
return $this->error("列表定义不正确!", url('/user/model/edit', array('id' => $this->modelInfo['id'])));
|
return $this->error("列表定义不正确!", url('/user/model/edit', array('id' => $this->modelInfo['id'])));
|
||||||
}
|
}
|
||||||
$order = "id desc";
|
$order = "id desc";
|
||||||
$map = [];
|
$map = [];
|
||||||
$map[] = ['uid', '=', session('userInfo.uid')];
|
$map[] = ['uid', '=', session('userInfo.uid')];
|
||||||
|
if (isset($param['keyword']) && $param['keyword'] != '') {
|
||||||
|
$map[] = ['title', 'LIKE', '%'.$param['keyword'].'%'];
|
||||||
|
}
|
||||||
|
|
||||||
$list = $this->model->where($map)->order($order)->paginate($this->modelInfo['list_row'], false, array(
|
$list = $this->model->where($map)->order($order)->paginate($this->modelInfo['list_row'], false, array(
|
||||||
'query' => $this->request->param(),
|
'query' => $this->request->param(),
|
||||||
@@ -48,7 +52,8 @@ class Content extends Base {
|
|||||||
'page' => $list->render(),
|
'page' => $list->render(),
|
||||||
'model_name' => $this->modelInfo['name'],
|
'model_name' => $this->modelInfo['name'],
|
||||||
'model_id' => $this->modelInfo['id'],
|
'model_id' => $this->modelInfo['id'],
|
||||||
'meta_title' => $this->modelInfo['title'].'列表'
|
'meta_title' => $this->modelInfo['title'].'列表',
|
||||||
|
'param' => $param
|
||||||
);
|
);
|
||||||
if ($this->modelInfo['template_list']) {
|
if ($this->modelInfo['template_list']) {
|
||||||
$template = 'user@content/' . $this->modelInfo['template_list'];
|
$template = 'user@content/' . $this->modelInfo['template_list'];
|
||||||
@@ -64,9 +69,34 @@ class Content extends Base {
|
|||||||
*/
|
*/
|
||||||
public function add() {
|
public function add() {
|
||||||
if ($this->request->isPost()) {
|
if ($this->request->isPost()) {
|
||||||
# code...
|
$data = $this->request->post();
|
||||||
|
$data['create_time'] = time();
|
||||||
|
$data['update_time'] = time();
|
||||||
|
$data['uid'] = session('userInfo.uid');
|
||||||
|
|
||||||
|
$result = $this->model->save($data);
|
||||||
|
if ($result) {
|
||||||
|
return $this->success("添加成功!", url('/user/'.$this->modelInfo['name'].'/index'));
|
||||||
|
} else {
|
||||||
|
return $this->error('添加失败!');
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
return $this->fetch();
|
$info = [
|
||||||
|
'model_name' => $this->modelInfo['name'],
|
||||||
|
'model_id' => $this->modelInfo['id']
|
||||||
|
];
|
||||||
|
$this->data = [
|
||||||
|
'info' => $info,
|
||||||
|
'fieldGroup' => Attribute::getField($this->modelInfo),
|
||||||
|
'meta_title' => $this->modelInfo['title'].'添加'
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($this->modelInfo['template_add']) {
|
||||||
|
$template = 'user/content/' . $this->modelInfo['template_add'];
|
||||||
|
} else {
|
||||||
|
$template = 'user@/edit';
|
||||||
|
}
|
||||||
|
return $this->fetch($template);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,11 +104,37 @@ class Content extends Base {
|
|||||||
* @title 修改内容
|
* @title 修改内容
|
||||||
* @return [type] [description]
|
* @return [type] [description]
|
||||||
*/
|
*/
|
||||||
public function edit() {
|
public function edit($id) {
|
||||||
if ($this->request->isPost()) {
|
if ($this->request->isPost()) {
|
||||||
# code...
|
$data = $this->request->post();
|
||||||
|
$data['update_time'] = time();
|
||||||
|
|
||||||
|
$result = $this->model->save($data);
|
||||||
|
if ($result !== false) {
|
||||||
|
return $this->success("更新成功!", url('/user/'.$this->modelInfo['name'].'/index'));
|
||||||
|
} else {
|
||||||
|
return $this->error('修改失败!');
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
return $this->fetch();
|
if (!$id) {
|
||||||
|
return $this->error("非法操作!");
|
||||||
|
}
|
||||||
|
$info = $this->model->find($id);
|
||||||
|
if (!$info) {
|
||||||
|
return $this->error('无此数据!');
|
||||||
|
}
|
||||||
|
$info['model_id'] = $this->modelInfo['id'];
|
||||||
|
$this->data = array(
|
||||||
|
'info' => $info,
|
||||||
|
'fieldGroup' => Attribute::getField($this->modelInfo, 'edit'),
|
||||||
|
'meta_title' => $this->modelInfo['title'].'修改'
|
||||||
|
);
|
||||||
|
if ($this->modelInfo['template_edit']) {
|
||||||
|
$template = 'user/content/' . $this->modelInfo['template_edit'];
|
||||||
|
} else {
|
||||||
|
$template = 'user@/edit';
|
||||||
|
}
|
||||||
|
return $this->fetch('user@/edit');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,5 +143,6 @@ class Content extends Base {
|
|||||||
* @return [type] [description]
|
* @return [type] [description]
|
||||||
*/
|
*/
|
||||||
public function del() {
|
public function del() {
|
||||||
|
return $this->error("无删除权限!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -184,7 +184,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var require = {
|
var require = {
|
||||||
config: {"site": {$config|json_encode|raw}, 'module': 'admin', 'jsname': "{$require['jsname']|default=''}", 'actionname': "{$require['actionname']|default=''}", }
|
config: {"site": {$config|json_encode|raw}, 'module': 'user', 'jsname': "{$require['jsname']|default=''}", 'actionname': "{$require['actionname']|default=''}", }
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<script src="__plugins__/require/require.js" data-main="__js__/main.js"></script>
|
<script src="__plugins__/require/require.js" data-main="__js__/main.js"></script>
|
||||||
|
|||||||
@@ -3,12 +3,15 @@
|
|||||||
<div class="box box-primary">
|
<div class="box box-primary">
|
||||||
<div class="box-header with-border">
|
<div class="box-header with-border">
|
||||||
<h3 class="box-title">{$meta_title}</h3>
|
<h3 class="box-title">{$meta_title}</h3>
|
||||||
|
<div class="box-tools pull-right">
|
||||||
|
<a class="btn btn-sm btn-primary" href="{:url('/user/'.$model_name.'/add')}">新 增</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-body">
|
<div class="box-body">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<form method="get">
|
<form method="get">
|
||||||
<div class="col-sm-12 col-md-4 col-lg-3">
|
<div class="col-sm-12 col-md-4 col-lg-3">
|
||||||
<input type="text" class="form-control" name="keyword" value="{$keyword|default=''}" placeholder="请输入关键字">
|
<input type="text" class="form-control" name="keyword" value="{$param['keyword']|default=''}" placeholder="请输入关键字">
|
||||||
</div>
|
</div>
|
||||||
{if isset($cate_list)}
|
{if isset($cate_list)}
|
||||||
<div class="col-sm-12 col-md-4 col-lg-3">
|
<div class="col-sm-12 col-md-4 col-lg-3">
|
||||||
@@ -56,8 +59,8 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{/volist}
|
{/volist}
|
||||||
<td>
|
<td>
|
||||||
<a href="{:url('/admin/'.$model_name.'/edit', ['id'=>$item['id']])}" >编辑</a>
|
<a href="{:url('/user/'.$model_name.'/edit', ['id'=>$item['id']])}" >编辑</a>
|
||||||
<a href="{:url('/admin/'.$model_name.'/del', ['id'=>$item['id']])}" class="ajax-get confirm">删除</a>
|
<a href="{:url('/user/'.$model_name.'/del', ['id'=>$item['id']])}" class="ajax-get confirm">删除</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{/volist}
|
{/volist}
|
||||||
|
|||||||
@@ -12,14 +12,14 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<form method="get">
|
<form method="get">
|
||||||
<div class="col-sm-12 col-md-4 col-lg-3">
|
<div class="col-sm-12 col-md-4 col-lg-3">
|
||||||
<input type="text" class="form-control" name="keyword" value="{$keyword|default=''}" placeholder="请输入关键字">
|
<input type="text" class="form-control" name="keyword" value="{$param['keyword']|default=''}" placeholder="请输入关键字">
|
||||||
</div>
|
</div>
|
||||||
{if isset($cate_list)}
|
{if isset($cate_list)}
|
||||||
<div class="col-sm-12 col-md-4 col-lg-3">
|
<div class="col-sm-12 col-md-4 col-lg-3">
|
||||||
<select name="category" id="category" class="form-control">
|
<select name="category" id="category" class="form-control">
|
||||||
<option value="">请选择栏目</option>
|
<option value="">请选择栏目</option>
|
||||||
{volist name="cate_list" id="item"}
|
{volist name="cate_list" id="item"}
|
||||||
<option value="{$item['id']}" {if isset($category) && $item['id'] == $category}selected{/if}>{$item['title_show']}</option>
|
<option value="{$item['id']}" {if isset($param['category']) && $item['id'] == $param['category']}selected{/if}>{$item['title_show']}</option>
|
||||||
{/volist}
|
{/volist}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user