easyui框架 jsp页面

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<meta charset="utf-8">
<link href="<%=basePath%>css/themes/default/easyui.css" rel="stylesheet" type="text/css"/>
<%-- <link href="<%=basePath%>css/themes/icon.css" rel="stylesheet" type="text/css"/> --%>
<link href="<%=basePath%>css/themes/color.css" rel="stylesheet" type="text/css"/>
<%-- <link href="<%=basePath%>css/themes/mobile.css" rel="stylesheet" type="text/css"/> --%>


<script type="text/javascript" src="<%=basePath%>js/jquery.min.js"></script>
<script type="text/javascript" src="<%=basePath%>js/easyloader.js"></script>
<script type="text/javascript" src="<%=basePath%>js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="<%=basePath%>js/jquery.easyui.mobile.js"></script>
<script type="text/javascript" src="<%=basePath%>js/plugins/jquery.parser.js"></script>
<script type="text/javascript" src="<%=basePath%>js/plugins/jquery.pagination.js"></script>
<script type="text/javascript" src="<%=basePath%>js/plugins/jquery.form.js"></script>
<style type="text/css">
#producttable{
width: 90%;
border-collapse:separate; border-spacing:0px 20px;
}
#producttable input{
height:32px;
}
</style>

</head>
<body>
<div style="height: 50%;width:70%;float: left;display:inline-block;margin-top: 35px;">
<table id="allotControltable">

</table>
</div>
<!-- 添加角色 -->
<div id="allotControlAdd">
<form id="allotControlAddform">
<table id="producttable">
<tr>
<td align="right">角色名称: </td>
<td>
<input id="REMARK" name="REMARK"></input>
</td>
<td align="right">类型生效标志:</td>
<td>
<select id="EFFECT_STS" name="EFFECT_STS" >
<option value="1" selected="selected">生效</option>
<option value="2">无效</option>
</select>
</td>
</tr>
</table>
</form>
</div>
<!-- 修改角色 -->
<div id="allotControlUpdate">
<form id="allotControlUpdateform">
<table id="producttable">
<tr>
<td align="right">角色名称: </td>
<td>
<input id="remark1" name="REMARK"></input>
</td>
<td align="right">类型生效标志:</td>
<td>
<select id="effect_STS1" name="EFFECT_STS" >
<option value="1" selected="selected">生效</option>
<option value="2">无效</option>
</select>
</td>
</tr>
<tr>
<td align="right">时间戳: </td>
<td>
<input id="tm_SMP1" name="TM_SMP" readonly="readonly"></input>
</td>

</tr>
</table>
</form>
</div>

<div id="container"
style="width: 12%; height: 800px;display:inline-block; float: left !important;">
<div class="easyui-panel" title="权限列表"
style="width: 100%; height: 99%; float: right !important; overflow-y: scroll; background-color: #fff">
<ul>
<input type="checkbox" id="tree_select" name="tree_select"
onclick="allselect()" />
<a>全选或者取消全选</a>
</ul>
<ul id="dgMenu" class="easyui-tree" style="width: 200px"></ul>
</div>
</div>
<script type="text/javascript">
//全选或者取消全选
function allselect(){
var tree_select = $('#tree_select').is(':checked');
var roots = $('#dgMenu').tree('getRoots');//返回tree的所有根节点数组
console.log(tree_select);
if (tree_select==true) {
for ( var i = 0; i < roots.length; i++) {
var node = $('#dgMenu').tree('find', roots[i].id);//查找节点
$('#dgMenu').tree('check', node.target);//将得到的节点选中
}
} else {
for ( var i = 0; i < roots.length; i++) {
var node = $('#dgMenu').tree('find', roots[i].id);
$('#dgMenu').tree('uncheck', node.target);
}
}
}

$('#dgMenu').tree({
checkbox: 'checked',
cascadeCheck: true,
url: '<%=basePath%>user/getMenu.do',
loadFilter: function(data){
console.log(data);
return data;
},
/* onBeforeLoad:function(node,param){
param.categoryId = "13";
} */
});

$("#allotControltable").datagrid({
//var row = $('#xyData_userListlk').datagrid('getSelected');
onClickRow: function (index, row) {
var categoryId=row.tm_SMP;//用户类别ID
//alert("查询已经有的权限======"+categoryId);
$('#dgMenu').tree({
checkbox: true,
cascadeCheck: true,
url: '<%=basePath%>user/getMenu.do?categoryId='+categoryId,
loadFilter: function(data){
return data;
}
});
}

});


