org.html 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="renderer" content="webkit|ie-comp|ie-stand">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  7. <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
  8. <meta http-equiv="Cache-Control" content="no-siteapp" />
  9. <!--[if lt IE 9]>
  10. <script type="text/javascript" src="${ctx}/assets/lib/html5.js"></script>
  11. <script type="text/javascript" src="${ctx}/assets/lib/respond.min.js"></script>
  12. <script type="text/javascript" src="${ctx}/assets/lib/PIE_IE678.js"></script>
  13. <![endif]-->
  14. <link rel="stylesheet" type="text/css" href="${ctx}/assets/static/h-ui/css/H-ui.min.css" />
  15. <link rel="stylesheet" type="text/css" href="${ctx}/assets/static/h-ui.admin/css/H-ui.admin.css" />
  16. <link rel="stylesheet" type="text/css" href="${ctx}/assets/lib/Hui-iconfont/1.0.7/iconfont.css" />
  17. <link rel="stylesheet" type="text/css" href="${ctx}/assets/lib/icheck/icheck.css" />
  18. <link rel="stylesheet" type="text/css" href="${ctx}/assets/static/h-ui.admin/skin/default/skin.css" id="skin" />
  19. <link rel="stylesheet" type="text/css" href="${ctx}/assets/static/h-ui.admin/css/style.css" />
  20. <link rel="stylesheet" type="text/css" media="screen" href="${ctx}/assets/lib/zTree/v3/css/zTreeStyle/zTreeStyle.css" >
  21. <script type="text/ecmascript" src="${ctx}/assets/lib/jquery/1.9.1/jquery.js"></script>
  22. <script type="text/javascript" src="${ctx}/assets/lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
  23. <script type="text/javascript" src="${ctx}/assets/static/h-ui/js/H-ui.js"></script>
  24. <link rel="stylesheet" type="text/css" media="screen" href="${ctx}/assets/lib/jqueryui/jquery-ui.css" />
  25. <link rel="stylesheet" type="text/css" media="screen" href="${ctx}/assets/lib/jqgrid/css/ui.jqgrid.css" />
  26. <script type="text/ecmascript" src="${ctx}/assets/lib/jqueryui/jquery-ui.js"></script>
  27. <script type="text/ecmascript" src="${ctx}/assets/lib/jqgrid/js/i18n/grid.locale-cn.js"></script>
  28. <script type="text/ecmascript" src="${ctx}/assets/lib/jqgrid/js/jquery.jqGrid.min.js"></script>
  29. <script type="text/javascript" src="${ctx}/assets/js/base.js"></script>
  30. <script type="text/javascript">
  31. $(function(){
  32. $(window).resize(function(){
  33. $("#tree").setGridWidth($(window).width()-40); 
  34. });
  35. $("#tree").jqGrid({
  36. caption:'机构管理',
  37. url:'${ctx}/myconsole/org/getByTree',
  38. editurl:'${ctx}/myconsole/org/saveOrUpdate',
  39. mtype:"POST",
  40. datatype: "json",
  41. hoverrows:false,
  42. viewrecords:false,
  43. gridview:true,
  44. height:"auto",
  45. rowNum:100,
  46. scrollrows:true,
  47. treeGrid:true,
  48. ExpandColumn:"orgname",
  49. treedatatype:"json",
  50. treeGridModel:"adjacency",
  51. sortorder:"asc",
  52. autowidth:true,
  53. pager:"#pager",
  54. prmNames:{
  55. id:"orgid"
  56. },
  57. colModel:[{
  58. label : '编号',
  59. name : 'orgid',
  60. hidden : true,
  61. key : true,
  62. width : 75
  63. }, {
  64. label : '机构名称',
  65. name : 'orgname',
  66. edittype : "text",
  67. editable : true,
  68. formoptions:{
  69. elmsuffix:" <span style='color:red'>*<span>",
  70. },
  71. editrules:{required:true},
  72. width : 100,
  73. editoptions: {
  74. size:50,
  75. maxlength: 120
  76. }
  77. }, {
  78. label : '机构编号',
  79. name : 'orgid',
  80. edittype : "text",
  81. editable: true,
  82. formoptions:{
  83. elmsuffix:" <span style='color:red'>*<span>",
  84. },
  85. editrules:{required:true},
  86. width : 50,
  87. editoptions: {
  88. size:50,
  89. maxlength: 120
  90. }
  91. }, {
  92. label : '上级机构',
  93. name:"parentid",
  94. editable: false,
  95. width : 50,
  96. editoptions:{value:"${orgOptions}"}
  97. }, {
  98. label : '排序值',
  99. name : 'sortid',
  100. editable: true,
  101. hidden:true,
  102. edittype : "text",
  103. editrules:{
  104. edithidden:true,
  105. custom:true, 
  106. custom_func: function(strFieldValue, strFieldName){
  107. var strFloat = /^([-\+]?(((\d+)(\.\d+))|(\.\d+)|(\d*)))?$/;
  108.  if(!strFloat.test(strFieldValue)){
  109.    return [false, strFieldName+"应该为实数"];
  110.   }
  111. else
  112. {
  113.   return [true,""];
  114. }
  115. }
  116. },
  117. formoptions:{
  118. elmsuffix:' 必须是数字'
  119. },
  120. width : 50,
  121. editoptions: {
  122. size:50,
  123. maxlength: 5
  124. }
  125. },{
  126. label : '机构类型',
  127. name : 'orgtype',
  128. editable: true,
  129. edittype: "select",
  130. editoptions:{
  131. dataInit: function(elem){
  132. $(elem).width(334);
  133. },
  134. value : "总公司:总公司;分公司:分公司;中支公司:中支公司;内部:内部"
  135. },
  136. editrules:{edithidden:true},
  137. width : 45
  138. },{
  139. label : '机构描述',
  140. name : 'orgdesc',
  141. editable: true,
  142. hidden:true,
  143. width : 100,
  144. edittype : "textarea",
  145. editrules:{
  146. edithidden : true
  147. },
  148. editoptions: {
  149. size:50,
  150. maxlength: 120,
  151. rows:"5",
  152. cols:"48"
  153. }
  154. }, {
  155. label : '创建人',
  156. name : 'insertusername',
  157. editable: false,
  158. width : 35
  159. }, {
  160. label : '创建时间',
  161. name : 'inserttime',
  162. editable: false,
  163. width : 50
  164. }, {
  165. name:"treelevel",
  166. hidden:true
  167. } ],
  168. treeReader:{
  169. level_field:"treelevel",
  170. leaf_field:"isleaf",
  171. expanded_field:"expanded",
  172. loaded:"loaded",
  173. parent_id_field:"parentid",
  174. icon_field:"icon"
  175. }
  176. });
  177. jQuery('#tree').jqGrid('navGrid','#pager',
  178. {
  179. add : true,
  180. edit : true,
  181. del : true,
  182. search : false,
  183. refresh : true,
  184. view : false,
  185. position : "left",
  186. cloneToTop : true
  187. },
  188. //编辑按钮事件处理
  189. {
  190. closeAfterEdit : true,
  191. recreateForm : true,
  192. width:800,
  193. afterShowForm : function(formid) {
  194. var orgidObj = formid.find('#orgid');
  195. orgidObj.attr('readOnly',true);
  196. orgidObj.css({'background':'#cccccc'});
  197. },
  198. beforeSubmit: function(postdata, formid){
  199. // 编辑时jqgrid 将主键变成 tree_id 手动添加 keyid
  200. postdata["keyid"] = postdata.tree_id;
  201. $.each(postdata,function (index, value) {
  202. if(index!="oper"){
  203. modifyJosnKey(postdata,index,"org."+index);
  204. }
  205. })
  206. return [true,'']; //返回值必须这么写 目前没找到原因,用true 和 返回对象都不好使。待查
  207. },
  208. afterSubmit: function(response,postdata)
  209. {
  210. var res=eval('(' + response.responseText + ')');
  211. if(res.flag)
  212. {
  213. parent.layer.alert(res.message, {
  214. skin: 'layui-layer-molv' //样式类名
  215. ,closeBtn: 0
  216. });
  217. return [true,res.message,''];
  218. }
  219. else
  220. {
  221. parent.layer.alert(res.message, {
  222. skin: 'layui-layer-molv' //样式类名
  223. ,closeBtn: 0
  224. });
  225. return [false,res.message,''];
  226. }
  227. },
  228. afterComplete : function (response, postdata, formid) {
  229. //取消选择
  230. $("#tree").jqGrid("resetSelection");
  231. //关闭对话框
  232. $(".ui-icon-closethick").trigger('click');
  233. },
  234. errorTextFormat : function(data) {
  235. return 'Error: ' + data.responseText
  236. }
  237. },
  238. //添加按钮处理事件
  239. {
  240. closeAfterAdd : true,
  241. recreateForm : true,
  242. checkOnUpdate : true,
  243. checkOnSubmit : true,
  244. width:800,
  245. afterShowForm : function(formid) {
  246. var orgidObj = formid.find('#orgid');
  247. orgidObj.blur(function(){
  248. verifyOrg(orgidObj.val());
  249. });
  250. },
  251. serializeEditData: function(postdata) {
  252. //对主键字段进行赋值传递 韩林平
  253. var selRowId = $("#tree").jqGrid ('getGridParam', 'selrow');
  254. if(selRowId == null) selRowId = "";
  255. //获取选中的父节点主键值,添加下级站点
  256. $.each(postdata,function(index,value){
  257. if(index!="oper"){
  258. modifyJosnKey(postdata,index,"org."+index);
  259. }
  260. })
  261. //jqgrid 做添加操作会把主键id的值设置成“_empty”;这里修改成空;
  262. postdata["org.keyid"] = "";
  263. postdata["org.parentid"] = selRowId;
  264. return postdata;
  265. },
  266. afterSubmit: function(response,postdata)
  267. {
  268. var res=eval('(' + response.responseText + ')');
  269. if(res.flag)
  270. {
  271. parent.layer.alert(res.message, {
  272. skin: 'layui-layer-molv' //样式类名
  273. ,closeBtn: 0
  274. });
  275. return [true,res.message,''];
  276. }
  277. else
  278. {
  279. parent.layer.alert(res.message, {
  280. skin: 'layui-layer-molv' //样式类名
  281. ,closeBtn: 0
  282. });
  283. return [false,res.message,''];
  284. }
  285. },
  286. errorTextFormat : function(data) {
  287. return 'Error: ' + data.responseText
  288. }
  289. },
  290. // options for the Delete Dailog
  291. {
  292. errorTextFormat : function(data) {
  293. return 'Error: ' + data.responseText
  294. },
  295. afterSubmit: function(response,postdata)
  296. {
  297. var res=eval('(' + response.responseText + ')');
  298. if(res.flag)
  299. {
  300. parent.layer.alert(res.message, {
  301. skin: 'layui-layer-molv' //样式类名
  302. ,closeBtn: 0
  303. });
  304. return [true,res.message,''];
  305. }
  306. else
  307. {
  308. parent.layer.alert(res.message, {
  309. skin: 'layui-layer-molv' //样式类名
  310. ,closeBtn: 0
  311. });
  312. return [false,res.message,''];
  313. }
  314. }
  315. })
  316. jQuery('#tree').jqGrid('bindKeys');
  317. })
  318. function verifyOrg(orgID){
  319. if(orgID == "") return ;
  320. var errorShow = $(".FormError");
  321. errorShow.html("").hide();
  322. $.post("${ctx}/myconsole/org/verifyOrg", {'orgID':orgID},
  323. function(data){
  324. if(data.length>0){
  325. $('#orgid').val("");
  326. errorShow.html("该机构编号["+orgID+"]已存在,请尝试其他编号").show();
  327. }
  328. }
  329. );
  330. }
  331. </script>
  332. <title>机构管理</title>
  333. </head>
  334. <body>
  335. <div class="page-container">
  336. <table id="tree"></table>
  337. <div id="pager"></div>
  338. </div>
  339. <footer class="footer mt-20">
  340. <div class="container">
  341. <p></p>
  342. </div>
  343. </footer>
  344. </body>
  345. </html>