mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-10 03:42:49 +08:00
完成内容管理
This commit is contained in:
@@ -125,7 +125,10 @@ abstract class BaseController
|
|||||||
|
|
||||||
if(\request()->isAjax()){
|
if(\request()->isAjax()){
|
||||||
$data['jump_to_url'] = (string)$jump_to_url;
|
$data['jump_to_url'] = (string)$jump_to_url;
|
||||||
throw new HttpResponseException(json_message($data,0,$msg));
|
if($code == 200){
|
||||||
|
$code = 0;
|
||||||
|
}
|
||||||
|
throw new HttpResponseException(json_message($data,$code,$msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
View::assign($data);
|
View::assign($data);
|
||||||
@@ -154,7 +157,10 @@ abstract class BaseController
|
|||||||
|
|
||||||
if(\request()->isAjax()){
|
if(\request()->isAjax()){
|
||||||
$data['jump_to_url'] = (string)$jump_to_url;
|
$data['jump_to_url'] = (string)$jump_to_url;
|
||||||
throw new HttpResponseException(json_message($data,0,$msg));
|
if($code == 200){
|
||||||
|
$code = 0;
|
||||||
|
}
|
||||||
|
throw new HttpResponseException(json_message($data,$code,$msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
View::assign($data);
|
View::assign($data);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace app\admin\controller;
|
namespace app\admin\controller;
|
||||||
|
|
||||||
|
use app\model\Category as ModelCategory;
|
||||||
use think\facade\View;
|
use think\facade\View;
|
||||||
use think\Request;
|
use think\Request;
|
||||||
|
|
||||||
@@ -18,6 +19,14 @@ class Category extends Common
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
|
||||||
|
$list = ModelCategory::getListLevel();
|
||||||
|
|
||||||
|
if($this->request->isAjax()){
|
||||||
|
return json_message($list);
|
||||||
|
}
|
||||||
|
|
||||||
|
View::assign('list',$list);
|
||||||
|
|
||||||
return View::fetch();
|
return View::fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,6 +39,10 @@ class Category extends Common
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
|
||||||
|
$list = ModelCategory::getListLevel();
|
||||||
|
|
||||||
|
View::assign('list_category',$list);
|
||||||
|
|
||||||
return View::fetch();
|
return View::fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,6 +55,33 @@ class Category extends Common
|
|||||||
public function save(Request $request)
|
public function save(Request $request)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
|
||||||
|
$post_data = $request->post();
|
||||||
|
|
||||||
|
if(empty($post_data['title'])){
|
||||||
|
return $this->error('标题不能为空',null,500);
|
||||||
|
}
|
||||||
|
|
||||||
|
$model_category = ModelCategory::where('title',$post_data['title'])
|
||||||
|
->where('pid',$post_data['pid'])
|
||||||
|
->find();
|
||||||
|
|
||||||
|
if(!empty($model_category)){
|
||||||
|
$this->error('相同名称相同级别不能出现两次',null,500);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($post_data['pid'] != 0){
|
||||||
|
|
||||||
|
$model_parent_category = ModelCategory::where('id',$post_data['pid'])->find();
|
||||||
|
|
||||||
|
$post_data['level'] = $model_parent_category->level + 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ModelCategory::create($post_data);
|
||||||
|
|
||||||
|
return $this->success('添加成功','index');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -64,6 +104,15 @@ class Category extends Common
|
|||||||
public function edit($id)
|
public function edit($id)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
|
||||||
|
$model_category = ModelCategory::find($id);
|
||||||
|
|
||||||
|
$list = ModelCategory::getListLevel();
|
||||||
|
|
||||||
|
View::assign('list_category',$list);
|
||||||
|
View::assign('category',$model_category);
|
||||||
|
|
||||||
|
return View::fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -76,6 +125,36 @@ class Category extends Common
|
|||||||
public function update(Request $request, $id)
|
public function update(Request $request, $id)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
|
$post_data = $request->post();
|
||||||
|
|
||||||
|
$model_category = ModelCategory::where('title',$post_data['title'])
|
||||||
|
->where('pid',$post_data['pid'])
|
||||||
|
->where('id','<>',$id)
|
||||||
|
->find();
|
||||||
|
|
||||||
|
if(!empty($model_category)){
|
||||||
|
$this->error('相同名称相同级别不能出现两次');
|
||||||
|
}
|
||||||
|
|
||||||
|
if($post_data['pid'] != 0){
|
||||||
|
|
||||||
|
$model_parent_category = ModelCategory::where('id',$post_data['pid'])->find();
|
||||||
|
|
||||||
|
$post_data['level'] = $model_parent_category->level + 1;
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$post_data['level'] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$model_category = ModelCategory::find($id);
|
||||||
|
|
||||||
|
$model_category->save($post_data);
|
||||||
|
|
||||||
|
return $this->success('保存成功','index');
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -87,5 +166,25 @@ class Category extends Common
|
|||||||
public function delete($id)
|
public function delete($id)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
|
||||||
|
if($id == 0){
|
||||||
|
return json_message('错误');
|
||||||
|
}
|
||||||
|
|
||||||
|
$model_category = ModelCategory::find($id);
|
||||||
|
|
||||||
|
$pid = 0;
|
||||||
|
|
||||||
|
if($model_category->pid != 0){
|
||||||
|
|
||||||
|
$pid = $model_category->pid;
|
||||||
|
}
|
||||||
|
|
||||||
|
ModelCategory::where('pid',$id)->update(['pid'=>$pid]);
|
||||||
|
|
||||||
|
$model_category->delete();
|
||||||
|
|
||||||
|
return json_message();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,11 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace app\admin\controller;
|
namespace app\admin\controller;
|
||||||
|
|
||||||
|
use app\model\Category;
|
||||||
use app\model\Post as ModelPost;
|
use app\model\Post as ModelPost;
|
||||||
|
use app\model\PostCategory;
|
||||||
|
use app\model\PostTag;
|
||||||
|
use app\model\Tag;
|
||||||
use think\facade\View;
|
use think\facade\View;
|
||||||
use think\Request;
|
use think\Request;
|
||||||
|
|
||||||
@@ -47,6 +51,35 @@ class Post extends Common
|
|||||||
public function save(Request $request)
|
public function save(Request $request)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
$post_data = $request->post();
|
||||||
|
|
||||||
|
$categorys = [];
|
||||||
|
$tags = [];
|
||||||
|
if (isset($post_data['categorys'])) {
|
||||||
|
$categorys = $post_data['categorys'];
|
||||||
|
unset($post_data['categorys']);
|
||||||
|
}
|
||||||
|
if (isset($post_data['tags'])) {
|
||||||
|
$tags = $post_data['tags'];
|
||||||
|
unset($post_data['tags']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$model_post = ModelPost::create($post_data);
|
||||||
|
|
||||||
|
foreach ($categorys as $category) {
|
||||||
|
PostCategory::create([
|
||||||
|
'post_id' => $model_post->id,
|
||||||
|
'category_id' => $category
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
foreach ($tags as $tag) {
|
||||||
|
PostTag::create([
|
||||||
|
'post_id' => $model_post->id,
|
||||||
|
'tag_id' => $tag
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->success('添加成功', 'index');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -69,6 +102,13 @@ class Post extends Common
|
|||||||
public function edit($id)
|
public function edit($id)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
|
||||||
|
$model_post = ModelPost::find($id);
|
||||||
|
|
||||||
|
|
||||||
|
View::assign('post', $model_post);
|
||||||
|
|
||||||
|
return View::fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -81,6 +121,63 @@ class Post extends Common
|
|||||||
public function update(Request $request, $id)
|
public function update(Request $request, $id)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
$post_data = $request->post();
|
||||||
|
|
||||||
|
$model_post = ModelPost::find($id);
|
||||||
|
|
||||||
|
$categorys = [];
|
||||||
|
$tags = [];
|
||||||
|
if (isset($post_data['categorys'])) {
|
||||||
|
$categorys = $post_data['categorys'];
|
||||||
|
unset($post_data['categorys']);
|
||||||
|
}
|
||||||
|
if (isset($post_data['tags'])) {
|
||||||
|
$tags = $post_data['tags'];
|
||||||
|
unset($post_data['tags']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$model_post->save($post_data);
|
||||||
|
|
||||||
|
$old_category_list = PostCategory::where('post_id', $id)->select();
|
||||||
|
$old_category_id_list = array_column((array)$old_category_list, 'id');
|
||||||
|
$old_tag_list = PostTag::where('post_id', $id)->select();
|
||||||
|
$old_tag_id_list = array_column((array)$old_tag_list, 'id');
|
||||||
|
|
||||||
|
// 旧的有新的没有
|
||||||
|
foreach ($old_category_list as $model_category) {
|
||||||
|
if (!in_array($model_category->id, $categorys)) {
|
||||||
|
$model_category->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($old_tag_list as $model_tag) {
|
||||||
|
if (!in_array($model_tag->id, $tags)) {
|
||||||
|
$model_tag->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 旧的没有新的有
|
||||||
|
foreach ($categorys as $category) {
|
||||||
|
if (!in_array($category, $old_category_id_list)) {
|
||||||
|
|
||||||
|
PostCategory::create([
|
||||||
|
'post_id' => $model_post->id,
|
||||||
|
'category_id' => $category
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($tags as $tag) {
|
||||||
|
if (!in_array($tag, $old_tag_id_list)) {
|
||||||
|
|
||||||
|
PostTag::create([
|
||||||
|
'post_id' => $model_post->id,
|
||||||
|
'tag_id' => $tag
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->success('保存成功', 'index');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace app\admin\controller;
|
namespace app\admin\controller;
|
||||||
|
|
||||||
|
use app\model\Tag as ModelTag;
|
||||||
|
use think\facade\View;
|
||||||
use think\Request;
|
use think\Request;
|
||||||
|
|
||||||
class Tag
|
class Tag extends Common
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 显示资源列表
|
* 显示资源列表
|
||||||
@@ -15,6 +18,16 @@ class Tag
|
|||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
|
||||||
|
$list_tag = ModelTag::order('id desc')->paginate();
|
||||||
|
|
||||||
|
if($this->request->isAjax()){
|
||||||
|
return json_message($list_tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
View::assign('list',$list_tag);
|
||||||
|
|
||||||
|
return View::fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,6 +49,22 @@ class Tag
|
|||||||
public function save(Request $request)
|
public function save(Request $request)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
|
||||||
|
$post_data = $request->post();
|
||||||
|
|
||||||
|
$arr = explode(' ',$post_data['tags']);
|
||||||
|
|
||||||
|
$arr = array_unique(array_filter($arr));
|
||||||
|
|
||||||
|
foreach ($arr as $tag) {
|
||||||
|
$model_tag = ModelTag::where('title',$tag)->find();
|
||||||
|
|
||||||
|
if(empty($model_tag)){
|
||||||
|
ModelTag::create(['title'=>$tag]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return json_message();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -58,6 +87,7 @@ class Tag
|
|||||||
public function edit($id)
|
public function edit($id)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -70,6 +100,16 @@ class Tag
|
|||||||
public function update(Request $request, $id)
|
public function update(Request $request, $id)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
|
||||||
|
$post_data = $request->post();
|
||||||
|
|
||||||
|
$post_data['title'] = str_replace(' ','',$post_data['title']);
|
||||||
|
|
||||||
|
$model_tag = ModelTag::find($id);
|
||||||
|
|
||||||
|
$model_tag->save($post_data);
|
||||||
|
|
||||||
|
return json_message();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -56,7 +56,8 @@ function get_source_link($url)
|
|||||||
{
|
{
|
||||||
if (strpos($url, '/') === 0) {
|
if (strpos($url, '/') === 0) {
|
||||||
return $url;
|
return $url;
|
||||||
}if(strpos($url,'http') === 0){
|
}
|
||||||
|
if (strpos($url, 'http') === 0) {
|
||||||
return $url;
|
return $url;
|
||||||
} else {
|
} else {
|
||||||
$resource_domain = get_system_config('resource_domain');
|
$resource_domain = get_system_config('resource_domain');
|
||||||
@@ -107,7 +108,8 @@ function save_url_file($url,$type)
|
|||||||
return $save_name;
|
return $save_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
function geturl($url){
|
function geturl($url)
|
||||||
|
{
|
||||||
$headerArray = array();
|
$headerArray = array();
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
@@ -122,7 +124,8 @@ function geturl($url){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function posturl($url,$data){
|
function posturl($url, $data)
|
||||||
|
{
|
||||||
$data = json_encode($data);
|
$data = json_encode($data);
|
||||||
$headerArray = array();
|
$headerArray = array();
|
||||||
$curl = curl_init();
|
$curl = curl_init();
|
||||||
@@ -138,26 +141,51 @@ function posturl($url,$data){
|
|||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
function format_size($filesize) {
|
function format_size($filesize)
|
||||||
|
{
|
||||||
|
|
||||||
if ($filesize >= 1073741824) {
|
if ($filesize >= 1073741824) {
|
||||||
|
|
||||||
$filesize = round($filesize / 1073741824 * 100) / 100 . ' GB';
|
$filesize = round($filesize / 1073741824 * 100) / 100 . ' GB';
|
||||||
|
|
||||||
} elseif ($filesize >= 1048576) {
|
} elseif ($filesize >= 1048576) {
|
||||||
|
|
||||||
$filesize = round($filesize / 1048576 * 100) / 100 . ' MB';
|
$filesize = round($filesize / 1048576 * 100) / 100 . ' MB';
|
||||||
|
|
||||||
} elseif ($filesize >= 1024) {
|
} elseif ($filesize >= 1024) {
|
||||||
|
|
||||||
$filesize = round($filesize / 1024 * 100) / 100 . ' KB';
|
$filesize = round($filesize / 1024 * 100) / 100 . ' KB';
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$filesize = $filesize . ' 字节';
|
$filesize = $filesize . ' 字节';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $filesize;
|
return $filesize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数组层级缩进转换
|
||||||
|
* @param array $array 源数组
|
||||||
|
* @param int $pid
|
||||||
|
* @param int $level
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function array2level($array, $pid = 0, $level = 1)
|
||||||
|
{
|
||||||
|
|
||||||
|
static $list = [];
|
||||||
|
if ($level == 0) {
|
||||||
|
$list = [];
|
||||||
|
$level = 1;
|
||||||
|
}
|
||||||
|
foreach ($array as $v) {
|
||||||
|
if ($v['pid'] == $pid) {
|
||||||
|
$v['level'] = $level;
|
||||||
|
$list[] = $v;
|
||||||
|
array2level($array, $v['id'], $level + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// halt($list);
|
||||||
|
|
||||||
|
return $list;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace app\model;
|
namespace app\model;
|
||||||
@@ -11,4 +12,12 @@ use think\Model;
|
|||||||
class Category extends Model
|
class Category extends Model
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
|
||||||
|
public static function getListLevel()
|
||||||
|
{
|
||||||
|
$model_list = Category::select();
|
||||||
|
|
||||||
|
// return $model_list;
|
||||||
|
return array2level($model_list,0,0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,4 +17,38 @@ class Post extends Model
|
|||||||
use SoftDelete;
|
use SoftDelete;
|
||||||
|
|
||||||
protected $defaultSoftDelete = 0;
|
protected $defaultSoftDelete = 0;
|
||||||
|
|
||||||
|
public function categorys()
|
||||||
|
{
|
||||||
|
return $this->hasMany(PostCategory::class,'post_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function tags()
|
||||||
|
{
|
||||||
|
return $this->hasMany(PostTag::class,'post_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPubishTimeAttr($value)
|
||||||
|
{
|
||||||
|
return strtotime($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setContentAttr($value)
|
||||||
|
{
|
||||||
|
return json_encode($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getContentAttr($value)
|
||||||
|
{
|
||||||
|
return json_decode($value,true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPosterAttr($value)
|
||||||
|
{
|
||||||
|
if(empty($value)){
|
||||||
|
$value = '/static/images/avatar.jpeg';
|
||||||
|
}
|
||||||
|
|
||||||
|
return get_source_link($value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
14
app/model/PostCategory.php
Normal file
14
app/model/PostCategory.php
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
declare (strict_types = 1);
|
||||||
|
|
||||||
|
namespace app\model;
|
||||||
|
|
||||||
|
use think\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @mixin think\Model
|
||||||
|
*/
|
||||||
|
class PostCategory extends Model
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
14
app/model/PostTag.php
Normal file
14
app/model/PostTag.php
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
declare (strict_types = 1);
|
||||||
|
|
||||||
|
namespace app\model;
|
||||||
|
|
||||||
|
use think\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @mixin think\Model
|
||||||
|
*/
|
||||||
|
class PostTag extends Model
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace app\model;
|
namespace app\model;
|
||||||
@@ -11,4 +12,5 @@ use think\Model;
|
|||||||
class Tag extends Model
|
class Tag extends Model
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
83
view/admin/category/create.html
Normal file
83
view/admin/category/create.html
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
|
<title>分类管理</title>
|
||||||
|
{include file="common/_require"}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var currentHeaderNavItem = 'Post';
|
||||||
|
var currentLeftNavItem = 'category';
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body class="layui-layout-body">
|
||||||
|
|
||||||
|
<div class="layui-layout layui-layout-admin">
|
||||||
|
{include file="common/_header"}
|
||||||
|
|
||||||
|
{include file="common/left_post"}
|
||||||
|
|
||||||
|
<div class="layui-body">
|
||||||
|
|
||||||
|
<div style="padding:15px">
|
||||||
|
<div class="main-header">
|
||||||
|
<span class="layui-breadcrumb">
|
||||||
|
<a>首页</a>
|
||||||
|
<a><cite>系统信息</cite></a>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="main-container">
|
||||||
|
<div class="layui-col-md6">
|
||||||
|
<fieldset class="layui-elem-field">
|
||||||
|
<legend>新增分类</legend>
|
||||||
|
<div class="layui-field-box">
|
||||||
|
<form class="layui-form" action="{:url('save')}" method="post">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<div class="layui-form-label">分类名称</div>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" name="title" value="" required lay-verify="required" class="layui-input">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<div class="layui-form-label">上级分类</div>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<select name="pid">
|
||||||
|
<option value="0">--无上级分类--</option>
|
||||||
|
{volist name='$list_category' id='category'}
|
||||||
|
|
||||||
|
<option value="{$category.id}">{:str_repeat('|--',$category.level)}{$category.title}</option>
|
||||||
|
{/volist}
|
||||||
|
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<button class="layui-btn layui-btn-fluid" submit lay-submit lay-filter="site-info">提交</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
{include file="common/_footer"}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
layui.use(['form'],function(){
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
89
view/admin/category/edit.html
Normal file
89
view/admin/category/edit.html
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
|
<title>分类管理</title>
|
||||||
|
{include file="common/_require"}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var currentHeaderNavItem = 'Post';
|
||||||
|
var currentLeftNavItem = 'category';
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body class="layui-layout-body">
|
||||||
|
|
||||||
|
<div class="layui-layout layui-layout-admin">
|
||||||
|
{include file="common/_header"}
|
||||||
|
|
||||||
|
{include file="common/left_post"}
|
||||||
|
|
||||||
|
<div class="layui-body">
|
||||||
|
|
||||||
|
<div style="padding:15px">
|
||||||
|
<div class="main-header">
|
||||||
|
<span class="layui-breadcrumb">
|
||||||
|
<a>首页</a>
|
||||||
|
<a><cite>系统信息</cite></a>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="main-container">
|
||||||
|
<div class="layui-col-md6">
|
||||||
|
<fieldset class="layui-elem-field">
|
||||||
|
<legend>编辑分类</legend>
|
||||||
|
<div class="layui-field-box">
|
||||||
|
<form class="layui-form" action="{:url('update')}" method="post" lay-filter="*">
|
||||||
|
<input type="hidden" name="id" value="{$category.id}">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<div class="layui-form-label">分类名称</div>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" name="title" value="{$category.title}" required lay-verify="required" class="layui-input">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<div class="layui-form-label">上级分类</div>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<select name="pid">
|
||||||
|
<option value="0">--无上级分类--</option>
|
||||||
|
{volist name='$list_category' id='vo'}
|
||||||
|
{if $category.id != $vo.id}
|
||||||
|
<option value="{$vo.id}">{:str_repeat('|--',$vo.level)}{$vo.title}</option>
|
||||||
|
{/if}
|
||||||
|
{/volist}
|
||||||
|
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<button class="layui-btn layui-btn-fluid" submit lay-submit lay-filter="site-info">提交</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
{include file="common/_footer"}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
layui.use(['form'],function(){
|
||||||
|
var form = layui.form;
|
||||||
|
|
||||||
|
form.val('*',{
|
||||||
|
pid:'{$category.pid}'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -1,17 +1,19 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
<title>应用管理</title>
|
<title>分类管理</title>
|
||||||
{include file="common/_require"}
|
{include file="common/_require"}
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var currentHeaderNavItem = 'Index';
|
var currentHeaderNavItem = 'Post';
|
||||||
var currentLeftNavItem = 'index';
|
var currentLeftNavItem = 'category';
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body class="layui-layout-body">
|
<body class="layui-layout-body">
|
||||||
|
|
||||||
<div class="layui-layout layui-layout-admin">
|
<div class="layui-layout layui-layout-admin">
|
||||||
@@ -32,6 +34,36 @@
|
|||||||
<div>
|
<div>
|
||||||
<a href="{:url('create')}" class="layui-btn">新增</a>
|
<a href="{:url('create')}" class="layui-btn">新增</a>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<table class="layui-table">
|
||||||
|
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>名称</th>
|
||||||
|
<th>操作</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
{volist name="list" id="vo"}
|
||||||
|
<tr class="item" data-id="{$vo.id}">
|
||||||
|
<td>{$vo.id}</td>
|
||||||
|
<td> {:str_repeat('|--',$vo.level)} {$vo.title}</td>
|
||||||
|
<td>
|
||||||
|
<div class="layui-btn-container">
|
||||||
|
<a class="layui-btn layui-btn-sm" href="{:url('edit',['id'=>$vo.id])}">编辑</a>
|
||||||
|
<div class="layui-btn layui-btn-sm delete">删除</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
{/volist}
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -39,5 +71,25 @@
|
|||||||
|
|
||||||
{include file="common/_footer"}
|
{include file="common/_footer"}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
|
||||||
|
$('.delete').click(function () {
|
||||||
|
var item = this;
|
||||||
|
layer.confirm('确定要删除吗?子分类将向上挪动一级', function () {
|
||||||
|
$.get('{:url("delete")}', {
|
||||||
|
id: $(item).parents('.item').data('id')
|
||||||
|
}, function (result) {
|
||||||
|
layer.msg('删除成功');
|
||||||
|
|
||||||
|
$(item).parents('.item').remove();
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<link rel="stylesheet" href="/static/css/reset.css">
|
<link rel="stylesheet" href="/static/css/reset.css">
|
||||||
<link rel="stylesheet" href="/static/css/pagination.css">
|
<link rel="stylesheet" href="/static/css/pagination.css">
|
||||||
<link rel="stylesheet" href="/static/lib/layui/css/layui.css">
|
<link rel="stylesheet" href="/static/lib/layui/css/layui.css">
|
||||||
<link rel="stylesheet" href="/static/css/{:cookie('skin-name','')}.css">
|
<link rel="stylesheet" href="/static/css/{$Request.cookie.skin_name|default='skin-0'}.css">
|
||||||
<link rel="stylesheet" href="/static/css/common.css">
|
<link rel="stylesheet" href="/static/css/common.css">
|
||||||
<script src="/static/lib/jquery/jquery-3.4.1.min.js"></script>
|
<script src="/static/lib/jquery/jquery-3.4.1.min.js"></script>
|
||||||
<script src="/static/lib/jquery/jquery.cookie.js"></script>
|
<script src="/static/lib/jquery/jquery.cookie.js"></script>
|
||||||
@@ -24,13 +24,13 @@
|
|||||||
, click: function (type) {
|
, click: function (type) {
|
||||||
console.log(type);
|
console.log(type);
|
||||||
if (type === 'bar1') {
|
if (type === 'bar1') {
|
||||||
var skinName = $.cookie('skin-name')
|
var skinName = $.cookie('skin_name')
|
||||||
$('body').removeClass()
|
$('body').removeClass()
|
||||||
if (skinName == 'skin-1') {
|
if (skinName == 'skin-1') {
|
||||||
$.cookie('skin-name', 'skin-0', defaultCookieSetting)
|
$.cookie('skin_name', 'skin-0', defaultCookieSetting)
|
||||||
$('body').addClass('skin-0')
|
$('body').addClass('skin-0')
|
||||||
} else {
|
} else {
|
||||||
$.cookie('skin-name', 'skin-1', defaultCookieSetting)
|
$.cookie('skin_name', 'skin-1', defaultCookieSetting)
|
||||||
$('body').addClass('skin-1')
|
$('body').addClass('skin-1')
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,13 @@
|
|||||||
var currentLeftNavItem = 'post';
|
var currentLeftNavItem = 'post';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
|
||||||
|
#toolbar select{
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body class="layui-layout-body">
|
<body class="layui-layout-body">
|
||||||
@@ -73,7 +79,7 @@
|
|||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<div id="toolbar">
|
<div id="toolbar">
|
||||||
<!-- Add font size dropdown -->
|
<!-- Add font size dropdown -->
|
||||||
<select class="ql-size" lay-ignore>
|
<select class="ql-size" lay-ignore="lay-ignore">
|
||||||
<option value="small">小号</option>
|
<option value="small">小号</option>
|
||||||
<!-- Note a missing, thus falsy value, is used to reset to default -->
|
<!-- Note a missing, thus falsy value, is used to reset to default -->
|
||||||
<option selected>正常</option>
|
<option selected>正常</option>
|
||||||
@@ -99,9 +105,9 @@
|
|||||||
<button class="ql-indent" value="-1"></button>
|
<button class="ql-indent" value="-1"></button>
|
||||||
<button class="ql-indent" value="+1"></button>
|
<button class="ql-indent" value="+1"></button>
|
||||||
<button class="ql-direction" value="rtl"></button>
|
<button class="ql-direction" value="rtl"></button>
|
||||||
<select class="ql-color" lay-ignore></select>
|
<select class="ql-color" lay-ignore="lay-ignore"></select>
|
||||||
<select class="ql-background" lay-ignore></select>
|
<select class="ql-background" lay-ignore="lay-ignore"></select>
|
||||||
<select class="ql-font" lay-ignore></select>
|
<select class="ql-font" lay-ignore="lay-ignore"></select>
|
||||||
<button class="ql-align" value="center"></button>
|
<button class="ql-align" value="center"></button>
|
||||||
<button class="ql-align" value=""></button>
|
<button class="ql-align" value=""></button>
|
||||||
<button class="ql-align" value="right"></button>
|
<button class="ql-align" value="right"></button>
|
||||||
@@ -141,27 +147,22 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<div class="layui-form-label">标签</div>
|
<div class="layui-form-label">分类</div>
|
||||||
<div class="layui-input-block ">
|
<div class="layui-input-block ">
|
||||||
<input type="checkbox" name="tags[]" value="0" title="高层" lay-skin="primary">
|
<div class="category-list"></div>
|
||||||
<br>
|
|
||||||
<input type="checkbox" name="tags[]" value="0" title="大" lay-skin="primary">
|
|
||||||
<br>
|
<div class="quick-input-item sm-quick-input-item">
|
||||||
<input type="checkbox" name="tags[]" value="0" title="PHP" lay-skin="primary">
|
<div class="new-category-option-list">
|
||||||
<br>
|
<select name="" lay-verify="">
|
||||||
<div class="quick-input-item sm-quick-input-item" title="输入新标签,使用空格分隔可一次添加多个标签" >
|
<option value="0">选择父分类</option>
|
||||||
<div>
|
|
||||||
<select name="city" lay-verify="">
|
|
||||||
<option value="">选择父分类</option>
|
|
||||||
<option value="010">北京</option>
|
|
||||||
<option value="021">上海</option>
|
|
||||||
<option value="0571">杭州</option>
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="">
|
<div class="">
|
||||||
|
|
||||||
<input type="text" name="" placeholder="输入新分类名称" id="newCategory" class="layui-input">
|
<input type="text" name="" placeholder="输入新分类名称" id="new-category" class="layui-input">
|
||||||
<div class="layui-btn">新增</div>
|
<div class="layui-btn create-category">新增</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -170,13 +171,13 @@
|
|||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<div class="layui-form-label">标签</div>
|
<div class="layui-form-label">标签</div>
|
||||||
<div class="layui-input-block ">
|
<div class="layui-input-block ">
|
||||||
<input type="checkbox" name="tags[]" value="0" title="高层" lay-skin="primary">
|
<div class="tag-list">
|
||||||
<input type="checkbox" name="tags[]" value="0" title="大" lay-skin="primary">
|
|
||||||
<input type="checkbox" name="tags[]" value="0" title="PHP" lay-skin="primary">
|
</div>
|
||||||
<div class="quick-input-item sm-quick-input-item" title="输入新标签,使用空格分隔可一次添加多个标签">
|
<div class="quick-input-item sm-quick-input-item" title="输入新标签,使用空格分隔可一次添加多个标签">
|
||||||
<div class="">
|
<div class="">
|
||||||
<input type="text" name="" placeholder="输入新标签" id="newTags" class="layui-input">
|
<input type="text" name="" placeholder="输入新标签" autocomplete="off" id="new-tags" class="layui-input">
|
||||||
<div class="layui-btn">新增</div>
|
<div class="layui-btn create-tags">新增</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -224,13 +225,29 @@
|
|||||||
|
|
||||||
|
|
||||||
{include file="common/_footer"}
|
{include file="common/_footer"}
|
||||||
|
|
||||||
|
<div class="tpl" style="display: none;">
|
||||||
|
<input type="checkbox" name="tags[]" class="tag-item" value="0" title="高层" lay-skin="primary">
|
||||||
|
<div class="category-item">
|
||||||
|
<input type="checkbox" name="categorys[]" value="0" title="PHP" lay-skin="primary">
|
||||||
|
</div>
|
||||||
|
<option value="0" class="new-category-item">选择父分类</option>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
layui.use(['form', 'upload'], function () {
|
layui.use(['form', 'upload','laydate'], function () {
|
||||||
var upload = layui.upload;
|
var upload = layui.upload;
|
||||||
var form = layui.form;
|
var form = layui.form;
|
||||||
|
var laydate = layui.laydate;
|
||||||
|
|
||||||
|
laydate.render({
|
||||||
|
elem:'.publish-time',
|
||||||
|
type:'datetime'
|
||||||
|
})
|
||||||
|
|
||||||
var currentRange = {
|
var currentRange = {
|
||||||
index: 0,
|
index: 0,
|
||||||
@@ -312,7 +329,6 @@
|
|||||||
|
|
||||||
form.on('submit(save)', function (data) {
|
form.on('submit(save)', function (data) {
|
||||||
|
|
||||||
|
|
||||||
var formData = data.field;
|
var formData = data.field;
|
||||||
|
|
||||||
formData.content = quill.getContents().ops
|
formData.content = quill.getContents().ops
|
||||||
@@ -320,10 +336,114 @@
|
|||||||
|
|
||||||
console.log(formData);
|
console.log(formData);
|
||||||
|
|
||||||
|
$.post('{:url("save")}',formData,function(result){
|
||||||
|
console.log(result);
|
||||||
|
layer.msg('添加成功')
|
||||||
|
setTimeout(() => {
|
||||||
|
location.href = result.data.jump_to_url
|
||||||
|
}, 1200);
|
||||||
|
})
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
})
|
})
|
||||||
|
var tagPage = 1;
|
||||||
|
initTags()
|
||||||
|
function initTags() {
|
||||||
|
$('.tag-list').children().remove()
|
||||||
|
$('#new-tags').val('')
|
||||||
|
tagPage = 1;
|
||||||
|
loadTags()
|
||||||
|
}
|
||||||
|
function loadTags() {
|
||||||
|
$.get('{:url("Tag/index")}', {
|
||||||
|
page: tagPage
|
||||||
|
}, function (result) {
|
||||||
|
tagPage++;
|
||||||
|
result.data.data.forEach(tag => {
|
||||||
|
var domTag = $('.tpl .tag-item').clone();
|
||||||
|
domTag.attr('title', tag.title)
|
||||||
|
domTag.val(tag.id)
|
||||||
|
domTag.appendTo('.tag-list')
|
||||||
|
});
|
||||||
|
form.render('checkbox')
|
||||||
|
if (result.data.current_page < result.data.last_page) {
|
||||||
|
loadTags()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
$('.create-tags').click(function () {
|
||||||
|
var value = $.trim($('#new-tags').val());
|
||||||
|
|
||||||
|
if(value.length == 0){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$.post('{:url("Tag/save")}', {
|
||||||
|
tags: value
|
||||||
|
}, function (result) {
|
||||||
|
layer.msg('添加成功')
|
||||||
|
initTags()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
var categoryPage = 1;
|
||||||
|
initCategory();
|
||||||
|
function initCategory(){
|
||||||
|
$('.category-list').children().remove();
|
||||||
|
$('.new-category-option-list').find('.new-category-item').remove();
|
||||||
|
$('.new-category-option-list').find('.layui-form-select').remove();
|
||||||
|
$('#new-category').val('')
|
||||||
|
categoryPage = 1;
|
||||||
|
loadCategory()
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadCategory() {
|
||||||
|
$.get('{:url("Category/index")}',function(result){
|
||||||
|
console.log(result);
|
||||||
|
result.data.forEach(category => {
|
||||||
|
var prefix = '';
|
||||||
|
for (let prefixLevelIndex = 0; prefixLevelIndex < category.level; prefixLevelIndex++) {
|
||||||
|
prefix += '|--'
|
||||||
|
|
||||||
|
}
|
||||||
|
var domCategory = $('.tpl .category-item').clone();
|
||||||
|
|
||||||
|
domCategory.find('input').val(category.id)
|
||||||
|
domCategory.find('input').attr('title', prefix+category.title)
|
||||||
|
|
||||||
|
domCategory.appendTo('.category-list')
|
||||||
|
|
||||||
|
var domNewCategory = $('.tpl .new-category-item').clone();
|
||||||
|
|
||||||
|
domNewCategory.text(prefix+category.title)
|
||||||
|
domNewCategory.val(category.id)
|
||||||
|
domNewCategory.attr('title',category.title)
|
||||||
|
|
||||||
|
domNewCategory.appendTo('.new-category-option-list select')
|
||||||
|
|
||||||
|
});
|
||||||
|
form.render()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
$('.create-category').click(function(){
|
||||||
|
var pid = $('.new-category-option-list').find('select').val();
|
||||||
|
var title = $('#new-category').val()
|
||||||
|
|
||||||
|
$.post('{:url("Category/save")}',{
|
||||||
|
title:title,
|
||||||
|
pid:pid
|
||||||
|
},function(result){
|
||||||
|
if(result.code == 0){
|
||||||
|
layer.msg('添加成功')
|
||||||
|
initCategory();
|
||||||
|
}else{
|
||||||
|
layer.msg(result.msg)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
475
view/admin/post/edit.html
Normal file
475
view/admin/post/edit.html
Normal file
@@ -0,0 +1,475 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
|
<title>文章编辑</title>
|
||||||
|
{include file="common/_require"}
|
||||||
|
<link rel="stylesheet" href="/static/lib/quill/quill.snow.css">
|
||||||
|
<script src="/static/lib/quill/quill.min.js"></script>
|
||||||
|
<script>
|
||||||
|
var currentHeaderNavItem = 'Post';
|
||||||
|
var currentLeftNavItem = 'post';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
#toolbar select {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body class="layui-layout-body">
|
||||||
|
|
||||||
|
<div class="layui-layout layui-layout-admin">
|
||||||
|
{include file="common/_header"}
|
||||||
|
|
||||||
|
{include file="common/left_post"}
|
||||||
|
|
||||||
|
<div class="layui-body">
|
||||||
|
|
||||||
|
<div style="padding:15px">
|
||||||
|
<div class="main-header">
|
||||||
|
<span class="layui-breadcrumb">
|
||||||
|
<a>首页</a>
|
||||||
|
<a><cite>文章编辑</cite></a>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="main-container">
|
||||||
|
<div class="layui-row">
|
||||||
|
<form action="{:url('update')}" method="POST" class="layui-form" lay-filter="*">
|
||||||
|
<input type="hidden" name="id" value="{$post.id}">
|
||||||
|
<div class="layui-col-md9 layui-col-lg10">
|
||||||
|
<fieldset class="layui-elem-field">
|
||||||
|
<legend>编辑</legend>
|
||||||
|
<div class="layui-field-box">
|
||||||
|
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<div class="layui-form-label">标题</div>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" name="title" required lay-verify="required" value="{$post->title}"
|
||||||
|
class="layui-input">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<div class="layui-form-label">封面</div>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="hidden" name="poster" value="{$post->getData('poster')}">
|
||||||
|
<div>
|
||||||
|
<div class="layui-btn upload-poster">上传</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<img src="{$post->poster}" class="poster" style="max-width: 200px;max-height: 200px;;" alt="">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<div class="layui-form-label">描述</div>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<textarea name="desc" class="layui-textarea">{$post->getData('desc')}</textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<div class="layui-form-label">内容</div>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<div id="toolbar">
|
||||||
|
<!-- Add font size dropdown -->
|
||||||
|
<select class="ql-size" lay-ignore="lay-ignore">
|
||||||
|
<option value="small">小号</option>
|
||||||
|
<!-- Note a missing, thus falsy value, is used to reset to default -->
|
||||||
|
<option selected>正常</option>
|
||||||
|
<option value="large">大号</option>
|
||||||
|
<option value="huge">特大号</option>
|
||||||
|
</select>
|
||||||
|
<!-- Add a bold button -->
|
||||||
|
<button class="ql-bold"></button>
|
||||||
|
<button class="ql-italic"></button>
|
||||||
|
<button class="ql-link"></button>
|
||||||
|
<button class="ql-underline"></button>
|
||||||
|
<button class="ql-strike"></button>
|
||||||
|
<button class="ql-blockquote"></button>
|
||||||
|
<button class="ql-code-block"></button>
|
||||||
|
<button class="ql-header" value="1" title="大标题"></button>
|
||||||
|
<button class="ql-header" value="2" title="小标题"></button>
|
||||||
|
<button class="ql-list" value="ordered" title="有序列表"></button>
|
||||||
|
<button class="ql-list" value="bullet" title="无序列表"></button>
|
||||||
|
|
||||||
|
<!-- Add subscript and superscript buttons -->
|
||||||
|
<button class="ql-script" value="sub"></button>
|
||||||
|
<button class="ql-script" value="super"></button>
|
||||||
|
<button class="ql-indent" value="-1"></button>
|
||||||
|
<button class="ql-indent" value="+1"></button>
|
||||||
|
<button class="ql-direction" value="rtl"></button>
|
||||||
|
<select class="ql-color" lay-ignore="lay-ignore"></select>
|
||||||
|
<select class="ql-background" lay-ignore="lay-ignore"></select>
|
||||||
|
<select class="ql-font" lay-ignore="lay-ignore"></select>
|
||||||
|
<button class="ql-align" value="center"></button>
|
||||||
|
<button class="ql-align" value=""></button>
|
||||||
|
<button class="ql-align" value="right"></button>
|
||||||
|
<button class="ql-align" value="justify"></button>
|
||||||
|
<button class="ql-image" title="选择图片"></button>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div id="editor" style="height: 600px;">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div id="content" style="display: none;">{:json_encode($post->content)}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<button class="layui-btn layui-btn-fluid" type="submit" lay-submit lay-filter="save">保存</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-md3 layui-col-lg2">
|
||||||
|
<fieldset class="layui-elem-field sm-form">
|
||||||
|
<legend>信息</legend>
|
||||||
|
<div class="layui-field-box">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<div class="layui-form-label">状态</div>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="radio" name="status" value="1" title="发布">
|
||||||
|
<input type="radio" name="status" value="0" title="不发布">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<div class="layui-form-label">发表时间</div>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" name="publish_time" value="{$post->publish_time}"
|
||||||
|
class="layui-input publish-time">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<div class="layui-form-label">分类</div>
|
||||||
|
<div class="layui-input-block ">
|
||||||
|
<div class="category-list"></div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="quick-input-item sm-quick-input-item">
|
||||||
|
<div class="new-category-option-list">
|
||||||
|
<select name="" lay-verify="">
|
||||||
|
<option value="0">选择父分类</option>
|
||||||
|
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="">
|
||||||
|
|
||||||
|
<input type="text" name="" placeholder="输入新分类名称" id="new-category" class="layui-input">
|
||||||
|
<div class="layui-btn create-category">新增</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<div class="layui-form-label">标签</div>
|
||||||
|
<div class="layui-input-block ">
|
||||||
|
<div class="tag-list">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="quick-input-item sm-quick-input-item" title="输入新标签,使用空格分隔可一次添加多个标签">
|
||||||
|
<div class="">
|
||||||
|
<input type="text" name="" placeholder="输入新标签" autocomplete="off" id="new-tags"
|
||||||
|
class="layui-input">
|
||||||
|
<div class="layui-btn create-tags">新增</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<div class="layui-form-label">是否置顶</div>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="radio" name="is_top" value="1" title="置顶">
|
||||||
|
<input type="radio" name="is_top" value="0" title="不置顶">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<div class="layui-form-label">跳转链接</div>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" name="jump_to_url" value="{$post->getData('jump_to_url')}"
|
||||||
|
class="layui-input">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<div class="layui-form-label">跳转链接状态</div>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="radio" name="jump_to_url_status" value="0" title="不显示">
|
||||||
|
<input type="radio" name="jump_to_url_status" value="1" title="仅显示">
|
||||||
|
<input type="radio" name="jump_to_url_status" value="2" title="自动跳转">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<div class="layui-form-label">排序</div>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="number" name="sort" value="{$post->getData('sort')}" class="layui-input">
|
||||||
|
<div class="layui-form-mid layui-word-aux">越大越靠前</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
{include file="common/_footer"}
|
||||||
|
|
||||||
|
<div class="tpl" style="display: none;">
|
||||||
|
<input type="checkbox" name="tags[]" class="tag-item" value="0" title="高层" lay-skin="primary">
|
||||||
|
<div class="category-item">
|
||||||
|
<input type="checkbox" name="categorys[]" value="0" title="PHP" lay-skin="primary">
|
||||||
|
</div>
|
||||||
|
<option value="0" class="new-category-item">选择父分类</option>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var categoryList = JSON.parse('{:json_encode($post->categorys->column("category_id"))}')
|
||||||
|
var tagList = JSON.parse('{:json_encode($post->tags->column("tag_id"))}')
|
||||||
|
layui.use(['form', 'upload', 'laydate'], function () {
|
||||||
|
var upload = layui.upload;
|
||||||
|
var form = layui.form;
|
||||||
|
var laydate = layui.laydate;
|
||||||
|
|
||||||
|
laydate.render({
|
||||||
|
elem: '.publish-time',
|
||||||
|
type: 'datetime'
|
||||||
|
})
|
||||||
|
|
||||||
|
var currentRange = {
|
||||||
|
index: 0,
|
||||||
|
lenght: 0
|
||||||
|
}
|
||||||
|
var quill = new Quill('#editor', {
|
||||||
|
theme: 'snow',
|
||||||
|
modules: {
|
||||||
|
toolbar: '#toolbar',
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
quill.setContents(JSON.parse($('#content').text()))
|
||||||
|
|
||||||
|
|
||||||
|
quill.on('selection-change', function (range, oldRange, source) {
|
||||||
|
if (range) {
|
||||||
|
if (range.length == 0) {
|
||||||
|
console.log('User cursor is on', range.index);
|
||||||
|
} else {
|
||||||
|
var text = quill.getText(range.index, range.length);
|
||||||
|
console.log('User has highlighted', text);
|
||||||
|
}
|
||||||
|
currentRange = range;
|
||||||
|
console.log(currentRange);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
console.log('Cursor not in the editor');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
quill.on('text-change', function (delta, oldDelta, source) {
|
||||||
|
|
||||||
|
if (source == 'api') {
|
||||||
|
console.log("An API call triggered this change.");
|
||||||
|
} else if (source == 'user') {
|
||||||
|
console.log("A user action triggered this change.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
upload.render({
|
||||||
|
elem: '.ql-image',
|
||||||
|
url: '{:url("api/Files/save")}',
|
||||||
|
data: {
|
||||||
|
type: 4,
|
||||||
|
dir: 'article'
|
||||||
|
},
|
||||||
|
accept: 'images',
|
||||||
|
done: function (result) {
|
||||||
|
if (result.code == 0) {
|
||||||
|
layer.msg('上传成功');
|
||||||
|
quill.insertEmbed(++currentRange.index, 'image', result.data.src);
|
||||||
|
} else {
|
||||||
|
layer.msg(result.msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
upload.render({
|
||||||
|
elem: '.upload-poster',
|
||||||
|
url: '{:url("api/Files/save")}',
|
||||||
|
data: {
|
||||||
|
type: 4,
|
||||||
|
dir: 'article'
|
||||||
|
},
|
||||||
|
accept: 'images',
|
||||||
|
done: function (result) {
|
||||||
|
if (result.code == 0) {
|
||||||
|
layer.msg('上传成功');
|
||||||
|
$('input[name="poster"]').val(result.data.save_name)
|
||||||
|
$('.poster').attr('src', result.data.src).show();
|
||||||
|
} else {
|
||||||
|
layer.msg(result.msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
var toolbar = quill.getModule('toolbar');
|
||||||
|
toolbar.addHandler('image', function () {
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
form.val('*', {
|
||||||
|
status: '{$post->getData("status")}',
|
||||||
|
is_top: '{$post->getData("is_top")}',
|
||||||
|
jump_to_url_status: '{$post->getData("jump_to_url_status")}',
|
||||||
|
})
|
||||||
|
|
||||||
|
form.on('submit(save)', function (data) {
|
||||||
|
|
||||||
|
var formData = data.field;
|
||||||
|
|
||||||
|
formData.content = quill.getContents().ops
|
||||||
|
formData.content_html = $('#editor .ql-editor').html()
|
||||||
|
|
||||||
|
console.log(formData);
|
||||||
|
|
||||||
|
$.post('{:url("update")}', formData, function (result) {
|
||||||
|
|
||||||
|
layer.msg('添加成功')
|
||||||
|
setTimeout(() => {
|
||||||
|
location.href = result.data.jump_to_url
|
||||||
|
}, 1200);
|
||||||
|
})
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
})
|
||||||
|
var tagPage = 1;
|
||||||
|
initTags()
|
||||||
|
function initTags() {
|
||||||
|
$('.tag-list').children().remove()
|
||||||
|
$('#new-tags').val('')
|
||||||
|
tagPage = 1;
|
||||||
|
loadTags()
|
||||||
|
}
|
||||||
|
function loadTags() {
|
||||||
|
$.get('{:url("Tag/index")}', {
|
||||||
|
page: tagPage
|
||||||
|
}, function (result) {
|
||||||
|
tagPage++;
|
||||||
|
result.data.data.forEach(tag => {
|
||||||
|
var domTag = $('.tpl .tag-item').clone();
|
||||||
|
domTag.attr('title', tag.title)
|
||||||
|
domTag.val(tag.id)
|
||||||
|
if (tagList.indexOf(tag.id) >= 0) {
|
||||||
|
domTag.attr('checked', 'checked')
|
||||||
|
}
|
||||||
|
domTag.appendTo('.tag-list')
|
||||||
|
});
|
||||||
|
form.render('checkbox')
|
||||||
|
if (result.data.current_page < result.data.last_page) {
|
||||||
|
loadTags()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
$('.create-tags').click(function () {
|
||||||
|
var value = $.trim($('#new-tags').val());
|
||||||
|
|
||||||
|
if (value.length == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$.post('{:url("Tag/save")}', {
|
||||||
|
tags: value
|
||||||
|
}, function (result) {
|
||||||
|
layer.msg('添加成功')
|
||||||
|
initTags()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
var categoryPage = 1;
|
||||||
|
initCategory();
|
||||||
|
function initCategory() {
|
||||||
|
$('.category-list').children().remove();
|
||||||
|
$('.new-category-option-list').find('.new-category-item').remove();
|
||||||
|
$('.new-category-option-list').find('.layui-form-select').remove();
|
||||||
|
$('#new-category').val('')
|
||||||
|
categoryPage = 1;
|
||||||
|
loadCategory()
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadCategory() {
|
||||||
|
$.get('{:url("Category/index")}', function (result) {
|
||||||
|
|
||||||
|
result.data.forEach(category => {
|
||||||
|
var prefix = '';
|
||||||
|
for (let prefixLevelIndex = 0; prefixLevelIndex < category.level; prefixLevelIndex++) {
|
||||||
|
prefix += '|--'
|
||||||
|
|
||||||
|
}
|
||||||
|
var domCategory = $('.tpl .category-item').clone();
|
||||||
|
|
||||||
|
domCategory.find('input').val(category.id)
|
||||||
|
domCategory.find('input').attr('title', prefix + category.title)
|
||||||
|
|
||||||
|
if (categoryList.indexOf(category.id) >= 0) {
|
||||||
|
|
||||||
|
domCategory.find('input').attr('checked', 'checked')
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
domCategory.appendTo('.category-list')
|
||||||
|
|
||||||
|
var domNewCategory = $('.tpl .new-category-item').clone();
|
||||||
|
|
||||||
|
domNewCategory.text(prefix + category.title)
|
||||||
|
domNewCategory.val(category.id)
|
||||||
|
domNewCategory.attr('title', category.title)
|
||||||
|
|
||||||
|
domNewCategory.appendTo('.new-category-option-list select')
|
||||||
|
|
||||||
|
});
|
||||||
|
form.render()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
$('.create-category').click(function () {
|
||||||
|
var pid = $('.new-category-option-list').find('select').val();
|
||||||
|
var title = $('#new-category').val()
|
||||||
|
|
||||||
|
$.post('{:url("Category/save")}', {
|
||||||
|
title: title,
|
||||||
|
pid: pid
|
||||||
|
}, function (result) {
|
||||||
|
if (result.code == 0) {
|
||||||
|
layer.msg('添加成功')
|
||||||
|
initCategory();
|
||||||
|
} else {
|
||||||
|
layer.msg(result.msg)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -43,6 +43,7 @@
|
|||||||
<th>名称</th>
|
<th>名称</th>
|
||||||
<th>封面</th>
|
<th>封面</th>
|
||||||
<th>简介</th>
|
<th>简介</th>
|
||||||
|
<th>排序</th>
|
||||||
<th>操作</th>
|
<th>操作</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -53,7 +54,8 @@
|
|||||||
<td>{$vo.id}</td>
|
<td>{$vo.id}</td>
|
||||||
<td>{$vo.title}</td>
|
<td>{$vo.title}</td>
|
||||||
|
|
||||||
<td>{$vo.value}</td>
|
<td><img src="{$vo.poster}" alt=""></td>
|
||||||
|
<td>{$vo.desc}</td>
|
||||||
<td>{$vo.sort}</td>
|
<td>{$vo.sort}</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="layui-btn-container">
|
<div class="layui-btn-container">
|
||||||
|
|||||||
131
view/admin/tag/index.html
Normal file
131
view/admin/tag/index.html
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
|
<title>标签管理</title>
|
||||||
|
{include file="common/_require"}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var currentHeaderNavItem = 'Post';
|
||||||
|
var currentLeftNavItem = 'tag';
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body class="layui-layout-body">
|
||||||
|
|
||||||
|
<div class="layui-layout layui-layout-admin">
|
||||||
|
{include file="common/_header"}
|
||||||
|
|
||||||
|
{include file="common/left_post"}
|
||||||
|
|
||||||
|
<div class="layui-body">
|
||||||
|
|
||||||
|
<div style="padding:15px">
|
||||||
|
<div class="main-header">
|
||||||
|
<span class="layui-breadcrumb">
|
||||||
|
<a>首页</a>
|
||||||
|
<a><cite>系统信息</cite></a>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="main-container">
|
||||||
|
<div>
|
||||||
|
<div class="layui-btn create">新增</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<table class="layui-table">
|
||||||
|
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>名称</th>
|
||||||
|
<th>操作</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
{volist name="list" id="vo"}
|
||||||
|
<tr class="item" data-id="{$vo.id}">
|
||||||
|
<td>{$vo.id}</td>
|
||||||
|
<td> {:str_repeat('|--',$vo.level)} <span class="tag-name">{$vo.title}</span></td>
|
||||||
|
<td>
|
||||||
|
<div class="layui-btn-container">
|
||||||
|
<div class="layui-btn layui-btn-sm edit" data-href="{:url('update',['id'=>$vo.id])}">编辑</div>
|
||||||
|
<div class="layui-btn layui-btn-sm delete">删除</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
{/volist}
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<div>
|
||||||
|
{$list|raw}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
{include file="common/_footer"}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
|
||||||
|
$('.delete').click(function () {
|
||||||
|
var item = this;
|
||||||
|
layer.confirm('确定要删除吗?', function () {
|
||||||
|
$.get('{:url("delete")}', {
|
||||||
|
id: $(item).parents('.item').data('id')
|
||||||
|
}, function (result) {
|
||||||
|
layer.msg('删除成功');
|
||||||
|
|
||||||
|
$(item).parents('.item').remove();
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
$('.create').click(function () {
|
||||||
|
layer.prompt({
|
||||||
|
title: '请输入标签,空格分隔可添加多个'
|
||||||
|
}, function (value, index) {
|
||||||
|
$.post('{:url("save")}', {
|
||||||
|
tags: value
|
||||||
|
}, function (result) {
|
||||||
|
layer.msg('添加成功')
|
||||||
|
setTimeout(() => {
|
||||||
|
location.reload()
|
||||||
|
}, 1200);
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
$('.edit').click(function(){
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
layer.prompt({
|
||||||
|
title:'请输入标签,空格无效',
|
||||||
|
value:$(self).parents('.item').find('.tag-name').text()
|
||||||
|
},function(value,index){
|
||||||
|
$.post($(self).data('href'),{
|
||||||
|
title:value
|
||||||
|
},function(result){
|
||||||
|
layer.msg('修改成功');
|
||||||
|
|
||||||
|
$(self).parents('.item').find('.tag-name').text(value)
|
||||||
|
layer.close(index)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user