mirror of https://github.com/1099438829/apeblog
This commit is contained in:
parent
6c5358f26d
commit
a767713971
|
|
@ -4,6 +4,7 @@ namespace app\admin\controller;
|
|||
|
||||
use app\admin\model\Document as aModel;
|
||||
use app\admin\model\DocumentCategory as cModel;
|
||||
use app\admin\model\DocumentArticle;
|
||||
use app\Request;
|
||||
use app\admin\services\UtilService as Util;
|
||||
|
||||
|
|
@ -65,6 +66,7 @@ class Article extends AuthController
|
|||
['type','article'],
|
||||
['abstract',''],
|
||||
['keywords',''],
|
||||
['content',''],
|
||||
['description',''],
|
||||
['is_recommend',0],
|
||||
['is_top',0],
|
||||
|
|
@ -81,15 +83,30 @@ class Article extends AuthController
|
|||
if ($data['cover_path'] == "") return app("json")->fail("主图不能为空");
|
||||
$data['writer'] = $data['writer']?:$this->adminInfo['nickname'];
|
||||
$data['uid'] = $this->adminId;
|
||||
if (!empty($data['content'])){
|
||||
$content = $data['content'];
|
||||
unset($data['content']);
|
||||
}
|
||||
if ($id=="")
|
||||
{
|
||||
$data['writer'] = $data['writer']?:$this->adminInfo['nickname'];
|
||||
$res = aModel::save($data);
|
||||
$id = aModel::insertGetId($data);
|
||||
if (!empty($content)){
|
||||
$updateData = [
|
||||
'id' => $id,
|
||||
'content' => $content
|
||||
];
|
||||
$res = DocumentArticle::save($updateData);
|
||||
}
|
||||
}else
|
||||
{
|
||||
$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]);
|
||||
}
|
||||
}
|
||||
return $res ? app("json")->success("操作成功",'code') : app("json")->fail("操作失败");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -196,20 +196,26 @@
|
|||
processData: false,
|
||||
contentType: false,
|
||||
success: function (res) {
|
||||
$("#"+inputName).val(res.data.filePath);
|
||||
let html =' <figure>\n' +
|
||||
' <img src="'+res.data.filePath+'" alt="'+res.data.name+'">\n' +
|
||||
' <figcaption>\n' +
|
||||
' <a class="btn btn-round btn-square btn-danger btn-image-delete" href="#!"><i class="mdi mdi-delete"></i></a>\n' +
|
||||
' </figcaption>\n' +
|
||||
' </figure>';
|
||||
$('#pic-image').html(html);
|
||||
$('#pic-image').show().next('li').hide();
|
||||
if (res.code == 200){
|
||||
$("#"+inputName).val(res.data.filePath);
|
||||
let html =' <figure>\n' +
|
||||
' <img src="'+res.data.filePath+'" alt="'+res.data.name+'">\n' +
|
||||
' <figcaption>\n' +
|
||||
' <a class="btn btn-round btn-square btn-danger btn-image-delete" href="#!"><i class="mdi mdi-delete"></i></a>\n' +
|
||||
' </figcaption>\n' +
|
||||
' </figure>';
|
||||
$('#pic-image').html(html);
|
||||
$('#pic-image').show().next('li').hide();
|
||||
}else{
|
||||
lightyear.notify(res.msg, 'danger', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
$(".add-form").submit(function () {
|
||||
let Arr = $('.add-form').serializeArray();
|
||||
let checkResult = true;
|
||||
$.each(Arr,function (index,item) {
|
||||
try {
|
||||
switch (item.name) {
|
||||
|
|
@ -239,7 +245,7 @@
|
|||
if (!checkResult) {
|
||||
return false;
|
||||
}
|
||||
$.post(url="/admin/cms.cms_article/save",$('.add-form').serialize(),function (res) {
|
||||
$.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)}
|
||||
else lightyear.notify(res.msg, 'danger', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@
|
|||
<div class="col-xs-6">显示</div>
|
||||
<div class="col-xs-6">
|
||||
<label class="lyear-switch switch-solid switch-primary">
|
||||
<input type="checkbox" name="display" checked="">
|
||||
<input type="checkbox" name="display" {if $info.is_top = 1}checked{/if}>
|
||||
<span></span>
|
||||
</label>
|
||||
</div>
|
||||
|
|
@ -196,20 +196,26 @@
|
|||
processData: false,
|
||||
contentType: false,
|
||||
success: function (res) {
|
||||
$("#"+inputName).val(res.data.filePath);
|
||||
let html =' <figure>\n' +
|
||||
' <img src="'+res.data.filePath+'" alt="'+res.data.name+'">\n' +
|
||||
' <figcaption>\n' +
|
||||
' <a class="btn btn-round btn-square btn-danger btn-image-delete" href="#!"><i class="mdi mdi-delete"></i></a>\n' +
|
||||
' </figcaption>\n' +
|
||||
' </figure>';
|
||||
$('#pic-image').html(html);
|
||||
$('#pic-image').show().next('li').hide();
|
||||
if (res.code == 200){
|
||||
$("#"+inputName).val(res.data.filePath);
|
||||
let html =' <figure>\n' +
|
||||
' <img src="'+res.data.filePath+'" alt="'+res.data.name+'">\n' +
|
||||
' <figcaption>\n' +
|
||||
' <a class="btn btn-round btn-square btn-danger btn-image-delete" href="#!"><i class="mdi mdi-delete"></i></a>\n' +
|
||||
' </figcaption>\n' +
|
||||
' </figure>';
|
||||
$('#pic-image').html(html);
|
||||
$('#pic-image').show().next('li').hide();
|
||||
}else{
|
||||
lightyear.notify(res.msg, 'danger', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
$(".add-form").submit(function () {
|
||||
let Arr = $('.add-form').serializeArray();
|
||||
let checkResult = true;
|
||||
$.each(Arr,function (index,item) {
|
||||
try {
|
||||
switch (item.name) {
|
||||
|
|
@ -239,7 +245,7 @@
|
|||
if (!checkResult) {
|
||||
return false;
|
||||
}
|
||||
$.post(url="/admin/cms.cms_article/save",$('.add-form').serialize(),function (res) {
|
||||
$.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)}
|
||||
else lightyear.notify(res.msg, 'danger', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue