<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
|
<%
|
String path = request.getContextPath();
|
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
|
+ path + "/";
|
%>
|
|
<!DOCTYPE HTML>
|
<html>
|
<head>
|
<base href="<%=basePath%>">
|
<meta name="viewport" charset="width=device-width, initial-scale=1.0">
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
<title>表单配置</title>
|
<link rel="stylesheet" href="static/plugins/jquery-steps/css/main.css" type="text/css">
|
<link rel="stylesheet" href="static/plugins/jquery-steps/css/jquery.steps.css" type="text/css">
|
<link href="static/plugins/font-awesome/css/font-awesome.css" rel="stylesheet" type="text/css">
|
<!--<link href="static/plugins/jquery-easyui/themes/bootstrap/easyui.css" rel="stylesheet" type="text/css">-->
|
<link href="static/plugins/ueditor-formdesign/css/bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css"/>
|
<!--[if lte IE 6]>
|
<link rel="stylesheet" type="text/css" href="static/plugins/ueditor-formdesign/css/bootstrap/css/bootstrap-ie6.css">
|
<![endif]-->
|
<!--[if lte IE 7]>
|
<link rel="stylesheet" type="text/css" href="static/plugins/ueditor-formdesign/css/bootstrap/css/ie.css">
|
<![endif]-->
|
<link href="static/plugins/ueditor-formdesign/css/site.css" rel="stylesheet" type="text/css">
|
<link rel="stylesheet" href="static/styles/initialize.css" type="text/css">
|
<link rel="stylesheet" href="static/styles/common.css" type="text/css">
|
<link rel="stylesheet" href="static/plugins/layer/theme/default/layer.css" type="text/css">
|
|
<script type="text/javascript" src="static/plugins/jquery/jquery.min.js"></script>
|
<script type="text/javascript" src="static/plugins/jquery-easyui/jquery.easyui.min.js"></script>
|
<script type="text/javascript" src="static/plugins/jquery-easyui/locale/easyui-lang-zh_CN.js"></script>
|
<script type="text/javascript" src="static/scripts/easyuiExtend.js"></script>
|
<script type="text/javascript" src="static/scripts/jquery-extend.js"></script>
|
<script type="text/javascript" src="static/plugins/slimScroll/jquery.slimscroll.min.js"></script>
|
<script type="text/javascript" src="static/scripts/ResizeScroll.js"></script>
|
<script src="static/plugins/ace/src-noconflict/ace.js" type="text/javascript"></script>
|
<!-- 弹窗加载组件 -->
|
<script type="text/javascript" src="static/plugins/layer/layer.js"></script>
|
<script type="text/javascript" src="static/plugins/spinjs/spin.js"></script>
|
<script type="text/javascript" src="static/plugins/spinjs/jquery.spin.js"></script>
|
<script type="text/javascript" src="static/plugins/jquery.blockUI.js"></script>
|
<!-- wcp组件 -->
|
<script type="text/javascript" src="static/wcp/scripts/wcp.js"></script>
|
<script type="text/javascript" src="static/wcp/scripts/libs/wcp.layer.js"></script>
|
<script type="text/javascript" src="static/wcp/scripts/libs/wcp.blockUI.js"></script>
|
<script type="text/javascript" src="static/wcp/scripts/libs/wcp.spin.js"></script>
|
<script type="text/javascript" src="static/wcp/scripts/libs/wcp.jquery.js"></script>
|
|
<!--[if lt IE 9]>
|
<script type="text/javascript" src="static/plugins/json2.js"></script>
|
<![endif]-->
|
<script type="text/javascript" src="static/wcp/scripts/libs/wcp.infoPicker.js"></script>
|
<style>
|
a:hover {
|
color: #fff;
|
text-decoration: none;
|
}
|
|
.alert {
|
margin: 10px 20px 16px 20px;
|
}
|
|
.row {
|
position: relative;
|
}
|
|
.span2 {
|
position: absolute;
|
left: 20px;
|
top: 0px;
|
}
|
|
.span10 {
|
width: 100%;
|
}
|
|
.pt-custom-list {
|
margin: 0;
|
}
|
|
.pt-custom-list p {
|
line-height: 38px;
|
margin: 0 0 8px 0;
|
padding: 0 0 0 20px;
|
background: #f9f9f9;
|
cursor: pointer;
|
border: 1px solid #d4d4d4;
|
border-radius: 4px;
|
}
|
|
.pt-custom-list p:hover {
|
background-color: #f3f2f2;
|
}
|
|
.pt-custom-list p:active {
|
background-color: #e8e8e8;
|
}
|
|
.pt-custom-list p .fa {
|
font-size: 18px;
|
margin-right: 6px;
|
}
|
</style>
|
<script>
|
|
</script>
|
</head>
|
|
<body>
|
<div>
|
<div class="pt-main-top clear">
|
<div class="pt-nav">
|
<span class="pt-title-icon"> <i class="fa fa-gears"></i>
|
</span>
|
<div class="pt-title">
|
|
<div>
|
<h4>表单设计</h4>
|
</div>
|
</div>
|
|
</div>
|
<div class="pt-box-tools">
|
<a href="javascript:;" class="pt-btn pt-btn-warning" onclick="leipiFormDesign.exec('preview');">
|
<i class="fa fa-eye"></i> 预览
|
</a>
|
<a href="javascript:;" class="pt-btn pt-btn-primary" onclick="leipiFormDesign.fnCheckForm('save');">
|
<i class="fa fa-save"></i> 保存
|
</a>
|
</div>
|
</div>
|
<form method="post" id="saveform" name="saveform">
|
<input type="hidden" name="fields" id="fields" value="0">
|
<input id="txtFormId" type="hidden" value="${form.formId}"/>
|
<div class="alert">
|
<button type="button" class="close" data-dismiss="alert">×</button>
|
<strong>提醒:</strong>单选框和复选框,如:
|
<code>{|-</code>
|
选项
|
<code>-|}</code>
|
两边边界是防止误删除控件,程序会把它们替换为空,请不要手动删除!
|
</div>
|
<div class="row">
|
<div class="span2">
|
<div class="pt-custom-list clear">
|
<p class="item" onclick="leipiFormDesign.exec('leipi_template');">
|
<i class="fa fa-table"></i> <span>表单模板</span>
|
</p>
|
<p class="item" onclick="leipiFormDesign.exec('text');">
|
<i class="fa fa-text-width"></i> <span>文本框</span>
|
</p>
|
<p class="item" onclick="leipiFormDesign.exec('textarea');">
|
<i class="fa fa-pencil-square-o"></i> <span>多行文本框</span>
|
</p>
|
<p class="item" onclick="leipiFormDesign.exec('radios');">
|
<i class="fa fa-dot-circle-o"></i> <span>单选框组</span>
|
</p>
|
<p class="item" onclick="leipiFormDesign.exec('checkboxs');">
|
<i class="fa fa-check-square-o"></i> <span>复选框组</span>
|
</p>
|
<p class="item" onclick="leipiFormDesign.exec('select');">
|
<i class="fa fa-caret-square-o-down"></i> <span>下拉菜单</span>
|
</p>
|
<p class="item" onclick="leipiFormDesign.exec('listctrl');">
|
<i class="fa fa-list-alt"></i>
|
<span>列表</span>
|
</p>
|
<p class="item" onclick="leipiFormDesign.exec('datetime');">
|
<i class="fa fa-clock-o"></i> <span>日期时间框</span>
|
</p>
|
<p class="item" onclick="leipiFormDesign.exec('person');">
|
<i class="fa fa-user"></i> <span>人员选择</span>
|
</p>
|
<p class="item" onclick="leipiFormDesign.exec('upload');">
|
<i class="fa fa-upload"></i> <span>上传文件</span>
|
</p>
|
<p class="item" onclick="leipiFormDesign.exec('resource');">
|
<i class="fa fa-columns"></i> <span>资源选择</span>
|
</p>
|
<p class="item" onclick="leipiFormDesign.exec('serial');">
|
<i class="fa fa-sort-numeric-asc"></i> <span>流水号</span>
|
</p>
|
<p class="item" onclick="leipiFormDesign.exec('formula');">
|
<i class="fa fa-superscript"></i> <span>公式字段</span>
|
</p>
|
</div>
|
</div>
|
|
<div style="margin:0 40px 0 180px;">
|
<div class="span10">
|
<script id="myFormDesign" type="text/plain" style="width:100%;">${form.formContentModel}</script>
|
</div>
|
</div>
|
</div>
|
<!--end row-->
|
</form>
|
<div class="mb10"></div>
|
<!-- <div class="pt-form-btn-frame">
|
<div class="pt-form-btn">
|
<div class="form-group">
|
<button type="reset" class="pt-btn pt-btn-default" onclick="leipiFormDesign.exec('preview');">预览</button>
|
<button type="submit" class="pt-btn pt-btn-primary" onclick="leipiFormDesign.exec('save');">保存</button>
|
|
</div>
|
</div>
|
</div> -->
|
</div>
|
<!--end container-->
|
<script type="text/javascript" charset="utf-8"
|
src="static/plugins/ueditor-formdesign/js/ueditor/ueditor.config.js"></script>
|
<script type="text/javascript" charset="utf-8"
|
src="static/plugins/ueditor-formdesign/js/ueditor/ueditor.all.js"></script>
|
<script type="text/javascript" charset="utf-8"
|
src="static/plugins/ueditor-formdesign/js/ueditor/lang/zh-cn/zh-cn.js"></script>
|
<script type="text/javascript" charset="utf-8"
|
src="static/plugins/ueditor-formdesign/js/ueditor/formdesign/leipi.formdesign.v5.js"></script>
|
|
<script type="text/javascript" src="static/scripts/ResizeScroll.js"></script>
|
|
<!-- script start-->
|
<script type="text/javascript">
|
$(function () {
|
new ResizeScroll({
|
"id": ".pt-custom-list",
|
"fun": function () {
|
var wh = $(window).height();
|
return (wh - 160);
|
}
|
});
|
});
|
|
var leipiEditor = UE.getEditor('myFormDesign', {
|
//allowDivTransToP: false,//阻止转换div 为p
|
toolleipi: true, //是否显示,设计器的 toolbars
|
textarea: 'design_content',
|
enterTag: 'br',
|
allowDivTransToP: false,
|
//这里可以选择自己需要的工具按钮名称,此处仅选择如下五个
|
toolbars: [[
|
'fullscreen', 'source', '|', 'undo', 'redo', '|', 'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'removeformat', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', '|', 'fontfamily', 'fontsize', '|', 'indent', '|', 'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'link', 'unlink', '|', 'horizontal', 'spechars', 'wordimage', '|', 'inserttable', 'deletetable', 'mergecells', 'splittocells']],
|
//focus时自动清空初始化时的内容
|
//autoClearinitialContent:true,
|
//关闭字数统计
|
wordCount: false,
|
//关闭elementPath
|
elementPathEnabled: false,
|
autoHeightEnabled: false,
|
//默认的编辑区域高度
|
initialFrameHeight: $(window).height() - 200
|
///,iframeCssUrl:"css/bootstrap/css/bootstrap.css" //引入自身 css使编辑器兼容你网站css
|
//更多其他参数,请参考ueditor.config.js中的配置项
|
});
|
var controlType,
|
tableName,
|
columnName,
|
displayName,
|
defaultValue,
|
dataType,
|
alignType,
|
controlWidth,
|
controlHeight,
|
fontSize,
|
customStyleName,
|
enableHidden,
|
enableUnique,
|
enableRequired,
|
enableEditable,
|
enableMultiselect,
|
enableJoinParent,
|
enableReturnIdType,
|
enableStrong,
|
outputFormat,
|
verifyFormat,
|
sortMode,
|
dataSourceType,
|
dataSourceKeys,
|
dataSourceSql,
|
dataSourceKeywordId,
|
dataSourceKeywordName,
|
userSelectType,
|
uploadType,
|
enableAutoUpload,
|
allowUploadCount,
|
targetModuleId,
|
targetModuleName,
|
targetTableId,
|
targetTableName,
|
contentFrom,
|
returnFunctionName,
|
localRelationColumnName,
|
targetRelationColumnName,
|
filterSql,
|
targetViewId,
|
targetViewName,
|
targetColumnNames,
|
targetColumnTitles,
|
localColumnNames,
|
codingGetType,
|
codingId,
|
codingName,
|
expression,
|
enableSaveDatabase,
|
itemCount,
|
dateType,
|
saveSelectType,
|
saveSelectNameField,
|
pickRangeType,
|
pickRangeId,
|
pickRangeNmae,
|
listType,
|
listHiddenParams,
|
listCondition,
|
listSubItemsJson,
|
listDefaultRows;
|
|
var number = 0; //全局变量,计数用,等于1时删除所有
|
var isSaveFormColumn = false; //全局变量,用于判断是否需要保存表单列字段
|
var columnNames = ""; //全局变量,用于判断是否解析过字段,每次解析完存入一个字符串
|
var errorColumnNames = ""; //全局变量,存多次出现的字段
|
var objList = [];
|
var leipiFormDesign = {
|
/*执行控件*/
|
exec: function (method) {
|
leipiEditor.execCommand(method);
|
},
|
/*
|
Javascript 解析表单
|
template 表单设计器里的Html内容
|
fields 字段总数
|
*/
|
parse_form: function (template, fields) {
|
//正则 radios|checkboxs|select 匹配的边界 |--| 因为当使用 {} 时js报错
|
var preg = /(\|-<span(((?!<span).)*leipiplugins=\"(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) {
|
number++;
|
var parse_attr = new Array(),
|
attr_arr_all = new Object(),
|
name = '',
|
select_dot = '',
|
is_new = false,
|
dir = '',
|
select_text_dot = '';
|
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('-|', '');
|
}
|
controlType = null, tableName = null, columnName = null, displayName = null, defaultValue = null, dataType = null, alignType = null, controlWidth = null, controlHeight = null,
|
fontSize = null, customStyleName = null, enableHidden = null, enableUnique = null, enableRequired = null, enableEditable = null, enableMultiselect = null,enableJoinParent=null,enableReturnIdType = null, enableStrong = null, outputFormat = null,
|
verifyFormat = null, sortMode = null, dataSourceType = null, dataSourceKeys = null, dataSourceSql = null, dataSourceKeywordId = null, dataSourceKeywordName = null, userSelectType = null,
|
uploadType = null, enableAutoUpload = null, allowUploadCount = null, targetTableName = null, targetTableId = null, targetModuleName = null, targetModuleId = null, contentFrom = null, returnFunctionName = null, localRelationColumnName = null,
|
targetRelationColumnName = null, filterSql = null, targetViewId = null, targetViewName = null, targetColumnNames = null, targetColumnTitles = null, localColumnNames = null, codingGetType = null, codingId = null, codingName = null,
|
expression = null, enableSaveDatabase = null, Type = null, itemCount = null, saveSelectType = null, saveSelectNameField = null, pickRangeType = null, pickRangeId = null, pickRangeName = null, pickRangeColumn = null,
|
listType = null, listHiddenParams = null, listCondition = null, listSubItemsJson = null, listDefaultRows = null;
|
plugin.replace(preg_attr, function (str0, attr, val) {
|
if (attr == 'name') {
|
if (val == 'leipiNewField') {
|
is_new = true;
|
fields++;
|
val = 'data_' + fields;
|
}
|
name = val;
|
}
|
|
if (attr == "orgitemdir") {
|
dir = 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 if (tag == 'select' && attr == 'text') {
|
if (!attr_arr_all[attr])
|
attr_arr_all[attr] = '';
|
attr_arr_all[attr] += select_text_dot + val;
|
select_text_dot = ',';
|
|
} else {
|
attr_arr_all[attr] = val;
|
}
|
var oField = new Object();
|
oField[attr] = val;
|
parse_attr.push(oField);
|
//设置json值
|
if (isSaveFormColumn) {
|
setFormColumnJson(attr, val.replace(">", ">").replace("<", "<")
|
.replace("'", "'").replace("'", "'"));
|
}
|
})
|
/*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['text'] = '';
|
attr_arr_all['value'] = '';
|
attr_arr_all['content'] = '<span leipiplugins="checkboxs" name="span_' + attr_arr_all['name'] + '" title="' + attr_arr_all['title'] + '">';
|
var dot_text = '',
|
dot_value = '',
|
index = 0;
|
p5.replace(preg_group, function (parse_group) {
|
var is_new = false,
|
option = new Object();
|
index++;
|
parse_group.replace(preg_attr, function (str0, k, val) {
|
if (k == 'text') {
|
attr_arr_all['text'] += dot_text + val;
|
dot_text = ',';
|
|
} 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'] != undefined ? 'checked="checked"' : '';
|
attr_arr_all['content'] += '<input type="checkbox" id="' + attr_arr_all['name'] + '_' + index + '" name="' + option['name'] + '" text="' + option['text'] + '" value="' + option['value'] + '" ' + checked + '/>' + option['text'] + ' ';
|
|
// if(is_new)
|
// {
|
// var arr = new Object();
|
// arr['name'] = option['name'];
|
// arr['leipiplugins'] = attr_arr_all['leipiplugins'];
|
// add_fields[option['name']] = arr;
|
|
// }
|
if (dir == "1") {
|
attr_arr_all['content'] += '<br/>';
|
}
|
|
});
|
if (dir == "1") {
|
var contentLength = attr_arr_all['content'].length;
|
attr_arr_all['content'] = attr_arr_all['content'].substr(0, contentLength - 5); //去掉最后的<br/>
|
}
|
attr_arr_all['content'] += '</span>';
|
|
//parse
|
template = template.replace(plugin, attr_arr_all['content']);
|
template = template.replace('{|-', '');
|
template = template.replace('-|}', '');
|
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['text'] = '';
|
var dataoptions = "";
|
if (attr_arr_all['dataoptions'] != undefined) {
|
dataoptions = attr_arr_all['dataoptions'];
|
}
|
attr_arr_all['content'] = '<span leipiplugins="radios" name="span_' + attr_arr_all['name']
|
+ '" title="' + attr_arr_all['title'] + '" dataoptions="' + dataoptions + '">';
|
var dot = '';
|
var dottext = '';
|
var index = 0;
|
p5.replace(preg_group, function (parse_group) {
|
var option = new Object();
|
index++;
|
parse_group.replace(preg_attr, function (str0, k, val) {
|
if (k == 'value') {
|
attr_arr_all['value'] += dot + val;
|
dot = ',';
|
}
|
|
|
if (k == 'text') {
|
attr_arr_all['text'] += dottext + val;
|
dottext = ',';
|
}
|
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'] != undefined ? 'checked="checked"' : '';
|
var itemdataoptions = "";
|
if (option['dataoptions'] != undefined) {
|
itemdataoptions = option['dataoptions'];
|
}
|
attr_arr_all['content'] += '<input type="radio" id="' + attr_arr_all['name'] + '_' + index + '" name="' + attr_arr_all['name'] + '" text="' + option['text'] + '" value="' + option['value'] + '" data-options="' + itemdataoptions + '" ' + checked + '/>' + option['text'] + ' ';
|
if (dir == "1") {
|
attr_arr_all['content'] += '<br/>';
|
}
|
|
});
|
if (dir == "1") {
|
var contentLength = attr_arr_all['content'].length;
|
attr_arr_all['content'] = attr_arr_all['content'].substr(0, contentLength - 5);
|
}
|
attr_arr_all['content'] += '</span>';
|
|
} else {
|
|
//attr_arr_all['content'] = is_new ? plugin.replace(/leipiNewField/,name) : plugin;
|
var r2 = / *org[a-z]+="[^"]*"/g; //去掉org开头的属性
|
var temp_plugin = plugin.replace(r2, "");
|
attr_arr_all['content'] = temp_plugin;
|
}
|
//attr_arr_all['itemid'] = fields;
|
//attr_arr_all['tag'] = tag;
|
template = template.replace(plugin, attr_arr_all['content']);
|
template = template.replace('{|-', '');
|
template = template.replace('-|}', '');
|
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['leipiplugins'] = attr_arr_all['leipiplugins'];
|
add_fields[arr['name']] = arr;
|
}
|
template_data[pno] = attr_arr_all;
|
}
|
pno++;
|
//--------表单字段保存至后台---------
|
if (columnName != null) {
|
if ("," + columnNames + ",".indexOf("," + columnName.columnName + ",") > -1) {
|
errorColumnNames += columnName.columnName + ",";
|
} else {
|
columnNames += columnName.columnName + ",";
|
var obj = $.extend({}, controlType, tableName, columnName, displayName, defaultValue, dataType, alignType, controlWidth, controlHeight,
|
fontSize, customStyleName, enableHidden, enableUnique, enableRequired, enableEditable, enableMultiselect,enableJoinParent,enableReturnIdType, enableStrong, outputFormat,
|
verifyFormat, sortMode, dataSourceType, dataSourceKeys, dataSourceSql, dataSourceKeywordId, dataSourceKeywordName, userSelectType,
|
uploadType, enableAutoUpload, allowUploadCount, targetTableName, targetTableId, targetModuleName, targetModuleId, contentFrom, returnFunctionName, localRelationColumnName,
|
targetRelationColumnName, filterSql, targetViewId, targetViewName, targetColumnNames, targetColumnTitles, localColumnNames, codingGetType, codingId, codingName,
|
expression, enableSaveDatabase, dateType, itemCount, saveSelectType, saveSelectNameField, pickRangeType, pickRangeId, pickRangeName, pickRangeColumn, listType, listHiddenParams, listCondition, listSubItemsJson, listDefaultRows);
|
objList.push(obj);
|
}
|
}
|
})
|
number = 0;
|
|
var parse_form = new Object({
|
'fields': fields, //总字段数
|
'template': template, //完整html
|
'parse': template_parse, //控件替换为{data_1}的html
|
'data': template_data, //控件属性
|
'add_fields': add_fields //新增控件
|
});
|
return parse_form; //JSON.stringify(parse_form);
|
},
|
/*type = save 保存设计 versions 保存版本 close关闭 */
|
fnCheckForm: function (type) {
|
if (leipiEditor.queryCommandState('source'))
|
leipiEditor.execCommand('source'); //切换到编辑模式才提交,否则有bug
|
|
if (leipiEditor.hasContents()) {
|
leipiEditor.sync(); /*同步内容*/
|
|
//alert("你点击了保存,这里可以异步提交,请自行处理....");
|
//return false;
|
//--------------以下仅参考-----------------------------------------------------------------------------------------------------
|
var type_value = '',
|
formid = 0,
|
fields = $("#fields").val(),
|
formeditor = '';
|
|
if (typeof type !== 'undefined') {
|
type_value = type;
|
}
|
//获取表单设计器里的内容
|
formeditor = leipiEditor.getContent();
|
//解析表单设计器控件
|
isSaveFormColumn = true;
|
|
columnNames = "";
|
errorColumnNames = "";
|
objList = []; //清空数据
|
var parse_form = this.parse_form(formeditor, fields);
|
|
//--------------表单模板(用于设计表单时加载)、解析后的表单html-------------------------------------------------------------------
|
if (formeditor.indexOf("<form") == -1 || formeditor.indexOf("formData") == -1) {
|
formeditor = "<form id=\"formData\">" + formeditor + "</form>";
|
}
|
var template = parse_form["template"];
|
if (template.indexOf("<form") == -1 || template.indexOf("formData") == -1) {
|
template = "<form id=\"formData\">" + template + "</form>";
|
}
|
var obj = {
|
'formId': '${form.formId}',
|
'formContentHtml': template,
|
'formContentModel': formeditor
|
};
|
|
//if(errorColumnNames=="")
|
//{
|
// wcp.notify.warn("存在多个字段:"+errorColumnNames+",请检查表单字段!");
|
//}
|
//---------------------------------------保存表单列-------------------------------------------------------------
|
wcp.ajax({
|
type: 'POST',
|
contentType: "application/json; charset=utf-8",
|
url: "config/form/saveFormColumn?formId=${form.formId}&number=" + number,
|
dataType: 'json',
|
data: JSON.stringify(objList),
|
beforeSend: function (XMLHttpRequest) {
|
wcp.ui.setBusy();
|
}
|
}).done(function (data) {
|
//保存
|
wcp.ajax({
|
url: "config/form/saveFormHtml",
|
data: JSON.stringify(obj),
|
}).done(function (result) {
|
wcp.ui.clearBusy();
|
wcp.notify.success("保存成功!");
|
}).fail(function (msg) {
|
console.log("error:" + msg);
|
wcp.ui.clearBusy();
|
});
|
}).fail(function (msg) {
|
console.log("error:" + msg);
|
wcp.ui.clearBusy();
|
})
|
} else {
|
wcp.notify.warn('表单内容不能为空!');
|
return false;
|
}
|
},
|
/*预览表单*/
|
fnReview: function () {
|
if (leipiEditor.queryCommandState('source'))
|
leipiEditor.execCommand('source'); /*切换到编辑模式才提交,否则部分浏览器有bug*/
|
|
if (leipiEditor.hasContents()) {
|
leipiEditor.sync(); /*同步内容*/
|
|
// alert("你点击了预览,请自行处理....");
|
// return false;
|
|
//获取表单设计器里的内容
|
formeditor = leipiEditor.getContent();
|
//解析表单设计器控件
|
isSaveFormColumn = false;
|
var fields = $("#fields").val();
|
var parse_form = this.parse_form(formeditor, fields);
|
console.log(parse_form);
|
|
win_parse = window.open('', '', "menubar=0,toolbar=0,status=0,resizable=1,left=0,top=0,scrollbars=1,width=" + (screen.availWidth - 10) + ",height=" + (screen.availHeight - 50) + "\"");
|
|
win_parse.document.write(parse_form["template"]);
|
win_parse.focus();
|
return false;
|
|
//--------------以下仅参考---------------------------------
|
|
|
/*设计form的target 然后提交至一个新的窗口进行预览
|
document.saveform.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.saveform.action="/index.php?s=/index/preview.html";
|
document.saveform.submit(); //提交表单
|
*/
|
} else {
|
wcp.notify.warn('表单内容不能为空!');
|
return false;
|
}
|
}
|
};
|
|
//生成表单列json串
|
var leipipluginsval = "";
|
|
function setFormColumnJson(attr, val) {
|
//alert(leipipluginsval);
|
switch (attr) {
|
case "leipiplugins":
|
leipipluginsval = val;
|
controlType = {
|
'controlType': val
|
};
|
break;
|
case "name":
|
case "orgname":
|
//if(leipipluginsval=="checkboxs"||leipipluginsval=="radios"||leipipluginsval=="resource"||leipipluginsval=="select")
|
//{
|
columnName = {
|
'columnName': val
|
};
|
//}
|
if (columnName == null) {
|
columnName = {
|
'columnName': val
|
};
|
}
|
break;
|
case "orgtablename":
|
tableName = {
|
'tableName': val
|
};
|
break;
|
case "orgdisplayname":
|
case "title":
|
displayName = {
|
'displayName': val
|
};
|
if (displayName == null) {
|
displayName = {
|
'displayName': val
|
};
|
}
|
break;
|
case "orgtargetmoduleid":
|
targetModuleId = {
|
'targetModuleId': val
|
};
|
break;
|
case "orgtargetmodulename":
|
targetModuleName = {
|
'targetModuleName': val
|
};
|
break;
|
case "orgtargettableid":
|
targetTableId = {
|
'targetTableId': val
|
};
|
break;
|
case "orgtargettablename":
|
targetTableName = {
|
'targetTableName': val
|
};
|
break;
|
case "orgvalue":
|
case "orgdefaultvalue": //下拉菜单默认值,公式获取
|
if (leipipluginsval == "formula") {
|
expression = {
|
'expression': val
|
};
|
} else {
|
defaultValue = {
|
'defaultValue': val
|
};
|
}
|
break;
|
case "orgedit":
|
enableEditable = {
|
'enableEditable': val
|
};
|
break;
|
case "orghide":
|
enableHidden = {
|
'enableHidden': val
|
};
|
break;
|
case "orgunique":
|
enableUnique = {
|
'enableUnique': val
|
};
|
break;
|
case "orgrequired":
|
enableRequired = {
|
'enableRequired': val
|
};
|
break;
|
case "orgmulti":
|
enableMultiselect = {
|
'enableMultiselect': val
|
};
|
break;
|
case "orgjoinparent":
|
enableJoinParent = {
|
'enableJoinParent': val
|
};
|
break;
|
case "orgreturnidtype":
|
enableReturnIdType = {
|
'enableReturnIdType': val
|
};
|
break;
|
case "orgdatasource":
|
//if (leipipluginsval == "resource") {
|
contentFrom = {
|
'contentFrom': val
|
};
|
dataSourceType = {
|
'dataSourceType': val
|
};
|
|
break;
|
case "orgkeyvalue":
|
dataSourceKeywordName = {
|
'dataSourceKeywordName': val
|
};
|
break;
|
case "orgkeyid":
|
dataSourceKeywordId = {
|
'dataSourceKeywordId': val
|
};
|
break;
|
case "orgsql":
|
if (leipipluginsval == "resource") {
|
filterSql = {
|
'filterSql': val
|
};
|
} else {
|
dataSourceSql = {
|
'dataSourceSql': val
|
};
|
}
|
break;
|
case "orgtype":
|
if (leipipluginsval == "datetime") //日期控件
|
{
|
dateType = {
|
'dateType': val
|
};
|
} else if (leipipluginsval == "person") //人员选择控件
|
{
|
userSelectType = {
|
'userSelectType': val
|
};
|
} else if (leipipluginsval == "upload") //上传类型
|
{
|
uploadType = {
|
'uploadType': val
|
};
|
} else if (leipipluginsval == "serial") //流水号
|
{
|
codingGetType = {
|
'codingGetType': val
|
};
|
} else {
|
dataType = {
|
'dataType': val
|
};
|
}
|
break;
|
case "orgfontsize":
|
fontSize = {
|
'fontSize': val
|
};
|
break;
|
case "orgcss":
|
customStyleName = {
|
'customStyleName': val
|
};
|
break;
|
case "orgalign":
|
alignType = {
|
'alignType': val
|
};
|
break;
|
case "orgheight":
|
if (val != "") {
|
controlHeight = {
|
'controlHeight': val
|
};
|
}
|
break;
|
case "orgwidth":
|
controlWidth = {
|
'controlWidth': val
|
};
|
break;
|
case "orgcss":
|
customStyleName = {
|
'customStyleName': val
|
};
|
break;
|
case "orgzz":
|
verifyFormat = {
|
'verifyFormat': val
|
};
|
break;
|
case "orgprintf":
|
outputFormat = {
|
'outputFormat': val
|
};
|
break;
|
case "orgitemdir":
|
sortMode = {
|
'sortMode': val
|
};
|
break;
|
case "orgrich":
|
enableStrong = {
|
'enableStrong': val
|
};
|
break;
|
case "orgautoupload":
|
enableAutoUpload = {
|
'enableAutoUpload': val
|
};
|
break;
|
case "orgnum":
|
allowUploadCount = {
|
'allowUploadCount': val
|
};
|
break;
|
case "orgnumber":
|
codingId = {
|
'codingId': val
|
};
|
break;
|
case "orgfunname":
|
returnFunctionName = {
|
'returnFunctionName': val
|
};
|
break;
|
case "orgsourcerelfield":
|
localRelationColumnName = {
|
'localRelationColumnName': val
|
};
|
break;
|
case "orgtargetrelfield":
|
targetRelationColumnName = {
|
'targetRelationColumnName': val
|
};
|
break;
|
case "orgtargetrelfield":
|
targetRelationColumnName = {
|
'targetRelationColumnName': val
|
};
|
break;
|
case "orgsourcefields":
|
localColumnNames = {
|
'localColumnNames': val
|
};
|
break;
|
case "orgtargetfields":
|
targetColumnNames = {
|
'targetColumnNames': val
|
};
|
break;
|
case "orgtargetfieldtitles":
|
targetColumnTitles = {
|
'targetColumnTitles': val
|
};
|
break;
|
case "title":
|
if (leipipluginsval == "resource") {
|
displayName = {
|
'displayName': val
|
};
|
}
|
break;
|
case "orgview":
|
targetViewId = {
|
'targetViewId': val
|
};
|
break;
|
case "orgsavedatabase":
|
enableSaveDatabase = {
|
'enableSaveDatabase': val
|
};
|
break;
|
case "orgitemdircount":
|
itemCount = {
|
'itemCount': val
|
};
|
break;
|
case "saveselecttype":
|
saveSelectType = {
|
'saveSelectType': val
|
};
|
break;
|
case "saveselectnamefield":
|
saveSelectNameField = {
|
'saveSelectNameField': val
|
};
|
break;
|
case "orgpickrangetype":
|
pickRangeType = {
|
'pickRangeType': val
|
};
|
break;
|
case "orgpickrangename":
|
pickRangeName = {
|
'pickRangeName': val
|
};
|
break;
|
case "orgpickrangecolumn":
|
pickRangeColumn = {
|
'pickRangeColumn': val
|
};
|
break;
|
case "orgpickrangeid":
|
pickRangeId = {
|
'pickRangeId': val
|
};
|
break;
|
case "orglisttype":
|
listType = {
|
'listType': val
|
};
|
break;
|
case "orghiddenparams":
|
listHiddenParams = {
|
'listHiddenParams': val
|
};
|
break;
|
case "orgcondition":
|
listCondition = {
|
'listCondition': val
|
};
|
break;
|
case "orgdefaultrows":
|
listDefaultRows = {
|
'listDefaultRows': val
|
};
|
break;
|
case "orgsubitems":
|
listSubItemsJson = {
|
'listSubItemsJson': val
|
};
|
}
|
}
|
</script>
|
<style>
|
.edui-default .edui-bubble .edui-popup-content {
|
background-color: #fff;
|
border: 1px solid #d4d4d4;
|
margin-top: 2px;
|
padding: 6px 0 4px 6px;
|
}
|
|
.edui-default span.edui-clickable {
|
margin-right: 6px;
|
text-decoration: none;
|
}
|
|
.pt-color-success {
|
color: #00a65a !important;
|
}
|
|
.pt-color-danger {
|
color: #dd4b39 !important;
|
}
|
|
.edui-default .fa {
|
margin-right: 4px;
|
}
|
</style>
|
</body>
|
</html>
|