优化知识模块
This commit is contained in:
parent
56ad54fb6f
commit
a7b65c0d5f
@ -4,7 +4,7 @@
|
|||||||
* @license https://opensource.org/licenses/GPL-2.0
|
* @license https://opensource.org/licenses/GPL-2.0
|
||||||
* @link https://www.gougucms.com
|
* @link https://www.gougucms.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare (strict_types = 1);
|
declare (strict_types = 1);
|
||||||
|
|
||||||
namespace app\home\controller;
|
namespace app\home\controller;
|
||||||
@ -12,7 +12,6 @@ namespace app\home\controller;
|
|||||||
use app\home\BaseController;
|
use app\home\BaseController;
|
||||||
use app\home\model\Article as ArticleList;
|
use app\home\model\Article as ArticleList;
|
||||||
use app\home\model\ArticleCate;
|
use app\home\model\ArticleCate;
|
||||||
use app\home\model\Keywords;
|
|
||||||
use app\home\validate\ArticleCateCheck;
|
use app\home\validate\ArticleCateCheck;
|
||||||
use app\home\validate\ArticleCheck;
|
use app\home\validate\ArticleCheck;
|
||||||
use think\exception\ValidateException;
|
use think\exception\ValidateException;
|
||||||
@ -26,35 +25,28 @@ class Article extends BaseController
|
|||||||
if (request()->isAjax()) {
|
if (request()->isAjax()) {
|
||||||
$cate = Db::name('ArticleCate')->order('create_time asc')->select();
|
$cate = Db::name('ArticleCate')->order('create_time asc')->select();
|
||||||
return to_assign(0, '', $cate);
|
return to_assign(0, '', $cate);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
return view();
|
return view();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//文章分类添加
|
//文章分类添加&编辑
|
||||||
public function cate_add()
|
public function cate_add()
|
||||||
{
|
{
|
||||||
return view('', ['pid' => get_params('pid')]);
|
$param = get_params();
|
||||||
}
|
|
||||||
|
|
||||||
//提交保存文章分类
|
|
||||||
public function cate_post_submit()
|
|
||||||
{
|
|
||||||
if (request()->isAjax()) {
|
if (request()->isAjax()) {
|
||||||
$param = get_params();
|
|
||||||
if (!empty($param['id']) && $param['id'] > 0) {
|
if (!empty($param['id']) && $param['id'] > 0) {
|
||||||
$data[$param['field']] = $param['value'];
|
$data[$param['field']] = $param['value'];
|
||||||
$data['id'] = $param['id'];
|
$data['id'] = $param['id'];
|
||||||
$data['update_time'] = time();
|
$data['update_time'] = time();
|
||||||
if(!empty($data['title'])){
|
if (!empty($data['title'])) {
|
||||||
try {
|
try {
|
||||||
validate(ArticleCateCheck::class)->scene('edit')->check($data);
|
validate(ArticleCateCheck::class)->scene('edit')->check($data);
|
||||||
} catch (ValidateException $e) {
|
} catch (ValidateException $e) {
|
||||||
// 验证失败 输出错误信息
|
// 验证失败 输出错误信息
|
||||||
return to_assign(1, $e->getError());
|
return to_assign(1, $e->getError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$res = ArticleCate::strict(false)->field(true)->update($data);
|
$res = ArticleCate::strict(false)->field(true)->update($data);
|
||||||
if ($res) {
|
if ($res) {
|
||||||
add_log('edit', $data['id'], $data);
|
add_log('edit', $data['id'], $data);
|
||||||
@ -75,9 +67,14 @@ class Article extends BaseController
|
|||||||
return to_assign();
|
return to_assign();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
$pid = isset($param['pid']) ? $param['pid'] : 0;
|
||||||
|
View::assign('pid', $pid);
|
||||||
|
return view();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//删除文章分配
|
//删除文章分类
|
||||||
public function cate_delete()
|
public function cate_delete()
|
||||||
{
|
{
|
||||||
$id = get_params("id");
|
$id = get_params("id");
|
||||||
@ -117,31 +114,17 @@ class Article extends BaseController
|
|||||||
->order('a.create_time desc')
|
->order('a.create_time desc')
|
||||||
->paginate($rows, false, ['query' => $param]);
|
->paginate($rows, false, ['query' => $param]);
|
||||||
return table_assign(0, '', $content);
|
return table_assign(0, '', $content);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
return view();
|
return view();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//文章添加&&编辑
|
//文章添加&&编辑
|
||||||
public function add()
|
public function add()
|
||||||
{
|
{
|
||||||
$id = empty(get_params('id')) ? 0 : get_params('id');
|
$param = get_params();
|
||||||
View::assign('id', $id);
|
|
||||||
if ($id > 0) {
|
|
||||||
$article = (new ArticleList())->detail($id);
|
|
||||||
View::assign('article', $article);
|
|
||||||
return view('edit');
|
|
||||||
}
|
|
||||||
return view();
|
|
||||||
}
|
|
||||||
|
|
||||||
//文章内容提交保存
|
|
||||||
public function post_submit()
|
|
||||||
{
|
|
||||||
if (request()->isAjax()) {
|
if (request()->isAjax()) {
|
||||||
$param = get_params();
|
$DbRes = false;
|
||||||
$DbRes=false;
|
|
||||||
if (!empty($param['id']) && $param['id'] > 0) {
|
if (!empty($param['id']) && $param['id'] > 0) {
|
||||||
try {
|
try {
|
||||||
validate(ArticleCheck::class)->scene('edit')->check($param);
|
validate(ArticleCheck::class)->scene('edit')->check($param);
|
||||||
@ -149,32 +132,30 @@ class Article extends BaseController
|
|||||||
// 验证失败 输出错误信息
|
// 验证失败 输出错误信息
|
||||||
return to_assign(1, $e->getError());
|
return to_assign(1, $e->getError());
|
||||||
}
|
}
|
||||||
$param['update_time'] = time();
|
$param['update_time'] = time();
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
$res = ArticleList::strict(false)->field(true)->update($param);
|
$res = ArticleList::strict(false)->field(true)->update($param);
|
||||||
$aid = $param['id'];
|
$aid = $param['id'];
|
||||||
if ($res) {
|
if ($res) {
|
||||||
//关联关键字
|
//关联关键字
|
||||||
if (isset($param['keyword_names']) && $param['keyword_names']) {
|
if (isset($param['keyword_names']) && $param['keyword_names']) {
|
||||||
Db::name('ArticleKeywords')->where(['aid'=>$aid])->delete();
|
Db::name('ArticleKeywords')->where(['aid' => $aid])->delete();
|
||||||
$keywordArray = explode(',', $param['keyword_names']);
|
$keywordArray = explode(',', $param['keyword_names']);
|
||||||
$res_keyword = (new ArticleList())->insertKeyword($keywordArray,$aid);
|
$res_keyword = (new ArticleList())->insertKeyword($keywordArray, $aid);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$res_keyword == true;
|
$res_keyword == true;
|
||||||
}
|
}
|
||||||
if($res_keyword!== false){
|
if ($res_keyword !== false) {
|
||||||
add_log('edit', $param['id'], $param);
|
add_log('edit', $param['id'], $param);
|
||||||
Db::commit();
|
Db::commit();
|
||||||
$DbRes=true;
|
$DbRes = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
}
|
}
|
||||||
}
|
} catch (\Exception $e) { ##这里参数不能删除($e:错误信息)
|
||||||
catch (\Exception $e) { ##这里参数不能删除($e:错误信息)
|
Db::rollback();
|
||||||
Db::rollback();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
@ -186,38 +167,45 @@ class Article extends BaseController
|
|||||||
$param['create_time'] = time();
|
$param['create_time'] = time();
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
if(empty($param['desc'])){
|
if (empty($param['desc'])) {
|
||||||
$param['desc'] = get_desc_content($param['content'], 100);
|
$param['desc'] = get_desc_content($param['content'], 100);
|
||||||
}
|
}
|
||||||
$aid = ArticleList::strict(false)->field(true)->insertGetId($param);
|
$aid = ArticleList::strict(false)->field(true)->insertGetId($param);
|
||||||
if ($aid) {
|
if ($aid) {
|
||||||
//关联关键字
|
//关联关键字
|
||||||
if (isset($param['keyword_names']) && $param['keyword_names']) {
|
if (isset($param['keyword_names']) && $param['keyword_names']) {
|
||||||
$keywordArray = explode(',', $param['keyword_names']);
|
$keywordArray = explode(',', $param['keyword_names']);
|
||||||
$res_keyword = (new ArticleList())->insertKeyword($keywordArray,$aid);
|
$res_keyword = (new ArticleList())->insertKeyword($keywordArray, $aid);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$res_keyword == true;
|
$res_keyword == true;
|
||||||
}
|
}
|
||||||
if($res_keyword!== false){
|
if ($res_keyword !== false) {
|
||||||
add_log('add', $aid, $param);
|
add_log('add', $aid, $param);
|
||||||
Db::commit();
|
Db::commit();
|
||||||
$DbRes=true;
|
$DbRes = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
}
|
}
|
||||||
}
|
} catch (\Exception $e) { ##这里参数不能删除($e:错误信息)
|
||||||
catch (\Exception $e) { ##这里参数不能删除($e:错误信息)
|
Db::rollback();
|
||||||
Db::rollback();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($DbRes){
|
if ($DbRes) {
|
||||||
return to_assign();
|
return to_assign();
|
||||||
}
|
} else {
|
||||||
else{
|
return to_assign(1, '操作失败');
|
||||||
return to_assign(1,'操作失败');
|
}
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
$id = isset($param['id']) ? $param['id'] : 0;
|
||||||
|
View::assign('id', $id);
|
||||||
|
if ($id > 0) {
|
||||||
|
$article = (new ArticleList())->detail($id);
|
||||||
|
View::assign('article', $article);
|
||||||
|
return view('edit');
|
||||||
|
}
|
||||||
|
return view();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,12 +32,6 @@ class Note extends BaseController
|
|||||||
|
|
||||||
//分类添加
|
//分类添加
|
||||||
public function cate_add()
|
public function cate_add()
|
||||||
{
|
|
||||||
return view('', ['pid' => get_params('pid')]);
|
|
||||||
}
|
|
||||||
|
|
||||||
//提交保存分类
|
|
||||||
public function cate_post_submit()
|
|
||||||
{
|
{
|
||||||
if (request()->isAjax()) {
|
if (request()->isAjax()) {
|
||||||
$param = get_params();
|
$param = get_params();
|
||||||
@ -72,6 +66,10 @@ class Note extends BaseController
|
|||||||
}
|
}
|
||||||
return to_assign();
|
return to_assign();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$pid = isset($param['pid']) ? $param['pid'] : 0;
|
||||||
|
View::assign('pid', $pid);
|
||||||
|
return view();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,20 +122,8 @@ class Note extends BaseController
|
|||||||
//添加
|
//添加
|
||||||
public function add()
|
public function add()
|
||||||
{
|
{
|
||||||
$id = empty(get_params('id')) ? 0 : get_params('id');
|
$param = get_params();
|
||||||
if ($id > 0) {
|
|
||||||
$note = Db::name('Note')->where(['id' => $id])->find();
|
|
||||||
View::assign('note', $note);
|
|
||||||
}
|
|
||||||
View::assign('id', $id);
|
|
||||||
return view();
|
|
||||||
}
|
|
||||||
|
|
||||||
//提交添加
|
|
||||||
public function post_submit()
|
|
||||||
{
|
|
||||||
if (request()->isAjax()) {
|
if (request()->isAjax()) {
|
||||||
$param = get_params();
|
|
||||||
$param['start_time'] = isset($param['start_time']) ? strtotime(urldecode($param['start_time'])) : 0;
|
$param['start_time'] = isset($param['start_time']) ? strtotime(urldecode($param['start_time'])) : 0;
|
||||||
$param['end_time'] = isset($param['end_time']) ? strtotime(urldecode($param['end_time'])) : 0;
|
$param['end_time'] = isset($param['end_time']) ? strtotime(urldecode($param['end_time'])) : 0;
|
||||||
if (!empty($param['id']) && $param['id'] > 0) {
|
if (!empty($param['id']) && $param['id'] > 0) {
|
||||||
@ -169,6 +155,14 @@ class Note extends BaseController
|
|||||||
|
|
||||||
return to_assign();
|
return to_assign();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$id = isset($param['id']) ? $param['id'] : 0;
|
||||||
|
if ($id > 0) {
|
||||||
|
$note = Db::name('Note')->where(['id' => $id])->find();
|
||||||
|
View::assign('note', $note);
|
||||||
|
}
|
||||||
|
View::assign('id', $id);
|
||||||
|
return view();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,10 +35,10 @@
|
|||||||
<td>
|
<td>
|
||||||
<input type="text" name="sort" value="0" placeholder="请输入排序,数字" autocomplete="off" class="layui-input">
|
<input type="text" name="sort" value="0" placeholder="请输入排序,数字" autocomplete="off" class="layui-input">
|
||||||
</td>
|
</td>
|
||||||
<td class="layui-td-gray2">首页显示</td>
|
<td class="layui-td-gray2">是否共享</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="radio" name="is_home" value="1" title="是" checked>
|
<input type="radio" name="is_share" value="1" title="是" checked>
|
||||||
<input type="radio" name="is_home" value="0" title="否">
|
<input type="radio" name="is_share" value="0" title="否">
|
||||||
</td>
|
</td>
|
||||||
<td class="layui-td-gray2">属性</td>
|
<td class="layui-td-gray2">属性</td>
|
||||||
<td>
|
<td>
|
||||||
@ -101,54 +101,53 @@
|
|||||||
<!-- 脚本 -->
|
<!-- 脚本 -->
|
||||||
{block name="script"}
|
{block name="script"}
|
||||||
<script>
|
<script>
|
||||||
function init(layui) {
|
function init(layui) {
|
||||||
var form = layui.form
|
var form = layui.form
|
||||||
, layer = layui.layer
|
, layer = layui.layer
|
||||||
, tagspicker = layui.tagpicker
|
, tagspicker = layui.tagpicker
|
||||||
, upload = layui.upload;
|
, upload = layui.upload;
|
||||||
|
|
||||||
var tags = new tagspicker({
|
var tags = new tagspicker({
|
||||||
'url': "{:url('home/api/get_keyword_cate')}",
|
'url': "{:url('home/api/get_keyword_cate')}",
|
||||||
'target': 'keyword_name',
|
'target': 'keyword_name',
|
||||||
'tag_ids': 'keyword_id',
|
'tag_ids': 'keyword_id',
|
||||||
'tag_tags': 'keyword_name',
|
'tag_tags': 'keyword_name',
|
||||||
'height': 500,
|
'height': 500,
|
||||||
'isDiy': 1
|
'isDiy': 1
|
||||||
});
|
});
|
||||||
|
|
||||||
//封面上传
|
//封面上传
|
||||||
var uploadInst = upload.render({
|
var uploadInst = upload.render({
|
||||||
elem: '#test1'
|
elem: '#test1'
|
||||||
, url: "{:url('home/api/upload')}",
|
, url: "{:url('home/api/upload')}"
|
||||||
, done: function (res) {
|
, done: function (res) {
|
||||||
//如果上传失败
|
//如果上传失败
|
||||||
if (res.code == 1) {
|
if (res.code == 1) {
|
||||||
return layer.msg('上传失败');
|
return layer.msg('上传失败');
|
||||||
}
|
}
|
||||||
//上传成功
|
//上传成功
|
||||||
$('#demo1 input').attr('value', res.data.id);
|
$('#demo1 input').attr('value', res.data.id);
|
||||||
$('#demo1 img').attr('src', res.data.filepath);
|
$('#demo1 img').attr('src', res.data.filepath);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//监听提交
|
//监听提交
|
||||||
form.on('submit(webform)', function (data) {
|
form.on('submit(webform)', function (data) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{:url('home/article/post_submit')}",
|
url: "{:url('home/article/add')}",
|
||||||
type: 'post',
|
type: 'post',
|
||||||
data: data.field,
|
data: data.field,
|
||||||
success: function (e) {
|
success: function (e) {
|
||||||
if (e.code == 0) {
|
if (e.code == 0) {
|
||||||
layer.confirm('保存成功,返回列表页吗?', { icon: 3, title: '提示' }, function (index) {
|
layer.confirm('保存成功,返回列表页吗?', { icon: 3, title: '提示' }, function (index) {
|
||||||
history.back(-1);
|
window.location.href="{:url('home/article/index')}";
|
||||||
layer.close(index);
|
});
|
||||||
});
|
} else {
|
||||||
} else {
|
layer.msg(e.msg);
|
||||||
layer.msg(e.msg);
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
})
|
return false;
|
||||||
return false;
|
|
||||||
});
|
});
|
||||||
//监听返回
|
//监听返回
|
||||||
$('.body-content').on('click', '[lay-event="back"]', function () {
|
$('.body-content').on('click', '[lay-event="back"]', function () {
|
||||||
@ -159,7 +158,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
{include file="common/layui" base='base' extend="['tagpicker']" callback="init" /}
|
{include file="common/layui" base="base" extend="['tagpicker']" callback="init" /}
|
||||||
{include file="common/ueditor" id="container" name="content" width="776" height="500" toolbar="[]" /}
|
{include file="common/ueditor" id="container" name="content" width="776" height="500" toolbar="[]" /}
|
||||||
{/block}
|
{/block}
|
||||||
<!-- /脚本 -->
|
<!-- /脚本 -->
|
@ -45,7 +45,6 @@
|
|||||||
,{field: 'sort', title: '排序', edit: "text", align:'center', style:'cursor: pointer;', width:80}
|
,{field: 'sort', title: '排序', edit: "text", align:'center', style:'cursor: pointer;', width:80}
|
||||||
,{field:'title', edit:'text',width:240, title: '分类名称'}
|
,{field:'title', edit:'text',width:240, title: '分类名称'}
|
||||||
,{field:'pid', title: '父级ID', edit:"text",width:80, align:'center'}
|
,{field:'pid', title: '父级ID', edit:"text",width:80, align:'center'}
|
||||||
,{field:'keywords', title: '关键词', edit:"text",width:200,}
|
|
||||||
,{field:'desc', title: '描述', edit:"text"}
|
,{field:'desc', title: '描述', edit:"text"}
|
||||||
,{width:100,title: '操作', align:'center'
|
,{width:100,title: '操作', align:'center'
|
||||||
,templet: function(d){
|
,templet: function(d){
|
||||||
@ -63,15 +62,15 @@
|
|||||||
treeGrid.on('edit('+tableId+')', function(obj){
|
treeGrid.on('edit('+tableId+')', function(obj){
|
||||||
layer.confirm('确定要提交修改吗?', {icon: 3, title:'提示'}, function(index){
|
layer.confirm('确定要提交修改吗?', {icon: 3, title:'提示'}, function(index){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url:"{:url('home/article/cate_post_submit')}",
|
url:"{:url('home/article/cate_add')}",
|
||||||
type:'post',
|
type:'post',
|
||||||
data:{id:obj.data.id,field:obj.field,value:obj.value},
|
data:{id:obj.data.id,field:obj.field,value:obj.value},
|
||||||
success:function(res){
|
success:function(res){
|
||||||
layer.msg(res.msg);
|
layer.msg(res.msg);
|
||||||
if(res.code == 1){
|
if(res.code == 0){
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
location.reload()
|
location.reload()
|
||||||
},2000)
|
},1200)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -17,20 +17,14 @@
|
|||||||
<td>
|
<td>
|
||||||
<input type="text" name="title" lay-verify="required" autocomplete="off" placeholder="请输入分类名称" lay-reqText="请输入分类名称" class="layui-input">
|
<input type="text" name="title" lay-verify="required" autocomplete="off" placeholder="请输入分类名称" lay-reqText="请输入分类名称" class="layui-input">
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="layui-td-gray2">排序</td>
|
<td class="layui-td-gray2">排序</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" name="sort" placeholder="请输入排序,数字" value="0" autocomplete="off" class="layui-input">
|
<input type="text" name="sort" placeholder="请输入排序,数字" value="0" autocomplete="off" class="layui-input">
|
||||||
</td>
|
</td>
|
||||||
<td class="layui-td-gray2">关键词</td>
|
|
||||||
<td>
|
|
||||||
<input type="text" name="keywords" placeholder="请输入关键词,用“,”隔开,可空" autocomplete="off" class="layui-input">
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="layui-td-gray2">描述</td>
|
<td class="layui-td-gray2">描述</td>
|
||||||
<td colspan="3"><textarea name="desc" placeholder="请输入描述,可空" class="layui-textarea"></textarea></td>
|
<td colspan="5"><textarea name="desc" placeholder="请输入描述,可空" class="layui-textarea"></textarea></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<div style="padding: 10px 0">
|
<div style="padding: 10px 0">
|
||||||
@ -44,38 +38,37 @@
|
|||||||
|
|
||||||
<!-- 脚本 -->
|
<!-- 脚本 -->
|
||||||
{block name="script"}
|
{block name="script"}
|
||||||
<script>
|
<script>
|
||||||
function init(layui){
|
function init(layui){
|
||||||
var form = layui.form
|
var form = layui.form
|
||||||
,layer = layui.layer;
|
,layer = layui.layer;
|
||||||
|
|
||||||
//监听提交
|
//监听提交
|
||||||
form.on('submit(webform)', function(data){
|
form.on('submit(webform)', function(data){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url:"{:url('home/article/cate_post_submit')}",
|
url:"{:url('home/article/cate_add')}",
|
||||||
type:'post',
|
type:'post',
|
||||||
data:data.field,
|
data:data.field,
|
||||||
success:function(e){
|
success:function(e){
|
||||||
if(e.code==0){
|
if(e.code==0){
|
||||||
layer.confirm('保存成功,返回列表页吗?', {icon: 3, title:'提示'}, function(index){
|
layer.confirm('保存成功,返回列表页吗?', {icon: 3, title:'提示'}, function(index){
|
||||||
history.back(-1);
|
history.back(-1);
|
||||||
layer.close(index);
|
layer.close(index);
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
layer.msg(e.msg);
|
layer.msg(e.msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})
|
})
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
//监听返回
|
//监听返回
|
||||||
$('.body-content').on('click','[lay-event="back"]',function () {
|
$('.body-content').on('click','[lay-event="back"]',function () {
|
||||||
history.back(-1);
|
history.back(-1);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
</script>
|
||||||
</script>
|
{include file="common/layui" base='base' extend="[]" callback="init" /}
|
||||||
{include file="common/layui" base='base' extend="[]" callback="init" /}
|
|
||||||
{/block}
|
{/block}
|
||||||
<!-- /脚本 -->
|
<!-- /脚本 -->
|
@ -37,10 +37,10 @@
|
|||||||
<input type="text" name="sort" placeholder="请输入排序,数字" autocomplete="off" class="layui-input"
|
<input type="text" name="sort" placeholder="请输入排序,数字" autocomplete="off" class="layui-input"
|
||||||
value="{$article.sort}">
|
value="{$article.sort}">
|
||||||
</td>
|
</td>
|
||||||
<td class="layui-td-gray2">首页显示</td>
|
<td class="layui-td-gray2">是否共享</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="radio" name="is_home" value="1" title="是" {eq name="$article.is_home" value="1" }checked{/eq}>
|
<input type="radio" name="is_share" value="1" title="是" {eq name="$article.is_share" value="1" }checked{/eq}>
|
||||||
<input type="radio" name="is_home" value="0" title="否" {eq name="$article.is_home" value="0" }checked{/eq}>
|
<input type="radio" name="is_share" value="0" title="否" {eq name="$article.is_share" value="0" }checked{/eq}>
|
||||||
</td>
|
</td>
|
||||||
<td class="layui-td-gray2">属性</td>
|
<td class="layui-td-gray2">属性</td>
|
||||||
<td>
|
<td>
|
||||||
@ -107,59 +107,58 @@
|
|||||||
<!-- 脚本 -->
|
<!-- 脚本 -->
|
||||||
{block name="script"}
|
{block name="script"}
|
||||||
<script>
|
<script>
|
||||||
function init(layui) {
|
function init(layui) {
|
||||||
var form = layui.form
|
var form = layui.form
|
||||||
, layer = layui.layer
|
, layer = layui.layer
|
||||||
, tagspicker = layui.tagpicker
|
, tagspicker = layui.tagpicker
|
||||||
, upload = layui.upload;
|
, upload = layui.upload;
|
||||||
|
|
||||||
var tags = new tagspicker({
|
var tags = new tagspicker({
|
||||||
'url': "{:url('home/api/get_keyword_cate')}",
|
'url': "{:url('home/api/get_keyword_cate')}",
|
||||||
'target': 'keyword_name',
|
'target': 'keyword_name',
|
||||||
'tag_ids': 'keyword_id',
|
'tag_ids': 'keyword_id',
|
||||||
'tag_tags': 'keyword_name',
|
'tag_tags': 'keyword_name',
|
||||||
'height': 500,
|
'height': 500,
|
||||||
'isDiy': 1
|
'isDiy': 1
|
||||||
});
|
});
|
||||||
|
|
||||||
//封面上传
|
//封面上传
|
||||||
var uploadInst = upload.render({
|
var uploadInst = upload.render({
|
||||||
elem: '#test1'
|
elem: '#test1'
|
||||||
, url: "{:url('home/api/upload')}",
|
, url: "{:url('home/api/upload')}"
|
||||||
, done: function (res) {
|
, done: function (res) {
|
||||||
//如果上传失败
|
//如果上传失败
|
||||||
if (res.code == 1) {
|
if (res.code == 1) {
|
||||||
return layer.msg('上传失败');
|
return layer.msg('上传失败');
|
||||||
}
|
}
|
||||||
//上传成功
|
//上传成功
|
||||||
$('#demo1 input').attr('value', res.data.id);
|
$('#demo1 input').attr('value', res.data.id);
|
||||||
$('#demo1 img').attr('src', res.data.filepath);
|
$('#demo1 img').attr('src', res.data.filepath);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//监听提交
|
//监听提交
|
||||||
form.on('submit(webform)', function (data) {
|
form.on('submit(webform)', function (data) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{:url('home/api/post_submit')}",
|
url: "{:url('home/article/add')}",
|
||||||
type: 'post',
|
type: 'post',
|
||||||
data: data.field,
|
data: data.field,
|
||||||
success: function (e) {
|
success: function (e) {
|
||||||
if (e.code == 0) {
|
if (e.code == 0) {
|
||||||
layer.confirm('保存成功,返回列表页吗?', { icon: 3, title: '提示' }, function (index) {
|
layer.confirm('保存成功,返回列表页吗?', { icon: 3, title: '提示' }, function (index) {
|
||||||
history.back(-1);
|
window.location.href="{:url('home/article/index')}";
|
||||||
layer.close(index);
|
});
|
||||||
});
|
} else {
|
||||||
} else {
|
layer.msg(e.msg);
|
||||||
layer.msg(e.msg);
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
})
|
return false;
|
||||||
return false;
|
|
||||||
});
|
});
|
||||||
//监听返回
|
//监听返回
|
||||||
$('.body-content').on('click', '[lay-event="back"]', function () {
|
$('.body-content').on('click', '[lay-event="back"]', function () {
|
||||||
history.back(-1);
|
history.back(-1);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
<script type="text/html" id="status">
|
<script type="text/html" id="status">
|
||||||
<i class="layui-icon {{# if(d.status == 1){ }}layui-icon-ok{{# } else { }}layui-icon-close{{# } }}"></i>
|
<i class="layui-icon {{# if(d.status == 1){ }}layui-icon-ok{{# } else { }}layui-icon-close{{# } }}"></i>
|
||||||
</script>
|
</script>
|
||||||
<script type="text/html" id="is_home">
|
<script type="text/html" id="is_share">
|
||||||
<i class="layui-icon {{# if(d.is_home == 1){ }}layui-icon-ok{{# } else { }}layui-icon-close{{# } }}"></i>
|
<i class="layui-icon {{# if(d.is_share == 1){ }}layui-icon-ok{{# } else { }}layui-icon-close{{# } }}"></i>
|
||||||
</script>
|
</script>
|
||||||
<script type="text/html" id="toolbarDemo">
|
<script type="text/html" id="toolbarDemo">
|
||||||
<div class="layui-btn-container">
|
<div class="layui-btn-container">
|
||||||
@ -79,8 +79,8 @@
|
|||||||
width: 66
|
width: 66
|
||||||
}, {
|
}, {
|
||||||
field: 'is_home',
|
field: 'is_home',
|
||||||
title: '首页显示',
|
title: '首页共享',
|
||||||
toolbar: '#is_home',
|
toolbar: '#is_share',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
width: 90
|
width: 90
|
||||||
}, {
|
}, {
|
||||||
|
@ -98,7 +98,7 @@ function init(layui) {
|
|||||||
//监听提交
|
//监听提交
|
||||||
form.on('submit(webform)', function (data) {
|
form.on('submit(webform)', function (data) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{:url('home/note/post_submit')}",
|
url: "{:url('home/note/add')}",
|
||||||
type: 'post',
|
type: 'post',
|
||||||
data: data.field,
|
data: data.field,
|
||||||
success: function (e) {
|
success: function (e) {
|
||||||
|
@ -61,7 +61,7 @@
|
|||||||
treeGrid.on('edit('+tableId+')', function(obj){
|
treeGrid.on('edit('+tableId+')', function(obj){
|
||||||
layer.confirm('确定要提交修改吗?', {icon: 3, title:'提示'}, function(index){
|
layer.confirm('确定要提交修改吗?', {icon: 3, title:'提示'}, function(index){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url:"{:url('home/note/cate_post_submit')}",
|
url:"{:url('home/note/cate_add')}",
|
||||||
type:'post',
|
type:'post',
|
||||||
data:{id:obj.data.id,field:obj.field,value:obj.value},
|
data:{id:obj.data.id,field:obj.field,value:obj.value},
|
||||||
success:function(res){
|
success:function(res){
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
//监听提交
|
//监听提交
|
||||||
form.on('submit(webform)', function(data){
|
form.on('submit(webform)', function(data){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url:"{:url('home/note/cate_post_submit')}",
|
url:"{:url('home/note/cate_add')}",
|
||||||
type:'post',
|
type:'post',
|
||||||
data:data.field,
|
data:data.field,
|
||||||
success:function(e){
|
success:function(e){
|
||||||
|
@ -361,8 +361,7 @@ CREATE TABLE `oa_article_cate` (
|
|||||||
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||||
`pid` int(11) NOT NULL DEFAULT 0 COMMENT '父类ID',
|
`pid` int(11) NOT NULL DEFAULT 0 COMMENT '父类ID',
|
||||||
`sort` int(5) NOT NULL DEFAULT 0 COMMENT '排序',
|
`sort` int(5) NOT NULL DEFAULT 0 COMMENT '排序',
|
||||||
`title` varchar(255) NOT NULL DEFAULT '' COMMENT '标题',
|
`title` varchar(255) NOT NULL DEFAULT '' COMMENT '分类标题',
|
||||||
`keywords` varchar(255) NULL DEFAULT '' COMMENT '关键字',
|
|
||||||
`desc` varchar(1000) NULL DEFAULT '' COMMENT '描述',
|
`desc` varchar(1000) NULL DEFAULT '' COMMENT '描述',
|
||||||
`create_time` int(11) NOT NULL DEFAULT 0 COMMENT '添加时间',
|
`create_time` int(11) NOT NULL DEFAULT 0 COMMENT '添加时间',
|
||||||
`update_time` int(11) NOT NULL DEFAULT 0 COMMENT '修改时间',
|
`update_time` int(11) NOT NULL DEFAULT 0 COMMENT '修改时间',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user