提交 365c450d 编写于 作者: Skyeye云's avatar Skyeye云

表单布局新增提交完成

上级 fbd02af4
......@@ -19,6 +19,7 @@ layui.config({
// 组件分类
sysDictDataUtil.showDictDataListByDictTypeCode(sysDictData["dsFormContentType"]["key"], 'select', "dsFormContentType", '', form);
skyeyeClassEnumUtil.showEnumDataListByClassName("dsFormShowType", 'select', "showType", '', form);
// 根据类型获取部分功能的使用说明
systemCommonUtil.queryExplainMationByType(2, function(json) {
......@@ -101,6 +102,7 @@ layui.config({
jsDisplayValue: encodeURIComponent(jsDisplayValue.getValue()),
jsFitValue: encodeURIComponent(jsFitValue.getValue()),
typeId: $("#dsFormContentType").val(),
showType: $("#showType").val(),
linkedData: '2',
displayTemplateId: '',
defaultData: '',
......
......@@ -47,6 +47,7 @@ layui.config({
// 组件分类
sysDictDataUtil.showDictDataListByDictTypeCode(sysDictData["dsFormContentType"]["key"], 'select', "dsFormContentType", json.bean.typeId, form);
skyeyeClassEnumUtil.showEnumDataListByClassName("dsFormShowType", 'select', "showType", json.bean.showType, form);
// 根据类型获取部分功能的使用说明
systemCommonUtil.queryExplainMationByType(2, function (json) {
......@@ -140,6 +141,7 @@ layui.config({
jsDisplayValue: encodeURIComponent(jsDisplayValue.getValue()),
jsFitValue: encodeURIComponent(jsFitValue.getValue()),
typeId: $("#dsFormContentType").val(),
showType: $("#showType").val(),
linkedData: '2',
displayTemplateId: '',
defaultData: '',
......
......@@ -29,6 +29,9 @@ layui.config({
{ field: 'numCode', title: '编码', width: 120 },
{ field: 'name', title: '名称', width: 120 },
{ field: 'typeName', title: '分类', width: 120 },
{ field: 'showType', title: '显示类型', width: 120, templet: function (d) {
return skyeyeClassEnumUtil.getEnumDataNameByCodeAndKey("dsFormShowType", 'id', d.showType, 'name');
}},
{ field: 'id', title: '图标', align: 'center', width: 60, templet: function (d) {
return systemCommonUtil.initIconShow(d);
}},
......
......@@ -25,7 +25,7 @@ layui.config({
if (!isNull(json.bean.dsFormPageMations)) {
$.each(json.bean.dsFormPageMations, function (i, item) {
addRow();
$("#dsFormChooseList" + (rowNum - 1)).val(item.pageNum);
$("#dsFormChooseList" + (rowNum - 1)).val(item.numCode);
$("#dsFormChooseList" + (rowNum - 1)).attr("dataId", item.id);
$("#name" + (rowNum - 1)).html(item.name);
})
......@@ -85,7 +85,7 @@ layui.config({
var btnId = par.dsFormChooseList + "Btn";
$("body").on("click", "#" + btnId, function (e) {
dsFormUtil.chooseType = false; // 单选
dsFormUtil.openDsFormPageChoosePage(function (){
dsFormUtil.openDsFormPageChoosePage(function () {
$("#" + par.dsFormChooseList).val(dsFormUtil.dsFormChooseMation.numCode);
$("#" + par.dsFormChooseList).attr("dataId", dsFormUtil.dsFormChooseMation.id);
$("#" + par.name).html(dsFormUtil.dsFormChooseMation.name);
......
......@@ -30,13 +30,13 @@ layui.config({
// 加载新增加的控件信息
function loadNewControl(item) {
if(item.associatedDataTypes == 1){//json串
if (item.associatedDataTypes == 1) {//json串
var obj = item.aData;
if(typeof item.aData == 'string'){
obj = JSON.parse(item.aData);
}
item.context = getDataUseHandlebars(item.dsFormComponent.templateContent, obj);
} else if (item.associatedDataTypes == 2){//接口
} else if (item.associatedDataTypes == 2) {//接口
AjaxPostUtil.request({url: flowableBasePath + "dsformpage011", params: {interfa: item.aData}, type: 'json', callback: function(j){
var obj = JSON.parse(j.bean.aData);
item.context = getDataUseHandlebars(item.dsFormComponent.templateContent, obj);
......
......@@ -41,6 +41,14 @@
</select>
</div>
</div>
<div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">显示类型<i class="red">*</i></label>
<div class="layui-input-block">
<select lay-filter="showType" lay-search="" id="showType" win-verify="required">
</select>
</div>
</div>
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">HTML脚本<i class="red">*</i></label>
<div class="layui-input-block">
......
......@@ -47,6 +47,14 @@
</select>
</div>
</div>
<div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">显示类型<i class="red">*</i></label>
<div class="layui-input-block">
<select lay-filter="showType" lay-search="" id="showType" win-verify="required">
</select>
</div>
</div>
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">HTML脚本<i class="red">*</i></label>
<div class="layui-input-block">
......
......@@ -87,7 +87,7 @@
<input type="text" id="{{dsFormChooseList}}" name="{{dsFormChooseList}}" placeholder="请选择表单" class="layui-input" win-verify="required" readonly="readonly"/>
<i class="fa fa-plus-circle input-icon" id="{{dsFormChooseList}}Btn" style="top: 12px;"></i>
</td>
<td id="{{pageName}}"></td>
<td id="{{name}}"></td>
</tr>
</script>
......
......@@ -78,9 +78,9 @@ layui.config({
initTableChooseUtil.deleteAllRow('productList');
$.each(json.bean.norms, function(i, item) {
var params = {
"materialId": item.product.materialName + "(" + item.product.materialModel + ")",
"materialId": item.materialName + "(" + item.materialModel + ")",
"mUnitId": {
"html": getDataUseHandlebars(selOption, {rows: item.product.unitList}),
"html": getDataUseHandlebars(selOption, {rows: item.unitList}),
"value": item.mUnitId
},
"allStock": item.allStock,
......@@ -95,7 +95,7 @@ layui.config({
};
var trcusid = initTableChooseUtil.resetData('productList', params);
// 将规格所属的商品信息加入到对象中存储
allChooseProduct[trcusid] = item.product;
allChooseProduct[trcusid] = item;
});
textool.init({eleId: 'remark', maxlength: 200});
......
......@@ -9,6 +9,7 @@ var dsFormUtil = {
dsFormDataKey: "initData",
dsFormBtnTemplate: '<button type="button" class="layui-btn layui-btn-primary layui-btn-xs" id="{{btnId}}">表单选择</button>',
customDsFormBox: '<div class="layui-form-item layui-col-xs12"><span class="hr-title">{{dsFormPage.name}}</span><hr></div><div id="{{dsFormPage.id}}" class="ds-form-page layui-col-xs12"></div>',
customWriteDsFormBox: '<div class="layui-form-item layui-col-xs12"><span class="hr-title">{{name}}</span><hr></div><div id="{{id}}" class="ds-form-page layui-col-xs12"></div>',
// 必须包含的包
mastHaveImport: ['laydate', 'layedit', 'colorpicker', 'slider', 'fileUpload', 'codemirror', 'xml', 'clike', 'css', 'htmlmixed', 'javascript', 'nginx', 'solr', 'sql', 'vue',
'matchbrackets', 'closebrackets', 'showHint', 'anywordHint', 'lint', 'jsonLint', 'foldcode', 'foldgutter', 'braceFold', 'commentFold', 'form'],
......@@ -97,90 +98,116 @@ var dsFormUtil = {
dsFormObjectRelationId: isNull(dsFormObjectRelationId) ? "" : dsFormObjectRelationId
};
AjaxPostUtil.request({url: reqBasePath + "dsFormObjectRelation006", params: params, method: "GET", type: 'json', callback: function(json) {
dsFormUtil.loadDsFormItem(showBoxId, json);
dsFormUtil.loadAddDsFormItem(showBoxId, json);
}, async: false});
},
loadDsFormItem: function(showBoxId, json) {
$.each(json.rows, function(j, bean){
var customBoxId = bean.dsFormPage.id;
$("#" + showBoxId).append(getDataUseHandlebars(dsFormUtil.customDsFormBox, bean));
dsFormUtil.loadDsFormItemToEdit(customBoxId, bean.content);
loadAddDsFormItem: function(showBoxId, json) {
$.each(json.rows, function(j, bean) {
var customBoxId = bean.id;
$("#" + showBoxId).append(getDataUseHandlebars(dsFormUtil.customWriteDsFormBox, bean));
dsFormUtil.loadDsFormItemToAdd(customBoxId, bean.content);
});
form.render();
},
loadDsFormItemToAdd: function (customBoxId, rows) {
$.each(rows, function(i, item) {
item.value = item.defaultValue;
dsFormUtil.setValue(customBoxId, item, i);
});
},
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) {
if (item.associatedDataTypes == 1) {//json串
var obj = item.aData;
if(typeof item.aData == 'string'){
obj = JSON.parse(item.aData);
}
item.context = getDataUseHandlebars(item.templateContent, obj);
} else if (item.associatedDataTypes == 2) {//接口
AjaxPostUtil.request({url: flowableBasePath + "dsformpage011", params: {interfa: item.aData}, type: 'json', callback: function(j) {
var obj = JSON.parse(j.bean.aData);
item.context = getDataUseHandlebars(item.templateContent, obj);
}, async: false});
var pageComponent = item.dsFormPageContent;
pageComponent.value = item.value;
dsFormUtil.setValue(customBoxId, pageComponent, i);
});
},
setValue: function (customBoxId, item, i) {
if (item.associatedDataTypes == 1) {//json串
var obj = item.aData;
if(typeof item.aData == 'string'){
obj = JSON.parse(item.aData);
}
var jsonStr = {bean: item};
var html = getDataUseHandlebars('{{#bean}}' + item.htmlContent + '{{/bean}}', jsonStr);
var html_js = getDataUseHandlebars('{{#bean}}' + item.jsContent + '{{/bean}}', jsonStr);
var jsCon = '<script>layui.define(["jquery"], function(exports) {var jQuery = layui.jquery;(function($) {' + html_js + '})(jQuery);});</script>';
$("#" + customBoxId).append(html + jsCon);
item.context = getDataUseHandlebars(item.dsFormComponent.templateContent, obj);
} else if (item.associatedDataTypes == 2) {//接口
AjaxPostUtil.request({url: flowableBasePath + "dsformpage011", params: {interfa: item.aData}, type: 'json', callback: function(j) {
var obj = JSON.parse(j.bean.aData);
item.context = getDataUseHandlebars(item.dsFormComponent.templateContent, obj);
}, async: false});
}
var jsonStr = {bean: item};
var html = getDataUseHandlebars('{{#bean}}' + item.dsFormComponent.htmlContent + '{{/bean}}', jsonStr);
var html_js = getDataUseHandlebars('{{#bean}}' + item.dsFormComponent.jsContent + '{{/bean}}', jsonStr);
var jsCon = '<script>layui.define(["jquery"], function(exports) {var jQuery = layui.jquery;(function($) {' + html_js + '})(jQuery);});</script>';
$("#" + customBoxId).append(html + jsCon);
// 给能通过id赋值的控件赋值
$("#" + item.id).val(item.value);
var _this = $("#" + customBoxId + " .layui-form-item").eq(i);//当前控件
if (!isNull(item.require) && item.require.indexOf("required") >= 0){
_this.find(".layui-form-label").append('<i class="red">*</i>');
// 给能通过id赋值的控件赋值
$("#" + item.id).val(item.value);
var _this = $("#" + customBoxId + " .layui-form-item").eq(i);
if (!isNull(item.require) && item.require.indexOf("required") >= 0){
_this.find(".layui-form-label").append('<i class="red">*</i>');
}
_this.attr("controId", item.id);
var vid = _this.attr("controlType");//控件类型
if (vid === 'color') {//类型为颜色选择器
_this.find("input").val(item.value);
_this.find('div[id="' + item.id + '"]').find("span .layui-colorpicker-trigger-span").attr("style", "background:" + item.value);
} else if (vid === 'switchedradio') {//类型为开关式单选框
_this.find("input").val(item.value);
if (item.value === 'true' || item.value == true) {
_this.find("input").prop("checked", true);
}
_this.attr("controId", item.id);
var vid = _this.attr("controlType");//控件类型
if (vid === 'color') {//类型为颜色选择器
_this.find("input").val(item.value);
_this.find('div[id="' + item.id + '"]').find("span .layui-colorpicker-trigger-span").attr("style", "background:" + item.value);
} else if (vid === 'switchedradio') {//类型为开关式单选框
_this.find("input").val(item.value);
if (item.value === 'true' || item.value == true) {
_this.find("input").prop("checked", true);
}
_this.find("input").attr('id', item.id);
_this.find("input").attr('name', item.id);
_this.find("input").attr('lay-filter', item.id);
} else if (vid === 'radio') {//类型为单选框
_this.find("input:radio").attr("name", item.id);
if (!isNull(item.value))
_this.find("input:radio[value=" + item.value + "]").attr("checked", true);
} else if (vid === 'richtextarea') {//类型为富文本框
_this.find('iframe[textarea="' + item.id + '"]').contents().find("body").html(item.value);
} else if (vid === 'checkbox') {//类型为多选框
var checkArray = item.value.split(",");
var checkBoxAll = _this.find("input:checkbox");
checkBoxAll.attr("name", item.id);
for (var k = 0; k < checkArray.length; k++) {
$.each(checkBoxAll, function (j, item) {
if (checkArray[k] == $(this).val()) {
$(this).prop("checked", true);
}
});
}
_this.find("input").attr('id', item.id);
_this.find("input").attr('name', item.id);
_this.find("input").attr('lay-filter', item.id);
} else if (vid === 'radio') {//类型为单选框
_this.find("input:radio").attr("name", item.id);
if (!isNull(item.value))
_this.find("input:radio[value=" + item.value + "]").attr("checked", true);
} else if (vid === 'richtextarea') {//类型为富文本框
_this.find('iframe[textarea="' + item.id + '"]').contents().find("body").html(item.value);
} else if (vid === 'checkbox') {//类型为多选框
var checkArray = item.value.split(",");
var checkBoxAll = _this.find("input:checkbox");
checkBoxAll.attr("name", item.id);
for (var k = 0; k < checkArray.length; k++) {
$.each(checkBoxAll, function (j, item) {
if (checkArray[k] == $(this).val()) {
$(this).prop("checked", true);
}
});
}
});
}
},
/**
* 获取保存的数据
*/
savePageData: function (showBoxId, objectId) {
var result = {};
var result = [];
$.each($("#" + showBoxId + " .ds-form-page"), function (i, item) {
var _item = $(item);
result[_item.attr("id")] = dsFormUtil.getPageData(_item);
result.push({
pageId: _item.attr("id"),
dsFormPageDataList: dsFormUtil.getPageData(_item)
});
});
var params = {
dataJson: JSON.stringify(result),
dsFormPageSequenceList: JSON.stringify(result),
objectId: objectId
}
AjaxPostUtil.request({url: flowableBasePath + "dsformpage014", params: params, type: 'json', method: "POST", callback: function(json) {
......@@ -192,18 +219,16 @@ var dsFormUtil = {
for(var i = 0; i < _item.find(".layui-form-item").length; i++){
var _this = _item.find(".layui-form-item").eq(i);
var vid = _this.attr("controlType"),//控件类型
showType = "", text = "", value = "";
text = "", value = "";
if (isNull(vid)) {
continue;
}
if (vid === 'textarea') {//类型为文本框
text = _this.find("textarea").val();
value = _this.find("textarea").val();
showType = "1";
} else if (vid === 'select') {//类型为下拉框
text = _this.find("select").find("option:selected").text();
value = _this.find("select").val();
showType = "1";
} else if (vid === 'checkbox') {//类型为多选框
var checkName = _this.find("input:first").attr("name");
var texts = [], values = [];
......@@ -214,11 +239,9 @@ var dsFormUtil = {
});
text = texts.join(",");
value = values.join(",");
showType = "1";
} else if (vid === 'radio') {//类型为单选框
text = _this.find("input:radio:checked").attr("title");
value = _this.find("input:radio:checked").val();
showType = "1";
} else if (vid === 'upload') {//类型为图片上传
var uploadId = _this.find(".upload").attr("id");
text = $("#" + uploadId).find("input[type='hidden'][name='upload']").attr("oldurl");
......@@ -227,17 +250,14 @@ var dsFormUtil = {
text = "";
if (isNull(value))
value = "";
showType = "4";
} else if (vid === 'range') {//类型为滑块
text = _this.find(".layui-slider-tips").html();
value = _this.find(".layui-slider-tips").html();
showType = "1";
} else if (vid === 'richtextarea') {//类型为富文本框
var textareaId = _this.find("textarea").attr("id");
var content = encodeURIComponent(_this.find('iframe[textarea="' + textareaId + '"]').contents().find("body").html());
text = content;
value = content;
showType = "3";
} else if (vid === 'switchedradio') {//类型为开关式单选框
value = _this.find("input").val();
var layText = _this.find("input").attr('lay-text');
......@@ -246,18 +266,14 @@ var dsFormUtil = {
} else {
text = layText.split('|')[1];
}
showType = "1";
} else {
text = _this.find("input").val();
value = _this.find("input").val();
showType = "1";
}
list.push({
value: value,
text: text,
showType: showType,
controlType: vid,
rowId: _this.attr("controId")
displayValue: text,
contentId: _this.attr("controId")
});
}
return list;
......@@ -274,11 +290,64 @@ var dsFormUtil = {
$.each(json.rows, function(j, bean) {
var customBoxId = bean.dsFormPage.id;
$("#" + showBoxId).append(getDataUseHandlebars(dsFormUtil.customDsFormBox, bean));
dsFormUtil.initSequenceDataDetails(customBoxId, bean.content);
dsFormUtil.initSequencePageDataDetails(customBoxId, bean.dsFormPageDataList);
});
}, async: false});
},
/**
* 表单布局的详情展示
*
* @param customBoxId
* @param rows
*/
initSequencePageDataDetails: function (customBoxId, rows) {
$.each(rows, function (i, item) {
item.label = item.dsFormPageContent.title;
item.proportion = item.dsFormPageContent.width;
var jsonStr = {
bean: item
};
var showType = item.dsFormPageContent.dsFormComponent.showType;
if (showType == 4) { // 图片展示
var photoValue = [];
if (!isNull(jsonStr.bean.displayValue)) {
photoValue = item.displayValue.split(",");
}
var rows = [];
$.each(photoValue, function(j, row){
rows.push({photoValue: row});
});
jsonStr.bean.photo = rows;
}
// 加载html
var str = getDataUseHandlebars(dsFormUtil.showType[showType], jsonStr);
$("#" + customBoxId).append(str);
if (showType == 5) { // 表格展示
var table = layui.table;
table.render({
id: "messageTable" + item.orderBy,
elem: "#messageTable" + item.orderBy,
data: item.displayValue,
page: false,
cols: dsFormUtil.getTableHead(item.attrTransformTableList)
});
} else if (showType == 6) { // 凭证展示
var boxId = "showVoucher" + item.orderBy;
// 初始化凭证
voucherUtil.initDataDetails(boxId, item.value);
}
});
},
/**
* 目前用于工作流详情展示
*
* @param customBoxId
* @param rows
*/
initSequenceDataDetails: function (customBoxId, rows) {
$.each(rows, function (i, item) {
var jsonStr = {
......@@ -286,7 +355,7 @@ var dsFormUtil = {
};
if (item.showType == 4) { // 图片展示
var photoValue = [];
if (!isNull(jsonStr.bean.displayValue)){
if (!isNull(jsonStr.bean.displayValue)) {
photoValue = item.displayValue.split(",");
}
var rows = [];
......@@ -343,7 +412,7 @@ var dsFormUtil = {
*/
loadPageToEditByObjectId: function(showBoxId, objectId) {
AjaxPostUtil.request({url: flowableBasePath + "dsformpage015", params: {objectId: objectId}, method: "GET", type: 'json', callback: function (json) {
dsFormUtil.loadDsFormItem(showBoxId, json);
dsFormUtil.loadEditDsFormItem(showBoxId, json);
}, async: false});
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册