dic_easyerror.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  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. <script type="text/ecmascript" src="${ctx}/assets/lib/jquery/1.9.1/jquery.js"></script>
  21. <script type="text/javascript" src="${ctx}/assets/static/h-ui/js/H-ui.js"></script>
  22. <link rel="stylesheet" type="text/css" media="screen" href="${ctx}/assets/lib/jqueryui/jquery-ui.css" />
  23. <link rel="stylesheet" type="text/css" media="screen" href="${ctx}/assets/lib/jqgrid/css/ui.jqgrid.css" />
  24. <script type="text/ecmascript" src="${ctx}/assets/lib/jqueryui/jquery-ui.js"></script>
  25. <script type="text/ecmascript" src="${ctx}/assets/lib/jqgrid/js/i18n/grid.locale-cn.js"></script>
  26. <script type="text/ecmascript" src="${ctx}/assets/lib/jqgrid/js/jquery.jqGrid.min.js"></script>
  27. <link rel="stylesheet" href="${ctx}/assets/lib/zTree/v3/css/zTreeStyle/zTreeStyle.css" type="text/css">
  28. <script type="text/javascript" src="${ctx}/assets/lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
  29. <script type="text/javascript" src="${ctx}/assets/js/base.js"></script>
  30. <style type="text/css">
  31. ul.ztree {margin-top: 10px;border: 1px solid #617775;background: #f0f6e4;width:220px;height:360px;overflow-y:scroll;overflow-x:auto;}
  32. </style>
  33. <!--[if IE 6]>
  34. <script type="text/javascript" src="${ctx}/assets/lib/DD_belatedPNG_0.0.8a-min.js" ></script>
  35. <script>DD_belatedPNG.fix('*');</script>
  36. <![endif]-->
  37. <style type="text/css">
  38. select{width: 243px;}
  39. </style>
  40. <script type="text/javascript">
  41. $(function() {
  42. $(window).resize(function(){
  43. $("#tree").setGridWidth($(window).width()-40); 
  44. });
  45. $("#tree").jqGrid({
  46. caption:'易错词管理',
  47. url : '${ctx}/myconsole/dic_easyerror/getByTree',
  48. editurl:"${ctx}/myconsole/dic_easyerror/saveOrUpdate", //定义对form编辑时的url
  49. mtype : "POST", // ajax提交方式。POST或者GET,默认GET
  50. hoverrows:false, // 当为false时mouse hovering会被禁用 默认 false
  51. viewrecords:false, // 定义是否要显示总记录数
  52. gridview:true, // 构造一行数据后添加到grid中,如果设为true则是将整个表格的数据都构造完成后再添加到grid中,但treeGrid, subGrid, or afterInsertRow 不能用 默认为false
  53. height:"auto", // 表格高度,可以是数字,像素值或者百分比
  54. rowNum:100, // 在grid上显示记录条数,这个参数是要被传递到后台
  55. scrollrows:true, // 当为true时让所选择的行可见
  56. treeGrid:true, // 启用或者禁用treegrid模式 默认false
  57. ExpandColumn:"tname", // 指定那列来展开tree grid,默认为第一列,只有在treeGrid为true时起作用
  58. treedatatype:"json", // 数据类型,通常情况下与datatype相同,不会变
  59. treeGridModel:"adjacency", // treeGrid所使用的方法
  60. sortorder:"asc", // 排序顺序,升序或者降序(asc or desc) 默认asc
  61. autowidth : true, // 如果为ture时,则当表格在首次被创建时会根据父元素比例重新调整表格宽度。如果父元素宽度改变,为了使表格宽度能够自动调整则需要实现函数:setGridWidth 默认 false
  62. datatype:"json",
  63. pager:"#pager", // 定义翻页用的导航栏,必须是有效的html元素。翻页工具栏可以放置在html页面任意位置
  64. prmNames : { //定义表单的主键 // Default valuesprmNames: {page:“page”,rows:“rows”, sort: “sidx”,order: “sord”, search:“_search”, nd:“nd”, npage:null} 当参数为null时不会被发到服务器端
  65. id: "keyid", 
  66. oper:"oper",    
  67. addoper:"add",
  68. editoper:"edit",
  69. deloper:"del" 
  70. },
  71. colModel : [ {
  72. label : '数据编号',
  73. name : 'keyid',
  74. key : true,
  75. editable: false,
  76. hidden:true
  77. }, {
  78. label : '易错词',
  79. name : 'tname',
  80. editable: true,
  81. edittype:"text",
  82. width : 100,
  83. editoptions: {
  84. size:31,
  85. maxlength: 50
  86. },
  87. editrules:{
  88. required: true
  89. },
  90. formoptions:{
  91. elmsuffix:" <span style='color:red'>*<span>",
  92. rowpos:1,
  93. colpos:1
  94. }
  95. },{
  96. label : '类型',
  97. name : 'ttype',
  98. editable: true,
  99. edittype: "select",
  100. width : 50,
  101. editrules:{
  102. edithidden : true
  103. },
  104. editoptions:{
  105. dataInit: function(elem){
  106. $(elem).width(218);
  107. },
  108. maxlength: 40,
  109. value : "文章:文章;图片:图片;文件:文件;视频:视频"
  110. },
  111. formoptions:{
  112. elmsuffix:" <span style='color:red'>*<span>",
  113. rowpos:2,
  114. colpos:1
  115. }
  116. },{
  117. label : '排序编号',
  118. name : 'sortid',
  119. editable: true,
  120. hidden : true,
  121. edittype: "text",
  122. width : 100,
  123. editoptions: {
  124. size:31,
  125. maxlength: 50
  126. },
  127. editrules:{
  128. edithidden:true,
  129. required: true,
  130. custom:true, 
  131. custom_func: function(strFieldValue, strFieldName){
  132. var strFloat = /^([-\+]?(((\d+)(\.\d+))|(\.\d+)|(\d*)))?$/;
  133.  if(!strFloat.test(strFieldValue)){
  134.    return [false, strFieldName+"应该为实数"];
  135.   }
  136. else
  137. {
  138.   return [true,""];
  139. }
  140. }
  141. },
  142. formoptions:{
  143. elmsuffix:" <span style='color:red'>*<span>",
  144. rowpos:3,
  145. colpos:1
  146. }
  147. },{
  148. label : '创建人',
  149. name : 'username',
  150. width : 60,
  151. editable: false,
  152. edittype:"text"
  153. },{
  154. label : '创建时间',
  155. name : 'recordtime',
  156. width : 60,
  157. editable: false,
  158. edittype:"text"
  159. }, {
  160. "name":"treelevel",
  161. "hidden":true
  162. } ],
  163. "treeReader":{
  164. "level_field":"treelevel",
  165. "leaf_field":"isleaf",
  166. "expanded_field":"expanded",
  167. "loaded":"loaded",
  168. "parent_id_field":"parentid",
  169. "icon_field":"icon"
  170. }
  171. });
  172. jQuery('#tree').jqGrid('navGrid','#pager',
  173. {
  174. add : true,
  175. edit : true,
  176. del : true,
  177. search : false,
  178. refresh : true,
  179. view : false,
  180. position : "left",
  181. cloneToTop : true
  182. },
  183. //编辑按钮事件处理
  184. {
  185. closeAfterEdit : true,
  186. recreateForm : true,
  187. width:400,
  188. afterShowForm : function(formid) {
  189. },
  190. beforeSubmit: function(postdata, formid){
  191. // 编辑时jqgrid 将主键变成 tree_id 手动添加 keyid
  192. postdata["keyid"] = postdata.tree_id;
  193. $.each(postdata,function (index, value) {
  194. if(index!="oper"){
  195. modifyJosnKey(postdata,index,"dIC_easyerror."+index);
  196. }
  197. })
  198. return [true,'']; //返回值必须这么写 目前没找到原因,用true 和 返回对象都不好使。待查
  199. },
  200. afterSubmit: function(response,postdata)
  201. {
  202. var res=eval('(' + response.responseText + ')');
  203. if(res.flag)
  204. {
  205. parent.layer.alert(res.message, {
  206. skin: 'layui-layer-molv' //样式类名
  207. ,closeBtn: 0
  208. });
  209. return [true,res.message,''];
  210. }
  211. else
  212. {
  213. parent.layer.alert(res.message, {
  214. skin: 'layui-layer-molv' //样式类名
  215. ,closeBtn: 0
  216. });
  217. return [false,res.message,''];
  218. }
  219. },
  220. afterComplete : function (response, postdata, formid) {
  221. //取消选择
  222. $("#tree").jqGrid("resetSelection");
  223. //关闭对话框
  224. $(".ui-icon-closethick").trigger('click');
  225. },
  226. errorTextFormat : function(data) {
  227. return 'Error: ' + data.responseText
  228. }
  229. },
  230. //添加按钮处理事件
  231. {
  232. closeAfterAdd : true,
  233. recreateForm : true,
  234. checkOnUpdate : true,
  235. checkOnSubmit : true,
  236. width:400,
  237. afterShowForm : function(formid) {
  238. },
  239. serializeEditData: function(postdata) {
  240. //对主键字段进行赋值传递 韩林平
  241. var selRowId = $("#tree").jqGrid ('getGridParam', 'selrow');
  242. if(selRowId == null) selRowId = "";
  243. //获取选中的父节点主键值,添加下级站点
  244. postdata.parentid=selRowId;
  245. $.each(postdata,function(index,value){
  246. if(index!="oper"){
  247. modifyJosnKey(postdata,index,"dIC_easyerror."+index);
  248. }
  249. })
  250. //jqgrid 做添加操作会把主键id的值设置成“_empty”;这里修改成空;
  251. postdata["dIC_easyerror.keyid"]="";
  252. return postdata;
  253. },
  254. afterSubmit: function(response,postdata)
  255. {
  256. var res=eval('(' + response.responseText + ')');
  257. if(res.flag)
  258. {
  259. parent.layer.alert(res.message, {
  260. skin: 'layui-layer-molv' //样式类名
  261. ,closeBtn: 0
  262. });
  263. return [true,res.message,''];
  264. }
  265. else
  266. {
  267. parent.layer.alert(res.message, {
  268. skin: 'layui-layer-molv' //样式类名
  269. ,closeBtn: 0
  270. });
  271. return [false,res.message,''];
  272. }
  273. },
  274. errorTextFormat : function(data) {
  275. return 'Error: ' + data.responseText
  276. }
  277. },
  278. // options for the Delete Dailog
  279. {
  280. errorTextFormat : function(data) {
  281. return 'Error: ' + data.responseText
  282. },
  283. afterSubmit: function(response,postdata)
  284. {
  285. var res=eval('(' + response.responseText + ')');
  286. if(res.flag)
  287. {
  288. //alert(res.message);
  289. parent.layer.alert(res.message, {
  290. skin: 'layui-layer-molv' //样式类名
  291. ,closeBtn: 0
  292. });
  293. return [true,res.message,''];
  294. }
  295. else
  296. {
  297. return [false,res.message,''];
  298. }
  299. }
  300. });
  301. jQuery('#tree').jqGrid('bindKeys');
  302. })
  303. var zTree;
  304. var setting = {
  305. check: {
  306. enable: true,
  307. chkStyle: "radio",
  308. radioType: "all"
  309. },
  310. data: {
  311. simpleData: {
  312. enable: true,
  313. idKey: "keyid",
  314. pIdKey: "parentid",
  315. rootPId: 0
  316. },
  317. key:{
  318. name:"tname"
  319. }
  320. },
  321. callback: {
  322. onClick: onClick,
  323. onCheck: onCheck
  324. }
  325. };
  326. var zNodes =${dic_easyerrors};
  327. function onClick(e, treeId, treeNode) {
  328. var zTree = $.fn.zTree.getZTreeObj("treeSite");
  329. zTree.checkNode(treeNode, !treeNode.checked, null, true);
  330. return false;
  331. }
  332. function onCheck(){
  333. }
  334. function showMenu() {
  335. var cityObj = $("#citySel");
  336. var cityOffset = $("#citySel").offset();
  337. $("#menuContent").css({left:cityOffset.left + "px", top:cityOffset.top + cityObj.outerHeight() + "px"}).slideDown("fast");
  338. $("body").bind("mousedown", onBodyDown);
  339. }
  340. function hideMenu() {
  341. $("#menuContent").fadeOut("fast");
  342. $("body").unbind("mousedown", onBodyDown);
  343. }
  344. function onBodyDown(event) {
  345. if (!(event.target.id == "menuBtn" || event.target.id == "citySel" || event.target.id == "menuContent" || $(event.target).parents("#menuContent").length>0)) {
  346. hideMenu();
  347. }
  348. }
  349. $(function(){
  350. zTree=$.fn.zTree.init($("#treeSite"), setting, zNodes);
  351. });
  352. //表单验证
  353. </script>
  354. <title>我的桌面</title>
  355. </head>
  356. <body>
  357. <div class="page-container">
  358. <table id="tree"></table>
  359. <div id="pager"></div>
  360. </div>
  361. <div id="menuContent" class="menuContent" style="display:none; position: absolute;">
  362. <ul id="treeSite" class="ztree" style="margin-top:0; width:300px; height: 300px;"></ul>
  363. </div>
  364. <footer class="footer mt-20">
  365. <div class="container">
  366. <p> </p>
  367. </div>
  368. </footer>
  369. </body>
  370. </html>