//添加用户
$('#allotControlAdd').dialog({
title:'添加用户',
width:'50%',
height:'300px',
iconCls:'icon-add',
closed:true,
closable: true,
draggable: false,
modal: true,
buttons:[ {
text : '保存',
iconCls : 'icon-ok',
handler : function() {
$('#allotControlAddform').form('submit',{
onSubmit:function(){
return $(this).form('enableValidation').form('validate');
},
url:'<%=basePath%>user/allotControlAdd.do',
success : function(data) {
data = eval("(" + data + ")");//JSON字符串转对象
$.messager.show({
title:'提示',
msg: data.msg,
showType:'show'
});
$('#allotControlAdd').dialog('close');
$('#allotControltable').datagrid('reload');
},
error: function(){
$.messager.show({
title:'提示',
msg: '添加失败',
showType:'show'
});
}
});
}
}, {
text : '取消',
iconCls : 'icon-cancel',
handler : function() {
$('#allotControlAdd').dialog('close');
}
} ]
});
//修改产品

$('#allotControlUpdate').dialog({
title:'添加用户',
width:'50%',
height:'300px',
iconCls:'icon-add',
closed:true,
closable: true,
draggable: false,
modal: true,
buttons:[ {
text : '保存',
iconCls : 'icon-ok',
handler : function() {
$('#allotControlUpdateform').form('submit',{
onSubmit:function(){
return $(this).form('enableValidation').form('validate');
},
url:'<%=basePath%>user/allotControlUpdate.do',
success : function(data) {
data = eval("(" + data + ")");//JSON字符串转对象
$.messager.show({
title:'提示',
msg: data.msg,
showType:'show'
});
$('#allotControlUpdate').dialog('close');
$('#allotControltable').datagrid('reload');
},
error: function(){
$.messager.show({
title:'提示',
msg: data.msg,
showType:'show'
});
}
});
}
}, {
text : '取消',
iconCls : 'icon-cancel',
handler : function() {
$('#allotControlUpdate').dialog('close');
}
} ]
});
$('#').dialog('close');
$('#allotControlUpdate').dialog('close');
$('#allotControltable').datagrid({
width: 'auto',
height:'auto',
striped: true,
fit: true,
pagination: true,
scrollbarSize: 0,
singleSelect: true,
url: '<%=basePath%>user/findAllotControl.do',
loadMsg: '数据加载中请稍后……',
columns: [[{
field: 'category_ID',
title: '产品编号',
align: 'center',
resizable: false,
width: '10%'
},{
field: 'remark',
title: '角色名称',
align: 'center',
resizable: false,
width: '15%'
}, {
field: 'effect_STS',
title: '类型生效标志',
align: 'center',
resizable: false,
width: '15%'
}, {
field: 'tm_SMP',
title: '时间戳',
align: 'center',
resizable: false,
width: '15%'
}, {
field: 'upd_OPER',
title: '维护操作员',
align: 'center',
resizable: false,
width: '15%'
}, {
field: 'org_NO',
title: '机构编号',
align: 'center',
resizable: false,
width: '15%'
}, {
field: 'del_STATUS',
title: '删除状态',
align: 'center',
resizable: false,
width: '15%'
}
]],
method: 'post',
toolbar: [{
text:'添加',
iconCls: 'icon-edit',
handler: function(){
$('#allotControlAddform').form('clear');
$('#allotControlAdd').dialog('open').dialog('setTitle', '添加产品');
$("#EFFECT_STS").val(Array('1'))
}
},'-',{
text:'修改',
iconCls: 'icon-help',
handler: function(){
var row=$('#allotControltable').datagrid('getSelected');
if(row){

$('#allotControlUpdateform').form('load',row);
$('#remark1').val(row.remark);
$('#tm_SMP1').val(row.tm_SMP);
$('#effect_STS1').val(row.effect_STS);
//alert(row.remark+"--"+row.tm_SMP+"--"+row.effect_STS)

$('#allotControlUpdate').dialog('open').dialog('setTitle', '添加产品');

}else{
$.messager.show({
title:'提示',
msg: '至少选择一条',
showType:'show'
});
}

}
},'-',{
text:'删除',
iconCls: 'icon-help',
handler: function(){
var row=$('#allotControltable').datagrid('getSelected');
if(row){
$.messager.confirm('删除数据', '您确定删除此用户吗?', function(r){
if (r){
$.post('<%=basePath%>user/deleteAllotControltable.do?TM_SMP=' + row.tm_SMP+"&CATEGORY_ID="+ row.tm_SMP,
function (result) {
$.messager.show({
title:'提示',
msg: result.msg,
showType:'show'
});
$('#allotControltable').datagrid('reload');

},'json');
}
});

}else{
$.messager.show({
title:'提示',
msg: '至少选择一条',
showType:'show'
});
}

}
},'-',{
text:'保存权限',
iconCls: 'icon-help',
handler: function(){
var row=$('#allotControltable').datagrid('getSelected');

if(row){
//获取选中的树状结构项
var nodes = $('#dgMenu').tree('getChecked', ['checked','indeterminate']);

console.log('nodes=='+nodes);
var checkNod='';
for(var i=0;i<nodes.length;i++){
if(i==nodes.length-1){
checkNod+=nodes[i].id;
}else{
checkNod+=nodes[i].id+',';
}
}
console.log('checkNod=='+checkNod);
$.messager.confirm('保存权限', '确认保存此权限吗?', function(r){
$.post('<%=basePath%>user/saveMenus.do?checkNod=' + checkNod+"&CATEGORY_ID="+ row.tm_SMP+'&UPD_OPER='+row.upd_OPER,
function(result){
$.messager.show({
title:'提示',
msg: result.msg,
showType:'show'
});
},'json')
})
}else{
$.messager.show({
title:'提示',
msg: '至少选择一条',
showType:'show'
});
}

}
}

]
});

