mirror of https://github.com/1099438829/apeblog
This commit is contained in:
parent
328c4f2186
commit
730c5d087e
|
|
@ -151,7 +151,6 @@ abstract class BaseController
|
|||
} elseif ($url) {
|
||||
$url = (strpos($url, '://') || 0 === strpos($url, '/')) ? $url : $this->app->route->buildUrl($url);
|
||||
}
|
||||
|
||||
$result = [
|
||||
'code' => 0,
|
||||
'msg' => $msg,
|
||||
|
|
@ -162,7 +161,7 @@ abstract class BaseController
|
|||
|
||||
$type = $this->getResponseType();
|
||||
if ($type == 'html'){
|
||||
$response = view(config('app.dispatch_success_tmpl'), $result);
|
||||
$response = view(config('app.exception_tmpl'), $result);
|
||||
} else if ($type == 'json') {
|
||||
$response = json($result);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -174,14 +174,17 @@ class Article extends AuthController
|
|||
*/
|
||||
public function edit(Request $request)
|
||||
{
|
||||
$where = [
|
||||
'name' => '',
|
||||
'status' => ''
|
||||
];
|
||||
$where = Util::postMore([
|
||||
['name',''],
|
||||
['id','']
|
||||
]);
|
||||
if ($where['id'] ==''){
|
||||
return $this->error('数据不存在');
|
||||
}
|
||||
$category = cModel::systemPage($where);
|
||||
$category = get_tree_list($category);
|
||||
$info = aModel::get($request->param(['id']));
|
||||
$info->content = DocumentArticle::get($request->param(['id']))->content;
|
||||
$info = aModel::get($where['id']);
|
||||
$info->content = DocumentArticle::get($where['id'])->content;
|
||||
$this->assign("category",$category);
|
||||
$this->assign("info",$info);
|
||||
return $this->fetch();
|
||||
|
|
|
|||
|
|
@ -57,31 +57,24 @@ class Category extends AuthController
|
|||
{
|
||||
$data = Util::postMore([
|
||||
['title',''],
|
||||
['en_title',''],
|
||||
['type',''],
|
||||
['pid',0],
|
||||
['title_en',''],
|
||||
['module',''],
|
||||
['controller',''],
|
||||
['action',''],
|
||||
['params',''],
|
||||
['rank',0],
|
||||
['is_menu',1],
|
||||
['status',1]
|
||||
['meta_title',''],
|
||||
['keywords',''],
|
||||
['description',''],
|
||||
['template',''],
|
||||
['link_str',''],
|
||||
['sort',0],
|
||||
['display',1]
|
||||
]);
|
||||
if ($data['name'] == "") return app("json")->fail("权限名称不能为空");
|
||||
if ($data['pid'] == "") return app("json")->fail("上级归属不能为空");
|
||||
if ($data['module'] == "") return app("json")->fail("模块名不能为空");
|
||||
if ($data['controller'] == "") return app("json")->fail("控制器名不能为空");
|
||||
if ($data['action'] == "") return app("json")->fail("方法名不能为空");
|
||||
$data['path'] = '/'.$data['module'].'/'.$data['controller'].'/'.$data['action'];
|
||||
if ($data['title'] == "") return app("json")->fail("分类名称不能为空");
|
||||
if ($data['type'] == "") return app("json")->fail("类型不能为空");
|
||||
if ($id=="")
|
||||
{
|
||||
$data['create_user'] = $this->adminId;
|
||||
$data['create_time'] = time();
|
||||
$res = aModel::insert($data);
|
||||
}else
|
||||
{
|
||||
$data['update_user'] = $this->adminId;
|
||||
$data['update_time'] = time();
|
||||
$res = aModel::update($data,['id'=>$id]);
|
||||
}
|
||||
return $res ? app("json")->success("操作成功",'code') : app("json")->fail("操作失败");
|
||||
|
|
|
|||
|
|
@ -27,10 +27,7 @@ class DocumentCategory extends BaseModel
|
|||
public static function systemPage($where): array
|
||||
{
|
||||
$model = new self;
|
||||
$model = $model->where('status','>',-1)
|
||||
->field(['id','pid','title','sort','display'])
|
||||
->order('sort asc,id asc');
|
||||
if (isset($where['status']) && $where['status'] != '') $model = $model->where("status",$where['status']);
|
||||
$model = $model->field(['id','pid','title','sort','display'])->order('sort asc,id asc');
|
||||
if (isset($where['title']) && $where['title'] != '') $model = $model->where("title|id","like","%$where[title]%");
|
||||
$data = $model->select();
|
||||
return $data->toArray() ?: [];
|
||||
|
|
|
|||
|
|
@ -46,26 +46,26 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label for="pid">属性</label>
|
||||
<label>排序</label>
|
||||
<input type="text" class="form-control" name="sort" placeholder="请输入排序">
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label>属性</label>
|
||||
<div class="form-controls">
|
||||
<select name="pid" class="form-control">
|
||||
<option value="0">请选择</option>
|
||||
<select name="type" id="type" class="form-control">
|
||||
<!-- <option value="0">请选择</option>-->
|
||||
<option value="1">列表</option>
|
||||
<option value="2">单页</option>
|
||||
<option value="3">外联</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label>排序</label>
|
||||
<input type="text" class="form-control" name="sort" placeholder="请输入排序" value="99">
|
||||
<div class="form-group col-md-12" id="page-link-str" style="display: none">
|
||||
<label>外链</label>
|
||||
<input type="text" class="form-control" name="link_str" placeholder="外链">
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label for="link_str">外链</label>
|
||||
<input type="text" class="form-control" name="link_str" id="link_str" placeholder="外链">
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label for="content">单页内容</label>
|
||||
<div class="form-group col-md-12" id="page-content" style="display: none">
|
||||
<label>单页内容</label>
|
||||
<textarea id="content" name="content"></textarea>
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
|
|
@ -188,7 +188,7 @@
|
|||
if (!checkResult) {
|
||||
return false;
|
||||
}
|
||||
$.post(url="/admin/article/save",$('.add-form').serialize(),function (res) {
|
||||
$.post(url="/admin/category/save",$('.add-form').serialize(),function (res) {
|
||||
if (res.code == 200) {lightyear.notify(res.msg, 'success', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');setTimeout(function () {location.href='/admin/article/index';},2000)}
|
||||
else lightyear.notify(res.msg, 'danger', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
|
||||
});
|
||||
|
|
@ -200,6 +200,31 @@
|
|||
$('#pic-image').hide().next('li').show();
|
||||
$('#cover_path').val('');
|
||||
})
|
||||
|
||||
// 切换类型选择事件
|
||||
$("body").on("change", "#type", function(){
|
||||
let type = parseInt($(this).val());
|
||||
switch(type){
|
||||
case 1:
|
||||
//普通
|
||||
$('#page-link-str').hide().children('input').val();
|
||||
$('#page-content').hide().children('textarea').val();
|
||||
break;
|
||||
case 2:
|
||||
$('#page-content').show();
|
||||
$('#page-link-str').hide().children('input').val();
|
||||
break;
|
||||
case 3:
|
||||
//单页
|
||||
//外联
|
||||
$('#page-link-str').show();
|
||||
$('#page-content').hide().children('textarea').val();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -45,10 +45,14 @@
|
|||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label>排序</label>
|
||||
<input type="text" class="form-control" name="sort" placeholder="请输入排序" value="{$info.sort}">
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label>属性</label>
|
||||
<div class="form-controls">
|
||||
<select name="type" class="form-control">
|
||||
<select name="type" id="type" class="form-control">
|
||||
<option value="0" {if 0== $info.type}selected{/if}>请选择</option>
|
||||
<option value="1" {if 1== $info.type}selected{/if}>列表</option>
|
||||
<option value="2" {if 2== $info.type}selected{/if}>单页</option>
|
||||
|
|
@ -56,16 +60,12 @@
|
|||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label>排序</label>
|
||||
<input type="text" class="form-control" name="sort" placeholder="请输入排序" value="{$info.sort}">
|
||||
<div class="form-group col-md-12" id="page-link-str" {if 3!= $info.type}style="display:none;"{/if}>
|
||||
<label>外链</label>
|
||||
<input type="text" class="form-control" name="link_str" placeholder="外链" value="{$info.link_str}">
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label for="link_str">外链</label>
|
||||
<input type="text" class="form-control" name="link_str" id="link_str" placeholder="外链" value="{$info.link_str}">
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label for="content">单页内容</label>
|
||||
<div class="form-group col-md-12" id="page-content" {if 2!= $info.type}style="display:none;"{/if}>
|
||||
<label>单页内容</label>
|
||||
<textarea id="content" name="content">{$info.content}</textarea>
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
|
|
@ -188,7 +188,7 @@
|
|||
if (!checkResult) {
|
||||
return false;
|
||||
}
|
||||
$.post(url="/admin/article/save",$('.add-form').serialize(),function (res) {
|
||||
$.post(url="/admin/category/save",$('.add-form').serialize(),function (res) {
|
||||
if (res.code == 200) {lightyear.notify(res.msg, 'success', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');setTimeout(function () {location.href='/admin/article/index';},2000)}
|
||||
else lightyear.notify(res.msg, 'danger', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
|
||||
});
|
||||
|
|
@ -200,6 +200,31 @@
|
|||
$('#pic-image').hide().next('li').show();
|
||||
$('#cover_path').val('');
|
||||
})
|
||||
|
||||
// 切换类型选择事件
|
||||
$("body").on("change", "#type", function(){
|
||||
let type = parseInt($(this).val());
|
||||
switch(type){
|
||||
case 1:
|
||||
//普通
|
||||
$('#page-link-str').hide().children('input').val();
|
||||
$('#page-content').hide().children('textarea').val();
|
||||
break;
|
||||
case 2:
|
||||
$('#page-content').show();
|
||||
$('#page-link-str').hide().children('input').val();
|
||||
break;
|
||||
case 3:
|
||||
//单页
|
||||
//外联
|
||||
$('#page-link-str').show();
|
||||
$('#page-content').hide().children('textarea').val();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in New Issue