From 26f16d57432ceddb976621dedfa60eea525f78f3 Mon Sep 17 00:00:00 2001 From: wanggeng <450292408@qq.com> Date: Mon, 11 Apr 2022 20:31:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=8A=A8=E6=80=81=E8=A1=A8?= =?UTF-8?q?=E5=8D=95=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/template/page/app/app-form-save.ftl | 126 +++++++++++++++ .../template/page/app/app-form-update.ftl | 126 +++++++++++++++ .../modules/components/checkbox.js | 28 ++-- .../form-design/modules/components/date.js | 23 ++- .../form-design/modules/components/input.js | 26 ++-- .../modules/components/numberInput.js | 23 ++- .../modules/components/password.js | 23 ++- .../form-design/modules/components/radio.js | 28 ++-- .../form-design/modules/components/select.js | 41 ++--- .../modules/components/textarea.js | 23 ++- .../modules/components/uploadFile.js | 4 + .../form-design/modules/formDesigner.js | 147 ++++++++++++++++++ 12 files changed, 544 insertions(+), 74 deletions(-) create mode 100644 module-form/src/main/java/ink/wgink/module/form/template/page/app/app-form-save.ftl create mode 100644 module-form/src/main/java/ink/wgink/module/form/template/page/app/app-form-update.ftl diff --git a/module-form/src/main/java/ink/wgink/module/form/template/page/app/app-form-save.ftl b/module-form/src/main/java/ink/wgink/module/form/template/page/app/app-form-save.ftl new file mode 100644 index 00000000..6d34bd4b --- /dev/null +++ b/module-form/src/main/java/ink/wgink/module/form/template/page/app/app-form-save.ftl @@ -0,0 +1,126 @@ + + +', + + + ${formName} + + + + + + + + + +
+
+
', +
+ ${formFieldHtml} +
+
+ +
+
+
+
+
+ , + , +
+ + + + + \ No newline at end of file diff --git a/module-form/src/main/java/ink/wgink/module/form/template/page/app/app-form-update.ftl b/module-form/src/main/java/ink/wgink/module/form/template/page/app/app-form-update.ftl new file mode 100644 index 00000000..6d34bd4b --- /dev/null +++ b/module-form/src/main/java/ink/wgink/module/form/template/page/app/app-form-update.ftl @@ -0,0 +1,126 @@ + + +', + + + ${formName} + + + + + + + + + +
+
+
', +
+ ${formFieldHtml} +
+
+ +
+
+
+
+
+ , + , +
+ + + + + \ No newline at end of file diff --git a/module-form/src/main/resources/static/form-design/modules/components/checkbox.js b/module-form/src/main/resources/static/form-design/modules/components/checkbox.js index fbbcf984..c0d67232 100644 --- a/module-form/src/main/resources/static/form-design/modules/components/checkbox.js +++ b/module-form/src/main/resources/static/form-design/modules/components/checkbox.js @@ -4,6 +4,16 @@ layui.define(['jquery', 'form', 'formUtils'], function(exports) { var utils = layui.formUtils; var formField = layui.formField; + var HTML_ARRAY = [ + '
', + ' ', + '
', + ' ', + ' ', + '
', + '
' + ] + var checkbox = { /** * 根据json对象生成html对象 @@ -16,18 +26,18 @@ layui.define(['jquery', 'form', 'formUtils'], function(exports) { } var _disabled = json.disabled ? 'disabled=""' : ''; var _required = json.required ? 'lay-verify="otherReq"' : ''; - var _html = '
'.format(json.id, json.tag, selected ? 'active' : '', json.index); - _html += ''.format(json.required ? 'layui-form-required' : '', json.label, json.required ? '*' : '', json.labelWidth); - _html += '
'.format(json.width, json.labelWidth); + var _html = HTML_ARRAY[0].format(json.id, json.tag, selected ? 'active' : '', json.index); + _html += HTML_ARRAY[1].format(json.required ? 'layui-form-required' : '', json.label, json.required ? '*' : '', json.labelWidth); + _html += HTML_ARRAY[2].format(json.width, json.labelWidth); for (var i = 0; i < json.options.length; i++) { if (json.options[i].checked) { - _html += ''.format(json.id, json.options[i].value, json.options[i].text, _disabled, _required); + _html += HTML_ARRAY[3].format(json.id, json.options[i].value, json.options[i].text, _disabled, _required); } else { - _html += ''.format(json.id, json.options[i].value, json.options[i].text, _disabled, _required); + _html += HTML_ARRAY[4].format(json.id, json.options[i].value, json.options[i].text, _disabled, _required); } } - _html += '
'; - _html += '
'; + _html += HTML_ARRAY[5]; + _html += HTML_ARRAY[6]; return _html; }, update: function (json) { @@ -41,9 +51,9 @@ layui.define(['jquery', 'form', 'formUtils'], function(exports) { //重绘设计区改id下的所有元素 for (var i = 0; i < json.options.length; i++) { if (json.options[i].checked) { - _html += ''.format(json.id, json.options[i].value, json.options[i].text, _disabled, _required); + _html += HTML_ARRAY[3].format(json.id, json.options[i].value, json.options[i].text, _disabled, _required); } else { - _html += ''.format(json.id, json.options[i].value, json.options[i].text, _disabled, _required); + _html += HTML_ARRAY[4].format(json.id, json.options[i].value, json.options[i].text, _disabled, _required); } } $block.append(_html); diff --git a/module-form/src/main/resources/static/form-design/modules/components/date.js b/module-form/src/main/resources/static/form-design/modules/components/date.js index 6f95ed62..84ac2b5c 100644 --- a/module-form/src/main/resources/static/form-design/modules/components/date.js +++ b/module-form/src/main/resources/static/form-design/modules/components/date.js @@ -4,6 +4,15 @@ layui.define(['jquery', 'laydate', 'formUtils'], function(exports) { var utils = layui.formUtils; var formField = layui.formField; + var HTML_ARRAY = [ + '
', + ' ', + '
', + ' ', + '
', + '
' + ]; + var date = { /** * 根据json对象生成html对象 @@ -17,12 +26,12 @@ layui.define(['jquery', 'laydate', 'formUtils'], function(exports) { var _disabledClass = json.disabled ? ' layui-disabled' : ''; var _disabledStyle = json.disabled ? ' pointer-events: none;' : ''; var _required = json.required ? 'required' : ''; - var _html = '
'.format(json.id, json.tag, selected ? 'active' : '', json.index); - _html += ''.format(json.required ? 'layui-form-required' : '', json.label, json.required ? '*' : '', json.labelWidth); - _html += '
'.format(json.width, json.labelWidth); - _html += ''.format(json.id, json.tag, _disabledClass, _disabledStyle, _required); - _html += '
'; - _html += '
'; + var _html = HTML_ARRAY[0].format(json.id, json.tag, selected ? 'active' : '', json.index); + _html += HTML_ARRAY[1].format(json.required ? 'layui-form-required' : '', json.label, json.required ? '*' : '', json.labelWidth); + _html += HTML_ARRAY[2].format(json.width, json.labelWidth); + _html += HTML_ARRAY[3].format(json.id, json.tag, _disabledClass, _disabledStyle, _required); + _html += HTML_ARRAY[4]; + _html += HTML_ARRAY[5]; return _html; }, update: function (json) { @@ -42,7 +51,7 @@ layui.define(['jquery', 'laydate', 'formUtils'], function(exports) { $block.css({ width: 'calc({0} - {1}px)'.format(json.width, json.labelWidth) }); - var _html = ''.format(json.id, json.tag, _disabledClass, _disabledStyle, _required); + var _html = HTML_ARRAY[3].format(json.id, json.tag, _disabledClass, _disabledStyle, _required); $block.append(_html); laydate.render({ elem: '#' + json.tag + json.id, diff --git a/module-form/src/main/resources/static/form-design/modules/components/input.js b/module-form/src/main/resources/static/form-design/modules/components/input.js index 55334d81..b8440b63 100644 --- a/module-form/src/main/resources/static/form-design/modules/components/input.js +++ b/module-form/src/main/resources/static/form-design/modules/components/input.js @@ -3,6 +3,15 @@ layui.define(['jquery', 'formField', 'formUtils'], function(exports) { var formField = layui.formField; var utils = layui.formUtils; + var HTML_ARRAY = [ + '
', + ' ', + '
', + ' ', + '
', + '
' + ] + var input = { /** * 根据json对象生成html对象 @@ -22,15 +31,12 @@ layui.define(['jquery', 'formField', 'formUtils'], function(exports) { _required = _required + '|' + json.expression; } } - var _html = '
'.format(json.id, json.tag, selected ? 'active' : '', json.index); - _html += ''.format(json.required ? 'layui-form-required' : '', json.label, json.required ? '*' : '', json.labelWidth); - _html += '
'.format(json.labelWidth); - _html += ''.format(json.id, json.defaultValue ? json.defaultValue : '', json.width, json.placeholder, _readonly, _disabled, _required, _disabledClass); - _html += '
'; - // if(selected){ - // _html +='
'; - // } - _html += '
'; + var _html = HTML_ARRAY[0].format(json.id, json.tag, selected ? 'active' : '', json.index); + _html += HTML_ARRAY[1].format(json.required ? 'layui-form-required' : '', json.label, json.required ? '*' : '', json.labelWidth); + _html += HTML_ARRAY[2].format(json.labelWidth); + _html += HTML_ARRAY[3].format(json.id, json.defaultValue ? json.defaultValue : '', json.width, json.placeholder, _readonly, _disabled, _required, _disabledClass); + _html += HTML_ARRAY[4]; + _html += HTML_ARRAY[5]; return _html; }, update: function (json) { @@ -55,7 +61,7 @@ layui.define(['jquery', 'formField', 'formUtils'], function(exports) { $label.append(json.label + ":"); var _html = ''; //重绘设计区改id下的所有元素 - _html += ''.format(json.id, json.defaultValue ? json.defaultValue : '', json.width, json.placeholder, _readonly, _disabled, _required, _disabledClass); + _html += HTML_ARRAY[3].format(json.id, json.defaultValue ? json.defaultValue : '', json.width, json.placeholder, _readonly, _disabled, _required, _disabledClass); $block.append(_html); }, /* 获取对象 */ diff --git a/module-form/src/main/resources/static/form-design/modules/components/numberInput.js b/module-form/src/main/resources/static/form-design/modules/components/numberInput.js index 5af3d36c..cf7b6981 100644 --- a/module-form/src/main/resources/static/form-design/modules/components/numberInput.js +++ b/module-form/src/main/resources/static/form-design/modules/components/numberInput.js @@ -3,6 +3,15 @@ layui.define(['jquery', 'formUtils', 'formField'], function(exports) { var utils = layui.formUtils; var formField = layui.formField; + var HTML_ARRAY = [ + '
', + ' ', + '
', + ' ', + '
', + '
' + ]; + var numberInput = { /** * 根据json对象生成html对象 @@ -16,12 +25,12 @@ layui.define(['jquery', 'formUtils', 'formField'], function(exports) { var _disabled = json.disabled ? 'disabled=""' : ''; var _disabledClass = json.disabled ? ' layui-disabled' : ''; var _required = json.required ? 'required' : ''; - var _html = '
'.format(json.id, json.tag, selected ? 'active' : '', json.index); - _html += ''.format(json.label, json.labelWidth); - _html += '
'.format(json.width, json.labelWidth); - _html += ''.format(json.id, json.defaultValue ? json.defaultValue : '0', json.width, json.placeholder, _disabled, _disabledClass, json.minValue, json.maxValue, json.stepValue, json.tag + json.id); - _html += '
'; - _html += '
'; + var _html = HTML_ARRAY[0].format(json.id, json.tag, selected ? 'active' : '', json.index); + _html += HTML_ARRAY[1].format(json.label, json.labelWidth); + _html += HTML_ARRAY[2].format(json.width, json.labelWidth); + _html += HTML_ARRAY[3].format(json.id, json.defaultValue ? json.defaultValue : '0', json.width, json.placeholder, _disabled, _disabledClass, json.minValue, json.maxValue, json.stepValue, json.tag + json.id); + _html += HTML_ARRAY[4]; + _html += HTML_ARRAY[5]; return _html; }, update: function (json) { @@ -39,7 +48,7 @@ layui.define(['jquery', 'formUtils', 'formField'], function(exports) { }); var _html = ''; //重绘设计区改id下的所有元素 - _html += ''.format(json.id, json.defaultValue ? json.defaultValue : '0', json.width, json.placeholder, _disabled, _disabledClass, json.minValue, json.maxValue, json.stepValue, json.tag + json.id); + _html += HTML_ARRAY[3].format(json.id, json.defaultValue ? json.defaultValue : '0', json.width, json.placeholder, _disabled, _disabledClass, json.minValue, json.maxValue, json.stepValue, json.tag + json.id); $block.append(_html); var _width = json.width.replace(/[^\d]/g, ''); if ('' != _width) { diff --git a/module-form/src/main/resources/static/form-design/modules/components/password.js b/module-form/src/main/resources/static/form-design/modules/components/password.js index e7bc83e3..0350ea41 100644 --- a/module-form/src/main/resources/static/form-design/modules/components/password.js +++ b/module-form/src/main/resources/static/form-design/modules/components/password.js @@ -3,6 +3,15 @@ layui.define(['jquery', 'formUtils', 'formField'], function (exports) { var utils = layui.formUtils; var formField = layui.formField; + var HTML_ARRAY = [ + '
', + ' ', + '
', + ' ', + '
', + '
' + ] + var password = { /** * 根据json对象生成html对象 @@ -17,12 +26,12 @@ layui.define(['jquery', 'formUtils', 'formField'], function (exports) { var _readonly = json.readonly ? 'readonly=""' : ''; var _required = json.required ? 'lay-verify="required"' : ''; var _disabledClass = json.disabled ? ' layui-disabled' : ''; - var _html = '
'.format(json.id, json.tag, selected ? 'active' : '', json.index); - _html += ''.format(json.required ? 'layui-form-required' : '', json.label, json.required ? '*' : '', json.labelWidth); - _html += '
'.format(json.labelWidth); - _html += ''.format(json.id, json.defaultValue ? json.defaultValue : '', json.width, json.placeholder, _readonly, _disabled, _required, _disabledClass); - _html += '
'; - _html += '
'; + var _html = HTML_ARRAY[0].format(json.id, json.tag, selected ? 'active' : '', json.index); + _html += HTML_ARRAY[1].format(json.required ? 'layui-form-required' : '', json.label, json.required ? '*' : '', json.labelWidth); + _html += HTML_ARRAY[2].format(json.labelWidth); + _html += HTML_ARRAY[3].format(json.id, json.defaultValue ? json.defaultValue : '', json.width, json.placeholder, _readonly, _disabled, _required, _disabledClass); + _html += HTML_ARRAY[4]; + _html += HTML_ARRAY[4]; return _html; }, update: function (json) { @@ -42,7 +51,7 @@ layui.define(['jquery', 'formUtils', 'formField'], function (exports) { $label.append(json.label + ":"); var _html = ''; //重绘设计区改id下的所有元素 - _html += ''.format(json.id, json.defaultValue ? json.defaultValue : '', json.width, json.placeholder, _readonly, _disabled, _required, _disabledClass); + _html += HTML_ARRAY[3].format(json.id, json.defaultValue ? json.defaultValue : '', json.width, json.placeholder, _readonly, _disabled, _required, _disabledClass); $block.append(_html); }, /* 获取对象 */ diff --git a/module-form/src/main/resources/static/form-design/modules/components/radio.js b/module-form/src/main/resources/static/form-design/modules/components/radio.js index f8a28752..74a23b8e 100644 --- a/module-form/src/main/resources/static/form-design/modules/components/radio.js +++ b/module-form/src/main/resources/static/form-design/modules/components/radio.js @@ -4,6 +4,16 @@ layui.define(['jquery', 'form', 'formUtils'], function(exports) { var utils = layui.formUtils; var formField = layui.formField; + var HTML_ARRAY = [ + '
', + ' ', + '
', + ' ', + ' ', + '
', + '
' + ]; + var radio = { /** * 根据json对象生成html对象 @@ -15,18 +25,18 @@ layui.define(['jquery', 'form', 'formUtils'], function(exports) { selected = false; } var _disabled = json.disabled ? 'disabled=""' : ''; - var _html = '
'.format(json.id, json.tag, selected ? 'active' : '', json.index); - _html += ''.format(json.label, json.labelWidth); - _html += '
'.format(json.labelWidth); + var _html = HTML_ARRAY[0].format(json.id, json.tag, selected ? 'active' : '', json.index); + _html += HTML_ARRAY[1].format(json.label, json.labelWidth); + _html += HTML_ARRAY[2].format(json.labelWidth); for (var i = 0; i < json.options.length; i++) { if (json.options[i].checked) { - _html += ''.format(json.id, json.options[i].value, json.options[i].text, _disabled); + _html += HTML_ARRAY[3].format(json.id, json.options[i].value, json.options[i].text, _disabled); } else { - _html += ''.format(json.id, json.options[i].value, json.options[i].text, _disabled); + _html += HTML_ARRAY[4].format(json.id, json.options[i].value, json.options[i].text, _disabled); } } - _html += '
'; - _html += '
'; + _html += HTML_ARRAY[5]; + _html += HTML_ARRAY[6]; return _html; }, update: function (json) { @@ -45,9 +55,9 @@ layui.define(['jquery', 'form', 'formUtils'], function(exports) { //重绘设计区改id下的所有元素 for (var i = 0; i < json.options.length; i++) { if (json.options[i].checked) { - _html += ''.format(json.id, json.options[i].value, json.options[i].text, _disabled); + _html += HTML_ARRAY[3].format(json.id, json.options[i].value, json.options[i].text, _disabled); } else { - _html += ''.format(json.id, json.options[i].value, json.options[i].text, _disabled); + _html += HTML_ARRAY[4].format(json.id, json.options[i].value, json.options[i].text, _disabled); } } $block.append(_html); diff --git a/module-form/src/main/resources/static/form-design/modules/components/select.js b/module-form/src/main/resources/static/form-design/modules/components/select.js index a312edc6..746019a5 100644 --- a/module-form/src/main/resources/static/form-design/modules/components/select.js +++ b/module-form/src/main/resources/static/form-design/modules/components/select.js @@ -4,6 +4,18 @@ layui.define(['jquery', 'form', 'formUtils'], function(exports) { var utils = layui.formUtils; var formField = layui.formField; + var HTML_ARRAY = [ + '
', + ' ', + '
', + ' ', + '
', + '
' + ]; + var select = { /** * 根据json对象生成html对象 @@ -16,23 +28,20 @@ layui.define(['jquery', 'form', 'formUtils'], function(exports) { } var _disabled = json.disabled ? 'disabled=""' : ''; var _required = json.required ? 'required' : ''; - var _html = '
'.format(json.id, json.tag, selected ? 'active' : '', json.index); - _html += ''.format(json.required ? 'layui-form-required' : '', json.label, json.required ? '*' : '', json.labelWidth); - _html += '
'.format(json.id, json.labelWidth); - _html += '' - _html += '
'; - _html += '
'; + _html += HTML_ARRAY[6] + _html += HTML_ARRAY[7]; + _html += HTML_ARRAY[8]; return _html; }, update: function (json) { @@ -44,15 +53,11 @@ layui.define(['jquery', 'form', 'formUtils'], function(exports) { $label.empty(); var _html = ''; _html += '' diff --git a/module-form/src/main/resources/static/form-design/modules/components/textarea.js b/module-form/src/main/resources/static/form-design/modules/components/textarea.js index 3a36685e..4eeb33c3 100644 --- a/module-form/src/main/resources/static/form-design/modules/components/textarea.js +++ b/module-form/src/main/resources/static/form-design/modules/components/textarea.js @@ -3,6 +3,15 @@ layui.define(['jquery', 'formUtils', 'formField'], function (exports) { var utils = layui.formUtils; var formField = layui.formField; + var HTML_ARRAY = [ + '
', + ' ', + '
', + ' ', + '
', + '
' + ] + var textarea = { /** * 根据json对象生成html对象 @@ -17,12 +26,12 @@ layui.define(['jquery', 'formUtils', 'formField'], function (exports) { var _required = json.required ? 'lay-verify="required"' : ''; var _readonly = json.readonly ? 'readonly=""' : ''; var _disabledClass = json.disabled ? ' layui-disabled' : ''; - var _html = '
'.format(json.id, json.tag, selected ? 'active' : '', json.index); - _html += ''.format(json.required ? 'layui-form-required' : '', json.label, json.required ? '*' : '', json.width); - _html += '
'.format(json.width); - _html += ''.format(json.id, json.defaultValue ? json.defaultValue : '', json.width, json.placeholder, _disabled, _required, _disabledClass, _readonly); - _html += '
'; - _html += '
'; + var _html = HTML_ARRAY[0].format(json.id, json.tag, selected ? 'active' : '', json.index); + _html += HTML_ARRAY[1].format(json.required ? 'layui-form-required' : '', json.label, json.required ? '*' : '', json.width); + _html += HTML_ARRAY[2].format(json.width); + _html += HTML_ARRAY[3].format(json.id, json.defaultValue ? json.defaultValue : '', json.width, json.placeholder, _disabled, _required, _disabledClass, _readonly); + _html += HTML_ARRAY[4]; + _html += HTML_ARRAY[5]; return _html; }, update: function (json) { @@ -35,7 +44,7 @@ layui.define(['jquery', 'formUtils', 'formField'], function (exports) { $block.empty(); $label.empty(); var _html = ''; - _html += ''.format(json.id, json.defaultValue ? json.defaultValue : '', json.width, json.placeholder, _disabled, _required, _disabledClass, _readonly); + _html += HTML_ARRAY[3].format(json.id, json.defaultValue ? json.defaultValue : '', json.width, json.placeholder, _disabled, _required, _disabledClass, _readonly); $('#' + json.id + ' .layui-input-block').append(_html); $label.css({ width: '{0}'.format(json.width) diff --git a/module-form/src/main/resources/static/form-design/modules/components/uploadFile.js b/module-form/src/main/resources/static/form-design/modules/components/uploadFile.js index c93f382a..f0052a1d 100644 --- a/module-form/src/main/resources/static/form-design/modules/components/uploadFile.js +++ b/module-form/src/main/resources/static/form-design/modules/components/uploadFile.js @@ -6,6 +6,10 @@ layui.define(['jquery', 'upload', 'dialog', 'restajax', 'formUtils'], function(e var restAjax = layui.restajax; var formField = layui.formField; + var HTML_ARRAY = [ + + ]; + var uploadFile = { /** * 根据json对象生成html对象 diff --git a/module-form/src/main/resources/static/form-design/modules/formDesigner.js b/module-form/src/main/resources/static/form-design/modules/formDesigner.js index 3157beb0..c0ac8326 100644 --- a/module-form/src/main/resources/static/form-design/modules/formDesigner.js +++ b/module-form/src/main/resources/static/form-design/modules/formDesigner.js @@ -2095,6 +2095,12 @@ layui.config({ options.htmlCode.script.init.update = []; options.htmlCode.script.submit = []; + var fieldArray = []; + + that.generateFieldHtml(options.data, fieldArray); + + return; + var _htmlelem = $('
'); that.generateHtml(options.data, _htmlelem); @@ -2331,6 +2337,147 @@ layui.config({ // } }); }; + + Class.prototype.generateFieldHtml = function (jsondata, elem) { + var that = this, + options = that.config; + // elem.append($('#formDesignerForm').clone(false)); + $.each(jsondata, function (index, item) { + var subElem = $(that.components[item.tag].render(item, false)); + elem.append(subElem); + if (item.tag === 'grid') { + $.each(item.columns, function (index2, item2) { + var colElem = subElem.find('.column'+ index2); + //获取当前的 DOM 对象 + if (item2.list.length > 0) { + that.generateHtml(item2.list, colElem); + } + }); + } + + if(item.tag === 'date') { + var script = date.genScript(item); + options.htmlCode.script.func.save.push(script.func.save); + options.htmlCode.script.func.update.push(script.func.update); + options.htmlCode.script.init.save.push(script.init.save); + options.htmlCode.script.init.update.push(script.init.update); + } else if (item.tag === 'checkbox') { + var script = checkbox.genScript(item); + options.htmlCode.script.submit.push(script.commit); + options.htmlCode.script.init.update.push(script.init.update); + } + + // if (item.tag === 'slider') { + // //定义初始值 + // options.htmlCode.script.func.push([ + // 'function init'+ item.id + '() {', + // ' slider.render({', + // ' elem: "#' + item.tag + item.id + '" ,', + // ' value: ' + item.defaultValue + ',', + // ' min: ' + item.minValue + ',', + // ' max: ' + item.maxValue + ',', + // ' step: ' + item.stepValue + ',', + // ' input:' + item.isInput + ',', + // ' change: function(value) {', + // ' $("#' + item.id + '").find("input[name="' + item.id + '"]").val(value);', + // ' }', + // ' });', + // '}' + // ].join('\n')); + // options.htmlCode.script.init.save.push(' function init'+ item.id + '();'); + // options.htmlCode.script.init.update.push('function init'+ item.id + '();'); + // } else if (item.tag === 'rate') { + // options.htmlCode.script.func.push([ + // 'function init'+ item.id + '() {', + // ' rate.render({', + // ' elem: "#' + item.tag + item.id + '" ,', + // ' value: ' + item.defaultValue + ',', + // ' text: ' + item.text + ',', + // ' length: ' + item.rateLength + ',', + // ' half: ' + item.half + ',', + // ' readonly: ' + item.readonly + ',', + // ' choose: function(value) {', + // ' $("#' + item.id + '").find("input[name="' + item.id + '"]").val(value);', + // ' }', + // ' });', + // '}' + // ].join('\n')); + // options.htmlCode.script.init.save.push(' function init'+ item.id + '();'); + // options.htmlCode.script.init.update.push('function init'+ item.id + '();'); + // } else if (item.tag === 'carousel') { + // options.htmlCode.script.func.push([ + // 'function init'+ item.id + '() {', + // ' carousel.render({', + // ' elem: "#' + item.tag + item.id + '",', + // ' width: "' + item.width + '",', + // ' height: "' + item.height + '",', + // ' arrow: "' + item.arrow + '",', + // ' interval: "' + item.interval + '",', + // ' anim: "' + item.anim + '",', + // ' autoplay: "' + item.autoplay + '"', + // ' });', + // '}' + // ].join('\n')); + // options.htmlCode.script.init.save.push(' function init'+ item.id + '();'); + // options.htmlCode.script.init.update.push('function init'+ item.id + '();'); + // } else if (item.tag === 'uploadFile') { + // + // } else if (item.tag === 'uploadImage') { + // console.log(item.tag); + // options.htmlCode.script.func.push([ + // ' function init'+ item.id +'(){', + // ' var files = $(\'#'+ item.id +'File\').val();', + // ' initFileList(\''+ item.id +'\', files, function(fileName) {', + // ' var viewer = new Viewer(document.getElementById(fileName +\'FileBox\'), {navbar: false});', + // ' viewerObj[fileName] = viewer;', + // ' });', + // ' function initUpload(){', + // ' upload.render({', + // ' elem: \'#' + item.id +'FileUpload\',', + // ' url: restAjax.path(\''+ item.uploadUrl +'\', []),', + // ' field: \'image\',', + // ' done: function(res) {', + // ' var dataset = this.item[0].dataset;', + // ' var name = dataset.name;', + // ' var files = $(\'#\'+ name).val();', + // ' if(files.length > 0) {', + // ' files += \',\';', + // ' }', + // ' files += res.data;', + // ' initFileList(name, files, function(fileName) {', + // ' viewerObj[fileName].update();', + // ' });', + // ' },', + // ' error: function() {', + // ' dialog.msg(\'图片上传异常\')', + // ' }', + // ' });', + // ' }', + // ' initUpload();', + // ' $(\'.'+ item.id +'\remove-image\').on(\'click\', function(){', + // ' var name = this.dataset.name;', + // ' var id = this.dataset.id;', + // ' var files = $(\'#\'+ name).val().replace(id, \'\');', + // ' files = files.replace(/\,+/g, \',\');', + // ' if(files.charAt(0) == \',\') {', + // ' files = files.substring(1);', + // ' }', + // ' if(files.charAt(files.length - 1) == \',\') {', + // ' files = files.substring(0, files.length - 1);', + // ' }', + // ' initFileList(name, files, function(fileName) {', + // ' viewerObj[fileName].update();', + // ' initUpload();', + // ' });', + // ' });', + // ' }', + // ].join('\n')); + // options.htmlCode.script.init.save.push(' init'+ item.id +'();'); + // options.htmlCode.script.init.update.push('init'+ item.id +'();'); + // } + }); + }; + /* 重新渲染设计区*/ Class.prototype.renderForm = function () { var that = this,