extendmodel.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  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. <script type="text/javascript" src="${ctx}/assets/js/base.js"></script>
  28. <!--[if IE 6]>
  29. <script type="text/javascript" src="${ctx}/assets/lib/DD_belatedPNG_0.0.8a-min.js" ></script>
  30. <script>DD_belatedPNG.fix('*');</script>
  31. <![endif]-->
  32. <script type="text/javascript">
  33. $(function() {
  34. $(window).resize(function(){
  35. $("#jqGrid").setGridWidth($(window).width()-40); 
  36. });
  37. $("#jqGrid").jqGrid({
  38. url : '${ctx}/myconsole/extendmodel/getByPage',
  39. editurl:"${ctx}/myconsole/extendmodel/saveOrUpdate",
  40. mtype : "POST",
  41. datatype : "json",
  42. caption:'扩展模型对象',
  43. prmNames : {
  44. id: "keyid", 
  45. oper:"oper",    
  46. addoper:"add",
  47. editoper:"edit",
  48. deloper:"del" 
  49. },
  50. colModel : [ {
  51. label : '扩展模型编号',
  52. name : 'keyid',
  53. hidden : true,
  54. key : true,
  55. width : 50
  56. }, {
  57. label : '对象名称',
  58. name : 'extendmodelname',
  59. editable: true,
  60. editrules:{required:true},
  61. formoptions:{
  62. elmsuffix:'*'
  63. },
  64. width : 80
  65. },{
  66. label : '对象描述',
  67. name : 'extendmodeldesc',
  68. editable: true,
  69. width : 80
  70. }, {
  71. label : '更新时间',
  72. name : 'updatetime',
  73. editable: false,
  74. width : 80
  75. }],
  76. rownumbers : true,//添加左侧行号
  77. viewrecords : true,//是否在浏览导航栏显示记录总数
  78. rowNum : 10,//每页显示记录数
  79. rowList : [10,15,20,30,40,50 ],//用于改变显示行数的下拉列表框的元素数组。
  80. autowidth : true,
  81. height : 'auto',
  82. onSelectRow : function( rowid ) {
  83. if(rowid.length>10){
  84. $("#jqGrid1").setColProp('extendmodelid',{editoptions:{value:rowid+":a"}});
  85. var row = $(this).getRowData(rowid);
  86. $("#jqGrid1").setCaption("扩展模型字段--"+row.extendmodelname);
  87. $("#jqGrid1").jqGrid('setGridParam',{url: "${ctx}/myconsole/extendfield/getByPage?extendModelID="+rowid});
  88. $("#jqGrid1").trigger("reloadGrid");
  89. }
  90. },
  91. pager : "#jqGridPager"
  92. });
  93. $('#jqGrid').navGrid('#jqGridPager',
  94. // the buttons to appear on the toolbar of the grid
  95. {
  96. edit : true,
  97. add : true,
  98. del : true,
  99. search : true,
  100. refresh : true,
  101. view : true,
  102. position : "left",
  103. cloneToTop : true
  104. },
  105. // options for the Edit Dialog
  106. {
  107. recreateForm : true,
  108. checkOnUpdate : true,
  109. checkOnSubmit : true,
  110. closeAfterEdit : true,
  111. onInitializeForm:function(formid) {
  112. },
  113. serializeEditData: function(postdata) {
  114. //myconsole.log(postdata);
  115. $.each(postdata,function (index, value) {
  116. //myconsole.log(index);
  117. if(index!="jqGrid_id" && index!="oper" && index!="keyid"){
  118. modifyJosnKey(postdata,index,"extendModel."+index);
  119. }
  120. if(index=="keyid"){
  121. postdata["extendModel."+index]=value
  122. }
  123. })
  124. //myconsole.log(postdata);
  125. return postdata;
  126. },
  127. errorTextFormat : function(data) {
  128. return 'Error: ' + data.responseText
  129. }
  130. },
  131. // options for the Add Dialog
  132. {
  133. closeAfterAdd : true,
  134. recreateForm : true,
  135. beforeSubmit: function(postdata, formid){
  136. $.each(postdata,function (index, value) {
  137. if(index!="jqGrid_id" && index!="oper"){
  138. modifyJosnKey(postdata,index,"extendModel."+index);
  139. }
  140. })
  141. return[true,''];
  142. },
  143. errorTextFormat : function(data) {
  144. return 'Error: ' + data.responseText
  145. }
  146. },
  147. // options for the Delete Dailog
  148. {
  149. errorTextFormat : function(data) {
  150. return 'Error: ' + data.responseText
  151. }
  152. },{
  153. // search options 这里支持多条件查询
  154. multipleSearch: true,
  155. sopt:['eq','ne','cn','nc','lt','le','gt','ge'],
  156. afterSubmit: function(r, data) {
  157. var messageString = r.responseText;
  158. var mesObj = eval('(' + messageString + ')');
  159. return [mesObj.state, mesObj.message];
  160. }
  161. }
  162. );
  163. /////////////////////////////////////////////////////////////////////////////////////////////////
  164. $(window).resize(function(){
  165. $("#jqGrid1").setGridWidth($(window).width()-40); 
  166. });
  167. $("#jqGrid1").jqGrid({
  168. url : '${ctx}/myconsole/extendfield/getByPage',
  169. editurl:"${ctx}/myconsole/extendfield/saveOrUpdate",
  170. mtype : "POST",
  171. datatype : "json",
  172. caption:'扩展模型字段',
  173. prmNames : {
  174. id: "keyid", 
  175. oper:"oper",    
  176. addoper:"add",
  177. editoper:"edit",
  178. deloper:"del" 
  179. },
  180. colModel : [ {
  181. label : '字段编号',
  182. name : 'keyid',
  183. hidden : true,
  184. key : true,
  185. width : 50
  186. }, {
  187. label : '扩展模型编号',
  188. name : 'extendmodelid',
  189. hidden : true,
  190. editable : true,
  191. edittype :"select",
  192. editoptions:{value:"a:a"}
  193. },{
  194. label : '字段名称',
  195. name : 'extendfieldname',
  196. editable: true,
  197. formoptions:{
  198. elmsuffix:'* 字母且唯一'
  199. },
  200. editrules:{
  201. custom:true,
  202. custom_func:function (value, colname) {
  203. var strEnglishOrNum = /^([0-9a-zA-Z.]+)?$/;
  204. if(!strEnglishOrNum.test(value))
  205. return [false, colname+"应该为英文字母或者数字"];
  206.   else if (value=='')
  207. return [false,colname+" 不允许为空"];
  208. else
  209. return [true,""];
  210. }
  211. },
  212. width : 80
  213. }, {
  214. label : '字段描述',
  215. name : 'extendfielddesc',
  216. editable: true,
  217. formoptions:{
  218. elmsuffix:'*'
  219. },
  220. editrules:{required:true},
  221. width : 80
  222. }, {
  223. label : '字段类型',
  224. name : 'extendfieldtype',
  225. editable: true,
  226. formatter:"select",
  227. edittype: "select",
  228. editoptions: {
  229. value: "${extendFieldType}"
  230. },
  231. stype:"select",
  232. searchoptions:{
  233. value: "${extendFieldType}"
  234. },
  235. width : 80
  236. }, {
  237. label : '表单类型',
  238. name : 'extendformtype',
  239. editable: true,
  240. formatter:"select",
  241. edittype: "select",
  242. editoptions: {
  243. value: "${extendFormType}"
  244. },
  245. stype:"select",
  246. searchoptions:{
  247. value: "${extendFormType}"
  248. },
  249. width : 80
  250. }, {
  251. label : '下拉选项',
  252. name : 'extendformoption',
  253. editable: true,
  254. formatter:"select",
  255. edittype: "select",
  256. editoptions: {
  257. value: "${extendFormOption}"
  258. },
  259. stype:"select",
  260. searchoptions:{
  261. value: "${extendFormOption}"
  262. },
  263. width : 80
  264. }, {
  265. label : '表单验证',
  266. name : 'extendformvalidate',
  267. editable: true,
  268. hidden : true,
  269. formatter:"select",
  270. edittype: "select",
  271. editoptions: {
  272. value: "${extendFormVerification}"
  273. },
  274. stype:"select",
  275. searchoptions:{
  276. value: "${extendFormVerification}"
  277. },
  278. width : 80
  279. }, {
  280. label : '表单提示',
  281. name : 'extendformsuffix',
  282. hidden : true,
  283. editable: true,
  284. width : 80
  285. }],
  286. rownumbers : true,//添加左侧行号
  287. viewrecords : true,//是否在浏览导航栏显示记录总数
  288. rowNum : 10,//每页显示记录数
  289. rowList : [10,15,20,30,40,50 ],//用于改变显示行数的下拉列表框的元素数组。
  290. autowidth : true,
  291. height : 'auto',
  292. pager : "#jqGridPager1"
  293. });
  294. $('#jqGrid1').navGrid('#jqGridPager1',
  295. // the buttons to appear on the toolbar of the grid
  296. {
  297. edit : true,
  298. add : true,
  299. del : true,
  300. search : true,
  301. refresh : true,
  302. view : true,
  303. position : "left",
  304. cloneToTop : true
  305. },
  306. // options for the Edit Dialog
  307. {
  308. recreateForm : true,
  309. checkOnUpdate : true,
  310. checkOnSubmit : true,
  311. closeAfterEdit : true,
  312. onInitializeForm:function(formid) {
  313. },
  314. serializeEditData: function(postdata) {
  315. //myconsole.log(postdata);
  316. $.each(postdata,function (index, value) {
  317. //myconsole.log(index);
  318. if(index!="jqGrid_id" && index!="oper" && index!="keyid"){
  319. modifyJosnKey(postdata,index,"extendField."+index);
  320. }
  321. if(index=="keyid"){
  322. postdata["extendField."+index]=value
  323. }
  324. })
  325. //myconsole.log(postdata);
  326. return postdata;
  327. },
  328. errorTextFormat : function(data) {
  329. return 'Error: ' + data.responseText
  330. }
  331. },
  332. // options for the Add Dialog
  333. {
  334. closeAfterAdd : true,
  335. recreateForm : true,
  336. beforeSubmit: function(postdata, formid){
  337. $.each(postdata,function (index, value) {
  338. if(index!="jqGrid_id" && index!="oper"){
  339. modifyJosnKey(postdata,index,"extendField."+index);
  340. }
  341. })
  342. return[true,''];
  343. },
  344. afterSubmit: function (response, postdata) {
  345. // console.log(response);
  346. return [true,'',''];
  347. },
  348. errorTextFormat : function(data) {
  349. return 'Error: ' + data.responseText
  350. }
  351. },
  352. // options for the Delete Dailog
  353. {
  354. errorTextFormat : function(data) {
  355. return 'Error: ' + data.responseText
  356. }
  357. },{
  358. // search options 这里支持多条件查询
  359. multipleSearch: true,
  360. sopt:['eq','ne','cn','nc','lt','le','gt','ge'],
  361. afterSubmit: function(r, data) {
  362. var messageString = r.responseText;
  363. var mesObj = eval('(' + messageString + ')');
  364. return [mesObj.state, mesObj.message];
  365. }
  366. }
  367. );
  368. $("#make").click(function(){
  369. $.get("${ctx}/myconsole/extendmodel/make",{},function(data){
  370. alert(data);
  371. })
  372. })
  373. })
  374. </script>
  375. <title>我的桌面</title>
  376. </head>
  377. <body>
  378. <div class="page-container">
  379. <table id="jqGrid"></table>
  380. <div id="jqGridPager"></div>
  381. <div>&nbsp;</div>
  382. <table id="jqGrid1"></table>
  383. <div id="jqGridPager1"></div>
  384. </div>
  385. <footer class="footer mt-20">
  386. <div class="container">
  387. <p></p>
  388. </div>
  389. </footer>
  390. </body>
  391. </html>