var p = $('#allotControltable').datagrid('getPager');
$(p).pagination({
pageSize : 10,//每页显示的记录条数,默认为10
pageList : [10, 20, 30],//可以设置每页记录条数的列表
beforePageText : '第',//页数文本框前显示的汉字
afterPageText : '页 共 {pages} 页',
displayMsg : '当前显示 {from} - {to} 条记录 共 {total} 条记录',
});
</script>
</body>
</html>

 

jsp基本页面===========

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<meta charset="utf-8">
<link href="<%=basePath%>css/themes/default/easyui.css" rel="stylesheet" type="text/css"/>
<%-- <link href="<%=basePath%>css/themes/icon.css" rel="stylesheet" type="text/css"/> --%>
<link href="<%=basePath%>css/themes/color.css" rel="stylesheet" type="text/css"/>
<%-- <link href="<%=basePath%>css/themes/mobile.css" rel="stylesheet" type="text/css"/> --%>


<script type="text/javascript" src="<%=basePath%>js/jquery.min.js"></script>
<script type="text/javascript" src="<%=basePath%>js/easyloader.js"></script>
<script type="text/javascript" src="<%=basePath%>js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="<%=basePath%>js/jquery.easyui.mobile.js"></script>
<script type="text/javascript" src="<%=basePath%>js/plugins/jquery.parser.js"></script>
<script type="text/javascript" src="<%=basePath%>js/plugins/jquery.pagination.js"></script>
<script type="text/javascript" src="<%=basePath%>js/plugins/jquery.form.js"></script>
<style type="text/css">
#producttable{
width: 90%;
border-collapse:separate; border-spacing:0px 20px;
}
#producttable input{
height:32px;
}
</style>

</head>
<body>

<div style="height: 800px;margin-top: 35px;">
<table id="listtable">

