提交 5a3c8602 编写于 作者: Skyeye云's avatar Skyeye云

表单布局编辑布局完成

上级 bcf0b6a6
......@@ -26,7 +26,7 @@ layui.config({
}});
var pageHtml = {
'create': `<div style="margin:0 auto;padding:20px;">
'createOrEdit': `<div style="margin:0 auto;padding:20px;">
<form class="layui-form" action="" id="showForm" autocomplete="off">
<div id="content"></div>
<div class="layui-form-item layui-col-xs12">
......@@ -55,7 +55,12 @@ layui.config({
// 初始化加载
function init() {
console.log(pageMation);
var html = pageHtml[pageMation.type];
var html;
if (pageMation.type == 'create' || pageMation.type == 'edit') {
html = pageHtml['createOrEdit'];
} else {
html = pageHtml[pageMation.type];
}
$("body").append(html);
// 加载页面
......@@ -66,6 +71,15 @@ layui.config({
if (pageMation.type == 'create') {
// 创建布局
dsFormUtil.initCreatePage('content', pageMation);
} else if (pageMation.type == 'edit') {
// 编辑布局
var params = {
objectId: GetUrlParam("id"),
objectKey: pageMation.className
};
AjaxPostUtil.request({url: reqBasePath + "queryBusinessDataByObject", params: params, type: 'json', method: 'POST', callback: function (json) {
dsFormUtil.initEditPage('content', pageMation, json.bean);
}});
} else if (pageMation.type == 'simpleTable') {
// 基本表格
dsFormTableUtil.initDynamicTable('messageTable', pageMation);
......
......@@ -46,6 +46,28 @@ var dsFormUtil = {
// todo 待删除
},
/**
* 加载动态表单(编辑操作)
*
* @param showBoxId
* @param pageMation
* @param data
*/
initEditPage: function(showBoxId, pageMation, data) {
dsFormUtil.initCreatePage(showBoxId, pageMation);
$.each(dsFormUtil.pageMation.dsFormPageContents, function (i, content) {
if (!isNull(content.attrDefinition)) {
// 获取组件中设置值的脚本
var dsFormComponent = content.dsFormComponent;
var setValueScript = getDataUseHandlebars('{{#this}}' + dsFormComponent.jsFitValue + '{{/this}}', content);
// value参数不能删除,用于组件的赋值脚本使用
var value = data[content.attrDefinition.attrKey];
eval(setValueScript);
}
});
layui.form.render();
},
/**
* 加载动态表单(新增操作)
*
......@@ -85,6 +107,10 @@ var dsFormUtil = {
params[content.attrDefinition.attrKey] = value;
}
});
if (dsFormUtil.pageMation.type == 'edit') {
// 编辑布局
params["id"] = GetUrlParam("id");
}
// 发送请求
dsFormUtil.sendRequest({
businessApi: dsFormUtil.pageMation.businessApi,
......@@ -99,24 +125,6 @@ var dsFormUtil = {
}
return false;
});
},
loadEditDsFormItem: function(showBoxId, json) {
$.each(json.rows, function(j, bean) {
var customBoxId = bean.pageId;
$("#" + showBoxId).append(getDataUseHandlebars(dsFormUtil.customWriteDsFormBox, bean.dsFormPage));
dsFormUtil.loadDsFormItemToEdit(customBoxId, bean.dsFormPageDataList);
});
form.render();
},
loadDsFormItemToEdit: function (customBoxId, rows) {
$.each(rows, function(i, item) {
var pageComponent = item.dsFormPageContent;
pageComponent.value = item.value;
dsFormUtil.setValue(customBoxId, pageComponent, i);
});
},
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册