list.jsp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  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. $.ajax({
  8. type: "post",
  9. dataType: "json",
  10. url: "columnSetAction_listColumn?tname=foreignCompany",
  11. complete :function(){$("#load").hide();},
  12. success: function(msg){
  13. if(msg.success){
  14. setId();
  15. var data = msg.obj;
  16. for(var i = 0;i<data.length;i++){
  17. if("1"==data[i].type){
  18. if(typeof(data[i].formatter)!="undefined"){
  19. data[i].formatter=eval(data[i].formatter);
  20. }
  21. user_columns.push(data[i]);
  22. }else{
  23. user_frozenColumns.push(data[i]);
  24. }
  25. }
  26. columns.push(user_columns);
  27. frozenColumns.push(user_frozenColumns);
  28. $('#foreignCompanyDataGrid').datagrid({
  29. rownumbers:true,
  30. fit:true,
  31. pageSize:20,
  32. pageList : [ 10, 20, 30, 40, 50 ],
  33. fitColumns:false,
  34. border:false,
  35. sortOrder:'desc',
  36. pagination:true,
  37. idField:'id',
  38. url:whzl.basePath + '/foreignCompanyAction_list',
  39. toolbar:'#searchtool',
  40. checkOnSelect:true,
  41. selectOnCheck:true,
  42. singleSelect:true,
  43. showFooter: true,
  44. columns:columns,
  45. frozenColumns:frozenColumns,
  46. loadFilter:function(result){
  47. if(result.success){
  48. return result.obj;
  49. }else{
  50. $.messager.alert("提示",result.message);
  51. return ;
  52. }
  53. }
  54. });
  55. toolBar("foreignCompanyDataGrid","setForeignCompanyDialog","foreignCompany");
  56. }
  57. }
  58. });
  59. /* $('#foreignCompanyDataGrid').datagrid({
  60. rownumbers:true,
  61. fit:true,
  62. pageSize:20,
  63. pageList : [ 10, 20, 30, 40, 50 ],
  64. fitColumns:false,
  65. border:false,
  66. sortOrder:'desc',
  67. pagination:true,
  68. idField:'id',
  69. url:whzl.basePath + '/foreignCompanyAction_list',
  70. toolbar:'#searchtool',
  71. checkOnSelect:true,
  72. selectOnCheck:false,
  73. nowrap:true,
  74. loadFilter:function(result){
  75. if(result.success){
  76. return result.obj;
  77. }else{
  78. $.messager.alert("提示",result.message);
  79. return ;
  80. }
  81. }
  82. }
  83. );*/
  84. });
  85. /**查询*/
  86. function searchFun(){
  87. /*var params = encodeURI("foreignCompany.name="+trim($('#name').val())+
  88. "&foreignCompany.contacts="+trim($('#contacts').val())
  89. );*/
  90. $("#foreignCompanyDataGrid").datagrid("load", {
  91. "foreignCompany.name":$("#tblQuery").find("input[id='name']").val(),
  92. "foreignCompany.contacts":$("#tblQuery").find("input[id='contacts']").val()
  93. });
  94. $('#foreignCompanyDataGrid').datagrid({url:whzl.basePath + '/foreignCompanyAction_list',pageNumber:1});
  95. $('#foreignCompanyDataGrid').datagrid({
  96. columns:columns,
  97. frozenColumns:frozenColumns
  98. //url:whzl.basePath + '/foreignCompanyAction_list?'+params,pageNumber:1
  99. });
  100. toolBar("foreignCompanyDataGrid","setForeignCompanyDialog","foreignCompany");
  101. }
  102. /*清除查询条件**/
  103. function ClearQuery() {
  104. $("#tblQuery").find("input").val("");
  105. $("#tblQuery").find("select").val("-1");
  106. }
  107. /**录入人*/
  108. var userNameFormatter = function(value , row , index){
  109. return row.createUser.fullName;
  110. };
  111. /**详细*/
  112. var detailsFormatter = function(value , row , index){
  113. return "<img src='<%=basePath%>/js/easyui/themes/itemicon/detail.png' title='查看详情' onclick=foreignCompanyDetails(" + row.id + ") style='cursor:pointer' />";
  114. };
  115. /**详细页面对话框*/
  116. var foreignCompanyDetails = function(id){
  117. $("#detailforeignCompanyDialog").dialog(
  118. {
  119. buttons : [
  120. {
  121. text : '确定',
  122. iconCls : 'icon-ok',
  123. handler : function(){
  124. $("#detailforeignCompanyDialog").dialog("close");
  125. }
  126. }
  127. ],
  128. onLoad : function(){
  129. $.ajax({
  130. type: "post",//使用get方法访问后台
  131. dataType: "json",//返回json格式的数据
  132. url: "foreignCompanyAction_findById",//要访问的后台地址
  133. data: "foreignCompany.id="+id,//要发送的数据
  134. complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
  135. success: function(msg){//msg为返回的数据,在这里做数据绑定
  136. $("#name_detail").html(msg.obj.name);
  137. $("#address_detail").html(msg.obj.address);
  138. $("#contacts_detail").html(msg.obj.contacts);
  139. $("#phone_detail").html(msg.obj.phone);
  140. }
  141. });
  142. }
  143. }
  144. );
  145. };
  146. /**更新*/
  147. var updateFormatter = function(value , row , index){
  148. return "<img src='<%=basePath%>/images/pencil.png' title='修改' onclick=updateRow(" + row.id + ") style='cursor:pointer' />";
  149. };
  150. /**更新事件*/
  151. function updateRow(){
  152. //var updateIndex = $('#foreignCompanyDataGrid').datagrid('getRowIndex', id);
  153. var row = $('#foreignCompanyDataGrid').datagrid('getSelected');
  154. if(row == null){
  155. $.messager.alert("提示","请先选择要修改的外方单位!");
  156. }
  157. var id = row.id;
  158. $('#updateforeignCompanyDialog').dialog(
  159. {
  160. buttons : [
  161. {
  162. text : '提交',
  163. iconCls : 'icon-ok',
  164. handler : function(){
  165. $('#updateForeignCompanyForm').form('submit',
  166. {
  167. url : whzl.basePath+'/foreignCompanyAction_update',
  168. success : function(result){
  169. var parseResult = $.parseJSON(result);
  170. if(parseResult.success){
  171. //修改完数据,更新对应行的数据
  172. $("#updateforeignCompanyDialog").dialog("close");
  173. $('#foreignCompanyDataGrid').datagrid('reload');
  174. }else{
  175. $.messager.alert("提示",parseResult.message);
  176. }
  177. }
  178. }
  179. );
  180. }
  181. },
  182. {
  183. text : '取消',
  184. iconCls : 'icon-cancel',
  185. handler : function(){
  186. $("#updateforeignCompanyDialog").dialog("close");
  187. }
  188. }
  189. ],
  190. onLoad : function(){
  191. $.ajax({
  192. type: "post",//使用get方法访问后台
  193. dataType: "json",//返回json格式的数据
  194. url: "foreignCompanyAction_findById",//要访问的后台地址
  195. data: "foreignCompany.id="+id,//要发送的数据
  196. complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
  197. success: function(msg){//msg为返回的数据,在这里做数据绑定
  198. $("#id_update").val(msg.obj.id);
  199. $("#name_update").val(msg.obj.name);
  200. $("#address_update").val(msg.obj.address);
  201. $("#contacts_update").val(msg.obj.contacts);
  202. $("#phone_update").val(msg.obj.phone);
  203. }
  204. });
  205. }
  206. }
  207. );
  208. }
  209. /**增加用户*/
  210. function add(){
  211. $('#addforeignCompanyDialog').dialog(
  212. {
  213. buttons : [
  214. {
  215. text : '提交',
  216. iconCls : 'icon-ok',
  217. handler : function(){
  218. $('#addForeignCompanyForm').form('submit',
  219. {
  220. url : whzl.basePath+'/foreignCompanyAction_add',
  221. success : function(result){
  222. var parseResult = $.parseJSON(result);
  223. if(parseResult.success){
  224. $("#addforeignCompanyDialog").dialog("close");
  225. $('#foreignCompanyDataGrid').datagrid('reload');
  226. }else{
  227. $.messager.alert("提示",parseResult.message);
  228. }
  229. }
  230. }
  231. );
  232. }
  233. },
  234. {
  235. text : '取消',
  236. iconCls : 'icon-cancel',
  237. handler : function(){
  238. $("#addforeignCompanyDialog").dialog("close");
  239. }
  240. }
  241. ]
  242. }
  243. );
  244. }
  245. /**删除*/
  246. var delFormatter = function(value , row , index){
  247. return "<img src='<%=basePath%>/images/edit_remove.png' title='删除' onclick=deleteRow(" + row.id + ") style='cursor:pointer' />";
  248. };
  249. /**删除功能*/
  250. function deleteRow(){
  251. var row = $('#foreignCompanyDataGrid').datagrid('getSelected');
  252. if(row == null){
  253. $.messager.alert("提示","请先选择要删除的外方单位!");
  254. }
  255. var id = row.id;
  256. $.messager.confirm('删除提示', '确定删除这条记录吗?', function(r){
  257. if (r){
  258. $.ajax({
  259. type: "post",//使用get方法访问后台
  260. dataType: "json",//返回json格式的数据
  261. url: "foreignCompanyAction_delete",//要访问的后台地址
  262. data: "foreignCompany.id="+id,//要发送的数据
  263. complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
  264. success: function(msg){//msg为返回的数据,在这里做数据绑定
  265. if(msg.success){
  266. $.messager.alert('提示','删除成功!');
  267. $('#foreignCompanyDataGrid').datagrid('reload');
  268. }else{
  269. $.messager.alert('提示','删除失败!');
  270. }
  271. }
  272. });
  273. }
  274. });
  275. }
  276. </script>
  277. <div class="easyui-layout" data-options="fit:true,border:false">
  278. <div data-options="region:'center',border:false">
  279. <div id="searchtool" data-options="region:'north' , border:false">
  280. <div class="clear"></div>
  281. <table id="tblQuery" style="width:100%;">
  282. <tr>
  283. <td align="right" style="width: 10%;"><span>单位名称</span></td><td style="width: 10%;"><input id="name" type="text" style="width: 140px;"/></td>
  284. <td align="right" style="width: 8%;"><span>单位联系人</span></td><td style="width: 14%;"><input id="contacts" type="text" style="width: 100px;"/></td>
  285. <td align="left" style="width: 58%;">
  286. <a href="javascript:searchFun();" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true">查询</a>
  287. <a href="javascript:ClearQuery();" class="easyui-linkbutton" data-options="iconCls:'icon-emptied',plain:true">清空</a>
  288. <a href="javascript:add();" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true">增加</a>
  289. <a href="javascript:updateRow();" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true">修改</a>
  290. <a href="javascript:deleteRow();" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true">删除</a>
  291. </td>
  292. </tr>
  293. </table>
  294. <div class="clear"></div>
  295. </div>
  296. <table id="foreignCompanyDataGrid">
  297. <!--<thead frozen="true">
  298. <tr>
  299. <th data-options="field:'id',checkbox:true,width:30">ID</th>
  300. </tr>
  301. </thead>
  302. <thead>
  303. <tr>
  304. <th data-options="field:'name',sortable:true,width:150">单位名称</th>
  305. <th data-options="field:'address',sortable:true,width:200">单位地址</th>
  306. <th data-options="field:'contacts',sortable:true,width:100">单位联系人</th>
  307. <th data-options="field:'phone',align:'center',width:100">单位联系电话</th>
  308. <th data-options="field:'userName',align:'center',width:100,formatter:userNameFormatter">录入人</th>
  309. <th data-options="field:'details',align:'center',width:60,formatter:detailsFormatter">查看详情</th>
  310. <th data-options="field:'update',align:'center',width:38,formatter:updateFormatter">修改</th>
  311. <th data-options="field:'delete',align:'center',width:38,formatter:delFormatter">删除</th>
  312. </tr>
  313. </thead>-->
  314. </table>
  315. </div>
  316. </div>
  317. <div id="detailforeignCompanyDialog" data-options="title:'&nbsp;外方单位详细信息',iconCls:'icon-details',width:500,height:250,modal:true,href:'<%=basePath %>/foreignCompanyAction_toDetail'">
  318. </div>
  319. <div id="updateforeignCompanyDialog" data-options="title:'&nbsp;修改外方单位信息',iconCls:'icon-edit',width:500,height:250,modal:true,href:'<%=basePath %>/foreignCompanyAction_toUpdate'">
  320. </div>
  321. <div id="addforeignCompanyDialog" data-options="title:'&nbsp;增加外方单位信息',iconCls:'icon-add',width:500,height:250,modal:true,href:'<%=basePath %>/foreignCompanyAction_toAdd'">
  322. </div>
  323. <div id="setForeignCompanyDialog" data-options="title:'&nbsp;个性化设置',iconCls:'icon-cog',width:500,height:370,modal:true,href:'<%=basePath %>/columnSetAction_toSet?tname=foreignCompany'">
  324. </div>
  325. <script type="text/javascript">
  326. parent.$.messager.progress('close');
  327. </script>