autoForm-update.vm 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>表单表</title>
  5. <script type="text/javascript" src="plug-in/mutiLang/zh-cn.js"></script>
  6. <script type="text/javascript" src="plug-in/jquery/jquery-1.9.0.js"></script>
  7. <script type="text/javascript" src="plug-in/jquery/jquery.cookie.js"></script>
  8. <script type="text/javascript" src="plug-in/jquery-plugs/storage/jquery.storageapi.min.js"></script>
  9. <script type="text/javascript" src="plug-in/tools/dataformat.js"></script>
  10. <link id="easyuiTheme" rel="stylesheet" href="plug-in/easyui/themes/metrole/easyui.css" type="text/css"></link>
  11. <link id="easyuiTheme" rel="stylesheet" href="plug-in/easyui/themes/metrole/main.css" type="text/css"></link>
  12. <link id="easyuiTheme" rel="stylesheet" href="plug-in/easyui/themes/metrole/icon.css" type="text/css"></link>
  13. <link rel="stylesheet" type="text/css" href="plug-in/accordion/css/accordion.css">
  14. <link rel="stylesheet" type="text/css" href="plug-in/accordion/css/icons.css">
  15. <script type="text/javascript" src="plug-in/easyui/jquery.easyui.min.1.3.2.js"></script>
  16. <script type="text/javascript" src="plug-in/easyui/locale/zh-cn.js"></script>
  17. <script type="text/javascript" src="plug-in/tools/syUtil.js"></script>
  18. <script type="text/javascript" src="plug-in/easyui/extends/datagrid-scrollview.js"></script>
  19. <link rel="stylesheet" href="plug-in/tools/css/metrole/common.css" type="text/css"></link>
  20. <link rel="stylesheet" href="plug-in/ace/css/font-awesome.css" type="text/css"></link>
  21. <script type="text/javascript" src="plug-in/lhgDialog/lhgdialog.min.js?skin=metrole"></script>
  22. <script type="text/javascript" src="plug-in/ace/js/bootstrap-tab.js"></script>
  23. <script type="text/javascript" src="plug-in/tools/curdtools_zh-cn.js"></script>
  24. <script type="text/javascript" src="plug-in/tools/easyuiextend.js"></script>
  25. <script type="text/javascript" src="plug-in/jquery-plugs/hftable/jquery-hftable.js"></script>
  26. <script type="text/javascript" src="plug-in/tools/json2.js"></script>
  27. <link rel="stylesheet" type="text/css" href="plug-in/ztree/css/zTreeStyle.css">
  28. <script type="text/javascript" src="plug-in/ztree/js/jquery.ztree.core-3.5.min.js"></script>
  29. <script type="text/javascript" src="plug-in/ztree/js/jquery.ztree.excheck-3.5.min.js"></script>
  30. <script type="text/javascript">
  31. var setting = {
  32. check: {
  33. enable: true
  34. },
  35. data: {
  36. simpleData: {
  37. enable: true
  38. }
  39. }
  40. };
  41. var stylesetting = {
  42. check: {
  43. enable: true,
  44. chkStyle: "radio",
  45. radioType: "level"
  46. },
  47. data: {
  48. simpleData: {
  49. enable: true
  50. }
  51. }
  52. };
  53. function showIconForTree(treeId, treeNode) {
  54. return ! treeNode.isParent;
  55. }
  56. //初始化主数据源
  57. function initMainTableSourceSelect() {
  58. var ztree = jQuery.fn.zTree.getZTreeObj("dbSelect");
  59. var node = ztree.getNodesByParam("pid", 0, null);
  60. var options = "<option value=''>请选择主数据源</option>";
  61. jQuery.each(node, function(i, f) {
  62. options += "<option value='" + f.dbCode + "'>" + f.name + "</option>";
  63. })
  64. jQuery("#mainTableSource").html(options);
  65. jQuery("#mainTableSource").val("$!{autoFormPage.mainTableSource}");
  66. }
  67. jQuery(function() {
  68. var dbDate = eval('$!{dbDate}');
  69. jQuery.fn.zTree.init(jQuery("#dbSelect"), setting, dbDate);
  70. var styleDate = eval('$!{styleSelect}');
  71. var iconPath = "plug-in/ztree/css/img/diy/2.png";
  72. jQuery(styleDate).each(function(i) {
  73. this.icon = iconPath;
  74. });
  75. jQuery.fn.zTree.init(jQuery("#styleSelect"), stylesetting, styleDate);
  76. initMainTableSourceSelect();
  77. /* //自定义easyui表单验证规则
  78. jQuery.extend(jQuery.fn.validatebox.defaults.rules, {
  79. uniqueNm: {
  80. validator: function (value) {
  81. jQuery.post(
  82. 'autoFormController.do?checkFormNm',
  83. {formName:value},
  84. function(data){
  85. var d = jQuery.parseJSON(data);
  86. if(d.msg == '0' || d.msg == '1'){
  87. jQuery("#formName").removeClass();
  88. } else{
  89. return false;
  90. }
  91. }
  92. );
  93. },
  94. message: '表单名称重复,请重新输入'
  95. }
  96. });
  97. */
  98. //添加生成按钮的onclick事件
  99. jQuery("#createCode").click(function() {
  100. var formdbId = getNodeId();
  101. if (formdbId == '') {
  102. tip('请选择表单数据源');
  103. }
  104. var styleId = getStyleId();
  105. if (styleId == '') {
  106. tip('请选择自定义表单模板');
  107. }
  108. jQuery.post('autoFormController.do?docreateCode', {
  109. formdbId: formdbId,
  110. styleId: styleId
  111. },
  112. function(data) {
  113. var d = jQuery.parseJSON(data);
  114. if (d.success) {
  115. var editor = UE.getEditor('content');
  116. editor.ready(function() {
  117. setContent();
  118. //editor.setContent(jQuery("#formContent").val()+d.msg.replace(new RegExp(/(&quot;)/g),"'"));
  119. editor.execCommand('inserthtml', d.msg.replace(new RegExp(/(&quot;)/g), "'"));
  120. });
  121. }
  122. });
  123. });
  124. });
  125. function doAdd() {
  126. var addurl = "autoFormDbController.do?goAdd&autoFormId=$!{autoFormPage.id}";
  127. var width = window.top.document.body.offsetWidth;
  128. var height = window.top.document.body.offsetHeight - 100;
  129. jQuery.dialog({
  130. content: 'url:' + addurl,
  131. lock: true,
  132. //zIndex:1990,
  133. zIndex: getzIndex(),
  134. width: width,
  135. height: height,
  136. title: "录入",
  137. opacity: 0.3,
  138. cache: false,
  139. okVal: '确定',
  140. ok: function() {
  141. var iframe = this.iframe.contentWindow;
  142. iframe.$('#formobj').form('submit', {
  143. url: 'autoFormDbController.do?doAdd',
  144. onSubmit: function() {
  145. iframe.setDataSourceVal();
  146. return (iframe.jQuery("#formobj").Validform({
  147. tiptype: 3
  148. }).check());
  149. },
  150. success: function(data) {
  151. iframe.windowapi.close();
  152. var d = jQuery.parseJSON(data);
  153. if (d.success) {
  154. tip(d.msg);
  155. doReload();
  156. }
  157. }
  158. });
  159. return false;
  160. },
  161. cancelVal: '取消',
  162. cancel: true
  163. /*为true等价于function(){}*/
  164. });
  165. }
  166. function doUpdate() {
  167. var width = window.top.document.body.offsetWidth;
  168. var height = window.top.document.body.offsetHeight - 100;
  169. //获取选中的父节点
  170. var id = getNodeId();
  171. if (id == null || id == '') {
  172. alert('请选择需要编辑的表单数据源');
  173. return false;
  174. }
  175. var addurl = "autoFormDbController.do?goUpdate&id=" + id;
  176. jQuery.dialog({
  177. content: 'url:' + addurl,
  178. lock: true,
  179. //zIndex:1990,
  180. zIndex: getzIndex(),
  181. width: width,
  182. height: height,
  183. title: "编辑",
  184. opacity: 0.3,
  185. cache: false,
  186. okVal: '确定',
  187. ok: function() {
  188. var iframe = this.iframe.contentWindow;
  189. iframe.$('#formobj').form('submit', {
  190. url: 'autoFormDbController.do?doUpdate',
  191. onSubmit: function() {
  192. iframe.setDataSourceVal();
  193. return (iframe.jQuery("#formobj").Validform({
  194. tiptype: 3
  195. }).check(false));
  196. },
  197. success: function(data) {
  198. iframe.windowapi.close();
  199. var d = jQuery.parseJSON(data);
  200. if (d.success) {
  201. tip(d.msg);
  202. doReload();
  203. }
  204. }
  205. });
  206. return false;
  207. },
  208. cancelVal: '取消',
  209. cancel: true
  210. /*为true等价于function(){}*/
  211. });
  212. }
  213. function doDelete() {
  214. var id = getNodeId();
  215. if (id == null || id == '') {
  216. alert('请选择需要删除的表单数据源');
  217. return false;
  218. }
  219. jQuery.dialog.confirm('你确定永久删除该数据吗?',
  220. function() {
  221. jQuery.post('autoFormDbController.do?doBatchDel', {
  222. ids: id
  223. },
  224. function(data) {
  225. var d = jQuery.parseJSON(data);
  226. if (d.success) {
  227. doReload();
  228. }
  229. });
  230. });
  231. }
  232. function doReload() {
  233. jQuery.post('autoFormController.do?treeReload', {
  234. autoFormId: jQuery("#id").val()
  235. },
  236. function(data) {
  237. var d = jQuery.parseJSON(data);
  238. if (d.success) {
  239. var dbDate = eval(d.msg);
  240. jQuery.fn.zTree.init(jQuery("#dbSelect"), setting, dbDate);
  241. initMainTableSourceSelect();
  242. }
  243. });
  244. }
  245. //改成多选时取得多个ID根据","分割
  246. function getNodeId() {
  247. var treeObj = jQuery.fn.zTree.getZTreeObj("dbSelect");
  248. var nodes = treeObj.getCheckedNodes(true);
  249. if (nodes.length == 0) {
  250. return "";
  251. }
  252. var ids = [];
  253. for (var i = 0; i < nodes.length; i++) {
  254. if (nodes[i].pid == '0') {
  255. ids.push(nodes[i].id);
  256. }
  257. }
  258. return ids.join(',');
  259. }
  260. function getStyleId() {
  261. var treeObj = jQuery.fn.zTree.getZTreeObj("styleSelect");
  262. var nodes = treeObj.getCheckedNodes(true);
  263. if (nodes.length == 0) {
  264. return "";
  265. }
  266. var id = "";
  267. for (var i = 0; i < nodes.length; i++) {
  268. id = nodes[i].id;
  269. break;
  270. }
  271. return id;
  272. }
  273. function doExit() {
  274. var cur = window.top.jQuery('#maintabs').tabs('getSelected');
  275. var index = window.top.jQuery('#maintabs').tabs('getTabIndex', cur);
  276. window.top.jQuery('#maintabs').tabs('close', index);
  277. }
  278. function doSubmit() {
  279. jQuery('#formobj').form('submit', {
  280. url: 'autoFormController.do?doUpdate',
  281. onSubmit: function() {
  282. if (leipiEditor.queryCommandState('source')) leipiEditor.execCommand('source');
  283. if (leipiEditor.hasContents()) {
  284. leipiEditor.sync();
  285. var parse_form = leipiFormDesign.parse_form(leipiEditor.getContent());
  286. jQuery("#formContent").val(parse_form);
  287. } else {
  288. jQuery("#formContent").val('');
  289. }
  290. if (!jQuery("#formobj").form('validate')) {
  291. tip("请输入必须字段!");
  292. return false;
  293. } else {
  294. return true;
  295. }
  296. },
  297. success: function(data) {
  298. var d = jQuery.parseJSON(data);
  299. if (d.success) {
  300. tip(d.msg);
  301. } else {
  302. tip(d.msg);
  303. }
  304. }
  305. });
  306. }
  307. </script>
  308. <style>
  309. .menu {
  310. list-style: none;
  311. width: 100%;
  312. }
  313. .menu li {
  314. float: left;
  315. }
  316. </style>
  317. <link rel="stylesheet" href="plug-in/Validform/css/metrole/style.css" type="text/css" />
  318. <link rel="stylesheet" href="plug-in/Validform/css/metrole/tablefrom.css" type="text/css" />
  319. <script type="text/javascript" src="plug-in/Validform/js/Validform_v5.3.1_min_zh-cn.js"></script>
  320. <script type="text/javascript" src="plug-in/Validform/js/Validform_Datatype_zh-cn.js"></script>
  321. <script type="text/javascript" src="plug-in/Validform/js/datatype_zh-cn.js"></script>
  322. <script type="text/javascript">
  323. jQuery(function() {
  324. jQuery("#formobj").Validform({
  325. tiptype: 1,
  326. btnSubmit: "#btn",
  327. btnReset: "#btn_reset",
  328. ajaxPost: true,
  329. beforeSubmit: function(curform) {
  330. var tag = false;
  331. return setContent()
  332. },
  333. callback: function(data) {
  334. test(data);
  335. }
  336. });
  337. });
  338. </script>
  339. </head>
  340. <body>
  341. <div id="cc" class="easyui-layout" fit="true">
  342. <div data-options="region:'north',split:false,border:false">
  343. <div class="panel-header" align="left">
  344. <a href="#" class="easyui-linkbutton l-btn" plain="true" iconcls="icon-save" onclick="javascript:doSubmit();">保存</a>
  345. <a href="#" class="easyui-linkbutton l-btn" plain="true" iconcls="icon-cancel" onclick="javascript:doExit();">关闭</a></div>
  346. </div>
  347. <div data-options="region:'west',title:'表单数据源',split:true" style="width: 200px;">
  348. <div region="north" border="false" style="overflow: hidden;" fit="true">
  349. <div style="width: 99.5%; height: 300px; overflow-y: auto;">
  350. <ul class="menu" style="width: 187px">
  351. <li style="width: 15%;">
  352. <a href="#" onclick="javascript:doAdd();"><img src="plug-in/easyui/themes/icons/edit_add.png" /></a>
  353. </li>
  354. <li style="width: 15%;">
  355. <a href="#" onclick="javascript:doUpdate();"><img src="plug-in/easyui/themes/icons/pencil.png" /></a>
  356. </li>
  357. <li style="width: 15%;">
  358. <a href="#" onclick="javascript:doDelete();"><img src="plug-in/easyui/themes/icons/cancel.png" /></a>
  359. </li>
  360. <li style="width: 15%;">
  361. <a href="#" onclick="javascript:doReload();"><img src="plug-in/easyui/themes/icons/reload.png" /></a>
  362. </li>
  363. <li>
  364. <a href="#" class="easyui-linkbutton c1" id="createCode">&nbsp;生 成&nbsp;</a></li>
  365. </ul>
  366. <ul id="dbSelect" class="ztree" style="margin-top: 30px;"></ul>
  367. </div>
  368. </div>
  369. <div region="south" border="false" style="overflow: hidden;">
  370. <div style="width: 99.5%; overflow-y: auto;">
  371. <div class="panel-header">
  372. <div class="panel-title">选择默认模板样式</div></div>
  373. <ul id="styleSelect" class="ztree"></ul>
  374. </div>
  375. </div>
  376. </div>
  377. <div data-options="region:'center',title:'表单内容'" style="padding: 5px; background: #eee;">
  378. <form id="formobj" action="autoFormController.do?doUpdate" name="formobj" method="post">
  379. <input id="id" name="id" type="hidden" value="$!{autoFormPage.id}"/>
  380. <input id="createName" name="createName" type="hidden" value="$!{autoFormPage.createName}"/>
  381. <input id="createBy" name="createBy" type="hidden" value="$!{autoFormPage.createBy}"/>
  382. <input id="createDate" name="createDate" type="hidden" value="$!{autoFormPage.createDate}"/>
  383. <input id="updateName" name="updateName" type="hidden" value="$!{autoFormPage.updateName}"/>
  384. <input id="updateBy" name="updateBy" type="hidden" value="$!{autoFormPage.updateBy}"/>
  385. <input id="updateDate" name="updateDate" type="hidden" value="$!{autoFormPage.updateDate}"/>
  386. <input id="sysOrgCode" name="sysOrgCode" type="hidden" value="$!{autoFormPage.sysOrgCode}"/>
  387. <input id="sysCompanyCode" name="sysCompanyCode" type="hidden" value="$!{autoFormPage.sysCompanyCode}"/>
  388. <input id="formStyleId" name="formStyleId" type="hidden" value="$!{autoFormPage.formStyleId}"/>
  389. <table style="width: 100%;" cellpadding="0" cellspacing="1" class="formtable">
  390. <tr>
  391. <td align="right" style="width: 8%;">
  392. <label class="Validform_label">表单编码:</label>
  393. </td>
  394. <td class="value" style="width: 20%;">
  395. <input
  396. id="formName"
  397. name="formName"
  398. type="text"
  399. style="width: 75%;"
  400. class="easyui-validatebox"
  401. required="true"
  402. errorMsg="不能为中文"
  403. ajaxurl="autoFormController.do?checkTbCode&cVal=$!{autoFormPage.formName}"
  404. datatype="/^[A-Za-z\d-._]+$/"
  405. missingMessage="表单编码必须填写"
  406. value="$!{autoFormPage.formName}"
  407. />
  408. <span class="Validform_checktip"></span>
  409. <label class="Validform_label" style="display: none;">表单编码</label>
  410. </td>
  411. <td align="right" style="width: 8%;">
  412. <label class="Validform_label">表单名:</label>
  413. </td>
  414. <td class="value" style="width: 20%;">
  415. <input id="formDesc" required="true" name="formDesc" type="text" style="width: 75%;" class="easyui-validatebox" value="$!{autoFormPage.formDesc}"/>
  416. <span class="Validform_checktip"></span>
  417. <label class="Validform_label" style="display: none;">表单名</label>
  418. </td>
  419. <td align="right" style="width: 8%;">
  420. <label class="Validform_label">主数据源:</label>
  421. </td>
  422. <td class="value" style="width: 20%;">
  423. <select id="mainTableSource" name="mainTableSource"></select>
  424. <span class="Validform_checktip"></span>
  425. <label class="Validform_label" style="display: none;">表单名</label>
  426. </td>
  427. </tr>
  428. <tr>
  429. <td class="value" colspan=6>
  430. <input id="formContent" name="formContent" type="hidden">
  431. <script id="content" type="text/plain" style="width:99%;">$!{autoFormPage.formContent}</script>
  432. </td>
  433. </tr>
  434. </table>
  435. </form>
  436. </div>
  437. </div>
  438. </body>
  439. <script>UEDITOR_HOME_URL='$!{basePath}/plug-in/Formdesign/js/ueditor/';</script>
  440. <script type="text/javascript" charset="utf-8" src="plug-in/Formdesign/js/ueditor/ueditor.config.js?2023"></script>
  441. <script type="text/javascript" charset="utf-8" src="plug-in/Formdesign/js/ueditor/ueditor.all.js?2023"> </script>
  442. <script type="text/javascript" charset="utf-8" src="plug-in/Formdesign/js/ueditor/lang/zh-cn/zh-cn.js?2023"></script>
  443. <script type="text/javascript" charset="utf-8" src="plug-in/Formdesign/js/ueditor/formdesign/leipi.formdesign.v4.js?2023"></script>
  444. <script type="text/javascript">
  445. var leipiEditor = UE.getEditor('content',{
  446. //allowDivTransToP: false,//阻止转换div 为p
  447. toolleipi:true,//是否显示,设计器的 toolbars
  448. textarea: 'design_content',
  449. //这里可以选择自己需要的工具按钮名称,此处仅选择如下五个 /*
  450. toolbars: [[
  451. 'fullscreen', 'source', '|', 'undo', 'redo', '|',//'date', 'time',
  452. 'fontfamily', 'fontsize', '|', 'indent', '|',
  453. //'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
  454. //'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
  455. //'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
  456. //'directionalityltr', 'directionalityrtl', 'indent', '|',
  457. 'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', //'touppercase', 'tolowercase', '|',
  458. //'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
  459. //'simpleupload', 'insertimage', 'emotion', 'scrawl', 'insertvideo', 'music', 'attachment', 'map', 'insertframe', 'insertcode', 'webapp', 'pagebreak', 'template', 'background', '|',
  460. //'horizontal', 'spechars', 'snapscreen', 'wordimage', '|',
  461. 'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', '|',
  462. //'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', '|',//'charts', '|',
  463. //'print', 'preview', 'searchreplace', 'help', 'drafts'
  464. ]],
  465. wordCount:false,
  466. elementPathEnabled:false,
  467. initialFrameHeight:400
  468. });
  469. leipiEditor.ready(function() {
  470. leipiEditor.execCommand('serverparam', 'id', '$!{autoFormPage.id}');
  471. });
  472. var leipiFormDesign = {
  473. exec : function (method) {
  474. leipiEditor.execCommand(method);
  475. },
  476. parse_form:function(template,fields)
  477. {
  478. //正则 radios|checkboxs|select 匹配的边界 |--| 因为当使用 {} 时js报错 (plugins|fieldname|fieldflow)
  479. var preg = /(\|-<span(((?!<span).)*plugins=\"(radios|checkboxs|select)\".*?)>(.*?)<\/span>-\||<(img|input|textarea|select).*?(<\/select>|<\/textarea>|\/>))/gi,preg_attr =/(\w+)=\"(.?|.+?)\"/gi,preg_group =/<input.*?\/>/gi;
  480. if(!fields) fields = 0;
  481. var template_parse = template,template_data = new Array(),add_fields=new Object(),checkboxs=0;
  482. var pno = 0;
  483. template.replace(preg, function(plugin,p1,p2,p3,p4,p5,p6){
  484. var parse_attr = new Array(),attr_arr_all = new Object(),name = '', select_dot = '' , is_new=false;
  485. var p0 = plugin;
  486. var tag = p6 ? p6 : p4;
  487. //alert(tag + " \n- t1 - "+p1 +" \n-2- " +p2+" \n-3- " +p3+" \n-4- " +p4+" \n-5- " +p5+" \n-6- " +p6);
  488. if(tag == 'radios' || tag == 'checkboxs')
  489. {
  490. plugin = p2;
  491. }else if(tag == 'select')
  492. {
  493. plugin = plugin.replace('|-','');
  494. plugin = plugin.replace('-|','');
  495. }
  496. plugin.replace(preg_attr, function(str0,attr,val) {
  497. if(attr=='name')
  498. {
  499. if(val=='NEWFIELD')
  500. {
  501. is_new=true;
  502. fields++;
  503. val = 'data_'+fields;
  504. }
  505. name = val;
  506. }
  507. if(tag=='select' && attr=='value')
  508. {
  509. if(!attr_arr_all[attr]) attr_arr_all[attr] = '';
  510. attr_arr_all[attr] += select_dot + val;
  511. select_dot = ',';
  512. }else
  513. {
  514. attr_arr_all[attr] = val;
  515. }
  516. var oField = new Object();
  517. oField[attr] = val;
  518. parse_attr.push(oField);
  519. })
  520. /*alert(JSON.stringify(parse_attr));return;*/
  521. if(tag =='checkboxs') /*复选组 多个字段 */
  522. {
  523. plugin = p0;
  524. plugin = plugin.replace('|-','');
  525. plugin = plugin.replace('-|','');
  526. var name = 'checkboxs_'+checkboxs;
  527. attr_arr_all['parse_name'] = name;
  528. attr_arr_all['name'] = '';
  529. attr_arr_all['value'] = '';
  530. attr_arr_all['content'] = '<span leipiplugins="checkboxs" selector="'+attr_arr_all['selector']+'" autofield="'+attr_arr_all['autofield']+'" title="'+attr_arr_all['title']+'">';
  531. var dot_name ='', dot_value = '';
  532. p5.replace(preg_group, function(parse_group) {
  533. var is_new=false,option = new Object();
  534. parse_group.replace(preg_attr, function(str0,k,val) {
  535. if(k=='name')
  536. {
  537. if(val=='NEWFIELD')
  538. {
  539. is_new=true;
  540. fields++;
  541. val = 'data_'+fields;
  542. }
  543. attr_arr_all['name'] += dot_name + val;
  544. dot_name = ',';
  545. }
  546. else if(k=='value')
  547. {
  548. attr_arr_all['value'] += dot_value + val;
  549. dot_value = ',';
  550. }
  551. option[k] = val;
  552. });
  553. if(!attr_arr_all['options']) attr_arr_all['options'] = new Array();
  554. attr_arr_all['options'].push(option);
  555. if(!option['checked']) option['checked'] = '';
  556. var checked = option['checked'] ? 'checked="checked"' : '';
  557. var checkedtext=option['checkedtext'] ? option['checkedtext'] :option['value'];
  558. attr_arr_all['content'] +='<input type="checkbox" name="'+option['name']+'" checkedtext="'+checkedtext+'" value="'+option['value']+'" fieldname="' + attr_arr_all['fieldname'] + option['fieldname'] + '" fieldflow="' + attr_arr_all['fieldflow'] + '" '+checked+'/>'+checkedtext+'&nbsp;';
  559. if(is_new)
  560. {
  561. var arr = new Object();
  562. arr['name'] = option['name'];
  563. arr['plugins'] = attr_arr_all['plugins'];
  564. arr['fieldname'] = attr_arr_all['fieldname'] + option['fieldname'];
  565. arr['fieldflow'] = attr_arr_all['fieldflow'];
  566. add_fields[option['name']] = arr;
  567. }
  568. });
  569. attr_arr_all['content'] += '</span>';
  570. //parse
  571. template = template.replace(plugin,attr_arr_all['content']);
  572. template_parse = template_parse.replace(plugin,'{'+name+'}');
  573. template_parse = template_parse.replace('{|-','');
  574. template_parse = template_parse.replace('-|}','');
  575. template_data[pno] = attr_arr_all;
  576. checkboxs++;
  577. }else if(name)
  578. {
  579. if(tag =='radios') /*单选组 一个字段*/
  580. {
  581. plugin = p0;
  582. plugin = plugin.replace('|-','');
  583. plugin = plugin.replace('-|','');
  584. attr_arr_all['value'] = '';
  585. attr_arr_all['content'] = '<span leipiplugins="radios" selector="'+attr_arr_all['selector']+'" name="'+attr_arr_all['name']+'" autofield="'+attr_arr_all['autofield']+'" title="'+attr_arr_all['title']+'">';
  586. var dot='';
  587. p5.replace(preg_group, function(parse_group) {
  588. var option = new Object();
  589. parse_group.replace(preg_attr, function(str0,k,val) {
  590. if(k=='value')
  591. {
  592. attr_arr_all['value'] += dot + val;
  593. dot = ',';
  594. }
  595. option[k] = val;
  596. });
  597. option['name'] = attr_arr_all['name'];
  598. if(!attr_arr_all['options']) attr_arr_all['options'] = new Array();
  599. attr_arr_all['options'].push(option);
  600. if(!option['checked']) option['checked'] = '';
  601. var checked = option['checked'] ? 'checked="checked"' : '';
  602. var checkedtext=option['checkedtext'] ? option['checkedtext'] :option['value'];
  603. attr_arr_all['content'] +='<input type="radio" name="'+attr_arr_all['name']+'" checkedtext="'+checkedtext+'" value="'+option['value']+'" '+checked+'/>'+checkedtext+'&nbsp;';
  604. });
  605. attr_arr_all['content'] += '</span>';
  606. }else
  607. {
  608. attr_arr_all['content'] = is_new ? plugin.replace(/NEWFIELD/,name) : plugin;
  609. }
  610. //attr_arr_all['itemid'] = fields;
  611. //attr_arr_all['tag'] = tag;
  612. template = template.replace(plugin,attr_arr_all['content']);
  613. template_parse = template_parse.replace(plugin,'{'+name+'}');
  614. template_parse = template_parse.replace('{|-','');
  615. template_parse = template_parse.replace('-|}','');
  616. if(is_new)
  617. {
  618. var arr = new Object();
  619. arr['name'] = name;
  620. arr['plugins'] = attr_arr_all['plugins'];
  621. arr['title'] = attr_arr_all['title'];
  622. arr['orgtype'] = attr_arr_all['orgtype'];
  623. arr['fieldname'] = attr_arr_all['fieldname'];
  624. arr['fieldflow'] = attr_arr_all['fieldflow'];
  625. add_fields[arr['name']] = arr;
  626. }
  627. template_data[pno] = attr_arr_all;
  628. }
  629. pno++;
  630. })
  631. var view = template.replace(/{\|-/g,'');
  632. view = view.replace(/-\|}/g,'');
  633. var parse_form = new Object({
  634. 'fields':fields,//总字段数
  635. 'template':template,//完整html
  636. 'parse':view,
  637. 'data':template_data,//控件属性
  638. 'add_fields':add_fields//新增控件
  639. });
  640. return JSON.stringify(parse_form);
  641. },
  642. /*type = save 保存设计 versions 保存版本 close关闭 */
  643. fnCheckForm : function ( type ) {
  644. if(formEditor.queryCommandState( 'source' ))
  645. formEditor.execCommand('source');//切换到编辑模式才提交,否则有bug
  646. if(formEditor.hasContents()){
  647. formEditor.sync();/*同步内容*/
  648. //--------------以下仅参考-----------------------------------------------------------------------------------------------------
  649. var type_value='',formid=0,fields=jQuery("#fields").val(),formeditor='';
  650. if( typeof type!=='undefined' ){
  651. type_value = type;
  652. }
  653. //获取表单设计器里的内容
  654. formeditor=formEditor.getContent();
  655. //解析表单设计器控件
  656. var parse_form = this.parse_form(formeditor,fields);
  657. //alert(parse_form);
  658. //异步提交数据
  659. jQuery.ajax({
  660. type: 'POST',
  661. url : '/config/form/processor',
  662. //dataType : 'json',
  663. data : {'type' : type_value,'formid':'','parse_form':parse_form},
  664. success : function(data){
  665. if(data == true) {
  666. alert('表单保存成功');
  667. window.location.href='/config/form';
  668. } else {
  669. alert('表单保存失败');
  670. }
  671. }
  672. });
  673. } else {
  674. alert('表单内容不能为空!')
  675. jQuery('#submitbtn').button('reset');
  676. return false;
  677. }
  678. } ,
  679. // 预览表单
  680. fnReview : function (){
  681. if(leipiEditor.queryCommandState( 'source' ))
  682. leipiEditor.execCommand('source');
  683. if(leipiEditor.hasContents()){
  684. leipiEditor.sync();
  685. var parse_form = this.parse_form(leipiEditor.getContent());
  686. jQuery("#formContent").val(parse_form);
  687. document.formobj.target="mywin";
  688. window.open('','mywin',"menubar=0,toolbar=0,status=0,resizable=1,left=0,top=0,scrollbars=1,width=" +(screen.availWidth-10) + ",height=" + (screen.availHeight-50) + "\"");
  689. document.formobj.action="autoFormController.do?review";
  690. document.formobj.submit(); //提交表单
  691. } else {
  692. alert('表单内容不能为空!');
  693. return false;
  694. }
  695. }
  696. };
  697. function setContent(){
  698. if(leipiEditor.queryCommandState( 'source' ))
  699. leipiEditor.execCommand('source');//切换到编辑模式才提交,否则有bug
  700. if(leipiEditor.hasContents()){
  701. leipiEditor.sync();
  702. jQuery("#formContent").val(leipiEditor.getContent());
  703. }
  704. }
  705. </script>
  706. </html>