增加动态表单自动排版配置界面的保存回显逻辑
This commit is contained in:
parent
8b1203510f
commit
0075b650ec
@ -3,7 +3,6 @@ package cn.com.tenlion.bigdata.util;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import sun.misc.BASE64Decoder;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.KeyGenerator;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
@ -1,10 +1,7 @@
|
||||
package cn.com.tenlion.buildingpictures.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.sun.org.apache.bcel.internal.generic.NEW;
|
||||
import com.sun.org.apache.xml.internal.utils.StringToStringTable;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
|
@ -42,7 +42,8 @@ public class ConfigColumnAppController extends DefaultBaseController {
|
||||
@GetMapping("listhome")
|
||||
public List<ConfigColumnDTO> listHome(@RequestHeader("token") String token) {
|
||||
Map<String, Object> params = requestParams();
|
||||
return configColumnService.listDefault(token, params);
|
||||
params.put("configColumnDefault", "1");
|
||||
return configColumnService.listApp(token, params);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增", notes = "新增接口")
|
||||
@ -101,7 +102,7 @@ public class ConfigColumnAppController extends DefaultBaseController {
|
||||
@GetMapping("list")
|
||||
public List<ConfigColumnDTO> list(@RequestHeader("token") String token) {
|
||||
Map<String, Object> params = requestParams();
|
||||
return configColumnService.list(params);
|
||||
return configColumnService.listApp(token, params);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "分页列表", notes = "分页列表接口")
|
||||
|
@ -257,6 +257,6 @@ public interface IConfigColumnService {
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
List<ConfigColumnDTO> listDefault(String token, Map<String, Object> params);
|
||||
List<ConfigColumnDTO> listApp(String token, Map<String, Object> params);
|
||||
|
||||
}
|
@ -288,17 +288,21 @@ public class ConfigColumnServiceImpl extends DefaultBaseService implements IConf
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ConfigColumnDTO> listDefault(String token, Map<String, Object> params) {
|
||||
params.put("configColumnDefault", "1");
|
||||
public List<ConfigColumnDTO> listApp(String token, Map<String, Object> params) {
|
||||
params.put("configColumnStatus", "1");
|
||||
List<ConfigColumnDTO> list = configColumnDao.list(params);
|
||||
/**
|
||||
* 封装自定义的显示隐藏 . 自定义的栏目名称
|
||||
*/
|
||||
List<ConfigColumnDTO> resultList = new ArrayList<ConfigColumnDTO>();
|
||||
// 首页是加载名片创建者userId下配置的所有栏目, 个人中心加载的是token下配置的所有栏目
|
||||
String userIdOrToken = token;
|
||||
if(params.get("creator") != null) {
|
||||
userIdOrToken = params.get("creator").toString();
|
||||
}
|
||||
for(ConfigColumnDTO dto : list) {
|
||||
ConfigColumnSetDTO setDisplayDTO = iConfigColumnSetService.getSetDisplay(token, dto.getConfigColumnId());
|
||||
ConfigColumnSetDTO setNameDTO = iConfigColumnSetService.getSetName(token, dto.getConfigColumnId());
|
||||
ConfigColumnSetDTO setDisplayDTO = iConfigColumnSetService.getSetDisplayByUserId(userIdOrToken, dto.getConfigColumnId());
|
||||
ConfigColumnSetDTO setNameDTO = iConfigColumnSetService.getSetDisplayByUserId(userIdOrToken, dto.getConfigColumnId());
|
||||
ConfigTableDTO tableDTO = iConfigTableOperationService.getTable(dto.getConfigTableId());
|
||||
if (tableDTO != null) {
|
||||
dto.setConfigTableMode(tableDTO.getConfigTableMode());
|
||||
|
@ -190,4 +190,18 @@ public interface IConfigColumnSetService {
|
||||
*/
|
||||
ConfigColumnSetDTO getSetDisplay(String token, String configColumnId);
|
||||
|
||||
/**
|
||||
* 查询栏目的自定义名称
|
||||
* @param userId
|
||||
* @param configColumnId
|
||||
*/
|
||||
ConfigColumnSetDTO getSetNameByUserId(String userId, String configColumnId);
|
||||
|
||||
/**
|
||||
* 查询栏目的自定义隐藏
|
||||
* @param userId
|
||||
* @param configColumnId
|
||||
*/
|
||||
ConfigColumnSetDTO getSetDisplayByUserId(String userId, String configColumnId);
|
||||
|
||||
}
|
@ -271,4 +271,22 @@ public class ConfigColumnSetServiceImpl extends DefaultBaseService implements IC
|
||||
return count == null ? 0 : count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigColumnSetDTO getSetNameByUserId(String userId, String configColumnId) {
|
||||
Map<String, Object> params = getHashMap(3);
|
||||
params.put("userId", userId);
|
||||
params.put("configColumnId", configColumnId);
|
||||
params.put("configColumnSetMode", "2");
|
||||
return get(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigColumnSetDTO getSetDisplayByUserId(String userId, String configColumnId) {
|
||||
Map<String, Object> params = getHashMap(3);
|
||||
params.put("userId", userId);
|
||||
params.put("configColumnId", configColumnId);
|
||||
params.put("configColumnSetMode", "1");
|
||||
return get(params);
|
||||
}
|
||||
|
||||
}
|
@ -313,6 +313,7 @@ public class ConfigTableFieldServiceImpl extends DefaultBaseService implements I
|
||||
params.put("configTableId", configTableId);
|
||||
params.put("configTableFieldId", jsonArray.getJSONObject(i).getString("configTableFieldId"));
|
||||
params.put("configTableFieldRowCol", jsonArray.getJSONObject(i).getIntValue("configTableFieldRowCol"));
|
||||
params.put("configTableFieldRow", jsonArray.getJSONObject(i).getIntValue("configTableFieldRow"));
|
||||
params.put("configTableFieldOrder", jsonArray.getJSONObject(i).getIntValue("configTableFieldOrder"));
|
||||
configTableFieldDao.updateOrder(params);
|
||||
}
|
||||
|
@ -69,9 +69,7 @@
|
||||
UPDATE
|
||||
m_config_table_field
|
||||
SET
|
||||
<if test="configTableFieldRow != null and configTableFieldRow != 0">
|
||||
config_table_field_row = #{configTableFieldRow},
|
||||
</if>
|
||||
config_table_field_row_col = #{configTableFieldRowCol},
|
||||
config_table_field_order = #{configTableFieldOrder}
|
||||
WHERE
|
||||
|
@ -58,7 +58,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<form class="layui-form layui-form-pane" action="javascript:void(0);" lay-filter="dataForm">
|
||||
<div class="layui-row" style="height:30px;text-align: right;margin-bottom: 40px;">
|
||||
<div class="layui-row" style="height:30px;text-align: left;margin-bottom: 40px;">
|
||||
<div class="layui-col-lg12">
|
||||
<button type="button" class="saveEvent layui-btn layui-btn-sm" lay-event="saveEvent">
|
||||
<i class="fa fa-lg fa-save"></i> 保存布局配置
|
||||
@ -92,12 +92,6 @@
|
||||
<input type="checkbox" value="1" id="configTableFieldMust" name="configTableFieldMust" checked lay-skin="switch" lay-text="必填|非必填">
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="layui-form-item" pane >
|
||||
<label class="layui-form-label">列表显示<span style="color: red">*</span></label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" value="1" id="configTableFieldDisplay" name="configTableFieldDisplay" checked lay-skin="switch" lay-text="显示|不显示">
|
||||
</div>
|
||||
</div>-->
|
||||
<div class="layui-form-item" >
|
||||
<label class="layui-form-label">提示引导<span style="color: red">*</span></label>
|
||||
<div class="layui-input-block">
|
||||
@ -136,20 +130,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--<div class="layui-row layui-container" id="container">
|
||||
<!– <div class="layui-col-lg12" id="container">
|
||||
</div>–>
|
||||
<!– <div class="layui-col-lg4" >
|
||||
<div class="layui-form-item" pane >
|
||||
<label class="layui-form-label">是否必填<span style="color: red">*</span></label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" lay-verify="required" name="configColumnGroupStatus" value="1" title="显示">
|
||||
<input type="radio" lay-verify="required" name="configColumnGroupStatus" value="0" title="隐藏">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>–>
|
||||
</div>-->
|
||||
</form>
|
||||
|
||||
<div class="layui-collapse" lay-accordion style="display: none" id="widthChange">
|
||||
@ -159,7 +139,7 @@
|
||||
</div>
|
||||
|
||||
<script id="type1" type="text/html">
|
||||
<div row-col="{{ d.configTableFieldRowCol }}" class="layui-col-lg{{ d.configTableFieldRowCol }} layui-col-md{{ d.configTableFieldRowCol }} layui-col-sm{{ d.configTableFieldRowCol }} layui-form-item module1 js_module_{{ d.configTableFieldId }}" id="{{ d.configTableFieldId }}" >
|
||||
<div row-col="{{ d.configTableFieldRowCol }}" class="{{ d.configTableFieldRow ? 'clearOut' : '' }} layui-col-lg{{ d.configTableFieldRowCol }} layui-col-md{{ d.configTableFieldRowCol }} layui-col-sm{{ d.configTableFieldRowCol }} layui-form-item module1 js_module_{{ d.configTableFieldId }}" id="{{ d.configTableFieldId }}" >
|
||||
<div >
|
||||
<label class="layui-form-label" >{{ d.configTableFieldName }}{{ d.configTableFieldMust == 1 ? '<span class="mustField">*</span>' : '' }}</label>
|
||||
<div class="layui-input-block">
|
||||
@ -170,7 +150,7 @@
|
||||
</script>
|
||||
|
||||
<script id="type2" type="text/html">
|
||||
<div row-col="{{ d.configTableFieldRowCol }}" class="layui-col-lg{{ d.configTableFieldRowCol }} layui-col-md{{ d.configTableFieldRowCol }} layui-col-sm{{ d.configTableFieldRowCol }} layui-form-text layui-form-item module1 js_module_{{ d.configTableFieldId }}" id="{{ d.configTableFieldId }}" >
|
||||
<div row-col="{{ d.configTableFieldRowCol }}" class="{{ d.configTableFieldRow ? 'clearOut' : '' }} layui-col-lg{{ d.configTableFieldRowCol }} layui-col-md{{ d.configTableFieldRowCol }} layui-col-sm{{ d.configTableFieldRowCol }} layui-form-text layui-form-item module1 js_module_{{ d.configTableFieldId }}" id="{{ d.configTableFieldId }}" >
|
||||
<div >
|
||||
<label class="layui-form-label" >{{ d.configTableFieldName }}{{ d.configTableFieldMust == 1 ? '<span class="mustField">*</span>' : '' }}</label>
|
||||
<div class="layui-input-block">
|
||||
@ -182,7 +162,7 @@
|
||||
</script>
|
||||
|
||||
<script id="type3" type="text/html">
|
||||
<div row-col="{{ d.configTableFieldRowCol }}" class="layui-col-lg{{ d.configTableFieldRowCol }} layui-col-md{{ d.configTableFieldRowCol }} layui-col-sm{{ d.configTableFieldRowCol }} layui-form-text layui-form-item module1 js_module_{{ d.configTableFieldId }}" id="{{ d.configTableFieldId }}" >
|
||||
<div row-col="{{ d.configTableFieldRowCol }}" class="{{ d.configTableFieldRow ? 'clearOut' : '' }} layui-col-lg{{ d.configTableFieldRowCol }} layui-col-md{{ d.configTableFieldRowCol }} layui-col-sm{{ d.configTableFieldRowCol }} layui-form-text layui-form-item module1 js_module_{{ d.configTableFieldId }}" id="{{ d.configTableFieldId }}" >
|
||||
<div >
|
||||
<label class="layui-form-label" >{{ d.configTableFieldName }}{{ d.configTableFieldMust == 1 ? '<span class="mustField">*</span>' : '' }}</label>
|
||||
<div class="layui-input-block">
|
||||
@ -194,7 +174,7 @@
|
||||
</script>
|
||||
|
||||
<script id="type4" type="text/html">
|
||||
<div row-col="{{ d.configTableFieldRowCol }}" class="layui-col-lg{{ d.configTableFieldRowCol }} layui-col-md{{ d.configTableFieldRowCol }} layui-col-sm{{ d.configTableFieldRowCol }} layui-form-text layui-form-item module1 js_module_{{ d.configTableFieldId }}" id="{{ d.configTableFieldId }}" >
|
||||
<div row-col="{{ d.configTableFieldRowCol }}" class="{{ d.configTableFieldRow ? 'clearOut' : '' }} layui-col-lg{{ d.configTableFieldRowCol }} layui-col-md{{ d.configTableFieldRowCol }} layui-col-sm{{ d.configTableFieldRowCol }} layui-form-text layui-form-item module1 js_module_{{ d.configTableFieldId }}" id="{{ d.configTableFieldId }}" >
|
||||
<div >
|
||||
<label class="layui-form-label" >{{ d.configTableFieldName }}{{ d.configTableFieldMust == 1 ? '<span class="mustField">*</span>' : '' }}</label>
|
||||
<div class="layui-input-block">
|
||||
@ -205,8 +185,19 @@
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script id="type7" type="text/html">
|
||||
<div row-col="{{ d.configTableFieldRowCol }}" class="{{ d.configTableFieldRow ? 'clearOut' : '' }} layui-col-lg{{ d.configTableFieldRowCol }} layui-col-md{{ d.configTableFieldRowCol }} layui-col-sm{{ d.configTableFieldRowCol }} layui-form-text layui-form-item module1 js_module_{{ d.configTableFieldId }}" id="{{ d.configTableFieldId }}" >
|
||||
<div >
|
||||
<label class="layui-form-label" >{{ d.configTableFieldName }}{{ d.configTableFieldMust == 1 ? '<span class="mustField">*</span>' : '' }}</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea id="{{ d.configTableFieldCode }}" name="{{ d.configTableFieldCode }}" class="layui-btn-container layui-textarea" placeholder="{{ d.configTableFieldPlaceholder }}"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script id="type8" type="text/html">
|
||||
<div row-col="{{ d.configTableFieldRowCol }}" pane class="layui-col-lg{{ d.configTableFieldRowCol }} layui-col-md{{ d.configTableFieldRowCol }} layui-col-sm{{ d.configTableFieldRowCol }} layui-form-item module1 js_module_{{ d.configTableFieldId }}" id="{{ d.configTableFieldId }}" >
|
||||
<div row-col="{{ d.configTableFieldRowCol }}" pane class="{{ d.configTableFieldRow ? 'clearOut' : '' }} layui-col-lg{{ d.configTableFieldRowCol }} layui-col-md{{ d.configTableFieldRowCol }} layui-col-sm{{ d.configTableFieldRowCol }} layui-form-item module1 js_module_{{ d.configTableFieldId }}" id="{{ d.configTableFieldId }}" >
|
||||
<div >
|
||||
<label class="layui-form-label" >{{ d.configTableFieldName }}{{ d.configTableFieldMust == 1 ? '<span class="mustField">*</span>' : '' }}</label>
|
||||
<div class="layui-input-block layui-form" id="{{ d.configTableFieldCode }}TemplateBox" lay-filter="{{ d.configTableFieldCode }}TemplateBox" ></div>
|
||||
@ -215,7 +206,7 @@
|
||||
</script>
|
||||
|
||||
<script id="type9" type="text/html">
|
||||
<div row-col="{{ d.configTableFieldRowCol }}" class="layui-col-lg{{ d.configTableFieldRowCol }} layui-col-md{{ d.configTableFieldRowCol }} layui-col-sm{{ d.configTableFieldRowCol }} layui-form-item module1 js_module_{{ d.configTableFieldId }}" id="{{ d.configTableFieldId }}" >
|
||||
<div row-col="{{ d.configTableFieldRowCol }}" class="{{ d.configTableFieldRow ? 'clearOut' : '' }} layui-col-lg{{ d.configTableFieldRowCol }} layui-col-md{{ d.configTableFieldRowCol }} layui-col-sm{{ d.configTableFieldRowCol }} layui-form-item module1 js_module_{{ d.configTableFieldId }}" id="{{ d.configTableFieldId }}" >
|
||||
<div class="" pane="" >
|
||||
<label class="layui-form-label" >{{ d.configTableFieldName }}{{ d.configTableFieldMust == 1 ? '<span class="mustField">*</span>' : '' }}</label>
|
||||
<div class="layui-input-block layui-form" id="{{ d.configTableFieldCode }}TemplateBox" lay-filter="{{ d.configTableFieldCode }}TemplateBox" ></div>
|
||||
@ -284,6 +275,7 @@
|
||||
var configTableId = top.restAjax.params(window.location.href).configTableId;
|
||||
var fieldList = [];
|
||||
|
||||
// 通过ID获取某个字段对象
|
||||
function getField(fieldId) {
|
||||
for(var i = 0 ; i < fieldList.length ; i++ ) {
|
||||
if(fieldId == fieldList[i].configTableFieldId) {
|
||||
@ -302,7 +294,9 @@
|
||||
/**
|
||||
* 保存宽度比 / 保存排序 / 保存行
|
||||
*/
|
||||
orderArray.push({"configTableFieldId": e.id , "configTableFieldRowCol": Number($(e).data("configTableFieldRowCol")) , "configTableFieldOrder" : v + 1 })
|
||||
var order = {"configTableFieldId": e.id , "configTableFieldRowCol": $(e).attr("row-col") , "configTableFieldOrder" : v + 1 , "configTableFieldRow" : $(e).hasClass("clearOut")};
|
||||
console.log(order);
|
||||
orderArray.push(order);
|
||||
});
|
||||
var loadLayerIndex;
|
||||
top.restAjax.put(top.restAjax.path('api/configtablefield/updateorder/{configTableId}/{createPage}', [configTableId, 'notCreate']), orderArray, null, function(code, data) {
|
||||
@ -322,7 +316,10 @@
|
||||
/**
|
||||
* 保存宽度比 / 保存排序 / 保存行
|
||||
*/
|
||||
orderArray.push({"configTableFieldId": e.id , "configTableFieldRowCol": Number($(e).data("configTableFieldRowCol")) , "configTableFieldOrder" : v + 1 })
|
||||
console.log(e);
|
||||
var order = {"configTableFieldId": e.id , "configTableFieldRowCol": $(e).attr("row-col") , "configTableFieldOrder" : v + 1 , "configTableFieldRow" : $(e).hasClass("clearOut")};
|
||||
console.log(order);
|
||||
orderArray.push(order);
|
||||
});
|
||||
var loadLayerIndex;
|
||||
top.restAjax.put(top.restAjax.path('api/configtablefield/updateorder/{configTableId}/{createPage}', [configTableId, 'createSave']), orderArray, null, function(code, data) {
|
||||
@ -344,13 +341,14 @@
|
||||
return rgb;
|
||||
}
|
||||
|
||||
// 改变宽度
|
||||
function widthChange(data) {
|
||||
slider.render({
|
||||
elem: '#widthChangeDiv'
|
||||
,setTips: function(value){ //自定义提示文本
|
||||
return value ;
|
||||
},
|
||||
value:$("#" + data.configTableFieldId).data("rowCol"),
|
||||
value:$("#" + data.configTableFieldId).attr("row-col"),
|
||||
min:1,
|
||||
max:12,
|
||||
change: function(value){
|
||||
@ -362,26 +360,12 @@
|
||||
$("#" + data.configTableFieldId).addClass("layui-col-lg" + value);
|
||||
$("#" + data.configTableFieldId).addClass("layui-col-md" + value);
|
||||
$("#" + data.configTableFieldId).addClass("layui-col-sm" + value);
|
||||
$("#" + data.configTableFieldId).data("rowCol", value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addItem() {
|
||||
top.layer.open({
|
||||
type: 2,
|
||||
title: false,
|
||||
closeBtn: 0,
|
||||
area: ['800px', '95%'],
|
||||
shadeClose: true,
|
||||
anim: 2,
|
||||
content: top.restAjax.path('route/columnmngitem/save.html?columnId=' + columnId, []),
|
||||
end: function() {
|
||||
initData();
|
||||
$("#" + data.configTableFieldId).attr("row-col", value + "");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 初始化文件上传
|
||||
function initFile(data) {
|
||||
var template = "fileTemplate";
|
||||
laytpl(document.getElementById(template).innerHTML).render(data, function (html) {
|
||||
@ -390,6 +374,7 @@
|
||||
form.render(null, "dataForm");
|
||||
}
|
||||
|
||||
// 初始化数据字典下拉框
|
||||
function initDictionaries(data) {
|
||||
// 单选下拉框
|
||||
var template = "";
|
||||
@ -417,6 +402,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
// 创建字段区域块
|
||||
function createDiv(data) {
|
||||
var type = data.configTableFieldType;
|
||||
var div = "";
|
||||
@ -445,6 +431,12 @@
|
||||
div = html;
|
||||
});
|
||||
break;
|
||||
<!-- 多行文本框 -->
|
||||
case "7":
|
||||
laytpl(document.getElementById("type7").innerHTML).render(data, function (html) {
|
||||
div = html;
|
||||
});
|
||||
break;
|
||||
<!-- 单选框 -->
|
||||
case "8":
|
||||
laytpl(document.getElementById("type8").innerHTML).render(data, function (html) {
|
||||
@ -478,6 +470,29 @@
|
||||
});
|
||||
},iconfont:'fa-arrows-h'},
|
||||
{text:'合并', value:data.configTableFieldId, callback:function(data){
|
||||
// 开启合并
|
||||
if(!$("#" + data.value).hasClass("clearOut")) {
|
||||
/**
|
||||
* 找到上一个同级节点
|
||||
*/
|
||||
var prevArray = $("#" + data.value).prevAll(".module1");
|
||||
if(prevArray.length < 1) {
|
||||
top.layer.msg("当前是第一个");
|
||||
return;
|
||||
}
|
||||
var rowColSize = Number($("#" + data.value).attr("row-col"));
|
||||
for(var i = 0 ; i < prevArray.length; i++) {
|
||||
var rowCol = Number($(prevArray[i]).attr("row-col"));
|
||||
rowColSize = rowColSize + rowCol;
|
||||
if(!$(prevArray[i]).hasClass("clearOut")) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(rowColSize > 12) {
|
||||
top.layer.msg("宽度超出无法合并");
|
||||
return;
|
||||
}
|
||||
}
|
||||
$("#" + data.value).toggleClass("clearOut");
|
||||
},iconfont:'fa-cube'}
|
||||
],
|
||||
@ -509,7 +524,6 @@
|
||||
console.log(evt);
|
||||
console.log(evt.item);
|
||||
console.log(evt.nextSibling);
|
||||
|
||||
}
|
||||
});
|
||||
form.render(null, 'dataForm');
|
||||
|
Loading…
Reference in New Issue
Block a user