123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314 |
- <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
- <jsp:include page="../../common/include.jsp" />
- <%String basePath = request.getScheme()+ "://" + request.getServerName() + ":" +request.getServerPort() + request.getContextPath(); %>
- <script type="text/javascript">
- /**显示区*/
- $(function() {
- $('#contactPersonDataGrid').datagrid({
- rownumbers:true,
- fit:true,
- pageSize:20,
- pageList : [ 10, 20, 30, 40, 50 ],
- fitColumns:false,
- border:false,
- sortOrder:'desc',
- pagination:true,
- idField:'id',
- url:whzl.basePath + '/contactPersonAction_list',
- toolbar:'#searchtool',
- checkOnSelect:true,
- selectOnCheck:true,
- nowrap:true,
- singleSelect:true,
- showFooter: true,
- loadFilter:function(result){
- if(result.success){
- return result.obj;
- }else{
- $.messager.alert("提示",result.message);
- return ;
- }
- }
- });
- });
-
- /**查询*/
- function searchFun(){
- $("#contactPersonDataGrid").datagrid("load", {
- "contactPerson.name":trim($("#name").val())
- });
- }
-
- /*清除查询条件**/
- function ClearQuery() {
- $("#tblQuery").find("input").val("");
- $("#tblQuery").find("select").val("-1");
- }
-
- /**详细*/
- var detailsFormatter = function(value , row , index){
- return "<img src='<%=basePath%>/js/easyui/themes/itemicon/detail.png' title='查看详情' onclick=details(" + row.id + ") style='cursor:pointer' />";
- };
-
- /**详细页面对话框*/
- var details = function(id){
- $("#detailDialog").dialog(
- {
- buttons : [
- {
- text : '确定',
- iconCls : 'icon-ok',
- handler : function(){
- $("#detailDialog").dialog("close");
- }
- }
- ],
- onLoad : function(){
- var contactsId;
- $.ajax({
- type: "post",//使用get方法访问后台
- dataType: "json",//返回json格式的数据
- url: "contactPersonAction_findById",//要访问的后台地址
- data: "contactPerson.id="+id,//要发送的数据
- complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
- success: function(msg){//msg为返回的数据,在这里做数据绑定
- $("#name_detail").text(msg.obj.name);
- $("#phone_detail").text(msg.obj.phone);
- contactsId = msg.obj.contactsId;
- }
- });
-
- $.ajax({
- type: "post",//使用get方法访问后台
- dataType: "json",//返回json格式的数据
- url: "contactsAction_list",//要访问的后台地址
- complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
- success: function(msg){//msg为返回的数据,在这里做数据绑定
- for(var i =0; i < msg.obj.rows.length; i++){
- if(contactsId == msg.obj.rows[i].id){
- $("#contactsId_detail").text(msg.obj.rows[i].name);
- }
- }
- }
- });
- }
- }
- );
- };
-
- /**更新*/
- var updateFormatter = function(value , row , index){
- return "<img src='<%=basePath%>/images/pencil.png' title='修改' onclick=updateRow(" + row.id + ") style='cursor:pointer' />";
- };
-
- /**更新事件*/
- function updateRow(){
- var row = $('#contactPersonDataGrid').datagrid('getSelected');
- if(row == null){
- $.messager.alert("提示","请先选择要修改的信息!");
- }
- var id = row.id;
- $('#updateDialog').dialog(
- {
- buttons : [
- {
- text : '提交',
- iconCls : 'icon-ok',
- handler : function(){
- $('#updateForm').form('submit',
- {
- url : whzl.basePath+'/contactPersonAction_update',
- success : function(result){
- var parseResult = $.parseJSON(result);
- if(parseResult.success){
- $("#updateDialog").dialog("close");
- $('#contactPersonDataGrid').datagrid('reload');
- }else{
- $.messager.alert("提示",parseResult.message);
- }
- }
- }
- );
- }
- },
- {
- text : '取消',
- iconCls : 'icon-cancel',
- handler : function(){
- $("#updateDialog").dialog("close");
- }
- }
- ],
- onLoad : function(){
- $.ajax({
- type: "post",//使用get方法访问后台
- dataType: "json",//返回json格式的数据
- url: "contactsAction_list",//要访问的后台地址
- complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
- success: function(msg){//msg为返回的数据,在这里做数据绑定
- for(var i =0; i < msg.obj.rows.length; i++){
- $("#contactsId_update").append("<option value="+msg.obj.rows[i].id+">"+msg.obj.rows[i].name+"</option>");
- }
- }
- });
-
- $.ajax({
- type: "post",//使用get方法访问后台
- dataType: "json",//返回json格式的数据
- url: "contactPersonAction_findById",//要访问的后台地址
- data: "contactPerson.id="+id,//要发送的数据
- complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
- success: function(msg){//msg为返回的数据,在这里做数据绑定
- $("#id_update").val(msg.obj.id);
- $("#name_update").val(msg.obj.name);
- $("#phone_update").val(msg.obj.phone);
- $("#contactsId_update").val(msg.obj.contactsId);
- }
- });
- }
- }
- );
- }
-
- /**删除*/
- var delFormatter = function(value , row , index){
- return "<img src='<%=basePath%>/images/edit_remove.png' title='删除' onclick=deleteRow(" + row.id+",'"+row.name + "') style='cursor:pointer' />";
- };
-
- /**删除功能*/
- function deleteRow(){
- var row = $('#contactPersonDataGrid').datagrid('getSelected');
- var id = row.id;
- var name = row.name;
- $.messager.confirm('删除提示', '确定删除这条记录吗?', function(r){
- if (r){
- $.ajax({
- type: "post",//使用get方法访问后台
- dataType: "json",//返回json格式的数据
- url: "contactPersonAction_del",//要访问的后台地址
- data: "contactPerson.id="+id,//要发送的数据
- complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
- success: function(msg){//msg为返回的数据,在这里做数据绑定
- if(msg.success){
- $.messager.alert('提示','删除成功!');
- $('#contactPersonDataGrid').datagrid('reload');
- }else{
- $.messager.alert('提示',msg.message);
- }
- }
- });
- }
- });
- }
-
- /**增加*/
- function add(){
- $('#addDialog').dialog(
- {
- buttons : [
- {
- text : '提交',
- iconCls : 'icon-ok',
- handler : function(){
- parent.$.messager.progress({
- title : '提示',
- text : '保存中,请稍后....'
- });
- $('#addForm').form('submit',
- {
- url : whzl.basePath+'/contactPersonAction_add',
- onSubmit: function(){
- var isValid =$('#addForm').form('validate');
- if(isValid == false){
- parent.$.messager.progress('close');
- }
- return isValid;
- },
- success : function(result){
- parent.$.messager.progress('close');
- var parseResult = $.parseJSON(result);
- if(parseResult.success){
- $("#addDialog").dialog("close");
- searchFun();
- }else{
- $.messager.alert("提示",parseResult.message);
- }
- }
- }
- );
- }
- },
- {
- text : '取消',
- iconCls : 'icon-cancel',
- handler : function(){
- $("#addDialog").dialog("close");
- }
- }
- ],
- onLoad : function(){
- $.ajax({
- type: "post",//使用get方法访问后台
- dataType: "json",//返回json格式的数据
- url: "contactsAction_list",//要访问的后台地址
- complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
- success: function(msg){//msg为返回的数据,在这里做数据绑定
- for(var i =0; i < msg.obj.rows.length; i++){
- $("#contactsId_add").append("<option value="+msg.obj.rows[i].id+">"+msg.obj.rows[i].name+"</option>");
- }
- }
- });
- }
- }
- );
- }
- </script>
- <div class="easyui-layout" data-options="fit:true,border:false">
- <div data-options="region:'center',border:false">
- <div id="searchtool" data-options="region:'north', border:false">
- <div class="clear"></div>
- <table id="tblQuery" style="width:100%;font-size:12px;">
- <tr>
- <td align="right"><span>姓名</span></td>
- <td width="250px"><input id="name" name="contactPerson.name" type="text"/></td>
- <td align="left">
- <a href="javascript:searchFun();" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true">查询</a>
- <a href="javascript:add();" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true">增加</a>
- <a href="javascript:updateRow();" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true">修改</a>
- <a href="javascript:deleteRow();" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true">删除</a>
- </td>
- </tr>
- </table>
- <div class="clear"></div>
- </div>
-
- <table id="contactPersonDataGrid">
- <thead frozen="true">
- <tr>
- <th data-options="field:'id',checkbox:true,width:30">ID</th>
- </tr>
- </thead>
- <thead>
- <tr>
- <th data-options="field:'name',sortable:true,width:150">姓名</th>
- <th data-options="field:'phone',sortable:true,width:200">手机号码</th>
- <th data-options="field:'details',align:'center',width:60,formatter:detailsFormatter">查看详情</th>
- </tr>
- </thead>
- </table>
- </div>
- </div>
- <div id="detailDialog" data-options="title:' 用户详细信息',iconCls:'icon-details',width:600,height:250,modal:true,href:'<%=basePath %>/contactPersonAction_toDetail'">
- </div>
- <div id="updateDialog" data-options="title:' 修改用户信息',iconCls:'icon-edit',width:600,height:250,modal:true,href:'<%=basePath %>/contactPersonAction_toUpdate'">
- </div>
- <div id="addDialog" data-options="title:' 增加用户信息',iconCls:'icon-add',width:600,height:250,modal:true,href:'<%=basePath %>/contactPersonAction_toAdd'">
- </div>
- <script type="text/javascript">
- <!--
- $(function(){
- parent.$.messager.progress('close');
- });
- //-->
- </script>
|