314 lines
		
	
	
		
			10 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			314 lines
		
	
	
		
			10 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php /*a:3:{s:68:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\yunzertest\test_list.php";i:1745483534;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1745500576;s:59:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\tail.php";i:1745482530;}*/ ?>
 | |
| <!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/third/layui/css/layui.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/third/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="header">
 | |
| 	<span>演示列表-方法渲染</span>
 | |
| 	<div></div>
 | |
| </div>
 | |
| <div class="layui-form layui-card-header layuiadmin-card-header-auto" lay-filter="layadmin-useradmin-formlist" style="height:100%;">
 | |
| 	<div class="layui-form-item" id="search"></div>
 | |
| </div>
 | |
| <script type="text/html" id="toolbar">
 | |
| 	<div class="layui-btn-container">
 | |
| 		<div class="layui-btn-group">
 | |
| 			<button type="button" class="layui-btn layui-btn-primary" lay-event="add">
 | |
| 				<i class="layui-icon layui-icon-add-1"></i>添加
 | |
| 			</button>
 | |
| 			<button type="button" class="layui-btn layui-btn-primary" lay-event="edit">
 | |
| 				<i class="layui-icon layui-icon-edit"></i>修改
 | |
| 			</button>
 | |
| 			<button type="button" class="layui-btn layui-btn-primary" lay-event="del">
 | |
| 				<i class="layui-icon layui-icon-delete"></i>删除
 | |
| 			</button>
 | |
| 		</div>
 | |
| 	</div>
 | |
| </script>
 | |
| <table class="layui-hide" id="datalist" lay-filter="datalist"></table>
 | |
| <script type="text/javascript">
 | |