</table>
</div>
<!-- 添加产品 -->
<div id="addproduct">
<form id="addproductform" enctype="multipart/form-data" >
<table id="producttable">
<tr>
<td align="right">生产人: </td>
<td>
<input id="creat_pepole" name="creat_pepole"></input>
</td>
<td align="right">产品名称:</td>
<td>
<input id="product_name" name="product_name"></input>
</td>
</tr>
<tr>
<td align="right">生产时间: </td>
<td>
<input id="creat_time" name="creat_time" class="easyui-datebox" required="required"></input>
</td>
<td align="right">产品数量:</td>
<td>
<input id="product_count" name="product_count"></input>
</td>
</tr>
<tr>
<td align="right">生产编号: </td>
<td>
<input id="creat_num" name="creat_num"></input>
</td>
<td align="right">生产地址:</td>
<td>
<input id="product_addres" name="product_addres"></input>
</td>
</tr>
<tr>
<td align="right">保质期: </td>
<td>
<select id="save_time" name="save_time" style="width: 170px;height: 32px;">
<option value="5" selected="selected">5</option>
<option value="10">10</option>
<option value="15">15</option>
</select>
</td>
<td align="right">上传附件: </td>
<td>
<input type="file" onchange="upload()" name="download" ></input>
</td>
</tr>
<tr>
<td align="right">文件路径: </td>
<td>
<input name="filePath" id="filePath" type="text" readonly="readonly"></input>
</td>
<td align="right">上传附件: </td>
<td>
<input type="text" name="myfiles" id="myfiles" readonly="readonly"></input>
</td>
</tr>
</table>
</form>
</div>
<!-- 修改产品 -->
<div id="updateproduct">
<form id="updateproductform">
<table id="producttable">
<tr>
<td align="right">生产人: </td>
<td>
<input id="creat_pepole" name="creat_pepole"></input>
</td>
<td align="right">单位类别:</td>
<td>
<input id="product_name" name="product_name"></input>
</td>
</tr>
<tr>
<td align="right">生产时间: </td>
<td>
<input id="creat_time" name="creat_time" class="easyui-datebox" required="required"></input>
</td>
<td align="right">产品数量:</td>
<td>
<input id="product_count" name="product_count"></input>
</td>
</tr>
<tr>
<td align="right">生产编号: </td>
<td>
<input id="creat_num" name="creat_num"></input>
</td>
<td align="right">生产地址:</td>
<td>
<input id="product_addres" name="product_addres"></input>
</td>
</tr>
<tr>
<td align="right">保质期: </td>
<td>
<select id="save_time" name="save_time" style="width: 170px;height: 32px;">
<option value="5" selected="selected">5</option>
<option value="10">10</option>
<option value="15">15</option>
</select>
</td>
<td align="right">上传附件: </td>
<td>
<input type="text" name="myfiles" id="myfilesdown" readonly="readonly"></input>
</td>
</tr>
<tr>
<td align="right">文件路径: </td>
<td>
<input name="filePath" id="filePathdown" type="text" readonly="readonly"></input>
</td>
<td align="right">下载: </td>
<td>
<input value="下载" type="button" onclick="download()"></input>
</td>
</tr>
</table>
</form>
</div>
<script type="text/javascript">
function download(){
var fileName=$('#myfilesdown').val();
var filePathdown=$('#filePathdown').val();
if(null!=fileName&&""!=fileName){
window.location.href="<%=basePath%>file/download.do?fileName="+fileName;
}
}

function upload(){

//var myfiles =$('#myfiles').val();
var fomdata=new FormData($('#addproductform')[0])
//alert('进来看看fomdata=='+fomdata)

$.ajax({
url:'<%=basePath%>file/fileUpload.do',//地址
data:fomdata,
type:'post',//类型
cache:false,
processData:false,
contentType:false,
//请求成功
success:function(data){
//alert(data.fileName);
var filePath=data.filePath;
$("#filePath").val(filePath);
$("#myfiles").val(data.fileName);

},
//失败/超时
error:function(XMLHttpRequest,textStatus,errorThrown){
if(textStatus==='timeout'){
alert('請求超時');
setTimeout(function(){
alert('重新请求');
},2000);
}
//alert(errorThrown);
}
})
<%-- window.location.href="<%=basePath%>files/toUpload.do"; --%>
}

//设置日期格式
$.fn.datebox.defaults.formatter = function(date){
var y = date.getFullYear();
var m = date.getMonth()+1;
var d = date.getDate();
return y+'-'+m+'-'+d;
}

//添加用户
$('#addproduct').dialog({
title:'添加用户',
width:'50%',
height:'600px',
iconCls:'icon-add',
closed:true,
closable: true,
draggable: false,
modal: true,
buttons:[ {
text : '保存',
iconCls : 'icon-ok',
handler : function() {
$('#addproductform').form('submit',{
onSubmit:function(){
return $(this).form('enableValidation').form('validate');
},
url:'<%=basePath%>product/addProduct.do',
success : function(data) {
data = eval("(" + data + ")");//JSON字符串转对象
$.messager.show({
title:'提示',
msg: data.msg,
showType:'show'
});
$('#addproduct').dialog('close');
$('#listtable').datagrid('reload');
},
error: function(){
$.messager.show({
title:'提示',
msg: '添加失败',
showType:'show'
});
}
});
}
}, {
text : '取消',
iconCls : 'icon-cancel',
handler : function() {
$('#addproduct').dialog('close');
}
} ]
});
//修改产品

