171 lines
		
	
	
		
			6.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			171 lines
		
	
	
		
			6.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php /*a:2:{s:53:"E:\Demo\PHP\yunzer\app\admin\view\article\cateadd.php";i:1746796639;s:51:"E:\Demo\PHP\yunzer\app\admin\view\public\header.php";i:1746890051;}*/ ?>
 | |
| <!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 style="padding: 50px;padding-bottom: 0px;">
 | |
|     <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" id="name" name="name" required lay-verify="required" placeholder="请输入分类名称"
 | |
|                     class="layui-input">
 | |
|             </div>
 | |
|         </div>
 | |
| 
 | |
|         <div class="layui-form-item">
 | |
|             <label class="layui-form-label">父级分类</label>
 | |
|             <div class="layui-input-block">
 | |
|                 <select id="cid" 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">
 | |
|                 <input type="number" id="sort" name="sort" value="0" placeholder="请输入排序值" class="layui-input">
 | |
|             </div>
 | |
|         </div>
 | |
| 
 | |
|         <div class="layui-form-item">
 | |
|             <div class="layui-input-block">
 | |
|                 <button class="layui-btn" lay-submit lay-filter="formSubmit">添加分类</button>
 | |
|             </div>
 | |
|         </div>
 | |
|     </form>
 | |
| </div>
 | |
| 
 | |
| <script>
 | |
|     layui.use(['form', 'layer'], function () {
 | |
|         var form = layui.form;
 | |
|         var layer = layui.layer;
 | |
|         var $ = layui.jquery;
 | |
| 
 | |
|         // 获取URL中的cid参数
 | |
|         var urlParams = new URLSearchParams(window.location.search);
 | |
|         var cid = urlParams.get('cid');
 | |
| 
 | |
|         // 获取分类列表
 | |
|         $.get('<?php echo url("article/getcate"); ?>', function (res) {
 | |
|             if (res.code == 0) {
 | |
|                 var html = '<option value="0">顶级分类</option>';
 | |
|                 res.data.forEach(function (item) {
 | |
|                     html += '<option value="' + item.id + '"' + (cid == item.id ? ' selected' : '') + '>' + item.name + '</option>';
 | |
|                 });
 | |
|                 $('#cid').html(html);
 | |
|                 form.render('select');
 | |
|             } else {
 | |
|                 layer.msg(res.msg, { icon: 2 });
 | |
|             }
 | |
|         });
 | |
| 
 | |
|         // 表单提交
 | |
|         form.on('submit(formSubmit)', function (data) {
 | |
|             $.post('<?php echo url("article/cateadd"); ?>', data.field, function (res) {
 | |
|                 if (res.code == 0) {
 | |
|                     layer.msg(res.msg, { icon: 1 });
 | |
|                     setTimeout(function () {
 | |
|                         var index = parent.layer.getFrameIndex(window.name);
 | |
|                         parent.layer.close(index);
 | |
|                         parent.location.reload();
 | |
|                     }, 1000);
 | |
|                 } else {
 | |
|                     layer.msg(res.msg, { icon: 2 });
 | |
|                 }
 | |
|             });
 | |
|             return false;
 | |
|         });
 | |
|     });
 | |
| </script>
 | 
