后端增加资源发布功能
This commit is contained in:
parent
fff1a1cb3f
commit
02b21dcc6d
414
app/admin/controller/Resources.php
Normal file
414
app/admin/controller/Resources.php
Normal file
@ -0,0 +1,414 @@
|
||||
<?php
|
||||
/**
|
||||
* 后台管理系统-资源管理
|
||||
*/
|
||||
namespace app\admin\controller;
|
||||
use app\admin\controller\Base;
|
||||
use think\facade\Db;
|
||||
use think\facade\View;
|
||||
use think\facade\Request;
|
||||
|
||||
class Resources extends Base
|
||||
{
|
||||
// 资源列表
|
||||
public function lists()
|
||||
{
|
||||
if (Request::isPost()) {
|
||||
$category = input('post.category');
|
||||
$page = input('post.page', 1);
|
||||
$limit = input('post.limit', 10);
|
||||
$name = input('post.name');
|
||||
$uploader = input('post.uploader');
|
||||
|
||||
$query = Db::table('yz_resources')
|
||||
->where('delete_time', null)
|
||||
->where('status', '<>', 3);
|
||||
|
||||
// 分类筛选
|
||||
if (!empty($category)) {
|
||||
// 先获取分类ID
|
||||
$cateInfo = Db::table('yz_resources_category')
|
||||
->where('name', $category)
|
||||
->where('delete_time', null)
|
||||
->where('status', 1)
|
||||
->find();
|
||||
|
||||
if ($cateInfo) {
|
||||
$query = $query->where('cate', $cateInfo['id']);
|
||||
}
|
||||
}
|
||||
|
||||
// 名称搜索
|
||||
if (!empty($name)) {
|
||||
$query = $query->where('name', 'like', '%'.$name.'%');
|
||||
}
|
||||
|
||||
// 上传者搜索
|
||||
if (!empty($uploader)) {
|
||||
$query = $query->where('uploader', 'like', '%'.$uploader.'%');
|
||||
}
|
||||
|
||||
// 获取总记录数
|
||||
$count = $query->count();
|
||||
|
||||
// 获取分页数据
|
||||
$lists = $query->order('id DESC')
|
||||
->page($page, $limit)
|
||||
->select()
|
||||
->each(function ($item) {
|
||||
// 获取分类信息
|
||||
$cateInfo = Db::table('yz_resources_category')
|
||||
->where('id', $item['cate'])
|
||||
->field('name, icon')
|
||||
->find();
|
||||
|
||||
// 设置分类名称
|
||||
$item['cate'] = $cateInfo['name'];
|
||||
|
||||
// 如果资源没有图标,使用分类的图标
|
||||
if (empty($item['icon']) && !empty($cateInfo['icon'])) {
|
||||
$item['icon'] = $cateInfo['icon'];
|
||||
}
|
||||
|
||||
// 格式化时间
|
||||
$item['create_time'] = date('Y-m-d H:i:s', $item['create_time']);
|
||||
$item['upload_time'] = $item['upload_time'] ? date('Y-m-d H:i:s', $item['upload_time']) : '';
|
||||
|
||||
return $item;
|
||||
});
|
||||
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => '获取成功',
|
||||
'count' => $count,
|
||||
'data' => $lists
|
||||
]);
|
||||
} else {
|
||||
// 获取所有分类并构建父子结构
|
||||
$allCategories = Db::table('yz_resources_category')
|
||||
->where('delete_time', null)
|
||||
->where('status', 1)
|
||||
->order('sort asc, id asc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$categories = [];
|
||||
foreach ($allCategories as $category) {
|
||||
if ($category['cid'] == 0) {
|
||||
$category['children'] = [];
|
||||
foreach ($allCategories as $subCategory) {
|
||||
if ($subCategory['cid'] == $category['id']) {
|
||||
$category['children'][] = $subCategory;
|
||||
}
|
||||
}
|
||||
$categories[] = $category;
|
||||
}
|
||||
}
|
||||
|
||||
View::assign([
|
||||
'categories' => $categories
|
||||
]);
|
||||
return View::fetch();
|
||||
}
|
||||
}
|
||||
|
||||
// 添加资源
|
||||
public function add()
|
||||
{
|
||||
if (Request::isPost()) {
|
||||
$data = [
|
||||
'name' => input('post.name'),
|
||||
'cate' => input('post.cate'),
|
||||
'icon' => input('post.icon'),
|
||||
'url' => input('post.url'),
|
||||
'code' => input('post.code'),
|
||||
'uploader' => input('post.uploader'),
|
||||
'desc' => input('post.desc'),
|
||||
'status' => input('post.status', 2),
|
||||
'upload_time' => time(),
|
||||
'create_time' => time()
|
||||
];
|
||||
|
||||
$insert = Db::table('yz_resources')->insert($data);
|
||||
if (empty($insert)) {
|
||||
return json(['code' => 1, 'msg' => '添加失败', 'data' => []]);
|
||||
}
|
||||
return json(['code' => 0, 'msg' => '添加成功', 'data' => []]);
|
||||
} else {
|
||||
$lists = Db::table('yz_resources')
|
||||
->order('id DESC')
|
||||
->select()
|
||||
->each(function ($item, $key) {
|
||||
$item['create_time'] = time();
|
||||
return $item;
|
||||
});
|
||||
View::assign([
|
||||
'lists' => $lists
|
||||
]);
|
||||
return View::fetch();
|
||||
}
|
||||
}
|
||||
|
||||
// 编辑资源
|
||||
public function edit()
|
||||
{
|
||||
if (Request::isPost()) {
|
||||
$id = input('get.id');
|
||||
$data = [
|
||||
'name' => input('post.name'),
|
||||
'cate' => input('post.cate'),
|
||||
'icon' => input('post.icon'),
|
||||
'url' => input('post.url'),
|
||||
'code' => input('post.code'),
|
||||
'uploader' => input('post.uploader'),
|
||||
'desc' => input('post.desc'),
|
||||
'status' => input('post.status', 2),
|
||||
'update_time' => time()
|
||||
];
|
||||
|
||||
$update = Db::table('yz_resources')->where('id', $id)->update($data);
|
||||
return json(['code' => $update === false ? 1 : 0, 'msg' => $update === false ? '更新失败' : '更新成功', 'data' => []]);
|
||||
} else {
|
||||
$id = input('get.id');
|
||||
$info = Db::table('yz_resources')->where('id', $id)->find();
|
||||
if ($info === null) {
|
||||
return json(['code' => 1, 'msg' => '资源不存在', 'data' => []]);
|
||||
}
|
||||
|
||||
$cates = Db::table('yz_resources_category')
|
||||
->where('delete_time', null)
|
||||
->where('status', 1)
|
||||
->order('sort asc, id asc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$currentCate = Db::table('yz_resources_category')
|
||||
->where('id', $info['cate'])
|
||||
->where('delete_time', null)
|
||||
->where('status', 1)
|
||||
->find();
|
||||
$info['cate_name'] = $currentCate ? $currentCate['name'] : '';
|
||||
|
||||
View::assign([
|
||||
'info' => $info,
|
||||
'cates' => $cates
|
||||
]);
|
||||
return View::fetch();
|
||||
}
|
||||
}
|
||||
|
||||
// 删除资源
|
||||
public function delete()
|
||||
{
|
||||
$id = input('post.id');
|
||||
$data = [
|
||||
'delete_time' => time(),
|
||||
];
|
||||
$delete = Db::table('yz_resources')->where('id', $id)->update($data);
|
||||
if ($delete === false) {
|
||||
return json(['code' => 1, 'msg' => '删除失败', 'data' => []]);
|
||||
}
|
||||
return json(['code' => 0, 'msg' => '删除成功', 'data' => []]);
|
||||
}
|
||||
|
||||
// 资源分类
|
||||
public function cate()
|
||||
{
|
||||
if (Request::isPost()) {
|
||||
$lists = Db::table('yz_resources_category')
|
||||
->where('delete_time', null)
|
||||
->where('status', 1)
|
||||
->order('sort asc, id asc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
// 构建树形结构
|
||||
$tree = [];
|
||||
foreach ($lists as $item) {
|
||||
if ($item['cid'] == 0) {
|
||||
$node = [
|
||||
'id' => $item['id'],
|
||||
'title' => $item['name'],
|
||||
'children' => []
|
||||
];
|
||||
|
||||
// 查找子分类
|
||||
foreach ($lists as $subItem) {
|
||||
if ($subItem['cid'] == $item['id']) {
|
||||
$node['children'][] = [
|
||||
'id' => $subItem['id'],
|
||||
'title' => $subItem['name'],
|
||||
'children' => []
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$tree[] = $node;
|
||||
}
|
||||
}
|
||||
|
||||
return json(['code' => 0, 'msg' => '获取成功', 'data' => $tree]);
|
||||
}
|
||||
|
||||
// 非 POST 请求返回视图
|
||||
return View::fetch();
|
||||
}
|
||||
|
||||
//获取分类结构
|
||||
public function getcate()
|
||||
{
|
||||
// 获取所有分类
|
||||
$lists = Db::table('yz_resources_category')
|
||||
->where('delete_time', null)
|
||||
->where('status', 1)
|
||||
->order('sort asc, id asc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
// 构建父子结构
|
||||
$tree = [];
|
||||
foreach ($lists as $item) {
|
||||
if ($item['cid'] == 0) {
|
||||
// 顶级分类
|
||||
$tree[] = $item;
|
||||
} else {
|
||||
// 子分类
|
||||
foreach ($tree as &$parent) {
|
||||
if ($parent['id'] == $item['cid']) {
|
||||
if (!isset($parent['children'])) {
|
||||
$parent['children'] = [];
|
||||
}
|
||||
$parent['children'][] = $item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return json(['code' => 0, 'msg' => '获取成功', 'data' => $tree]);
|
||||
}
|
||||
|
||||
// 添加资源分类
|
||||
public function cateadd()
|
||||
{
|
||||
if (Request::isPost()) {
|
||||
$data = [
|
||||
'name' => input('post.name'),
|
||||
'icon' => input('post.icon'),
|
||||
'cid' => input('post.cid'),
|
||||
'sort' => input('post.sort', 0),
|
||||
'status' => input('post.status', 1),
|
||||
'create_time' => time()
|
||||
];
|
||||
|
||||
$insert = Db::table('yz_resources_category')->insert($data);
|
||||
if (empty($insert)) {
|
||||
return json(['code' => 1, 'msg' => '添加失败', 'data' => []]);
|
||||
}
|
||||
return json(['code' => 0, 'msg' => '添加成功', 'data' => []]);
|
||||
} else {
|
||||
// 获取所有可选的父级分类
|
||||
$parentCategories = Db::table('yz_resources_category')
|
||||
->where('delete_time', null)
|
||||
->where('status', 1)
|
||||
->where('cid', 0)
|
||||
->field('id, name')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => '获取成功',
|
||||
'data' => [
|
||||
'parentOptions' => $parentCategories
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
//编辑资源分类
|
||||
public function cateedit()
|
||||
{
|
||||
if (Request::isPost()) {
|
||||
$data = [
|
||||
'id' => input('post.id'),
|
||||
'name' => input('post.name'),
|
||||
'icon' => input('post.icon'),
|
||||
'cid' => input('post.cid'),
|
||||
'sort' => input('post.sort', 0),
|
||||
'status' => input('post.status', 1),
|
||||
'update_time' => time()
|
||||
];
|
||||
|
||||
$update = Db::table('yz_resources_category')
|
||||
->where('id', $data['id'])
|
||||
->update($data);
|
||||
|
||||
if ($update === false) {
|
||||
return json(['code' => 1, 'msg' => '更新失败', 'data' => []]);
|
||||
}
|
||||
return json(['code' => 0, 'msg' => '更新成功', 'data' => []]);
|
||||
} else {
|
||||
$id = input('get.id');
|
||||
$info = Db::table('yz_resources_category')->where('id', $id)->find();
|
||||
|
||||
// 获取所有可选的父级分类
|
||||
$parentCategories = Db::table('yz_resources_category')
|
||||
->where('delete_time', null)
|
||||
->where('status', 1)
|
||||
->where('id', '<>', $id) // 排除自己
|
||||
->where(function ($query) use ($id) {
|
||||
// 排除自己的所有子分类
|
||||
$query->where('cid', '<>', $id);
|
||||
})
|
||||
->field('id, name, cid')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
// 构建父级分类选项
|
||||
$parentOptions = [];
|
||||
foreach ($parentCategories as $category) {
|
||||
if ($category['cid'] == 0) {
|
||||
$parentOptions[] = [
|
||||
'id' => $category['id'],
|
||||
'name' => $category['name']
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => '获取成功',
|
||||
'data' => [
|
||||
'info' => $info,
|
||||
'parentOptions' => $parentOptions
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
//删除资源分类
|
||||
public function catedel()
|
||||
{
|
||||
$id = input('post.id');
|
||||
|
||||
// 检查是否有子分类
|
||||
$hasChildren = Db::table('yz_resources_category')
|
||||
->where('cid', $id)
|
||||
->where('delete_time', null)
|
||||
->find();
|
||||
|
||||
if ($hasChildren) {
|
||||
return json(['code' => 1, 'msg' => '该分类下有子分类,无法删除', 'data' => []]);
|
||||
}
|
||||
|
||||
$delete = Db::table('yz_resources_category')
|
||||
->where('id', $id)
|
||||
->update(['delete_time' => time()]);
|
||||
|
||||
if ($delete === false) {
|
||||
return json(['code' => 1, 'msg' => '删除失败', 'data' => []]);
|
||||
}
|
||||
return json(['code' => 0, 'msg' => '删除成功', 'data' => []]);
|
||||
}
|
||||
}
|
||||
@ -411,10 +411,31 @@
|
||||
// 更新父级分类选项
|
||||
var $select = $('select[name="cid"]');
|
||||
$select.empty().append('<option value="0">顶级分类</option>');
|
||||
if (data && data.parentOptions) {
|
||||
data.parentOptions.forEach(function (item) {
|
||||
$select.append('<option value="' + item.id + '">' + item.name + '</option>');
|
||||
});
|
||||
// 获取所有分类作为父级选项
|
||||
$.ajax({
|
||||
url: '/admin/article/articlecate',
|
||||
type: 'POST',
|
||||
async: false,
|
||||
success: function (res) {
|
||||
if (res.code === 0) {
|
||||
// 当前编辑的分类ID
|
||||
var currentId = data ? data.info.id : 0;
|
||||
// 递归构建分类选项
|
||||
function buildOptions(categories, level) {
|
||||
categories.forEach(function (category) {
|
||||
// 不能选择自己或自己的子分类作为父级
|
||||
if (category.id != currentId) {
|
||||
var prefix = new Array(level + 1).join('├─ ');
|
||||
$select.append('<option value="' + category.id + '">' + prefix + category.title + '</option>'); if (category.children && category.children.length > 0) { buildOptions(category.children, level + 1); }
|
||||
}
|
||||
});
|
||||
} buildOptions(res.data, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
// 设置选中的父级分类
|
||||
if (data && data.info.cid) {
|
||||
$select.val(data.info.cid);
|
||||
}
|
||||
|
||||
// 更新图片预览
|
||||
|
||||
190
app/admin/view/resources/add.php
Normal file
190
app/admin/view/resources/add.php
Normal file
@ -0,0 +1,190 @@
|
||||
{include file="public/header" /}
|
||||
<div class="config-container">
|
||||
<div class="config-header" style="display:flex;justify-content: space-between;">
|
||||
<div>
|
||||
<span>添加资源</span>
|
||||
</div>
|
||||
<div>
|
||||
<button type="button" class="layui-btn layui-btn-primary layui-btn-sm" onclick="goBack()">
|
||||
<i class="layui-icon layui-icon-return"></i>返回
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<form class="layui-form" action="" method="post">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">资源名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="name" required lay-verify="required" placeholder="请输入资源名称" autocomplete="off"
|
||||
class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">分类</label>
|
||||
<div class="layui-input-block">
|
||||
<select name="cate_id" lay-verify="required">
|
||||
<option value="">请选择分类</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">描述</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea name="desc" placeholder="请输入资源描述" class="layui-textarea"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">上传者</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="uploader" required lay-verify="required" placeholder="请输入上传者" autocomplete="off"
|
||||
class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">资源图标</label>
|
||||
<div class="layui-input-block">
|
||||
<button type="button" class="layui-btn" id="upload-btn">
|
||||
<i class="layui-icon layui-icon-upload"></i> 图标上传
|
||||
</button>
|
||||
<div style="width: 120px;">
|
||||
<div class="layui-upload-list">
|
||||
<img class="layui-upload-img" id="upload-img"
|
||||
style="width: 118px; height: 118px;object-fit: cover;">
|
||||
<div id="upload-text"></div>
|
||||
</div>
|
||||
<div class="layui-progress layui-progress-big" lay-showPercent="yes" lay-filter="filter-demo">
|
||||
<div class="layui-progress-bar" lay-percent=""></div>
|
||||
</div>
|
||||
<input type="hidden" name="icon" id="icon" value="">
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux">建议尺寸:128px * 128px</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">资源链接</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="url" required lay-verify="required" placeholder="请输入资源链接" autocomplete="off"
|
||||
class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">分享码</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="code" required lay-verify="required" placeholder="请输入分享码" autocomplete="off"
|
||||
class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">排序</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="sort" value="0" class="layui-input" placeholder="数字越大越靠前">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn" lay-submit lay-filter="formSubmit">立即提交</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
layui.use(['form', 'layer'], function () {
|
||||
var form = layui.form;
|
||||
var layer = layui.layer;
|
||||
var $ = layui.jquery;
|
||||
var upload = layui.upload;
|
||||
var element = layui.element;
|
||||
|
||||
// 图标上传
|
||||
var uploadInst = upload.render({
|
||||
elem: '#upload-btn',
|
||||
url: '{:url("index/upload_img")}',
|
||||
before: function (obj) {
|
||||
obj.preview(function (index, file, result) {
|
||||
$('#upload-img').attr('src', result);
|
||||
});
|
||||
element.progress('filter-demo', '0%');
|
||||
layer.msg('上传中', { icon: 16, time: 0 });
|
||||
},
|
||||
done: function (res) {
|
||||
if (res.code > 0) {
|
||||
return layer.msg('上传失败');
|
||||
}
|
||||
$('#icon').val(res.data);
|
||||
$('#upload-text').html('');
|
||||
layer.msg('上传成功', { icon: 1 });
|
||||
},
|
||||
uploadError: function () {
|
||||
var demoText = $('#upload-text');
|
||||
demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
|
||||
demoText.find('.demo-reload').on('click', function () {
|
||||
uploadInst.upload();
|
||||
});
|
||||
},
|
||||
progress: function (n, elem, e) {
|
||||
element.progress('filter-demo', n + '%');
|
||||
if (n == 100) {
|
||||
layer.msg('上传完毕', { icon: 1 });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 获取分类列表
|
||||
$.get('{:url("resources/cate")}', function (res) {
|
||||
if (res.code == 0) {
|
||||
var html = '<option value="">请选择分类</option>';
|
||||
res.data.forEach(function (item) {
|
||||
var disabled = item.cid == 0 ? 'disabled' : '';
|
||||
html += '<option value="' + item.id + '" ' + disabled + '>' + item.name + '</option>';
|
||||
if (item.children && item.children.length > 0) {
|
||||
item.children.forEach(function (child) {
|
||||
html += '<option value="' + child.id + '">├─ ' + child.name + '</option>';
|
||||
});
|
||||
}
|
||||
});
|
||||
$('select[name="cate_id"]').html(html);
|
||||
form.render('select');
|
||||
} else {
|
||||
layer.msg(res.msg, { icon: 2 });
|
||||
}
|
||||
});
|
||||
|
||||
// 表单提交
|
||||
form.on('submit(formSubmit)', function (data) {
|
||||
var loadIndex = layer.load(2);
|
||||
$.ajax({
|
||||
url: '{:url("resources/add")}',
|
||||
type: 'POST',
|
||||
data: data.field,
|
||||
success: function (res) {
|
||||
layer.close(loadIndex);
|
||||
if (res.code == 0) {
|
||||
layer.msg(res.msg, { icon: 1 });
|
||||
setTimeout(function () {
|
||||
window.location.href = '{:url("resources/lists")}';
|
||||
}, 1000);
|
||||
} else {
|
||||
layer.msg(res.msg, { icon: 2 });
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
//返回资源列表
|
||||
function goBack() {
|
||||
window.location.href = '{:url("resources/lists")}';
|
||||
}
|
||||
</script>
|
||||
525
app/admin/view/resources/cate.php
Normal file
525
app/admin/view/resources/cate.php
Normal file
@ -0,0 +1,525 @@
|
||||
{include file="public/header" /}
|
||||
<div class="config-container">
|
||||
<!-- 页面头部样式 -->
|
||||
<div class="config-header" style="display: flex;flex-direction: column;flex-wrap: wrap;align-items: flex-start;">
|
||||
<div class="maintitle">
|
||||
<i class="layui-icon layui-icon-app"></i>
|
||||
<span>资源分类管理</span>
|
||||
</div>
|
||||
<div style="display: flex;align-items: flex-start;flex-direction: column;gap: 15px;margin-bottom: 10px;">
|
||||
<div>
|
||||
<button type="button" class="layui-btn layui-btn-normal" onclick="add()">
|
||||
<i class="layui-icon layui-icon-add-1"></i>添加分类
|
||||
</button>
|
||||
<button type="button" class="layui-btn layui-btn-primary layui-border-blue" onclick="refresh()">
|
||||
<i class="layui-icon layui-icon-refresh"></i>刷新
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 主要内容区 -->
|
||||
<div class="main-content">
|
||||
<div class="layui-row layui-col-space20">
|
||||
<!-- 左侧分类列表 -->
|
||||
<div class="layui-col-md7">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">
|
||||
<span>分类列表</span>
|
||||
<small class="text-muted">支持两级分类结构</small>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div id="categoryList" class="category-tree"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 右侧分类信息 -->
|
||||
<div class="layui-col-md5">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">
|
||||
<span>分类信息</span>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<!-- 默认提示 -->
|
||||
<div id="defaultTip" class="empty-tip">
|
||||
<i class="layui-icon layui-icon-face-surprised"></i>
|
||||
<p>请选择左侧分类或点击新增按钮</p>
|
||||
</div>
|
||||
|
||||
<!-- 分类表单 -->
|
||||
<form class="layui-form category-form" lay-filter="categoryForm" style="display: none;">
|
||||
<input type="hidden" name="id" id="categoryId">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">分类名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="name" required lay-verify="required" placeholder="请输入分类名称"
|
||||
autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">父级分类</label>
|
||||
<div class="layui-input-block">
|
||||
<select name="cid" lay-verify="required">
|
||||
<option value="0">顶级分类</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">分类图标</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-upload-drag" id="uploadImage">
|
||||
<i class="layui-icon layui-icon-upload"></i>
|
||||
<p>点击上传或拖拽图片至此处</p>
|
||||
<div class="layui-hide" id="uploadPreview">
|
||||
<hr>
|
||||
<img src="" alt="分类图标" style="max-width: 100%">
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="icon" id="imageInput">
|
||||
<div class="layui-form-mid layui-word-aux">建议尺寸:128px * 128px</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">排序</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="sort" value="0" class="layui-input"
|
||||
placeholder="数字越大越靠前">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">状态</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="status" value="1" title="正常" checked>
|
||||
<input type="radio" name="status" value="0" title="禁用">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item form-actions">
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn" lay-submit lay-filter="saveCategory">保存</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
<button type="button" class="layui-btn layui-btn-danger" id="deleteBtn"
|
||||
style="display: none;">删除</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
/* 页面整体样式 */
|
||||
.config-container {
|
||||
padding: 15px;
|
||||
/* background: #f2f2f2; */
|
||||
}
|
||||
|
||||
.layui-col-md7 .layui-btn-primary {
|
||||
border-color: #d2d2d2;
|
||||
background: 0 0;
|
||||
color: #5f5f5f
|
||||
}
|
||||
|
||||
.layui-col-md7 .layui-btn-primary:hover {
|
||||
background-color: #1e9fff;
|
||||
color: #efefef
|
||||
}
|
||||
|
||||
/* 页面头部样式 */
|
||||
.page-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 15px;
|
||||
padding: 10px 15px;
|
||||
background: #fff;
|
||||
border-radius: 2px;
|
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.header-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.header-title .layui-icon {
|
||||
margin-right: 8px;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.header-actions .layui-btn {
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
/* 主要内容区样式 */
|
||||
.main-content {
|
||||
min-height: calc(100vh - 170px);
|
||||
}
|
||||
|
||||
.layui-card {
|
||||
margin-bottom: 0;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.layui-card-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: auto;
|
||||
padding: 12px 15px;
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.text-muted {
|
||||
margin-left: 10px;
|
||||
font-size: 12px;
|
||||
font-weight: normal;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
/* 分类树样式 */
|
||||
.category-tree {
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
.category-item {
|
||||
margin: 5px 0;
|
||||
}
|
||||
|
||||
.category-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 10px 15px;
|
||||
background-color: #f8f8f8;
|
||||
border-radius: 2px;
|
||||
transition: all 0.3s;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.category-header:hover {
|
||||
background-color: #f2f2f2;
|
||||
}
|
||||
|
||||
.category-header.active {
|
||||
background-color: #e6f7ff;
|
||||
border-right: 3px solid #1890ff;
|
||||
}
|
||||
|
||||
.category-name {
|
||||
flex: 1;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.category-actions {
|
||||
/* opacity: 0; */
|
||||
transition: opacity 0.3s;
|
||||
}
|
||||
|
||||
.category-header:hover .category-actions {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.category-children {
|
||||
margin-left: 20px;
|
||||
padding-left: 15px;
|
||||
border-left: 1px dashed #e6e6e6;
|
||||
}
|
||||
|
||||
.add-child {
|
||||
padding: 3px 8px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.add-child .layui-icon {
|
||||
font-size: 12px;
|
||||
margin-right: 3px;
|
||||
}
|
||||
|
||||
/* 空状态提示 */
|
||||
.empty-tip {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 40px 0;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.empty-tip .layui-icon {
|
||||
font-size: 32px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
/* 表单样式优化 */
|
||||
.category-form {
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
.layui-form-label {
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.layui-input-block {
|
||||
margin-left: 130px;
|
||||
}
|
||||
|
||||
.form-actions {
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
.layui-upload-drag {
|
||||
padding: 20px;
|
||||
border: 1px dashed #e2e2e2;
|
||||
background-color: #fff;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.layui-upload-drag:hover {
|
||||
border-color: #009688;
|
||||
}
|
||||
|
||||
.layui-upload-drag img {
|
||||
max-width: 100%;
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
.layui-btn-xs {
|
||||
height: 30px;
|
||||
line-height: 25px;
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
// 定义全局变量和函数
|
||||
var categoryManager = {
|
||||
init: function () {
|
||||
this.initLayui();
|
||||
},
|
||||
|
||||
initLayui: function () {
|
||||
var that = this;
|
||||
layui.use(['layer', 'form', 'upload'], function () {
|
||||
var layer = layui.layer;
|
||||
var form = layui.form;
|
||||
var upload = layui.upload;
|
||||
var $ = layui.jquery;
|
||||
|
||||
// 初始化分类列表
|
||||
that.initCategoryList = function () {
|
||||
$.ajax({
|
||||
url: '/admin/resources/cate',
|
||||
type: 'POST',
|
||||
success: function (res) {
|
||||
if (res.code === 0) {
|
||||
var html = '';
|
||||
res.data.forEach(function (item) {
|
||||
html += that.renderCategory(item);
|
||||
});
|
||||
$('#categoryList').html(html);
|
||||
that.bindEvents();
|
||||
} else {
|
||||
layer.msg('获取分类数据失败', { icon: 2 });
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 渲染分类项
|
||||
that.renderCategory = function (category, level = 0) {
|
||||
var html = '<div class="category-item" data-id="' + category.id + '">';
|
||||
html += '<div class="category-header">';
|
||||
html += '<div class="category-name">' + category.title + '</div>';
|
||||
if (level === 0) {
|
||||
html += '<div class="category-actions">';
|
||||
html += '<button type="button" class="layui-btn layui-btn-primary layui-btn-xs add-child">';
|
||||
html += '<i class="layui-icon layui-icon-add-1"></i>添加子分类</button>';
|
||||
html += '</div>';
|
||||
}
|
||||
html += '</div>';
|
||||
|
||||
if (category.children && category.children.length > 0) {
|
||||
html += '<div class="category-children">';
|
||||
category.children.forEach(function (child) {
|
||||
html += that.renderCategory(child, level + 1);
|
||||
});
|
||||
html += '</div>';
|
||||
}
|
||||
html += '</div>';
|
||||
return html;
|
||||
};
|
||||
|
||||
// 绑定事件
|
||||
that.bindEvents = function () {
|
||||
// 点击分类项加载编辑信息
|
||||
$('.category-header').off('click').on('click', function (e) {
|
||||
if (!$(e.target).closest('.add-child').length) {
|
||||
var id = $(this).closest('.category-item').data('id');
|
||||
that.loadCategoryInfo(id);
|
||||
|
||||
// 添加选中效果
|
||||
$('.category-header').removeClass('active');
|
||||
$(this).addClass('active');
|
||||
}
|
||||
});
|
||||
|
||||
// 添加子分类
|
||||
$('.add-child').off('click').on('click', function (e) {
|
||||
e.stopPropagation();
|
||||
var parentId = $(this).closest('.category-item').data('id');
|
||||
that.showCategoryForm(parentId);
|
||||
});
|
||||
};
|
||||
|
||||
// 加载分类信息
|
||||
that.loadCategoryInfo = function (id) {
|
||||
$.get('/admin/resources/cateedit?id=' + id, function (res) {
|
||||
if (res.code === 0) {
|
||||
that.showCategoryForm(0, res.data);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 显示分类表单
|
||||
that.showCategoryForm = function (parentId = 0, data = null) {
|
||||
$('#defaultTip').hide();
|
||||
$('.category-form').show();
|
||||
|
||||
// 重置表单
|
||||
form.val('categoryForm', {
|
||||
id: data ? data.info.id : '',
|
||||
name: data ? data.info.name : '',
|
||||
cid: data ? data.info.cid : parentId,
|
||||
sort: data ? data.info.sort : 0,
|
||||
status: data ? data.info.status : 1
|
||||
});
|
||||
|
||||
// 更新父级分类选项
|
||||
var $select = $('select[name="cid"]');
|
||||
$select.empty().append('<option value="0">顶级分类</option>');
|
||||
// 获取所有分类作为父级选项
|
||||
$.ajax({
|
||||
url: '/admin/resources/cate',
|
||||
type: 'POST',
|
||||
async: false,
|
||||
success: function (res) {
|
||||
if (res.code === 0) {
|
||||
// 当前编辑的分类ID
|
||||
var currentId = data ? data.info.id : 0;
|
||||
// 递归构建分类选项
|
||||
function buildOptions(categories, level) {
|
||||
categories.forEach(function (category) {
|
||||
// 不能选择自己或自己的子分类作为父级
|
||||
if (category.id != currentId) {
|
||||
var prefix = new Array(level + 1).join('├─ ');
|
||||
$select.append('<option value="' + category.id + '">' + prefix + category.title + '</option>'); if (category.children && category.children.length > 0) { buildOptions(category.children, level + 1); }
|
||||
}
|
||||
});
|
||||
} buildOptions(res.data, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
// 设置选中的父级分类
|
||||
if (data && data.info.cid) {
|
||||
$select.val(data.info.cid);
|
||||
}
|
||||
|
||||
// 更新图标预览
|
||||
if (data && data.info.icon) {
|
||||
$('#uploadPreview').removeClass('layui-hide').find('img').attr('src', data.info.icon);
|
||||
$('#imageInput').val(data.info.icon);
|
||||
} else {
|
||||
$('#uploadPreview').addClass('layui-hide').find('img').attr('src', '');
|
||||
$('#imageInput').val('');
|
||||
}
|
||||
|
||||
// 显示/隐藏删除按钮
|
||||
$('#deleteBtn')[data ? 'show' : 'hide']();
|
||||
|
||||
form.render();
|
||||
};
|
||||
|
||||
// 初始化上传组件
|
||||
upload.render({
|
||||
elem: '#uploadImage',
|
||||
url: '/admin/upload/image',
|
||||
accept: 'images',
|
||||
acceptMime: 'image/*',
|
||||
done: function (res) {
|
||||
if (res.code === 0) {
|
||||
$('#uploadPreview').removeClass('layui-hide').find('img').attr('src', res.data.url);
|
||||
$('#imageInput').val(res.data.url);
|
||||
layer.msg('上传成功');
|
||||
} else {
|
||||
layer.msg('上传失败');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 监听表单提交
|
||||
form.on('submit(saveCategory)', function (data) {
|
||||
var url = data.field.id ? '/admin/resources/cateedit' : '/admin/resources/cateadd';
|
||||
$.post(url, data.field, function (res) {
|
||||
if (res.code === 0) {
|
||||
layer.msg(res.msg, { icon: 1 });
|
||||
that.initCategoryList();
|
||||
} else {
|
||||
layer.msg(res.msg, { icon: 2 });
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
// 监听删除按钮
|
||||
$('#deleteBtn').on('click', function () {
|
||||
var id = $('#categoryId').val();
|
||||
if (!id) return;
|
||||
|
||||
layer.confirm('确定要删除该分类吗?', function (index) {
|
||||
$.post('/admin/resources/catedel', { id: id }, function (res) {
|
||||
if (res.code === 0) {
|
||||
layer.msg(res.msg, { icon: 1 });
|
||||
that.initCategoryList();
|
||||
$('#defaultTip').show();
|
||||
$('.category-form').hide();
|
||||
} else {
|
||||
layer.msg(res.msg, { icon: 2 });
|
||||
}
|
||||
});
|
||||
layer.close(index);
|
||||
});
|
||||
});
|
||||
|
||||
// 初始化页面
|
||||
that.initCategoryList();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 初始化
|
||||
categoryManager.init();
|
||||
|
||||
// 新增分类
|
||||
function add() {
|
||||
categoryManager.showCategoryForm();
|
||||
}
|
||||
|
||||
// 刷新列表
|
||||
function refresh() {
|
||||
categoryManager.initCategoryList();
|
||||
}
|
||||
</script>
|
||||
205
app/admin/view/resources/lists.php
Normal file
205
app/admin/view/resources/lists.php
Normal file
@ -0,0 +1,205 @@
|
||||
{include file="public/header" /}
|
||||
<div class="config-container">
|
||||
<!-- 页面头部样式 -->
|
||||
<div class="config-header" style="display: flex;flex-direction: column;flex-wrap: wrap;align-items: flex-start;">
|
||||
<div class="maintitle">
|
||||
<i class="layui-icon layui-icon-file"></i>
|
||||
<span>资源列表</span>
|
||||
</div>
|
||||
<div style="display: flex;align-items: flex-start;flex-direction: column;gap: 15px;margin-bottom: 10px;">
|
||||
<div class="shaixuan">
|
||||
<label>筛选:</label>
|
||||
<div class="layui-form" style="display: flex; gap: 10px;">
|
||||
<div class="layui-input-inline">
|
||||
<select id="categoryFilter" lay-filter="categoryFilter" lay-verify="">
|
||||
<option value="">全部分类</option>
|
||||
{volist name="categories" id="category"}
|
||||
<optgroup label="{$category.name}">
|
||||
{volist name="category.children" id="subCategory"}
|
||||
<option value="{$subCategory.id}">{$subCategory.name}</option>
|
||||
{/volist}
|
||||
</optgroup>
|
||||
{/volist}
|
||||
</select>
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="nameSearch" placeholder="搜索资源名称" class="layui-input">
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="uploaderSearch" placeholder="搜索上传者" class="layui-input">
|
||||
</div>
|
||||
<button type="button" class="layui-btn layui-btn-normal" onclick="doSearch()">
|
||||
<i class="layui-icon layui-icon-search"></i>搜索
|
||||
</button>
|
||||
<button type="button" class="layui-btn layui-btn-primary layui-border-blue" onclick="doRefresh()">
|
||||
<i class="layui-icon layui-icon-refresh"></i>重置
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<button type="button" class="layui-btn layui-btn-normal" onclick="add()">
|
||||
<i class="layui-icon layui-icon-add-1"></i>添加资源
|
||||
</button>
|
||||
<button type="button" class="layui-btn layui-btn-primary layui-border-blue" onclick="refresh()">
|
||||
<i class="layui-icon layui-icon-refresh"></i>刷新
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table id="resourceTable" lay-filter="resourceTable"></table>
|
||||
</div>
|
||||
|
||||
<script type="text/html" id="iconTemplate">
|
||||
{{# if(d.icon){ }}
|
||||
<img src="{{ d.icon }}" style="max-width: 50px; max-height: 50px;">
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="statusTemplate">
|
||||
{{# if(d.status === 0){ }}
|
||||
<span style="color:red;">未审核</span>
|
||||
{{# } else if(d.status === 1){ }}
|
||||
<span style="color:orange;">待审核</span>
|
||||
{{# } else if(d.status === 2){ }}
|
||||
<span style="color:green;">已发布</span>
|
||||
{{# } else if(d.status === 3){ }}
|
||||
<span style="color:gray;">已下架</span>
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="operationBar">
|
||||
<button type="button" class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit">
|
||||
<i class="layui-icon layui-icon-edit"></i>编辑
|
||||
</button>
|
||||
<button type="button" class="layui-btn layui-btn-primary layui-btn-xs" lay-event="del">
|
||||
<i class="layui-icon layui-icon-delete"></i>删除
|
||||
</button>
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
layui.use(['layer', 'form', 'table'], function () {
|
||||
var layer = layui.layer;
|
||||
var $ = layui.jquery;
|
||||
var form = layui.form;
|
||||
var table = layui.table;
|
||||
|
||||
// 初始化表格
|
||||
table.render({
|
||||
elem: '#resourceTable',
|
||||
url: '/admin/resources/lists',
|
||||
method: 'post',
|
||||
cols: [[
|
||||
{ field: 'id', title: 'ID', align: 'center', width: 80 },
|
||||
{ field: 'name', title: '资源名称' },
|
||||
{ field: 'cate', title: '分类', align: 'center', width: 120 },
|
||||
{ field: 'icon', title: '图标', templet: '#iconTemplate', align: 'center', width: 100 },
|
||||
{ field: 'uploader', title: '上传者', align: 'center', width: 100 },
|
||||
{ field: 'desc', title: '描述', width: 200 },
|
||||
{ field: 'status', title: '状态', templet: '#statusTemplate', align: 'center', width: 80 },
|
||||
{ field: 'upload_time', title: '上传时间', align: 'center', width: 160 },
|
||||
{ title: '操作', toolbar: '#operationBar', align: 'center', width: 150, fixed: 'right' }
|
||||
]],
|
||||
page: true,
|
||||
limit: 10,
|
||||
limits: [10, 50, 100],
|
||||
//height: 'full-220'
|
||||
});
|
||||
|
||||
// 监听工具条事件
|
||||
table.on('tool(resourceTable)', function (obj) {
|
||||
var data = obj.data;
|
||||
if (obj.event === 'edit') {
|
||||
edit(data.id);
|
||||
} else if (obj.event === 'del') {
|
||||
del(data.id);
|
||||
}
|
||||
});
|
||||
|
||||
// 监听分类筛选变化
|
||||
form.on('select(categoryFilter)', function (data) {
|
||||
filterByCategory(data.value);
|
||||
});
|
||||
});
|
||||
|
||||
function filterByCategory(categoryId) {
|
||||
reloadTable();
|
||||
}
|
||||
|
||||
function doSearch() {
|
||||
var nameKeyword = $('#nameSearch').val().trim();
|
||||
var uploaderKeyword = $('#uploaderSearch').val().trim();
|
||||
|
||||
if (!nameKeyword && !uploaderKeyword && !$('#categoryFilter').val()) {
|
||||
layer.msg('请输入搜索条件', { icon: 0 });
|
||||
return;
|
||||
}
|
||||
|
||||
reloadTable();
|
||||
}
|
||||
|
||||
function doRefresh() {
|
||||
// 清空搜索条件
|
||||
$('#nameSearch').val('');
|
||||
$('#uploaderSearch').val('');
|
||||
$('#categoryFilter').val('');
|
||||
layui.form.render('select'); // 重新渲染select
|
||||
|
||||
// 重新加载表格,不带任何筛选条件
|
||||
layui.table.reload('resourceTable', {
|
||||
where: {},
|
||||
page: {
|
||||
curr: 1
|
||||
}
|
||||
});
|
||||
|
||||
layer.msg('已重置', { icon: 1 });
|
||||
}
|
||||
|
||||
function reloadTable() {
|
||||
var categoryId = $('#categoryFilter').val();
|
||||
var categoryName = categoryId ? $('#categoryFilter option[value="' + categoryId + '"]').text() : '';
|
||||
var nameKeyword = $('#nameSearch').val().trim();
|
||||
var uploaderKeyword = $('#uploaderSearch').val().trim();
|
||||
|
||||
layui.table.reload('resourceTable', {
|
||||
where: {
|
||||
category: categoryName,
|
||||
name: nameKeyword,
|
||||
uploader: uploaderKeyword
|
||||
},
|
||||
page: {
|
||||
curr: 1
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function add() {
|
||||
window.location.href = '/admin/resources/add';
|
||||
}
|
||||
|
||||
function edit(id) {
|
||||
window.location.href = '/admin/resources/edit?id=' + id;
|
||||
}
|
||||
|
||||
function del(id) {
|
||||
layer.confirm('确定要删除该资源吗?', {
|
||||
btn: ['确定', '取消']
|
||||
}, function () {
|
||||
$.post('/admin/resources/delete', { id: id }, function (res) {
|
||||
if (res.code == 0) {
|
||||
layer.msg(res.msg, { icon: 1 });
|
||||
setTimeout(function () {
|
||||
layui.table.reload('resourceTable');
|
||||
}, 1000);
|
||||
} else {
|
||||
layer.msg(res.msg, { icon: 2 });
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function refresh() {
|
||||
layui.table.reload('resourceTable');
|
||||
}
|
||||
</script>
|
||||
@ -208,29 +208,40 @@
|
||||
|
||||
/* Banner样式 */
|
||||
.banner-content {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.banner-image {
|
||||
position: absolute;
|
||||
/* top: 65%;
|
||||
left: 35%;
|
||||
transform: translate(-50%, -50%); */
|
||||
color: #fff;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.banner-image img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
object-position: center;
|
||||
}
|
||||
|
||||
.banner-text {
|
||||
position: absolute;
|
||||
top: 40%;
|
||||
left: 10%;
|
||||
/* transform: translate(-50%, -50%); */
|
||||
z-index: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.banner-text a{
|
||||
.banner-text a {
|
||||
text-decoration: none;
|
||||
/* text-align: center; */
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
@ -238,18 +249,14 @@
|
||||
font-size: 4em;
|
||||
font-weight: 600;
|
||||
margin-bottom: 10px;
|
||||
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.banner-desc {
|
||||
font-size: 2em;
|
||||
font-weight: 400;
|
||||
max-width: 800px;
|
||||
}
|
||||
|
||||
.banner-image img{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.banner-btn {
|
||||
@ -258,6 +265,7 @@
|
||||
padding: 10px 20px;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.banner-btn:hover {
|
||||
@ -297,25 +305,6 @@
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.banner-content {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.banner-slide {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.banner-slide img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
/* 确保轮播容器和项目的高度正确 */
|
||||
#test10,
|
||||
#test10 [carousel-item],
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
<div class="module-header">
|
||||
<div>
|
||||
<div class="ModuleTitle_titleWrapper">
|
||||
<h3 class="ModuleTitle_title">技术文章11</h3>
|
||||
<h3 class="ModuleTitle_title">技术文章</h3>
|
||||
<div class="tab-container">
|
||||
<div class="tab-header">
|
||||
<div class="tab-item active" data-tab="all">全部</div>
|
||||
|
||||
299
runtime/admin/temp/4362e65c6d8297a2ebddffccccfcd7f3.php
Normal file
299
runtime/admin/temp/4362e65c6d8297a2ebddffccccfcd7f3.php
Normal file
@ -0,0 +1,299 @@
|
||||
<?php /*a:2:{s:63:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\resources\lists.php";i:1747386799;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746849526;}*/ ?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title><?php echo htmlentities((string) $config['admin_name']); ?></title>
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" type="text/css" href="/static/layui/css/layui.css" media="all"/>
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/moban.css" media="all"/>
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/wangeditor.css" media="all"/>
|
||||
<style type="text/css">
|
||||
.header span{background:#009688;margin-left:30px;padding:10px;color:#ffffff;}
|
||||
.header div{border-bottom:solid 2px #009688;margin-top: 8px;}
|
||||
.header button{float:right;margin-top:-5px;}
|
||||
.pagination {
|
||||
display: inline-block;
|
||||
padding-left: 0;
|
||||
margin: 20px 0;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.pagination > li {
|
||||
display: inline;
|
||||
}
|
||||
.pagination > li > a,
|
||||
.pagination > li > span {
|
||||
position: relative;
|
||||
float: left;
|
||||
padding: 6px 12px;
|
||||
margin-left: -1px;
|
||||
line-height: 1.42857143;
|
||||
color: #337ab7;
|
||||
text-decoration: none;
|
||||
background-color: #fff;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
.pagination > li:first-child > a,
|
||||
.pagination > li:first-child > span {
|
||||
margin-left: 0;
|
||||
border-top-left-radius: 4px;
|
||||
border-bottom-left-radius: 4px;
|
||||
}
|
||||
.pagination > li:last-child > a,
|
||||
.pagination > li:last-child > span {
|
||||
border-top-right-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
}
|
||||
.pagination > li > a:hover,
|
||||
.pagination > li > span:hover,
|
||||
.pagination > li > a:focus,
|
||||
.pagination > li > span:focus {
|
||||
z-index: 2;
|
||||
color: #23527c;
|
||||
background-color: #eee;
|
||||
border-color: #ddd;
|
||||
}
|
||||
.pagination > .active > a,
|
||||
.pagination > .active > span,
|
||||
.pagination > .active > a:hover,
|
||||
.pagination > .active > span:hover,
|
||||
.pagination > .active > a:focus,
|
||||
.pagination > .active > span:focus {
|
||||
z-index: 3;
|
||||
color: #fff;
|
||||
cursor: default;
|
||||
background-color: #337ab7;
|
||||
border-color: #337ab7;
|
||||
}
|
||||
.pagination > .disabled > span,
|
||||
.pagination > .disabled > span:hover,
|
||||
.pagination > .disabled > span:focus,
|
||||
.pagination > .disabled > a,
|
||||
.pagination > .disabled > a:hover,
|
||||
.pagination > .disabled > a:focus {
|
||||
color: #777;
|
||||
cursor: not-allowed;
|
||||
background-color: #fff;
|
||||
border-color: #ddd;
|
||||
}
|
||||
.close-img { background: url(/static/images/close_img.png); background-size: 20px 20px; width:20px; height: 20px; position: absolute; right: 5px; top: 5px; z-index: 2;}
|
||||
</style>
|
||||
<script type="text/javascript" src="/static/layui/layui.js"></script>
|
||||
<script type="text/javascript">
|
||||
layui.use(['layer','form','table','laydate','element','upload'],function(){
|
||||
layer = layui.layer; // layui 弹框
|
||||
form = layui.form; // layui form表单
|
||||
table = layui.table; // layui 表格
|
||||
laydate = layui.laydate; // layui 时间框
|
||||
element = layui.element; // layui element
|
||||
upload = layui.upload; // layui 上传
|
||||
$ = layui.jquery; // layui jquery
|
||||
})
|
||||
</script>
|
||||
</head>
|
||||
<body style="padding:10px; box-sizing: border-box;">
|
||||
<div class="config-container">
|
||||
<!-- 页面头部样式 -->
|
||||
<div class="config-header" style="display: flex;flex-direction: column;flex-wrap: wrap;align-items: flex-start;">
|
||||
<div class="maintitle">
|
||||
<i class="layui-icon layui-icon-file"></i>
|
||||
<span>资源列表</span>
|
||||
</div>
|
||||
<div style="display: flex;align-items: flex-start;flex-direction: column;gap: 15px;margin-bottom: 10px;">
|
||||
<div class="shaixuan">
|
||||
<label>筛选:</label>
|
||||
<div class="layui-form" style="display: flex; gap: 10px;">
|
||||
<div class="layui-input-inline">
|
||||
<select id="categoryFilter" lay-filter="categoryFilter" lay-verify="">
|
||||
<option value="">全部分类</option>
|
||||
<?php if(is_array($categories) || $categories instanceof \think\Collection || $categories instanceof \think\Paginator): $i = 0; $__LIST__ = $categories;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$category): $mod = ($i % 2 );++$i;?>
|
||||
<optgroup label="<?php echo htmlentities((string) $category['name']); ?>">
|
||||
<?php if(is_array($category['children']) || $category['children'] instanceof \think\Collection || $category['children'] instanceof \think\Paginator): $i = 0; $__LIST__ = $category['children'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$subCategory): $mod = ($i % 2 );++$i;?>
|
||||
<option value="<?php echo htmlentities((string) $subCategory['id']); ?>"><?php echo htmlentities((string) $subCategory['name']); ?></option>
|
||||
<?php endforeach; endif; else: echo "" ;endif; ?>
|
||||
</optgroup>
|
||||
<?php endforeach; endif; else: echo "" ;endif; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="nameSearch" placeholder="搜索资源名称" class="layui-input">
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="uploaderSearch" placeholder="搜索上传者" class="layui-input">
|
||||
</div>
|
||||
<button type="button" class="layui-btn layui-btn-normal" onclick="doSearch()">
|
||||
<i class="layui-icon layui-icon-search"></i>搜索
|
||||
</button>
|
||||
<button type="button" class="layui-btn layui-btn-primary layui-border-blue" onclick="doRefresh()">
|
||||
<i class="layui-icon layui-icon-refresh"></i>重置
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<button type="button" class="layui-btn layui-btn-normal" onclick="add()">
|
||||
<i class="layui-icon layui-icon-add-1"></i>添加资源
|
||||
</button>
|
||||
<button type="button" class="layui-btn layui-btn-primary layui-border-blue" onclick="refresh()">
|
||||
<i class="layui-icon layui-icon-refresh"></i>刷新
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table id="resourceTable" lay-filter="resourceTable"></table>
|
||||
</div>
|
||||
|
||||
<script type="text/html" id="iconTemplate">
|
||||
{{# if(d.icon){ }}
|
||||
<img src="{{ d.icon }}" style="max-width: 50px; max-height: 50px;">
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="statusTemplate">
|
||||
{{# if(d.status === 0){ }}
|
||||
<span style="color:red;">未审核</span>
|
||||
{{# } else if(d.status === 1){ }}
|
||||
<span style="color:orange;">待审核</span>
|
||||
{{# } else if(d.status === 2){ }}
|
||||
<span style="color:green;">已发布</span>
|
||||
{{# } else if(d.status === 3){ }}
|
||||
<span style="color:gray;">已下架</span>
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="operationBar">
|
||||
<button type="button" class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit">
|
||||
<i class="layui-icon layui-icon-edit"></i>编辑
|
||||
</button>
|
||||
<button type="button" class="layui-btn layui-btn-primary layui-btn-xs" lay-event="del">
|
||||
<i class="layui-icon layui-icon-delete"></i>删除
|
||||
</button>
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
layui.use(['layer', 'form', 'table'], function () {
|
||||
var layer = layui.layer;
|
||||
var $ = layui.jquery;
|
||||
var form = layui.form;
|
||||
var table = layui.table;
|
||||
|
||||
// 初始化表格
|
||||
table.render({
|
||||
elem: '#resourceTable',
|
||||
url: '/admin/resources/lists',
|
||||
method: 'post',
|
||||
cols: [[
|
||||
{ field: 'id', title: 'ID', align: 'center', width: 80 },
|
||||
{ field: 'name', title: '资源名称' },
|
||||
{ field: 'cate', title: '分类', align: 'center', width: 120 },
|
||||
{ field: 'icon', title: '图标', templet: '#iconTemplate', align: 'center', width: 100 },
|
||||
{ field: 'uploader', title: '上传者', align: 'center', width: 100 },
|
||||
{ field: 'desc', title: '描述', width: 200 },
|
||||
{ field: 'status', title: '状态', templet: '#statusTemplate', align: 'center', width: 80 },
|
||||
{ field: 'upload_time', title: '上传时间', align: 'center', width: 160 },
|
||||
{ title: '操作', toolbar: '#operationBar', align: 'center', width: 150, fixed: 'right' }
|
||||
]],
|
||||
page: true,
|
||||
limit: 10,
|
||||
limits: [10, 50, 100],
|
||||
//height: 'full-220'
|
||||
});
|
||||
|
||||
// 监听工具条事件
|
||||
table.on('tool(resourceTable)', function (obj) {
|
||||
var data = obj.data;
|
||||
if (obj.event === 'edit') {
|
||||
edit(data.id);
|
||||
} else if (obj.event === 'del') {
|
||||
del(data.id);
|
||||
}
|
||||
});
|
||||
|
||||
// 监听分类筛选变化
|
||||
form.on('select(categoryFilter)', function (data) {
|
||||
filterByCategory(data.value);
|
||||
});
|
||||
});
|
||||
|
||||
function filterByCategory(categoryId) {
|
||||
reloadTable();
|
||||
}
|
||||
|
||||
function doSearch() {
|
||||
var nameKeyword = $('#nameSearch').val().trim();
|
||||
var uploaderKeyword = $('#uploaderSearch').val().trim();
|
||||
|
||||
if (!nameKeyword && !uploaderKeyword && !$('#categoryFilter').val()) {
|
||||
layer.msg('请输入搜索条件', { icon: 0 });
|
||||
return;
|
||||
}
|
||||
|
||||
reloadTable();
|
||||
}
|
||||
|
||||
function doRefresh() {
|
||||
// 清空搜索条件
|
||||
$('#nameSearch').val('');
|
||||
$('#uploaderSearch').val('');
|
||||
$('#categoryFilter').val('');
|
||||
layui.form.render('select'); // 重新渲染select
|
||||
|
||||
// 重新加载表格,不带任何筛选条件
|
||||
layui.table.reload('resourceTable', {
|
||||
where: {},
|
||||
page: {
|
||||
curr: 1
|
||||
}
|
||||
});
|
||||
|
||||
layer.msg('已重置', { icon: 1 });
|
||||
}
|
||||
|
||||
function reloadTable() {
|
||||
var categoryId = $('#categoryFilter').val();
|
||||
var categoryName = categoryId ? $('#categoryFilter option[value="' + categoryId + '"]').text() : '';
|
||||
var nameKeyword = $('#nameSearch').val().trim();
|
||||
var uploaderKeyword = $('#uploaderSearch').val().trim();
|
||||
|
||||
layui.table.reload('resourceTable', {
|
||||
where: {
|
||||
category: categoryName,
|
||||
name: nameKeyword,
|
||||
uploader: uploaderKeyword
|
||||
},
|
||||
page: {
|
||||
curr: 1
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function add() {
|
||||
window.location.href = '/admin/resources/add';
|
||||
}
|
||||
|
||||
function edit(id) {
|
||||
window.location.href = '/admin/resources/edit?id=' + id;
|
||||
}
|
||||
|
||||
function del(id) {
|
||||
layer.confirm('确定要删除该资源吗?', {
|
||||
btn: ['确定', '取消']
|
||||
}, function () {
|
||||
$.post('/admin/resources/delete', { id: id }, function (res) {
|
||||
if (res.code == 0) {
|
||||
layer.msg(res.msg, { icon: 1 });
|
||||
setTimeout(function () {
|
||||
layui.table.reload('resourceTable');
|
||||
}, 1000);
|
||||
} else {
|
||||
layer.msg(res.msg, { icon: 2 });
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function refresh() {
|
||||
layui.table.reload('resourceTable');
|
||||
}
|
||||
</script>
|
||||
@ -1,4 +1,4 @@
|
||||
<?php /*a:3:{s:63:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\yunzer\menuinfo.php";i:1747385442;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746849526;s:59:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\tail.php";i:1746709977;}*/ ?>
|
||||
<?php /*a:3:{s:63:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\yunzer\menuinfo.php";i:1747385555;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746849526;s:59:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\tail.php";i:1746709977;}*/ ?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
@ -102,7 +102,7 @@
|
||||
</div>
|
||||
<div style="display: flex;align-items: flex-start;flex-direction: column;gap: 15px;margin-bottom: 10px;">
|
||||
<div>
|
||||
<button class="layui-btn layui-bg-blue" id="addBanner">
|
||||
<button class="layui-btn layui-bg-blue" onclick="add()">
|
||||
<i class="layui-icon layui-icon-add-1"></i>添加菜单
|
||||
</button>
|
||||
<button type="button" class="layui-btn layui-btn-primary layui-border-blue" onclick="refresh()">
|
||||
|
||||
284
runtime/admin/temp/59fe0658cc9cd89331c4634f2d4b0bed.php
Normal file
284
runtime/admin/temp/59fe0658cc9cd89331c4634f2d4b0bed.php
Normal file
@ -0,0 +1,284 @@
|
||||
<?php /*a:2:{s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\resources\add.php";i:1747388179;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746849526;}*/ ?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title><?php echo htmlentities((string) $config['admin_name']); ?></title>
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" type="text/css" href="/static/layui/css/layui.css" media="all"/>
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/moban.css" media="all"/>
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/wangeditor.css" media="all"/>
|
||||
<style type="text/css">
|
||||
.header span{background:#009688;margin-left:30px;padding:10px;color:#ffffff;}
|
||||
.header div{border-bottom:solid 2px #009688;margin-top: 8px;}
|
||||
.header button{float:right;margin-top:-5px;}
|
||||
.pagination {
|
||||
display: inline-block;
|
||||
padding-left: 0;
|
||||
margin: 20px 0;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.pagination > li {
|
||||
display: inline;
|
||||
}
|
||||
.pagination > li > a,
|
||||
.pagination > li > span {
|
||||
position: relative;
|
||||
float: left;
|
||||
padding: 6px 12px;
|
||||
margin-left: -1px;
|
||||
line-height: 1.42857143;
|
||||
color: #337ab7;
|
||||
text-decoration: none;
|
||||
background-color: #fff;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
.pagination > li:first-child > a,
|
||||
.pagination > li:first-child > span {
|
||||
margin-left: 0;
|
||||
border-top-left-radius: 4px;
|
||||
border-bottom-left-radius: 4px;
|
||||
}
|
||||
.pagination > li:last-child > a,
|
||||
.pagination > li:last-child > span {
|
||||
border-top-right-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
}
|
||||
.pagination > li > a:hover,
|
||||
.pagination > li > span:hover,
|
||||
.pagination > li > a:focus,
|
||||
.pagination > li > span:focus {
|
||||
z-index: 2;
|
||||
color: #23527c;
|
||||
background-color: #eee;
|
||||
border-color: #ddd;
|
||||
}
|
||||
.pagination > .active > a,
|
||||
.pagination > .active > span,
|
||||
.pagination > .active > a:hover,
|
||||
.pagination > .active > span:hover,
|
||||
.pagination > .active > a:focus,
|
||||
.pagination > .active > span:focus {
|
||||
z-index: 3;
|
||||
color: #fff;
|
||||
cursor: default;
|
||||
background-color: #337ab7;
|
||||
border-color: #337ab7;
|
||||
}
|
||||
.pagination > .disabled > span,
|
||||
.pagination > .disabled > span:hover,
|
||||
.pagination > .disabled > span:focus,
|
||||
.pagination > .disabled > a,
|
||||
.pagination > .disabled > a:hover,
|
||||
.pagination > .disabled > a:focus {
|
||||
color: #777;
|
||||
cursor: not-allowed;
|
||||
background-color: #fff;
|
||||
border-color: #ddd;
|
||||
}
|
||||
.close-img { background: url(/static/images/close_img.png); background-size: 20px 20px; width:20px; height: 20px; position: absolute; right: 5px; top: 5px; z-index: 2;}
|
||||
</style>
|
||||
<script type="text/javascript" src="/static/layui/layui.js"></script>
|
||||
<script type="text/javascript">
|
||||
layui.use(['layer','form','table','laydate','element','upload'],function(){
|
||||
layer = layui.layer; // layui 弹框
|
||||
form = layui.form; // layui form表单
|
||||
table = layui.table; // layui 表格
|
||||
laydate = layui.laydate; // layui 时间框
|
||||
element = layui.element; // layui element
|
||||
upload = layui.upload; // layui 上传
|
||||
$ = layui.jquery; // layui jquery
|
||||
})
|
||||
</script>
|
||||
</head>
|
||||
<body style="padding:10px; box-sizing: border-box;">
|
||||
<div class="config-container">
|
||||
<div class="config-header" style="display:flex;justify-content: space-between;">
|
||||
<div>
|
||||
<span>添加资源</span>
|
||||
</div>
|
||||
<div>
|
||||
<button type="button" class="layui-btn layui-btn-primary layui-btn-sm" onclick="goBack()">
|
||||
<i class="layui-icon layui-icon-return"></i>返回
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<form class="layui-form" action="" method="post">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">资源名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="name" required lay-verify="required" placeholder="请输入资源名称" autocomplete="off"
|
||||
class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">分类</label>
|
||||
<div class="layui-input-block">
|
||||
<select name="cate_id" lay-verify="required">
|
||||
<option value="">请选择分类</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">描述</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea name="desc" placeholder="请输入资源描述" class="layui-textarea"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">上传者</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="uploader" required lay-verify="required" placeholder="请输入上传者" autocomplete="off"
|
||||
class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">资源图标</label>
|
||||
<div class="layui-input-block">
|
||||
<button type="button" class="layui-btn" id="upload-btn">
|
||||
<i class="layui-icon layui-icon-upload"></i> 图标上传
|
||||
</button>
|
||||
<div style="width: 120px;">
|
||||
<div class="layui-upload-list">
|
||||
<img class="layui-upload-img" id="upload-img"
|
||||
style="width: 118px; height: 118px;object-fit: cover;">
|
||||
<div id="upload-text"></div>
|
||||
</div>
|
||||
<div class="layui-progress layui-progress-big" lay-showPercent="yes" lay-filter="filter-demo">
|
||||
<div class="layui-progress-bar" lay-percent=""></div>
|
||||
</div>
|
||||
<input type="hidden" name="icon" id="icon" value="">
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux">建议尺寸:128px * 128px</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">资源链接</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="url" required lay-verify="required" placeholder="请输入资源链接" autocomplete="off"
|
||||
class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">分享码</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="code" required lay-verify="required" placeholder="请输入分享码" autocomplete="off"
|
||||
class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">排序</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="sort" value="0" class="layui-input" placeholder="数字越大越靠前">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn" lay-submit lay-filter="formSubmit">立即提交</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
layui.use(['form', 'layer'], function () {
|
||||
var form = layui.form;
|
||||
var layer = layui.layer;
|
||||
var $ = layui.jquery;
|
||||
var upload = layui.upload;
|
||||
var element = layui.element;
|
||||
|
||||
// 图标上传
|
||||
var uploadInst = upload.render({
|
||||
elem: '#upload-btn',
|
||||
url: '<?php echo url("index/upload_img"); ?>',
|
||||
before: function (obj) {
|
||||
obj.preview(function (index, file, result) {
|
||||
$('#upload-img').attr('src', result);
|
||||
});
|
||||
element.progress('filter-demo', '0%');
|
||||
layer.msg('上传中', { icon: 16, time: 0 });
|
||||
},
|
||||
done: function (res) {
|
||||
if (res.code > 0) {
|
||||
return layer.msg('上传失败');
|
||||
}
|
||||
$('#icon').val(res.data);
|
||||
$('#upload-text').html('');
|
||||
layer.msg('上传成功', { icon: 1 });
|
||||
},
|
||||
uploadError: function () {
|
||||
var demoText = $('#upload-text');
|
||||
demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
|
||||
demoText.find('.demo-reload').on('click', function () {
|
||||
uploadInst.upload();
|
||||
});
|
||||
},
|
||||
progress: function (n, elem, e) {
|
||||
element.progress('filter-demo', n + '%');
|
||||
if (n == 100) {
|
||||
layer.msg('上传完毕', { icon: 1 });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 获取分类列表
|
||||
$.get('<?php echo url("resources/cate"); ?>', function (res) {
|
||||
if (res.code == 0) {
|
||||
var html = '<option value="">请选择分类</option>';
|
||||
res.data.forEach(function (item) {
|
||||
var disabled = item.cid == 0 ? 'disabled' : '';
|
||||
html += '<option value="' + item.id + '" ' + disabled + '>' + item.name + '</option>';
|
||||
if (item.children && item.children.length > 0) {
|
||||
item.children.forEach(function (child) {
|
||||
html += '<option value="' + child.id + '">├─ ' + child.name + '</option>';
|
||||
});
|
||||
}
|
||||
});
|
||||
$('select[name="cate_id"]').html(html);
|
||||
form.render('select');
|
||||
} else {
|
||||
layer.msg(res.msg, { icon: 2 });
|
||||
}
|
||||
});
|
||||
|
||||
// 表单提交
|
||||
form.on('submit(formSubmit)', function (data) {
|
||||
var loadIndex = layer.load(2);
|
||||
$.ajax({
|
||||
url: '<?php echo url("resources/add"); ?>',
|
||||
type: 'POST',
|
||||
data: data.field,
|
||||
success: function (res) {
|
||||
layer.close(loadIndex);
|
||||
if (res.code == 0) {
|
||||
layer.msg(res.msg, { icon: 1 });
|
||||
setTimeout(function () {
|
||||
window.location.href = '<?php echo url("resources/lists"); ?>';
|
||||
}, 1000);
|
||||
} else {
|
||||
layer.msg(res.msg, { icon: 2 });
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
//返回资源列表
|
||||
function goBack() {
|
||||
window.location.href = '<?php echo url("resources/lists"); ?>';
|
||||
}
|
||||
</script>
|
||||
@ -1,4 +1,4 @@
|
||||
<?php /*a:3:{s:63:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\yunzer\menuedit.php";i:1746709977;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746709977;s:59:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\tail.php";i:1746709977;}*/ ?>
|
||||
<?php /*a:3:{s:63:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\yunzer\menuedit.php";i:1746709977;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746849526;s:59:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\tail.php";i:1746709977;}*/ ?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
@ -6,8 +6,9 @@
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" type="text/css" href="/static/layui/css/layui.css" media="all"/>
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/moban.css" media="all"/>
|
||||
<link rel="stylesheet" type="text/css" href="/static/third/layui/css/layui.css" media="all"/>
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/wangeditor.css" media="all"/>
|
||||
<style type="text/css">
|
||||
.header span{background:#009688;margin-left:30px;padding:10px;color:#ffffff;}
|
||||
.header div{border-bottom:solid 2px #009688;margin-top: 8px;}
|
||||
@ -78,7 +79,7 @@
|
||||
}
|
||||
.close-img { background: url(/static/images/close_img.png); background-size: 20px 20px; width:20px; height: 20px; position: absolute; right: 5px; top: 5px; z-index: 2;}
|
||||
</style>
|
||||
<script type="text/javascript" src="/static/third/layui/layui.js"></script>
|
||||
<script type="text/javascript" src="/static/layui/layui.js"></script>
|
||||
<script type="text/javascript">
|
||||
layui.use(['layer','form','table','laydate','element','upload'],function(){
|
||||
layer = layui.layer; // layui 弹框
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<?php /*a:3:{s:62:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\yunzer\menuadd.php";i:1746709977;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746709977;s:59:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\tail.php";i:1746709977;}*/ ?>
|
||||
<?php /*a:3:{s:62:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\yunzer\menuadd.php";i:1746709977;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746849526;s:59:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\tail.php";i:1746709977;}*/ ?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
@ -6,8 +6,9 @@
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" type="text/css" href="/static/layui/css/layui.css" media="all"/>
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/moban.css" media="all"/>
|
||||
<link rel="stylesheet" type="text/css" href="/static/third/layui/css/layui.css" media="all"/>
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/wangeditor.css" media="all"/>
|
||||
<style type="text/css">
|
||||
.header span{background:#009688;margin-left:30px;padding:10px;color:#ffffff;}
|
||||
.header div{border-bottom:solid 2px #009688;margin-top: 8px;}
|
||||
@ -78,7 +79,7 @@
|
||||
}
|
||||
.close-img { background: url(/static/images/close_img.png); background-size: 20px 20px; width:20px; height: 20px; position: absolute; right: 5px; top: 5px; z-index: 2;}
|
||||
</style>
|
||||
<script type="text/javascript" src="/static/third/layui/layui.js"></script>
|
||||
<script type="text/javascript" src="/static/layui/layui.js"></script>
|
||||
<script type="text/javascript">
|
||||
layui.use(['layer','form','table','laydate','element','upload'],function(){
|
||||
layer = layui.layer; // layui 弹框
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<?php /*a:3:{s:68:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\yunzeradmin\userinfo.php";i:1747385487;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746849526;s:59:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\tail.php";i:1746709977;}*/ ?>
|
||||
<?php /*a:3:{s:68:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\yunzeradmin\userinfo.php";i:1747385548;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746849526;s:59:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\tail.php";i:1746709977;}*/ ?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
@ -102,7 +102,7 @@
|
||||
</div>
|
||||
<div style="display: flex;align-items: flex-start;flex-direction: column;gap: 15px;margin-bottom: 10px;">
|
||||
<div>
|
||||
<button class="layui-btn layui-bg-blue" id="addBanner">
|
||||
<button class="layui-btn layui-bg-blue" onclick="add()">
|
||||
<i class="layui-icon layui-icon-add-1"></i>添加
|
||||
</button>
|
||||
<button type="button" class="layui-btn layui-btn-primary layui-border-blue" onclick="refresh()">
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<?php /*a:3:{s:65:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\yunzer\buttonedit.php";i:1746709977;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746709977;s:59:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\tail.php";i:1746709977;}*/ ?>
|
||||
<?php /*a:3:{s:65:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\yunzer\buttonedit.php";i:1746709977;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746849526;s:59:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\tail.php";i:1746709977;}*/ ?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
@ -6,8 +6,9 @@
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" type="text/css" href="/static/layui/css/layui.css" media="all"/>
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/moban.css" media="all"/>
|
||||
<link rel="stylesheet" type="text/css" href="/static/third/layui/css/layui.css" media="all"/>
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/wangeditor.css" media="all"/>
|
||||
<style type="text/css">
|
||||
.header span{background:#009688;margin-left:30px;padding:10px;color:#ffffff;}
|
||||
.header div{border-bottom:solid 2px #009688;margin-top: 8px;}
|
||||
@ -78,7 +79,7 @@
|
||||
}
|
||||
.close-img { background: url(/static/images/close_img.png); background-size: 20px 20px; width:20px; height: 20px; position: absolute; right: 5px; top: 5px; z-index: 2;}
|
||||
</style>
|
||||
<script type="text/javascript" src="/static/third/layui/layui.js"></script>
|
||||
<script type="text/javascript" src="/static/layui/layui.js"></script>
|
||||
<script type="text/javascript">
|
||||
layui.use(['layer','form','table','laydate','element','upload'],function(){
|
||||
layer = layui.layer; // layui 弹框
|
||||
|
||||
619
runtime/admin/temp/e123693510a704bff17ec99b832b2bd4.php
Normal file
619
runtime/admin/temp/e123693510a704bff17ec99b832b2bd4.php
Normal file
@ -0,0 +1,619 @@
|
||||
<?php /*a:2:{s:62:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\resources\cate.php";i:1747387682;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746849526;}*/ ?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title><?php echo htmlentities((string) $config['admin_name']); ?></title>
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" type="text/css" href="/static/layui/css/layui.css" media="all"/>
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/moban.css" media="all"/>
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/wangeditor.css" media="all"/>
|
||||
<style type="text/css">
|
||||
.header span{background:#009688;margin-left:30px;padding:10px;color:#ffffff;}
|
||||
.header div{border-bottom:solid 2px #009688;margin-top: 8px;}
|
||||
.header button{float:right;margin-top:-5px;}
|
||||
.pagination {
|
||||
display: inline-block;
|
||||
padding-left: 0;
|
||||
margin: 20px 0;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.pagination > li {
|
||||
display: inline;
|
||||
}
|
||||
.pagination > li > a,
|
||||
.pagination > li > span {
|
||||
position: relative;
|
||||
float: left;
|
||||
padding: 6px 12px;
|
||||
margin-left: -1px;
|
||||
line-height: 1.42857143;
|
||||
color: #337ab7;
|
||||
text-decoration: none;
|
||||
background-color: #fff;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
.pagination > li:first-child > a,
|
||||
.pagination > li:first-child > span {
|
||||
margin-left: 0;
|
||||
border-top-left-radius: 4px;
|
||||
border-bottom-left-radius: 4px;
|
||||
}
|
||||
.pagination > li:last-child > a,
|
||||
.pagination > li:last-child > span {
|
||||
border-top-right-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
}
|
||||
.pagination > li > a:hover,
|
||||
.pagination > li > span:hover,
|
||||
.pagination > li > a:focus,
|
||||
.pagination > li > span:focus {
|
||||
z-index: 2;
|
||||
color: #23527c;
|
||||
background-color: #eee;
|
||||
border-color: #ddd;
|
||||
}
|
||||
.pagination > .active > a,
|
||||
.pagination > .active > span,
|
||||
.pagination > .active > a:hover,
|
||||
.pagination > .active > span:hover,
|
||||
.pagination > .active > a:focus,
|
||||
.pagination > .active > span:focus {
|
||||
z-index: 3;
|
||||
color: #fff;
|
||||
cursor: default;
|
||||
background-color: #337ab7;
|
||||
border-color: #337ab7;
|
||||
}
|
||||
.pagination > .disabled > span,
|
||||
.pagination > .disabled > span:hover,
|
||||
.pagination > .disabled > span:focus,
|
||||
.pagination > .disabled > a,
|
||||
.pagination > .disabled > a:hover,
|
||||
.pagination > .disabled > a:focus {
|
||||
color: #777;
|
||||
cursor: not-allowed;
|
||||
background-color: #fff;
|
||||
border-color: #ddd;
|
||||
}
|
||||
.close-img { background: url(/static/images/close_img.png); background-size: 20px 20px; width:20px; height: 20px; position: absolute; right: 5px; top: 5px; z-index: 2;}
|
||||
</style>
|
||||
<script type="text/javascript" src="/static/layui/layui.js"></script>
|
||||
<script type="text/javascript">
|
||||
layui.use(['layer','form','table','laydate','element','upload'],function(){
|
||||
layer = layui.layer; // layui 弹框
|
||||
form = layui.form; // layui form表单
|
||||
table = layui.table; // layui 表格
|
||||
laydate = layui.laydate; // layui 时间框
|
||||
element = layui.element; // layui element
|
||||
upload = layui.upload; // layui 上传
|
||||
$ = layui.jquery; // layui jquery
|
||||
})
|
||||
</script>
|
||||
</head>
|
||||
<body style="padding:10px; box-sizing: border-box;">
|
||||
<div class="config-container">
|
||||
<!-- 页面头部样式 -->
|
||||
<div class="config-header" style="display: flex;flex-direction: column;flex-wrap: wrap;align-items: flex-start;">
|
||||
<div class="maintitle">
|
||||
<i class="layui-icon layui-icon-app"></i>
|
||||
<span>资源分类管理</span>
|
||||
</div>
|
||||
<div style="display: flex;align-items: flex-start;flex-direction: column;gap: 15px;margin-bottom: 10px;">
|
||||
<div>
|
||||
<button type="button" class="layui-btn layui-btn-normal" onclick="add()">
|
||||
<i class="layui-icon layui-icon-add-1"></i>添加分类
|
||||
</button>
|
||||
<button type="button" class="layui-btn layui-btn-primary layui-border-blue" onclick="refresh()">
|
||||
<i class="layui-icon layui-icon-refresh"></i>刷新
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 主要内容区 -->
|
||||
<div class="main-content">
|
||||
<div class="layui-row layui-col-space20">
|
||||
<!-- 左侧分类列表 -->
|
||||
<div class="layui-col-md7">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">
|
||||
<span>分类列表</span>
|
||||
<small class="text-muted">支持两级分类结构</small>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div id="categoryList" class="category-tree"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 右侧分类信息 -->
|
||||
<div class="layui-col-md5">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">
|
||||
<span>分类信息</span>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<!-- 默认提示 -->
|
||||
<div id="defaultTip" class="empty-tip">
|
||||
<i class="layui-icon layui-icon-face-surprised"></i>
|
||||
<p>请选择左侧分类或点击新增按钮</p>
|
||||
</div>
|
||||
|
||||
<!-- 分类表单 -->
|
||||
<form class="layui-form category-form" lay-filter="categoryForm" style="display: none;">
|
||||
<input type="hidden" name="id" id="categoryId">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">分类名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="name" required lay-verify="required" placeholder="请输入分类名称"
|
||||
autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">父级分类</label>
|
||||
<div class="layui-input-block">
|
||||
<select name="cid" lay-verify="required">
|
||||
<option value="0">顶级分类</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">分类图标</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-upload-drag" id="uploadImage">
|
||||
<i class="layui-icon layui-icon-upload"></i>
|
||||
<p>点击上传或拖拽图片至此处</p>
|
||||
<div class="layui-hide" id="uploadPreview">
|
||||
<hr>
|
||||
<img src="" alt="分类图标" style="max-width: 100%">
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="icon" id="imageInput">
|
||||
<div class="layui-form-mid layui-word-aux">建议尺寸:128px * 128px</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">排序</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="sort" value="0" class="layui-input"
|
||||
placeholder="数字越大越靠前">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">状态</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="status" value="1" title="正常" checked>
|
||||
<input type="radio" name="status" value="0" title="禁用">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item form-actions">
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn" lay-submit lay-filter="saveCategory">保存</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
<button type="button" class="layui-btn layui-btn-danger" id="deleteBtn"
|
||||
style="display: none;">删除</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
/* 页面整体样式 */
|
||||
.config-container {
|
||||
padding: 15px;
|
||||
/* background: #f2f2f2; */
|
||||
}
|
||||
|
||||
.layui-col-md7 .layui-btn-primary {
|
||||
border-color: #d2d2d2;
|
||||
background: 0 0;
|
||||
color: #5f5f5f
|
||||
}
|
||||
|
||||
.layui-col-md7 .layui-btn-primary:hover {
|
||||
background-color: #1e9fff;
|
||||
color: #efefef
|
||||
}
|
||||
|
||||
/* 页面头部样式 */
|
||||
.page-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 15px;
|
||||
padding: 10px 15px;
|
||||
background: #fff;
|
||||
border-radius: 2px;
|
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.header-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.header-title .layui-icon {
|
||||
margin-right: 8px;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.header-actions .layui-btn {
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
/* 主要内容区样式 */
|
||||
.main-content {
|
||||
min-height: calc(100vh - 170px);
|
||||
}
|
||||
|
||||
.layui-card {
|
||||
margin-bottom: 0;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.layui-card-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: auto;
|
||||
padding: 12px 15px;
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.text-muted {
|
||||
margin-left: 10px;
|
||||
font-size: 12px;
|
||||
font-weight: normal;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
/* 分类树样式 */
|
||||
.category-tree {
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
.category-item {
|
||||
margin: 5px 0;
|
||||
}
|
||||
|
||||
.category-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 10px 15px;
|
||||
background-color: #f8f8f8;
|
||||
border-radius: 2px;
|
||||
transition: all 0.3s;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.category-header:hover {
|
||||
background-color: #f2f2f2;
|
||||
}
|
||||
|
||||
.category-header.active {
|
||||
background-color: #e6f7ff;
|
||||
border-right: 3px solid #1890ff;
|
||||
}
|
||||
|
||||
.category-name {
|
||||
flex: 1;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.category-actions {
|
||||
/* opacity: 0; */
|
||||
transition: opacity 0.3s;
|
||||
}
|
||||
|
||||
.category-header:hover .category-actions {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.category-children {
|
||||
margin-left: 20px;
|
||||
padding-left: 15px;
|
||||
border-left: 1px dashed #e6e6e6;
|
||||
}
|
||||
|
||||
.add-child {
|
||||
padding: 3px 8px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.add-child .layui-icon {
|
||||
font-size: 12px;
|
||||
margin-right: 3px;
|
||||
}
|
||||
|
||||
/* 空状态提示 */
|
||||
.empty-tip {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 40px 0;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.empty-tip .layui-icon {
|
||||
font-size: 32px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
/* 表单样式优化 */
|
||||
.category-form {
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
.layui-form-label {
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.layui-input-block {
|
||||
margin-left: 130px;
|
||||
}
|
||||
|
||||
.form-actions {
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
.layui-upload-drag {
|
||||
padding: 20px;
|
||||
border: 1px dashed #e2e2e2;
|
||||
background-color: #fff;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.layui-upload-drag:hover {
|
||||
border-color: #009688;
|
||||
}
|
||||
|
||||
.layui-upload-drag img {
|
||||
max-width: 100%;
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
.layui-btn-xs {
|
||||
height: 30px;
|
||||
line-height: 25px;
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
// 定义全局变量和函数
|
||||
var categoryManager = {
|
||||
init: function () {
|
||||
this.initLayui();
|
||||
},
|
||||
|
||||
initLayui: function () {
|
||||
var that = this;
|
||||
layui.use(['layer', 'form', 'upload'], function () {
|
||||
var layer = layui.layer;
|
||||
var form = layui.form;
|
||||
var upload = layui.upload;
|
||||
var $ = layui.jquery;
|
||||
|
||||
// 初始化分类列表
|
||||
that.initCategoryList = function () {
|
||||
$.ajax({
|
||||
url: '/admin/resources/cate',
|
||||
type: 'POST',
|
||||
success: function (res) {
|
||||
if (res.code === 0) {
|
||||
var html = '';
|
||||
res.data.forEach(function (item) {
|
||||
html += that.renderCategory(item);
|
||||
});
|
||||
$('#categoryList').html(html);
|
||||
that.bindEvents();
|
||||
} else {
|
||||
layer.msg('获取分类数据失败', { icon: 2 });
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 渲染分类项
|
||||
that.renderCategory = function (category, level = 0) {
|
||||
var html = '<div class="category-item" data-id="' + category.id + '">';
|
||||
html += '<div class="category-header">';
|
||||
html += '<div class="category-name">' + category.title + '</div>';
|
||||
if (level === 0) {
|
||||
html += '<div class="category-actions">';
|
||||
html += '<button type="button" class="layui-btn layui-btn-primary layui-btn-xs add-child">';
|
||||
html += '<i class="layui-icon layui-icon-add-1"></i>添加子分类</button>';
|
||||
html += '</div>';
|
||||
}
|
||||
html += '</div>';
|
||||
|
||||
if (category.children && category.children.length > 0) {
|
||||
html += '<div class="category-children">';
|
||||
category.children.forEach(function (child) {
|
||||
html += that.renderCategory(child, level + 1);
|
||||
});
|
||||
html += '</div>';
|
||||
}
|
||||
html += '</div>';
|
||||
return html;
|
||||
};
|
||||
|
||||
// 绑定事件
|
||||
that.bindEvents = function () {
|
||||
// 点击分类项加载编辑信息
|
||||
$('.category-header').off('click').on('click', function (e) {
|
||||
if (!$(e.target).closest('.add-child').length) {
|
||||
var id = $(this).closest('.category-item').data('id');
|
||||
that.loadCategoryInfo(id);
|
||||
|
||||
// 添加选中效果
|
||||
$('.category-header').removeClass('active');
|
||||
$(this).addClass('active');
|
||||
}
|
||||
});
|
||||
|
||||
// 添加子分类
|
||||
$('.add-child').off('click').on('click', function (e) {
|
||||
e.stopPropagation();
|
||||
var parentId = $(this).closest('.category-item').data('id');
|
||||
that.showCategoryForm(parentId);
|
||||
});
|
||||
};
|
||||
|
||||
// 加载分类信息
|
||||
that.loadCategoryInfo = function (id) {
|
||||
$.get('/admin/resources/cateedit?id=' + id, function (res) {
|
||||
if (res.code === 0) {
|
||||
that.showCategoryForm(0, res.data);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 显示分类表单
|
||||
that.showCategoryForm = function (parentId = 0, data = null) {
|
||||
$('#defaultTip').hide();
|
||||
$('.category-form').show();
|
||||
|
||||
// 重置表单
|
||||
form.val('categoryForm', {
|
||||
id: data ? data.info.id : '',
|
||||
name: data ? data.info.name : '',
|
||||
cid: data ? data.info.cid : parentId,
|
||||
sort: data ? data.info.sort : 0,
|
||||
status: data ? data.info.status : 1
|
||||
});
|
||||
|
||||
// 更新父级分类选项
|
||||
var $select = $('select[name="cid"]');
|
||||
$select.empty().append('<option value="0">顶级分类</option>');
|
||||
// 获取所有分类作为父级选项
|
||||
$.ajax({
|
||||
url: '/admin/resources/cate',
|
||||
type: 'POST',
|
||||
async: false,
|
||||
success: function (res) {
|
||||
if (res.code === 0) {
|
||||
// 当前编辑的分类ID
|
||||
var currentId = data ? data.info.id : 0;
|
||||
// 递归构建分类选项
|
||||
function buildOptions(categories, level) {
|
||||
categories.forEach(function (category) {
|
||||
// 不能选择自己或自己的子分类作为父级
|
||||
if (category.id != currentId) {
|
||||
var prefix = new Array(level + 1).join('├─ ');
|
||||
$select.append('<option value="' + category.id + '">' + prefix + category.title + '</option>'); if (category.children && category.children.length > 0) { buildOptions(category.children, level + 1); }
|
||||
}
|
||||
});
|
||||
} buildOptions(res.data, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
// 设置选中的父级分类
|
||||
if (data && data.info.cid) {
|
||||
$select.val(data.info.cid);
|
||||
}
|
||||
|
||||
// 更新图标预览
|
||||
if (data && data.info.icon) {
|
||||
$('#uploadPreview').removeClass('layui-hide').find('img').attr('src', data.info.icon);
|
||||
$('#imageInput').val(data.info.icon);
|
||||
} else {
|
||||
$('#uploadPreview').addClass('layui-hide').find('img').attr('src', '');
|
||||
$('#imageInput').val('');
|
||||
}
|
||||
|
||||
// 显示/隐藏删除按钮
|
||||
$('#deleteBtn')[data ? 'show' : 'hide']();
|
||||
|
||||
form.render();
|
||||
};
|
||||
|
||||
// 初始化上传组件
|
||||
upload.render({
|
||||
elem: '#uploadImage',
|
||||
url: '/admin/upload/image',
|
||||
accept: 'images',
|
||||
acceptMime: 'image/*',
|
||||
done: function (res) {
|
||||
if (res.code === 0) {
|
||||
$('#uploadPreview').removeClass('layui-hide').find('img').attr('src', res.data.url);
|
||||
$('#imageInput').val(res.data.url);
|
||||
layer.msg('上传成功');
|
||||
} else {
|
||||
layer.msg('上传失败');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 监听表单提交
|
||||
form.on('submit(saveCategory)', function (data) {
|
||||
var url = data.field.id ? '/admin/resources/cateedit' : '/admin/resources/cateadd';
|
||||
$.post(url, data.field, function (res) {
|
||||
if (res.code === 0) {
|
||||
layer.msg(res.msg, { icon: 1 });
|
||||
that.initCategoryList();
|
||||
} else {
|
||||
layer.msg(res.msg, { icon: 2 });
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
// 监听删除按钮
|
||||
$('#deleteBtn').on('click', function () {
|
||||
var id = $('#categoryId').val();
|
||||
if (!id) return;
|
||||
|
||||
layer.confirm('确定要删除该分类吗?', function (index) {
|
||||
$.post('/admin/resources/catedel', { id: id }, function (res) {
|
||||
if (res.code === 0) {
|
||||
layer.msg(res.msg, { icon: 1 });
|
||||
that.initCategoryList();
|
||||
$('#defaultTip').show();
|
||||
$('.category-form').hide();
|
||||
} else {
|
||||
layer.msg(res.msg, { icon: 2 });
|
||||
}
|
||||
});
|
||||
layer.close(index);
|
||||
});
|
||||
});
|
||||
|
||||
// 初始化页面
|
||||
that.initCategoryList();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 初始化
|
||||
categoryManager.init();
|
||||
|
||||
// 新增分类
|
||||
function add() {
|
||||
categoryManager.showCategoryForm();
|
||||
}
|
||||
|
||||
// 刷新列表
|
||||
function refresh() {
|
||||
categoryManager.initCategoryList();
|
||||
}
|
||||
</script>
|
||||
@ -1,4 +1,4 @@
|
||||
<?php /*a:2:{s:67:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\article\articlecate.php";i:1747384911;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746849526;}*/ ?>
|
||||
<?php /*a:2:{s:67:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\article\articlecate.php";i:1747387836;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746849526;}*/ ?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
@ -505,10 +505,31 @@
|
||||
// 更新父级分类选项
|
||||
var $select = $('select[name="cid"]');
|
||||
$select.empty().append('<option value="0">顶级分类</option>');
|
||||
if (data && data.parentOptions) {
|
||||
data.parentOptions.forEach(function (item) {
|
||||
$select.append('<option value="' + item.id + '">' + item.name + '</option>');
|
||||
});
|
||||
// 获取所有分类作为父级选项
|
||||
$.ajax({
|
||||
url: '/admin/article/articlecate',
|
||||
type: 'POST',
|
||||
async: false,
|
||||
success: function (res) {
|
||||
if (res.code === 0) {
|
||||
// 当前编辑的分类ID
|
||||
var currentId = data ? data.info.id : 0;
|
||||
// 递归构建分类选项
|
||||
function buildOptions(categories, level) {
|
||||
categories.forEach(function (category) {
|
||||
// 不能选择自己或自己的子分类作为父级
|
||||
if (category.id != currentId) {
|
||||
var prefix = new Array(level + 1).join('├─ ');
|
||||
$select.append('<option value="' + category.id + '">' + prefix + category.title + '</option>'); if (category.children && category.children.length > 0) { buildOptions(category.children, level + 1); }
|
||||
}
|
||||
});
|
||||
} buildOptions(res.data, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
// 设置选中的父级分类
|
||||
if (data && data.info.cid) {
|
||||
$select.val(data.info.cid);
|
||||
}
|
||||
|
||||
// 更新图片预览
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<?php /*a:4:{s:59:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\index\index.php";i:1746865108;s:64:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\header.php";i:1747383384;s:62:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\main.php";i:1747362104;s:64:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\footer.php";i:1747360756;}*/ ?>
|
||||
<?php /*a:4:{s:59:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\index\index.php";i:1746865108;s:64:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\header.php";i:1747385836;s:62:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\main.php";i:1747385879;s:64:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\footer.php";i:1747360756;}*/ ?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
@ -226,29 +226,40 @@
|
||||
|
||||
/* Banner样式 */
|
||||
.banner-content {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.banner-image {
|
||||
position: absolute;
|
||||
/* top: 65%;
|
||||
left: 35%;
|
||||
transform: translate(-50%, -50%); */
|
||||
color: #fff;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.banner-image img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
object-position: center;
|
||||
}
|
||||
|
||||
.banner-text {
|
||||
position: absolute;
|
||||
top: 40%;
|
||||
left: 10%;
|
||||
/* transform: translate(-50%, -50%); */
|
||||
z-index: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.banner-text a{
|
||||
.banner-text a {
|
||||
text-decoration: none;
|
||||
/* text-align: center; */
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
@ -256,18 +267,14 @@
|
||||
font-size: 4em;
|
||||
font-weight: 600;
|
||||
margin-bottom: 10px;
|
||||
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.banner-desc {
|
||||
font-size: 2em;
|
||||
font-weight: 400;
|
||||
max-width: 800px;
|
||||
}
|
||||
|
||||
.banner-image img{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.banner-btn {
|
||||
@ -276,6 +283,7 @@
|
||||
padding: 10px 20px;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.banner-btn:hover {
|
||||
@ -315,25 +323,6 @@
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.banner-content {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.banner-slide {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.banner-slide img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
/* 确保轮播容器和项目的高度正确 */
|
||||
#test10,
|
||||
#test10 [carousel-item],
|
||||
@ -382,7 +371,7 @@
|
||||
height: '100vh',
|
||||
interval: 4000,
|
||||
anim: 'fade',
|
||||
autoplay: false,
|
||||
autoplay: true,
|
||||
full: false,
|
||||
arrow: 'hover'
|
||||
});
|
||||
@ -489,7 +478,7 @@
|
||||
<div class="module-header">
|
||||
<div>
|
||||
<div class="ModuleTitle_titleWrapper">
|
||||
<h3 class="ModuleTitle_title">技术文章11</h3>
|
||||
<h3 class="ModuleTitle_title">技术文章</h3>
|
||||
<div class="tab-container">
|
||||
<div class="tab-header">
|
||||
<div class="tab-item active" data-tab="all">全部</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user