$('#updateproduct').dialog({
title:'添加用户',
width:'50%',
height:'600px',
iconCls:'icon-add',
closed:true,
closable: true,
draggable: false,
modal: true,
buttons:[ {
text : '保存',
iconCls : 'icon-ok',
handler : function() {
$('#updateproductform').form('submit',{
onSubmit:function(){
return $(this).form('enableValidation').form('validate');
},
url:'<%=basePath%>product/supdateProduct.do',
success : function(data) {
alert(data)
data = eval("(" + data + ")");//JSON字符串转对象
$.messager.show({
title:'提示',
msg: data.msg,
showType:'show'
});
$('#updateproduct').dialog('close');
$('#listtable').datagrid('reload');
},
error: function(){
$.messager.show({
title:'提示',
msg: data.msg,
showType:'show'
});
}
});
}
}, {
text : '取消',
iconCls : 'icon-cancel',
handler : function() {
$('#updateproduct').dialog('close');
}
} ]
});
$('#addproduct').dialog('close');
$('#updateproduct').dialog('close');
$('#listtable').datagrid({
width: 'auto',
height:'auto',
striped: true,
fit: true,
pagination: true,
scrollbarSize: 0,
singleSelect: true,
url: '<%=basePath%>product/findProductList.do',
loadMsg: '数据加载中请稍后……',
columns: [[{
field: 'product_no',
title: '产品编号',
align: 'center',
resizable: false,
width: '10%'
},{
field: 'product_name',
title: '产品名',
align: 'center',
resizable: false,
width: '15%'
}, {
field: 'creat_time',
title: '生产日期',
align: 'center',
resizable: false,
width: '15%'
}, {
field: 'product_count',
title: '产品数量',
align: 'center',
resizable: false,
width: '15%'
}, {
field: 'creat_num',
title: '生产编号',
align: 'center',
resizable: false,
width: '15%'
}, {
field: 'product_addres',
title: '生产地址',
align: 'center',
resizable: false,
width: '15%'
}, {
field: 'creat_pepole',
title: '生产人',
align: 'center',
resizable: false,
width: '15%'
}, {
field: 'save_time',
title: '保质期',
align: 'center',
resizable: false,
width: '15%'
}, {
field: 'myfiles',
title: '文件名称',
align: 'center',
resizable: false,
width: '15%'
}, {
field: 'filePath',
title: '文件路径',
align: 'center',
resizable: false,
width: '15%'
}
]],
method: 'post',
toolbar: [{
text:'添加',
iconCls: 'icon-edit',
handler: function(){
$('#addproductform').form('clear');
$('#addproduct').dialog('open').dialog('setTitle', '添加产品');
$("#save_time").val(Array('5'))
}
},'-',{
text:'修改',
iconCls: 'icon-help',
handler: function(){
var row=$('#listtable').datagrid('getSelected');
if(row){

$('#updateproductform').form('load',row);
$('#updateproduct').dialog('open').dialog('setTitle', '添加产品');

}else{
$.messager.show({
title:'提示',
msg: '至少选择一条',
showType:'show'
});
}

}
},'-',{
text:'删除',
iconCls: 'icon-help',
handler: function(){
var row=$('#listtable').datagrid('getSelected');
if(row){
$.messager.confirm('删除数据', '您确定删除此用户吗?', function(r){
if (r){
$.post('<%=basePath%>product/deleteProduct.do?product_no=' + row.product_no,
function (result) {
$.messager.show({
title:'提示',
msg: result.msg,
showType:'show'
});
$('#listtable').datagrid('reload');

},'json');
}
});

}else{
$.messager.show({
title:'提示',
msg: '至少选择一条',
showType:'show'
});
}

}
}]
});

var p = $('#listtable').datagrid('getPager');
$(p).pagination({
pageSize : 10,//每页显示的记录条数,默认为10
pageList : [10, 20, 30],//可以设置每页记录条数的列表
beforePageText : '第',//页数文本框前显示的汉字
afterPageText : '页 共 {pages} 页',
displayMsg : '当前显示 {from} - {to} 条记录 共 {total} 条记录',
});
</script>
</body>
</html>

posted @ 2019-12-08 12:52  红尘沙漏  阅读(870)  评论(0编辑  收藏  举报