<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'cmfz_listen.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/datagrid-detailview.js"></script>
<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/css/css.css">
<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/css/easyui.css">
<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/css/icon.css">
</head>
<body>
<form id="queryUserForm" method="post" enctype="multipart/form-data">
<table id="showAllcmfz_user">
<div id="lele">
<a href="javascript:void(0)" class="easyui-linkbutton" plain="true" data-options="iconCls:'icon-add'" onClick="toAdd()">添加</a>
<a href="javascript:void(0)" class="easyui-linkbutton" plain="true" data-options="iconCls:'icon-edit'"onClick="toUpdate()">修改</a>
<a href="javascript:void(0)" class="easyui-linkbutton" plain="true" data-options="iconCls:'icon-remove'"onClick="toDelete()">删除</a>
<a href="javascript:void(0)" class="easyui-linkbutton" plain="true" data-options="iconCls:'icon-print'" onClick="exportUser();">导出</a>
<input id="fileName" class="easyui-filebox" name="fileName" style="width:200px;vertical-align:middle;" />
<a href="javascript:void(0)" onclick="importUser()" class="easyui-linkbutton">开始导入</a>
</div>
</table>
</form>
<div id="adduser" class="easyui-dialog" data-options="closed:true">
<form id="adduserInformation" enctype="multipart/form-data" method="post">
用户名:<input name="telphone"><br/>
密码:<input name="password"><br/>
用户头像:<input name="uploadFile" class="easyui-filebox" data-options="
buttonText:'选择文件',
width:150,
height:20
"><br/>
真实名字:<input name="name"><br/>
法号:<input name="nickname"><br/>
所在省:<input name="userSheng"><br/>
所在市:<input name="userShi"><br/>
<a href="javascript:void(0)" onclick="doAdd()" class="easyui-linkbutton">确认</a>
</form>
</div>
<div id="updateuser"class="easyui-dialog" data-options="closed:true">
<form id="updateuserInformation" enctype="multipart/form-data" method="post">
<input id="userId" name="userId" style="display: none">
用户名:<input id="telphone" name="telphone"><br/><br/>
密码:<input id="password" name="password"><br/><br/>
<input id="userImage" name="userImage" style="display: none">
用户头像:<input name="uploadFile" class="easyui-filebox" data-options="
buttonText:'选择文件',
width:150,
height:20
"><br/><br/>
真实名字:<input id="name" name="name"><br/><br/>
法号:<input id="nickname" name="nickname"><br/><br/>
所在省:<input id="userSheng" name="userSheng"><br/><br/>
所在市:<input id="userShi" name="userShi"><br/><br/>
<a href="javascript:void(0)" onclick="doUpdate()" class="easyui-linkbutton">确认</a>
</form>
<p id="guru_picture"></p>
</div>
</body>
</html>
<script type="text/javascript">
$(function(){
$("#showAllcmfz_user").datagrid({
url:"${pageContext.request.contextPath}/user/showtAllUser.do",
pagination:true,
pageSize:5,
pageList:[5,10],
toolbar:"#lele",
columns:[[
{field:"",title:"",checkbox:true},
{field:"userId",title:"用户ID",width:40,align:"center",hidden:true},
{field:"telphone",title:"用户名",width:100,align:"center"},
{field:"password",title:"密码",width:100,align:"center"},
{field:"userImage",title:"用户头像",width:100,align:"center",formatter:function(value,row){
if(value){
return "<image width=50 height=50 src='${pageContext.request.contextPath}/picture"+value+"'/>"
}
}},
{field:"name",title:"真实名字",width:100,align:"center"},
{field:"nickname",title:"法号",width:100,align:"center"},
{field:"userSheng",title:"所在省",width:100,align:"center"},
{field:"userShi",title:"所在市",width:100,align:"center"},
]]
});
$("#queryUserForm").form({
url:'${pageContext.request.contextPath}/user/importUser.do',
success:function(data){
$.messager.alert("提示框","导入成功",'info');
$("#showAllcmfz_user").datagrid("reload");
}
});
});
function importUser(){
var fileName = $("#fileName").filebox("getValue");
var fileNameStr = fileName.substr(fileName.indexOf(".")+1).toUpperCase();
if(fileName==null || fileName==""){
alert("请选择要导入的excel文件");
}else if(fileNameStr=="XLS" || fileNameStr=="XLSX"){
var flag=true;
if(flag){
$.messager.confirm("确定对话框","确认导入吗?",function(n){
if(n){
$("#queryUserForm").submit();
}
})
}
}else{
$.messager.alert("提示框","文件类型不一致",'warning');
}
}
function exportUser(){
var ids = [];
var users = $("#showAllcmfz_user").datagrid("getChecked");
if(users.length==0){
$.messager.alert("提示","请选择要导出的数据");
}else{
$.each(users,function(index,value){
ids.push(value.userId)
})
$.messager.confirm('提示','您确认要导出吗?',function(n){
if(n){
window.location.href="${pageContext.request.contextPath}/user/exportMessage.do?ids="+ids+"&time="+new Date();
}else{
alert("取消")
}
});
}
}
function toAdd() {
$("#adduser").dialog("open");
}
function doAdd() {
$("#adduserInformation").form("submit", {
url : "${pageContext.request.contextPath}/user/insert.do",
success : function(data) {
var i = JSON.parse(data);
if (i.insert == "200") {
$("#adduser").dialog("close");
$("#showAllcmfz_user").datagrid("reload");
} else {
alert("添加失败");
}
}
});
}
function toDelete() {
var rows = $("#showAllcmfz_user").datagrid("getSelections");
if (rows.length == 0) {
alert("请选中要删除的内容")
} else {
var isDelete = confirm("确认是否要删除选中的所有内容;一旦确认删除将无法恢复!");
if (isDelete) {
var ids = new Array(rows.length);
for (var i = 0; i < rows.length; i++) {
ids[i] = rows[i].userId;
}
$.ajax({
url : "${pageContext.request.contextPath}/user/deleteMore.do",
data : {
"ids" : ids
},
traditional : true,
success : function(data) {
if (data.delete == "200") {
$("#showAllcmfz_user").datagrid("reload");
} else {
alert("删除失败");
}
}
});
}
}
}
function toUpdate() {
alert("修改操作")
var row = $("#showAllcmfz_user").datagrid("getSelected");
alert("修改操作")
if (row == null) {
alert("请选中要修改的内容")
} else {
$("#updateuser").dialog("open");
$("#userId").val(row.userId);
$("#telphone").val(row.telphone);
$("#password").val(row.password);
$("#nickname").val(row.nickname);
$("#name").val(row.name);
$("#userSheng").val(row.userSheng);
$("#userShi").val(row.userShi);
$("#userImage").val(row.userImage);
}
}
function doUpdate() {
alert("------------------------")
$("#updateuserInformation").form("submit", {
url : "${pageContext.request.contextPath}/user/update.do",
success : function(data) {
data = JSON.parse(data);
if (data.update == "200") {
$("#updateuser").dialog("close");
$("#showAllcmfz_user").datagrid("reload");
} else {
alert("修改失败");
}
}
});
}
</script>