修正编辑

This commit is contained in:
1099438829 2021-03-07 19:28:37 +08:00
parent 35abf36006
commit 212edac63a
3 changed files with 26 additions and 10 deletions

View File

@ -86,8 +86,8 @@ class Article extends AuthController
$data['uid'] = $this->adminId;
if (!empty($data['content'])){
$content = $data['content'];
unset($data['content']);
}
unset($data['content']);
if ($data['is_recommend']) $data['is_recommend'] = 1;
if ($data['is_hot']) $data['is_hot'] = 1;
if ($data['display']) $data['display'] = 1;
@ -110,6 +110,7 @@ class Article extends AuthController
$ainfo = aModel::get($id);
if (!$ainfo)return app("json")->fail("数据不存在");
$res = aModel::where('id',$id)->save($data);
if (!empty($content)){
//更新文档
$res = DocumentArticle::where('id',$id)->save(['content'=>$content]);
@ -166,9 +167,10 @@ class Article extends AuthController
];
$category = cModel::systemPage($where);
$category = get_tree_list($category);
$info = aModel::get($request->param(['id']));
$info->content = DocumentArticle::get($request->param(['id']))->content;
$this->assign("category",$category);
$this->assign("info",aModel::get($request->param(['id'])));
$this->assign("info",$info);
return $this->fetch();
}
}

View File

@ -246,7 +246,7 @@
return false;
}
$.post(url="/admin/article/save",$('.add-form').serialize(),function (res) {
if (res.code == 200) {lightyear.notify(res.msg, 'success', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');setTimeout(function () {parent.location.reload()},2000)}
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');
});
return true;

View File

@ -28,6 +28,7 @@
<form action="#!" method="post" class="row add-form" onsubmit="return false;">
<div class="form-group col-md-12">
<label>文章名称</label>
<input type="hidden" name="id" value="{$info.id}">
<input type="text" class="form-control" id="title" name="title" placeholder="文章名称" value="{$info.title}" />
</div>
<div class="form-group col-md-12">
@ -49,13 +50,26 @@
<label>主图</label>
<div class="form-controls">
<ul class="list-inline clearfix lyear-uploads-pic">
<li class="col-xs-4 col-sm-3 col-md-2" id="pic-image" style="display: none;">
</li>
<li class="col-xs-4 col-sm-3 col-md-2" id="pic-upload">
<input type="hidden" class="form-control" name="cover_path" id="cover_path" value="" />
<input type="file" id="file_cover_path" style="display: none;" onchange="upload('cover_path')"/>
{notempty name="info.cover_path"}
<li class="col-xs-4 col-sm-3 col-md-2" id="pic-image" style="display: block;"> <figure>
<img src="{$info.cover_path}" alt="{$info.cover_path|basename}">
<figcaption>
<a class="btn btn-round btn-square btn-danger btn-image-delete" href="#!"><i class="mdi mdi-delete"></i></a>
</figcaption>
</figure></li>
<li class="col-xs-4 col-sm-3 col-md-2" id="pic-upload" style="display: none;">
<input type="hidden" class="form-control" name="cover_path" id="cover_path" value="{$info.cover_path}">
<input type="file" id="file_cover_path" style="display: none;" onchange="upload('cover_path')">
<a class="pic-add" href="#!" onclick="btnClick('cover_path')" title="上传"></a>
</li>
{else /}
<li class="col-xs-4 col-sm-3 col-md-2" id="pic-image" style="display: none;"></li>
<li class="col-xs-4 col-sm-3 col-md-2" id="pic-upload">
<input type="hidden" class="form-control" name="cover_path" id="cover_path">
<input type="file" id="file_cover_path" style="display: none;" onchange="upload('cover_path')">
<a class="pic-add" href="#!" onclick="btnClick('cover_path')" title="上传"></a>
</li>
{/notempty}
</ul>
</div>
</div>
@ -246,7 +260,7 @@
return false;
}
$.post(url="/admin/article/save",$('.add-form').serialize(),function (res) {
if (res.code == 200) {lightyear.notify(res.msg, 'success', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');setTimeout(function () {parent.location.reload()},2000)}
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');
});
return true;