columnList.jsp 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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. $('#columnDataGrid').datagrid({
  8. rownumbers:true,
  9. fit:true,
  10. pageSize:10,
  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 + '/columnAction_listColumn',
  18. toolbar:'#searchtool',
  19. checkOnSelect:true,
  20. selectOnCheck:false,
  21. nowrap:true,
  22. loadFilter:function(result){
  23. if(result.success){
  24. return result.obj;
  25. }else{
  26. $.messager.alert("提示",result.message);
  27. return ;
  28. }
  29. }
  30. }
  31. );
  32. });
  33. /**查询*/
  34. function searchFun(){
  35. var params = encodeURI("column.title="+trim($("#tblQuery").find("input[id='title']").val())+
  36. "&column.tname="+trim($("#tblQuery").find("input[id='tname']").val()));
  37. $('#columnDataGrid').datagrid({url:whzl.basePath + '/columnAction_listColumn?'+params,pageNumber:1});
  38. }
  39. /**查询*/
  40. function searchOrder(){
  41. var params = encodeURI("column.title="+trim($("#tblQuery").find("input[id='title']").val())+
  42. "&column.tname="+trim($("#tblQuery").find("input[id='tname']").val()));
  43. $('#columnDataGrid').datagrid({url:whzl.basePath + '/columnAction_listColumn?sort=id&order=desc&'+params,pageNumber:1});
  44. }
  45. /*清除查询条件**/
  46. function ClearQuery() {
  47. $("#tblQuery").find("input").val("");
  48. $("#tblQuery").find("select").val("-1");
  49. }
  50. /**更新*/
  51. var updateFormatter = function(value , row , index){
  52. return "<img src='<%=basePath%>/js/easyui/themes/itemicon/update.png' title='修改' onclick=updateRow(" + row.id + ") style='cursor:pointer' />";
  53. };
  54. /**更新事件*/
  55. function updateRow(id){
  56. var updateIndex = $('#columnDataGrid').datagrid('getRowIndex', id);
  57. $('#updateColumnDialog').dialog(
  58. {
  59. buttons : [
  60. {
  61. text : '提交',
  62. iconCls : 'icon-ok',
  63. handler : function(){
  64. $('#updateColumnForm').form('submit',
  65. {
  66. url : whzl.basePath+'/columnAction_updateColumn',
  67. success : function(result){
  68. var parseResult = $.parseJSON(result);
  69. if(parseResult.success){
  70. //修改完数据,更新对应行的数据
  71. $('#columnDataGrid').datagrid('updateRow',
  72. {
  73. index : updateIndex,
  74. row : parseResult.obj
  75. }
  76. );
  77. $("#updateColumnDialog").dialog("close");
  78. //$('#columnDataGrid').datagrid('reload');
  79. }else{
  80. $.messager.alert("提示",parseResult.message);
  81. }
  82. }
  83. }
  84. );
  85. }
  86. },
  87. {
  88. text : '取消',
  89. iconCls : 'icon-cancel',
  90. handler : function(){
  91. $("#updateColumnDialog").dialog("close");
  92. }
  93. }
  94. ],
  95. onLoad : function(){
  96. $.ajax({
  97. type: "post",//使用get方法访问后台
  98. dataType: "json",//返回json格式的数据
  99. url: "columnAction_findById",//要访问的后台地址
  100. data: "column.id="+id,//要发送的数据
  101. complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
  102. success: function(msg){//msg为返回的数据,在这里做数据绑定
  103. $("#id_update").val(msg.obj.id);
  104. $("#title_update").val(msg.obj.title);
  105. $("#tname_update").val(msg.obj.tname);
  106. $("#field_update").val(msg.obj.field);
  107. $("#num_update").val(msg.obj.num);
  108. $("#formatter_update").val(msg.obj.formatter);
  109. }
  110. });
  111. }
  112. }
  113. );
  114. }
  115. /**删除*/
  116. var delFormatter = function(value , row , index){
  117. return "<img src='<%=basePath%>/js/easyui/themes/itemicon/delete.png' title='删除' onclick=deleteRow(" + row.id + ") style='cursor:pointer' />";
  118. };
  119. /**删除功能*/
  120. function deleteRow(id){
  121. $.messager.confirm('删除提示', '确定删除这条记录吗?', function(r){
  122. if (r){
  123. $.ajax({
  124. type: "post",//使用get方法访问后台
  125. dataType: "json",//返回json格式的数据
  126. url: "columnAction_deleteColumn",//要访问的后台地址
  127. data: "column.id="+id,//要发送的数据
  128. complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
  129. success: function(msg){//msg为返回的数据,在这里做数据绑定
  130. if(msg.success){
  131. $.messager.alert('提示','删除成功!');
  132. //$('#columnDataGrid').datagrid('reload');
  133. searchFun();
  134. }else{
  135. $.messager.alert('提示','删除失败!');
  136. }
  137. }
  138. });
  139. }
  140. });
  141. }
  142. /**增加数据字典*/
  143. function columnAdd(){
  144. $('#addColumnDialog').dialog(
  145. {
  146. buttons : [
  147. {
  148. text : '提交',
  149. iconCls : 'icon-ok',
  150. handler : function(){
  151. $('#addColumnForm').form('submit',
  152. {
  153. url : whzl.basePath+'/columnAction_addColumn',
  154. success : function(result){
  155. var parseResult = $.parseJSON(result);
  156. if(parseResult.success){
  157. $("#addColumnDialog").dialog("close");
  158. searchOrder();
  159. }else{
  160. $.messager.alert("提示",parseResult.message);
  161. }
  162. }
  163. }
  164. );
  165. }
  166. },
  167. {
  168. text : '取消',
  169. iconCls : 'icon-cancel',
  170. handler : function(){
  171. $("#addColumnDialog").dialog("close");
  172. }
  173. }
  174. ]
  175. }
  176. );
  177. }
  178. </script>
  179. <div class="easyui-layout" data-options="fit:true,border:false">
  180. <div data-options="region:'center',border:false">
  181. <div id="searchtool" data-options="region:'north' , border:false">
  182. <div class="clear"></div>
  183. <table id="tblQuery" style="width:100%;font-size:12px;">
  184. <tr>
  185. <td align="right" width="80px"><span>表名</span></td><td width="100px"><input id="tname" name="column.tname" type="text"/></td>
  186. <td align="right" width="60px"><span>名称</span></td><td width="240px"><input id="title" name="column.title" type="text"/></td>
  187. <td align="left">
  188. <a href="javascript:searchFun();" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true">查询</a>
  189. <a href="javascript:ClearQuery();" class="easyui-linkbutton" data-options="iconCls:'icon-emptied',plain:true">清空</a>
  190. <a href="javascript:columnAdd();" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true">增加</a>
  191. </td>
  192. </tr>
  193. </table>
  194. <div class="clear"></div>
  195. </div>
  196. <table id="columnDataGrid">
  197. <thead frozen="true">
  198. <tr>
  199. <th data-options="field:'id',checkbox:true,width:30">ID</th>
  200. </tr>
  201. </thead>
  202. <thead>
  203. <tr>
  204. <th data-options="field:'tname',width:100,editor:'textbox'">表名</th>
  205. <th data-options="field:'title',width:90,editor:'textbox'">名称</th>
  206. <th data-options="field:'field',width:100,editor:'textbox'">属性</th>
  207. <th data-options="field:'num',width:120">排序</th>
  208. <th data-options="field:'formatter',width:120">格式化</th>
  209. <th data-options="field:'update',align:'center',width:38,formatter:updateFormatter">修改</th>
  210. <th data-options="field:'delete',align:'center',width:38,formatter:delFormatter">删除</th>
  211. </tr>
  212. </thead>
  213. </table>
  214. </div>
  215. </div>
  216. <div id="updateColumnDialog" data-options="title:'&nbsp;修改数据字典信息',iconCls:'icon-edit',width:700,height:250,modal:true,href:'<%=basePath %>/columnAction_toUpdate'">
  217. </div>
  218. <div id="addColumnDialog" data-options="title:'&nbsp;增加数据字典信息',iconCls:'icon-add',width:700,height:250,modal:true,href:'<%=basePath %>/columnAction_toAdd'">
  219. </div>
  220. <script type="text/javascript">
  221. <!--
  222. $(function(){
  223. parent.$.messager.progress('close');
  224. });
  225. //-->
  226. </script>