list.jsp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
  2. <jsp:include page="../../common/include.jsp" />
  3. <%String basePath = request.getScheme()+ "://" + request.getServerName() + ":" +request.getServerPort() + request.getContextPath(); %>
  4. <script type="text/javascript">
  5. /**显示区*/
  6. $(function() {
  7. $('#contactPersonDataGrid').datagrid({
  8. rownumbers:true,
  9. fit:true,
  10. pageSize:20,
  11. pageList : [ 10, 20, 30, 40, 50 ],
  12. fitColumns:false,
  13. border:false,
  14. sortOrder:'desc',
  15. pagination:true,
  16. idField:'id',
  17. url:whzl.basePath + '/contactPersonAction_list',
  18. toolbar:'#searchtool',
  19. checkOnSelect:true,
  20. selectOnCheck:true,
  21. nowrap:true,
  22. singleSelect:true,
  23. showFooter: true,
  24. loadFilter:function(result){
  25. if(result.success){
  26. return result.obj;
  27. }else{
  28. $.messager.alert("提示",result.message);
  29. return ;
  30. }
  31. }
  32. });
  33. });
  34. /**查询*/
  35. function searchFun(){
  36. $("#contactPersonDataGrid").datagrid("load", {
  37. "contactPerson.name":trim($("#name").val())
  38. });
  39. }
  40. /*清除查询条件**/
  41. function ClearQuery() {
  42. $("#tblQuery").find("input").val("");
  43. $("#tblQuery").find("select").val("-1");
  44. }
  45. /**详细*/
  46. var detailsFormatter = function(value , row , index){
  47. return "<img src='<%=basePath%>/js/easyui/themes/itemicon/detail.png' title='查看详情' onclick=details(" + row.id + ") style='cursor:pointer' />";
  48. };
  49. /**详细页面对话框*/
  50. var details = function(id){
  51. $("#detailDialog").dialog(
  52. {
  53. buttons : [
  54. {
  55. text : '确定',
  56. iconCls : 'icon-ok',
  57. handler : function(){
  58. $("#detailDialog").dialog("close");
  59. }
  60. }
  61. ],
  62. onLoad : function(){
  63. var contactsId;
  64. $.ajax({
  65. type: "post",//使用get方法访问后台
  66. dataType: "json",//返回json格式的数据
  67. url: "contactPersonAction_findById",//要访问的后台地址
  68. data: "contactPerson.id="+id,//要发送的数据
  69. complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
  70. success: function(msg){//msg为返回的数据,在这里做数据绑定
  71. $("#name_detail").text(msg.obj.name);
  72. $("#phone_detail").text(msg.obj.phone);
  73. contactsId = msg.obj.contactsId;
  74. }
  75. });
  76. $.ajax({
  77. type: "post",//使用get方法访问后台
  78. dataType: "json",//返回json格式的数据
  79. url: "contactsAction_list",//要访问的后台地址
  80. complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
  81. success: function(msg){//msg为返回的数据,在这里做数据绑定
  82. for(var i =0; i < msg.obj.rows.length; i++){
  83. if(contactsId == msg.obj.rows[i].id){
  84. $("#contactsId_detail").text(msg.obj.rows[i].name);
  85. }
  86. }
  87. }
  88. });
  89. }
  90. }
  91. );
  92. };
  93. /**更新*/
  94. var updateFormatter = function(value , row , index){
  95. return "<img src='<%=basePath%>/images/pencil.png' title='修改' onclick=updateRow(" + row.id + ") style='cursor:pointer' />";
  96. };
  97. /**更新事件*/
  98. function updateRow(){
  99. var row = $('#contactPersonDataGrid').datagrid('getSelected');
  100. if(row == null){
  101. $.messager.alert("提示","请先选择要修改的信息!");
  102. }
  103. var id = row.id;
  104. $('#updateDialog').dialog(
  105. {
  106. buttons : [
  107. {
  108. text : '提交',
  109. iconCls : 'icon-ok',
  110. handler : function(){
  111. $('#updateForm').form('submit',
  112. {
  113. url : whzl.basePath+'/contactPersonAction_update',
  114. success : function(result){
  115. var parseResult = $.parseJSON(result);
  116. if(parseResult.success){
  117. $("#updateDialog").dialog("close");
  118. $('#contactPersonDataGrid').datagrid('reload');
  119. }else{
  120. $.messager.alert("提示",parseResult.message);
  121. }
  122. }
  123. }
  124. );
  125. }
  126. },
  127. {
  128. text : '取消',
  129. iconCls : 'icon-cancel',
  130. handler : function(){
  131. $("#updateDialog").dialog("close");
  132. }
  133. }
  134. ],
  135. onLoad : function(){
  136. $.ajax({
  137. type: "post",//使用get方法访问后台
  138. dataType: "json",//返回json格式的数据
  139. url: "contactsAction_list",//要访问的后台地址
  140. complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
  141. success: function(msg){//msg为返回的数据,在这里做数据绑定
  142. for(var i =0; i < msg.obj.rows.length; i++){
  143. $("#contactsId_update").append("<option value="+msg.obj.rows[i].id+">"+msg.obj.rows[i].name+"</option>");
  144. }
  145. }
  146. });
  147. $.ajax({
  148. type: "post",//使用get方法访问后台
  149. dataType: "json",//返回json格式的数据
  150. url: "contactPersonAction_findById",//要访问的后台地址
  151. data: "contactPerson.id="+id,//要发送的数据
  152. complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
  153. success: function(msg){//msg为返回的数据,在这里做数据绑定
  154. $("#id_update").val(msg.obj.id);
  155. $("#name_update").val(msg.obj.name);
  156. $("#phone_update").val(msg.obj.phone);
  157. $("#contactsId_update").val(msg.obj.contactsId);
  158. }
  159. });
  160. }
  161. }
  162. );
  163. }
  164. /**删除*/
  165. var delFormatter = function(value , row , index){
  166. return "<img src='<%=basePath%>/images/edit_remove.png' title='删除' onclick=deleteRow(" + row.id+",'"+row.name + "') style='cursor:pointer' />";
  167. };
  168. /**删除功能*/
  169. function deleteRow(){
  170. var row = $('#contactPersonDataGrid').datagrid('getSelected');
  171. var id = row.id;
  172. var name = row.name;
  173. $.messager.confirm('删除提示', '确定删除这条记录吗?', function(r){
  174. if (r){
  175. $.ajax({
  176. type: "post",//使用get方法访问后台
  177. dataType: "json",//返回json格式的数据
  178. url: "contactPersonAction_del",//要访问的后台地址
  179. data: "contactPerson.id="+id,//要发送的数据
  180. complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
  181. success: function(msg){//msg为返回的数据,在这里做数据绑定
  182. if(msg.success){
  183. $.messager.alert('提示','删除成功!');
  184. $('#contactPersonDataGrid').datagrid('reload');
  185. }else{
  186. $.messager.alert('提示',msg.message);
  187. }
  188. }
  189. });
  190. }
  191. });
  192. }
  193. /**增加*/
  194. function add(){
  195. $('#addDialog').dialog(
  196. {
  197. buttons : [
  198. {
  199. text : '提交',
  200. iconCls : 'icon-ok',
  201. handler : function(){
  202. parent.$.messager.progress({
  203. title : '提示',
  204. text : '保存中,请稍后....'
  205. });
  206. $('#addForm').form('submit',
  207. {
  208. url : whzl.basePath+'/contactPersonAction_add',
  209. onSubmit: function(){
  210. var isValid =$('#addForm').form('validate');
  211. if(isValid == false){
  212. parent.$.messager.progress('close');
  213. }
  214. return isValid;
  215. },
  216. success : function(result){
  217. parent.$.messager.progress('close');
  218. var parseResult = $.parseJSON(result);
  219. if(parseResult.success){
  220. $("#addDialog").dialog("close");
  221. searchFun();
  222. }else{
  223. $.messager.alert("提示",parseResult.message);
  224. }
  225. }
  226. }
  227. );
  228. }
  229. },
  230. {
  231. text : '取消',
  232. iconCls : 'icon-cancel',
  233. handler : function(){
  234. $("#addDialog").dialog("close");
  235. }
  236. }
  237. ],
  238. onLoad : function(){
  239. $.ajax({
  240. type: "post",//使用get方法访问后台
  241. dataType: "json",//返回json格式的数据
  242. url: "contactsAction_list",//要访问的后台地址
  243. complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
  244. success: function(msg){//msg为返回的数据,在这里做数据绑定
  245. for(var i =0; i < msg.obj.rows.length; i++){
  246. $("#contactsId_add").append("<option value="+msg.obj.rows[i].id+">"+msg.obj.rows[i].name+"</option>");
  247. }
  248. }
  249. });
  250. }
  251. }
  252. );
  253. }
  254. </script>
  255. <div class="easyui-layout" data-options="fit:true,border:false">
  256. <div data-options="region:'center',border:false">
  257. <div id="searchtool" data-options="region:'north', border:false">
  258. <div class="clear"></div>
  259. <table id="tblQuery" style="width:100%;font-size:12px;">
  260. <tr>
  261. <td align="right"><span>姓名</span></td>
  262. <td width="250px"><input id="name" name="contactPerson.name" type="text"/></td>
  263. <td align="left">
  264. <a href="javascript:searchFun();" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true">查询</a>
  265. <a href="javascript:add();" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true">增加</a>
  266. <a href="javascript:updateRow();" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true">修改</a>
  267. <a href="javascript:deleteRow();" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true">删除</a>
  268. </td>
  269. </tr>
  270. </table>
  271. <div class="clear"></div>
  272. </div>
  273. <table id="contactPersonDataGrid">
  274. <thead frozen="true">
  275. <tr>
  276. <th data-options="field:'id',checkbox:true,width:30">ID</th>
  277. </tr>
  278. </thead>
  279. <thead>
  280. <tr>
  281. <th data-options="field:'name',sortable:true,width:150">姓名</th>
  282. <th data-options="field:'phone',sortable:true,width:200">手机号码</th>
  283. <th data-options="field:'details',align:'center',width:60,formatter:detailsFormatter">查看详情</th>
  284. </tr>
  285. </thead>
  286. </table>
  287. </div>
  288. </div>
  289. <div id="detailDialog" data-options="title:'&nbsp;用户详细信息',iconCls:'icon-details',width:600,height:250,modal:true,href:'<%=basePath %>/contactPersonAction_toDetail'">
  290. </div>
  291. <div id="updateDialog" data-options="title:'&nbsp;修改用户信息',iconCls:'icon-edit',width:600,height:250,modal:true,href:'<%=basePath %>/contactPersonAction_toUpdate'">
  292. </div>
  293. <div id="addDialog" data-options="title:'&nbsp;增加用户信息',iconCls:'icon-add',width:600,height:250,modal:true,href:'<%=basePath %>/contactPersonAction_toAdd'">
  294. </div>
  295. <script type="text/javascript">
  296. <!--
  297. $(function(){
  298. parent.$.messager.progress('close');
  299. });
  300. //-->
  301. </script>