增加动态表单自动排版配置界面的保存回显逻辑

This commit is contained in:
cuibaocheng 2021-08-13 19:26:23 +08:00
parent c1212fb799
commit 11a3cb425e
2 changed files with 136 additions and 100 deletions

View File

@ -42,17 +42,26 @@
<input type="text" id="id" name="id" disabled="disabled" class="layui-input" value="{{d.id}}" placeholder="" >
</div>
</div>
{{# if(typeof(d.title) == 'string' && !d.title.match(RegExp(/\"/g))) { }}
<div class="layui-form-item">
<label class="layui-form-label">title<span style="color: red">*</span></label>
<div class="layui-input-block">
<input type="text" id="title" name="title" class="layui-input title" value="{{d.title}}" placeholder="请输入标题" >
</div>
</div>
{{# } else { }}
<div class="layui-form-item layui-form-text">
<label class="layui-form-label">title<span style="color: red">*</span></label>
<div class="layui-input-block">
<textarea id="title" name="title" placeholder="请输入标题" class="layui-input title layui-textarea">{{ d.title}}</textarea>
</div>
</div>
{{# } }}
<div class="layui-formitem" style="text-align: center;width:100% !important;font-size: 17px">
<b style="color: red">模块data对象参数</b>
</div>
{{# for(let key in d.data) { }}
{{# if(typeof(d.data[key]) == 'string') { }}
{{# if(typeof(d.data[key]) == 'string' && !d.data[key].match(RegExp(/\"/g))) { }}
<div class="layui-form-item">
<label class="layui-form-label">{{key}}<span style="color: red">*</span></label>
<div class="layui-input-block">
@ -77,6 +86,13 @@
<input type="checkbox" id="data_{{key}}" name="data_{{key}}" lay-filter="dataSwitchRowFilter" value="{{d.data[key]}}" {{d.data[key] == true ? 'checked="checked"' : ''}} lay-skin="switch" lay-text="开|关">
</div>
</div>
{{# } else { }}
<div class="layui-form-item layui-form-text">
<label class="layui-form-label">{{key}}<span style="color: red">*</span></label>
<div class="layui-input-block">
<textarea id="data_{{key}}" name="data_{{key}}" placeholder="" class="layui-input dataInputRowFilter layui-textarea">{{d.data[key]}}</textarea>
</div>
</div>
{{# } }}
{{# } }}
{{# var mList = d.list; }}
@ -93,7 +109,7 @@
<botton class="layui-btn layui-btn-xs layui-btn-danger removeRow" style="margin-left: 10px;margin-bottom: 5px;" listIndex="{{i}}" >删除本行</botton>
</div>
{{# var mData = mList[i]; }}
{{# if(typeof(mData) == 'string') { }}
{{# if(typeof(mData) == 'string' && !mData.match(RegExp(/\"/g))) { }}
<div class="layui-form-item">
<label class="layui-form-label">字符<span style="color: red">*</span></label>
<div class="layui-input-block">
@ -116,7 +132,7 @@
</div>
{{# } else if(typeof(mData) == 'object') { }}
{{# for(let key in mData) { }}
{{# if(typeof(mData[key]) == 'string') { }}
{{# if(typeof(mData[key]) == 'string' && !mData[key].match(RegExp(/\"/g))) { }}
<div class="layui-form-item">
<label class="layui-form-label">{{key}}<span style="color: red">*</span></label>
<div class="layui-input-block">
@ -140,11 +156,21 @@
<input type="checkbox" id="list_{{i}}_{{key}}" name="list_{{i}}_{{key}}" lay-filter="dataSwitchRowFilter" value="{{mData[key]}}" {{mData[key] == true ? 'checked="checked"' : ''}} lay-skin="switch" lay-text="开|关">
</div>
</div>
{{# } else { }}
<div class="layui-form-item layui-form-text">
<label class="layui-form-label">{{key}}<span style="color: red">*</span></label>
<div class="layui-input-block">
<textarea id="list_{{i}}_{{key}}" name="list_{{i}}_{{key}}" placeholder="" class="layui-input dataInputRowFilter layui-textarea">{{mData[key]}}</textarea>
</div>
</div>
{{# } }}
{{# } }}
{{# } else { }}
<div class="layui-form-item">
<label class="layui-form-label">{{typeof(mData) }}<span style="color: red">*</span></label>
<div class="layui-form-item layui-form-text">
<label class="layui-form-label">{{key}}<span style="color: red">*</span></label>
<div class="layui-input-block">
<textarea id="list_{{i}}" name="list_{{i}}" placeholder="" class="layui-input dataInputRowFilter layui-textarea">{{mData}}</textarea>
</div>
</div>
{{# } }}
{{# } }}
@ -403,6 +429,7 @@
top.restAjax.get(top.restAjax.path('api/bigdatatemplatearea/getbigdatatemplateareabyid/{bigdataTemplateAreaId}', [bigdataTemplateAreaId]), {}, null, function(code, data) {
areaData = data;
templateAreaModuleData = eval("("+ data.templateAreaModuleData +")");
console.log(templateAreaModuleData)
laytpl(document.getElementById('templateAreaModuleDataScript').innerHTML).render(templateAreaModuleData, function(html) {
document.getElementById('templateAreaModuleDataDiv').innerHTML = html;
form.render();
@ -488,7 +515,16 @@
dataList.push(data);
}
templateAreaModuleJsonData.list = dataList;
var newtTemplateAreaModuleData = JSON.stringify(templateAreaModuleJsonData).replace(/\"/g,"'");
var newtTemplateAreaModuleData = JSON.stringify(templateAreaModuleJsonData)
if(newtTemplateAreaModuleData.indexOf("\'") > 1) {
layer.msg("不允许使用单引号");
return;
}
console.log(newtTemplateAreaModuleData);
newtTemplateAreaModuleData = newtTemplateAreaModuleData.replace(/\"/g,"'");
console.log(newtTemplateAreaModuleData);
newtTemplateAreaModuleData = newtTemplateAreaModuleData.replace(/\\'/g,"\"");
console.log(newtTemplateAreaModuleData);
top.restAjax.put(top.restAjax.path('api/bigdatatemplatearea/updatebigdatatemplateareapointmoduledata/{bigdataTemplateAreaId}?templateAreaModuleData={newtTemplateAreaModuleData}', [bigdataTemplateAreaId]), newtTemplateAreaModuleData, null, function(code, data) {
top.dialog.close(index);
// window.location.reload();

View File

@ -43,7 +43,7 @@ public class PicturesTemplateAreaBuildingDTO {
@ApiModelProperty(name = "templateAreaFontColor", value = "文字颜色")
private String templateAreaFontColor;
@ApiModelProperty(name = "templateAreaFontSize", value = "文字大小")
private String templateAreaFontSize;
private Integer templateAreaFontSize;
@ApiModelProperty(name = "templateAreaFontLength", value = "字体长度限制")
private Integer templateAreaFontLength = 0;
@ApiModelProperty(name = "templateAreaFontBold", value = "文字加粗0:正常,1:加粗,2:斜体")
@ -179,11 +179,11 @@ public class PicturesTemplateAreaBuildingDTO {
this.templateAreaFontColor = templateAreaFontColor;
}
public String getTemplateAreaFontSize() {
return templateAreaFontSize == null ? "" : templateAreaFontSize;
public Integer getTemplateAreaFontSize() {
return templateAreaFontSize == null ? 0 : templateAreaFontSize;
}
public void setTemplateAreaFontSize(String templateAreaFontSize) {
public void setTemplateAreaFontSize(Integer templateAreaFontSize) {
this.templateAreaFontSize = templateAreaFontSize;
}