| 	layui.use(['layer','table'],function(){
 | |
| 		table = layui.table;
 | |
| 		layer = layui.layer;
 | |
| 		$ = layui.jquery;
 | |
| 		get_data();
 | |
| 
 | |
| 		table.on('row(datalist)',function(obj){
 | |
| 			obj.tr.addClass('layui-table-click').siblings().removeClass('layui-table-click');
 | |
| 			obj.tr.find("div.layui-unselect.layui-form-radio")[0].click();
 | |
| 		});
 | |
| 		table.on('toolbar(datalist)',function(obj){
 | |
| 			var checkStatus = table.checkStatus(obj.config.id);
 | |
| 			var data = checkStatus.data;
 | |
| 			var datas = obj.data;
 | |
| 			var layEvent = obj.event;
 | |
| 			var tr = obj.tr;
 | |
| 
 | |
| 			switch(obj.event){
 | |
| 				case 'add':
 | |
| 					layer.full(layer.open({
 | |
| 						title: '添加',
 | |
| 						type: 2,
 | |
| 						content: "<?php echo htmlentities((string) $config['admin_route']); ?>yunzertest/test_add",
 | |
| 						maxmin: true,
 | |
| 						area: ['70%','70%'],
 | |
| 						btn: ['确定','关闭'],
 | |
| 						yes: function(index,layero){
 | |
| 							var form = layero.find('iframe')[0].contentWindow;
 | |
| 							var body = layer.getChildFrame('body', index);
 | |
| 							var test_img =[];
 | |
| 							body.find("input[name='test_img']").each(function(){
 | |
| 								test_img.push($(this).val());
 | |
| 							})
 | |
| 							var dataj = {
 | |
| 								test_input : form.test_input.value,
 | |
| 								test_reference : form.test_reference.value,
 | |
| 								test_time : form.test_time.value,
 | |
| 								test_data : form.test_data.value,
 | |
| 								test_datatime : form.test_datatime.value,
 | |
| 								test_img : test_img,
 | |
| 								test_rich : form.test_rich.value,
 | |
| 								test_rich_baidu : form.test_rich_baidu.value,
 | |
| 								test_url : form.test_url.value
 | |
| 							};
 | |
| 							$.post('<?php echo htmlentities((string) $config["admin_route"]); ?>yunzertest/test_add',dataj,function(res){
 | |
| 								if(res.code>0){
 | |
| 									layer.msg(res.msg,{'icon':2});
 | |
| 								}else{
 | |
| 									layer.msg(res.msg,{'icon':1});
 | |
| 									get_data();
 | |
| 									layer.close(index);
 | |
| 								}
 | |
| 							},'json');
 | |
| 						}
 | |
| 					}))
 | |
| 					break;
 | |
| 				case 'edit':
 | |
| 					if(!data[0]){
 | |
| 						layer.msg('请选择一条数据',{'icon':2});
 | |
| 						return false;
 | |
| 					}
 | |
| 					layer.full(layer.open({
 | |
| 						title: '修改',
 | |
| 						type: 2,
 | |
| 						content: "<?php echo htmlentities((string) $config['admin_route']); ?>yunzertest/test_edit?test_id="+data[0].test_id,
 | |
| 						maxmin: true,
 | |
| 						area: ['70%','70%'],
 | |
| 						btn: ['确定','关闭'],
 | |
| 						yes: function(index,layero){
 | |
| 							var form = layero.find('iframe')[0].contentWindow;
 | |
| 							var body = layer.getChildFrame('body', index);
 | |
| 
 | |
| 							var test_img =[];
 | |
| 							body.find("input[name='test_img']").each(function(){
 | |
| 								test_img.push($(this).val());
 | |
| 							})
 | |
| 							var dataj = {
 | |
| 								test_id : data[0].test_id,
 | |
| 								test_input : form.test_input.value,
 | |
| 								test_reference : form.test_reference.value,
 | |
| 								test_time : form.test_time.value,
 | |
| 								test_data : form.test_data.value,
 | |
| 								test_datatime : form.test_datatime.value,
 | |
| 								test_img : test_img,
 | |
| 								test_rich : form.test_rich.value,
 | |
| 								test_rich_baidu : form.test_rich_baidu.value,
 | |
| 								test_url : form.test_url.value
 | |
| 							};
 | |
| 							$.post('<?php echo htmlentities((string) $config["admin_route"]); ?>yunzertest/test_edit',dataj,function(res){
 | |
| 								if(res.code>0){
 | |
| 									layer.msg(res.msg,{'icon':2});
 | |
| 								}else{
 | |
| 									layer.msg(res.msg,{'icon':1});
 | |
| 									get_data();
 | |
| 									layer.close(index);
 | |
| 								}
 | |
| 							},'json');
 | |
| 						}
 | |
| 					}))
 | |
| 					break;
 | |
| 				case 'del':
 | |
| 					if(!data[0]){
 | |
| 						layer.msg('请选择一条数据',{'icon':2});
 | |
| 						return false;
 | |
| 					}
 | |
| 					layer.confirm('确定要删除吗?',{
 | |
| 						icon:3,
 | |
| 						btn: ['确定','取消']
 | |
| 					},function(){
 | |
| 						$.post('<?php echo htmlentities((string) $config["admin_route"]); ?>yunzertest/test_del',{'test_id':data[0].test_id},function(res){
 | |
| 							if(res.code>0){
 | |
| 								layer.alert(res.msg,{icon:2});
 | |
| 							}else{
 | |
| 								layer.msg(res.msg);
 | |
| 								setTimeout(function(){window.location.reload();},1000);
 | |
| 							}
 | |
| 						},'json');
 | |
| 					});
 | |
| 				break;
 | |
| 			};
 | |
| 		});
 | |
| 
 | |
| 		function get_data(){
 | |
| 			table.render({
 | |
| 				elem: '#datalist',
 | |
| 				method : 'post'
 | |
| 				,url:"<?php echo htmlentities((string) $config['admin_route']); ?>yunzertest/test_list"
 | |
| 				,toolbar: '#toolbar'
 | |
| 				,defaultToolbar: ['filter', 'print', 'exports', {
 | |
| 					title: '提示'
 | |
| 					,layEvent: 'LAYTABLE_TIPS'
 | |
| 					,icon: 'layui-icon-tips'
 | |
| 				}]
 | |
| 				,title: '演示列表'
 | |
| 				,page: true
 | |
| 				,cols: [[
 | |
| 					{type:'checkbox'},
 | |
| 					{type:'radio'}
 | |
| 					,{field:'test_id', width:50, title:'ID'}
 | |
| 					,{field:'test_input', width:100, title: '文本'}
 | |
| 					,{field:'test_rich', width:100, title: '富文本'}
 | |
| 					,{field:'test_rich_baidu', width:120, title: '百度文本'}
 | |
| 					,{field:'test_img', width:100, title: '图片',templet:function(res){
 | |
| 						return '<img style="width:30px;height:30px;" onmouseover="show_img(this)" onmouseleave="hide_img()" src="'+res.test_img+'"';
 | |
| 					}}
 | |
| 					,{field:'test_reference', width:100, title: '参照',templet:function(res){
 | |
| 						if(res.test_reference == 1){
 | |
| 							return '<span style="color:green;">开启</span>';
 | |
| 						}else{
 | |
| 							return '<span style="color:grey;">关闭</span>';
 | |
| 						}
 | |
| 					}}
 | |
| 					,{field:'test_time', width:100, title: '时间戳'}
 | |
| 					,{field:'test_data', width:100, title: '日期'}
 | |
| 					,{field:'test_datatime', width:150, title: '日期时间'}
 | |
| 					,{field:'test_url', width:150, title: '网址链接',templet:function(res){
 | |
| 						return '<a href="'+res.test_url+'" target="_blank">'+res.test_url+'</a>';
 | |
| 					}}
 | |
| 				]]
 | |
| 				,data:[]
 | |
| 				,limit :10
 | |
| 				,limits:[10,20,30]
 | |
| 				,height: 'full-100'
 | |
| 			});
 | |
| 		}
 | |
| 	});
 | |
| </script>
 | |
| 	</body>
 | |
| </html>
 | |
| <script type="text/javascript">
 | |
| 	// 显示图片
 | |
| 	function show_img(obj){
 | |
| 		var imgurl = $(obj).attr('src');
 | |
| 		var res = getMousePos();
 | |
| 		var html = '<div style="background:#fff;position:absolute;width:200px;border:solid 1px #cdcdcd;border-radius:6px;padding:2px;left:'+res.x+'px;top:'+res.y+'px;z-index:1000" id="preview">\
 | |
| 				<img style="width:100%;border-radius:6px;" src="'+imgurl+'">\
 | |
| 			</div>';
 | |
| 		$('body').append(html);
 | |
| 	}
 | |
| 	// 隐藏图片
 | |
| 	function hide_img(){
 | |
| 		$('#preview').remove();
 | |
| 	}
 | |
| 	// 图片位置计算
 | |
| 	function getMousePos(event) {
 | |
| 		var e = event || window.event;
 | |
| 		var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
 | |
| 		var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
 | |
| 		var x = e.pageX || e.clientX + scrollX;
 | |
| 		var y = e.pageY || e.clientY + scrollY;
 | |
| 		return { 'x': x, 'y': y };
 | |
| 	}
 | |
| 	// 删除图片
 | |
| 	function deleteImage(path,obj){
 | |
| 		$(obj).closest('.upload_pic_li').remove();
 | |
| 	}
 | |
| </script>
 |