-
+
-
+
@@ -62,14 +69,14 @@
-
+
@@ -192,7 +202,9 @@
editNextOnEnterKey="true" editNextRowCell="true" allowLeafDropIn="true"
allowDrag="true" allowDrop="true" iconField="iconCls" treeColumn="index" idField="field">
- 序号(拖动排序)
+
+ 序号(拖动排序)
+
标识
@@ -203,7 +215,8 @@
操作
-
+
@@ -213,6 +226,282 @@
+
+
+
+
+
@@ -223,7 +512,8 @@
+ editNextOnEnterKey="true" showFilterRow="true" treeColumn="name" nodesField="columns"
+ editNextRowCell="true">
名称
类型
备注
-
操作
@@ -242,5 +533,72 @@
+
+
+
+
+
+
+ #
+ 字段
+
+
+ 文本字段
+
+
+ 标题
+
+
+ 宽度
+
+
+
+ 操作
+
+
+
+
+
+
+
+
+
+
+
+
+
+ #
+ 标题
+
+
+
+ URL
+
+
+
+
+
+
+
+ 操作
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/hsweb-ui/admin/form/designer-drag/index.js b/hsweb-ui/admin/form/designer-drag/index.js
index 645d9e8..8ce8ddb 100644
--- a/hsweb-ui/admin/form/designer-drag/index.js
+++ b/hsweb-ui/admin/form/designer-drag/index.js
@@ -24,27 +24,33 @@ function initClp(desinger) {
message.showTips("格式错误,仅支持json或者html格式!")
}
}
- mini.showMessageBox({
- title: "请输入粘贴内容",
- iconCls: "mini-messagebox-question",
- buttons: ["新建", "复制", "取消"],
- message: "选择粘贴方式 新建: 粘贴为新的表单. 复制: 保持粘贴的配置不变",
- callback: function (action) {
- if (action === '复制') {
- desinger.loadConfig(cfg);
+ if (componentRepo.useIdForName) {
+ desinger.loadConfig(cfg, true);
+ } else {
+ mini.showMessageBox({
+ title: "请输入粘贴内容",
+ iconCls: "mini-messagebox-question",
+ buttons: ["新建", "复制", "取消"],
+ message: "选择粘贴方式 新建: 粘贴为新的表单. 复制: 保持粘贴的配置不变",
+ callback: function (action) {
+ if (action === '复制') {
+ desinger.loadConfig(cfg);
+ }
+ if (action === '新建') {
+ desinger.loadConfig(cfg, true);
+ }
}
- if (action === '新建') {
- desinger.loadConfig(cfg, true);
- }
- }
- });
+ });
+ }
});
})
});
require(["clipboard.min.js"], function (Clipboard) {
var clipboard = new Clipboard('.copy-button', {
text: function (trigger) {
- return JSON.stringify(desinger.getConfig());
+ var json = JSON.stringify(desinger.getConfig());
+
+ return json;
}
});
@@ -52,13 +58,17 @@ function initClp(desinger) {
require(["message"], function (message) {
message.showTips("已将配置内容复制到粘贴板");
});
- // console.log(e);
+ //console.log(e);
e.clearSelection();
});
clipboard.on('error', function (e) {
- //console.error('Action:', e.action);
- // console.error('Trigger:', e.trigger);
+ console.error('ERROR:', e);
+ editScript("text", e.text, function (editor) {
+
+ }, function (editor) {
+
+ },"自动复制失败,请手动复制.");
});
});
$(".preview-button").on("click", function () {
@@ -138,7 +148,9 @@ importMiniui(function () {
"components", "css!defaults", "css!plugin/font-awesome/4.7.0/css/font-awesome.css",
"css!fonts/iconfont",
"css!plugin/jquery-ui/jquery-ui.min",
- 'css!designer'], function (Designer, md5, request) {
+ 'css!designer'
+ // ,"css!designer-custom"
+ ], function (Designer, md5, request) {
componentRepo.useIdForName = request.getParameter("useIdForName") === 'true';
var param = request.getParameter("components");
@@ -155,6 +167,9 @@ importMiniui(function () {
require(componentsImport, function () {
var designer = window.designer = new Designer();
+ window.getDesigner = function () {
+ return designer;
+ }
initClp(designer);
designer.init();
designer.on("configChanged", function () {
@@ -179,7 +194,8 @@ importMiniui(function () {
window.tools = tools;
window.message = message;
});
- window.editScript = function (lang, script, call, onSubmit) {
+ window.editScript = function (lang, script, call, onSubmit,title) {
+ mini.get("script-editor-window").setTitle(title||"脚本编辑");
require(['script-editor'], function (editorBuilder) {
editorBuilder.createEditor("script-editor", function (editor) {
editor.init(lang, script);
@@ -200,8 +216,8 @@ importMiniui(function () {
var optionType = mini.get("optionType");
var optionalGrid = mini.get("operation-grid");
- window.addOperationData=function () {
- var data = {text:"新建选项"};
+ window.addOperationData = function () {
+ var data = {text: "新建选项"};
if (componentRepo.useIdForName) {
data.id = md5(new Date().getTime() + "" + Math.random());
}
@@ -243,6 +259,17 @@ importMiniui(function () {
e.sender.removeNode(e.record);
})
};
+
+ mini.get("data-table-datagrid").getColumn("action").renderer = function (e) {
+ return tools.createActionButton("删除", "icon-remove", function () {
+ e.sender.removeNode(e.record);
+ })
+ };
+ mini.get("tabs-datagrid").getColumn("action").renderer = function (e) {
+ return tools.createActionButton("删除", "icon-remove", function () {
+ e.sender.removeNode(e.record);
+ })
+ };
$(".edit-javascript").on("click", function () {
editScript("javascript", designer.javascript || "// this为formParser对象." +
"\n// this.on('load',function(){ this.setData({ }) })", function (editor) {
@@ -253,7 +280,7 @@ importMiniui(function () {
});
$(".edit-css").on("click", function () {
- editScript("css", designer.css || "/*.dynamic-form * {\n\tfont-size:20px;\n}/*", function (editor) {
+ editScript("css", designer.css || "/*.dynamic-form {font-size:20px;}/*", function (editor) {
}, function (editor) {
designer.css = editor.getScript();
diff --git a/hsweb-ui/admin/form/designer-drag/parser.js b/hsweb-ui/admin/form/designer-drag/parser.js
index b6d8b1a..48b8669 100644
--- a/hsweb-ui/admin/form/designer-drag/parser.js
+++ b/hsweb-ui/admin/form/designer-drag/parser.js
@@ -30,6 +30,66 @@
this.call(args);
})
};
+
+ FormParser.prototype.getbyName = function (name) {
+ return this.getComponent(function (comp) {
+ return comp.getProperty('name').value === name
+ })
+ };
+ FormParser.prototype.get = function (id) {
+ return this.getComponent(function (comp) {
+ return comp.id === id || comp._uid === id;
+ })
+ };
+
+ FormParser.prototype.getComponent = function (call) {
+ for (var i = 0; i < this.components.length; i++) {
+ if (call(this.components[i].target)) {
+ return this.components[i].target;
+ }
+ }
+ return null;
+ };
+
+ FormParser.prototype.setErrors = function (errorMessage) {
+ var me = this;
+ if (typeof errorMessage === 'string') {
+ errorMessage = mini.decode(errorMessage);
+ }
+ if (errorMessage) {
+ $(errorMessage).each(function () {
+ var field = mini.getbyName(this.field);
+ if (field) {
+ field.setIsValid(false);
+ field.setErrorText(this.message);
+ } else {
+ var component = me.getbyName(this.field);
+ if (component && component.setError) {
+ component.setError(this);
+ }
+ }
+ });
+ }
+ }
+ FormParser.prototype.setReadOnly = function (readonly) {
+ if (this.formId) {
+ var form = new mini.Form("#" + this.formId);
+ var fields = form.getFields();
+ for (var i = 0, l = fields.length; i < l; i++) {
+ var c = fields[i];
+ if (c.setReadOnly) c.setReadOnly(readonly); //只读
+ if (c.setIsValid) c.setIsValid(true); //去除错误提示
+ if (c.addCls) c.addCls("read-only"); //增加asLabel外观
+ }
+ $(this.components).each(function () {
+ var target = this.target;
+ if (target && target.setReadOnly) {
+ target.setReadOnly(readonly);
+ }
+ });
+ }
+ };
+
FormParser.prototype.setData = function (data) {
if (this.formId) {
var form = new mini.Form("#" + this.formId);
@@ -37,8 +97,20 @@
form.setData(data);
$(this.components).each(function () {
var target = this.target;
- if (target && target.setValue) {
- target.setValue(name, data);
+ var name = this.target.getProperty('name').value;
+
+ if (name) {
+ var nestName = name.split(".");
+ var val = data;
+ for (var i = 0; i < nestName.length; i++) {
+ val = val[nestName[i]];
+ }
+ if (target && val && target.setValue) {
+ target.setValue(val, data);
+ }
+ }
+ if (target.setData) {
+ target.setData(data);
}
});
this.doEvent("setData", this);
@@ -66,6 +138,7 @@
}
};
+
FormParser.prototype.render = function (el) {
var customEvents = {};
var me = this;
@@ -82,34 +155,48 @@
console.log("加载表单脚本失败", e);
}
}
+
var html = $(" |