mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-07-16 07:59:54 +08:00
routine update
This commit is contained in:
parent
82c1519648
commit
a39b6c1552
@ -26,6 +26,11 @@ namespace OpenAuth.Mvc.Controllers
|
||||
return View();
|
||||
}
|
||||
|
||||
public ActionResult Edit()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public string Get(string id)
|
||||
{
|
||||
try
|
||||
|
@ -199,6 +199,7 @@
|
||||
<Content Include="userJs\flowInstanceOp.js" />
|
||||
<Content Include="userJs\flowInstanceEdit.js" />
|
||||
<Content Include="userJs\flowSchemes.js" />
|
||||
<Content Include="userJs\formEdit.js" />
|
||||
<Content Include="userJs\nodeInfo.js" />
|
||||
<Content Include="userJs\categories.js" />
|
||||
<Content Include="userJs\assign.js" />
|
||||
@ -641,6 +642,7 @@
|
||||
<Content Include="Views\FlowSchemes\Design.cshtml" />
|
||||
<Content Include="Views\FlowInstances\Edit.cshtml" />
|
||||
<Content Include="Views\FlowInstances\Verification.cshtml" />
|
||||
<Content Include="Views\Forms\Edit.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
|
@ -41,19 +41,17 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-tab-item">
|
||||
<div class="layui-tab-item layui-fluid">
|
||||
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-md3">
|
||||
<ul id="frmTree" class="ztree" style="width: 180px; padding: 10px; border: 1px solid #ddd; overflow: auto;"></ul>
|
||||
<div class="layui-col-xs3">
|
||||
<ul id="frmTree" class="ztree" style="padding: 10px; border: 1px solid #ddd; overflow: auto;"></ul>
|
||||
</div>
|
||||
<div class="layui-col-md9 layui-col-space5">
|
||||
<div class="layui-col-xs9">
|
||||
<div class="layui-row"><div id="flowPanel"></div></div>
|
||||
<div class="layui-row"><div id="frmPreview"></div></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
@ -64,10 +64,17 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="layui-tab-item">
|
||||
<ul id="frmTree" class="ztree" style="display: inline-block; width: 180px; padding: 10px; border: 1px solid #ddd; overflow: auto;"></ul>
|
||||
<div id="frmPreview"></div>
|
||||
<div class="layui-tab-item layui-fluid">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-xs3">
|
||||
<ul id="frmTree" class="ztree" style=" padding: 10px; border: 1px solid #ddd; overflow: auto;"></ul>
|
||||
</div>
|
||||
<div class="layui-col-xs9">
|
||||
<div id="frmPreview"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-tab-item">
|
||||
|
95
OpenAuth.Mvc/Views/Forms/Edit.cshtml
Normal file
95
OpenAuth.Mvc/Views/Forms/Edit.cshtml
Normal file
@ -0,0 +1,95 @@
|
||||
@section header
|
||||
{
|
||||
<link rel="stylesheet" href="/css/treetable.css" />
|
||||
<style>
|
||||
.layui-btn + .layui-btn {
|
||||
margin-left: inherit !important;
|
||||
}
|
||||
</style>
|
||||
}
|
||||
|
||||
|
||||
<form class="layui-form" action="" id="formEdit">
|
||||
<input type="hidden" name="Id" v-model="Id" />
|
||||
<input type="hidden" name="Fields" id="Fields" value="0">
|
||||
|
||||
<div class="layui-row">
|
||||
<div class="layui-tab layui-tab-brief" lay-filter="tab">
|
||||
<ul class="layui-tab-title">
|
||||
<li class="layui-this">基本信息</li>
|
||||
<li>表单设计</li>
|
||||
</ul>
|
||||
<div class="layui-tab-content" style="height: 100px;">
|
||||
<div class="layui-tab-item layui-show">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">表单名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="Name" v-model="Name" required lay-verify="required"
|
||||
placeholder="表单名称" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">关联数据表名称【英文】</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="DbName" v-model="DbName" required lay-verify="required"
|
||||
placeholder="关联数据表名称" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">排序码</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="SortCode" value="1" v-model="SortCode" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">备注</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="Description" v-model="Description"
|
||||
placeholder="备注" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="layui-tab-item">
|
||||
<div class="layui-row">
|
||||
<blockquote class="layui-elem-quote">
|
||||
提醒:单选框和复选框,如:{|-选项-|}两边边界是防止误删除控件,程序会把它们替换为空,请不要手动删除!
|
||||
</blockquote>
|
||||
</div>
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-xs2">
|
||||
<button class="layui-btn layui-btn-radius layui-btn-fluid" onclick="leipiFormDesign.exec('text');">文本框</button>
|
||||
<button class="layui-btn layui-btn-radius layui-btn-fluid" onclick="leipiFormDesign.exec('textarea');">多行文本</button>
|
||||
<button class="layui-btn layui-btn-radius layui-btn-fluid" onclick="leipiFormDesign.exec('select');">下拉菜单</button>
|
||||
<button class="layui-btn layui-btn-radius layui-btn-fluid" onclick="leipiFormDesign.exec('radios');">单选框</button>
|
||||
<button class="layui-btn layui-btn-radius layui-btn-fluid" onclick="leipiFormDesign.exec('checkboxs');">复选框</button>
|
||||
<button class="layui-btn layui-btn-radius layui-btn-fluid" onclick="leipiFormDesign.exec('macros');">宏控件</button>
|
||||
<button class="layui-btn layui-btn-radius layui-btn-fluid" onclick="leipiFormDesign.exec('progressbar');">进度条</button>
|
||||
<button class="layui-btn layui-btn-radius layui-btn-fluid" onclick="leipiFormDesign.exec('qrcode');">二维码</button>
|
||||
<button class="layui-btn layui-btn-radius layui-btn-fluid" onclick="leipiFormDesign.exec('listctrl');">列表控件</button>
|
||||
</div>
|
||||
<div class="layui-col-xs10">
|
||||
<script id="myFormDesign" type="text/plain" style="width: 100%;">
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" lay-submit id="btnSubmit" lay-filter="formSubmit" />
|
||||
</form>
|
||||
|
||||
<script type="text/javascript" charset="utf-8" src="/js/ueditor/ueditor.config.js?2023"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="/js/ueditor/ueditor.all.js?2023"> </script>
|
||||
<script type="text/javascript" charset="utf-8" src="/js/ueditor/lang/zh-cn/zh-cn.js?2023"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="/js/ueditor/formdesign/leipi.formdesign.v4.js?2023"></script>
|
||||
|
||||
<script type="text/javascript" src="/layui/layui.js"></script>
|
||||
<script type="text/javascript" src="/userJs/formEdit.js?v4"></script>
|
||||
|
||||
|
@ -32,94 +32,6 @@
|
||||
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
|
||||
</script>
|
||||
|
||||
<!--用户添加/编辑窗口-->
|
||||
<div id="divEdit" style="display: none">
|
||||
<form class="layui-form" action="" id="formEdit">
|
||||
<input type="hidden" name="Id" v-model="Id" />
|
||||
<input type="hidden" name="Fields" id="Fields" value="0">
|
||||
|
||||
<div class="layui-row">
|
||||
<div class="layui-tab layui-tab-brief" lay-filter="tab">
|
||||
<ul class="layui-tab-title">
|
||||
<li class="layui-this">基本信息</li>
|
||||
<li>表单设计</li>
|
||||
</ul>
|
||||
<div class="layui-tab-content" style="height: 100px;">
|
||||
<div class="layui-tab-item layui-show">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">表单名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="Name" v-model="Name" required lay-verify="required"
|
||||
placeholder="表单名称" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">关联数据表名称【英文】</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="DbName" v-model="DbName" required lay-verify="required"
|
||||
placeholder="关联数据表名称" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">排序码</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="SortCode" value="1" v-model="SortCode" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">备注</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="Description" v-model="Description"
|
||||
placeholder="备注" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="layui-tab-item">
|
||||
<div class="layui-row">
|
||||
<blockquote class="layui-elem-quote">
|
||||
提醒:单选框和复选框,如:{|-选项-|}两边边界是防止误删除控件,程序会把它们替换为空,请不要手动删除!
|
||||
</blockquote>
|
||||
</div>
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-xs3">
|
||||
<ul class="layui-nav" style="margin-right: 5px;">
|
||||
<li class="layui-nav-item" style="line-height: 40px"><a href="javascript:void(0);" onclick="leipiFormDesign.exec('text');">文本框</a></li>
|
||||
<li class="layui-nav-item" style="line-height: 40px"><a href="javascript:void(0);" onclick="leipiFormDesign.exec('textarea');">多行文本</a></li>
|
||||
<li class="layui-nav-item" style="line-height: 40px"><a href="javascript:void(0);" onclick="leipiFormDesign.exec('select');">下拉菜单</a></li>
|
||||
<li class="layui-nav-item" style="line-height: 40px"><a href="javascript:void(0);" onclick="leipiFormDesign.exec('radios');">单选框</a></li>
|
||||
<li class="layui-nav-item" style="line-height: 40px"><a href="javascript:void(0);" onclick="leipiFormDesign.exec('checkboxs');" class="btn btn-link">复选框</a></li>
|
||||
<li class="layui-nav-item" style="line-height: 40px"><a href="javascript:void(0);" onclick="leipiFormDesign.exec('macros');" class="btn btn-link">宏控件</a></li>
|
||||
<li class="layui-nav-item" style="line-height: 40px"><a href="javascript:void(0);" onclick="leipiFormDesign.exec('progressbar');" class="btn btn-link">进度条</a></li>
|
||||
<li class="layui-nav-item" style="line-height: 40px"><a href="javascript:void(0);" onclick="leipiFormDesign.exec('qrcode');" class="btn btn-link">二维码</a></li>
|
||||
<li class="layui-nav-item" style="line-height: 40px"><a href="javascript:void(0);" onclick="leipiFormDesign.exec('listctrl');" class="btn btn-link">列表控件</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="layui-col-xs9">
|
||||
<script id="myFormDesign" type="text/plain" style="width: 100%;">
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-row">
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn" lay-submit lay-filter="formSubmit">立即提交</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<script type="text/javascript" charset="utf-8" src="/js/ueditor/ueditor.config.js?2023"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="/js/ueditor/ueditor.all.js?2023"> </script>
|
||||
<script type="text/javascript" charset="utf-8" src="/js/ueditor/lang/zh-cn/zh-cn.js?2023"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="/js/ueditor/formdesign/leipi.formdesign.v4.js?2023"></script>
|
||||
|
||||
<script type="text/javascript" src="/layui/layui.js"></script>
|
||||
<script type="text/javascript" src="/userJs/forms.js?v4"></script>
|
||||
|
@ -69,7 +69,7 @@
|
||||
|
||||
layer.open({
|
||||
type: 2,
|
||||
area: ['600px', '500px'], //宽高
|
||||
area: ['750px', '550px'], //宽高
|
||||
maxmin: true, //开启最大化最小化按钮
|
||||
title: title,
|
||||
content: '/flowInstances/edit?id=' + data.Id,
|
||||
@ -142,7 +142,7 @@
|
||||
|
||||
layer.open({
|
||||
type: 2,
|
||||
area: ['600px', '500px'], //宽高
|
||||
area: ['750px', '550px'], //宽高
|
||||
maxmin: true, //开启最大化最小化按钮
|
||||
title: '处理流程',
|
||||
content: '/flowInstances/Verification?id=' + data[0].Id,
|
||||
|
312
OpenAuth.Mvc/userJs/formEdit.js
Normal file
312
OpenAuth.Mvc/userJs/formEdit.js
Normal file
@ -0,0 +1,312 @@
|
||||
layui.config({
|
||||
base: "/js/"
|
||||
}).use(['form','vue', 'ztree', 'layer','utils', 'jquery', 'table','droptree','openauth','element'], function () {
|
||||
var form = layui.form,
|
||||
element = layui.element,
|
||||
//layer = (parent == undefined || parent.layer === undefined )? layui.layer : parent.layer,
|
||||
layer = layui.layer,
|
||||
$ = layui.jquery;
|
||||
var table = layui.table;
|
||||
var openauth = layui.openauth;
|
||||
|
||||
var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
|
||||
var id = $.getUrlParam("id"); //ID
|
||||
var update = (id != null && id != '');
|
||||
//提交的URL
|
||||
var url = "/Forms/Add";
|
||||
|
||||
var vm = new Vue({
|
||||
el: "#formEdit"
|
||||
});
|
||||
|
||||
//表单设计器
|
||||
var ue = UE.getEditor('myFormDesign', {
|
||||
//allowDivTransToP: false,//阻止转换div 为p
|
||||
toolleipi: true,//是否显示,设计器的 toolbars
|
||||
textarea: 'design_content',
|
||||
//这里可以选择自己需要的工具按钮名称,此处仅选择如下五个
|
||||
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']],
|
||||
//关闭字数统计
|
||||
wordCount: false,
|
||||
//关闭elementPath
|
||||
elementPathEnabled: false,
|
||||
autoHeightEnabled:true
|
||||
//默认的编辑区域高度
|
||||
, initialFrameHeight: 430
|
||||
, iframeCssUrl: "/js/ueditor/formdesign/bootstrap/css/bootstrap.min.css" //引入自身 css使编辑器兼容你网站css
|
||||
//更多其他参数,请参考ueditor.config.js中的配置项
|
||||
});
|
||||
|
||||
leipiFormDesign = {
|
||||
/*执行控件*/
|
||||
exec: function (method) {
|
||||
ue.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) {
|
||||
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 == 'leipiNewField') {
|
||||
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" 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 == 'leipiNewField') {
|
||||
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'] != undefined ? 'checked="checked"' : '';
|
||||
attr_arr_all['content'] += '<input type="checkbox" name="' + option['name'] + '" value="' + option['value'] + '" ' + checked + '/>' + option['value'] + ' ';
|
||||
|
||||
if (is_new) {
|
||||
var arr = new Object();
|
||||
arr['name'] = option['name'];
|
||||
arr['leipiplugins'] = attr_arr_all['leipiplugins'];
|
||||
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" name="' + attr_arr_all['name'] + '" 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'] != undefined ? 'checked="checked"' : '';
|
||||
attr_arr_all['content'] += '<input type="radio" name="' + attr_arr_all['name'] + '" value="' + option['value'] + '" ' + checked + '/>' + option['value'] + ' ';
|
||||
|
||||
});
|
||||
attr_arr_all['content'] += '</span>';
|
||||
|
||||
} else {
|
||||
attr_arr_all['content'] = is_new ? plugin.replace(/leipiNewField/, 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['leipiplugins'] = attr_arr_all['leipiplugins'];
|
||||
add_fields[arr['name']] = arr;
|
||||
}
|
||||
template_data[pno] = attr_arr_all;
|
||||
|
||||
|
||||
}
|
||||
pno++;
|
||||
})
|
||||
var parse_form = new Object({
|
||||
'Fields': fields,//总字段数
|
||||
'Content': template,//完整html
|
||||
'ContentParse': template_parse,//控件替换为{data_1}的html
|
||||
'ContentData': JSON.stringify(template_data),//控件属性
|
||||
'add_fields': add_fields//新增控件
|
||||
});
|
||||
return parse_form;
|
||||
},
|
||||
/*type = save 保存设计 versions 保存版本 close关闭 */
|
||||
fnCheckForm: function (type) {
|
||||
if (ue.queryCommandState('source'))
|
||||
ue.execCommand('source');//切换到编辑模式才提交,否则有bug
|
||||
|
||||
if (ue.hasContents()) {
|
||||
ue.sync();/*同步内容*/
|
||||
|
||||
return false;
|
||||
|
||||
} else {
|
||||
layer.msg('表单内容不能为空!');
|
||||
$('#submitbtn').button('reset');
|
||||
return false;
|
||||
}
|
||||
},
|
||||
/*预览表单*/
|
||||
fnReview: function () {
|
||||
if (ue.queryCommandState('source'))
|
||||
ue.execCommand('source');/*切换到编辑模式才提交,否则部分浏览器有bug*/
|
||||
if (ue.hasContents()) {
|
||||
ue.sync(); /*同步内容*/
|
||||
//--------------以下仅参考-------------------------------------------------------------------
|
||||
/*设计form的target 然后提交至一个新的窗口进行预览*/
|
||||
var fields = $("#Fields").val(), formeditor = '';
|
||||
|
||||
//获取表单设计器里的内容
|
||||
formeditor = ue.getContent();
|
||||
//解析表单设计器控件
|
||||
var parse_form = this.parse_form(formeditor, fields);
|
||||
|
||||
var forms1 = parse_form.Content;
|
||||
win_parse = window.open('', '', 'width=800,height=400,alwaysRaised=yes,top=100,left=200');
|
||||
var str = '<div style="width:500px;height:300px;border:1px solid grey">' + forms1 + '</div>';
|
||||
win_parse.document.write(forms1);
|
||||
win_parse.focus();
|
||||
} else {
|
||||
alert('表单内容不能为空!');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (update) {
|
||||
$.getJSON('/Forms/get?id=' + id,
|
||||
function (data) {
|
||||
var obj = data.Result;
|
||||
url = "/Forms/Update";
|
||||
vm.$set('$data', obj);
|
||||
//玄学:加个延迟ueditor才能正常
|
||||
setTimeout(function () {
|
||||
ue.setContent(obj.Content);
|
||||
}, 500);
|
||||
});
|
||||
} else {
|
||||
vm.$set('$data',
|
||||
{
|
||||
Id: ''
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//提交数据
|
||||
form.on('submit(formSubmit)',
|
||||
function (data) {
|
||||
|
||||
//解析表单数据
|
||||
var fields = $("#Fields").val(), formeditor = '';
|
||||
//获取表单设计器里的内容
|
||||
formeditor = ue.getContent();
|
||||
//解析表单设计器控件
|
||||
var parseForm = leipiFormDesign.parse_form(formeditor, fields);
|
||||
//alert(parse_form);\
|
||||
|
||||
$.extend(data.field, parseForm);
|
||||
|
||||
$.post(url,
|
||||
data.field,
|
||||
function (data) {
|
||||
layer.msg(data.Message);
|
||||
},
|
||||
"json");
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
//该函数供给父窗口确定时调用
|
||||
submit = function () {
|
||||
//只能用隐藏的submit btn才行,用form.submit()时data.field里没有数据
|
||||
$("#btnSubmit").click();
|
||||
}
|
||||
|
||||
//让层自适应iframe
|
||||
//parent.layer.iframeAuto(index);
|
||||
|
||||
})
|
@ -1,6 +1,6 @@
|
||||
layui.config({
|
||||
base: "/js/"
|
||||
}).use(['form','vue', 'ztree', 'layer', 'jquery', 'table','droptree','openauth','element'], function () {
|
||||
}).use(['form','vue', 'ztree', 'layer', 'jquery', 'table','droptree','openauth'], function () {
|
||||
var form = layui.form,
|
||||
element = layui.element,
|
||||
//layer = (parent == undefined || parent.layer === undefined )? layui.layer : parent.layer,
|
||||
@ -9,247 +9,6 @@
|
||||
var table = layui.table;
|
||||
var openauth = layui.openauth;
|
||||
|
||||
//标签切换
|
||||
element.on('tab(tab)', function (data) {
|
||||
console.log(data);
|
||||
});
|
||||
|
||||
//表单设计器
|
||||
var ue = UE.getEditor('myFormDesign', {
|
||||
//allowDivTransToP: false,//阻止转换div 为p
|
||||
toolleipi: true,//是否显示,设计器的 toolbars
|
||||
textarea: 'design_content',
|
||||
//这里可以选择自己需要的工具按钮名称,此处仅选择如下五个
|
||||
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']],
|
||||
//关闭字数统计
|
||||
wordCount: false,
|
||||
//关闭elementPath
|
||||
elementPathEnabled: false,
|
||||
//默认的编辑区域高度
|
||||
initialFrameHeight: 300
|
||||
, iframeCssUrl: "/js/ueditor/formdesign/bootstrap/css/bootstrap.min.css" //引入自身 css使编辑器兼容你网站css
|
||||
//更多其他参数,请参考ueditor.config.js中的配置项
|
||||
});
|
||||
|
||||
leipiFormDesign = {
|
||||
/*执行控件*/
|
||||
exec: function (method) {
|
||||
ue.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) {
|
||||
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 == 'leipiNewField') {
|
||||
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" 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 == 'leipiNewField') {
|
||||
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'] != undefined ? 'checked="checked"' : '';
|
||||
attr_arr_all['content'] += '<input type="checkbox" name="' + option['name'] + '" value="' + option['value'] + '" ' + checked + '/>' + option['value'] + ' ';
|
||||
|
||||
if (is_new) {
|
||||
var arr = new Object();
|
||||
arr['name'] = option['name'];
|
||||
arr['leipiplugins'] = attr_arr_all['leipiplugins'];
|
||||
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" name="' + attr_arr_all['name'] + '" 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'] != undefined ? 'checked="checked"' : '';
|
||||
attr_arr_all['content'] += '<input type="radio" name="' + attr_arr_all['name'] + '" value="' + option['value'] + '" ' + checked + '/>' + option['value'] + ' ';
|
||||
|
||||
});
|
||||
attr_arr_all['content'] += '</span>';
|
||||
|
||||
} else {
|
||||
attr_arr_all['content'] = is_new ? plugin.replace(/leipiNewField/, 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['leipiplugins'] = attr_arr_all['leipiplugins'];
|
||||
add_fields[arr['name']] = arr;
|
||||
}
|
||||
template_data[pno] = attr_arr_all;
|
||||
|
||||
|
||||
}
|
||||
pno++;
|
||||
})
|
||||
var parse_form = new Object({
|
||||
'Fields': fields,//总字段数
|
||||
'Content': template,//完整html
|
||||
'ContentParse': template_parse,//控件替换为{data_1}的html
|
||||
'ContentData': JSON.stringify(template_data),//控件属性
|
||||
'add_fields': add_fields//新增控件
|
||||
});
|
||||
return parse_form;
|
||||
},
|
||||
/*type = save 保存设计 versions 保存版本 close关闭 */
|
||||
fnCheckForm: function (type) {
|
||||
if (ue.queryCommandState('source'))
|
||||
ue.execCommand('source');//切换到编辑模式才提交,否则有bug
|
||||
|
||||
if (ue.hasContents()) {
|
||||
ue.sync();/*同步内容*/
|
||||
|
||||
return false;
|
||||
|
||||
} else {
|
||||
layer.msg('表单内容不能为空!');
|
||||
$('#submitbtn').button('reset');
|
||||
return false;
|
||||
}
|
||||
},
|
||||
/*预览表单*/
|
||||
fnReview: function () {
|
||||
if (ue.queryCommandState('source'))
|
||||
ue.execCommand('source');/*切换到编辑模式才提交,否则部分浏览器有bug*/
|
||||
if (ue.hasContents()) {
|
||||
ue.sync(); /*同步内容*/
|
||||
//--------------以下仅参考-------------------------------------------------------------------
|
||||
/*设计form的target 然后提交至一个新的窗口进行预览*/
|
||||
var fields = $("#Fields").val(), formeditor = '';
|
||||
|
||||
//获取表单设计器里的内容
|
||||
formeditor = ue.getContent();
|
||||
//解析表单设计器控件
|
||||
var parse_form = this.parse_form(formeditor, fields);
|
||||
|
||||
var forms1 = parse_form.Content;
|
||||
win_parse = window.open('', '', 'width=800,height=400,alwaysRaised=yes,top=100,left=200');
|
||||
var str = '<div style="width:500px;height:300px;border:1px solid grey">' + forms1 + '</div>';
|
||||
win_parse.document.write(forms1);
|
||||
win_parse.focus();
|
||||
} else {
|
||||
alert('表单内容不能为空!');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
layui.droptree("/UserSession/GetOrgs", "#Organizations", "#OrganizationIds");
|
||||
|
||||
@ -306,54 +65,30 @@
|
||||
|
||||
//添加(编辑)对话框
|
||||
var editDlg = function() {
|
||||
var vm = new Vue({
|
||||
el: "#formEdit"
|
||||
});
|
||||
var update = false; //是否为更新
|
||||
var show = function (data) {
|
||||
var title = update ? "编辑信息" : "添加";
|
||||
|
||||
layer.open({
|
||||
type: 2,
|
||||
area: ['800px', '700px'], //宽高
|
||||
maxmin: true, //开启最大化最小化按钮
|
||||
title: title,
|
||||
zIndex: 888,
|
||||
area: ["800px", "700px"],
|
||||
type: 1,
|
||||
content: $('#divEdit'),
|
||||
success: function() {
|
||||
vm.$set('$data', data);
|
||||
//玄学:加个延迟ueditor才能正常
|
||||
setTimeout(function() {
|
||||
ue.setContent(data.Content);
|
||||
},500);
|
||||
|
||||
content: '/forms/edit?id=' + data.Id,
|
||||
btn: ['保存', '关闭'],
|
||||
yes: function (index, layero) {
|
||||
var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象,执行iframe页的方法:iframeWin.method();
|
||||
iframeWin.submit();
|
||||
},
|
||||
end: mainList
|
||||
btn2: function (index) {
|
||||
layer.close(index);
|
||||
mainList();
|
||||
},
|
||||
cancel: function (index) {
|
||||
layer.close(index);
|
||||
mainList();
|
||||
}
|
||||
});
|
||||
var url = "/Forms/Add";
|
||||
if (update) {
|
||||
url = "/Forms/Update";
|
||||
}
|
||||
//提交数据
|
||||
form.on('submit(formSubmit)',
|
||||
function (data) {
|
||||
|
||||
//解析表单数据
|
||||
var fields = $("#Fields").val(), formeditor = '';
|
||||
//获取表单设计器里的内容
|
||||
formeditor = ue.getContent();
|
||||
//解析表单设计器控件
|
||||
var parseForm = leipiFormDesign.parse_form(formeditor, fields);
|
||||
//alert(parse_form);\
|
||||
|
||||
$.extend(data.field, parseForm);
|
||||
|
||||
$.post(url,
|
||||
data.field,
|
||||
function(data) {
|
||||
layer.msg(data.Message);
|
||||
},
|
||||
"json");
|
||||
return false;
|
||||
});
|
||||
}
|
||||
return {
|
||||
add: function() { //弹出添加
|
||||
|
@ -1,6 +1,12 @@
|
||||
layui.config({
|
||||
base: "/js/"
|
||||
}).use(['form', 'layer'], function () {
|
||||
|
||||
if (self != top) {
|
||||
//如果在iframe中,则跳转
|
||||
top.location.replace("/Login/Index");
|
||||
}
|
||||
|
||||
var form = layui.form,
|
||||
layer = parent.layer === undefined ? layui.layer : parent.layer,
|
||||
$ = layui.jquery;
|
||||
|
Loading…
Reference in New Issue
Block a user