<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
	<head>
	<%@include file="../../wdk/theme/je/module/public/common.jsp"%>
	<script type="text/javascript" src="<%=WDK_ROOT%>/theme/je/core/js/wdk.datatable.js"></script>
	  	<title>缓存管理</title>
 		<style type="text/css">
 			.inputgroup{
 				width : 390px;
 			}
 		</style>
		<script type="text/javascript">
		//grid相关
		var _gridcode = "eap.manage.cachegrid";
	  	var _gridid = $.getUUID();	
		//初始化
		$(function(){
			//单据状态
			$.combobox({
				id : 'tbname',
				url : 'wdk?action=wdk.pub&method=call_service&ajaxparam='+ new Date().getTime(),
				queryParams : {
					_SRVNAME : 'service.pf.cache',
					_SRVMETHOD : 'tb_query',
					_DATA : $.json2str({
						
					})
					,_RSTYPE:'combobox'
		 	   		,_RSFIELD:'rows'
		 	   		,_RSPARAM:$.json2str({
		   	   			idField:'id'
		   	   			,textField:'text'
		   	   		})

				},
				required : false,
				editable : false,
				multiple : false,
				initvalue : '',
				height : 25,
				tipPosition : 'right',
				defaultOption : '请选择缓存表'
			});
		});
		
	  	
		
		//查询
		function btn_query(){
			var _tbname = $.combobox_getValue({id:'tbname'});
   			var _type = $('#cache_key').val();
   			if(!_tbname){
   				alert('请选择缓存表');
   				return;
   			}
   			if(!_type){
   				alert('请输入key');
   				return;
   			}
			var _data = {
					_SRVNAME:'service.pf.cache',
			   	  	_SRVMETHOD:'cache_query',
		   	   		_DATA:$.json2str({
				   	   		tbname:$.combobox_getValue({id:'tbname'})
				   			,type: $('#cache_key').val()
		   			})
			    };
				//打开旋转 
				$.wait_open();
			  	//加载数据
				$.cuajax({
					url:'wdk?action=wdk.pub&method=call_service&ajaxparam='+new Date().getTime()
		     		,method:"post"
		      		,timeout:WDK_Timeout
		      		,data:_data
			  		,success:function(result) {
			  			//关闭旋转 
			  			$.wait_close();
				    		var jres = $.str2json(result);
				    		if (jres.code == "1") { //操作成功
				    			$('#layout_grid').html(jres.key+"="+$.json2str(jres.value));
						}else{
							alert(jres.desc);
							$('#layout_grid').html(jres.key+"不存在");
						}
			  		},
			  		error:function(result){
				    		$.wait_close();
				    		alert('网络错误!result='+result);
			  		}
			    });
		}
		function btn_remove(){
			var _tbname = $.combobox_getValue({id:'tbname'});
   			var _type = $('#cache_key').val();
   			if(!_tbname){
   				alert('请选择缓存表');
   				return;
   			}
   			if(!_type){
   				alert('请输入key');
   				return;
   			}
			var _data = {
					_SRVNAME:'service.pf.cache',
			   	  	_SRVMETHOD:'cache_remove',
		   	   		_DATA:$.json2str({
				   	   		tbname:$.combobox_getValue({id:'tbname'})
				   			,type: $('#cache_key').val()
		   			})
			    };
				//打开旋转 
				$.wait_open();
			  	//加载数据
				$.cuajax({
					url:'wdk?action=wdk.pub&method=call_service&ajaxparam='+new Date().getTime()
		     		,method:"post"
		      		,timeout:WDK_Timeout
		      		,data:_data
			  		,success:function(result) {
			  			//关闭旋转 
			  			$.wait_close();
				    		var jres = $.str2json(result);
						alert(jres.desc);
			  		},
			  		error:function(result){
				    		$.wait_close();
				    		alert('网络错误!result='+result);
			  		}
			    });
	  	}
		//重新加载
		function btn_reload(){
			var _tbname = $.combobox_getValue({id:'tbname'});
   			var _type = $('#cache_key').val();
   			if(!_tbname){
   				alert('请选择缓存表');
   				return;
   			}
			var _data = {
					_SRVNAME:'service.pf.cache',
			   	  	_SRVMETHOD:'cache_reload',
		   	   		_DATA:$.json2str({
				   	   		tbname:$.combobox_getValue({id:'tbname'})
		   			})
			    };
				//打开旋转 
				$.wait_open();
			  	//加载数据
				$.cuajax({
					url:'wdk?action=wdk.pub&method=call_service&ajaxparam='+new Date().getTime()
		     		,method:"post"
		      		,timeout:WDK_Timeout
		      		,data:_data
			  		,success:function(result) {
			  			//关闭旋转 
			  			$.wait_close();
				    		var jres = $.str2json(result);
						alert(jres.desc);
			  		},
			  		error:function(result){
				    		$.wait_close();
				    		alert('网络错误!result='+result);
			  		}
			    });
		}
		</script>
    
	
	</head>
	
	<body>
		<div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'north',border:false,collapsed:false" class="page-title" style="overflow:hidden">
				<div class="page-toolbar" style="padding-bottom: 5px;">
					<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'fa fa-info-circle'" onclick="btn_reload()" >通过消息加载</a>
					<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'fa fa-info-circle'" onclick="btn_reload()" >本地加载(必须在platform)里</a>
					<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'fa fa-info-circle'" onclick="btn_remove()" >删除</a>
				</div>
			</div>
			<div data-options="region:'center',border:false,collapsed:false" >	
				<div class="easyui-layout" data-options="fit:true">
					<div data-options="region:'north',border:false,collapsed:false" class="row-1" style="padding:0 10px;overflow:hidden;height:120px;" >
						<form id="search_form" >
							<div class="h_layout">
								<div>
									<div class="inputgroup">
										<label>缓存表:</label>
										<div>
											<input id="tbname" name="tbname" style="width:300px;"/>
										</div>
									</div>
									<div class="inputgroup">
										<label>缓存键:</label>
										<div>
											<input id="cache_key" name="cache_key" placeholder="请输入缓存键,复合键以逗号分隔"/>
										</div>
									</div>
								</div>
							</div>
							<div class="h_layout">
								<div>
									<div class="inputgroup">
										<label></label>
										<div>
										</div>
									</div>
									<div class="inputgroup">
										<label></label>
										<div>
										</div>
									</div>
								</div>
								<div style="width:125px;" >
									<a class="eapbutton" style="float:right;" onclick="btn_query()"><i class="fa fa-search" aria-hidden="true"></i><span><span>查询</span></span></a>
								</div>
							</div>
						</form>
					</div>
					<div id="layout_grid"  data-options="region:'center',border:false,collapsed:false" style="padding:0px 10px;" >
					</div>
				</div>
			</div>
		</div>
		
		
		
		<!-- 页面新增窗口 -->
		<div id="dlg_proj_oper" class="easyui-dialog" style="width:350px;height:350px;padding:10px 10px" title="新增缓存" closed="true" buttons="#dlg_button_page">
			<table>
				<tr>
					<td> <label>选择缓存表:</label></td>
					<td>
						<input id="dlg_cache_tbname" name="dlg_cache_tbname" class="easyui-validatebox" style="width:200px" >
					</td>
				</tr>
				<tr>
					<td> <label>缓存键:</label></td>
					<td><input id="dlg_cache_key" name="dlg_cache_key" class="easyui-validatebox" style="width:200px" ></td>
				</tr>
				<tr>
					<td> <label>缓存值:</label></td>
					<td><input id="dlg_cache_value" name="dlg_cache_value" class="easyui-validatebox" style="width:200px" ></td>
				</tr>
			</table>
	    </div>
	     <div id="dlg_button_page">
	        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="page_add_submit()">确定</a>
	        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg_proj_oper').dialog('close')">关闭</a>
	    </div>
	</body>
</html>