| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758 |
- <!DOCTYPE html>
- <html>
- <head>
- <title>表单表</title>
- <script type="text/javascript" src="plug-in/mutiLang/zh-cn.js"></script>
- <script type="text/javascript" src="plug-in/jquery/jquery-1.9.0.js"></script>
- <script type="text/javascript" src="plug-in/jquery/jquery.cookie.js"></script>
- <script type="text/javascript" src="plug-in/jquery-plugs/storage/jquery.storageapi.min.js"></script>
- <script type="text/javascript" src="plug-in/tools/dataformat.js"></script>
- <link id="easyuiTheme" rel="stylesheet" href="plug-in/easyui/themes/metrole/easyui.css" type="text/css"></link>
- <link id="easyuiTheme" rel="stylesheet" href="plug-in/easyui/themes/metrole/main.css" type="text/css"></link>
- <link id="easyuiTheme" rel="stylesheet" href="plug-in/easyui/themes/metrole/icon.css" type="text/css"></link>
- <link rel="stylesheet" type="text/css" href="plug-in/accordion/css/accordion.css">
- <link rel="stylesheet" type="text/css" href="plug-in/accordion/css/icons.css">
- <script type="text/javascript" src="plug-in/easyui/jquery.easyui.min.1.3.2.js"></script>
- <script type="text/javascript" src="plug-in/easyui/locale/zh-cn.js"></script>
- <script type="text/javascript" src="plug-in/tools/syUtil.js"></script>
- <script type="text/javascript" src="plug-in/easyui/extends/datagrid-scrollview.js"></script>
- <link rel="stylesheet" href="plug-in/tools/css/metrole/common.css" type="text/css"></link>
- <link rel="stylesheet" href="plug-in/ace/css/font-awesome.css" type="text/css"></link>
- <script type="text/javascript" src="plug-in/lhgDialog/lhgdialog.min.js?skin=metrole"></script>
- <script type="text/javascript" src="plug-in/ace/js/bootstrap-tab.js"></script>
- <script type="text/javascript" src="plug-in/tools/curdtools_zh-cn.js"></script>
- <script type="text/javascript" src="plug-in/tools/easyuiextend.js"></script>
- <script type="text/javascript" src="plug-in/jquery-plugs/hftable/jquery-hftable.js"></script>
- <script type="text/javascript" src="plug-in/tools/json2.js"></script>
- <link rel="stylesheet" type="text/css" href="plug-in/ztree/css/zTreeStyle.css">
- <script type="text/javascript" src="plug-in/ztree/js/jquery.ztree.core-3.5.min.js"></script>
- <script type="text/javascript" src="plug-in/ztree/js/jquery.ztree.excheck-3.5.min.js"></script>
- <script type="text/javascript">
- var setting = {
- check: {
- enable: true
- },
- data: {
- simpleData: {
- enable: true
- }
- }
- };
- var stylesetting = {
- check: {
- enable: true,
- chkStyle: "radio",
- radioType: "level"
- },
- data: {
- simpleData: {
- enable: true
- }
- }
- };
- function showIconForTree(treeId, treeNode) {
- return ! treeNode.isParent;
- }
- //初始化主数据源
- function initMainTableSourceSelect() {
- var ztree = jQuery.fn.zTree.getZTreeObj("dbSelect");
- var node = ztree.getNodesByParam("pid", 0, null);
- var options = "<option value=''>请选择主数据源</option>";
- jQuery.each(node, function(i, f) {
- options += "<option value='" + f.dbCode + "'>" + f.name + "</option>";
- })
- jQuery("#mainTableSource").html(options);
- jQuery("#mainTableSource").val("$!{autoFormPage.mainTableSource}");
- }
- jQuery(function() {
- var dbDate = eval('$!{dbDate}');
- jQuery.fn.zTree.init(jQuery("#dbSelect"), setting, dbDate);
- var styleDate = eval('$!{styleSelect}');
- var iconPath = "plug-in/ztree/css/img/diy/2.png";
- jQuery(styleDate).each(function(i) {
- this.icon = iconPath;
- });
- jQuery.fn.zTree.init(jQuery("#styleSelect"), stylesetting, styleDate);
- initMainTableSourceSelect();
- /* //自定义easyui表单验证规则
- jQuery.extend(jQuery.fn.validatebox.defaults.rules, {
- uniqueNm: {
- validator: function (value) {
- jQuery.post(
- 'autoFormController.do?checkFormNm',
- {formName:value},
- function(data){
- var d = jQuery.parseJSON(data);
- if(d.msg == '0' || d.msg == '1'){
- jQuery("#formName").removeClass();
- } else{
- return false;
- }
- }
- );
- },
- message: '表单名称重复,请重新输入'
- }
- });
- */
- //添加生成按钮的onclick事件
- jQuery("#createCode").click(function() {
- var formdbId = getNodeId();
- if (formdbId == '') {
- tip('请选择表单数据源');
- }
- var styleId = getStyleId();
- if (styleId == '') {
- tip('请选择自定义表单模板');
- }
- jQuery.post('autoFormController.do?docreateCode', {
- formdbId: formdbId,
- styleId: styleId
- },
- function(data) {
- var d = jQuery.parseJSON(data);
- if (d.success) {
- var editor = UE.getEditor('content');
- editor.ready(function() {
- setContent();
- //editor.setContent(jQuery("#formContent").val()+d.msg.replace(new RegExp(/(")/g),"'"));
- editor.execCommand('inserthtml', d.msg.replace(new RegExp(/(")/g), "'"));
- });
- }
- });
- });
- });
- function doAdd() {
- var addurl = "autoFormDbController.do?goAdd&autoFormId=$!{autoFormPage.id}";
- var width = window.top.document.body.offsetWidth;
- var height = window.top.document.body.offsetHeight - 100;
- jQuery.dialog({
- content: 'url:' + addurl,
- lock: true,
- //zIndex:1990,
- zIndex: getzIndex(),
- width: width,
- height: height,
- title: "录入",
- opacity: 0.3,
- cache: false,
- okVal: '确定',
- ok: function() {
- var iframe = this.iframe.contentWindow;
- iframe.$('#formobj').form('submit', {
- url: 'autoFormDbController.do?doAdd',
- onSubmit: function() {
- iframe.setDataSourceVal();
- return (iframe.jQuery("#formobj").Validform({
- tiptype: 3
- }).check());
- },
- success: function(data) {
- iframe.windowapi.close();
- var d = jQuery.parseJSON(data);
- if (d.success) {
- tip(d.msg);
- doReload();
- }
- }
- });
- return false;
- },
- cancelVal: '取消',
- cancel: true
- /*为true等价于function(){}*/
- });
- }
- function doUpdate() {
- var width = window.top.document.body.offsetWidth;
- var height = window.top.document.body.offsetHeight - 100;
- //获取选中的父节点
- var id = getNodeId();
- if (id == null || id == '') {
- alert('请选择需要编辑的表单数据源');
- return false;
- }
- var addurl = "autoFormDbController.do?goUpdate&id=" + id;
- jQuery.dialog({
- content: 'url:' + addurl,
- lock: true,
- //zIndex:1990,
- zIndex: getzIndex(),
- width: width,
- height: height,
- title: "编辑",
- opacity: 0.3,
- cache: false,
- okVal: '确定',
- ok: function() {
- var iframe = this.iframe.contentWindow;
- iframe.$('#formobj').form('submit', {
- url: 'autoFormDbController.do?doUpdate',
- onSubmit: function() {
- iframe.setDataSourceVal();
- return (iframe.jQuery("#formobj").Validform({
- tiptype: 3
- }).check(false));
- },
- success: function(data) {
- iframe.windowapi.close();
- var d = jQuery.parseJSON(data);
- if (d.success) {
- tip(d.msg);
- doReload();
- }
- }
- });
- return false;
- },
- cancelVal: '取消',
- cancel: true
- /*为true等价于function(){}*/
- });
- }
- function doDelete() {
- var id = getNodeId();
- if (id == null || id == '') {
- alert('请选择需要删除的表单数据源');
- return false;
- }
- jQuery.dialog.confirm('你确定永久删除该数据吗?',
- function() {
- jQuery.post('autoFormDbController.do?doBatchDel', {
- ids: id
- },
- function(data) {
- var d = jQuery.parseJSON(data);
- if (d.success) {
- doReload();
- }
- });
- });
- }
- function doReload() {
- jQuery.post('autoFormController.do?treeReload', {
- autoFormId: jQuery("#id").val()
- },
- function(data) {
- var d = jQuery.parseJSON(data);
- if (d.success) {
- var dbDate = eval(d.msg);
- jQuery.fn.zTree.init(jQuery("#dbSelect"), setting, dbDate);
- initMainTableSourceSelect();
- }
- });
- }
- //改成多选时取得多个ID根据","分割
- function getNodeId() {
- var treeObj = jQuery.fn.zTree.getZTreeObj("dbSelect");
- var nodes = treeObj.getCheckedNodes(true);
- if (nodes.length == 0) {
- return "";
- }
- var ids = [];
- for (var i = 0; i < nodes.length; i++) {
- if (nodes[i].pid == '0') {
- ids.push(nodes[i].id);
- }
- }
- return ids.join(',');
- }
- function getStyleId() {
- var treeObj = jQuery.fn.zTree.getZTreeObj("styleSelect");
- var nodes = treeObj.getCheckedNodes(true);
- if (nodes.length == 0) {
- return "";
- }
- var id = "";
- for (var i = 0; i < nodes.length; i++) {
- id = nodes[i].id;
- break;
- }
- return id;
- }
- function doExit() {
- var cur = window.top.jQuery('#maintabs').tabs('getSelected');
- var index = window.top.jQuery('#maintabs').tabs('getTabIndex', cur);
- window.top.jQuery('#maintabs').tabs('close', index);
- }
- function doSubmit() {
- jQuery('#formobj').form('submit', {
- url: 'autoFormController.do?doUpdate',
- onSubmit: function() {
- if (leipiEditor.queryCommandState('source')) leipiEditor.execCommand('source');
-
- if (leipiEditor.hasContents()) {
- leipiEditor.sync();
-
- var parse_form = leipiFormDesign.parse_form(leipiEditor.getContent());
- jQuery("#formContent").val(parse_form);
- } else {
- jQuery("#formContent").val('');
- }
- if (!jQuery("#formobj").form('validate')) {
- tip("请输入必须字段!");
- return false;
- } else {
- return true;
- }
- },
- success: function(data) {
- var d = jQuery.parseJSON(data);
- if (d.success) {
- tip(d.msg);
- } else {
- tip(d.msg);
- }
- }
- });
- }
- </script>
- <style>
- .menu {
- list-style: none;
- width: 100%;
- }
- .menu li {
- float: left;
- }
- </style>
-
- <link rel="stylesheet" href="plug-in/Validform/css/metrole/style.css" type="text/css" />
- <link rel="stylesheet" href="plug-in/Validform/css/metrole/tablefrom.css" type="text/css" />
- <script type="text/javascript" src="plug-in/Validform/js/Validform_v5.3.1_min_zh-cn.js"></script>
- <script type="text/javascript" src="plug-in/Validform/js/Validform_Datatype_zh-cn.js"></script>
- <script type="text/javascript" src="plug-in/Validform/js/datatype_zh-cn.js"></script>
- <script type="text/javascript">
- jQuery(function() {
- jQuery("#formobj").Validform({
- tiptype: 1,
- btnSubmit: "#btn",
- btnReset: "#btn_reset",
- ajaxPost: true,
- beforeSubmit: function(curform) {
- var tag = false;
- return setContent()
- },
- callback: function(data) {
- test(data);
- }
- });
- });
- </script>
-
- </head>
- <body>
- <div id="cc" class="easyui-layout" fit="true">
- <div data-options="region:'north',split:false,border:false">
- <div class="panel-header" align="left">
- <a href="#" class="easyui-linkbutton l-btn" plain="true" iconcls="icon-save" onclick="javascript:doSubmit();">保存</a>
- <a href="#" class="easyui-linkbutton l-btn" plain="true" iconcls="icon-cancel" onclick="javascript:doExit();">关闭</a></div>
- </div>
- <div data-options="region:'west',title:'表单数据源',split:true" style="width: 200px;">
- <div region="north" border="false" style="overflow: hidden;" fit="true">
- <div style="width: 99.5%; height: 300px; overflow-y: auto;">
- <ul class="menu" style="width: 187px">
- <li style="width: 15%;">
- <a href="#" onclick="javascript:doAdd();"><img src="plug-in/easyui/themes/icons/edit_add.png" /></a>
- </li>
- <li style="width: 15%;">
- <a href="#" onclick="javascript:doUpdate();"><img src="plug-in/easyui/themes/icons/pencil.png" /></a>
- </li>
- <li style="width: 15%;">
- <a href="#" onclick="javascript:doDelete();"><img src="plug-in/easyui/themes/icons/cancel.png" /></a>
- </li>
- <li style="width: 15%;">
- <a href="#" onclick="javascript:doReload();"><img src="plug-in/easyui/themes/icons/reload.png" /></a>
- </li>
- <li>
- <a href="#" class="easyui-linkbutton c1" id="createCode"> 生 成 </a></li>
- </ul>
- <ul id="dbSelect" class="ztree" style="margin-top: 30px;"></ul>
- </div>
- </div>
- <div region="south" border="false" style="overflow: hidden;">
- <div style="width: 99.5%; overflow-y: auto;">
- <div class="panel-header">
- <div class="panel-title">选择默认模板样式</div></div>
- <ul id="styleSelect" class="ztree"></ul>
- </div>
- </div>
- </div>
- <div data-options="region:'center',title:'表单内容'" style="padding: 5px; background: #eee;">
- <form id="formobj" action="autoFormController.do?doUpdate" name="formobj" method="post">
- <input id="id" name="id" type="hidden" value="$!{autoFormPage.id}"/>
- <input id="createName" name="createName" type="hidden" value="$!{autoFormPage.createName}"/>
- <input id="createBy" name="createBy" type="hidden" value="$!{autoFormPage.createBy}"/>
- <input id="createDate" name="createDate" type="hidden" value="$!{autoFormPage.createDate}"/>
- <input id="updateName" name="updateName" type="hidden" value="$!{autoFormPage.updateName}"/>
- <input id="updateBy" name="updateBy" type="hidden" value="$!{autoFormPage.updateBy}"/>
- <input id="updateDate" name="updateDate" type="hidden" value="$!{autoFormPage.updateDate}"/>
- <input id="sysOrgCode" name="sysOrgCode" type="hidden" value="$!{autoFormPage.sysOrgCode}"/>
- <input id="sysCompanyCode" name="sysCompanyCode" type="hidden" value="$!{autoFormPage.sysCompanyCode}"/>
- <input id="formStyleId" name="formStyleId" type="hidden" value="$!{autoFormPage.formStyleId}"/>
- <table style="width: 100%;" cellpadding="0" cellspacing="1" class="formtable">
- <tr>
- <td align="right" style="width: 8%;">
- <label class="Validform_label">表单编码:</label>
- </td>
- <td class="value" style="width: 20%;">
- <input
- id="formName"
- name="formName"
- type="text"
- style="width: 75%;"
- class="easyui-validatebox"
- required="true"
- errorMsg="不能为中文"
- ajaxurl="autoFormController.do?checkTbCode&cVal=$!{autoFormPage.formName}"
- datatype="/^[A-Za-z\d-._]+$/"
- missingMessage="表单编码必须填写"
- value="$!{autoFormPage.formName}"
- />
- <span class="Validform_checktip"></span>
- <label class="Validform_label" style="display: none;">表单编码</label>
- </td>
- <td align="right" style="width: 8%;">
- <label class="Validform_label">表单名:</label>
- </td>
- <td class="value" style="width: 20%;">
- <input id="formDesc" required="true" name="formDesc" type="text" style="width: 75%;" class="easyui-validatebox" value="$!{autoFormPage.formDesc}"/>
- <span class="Validform_checktip"></span>
- <label class="Validform_label" style="display: none;">表单名</label>
- </td>
- <td align="right" style="width: 8%;">
- <label class="Validform_label">主数据源:</label>
- </td>
- <td class="value" style="width: 20%;">
- <select id="mainTableSource" name="mainTableSource"></select>
- <span class="Validform_checktip"></span>
- <label class="Validform_label" style="display: none;">表单名</label>
- </td>
- </tr>
- <tr>
- <td class="value" colspan=6>
- <input id="formContent" name="formContent" type="hidden">
- <script id="content" type="text/plain" style="width:99%;">$!{autoFormPage.formContent}</script>
- </td>
- </tr>
- </table>
- </form>
- </div>
- </div>
- </body>
- <script>UEDITOR_HOME_URL='$!{basePath}/plug-in/Formdesign/js/ueditor/';</script>
- <script type="text/javascript" charset="utf-8" src="plug-in/Formdesign/js/ueditor/ueditor.config.js?2023"></script>
- <script type="text/javascript" charset="utf-8" src="plug-in/Formdesign/js/ueditor/ueditor.all.js?2023"> </script>
- <script type="text/javascript" charset="utf-8" src="plug-in/Formdesign/js/ueditor/lang/zh-cn/zh-cn.js?2023"></script>
- <script type="text/javascript" charset="utf-8" src="plug-in/Formdesign/js/ueditor/formdesign/leipi.formdesign.v4.js?2023"></script>
- <script type="text/javascript">
- var leipiEditor = UE.getEditor('content',{
- //allowDivTransToP: false,//阻止转换div 为p
- toolleipi:true,//是否显示,设计器的 toolbars
- textarea: 'design_content',
- //这里可以选择自己需要的工具按钮名称,此处仅选择如下五个 /*
- toolbars: [[
- 'fullscreen', 'source', '|', 'undo', 'redo', '|',//'date', 'time',
- 'fontfamily', 'fontsize', '|', 'indent', '|',
- //'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
- //'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
- //'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
- //'directionalityltr', 'directionalityrtl', 'indent', '|',
- 'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', //'touppercase', 'tolowercase', '|',
- //'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
- //'simpleupload', 'insertimage', 'emotion', 'scrawl', 'insertvideo', 'music', 'attachment', 'map', 'insertframe', 'insertcode', 'webapp', 'pagebreak', 'template', 'background', '|',
- //'horizontal', 'spechars', 'snapscreen', 'wordimage', '|',
- 'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', '|',
- //'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', '|',//'charts', '|',
- //'print', 'preview', 'searchreplace', 'help', 'drafts'
- ]],
- wordCount:false,
- elementPathEnabled:false,
- initialFrameHeight:400
- });
-
- leipiEditor.ready(function() {
- leipiEditor.execCommand('serverparam', 'id', '$!{autoFormPage.id}');
- });
-
- var leipiFormDesign = {
- exec : function (method) {
- leipiEditor.execCommand(method);
- },
- parse_form:function(template,fields)
- {
- //正则 radios|checkboxs|select 匹配的边界 |--| 因为当使用 {} 时js报错 (plugins|fieldname|fieldflow)
- var preg = /(\|-<span(((?!<span).)*plugins=\"(radios|checkboxs|select)\".*?)>(.*?)<\/span>-\||<(img|input|textarea|select).*?(<\/select>|<\/textarea>|\/>))/gi,preg_attr =/(\w+)=\"(.?|.+?)\"/gi,preg_group =/<input.*?\/>/gi;
- if(!fields) fields = 0;
- var template_parse = template,template_data = new Array(),add_fields=new Object(),checkboxs=0;
- var pno = 0;
- template.replace(preg, function(plugin,p1,p2,p3,p4,p5,p6){
- var parse_attr = new Array(),attr_arr_all = new Object(),name = '', select_dot = '' , is_new=false;
- var p0 = plugin;
- var tag = p6 ? p6 : p4;
- //alert(tag + " \n- t1 - "+p1 +" \n-2- " +p2+" \n-3- " +p3+" \n-4- " +p4+" \n-5- " +p5+" \n-6- " +p6);
- if(tag == 'radios' || tag == 'checkboxs')
- {
- plugin = p2;
- }else if(tag == 'select')
- {
- plugin = plugin.replace('|-','');
- plugin = plugin.replace('-|','');
- }
- plugin.replace(preg_attr, function(str0,attr,val) {
- if(attr=='name')
- {
- if(val=='NEWFIELD')
- {
- is_new=true;
- fields++;
- val = 'data_'+fields;
- }
- name = val;
- }
- if(tag=='select' && attr=='value')
- {
- if(!attr_arr_all[attr]) attr_arr_all[attr] = '';
- attr_arr_all[attr] += select_dot + val;
- select_dot = ',';
- }else
- {
- attr_arr_all[attr] = val;
- }
- var oField = new Object();
- oField[attr] = val;
- parse_attr.push(oField);
- })
- /*alert(JSON.stringify(parse_attr));return;*/
- if(tag =='checkboxs') /*复选组 多个字段 */
- {
- plugin = p0;
- plugin = plugin.replace('|-','');
- plugin = plugin.replace('-|','');
- var name = 'checkboxs_'+checkboxs;
- attr_arr_all['parse_name'] = name;
- attr_arr_all['name'] = '';
- attr_arr_all['value'] = '';
- attr_arr_all['content'] = '<span leipiplugins="checkboxs" selector="'+attr_arr_all['selector']+'" autofield="'+attr_arr_all['autofield']+'" title="'+attr_arr_all['title']+'">';
- var dot_name ='', dot_value = '';
- p5.replace(preg_group, function(parse_group) {
- var is_new=false,option = new Object();
- parse_group.replace(preg_attr, function(str0,k,val) {
- if(k=='name')
- {
- if(val=='NEWFIELD')
- {
- is_new=true;
- fields++;
- val = 'data_'+fields;
- }
- attr_arr_all['name'] += dot_name + val;
- dot_name = ',';
- }
- else if(k=='value')
- {
- attr_arr_all['value'] += dot_value + val;
- dot_value = ',';
- }
- option[k] = val;
- });
- if(!attr_arr_all['options']) attr_arr_all['options'] = new Array();
- attr_arr_all['options'].push(option);
- if(!option['checked']) option['checked'] = '';
- var checked = option['checked'] ? 'checked="checked"' : '';
- var checkedtext=option['checkedtext'] ? option['checkedtext'] :option['value'];
- 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+' ';
- if(is_new)
- {
- var arr = new Object();
- arr['name'] = option['name'];
- arr['plugins'] = attr_arr_all['plugins'];
- arr['fieldname'] = attr_arr_all['fieldname'] + option['fieldname'];
- arr['fieldflow'] = attr_arr_all['fieldflow'];
- add_fields[option['name']] = arr;
- }
- });
- attr_arr_all['content'] += '</span>';
- //parse
- template = template.replace(plugin,attr_arr_all['content']);
- template_parse = template_parse.replace(plugin,'{'+name+'}');
- template_parse = template_parse.replace('{|-','');
- template_parse = template_parse.replace('-|}','');
- template_data[pno] = attr_arr_all;
- checkboxs++;
- }else if(name)
- {
- if(tag =='radios') /*单选组 一个字段*/
- {
- plugin = p0;
- plugin = plugin.replace('|-','');
- plugin = plugin.replace('-|','');
- attr_arr_all['value'] = '';
- 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']+'">';
- var dot='';
- p5.replace(preg_group, function(parse_group) {
- var option = new Object();
- parse_group.replace(preg_attr, function(str0,k,val) {
- if(k=='value')
- {
- attr_arr_all['value'] += dot + val;
- dot = ',';
- }
- option[k] = val;
- });
- option['name'] = attr_arr_all['name'];
- if(!attr_arr_all['options']) attr_arr_all['options'] = new Array();
- attr_arr_all['options'].push(option);
- if(!option['checked']) option['checked'] = '';
- var checked = option['checked'] ? 'checked="checked"' : '';
- var checkedtext=option['checkedtext'] ? option['checkedtext'] :option['value'];
- attr_arr_all['content'] +='<input type="radio" name="'+attr_arr_all['name']+'" checkedtext="'+checkedtext+'" value="'+option['value']+'" '+checked+'/>'+checkedtext+' ';
- });
- attr_arr_all['content'] += '</span>';
- }else
- {
- attr_arr_all['content'] = is_new ? plugin.replace(/NEWFIELD/,name) : plugin;
- }
- //attr_arr_all['itemid'] = fields;
- //attr_arr_all['tag'] = tag;
- template = template.replace(plugin,attr_arr_all['content']);
- template_parse = template_parse.replace(plugin,'{'+name+'}');
- template_parse = template_parse.replace('{|-','');
- template_parse = template_parse.replace('-|}','');
- if(is_new)
- {
- var arr = new Object();
- arr['name'] = name;
- arr['plugins'] = attr_arr_all['plugins'];
- arr['title'] = attr_arr_all['title'];
- arr['orgtype'] = attr_arr_all['orgtype'];
- arr['fieldname'] = attr_arr_all['fieldname'];
- arr['fieldflow'] = attr_arr_all['fieldflow'];
- add_fields[arr['name']] = arr;
- }
- template_data[pno] = attr_arr_all;
- }
- pno++;
- })
- var view = template.replace(/{\|-/g,'');
- view = view.replace(/-\|}/g,'');
- var parse_form = new Object({
- 'fields':fields,//总字段数
- 'template':template,//完整html
- 'parse':view,
- 'data':template_data,//控件属性
- 'add_fields':add_fields//新增控件
- });
- return JSON.stringify(parse_form);
- },
- /*type = save 保存设计 versions 保存版本 close关闭 */
- fnCheckForm : function ( type ) {
- if(formEditor.queryCommandState( 'source' ))
- formEditor.execCommand('source');//切换到编辑模式才提交,否则有bug
- if(formEditor.hasContents()){
- formEditor.sync();/*同步内容*/
- //--------------以下仅参考-----------------------------------------------------------------------------------------------------
- var type_value='',formid=0,fields=jQuery("#fields").val(),formeditor='';
- if( typeof type!=='undefined' ){
- type_value = type;
- }
- //获取表单设计器里的内容
- formeditor=formEditor.getContent();
- //解析表单设计器控件
- var parse_form = this.parse_form(formeditor,fields);
- //alert(parse_form);
- //异步提交数据
- jQuery.ajax({
- type: 'POST',
- url : '/config/form/processor',
- //dataType : 'json',
- data : {'type' : type_value,'formid':'','parse_form':parse_form},
- success : function(data){
- if(data == true) {
- alert('表单保存成功');
- window.location.href='/config/form';
- } else {
- alert('表单保存失败');
- }
- }
- });
- } else {
- alert('表单内容不能为空!')
- jQuery('#submitbtn').button('reset');
- return false;
- }
- } ,
- // 预览表单
- fnReview : function (){
- if(leipiEditor.queryCommandState( 'source' ))
- leipiEditor.execCommand('source');
-
- if(leipiEditor.hasContents()){
- leipiEditor.sync();
-
- var parse_form = this.parse_form(leipiEditor.getContent());
- jQuery("#formContent").val(parse_form);
-
- document.formobj.target="mywin";
- 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) + "\"");
- document.formobj.action="autoFormController.do?review";
- document.formobj.submit(); //提交表单
-
- } else {
- alert('表单内容不能为空!');
- return false;
- }
- }
- };
- function setContent(){
- if(leipiEditor.queryCommandState( 'source' ))
- leipiEditor.execCommand('source');//切换到编辑模式才提交,否则有bug
-
- if(leipiEditor.hasContents()){
- leipiEditor.sync();
- jQuery("#formContent").val(leipiEditor.getContent());
- }
- }
- </script>
- </html>
|