mirror of https://github.com/1099438829/apeblog
修正幻灯片管理和友链编辑
This commit is contained in:
parent
3471a2bfa8
commit
8765f122b6
|
|
@ -51,7 +51,7 @@ class FriendLink extends AuthController
|
|||
}
|
||||
|
||||
/**
|
||||
* 添加账号
|
||||
* 添加友链
|
||||
* @param Request $request
|
||||
* @return string
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
|
|
@ -71,7 +71,7 @@ class FriendLink extends AuthController
|
|||
}
|
||||
|
||||
/**
|
||||
* 修改账号
|
||||
* 修改友链
|
||||
* @return string
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
|
|
@ -83,7 +83,7 @@ class FriendLink extends AuthController
|
|||
$form = array();
|
||||
$form[] = Elm::input('title','链接名称',$ainfo['title'])->col(10);
|
||||
$form[] = Elm::input('url','链接地址',$ainfo['url'])->col(10);
|
||||
$form[] = Elm::frameImage('image','网站图标',Url::buildUrl('admin/images/index',array('fodder'=>'image','limit'=>1)),$ainfo['avatar'])->icon("ios-image")->width('96%')->height('440px')->col(10);
|
||||
$form[] = Elm::frameImage('image','网站图标',Url::buildUrl('admin/images/index',array('fodder'=>'image','limit'=>1)),$ainfo['image'])->icon("ios-image")->width('96%')->height('440px')->col(10);
|
||||
$form[] = Elm::input('sort','排序',$ainfo['sort'])->col(10);
|
||||
$form[] = Elm::textarea('description','描述',$ainfo['description'])->col(10);
|
||||
$form[] = Elm::radio('status','状态',$ainfo['status'])->options([['label'=>'启用','value'=>1],['label'=>'冻结','value'=>0]])->col(10);
|
||||
|
|
@ -117,8 +117,10 @@ class FriendLink extends AuthController
|
|||
if ($info){
|
||||
return app("json")->fail("链接已存在");
|
||||
}
|
||||
$data['uid'] = $this->adminId;
|
||||
$res = aModel::create($data);
|
||||
}else {
|
||||
$data['uid'] = $this->adminId;
|
||||
$res = aModel::update($data,['id'=>$id]);
|
||||
}
|
||||
return $res ? app("json")->success("操作成功",'code') : app("json")->fail("操作失败");
|
||||
|
|
|
|||
|
|
@ -3,8 +3,11 @@
|
|||
namespace app\admin\controller;
|
||||
|
||||
use app\admin\model\Slides as aModel;
|
||||
use app\admin\services\FormBuilderService as Form;
|
||||
use app\Request;
|
||||
use app\admin\services\UtilService as Util;
|
||||
use FormBuilder\Factory\Elm;
|
||||
use think\facade\Route as Url;
|
||||
|
||||
/**
|
||||
* Class Slides
|
||||
|
|
@ -48,4 +51,75 @@ class Slides extends AuthController
|
|||
]);
|
||||
return app("json")->layui(aModel::systemPage($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加账号
|
||||
* @param Request $request
|
||||
* @return string
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function add(Request $request)
|
||||
{
|
||||
$form = array();
|
||||
$form[] = Elm::input('title','幻灯片名称')->col(10);
|
||||
$form[] = Elm::input('url','链接地址')->col(10);
|
||||
$form[] = Elm::frameImage('image','幻灯片图片',Url::buildUrl('admin/images/index',array('fodder'=>'image','limit'=>1)))->icon("ios-image")->width('96%')->height('440px')->col(10);
|
||||
$form[] = Elm::input('sort','排序')->col(10);
|
||||
$form[] = Elm::radio('status','状态',1)->options([['label'=>'启用','value'=>1],['label'=>'冻结','value'=>0]])->col(10);
|
||||
$form = Form::make_post_form($form, url('save')->build());
|
||||
$this->assign(compact('form'));
|
||||
return $this->fetch("public/form-builder");
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改账号
|
||||
* @return string
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function edit($id="")
|
||||
{
|
||||
if (!$id) return app("json")->fail("数据id不能为空");
|
||||
$ainfo = aModel::get($id);
|
||||
if (!$ainfo) return app("json")->fail("没有该数据");
|
||||
$form = array();
|
||||
$form[] = Elm::input('title','幻灯片名称',$ainfo['title'])->col(10);
|
||||
$form[] = Elm::input('url','链接地址',$ainfo['url'])->col(10);
|
||||
$form[] = Elm::frameImage('image','幻灯片图片',Url::buildUrl('admin/images/index',array('fodder'=>'image','limit'=>1)),$ainfo['image'])->icon("ios-image")->width('96%')->height('440px')->col(10);
|
||||
$form[] = Elm::input('sort','排序',$ainfo['sort'])->col(10);
|
||||
$form[] = Elm::radio('status','状态',$ainfo['status'])->options([['label'=>'启用','value'=>1],['label'=>'冻结','value'=>0]])->col(10);
|
||||
$form = Form::make_post_form($form, url('save',['id'=>$id])->build());
|
||||
$this->assign(compact('form'));
|
||||
return $this->fetch("public/form-builder");
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存修改
|
||||
* @param string $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function save($id="")
|
||||
{
|
||||
$data = Util::postMore([
|
||||
['id',''],
|
||||
['title',''],
|
||||
['url',''],
|
||||
['image',''],
|
||||
['sort',''],
|
||||
['status',1],
|
||||
]);
|
||||
if ($data['title'] == "") return app("json")->fail("幻灯片名称不能为空");
|
||||
if ($data['url'] == "") return app("json")->fail("链接地址不能为空");
|
||||
if (is_array($data['image'])) $data['image'] = $data['avatar'][0];
|
||||
if ($id=="") {
|
||||
//判断下用户是否存在
|
||||
$info = aModel::where('url',$data['url'])->find();
|
||||
if ($info){
|
||||
return app("json")->fail("链接已存在");
|
||||
}
|
||||
$res = aModel::create($data);
|
||||
}else {
|
||||
$res = aModel::update($data,['id'=>$id]);
|
||||
}
|
||||
return $res ? app("json")->success("操作成功",'code') : app("json")->fail("操作失败");
|
||||
}
|
||||
}
|
||||
|
|
@ -153,10 +153,10 @@
|
|||
title: '操作',
|
||||
formatter: btnGroup, // 自定义方法
|
||||
events: {
|
||||
'click .edit-btn': function (event, value, row, index) {
|
||||
'click .btn-edit': function (event, value, row, index) {
|
||||
iframe.createIframe('修改用户','/admin/admin/edit?id='+row.id)
|
||||
},
|
||||
'click .del-btn': function (event, value, row, index) {
|
||||
'click .btn-del': function (event, value, row, index) {
|
||||
$.alert({
|
||||
title: '系统提示',
|
||||
content: '删除提醒',
|
||||
|
|
@ -213,8 +213,8 @@
|
|||
function btnGroup ()
|
||||
{
|
||||
let html =
|
||||
'<a href="#!" class="btn btn-xs btn-default m-r-5 edit-btn" title="编辑" data-toggle="tooltip"><i class="mdi mdi-pencil"></i></a>' +
|
||||
'<a href="#!" class="btn btn-xs btn-default del-btn" title="删除" data-toggle="tooltip"><i class="mdi mdi-window-close"></i></a>';
|
||||
'<a href="#!" class="btn btn-xs btn-default m-r-5 btn-edit" title="编辑" data-toggle="tooltip"><i class="mdi mdi-pencil"></i></a>' +
|
||||
'<a href="#!" class="btn btn-xs btn-default btn-del" title="删除" data-toggle="tooltip"><i class="mdi mdi-window-close"></i></a>';
|
||||
return html;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
<div class="card">
|
||||
<div class="card-toolbar clearfix">
|
||||
<div id="toolbar" class="toolbar-btn-action">
|
||||
<button id="btn_add" type="button" class="btn btn-primary m-r-5" onclick="iframe.createIframe('添加用户','/admin/admin/add')">
|
||||
<button id="btn_add" type="button" class="btn btn-primary m-r-5" onclick="iframe.createIframe('添加幻灯片','/admin/slides/add')">
|
||||
<span class="mdi mdi-plus" aria-hidden="true"></span>新增
|
||||
</button>
|
||||
<a class="btn btn-warning" href="#!" onclick="delSelect()"><i class="mdi mdi-window-close"></i> 删除</a>
|
||||
|
|
@ -89,7 +89,7 @@
|
|||
title: '幻灯片名称'
|
||||
},
|
||||
{
|
||||
field: 'pic',
|
||||
field: 'image',
|
||||
title: '幻灯片图片',
|
||||
formatter:function (value,row,index) {
|
||||
let html ='<img src="'+value+'" alt="" width="50px;">';
|
||||
|
|
@ -98,14 +98,40 @@
|
|||
},
|
||||
{
|
||||
field: 'url',
|
||||
title: '幻灯片链接地址',
|
||||
title: '链接地址',
|
||||
}, {
|
||||
field: 'create_time',
|
||||
title: '添加时间',
|
||||
}, {
|
||||
field: 'operate',
|
||||
title: '操作',
|
||||
formatter:operateFormatter
|
||||
formatter:operateFormatter,
|
||||
events: {
|
||||
'click .btn-edit': function (event, value, row, index) {
|
||||
iframe.createIframe('修改幻灯片','/admin/slides/edit?id='+row.id)
|
||||
},
|
||||
'click .btn-del': function (event, value, row, index) {
|
||||
$.alert({
|
||||
title: '系统提示',
|
||||
content: '删除提醒',
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: '确认',
|
||||
btnClass: 'btn-primary',
|
||||
action: function(){
|
||||
$.post(url="/admin/slides/del",data={"id":row.id},function (res) {
|
||||
if (res.status == 200) {parent.lightyear.notify('删除成功', 'success', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');$("#tb_departments").bootstrapTable('refresh');}
|
||||
else parent.lightyear.notify('删除失败', 'danger', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
|
||||
});
|
||||
}
|
||||
},
|
||||
cancel: {
|
||||
text: '取消'
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}],
|
||||
onLoadSuccess: function(data){
|
||||
$("[data-toggle='tooltip']").tooltip();
|
||||
|
|
@ -126,9 +152,8 @@
|
|||
// 操作按钮
|
||||
function operateFormatter(value, row, index) {
|
||||
return [
|
||||
'<a type="button" class="role-add btn btn-xs btn-default m-r-5" title="编辑" data-toggle="tooltip"><i class="mdi mdi-plus"></i></a>',
|
||||
'<a type="button" class="role-edit btn btn-xs btn-default m-r-5" title="修改" data-toggle="tooltip"><i class="mdi mdi-pencil"></i></a>',
|
||||
'<a type="button" class="role-delete btn btn-xs btn-default" title="删除" data-toggle="tooltip"><i class="mdi mdi-delete"></i></a>'
|
||||
'<a type="button" class="btn-edit btn btn-xs btn-default m-r-5" title="修改" data-toggle="tooltip"><i class="mdi mdi-pencil"></i></a>',
|
||||
'<a type="button" class="btn-del btn btn-xs btn-default" title="删除" data-toggle="tooltip"><i class="mdi mdi-delete"></i></a>'
|
||||
].join('');
|
||||
}
|
||||
|
||||
|
|
@ -142,31 +167,7 @@
|
|||
text: '确认',
|
||||
btnClass: 'btn-danger',
|
||||
action: function () {
|
||||
$.post("/admin/admin_log/del",data={id:id},function (res) {
|
||||
if (res.status == 200 || res.code == 200) lightyear.notify(res.msg, 'success', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
|
||||
else lightyear.notify(res.msg, 'danger', 3000, 'mdi mdi-emoticon-neutral', 'top', 'center');
|
||||
location.reload();
|
||||
})
|
||||
}
|
||||
},
|
||||
cancel: {
|
||||
text: '取消',
|
||||
btnClass: 'btn-primary'
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
function delAll() {
|
||||
$.confirm({
|
||||
title: '重要提醒!',
|
||||
content: '清空后将不可恢复,请谨慎操作!',
|
||||
backgroundDismiss: true,
|
||||
buttons: {
|
||||
ok: {
|
||||
text: '确认',
|
||||
btnClass: 'btn-danger',
|
||||
action: function () {
|
||||
$.post("/admin/admin_log/empty",data={},function (res) {
|
||||
$.post("/admin/slides/del",data={id:id},function (res) {
|
||||
if (res.status == 200 || res.code == 200) lightyear.notify(res.msg, 'success', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
|
||||
else lightyear.notify(res.msg, 'danger', 3000, 'mdi mdi-emoticon-neutral', 'top', 'center');
|
||||
location.reload();
|
||||
|
|
@ -199,7 +200,7 @@
|
|||
text: '确认',
|
||||
btnClass: 'btn-danger',
|
||||
action: function () {
|
||||
$.post("/admin/admin_log/del",data={id:checkID},function (res) {
|
||||
$.post("/admin/slides/del",data={id:checkID},function (res) {
|
||||
if (res.status == 200 || res.code == 200) { lightyear.notify(res.msg, 'success', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');location.reload();}
|
||||
else lightyear.notify(res.msg, 'danger', 3000, 'mdi mdi-emoticon-neutral', 'top', 'center');
|
||||
})
|
||||
|
|
|
|||
|
|
@ -118,10 +118,10 @@
|
|||
title: '操作',
|
||||
formatter: btnGroup, // 自定义方法
|
||||
events: {
|
||||
'click .edit-btn': function (event, value, row, index) {
|
||||
'click .btn-edit': function (event, value, row, index) {
|
||||
iframe.createIframe('{$tab.name}-修改字段','/admin/system_config/edit?id='+row.id)
|
||||
},
|
||||
'click .del-btn': function (event, value, row, index) {
|
||||
'click .btn-del': function (event, value, row, index) {
|
||||
$.alert({
|
||||
title: '系统提示',
|
||||
content: '删除提醒',
|
||||
|
|
@ -150,8 +150,8 @@
|
|||
function btnGroup ()
|
||||
{
|
||||
let html =
|
||||
'<a href="#!" class="btn btn-xs btn-default m-r-5 edit-btn" title="编辑" data-toggle="tooltip"><i class="mdi mdi-pencil"></i></a>' +
|
||||
'<a href="#!" class="btn btn-xs btn-default m-r-5 del-btn" title="删除" data-toggle="tooltip"><i class="mdi mdi-window-close"></i></a>';
|
||||
'<a href="#!" class="btn btn-xs btn-default m-r-5 btn-edit" title="编辑" data-toggle="tooltip"><i class="mdi mdi-pencil"></i></a>' +
|
||||
'<a href="#!" class="btn btn-xs btn-default m-r-5 btn-del" title="删除" data-toggle="tooltip"><i class="mdi mdi-window-close"></i></a>';
|
||||
return html;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -114,13 +114,13 @@
|
|||
title: '操作',
|
||||
formatter: btnGroup, // 自定义方法
|
||||
events: {
|
||||
'click .edit-btn': function (event, value, row, index) {
|
||||
'click .btn-edit': function (event, value, row, index) {
|
||||
iframe.createIframe('修改配置','/admin/system_config_tab/edit?id='+row.id)
|
||||
},
|
||||
'click .add-btn': function (event, value, row, index) {
|
||||
window.location.href = "/admin/system_config/index?tab_id="+row.id;
|
||||
},
|
||||
'click .del-btn': function (event, value, row, index) {
|
||||
'click .btn-del': function (event, value, row, index) {
|
||||
$.alert({
|
||||
title: '系统提示',
|
||||
content: '删除提醒',
|
||||
|
|
@ -152,8 +152,8 @@
|
|||
function btnGroup ()
|
||||
{
|
||||
let html =
|
||||
'<a href="#!" class="btn btn-xs btn-default m-r-5 edit-btn" title="编辑" data-toggle="tooltip"><i class="mdi mdi-pencil"></i></a>' +
|
||||
'<a href="#!" class="btn btn-xs btn-default m-r-5 del-btn" title="删除" data-toggle="tooltip"><i class="mdi mdi-window-close"></i></a>' +
|
||||
'<a href="#!" class="btn btn-xs btn-default m-r-5 btn-edit" title="编辑" data-toggle="tooltip"><i class="mdi mdi-pencil"></i></a>' +
|
||||
'<a href="#!" class="btn btn-xs btn-default m-r-5 btn-del" title="删除" data-toggle="tooltip"><i class="mdi mdi-window-close"></i></a>' +
|
||||
'<a href="#!" class="btn btn-xs btn-default add-btn" title="添加" data-toggle="tooltip"><i class="mdi mdi-plus"></i></a>';
|
||||
return html;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -147,10 +147,10 @@
|
|||
title: '操作',
|
||||
formatter: btnGroup, // 自定义方法
|
||||
events: {
|
||||
'click .edit-btn': function (event, value, row, index) {
|
||||
'click .btn-edit': function (event, value, row, index) {
|
||||
iframe.createIframe('修改用户','/admin/user/edit?id='+row.id)
|
||||
},
|
||||
'click .del-btn': function (event, value, row, index) {
|
||||
'click .btn-del': function (event, value, row, index) {
|
||||
$.alert({
|
||||
title: '系统提示',
|
||||
content: '删除提醒',
|
||||
|
|
@ -207,8 +207,8 @@
|
|||
function btnGroup ()
|
||||
{
|
||||
let html =
|
||||
'<a href="#!" class="btn btn-xs btn-default m-r-5 edit-btn" title="编辑" data-toggle="tooltip"><i class="mdi mdi-pencil"></i></a>' +
|
||||
'<a href="#!" class="btn btn-xs btn-default del-btn" title="删除" data-toggle="tooltip"><i class="mdi mdi-window-close"></i></a>';
|
||||
'<a href="#!" class="btn btn-xs btn-default m-r-5 btn-edit" title="编辑" data-toggle="tooltip"><i class="mdi mdi-pencil"></i></a>' +
|
||||
'<a href="#!" class="btn btn-xs btn-default btn-del" title="删除" data-toggle="tooltip"><i class="mdi mdi-window-close"></i></a>';
|
||||
return html;
|
||||
}
|
||||
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue