299 lines
		
	
	
		
			12 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			299 lines
		
	
	
		
			12 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?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>
 |