完善动态表单联表功能

This commit is contained in:
wenc000 2020-01-29 00:08:31 +08:00
parent 39ba55149e
commit f4cb139f8d
8 changed files with 448 additions and 101 deletions

View File

@ -33,6 +33,12 @@ public class DynamicFormFormShowFieldDTO {
private String verifyType;
@ApiModelProperty(name = "verifyRegular", value = "校验正则")
private String verifyRegular;
@ApiModelProperty(name = "joinTable", value = "联表表名")
private String joinTable;
@ApiModelProperty(name = "joinTableField", value = "联表字段")
private String joinTableField;
@ApiModelProperty(name = "joinTableFormShow", value = "联表显示字段")
private String joinTableFormShow;
public String getFieldName() {
return fieldName == null ? "" : fieldName.trim();
@ -90,6 +96,30 @@ public class DynamicFormFormShowFieldDTO {
this.verifyRegular = verifyRegular;
}
public String getJoinTable() {
return joinTable == null ? "" : joinTable.trim();
}
public void setJoinTable(String joinTable) {
this.joinTable = joinTable;
}
public String getJoinTableField() {
return joinTableField == null ? "" : joinTableField.trim();
}
public void setJoinTableField(String joinTableField) {
this.joinTableField = joinTableField;
}
public String getJoinTableFormShow() {
return joinTableFormShow == null ? "" : joinTableFormShow.trim();
}
public void setJoinTableFormShow(String joinTableFormShow) {
this.joinTableFormShow = joinTableFormShow;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("{");
@ -107,6 +137,12 @@ public class DynamicFormFormShowFieldDTO {
.append("\"").append(verifyType).append("\"");
sb.append(",\"verifyRegular\":")
.append("\"").append(verifyRegular).append("\"");
sb.append(",\"joinTable\":")
.append("\"").append(joinTable).append("\"");
sb.append(",\"joinTableField\":")
.append("\"").append(joinTableField).append("\"");
sb.append(",\"joinTableFormShow\":")
.append("\"").append(joinTableFormShow).append("\"");
sb.append('}');
return sb.toString();
}

View File

@ -113,16 +113,11 @@ public class DynamicFormServiceImpl extends AbstractService implements IDynamicF
public List<DynamicFormFormShowFieldDTO> listFormShowFieldOfPage(String tableName) throws SearchException {
List<DynamicFormDTO> dynamicFormDTOs = listDynamicForm(tableName);
List<DynamicFormFormShowFieldDTO> dynamicFormFormShowFieldDTOList = new ArrayList<>();
int joinIndex = 0;
for (DynamicFormDTO dynamicFormDTO : dynamicFormDTOs) {
// 显示字段
if (dynamicFormDTO.getFormShow() == 1) {
dynamicFormFormShowFieldDTOList.add(getDynamicFormFormShowFieldDTOByDynamicFormDTO(dynamicFormDTO));
}
// 联表字段
if (isJoinDynamicField(dynamicFormDTO)) {
dynamicFormFormShowFieldDTOList.addAll(listJoinDynamicFormFormShowField(dynamicFormDTO, ++joinIndex));
}
}
return dynamicFormFormShowFieldDTOList;
}
@ -137,38 +132,18 @@ public class DynamicFormServiceImpl extends AbstractService implements IDynamicF
private List<DynamicFormListShowFieldDTO> listJoinDynamicFormListShowField(DynamicFormDTO dynamicFormDTO, int index) {
List<DynamicFormListShowFieldDTO> dynamicFormListShowFieldDTOList = new ArrayList<>();
Map<String, Object> params = getHashMap(2);
params.put("tableName", WStringUtil.firstToLower(dynamicFormDTO.getJoinTable().replaceFirst("dynamic", "")));
params.put("tableName", dynamicFormDTO.getJoinTable());
params.put("fieldNameList", Arrays.asList(dynamicFormDTO.getJoinTableListShow().split(",")));
List<DynamicFormDTO> joinDynamicFormDTOs = dynamicFormDao.listDynamicForm(params);
for (DynamicFormDTO joinDynamicFormDTO : joinDynamicFormDTOs) {
DynamicFormListShowFieldDTO dynamicFormListShowFieldDTO = getDynamicFormListShowFieldDTOByDynamicFormDTO(joinDynamicFormDTO);
dynamicFormListShowFieldDTO.setFieldName(String.format("%sJt%d", dynamicFormListShowFieldDTO.getFieldName(), index));
dynamicFormListShowFieldDTO.setFieldExplain(String.format("%s%d", dynamicFormListShowFieldDTO.getFieldExplain(), index));
dynamicFormListShowFieldDTOList.add(dynamicFormListShowFieldDTO);
}
return dynamicFormListShowFieldDTOList;
}
/**
* 设置动态表单列表 联表 表单显示字段
*
* @param dynamicFormDTO
* @param index 下标
* @return
*/
private List<DynamicFormFormShowFieldDTO> listJoinDynamicFormFormShowField(DynamicFormDTO dynamicFormDTO, int index) {
List<DynamicFormFormShowFieldDTO> dynamicFormFormShowFieldDTOList = new ArrayList<>();
Map<String, Object> params = getHashMap(2);
params.put("tableName", WStringUtil.firstToLower(dynamicFormDTO.getJoinTable().replaceFirst("dynamic", "")));
params.put("fieldNameList", Arrays.asList(dynamicFormDTO.getJoinTableListShow().split(",")));
List<DynamicFormDTO> joinDynamicFormDTOs = dynamicFormDao.listDynamicForm(params);
for (DynamicFormDTO joinDynamicFormDTO : joinDynamicFormDTOs) {
DynamicFormFormShowFieldDTO dynamicFormFormShowFieldDTO = getDynamicFormFormShowFieldDTOByDynamicFormDTO(joinDynamicFormDTO);
dynamicFormFormShowFieldDTO.setFieldName(String.format("%sJt%d", dynamicFormFormShowFieldDTO.getFieldName(), index));
dynamicFormFormShowFieldDTOList.add(dynamicFormFormShowFieldDTO);
}
return dynamicFormFormShowFieldDTOList;
}
/**
* 设置动态表单的列表字段
*
@ -198,6 +173,9 @@ public class DynamicFormServiceImpl extends AbstractService implements IDynamicF
dynamicFormFormShowFieldDTO.setFieldType(dynamicFormDTO.getFieldType());
dynamicFormFormShowFieldDTO.setVerifyType(dynamicFormDTO.getVerifyType());
dynamicFormFormShowFieldDTO.setVerifyRegular(dynamicFormDTO.getVerifyRegular());
dynamicFormFormShowFieldDTO.setJoinTable(dynamicFormDTO.getJoinTable());
dynamicFormFormShowFieldDTO.setJoinTableField(dynamicFormDTO.getJoinTableField());
dynamicFormFormShowFieldDTO.setJoinTableFormShow(dynamicFormDTO.getJoinTableFormShow());
return dynamicFormFormShowFieldDTO;
}
@ -210,7 +188,7 @@ public class DynamicFormServiceImpl extends AbstractService implements IDynamicF
Map<String, Object> listShow = new HashMap<>(2);
listShow.put("fieldType", dynamicFormDTO.getFieldType());
listShow.put("fieldName", WStringUtil.lowerUpper2UnderLine(dynamicFormDTO.getFieldName()));
listShow.put("joinTable", WStringUtil.lowerUpper2UnderLine(dynamicFormDTO.getJoinTable()));
listShow.put("joinTable", String.format("%s%s", IDynamicTableService.DYNAMIC_TABLE_PREFIX, WStringUtil.lowerUpper2UnderLine(dynamicFormDTO.getJoinTable())));
listShow.put("joinTableField", WStringUtil.lowerUpper2UnderLine(dynamicFormDTO.getJoinTableField()));
listShow.put("joinTableSort", dynamicFormDTO.getJoinTableSort());
// 构建连表显示字段

View File

@ -77,26 +77,27 @@
<!-- 动态数据列表 -->
<select id="listDynamicData" parameterType="map" resultType="map">
SELECT
<foreach collection="listShowFieldList" item="item" open="" separator="," close="">
t1.${item.fieldName}
</foreach>
<foreach collection="listShowFieldList" index="index" item="item" open="," separator="" close="">
<foreach collection="listShowFieldList" index="index" item="item" open="" separator="" close="">
t1.${item.fieldName},
<if test="item.fieldType == 'radio' or item.fieldType == 'checkbox' or item.fieldType == 'select'">
GROUP_CONCAT(dt${index + 1}.dictionary_name) ${item.fieldName}_dictionary_name,
</if>
</foreach>
<!-- 主表字典表字段 start -->
<if test="listJoinTableField != null and listJoinTableField.size > 0">
<foreach collection="listJoinTableField" index="index" item="item" open="" separator="" close="">
<if test="item.joinTableListShow != null and item.joinTableListShow.size > 0" >
<foreach collection="item.joinTableListShow" index="joinIndex" item="item" open="" separator="" close="">
jt${index + 1}.${item} ${item}_jt${index + 1},
<foreach collection="item.joinTableListShow" index="joinIndex" item="joinItem" open="" separator="" close="">
jt${index + 1}.${joinItem} ${joinItem}_jt${index + 1},
</foreach>
</if>
</foreach>
</if>
<!-- 主表字典表字段 end -->
t1.${uuidField}
FROM
${tableName} t1
<!-- 主表字典表 start -->
<foreach collection="listShowFieldList" index="index" item="item" open="" separator="" close="">
<if test="item.fieldType == 'radio' or item.fieldType == 'checkbox' or item.fieldType == 'select'">
LEFT JOIN
@ -107,6 +108,8 @@
dt${index + 1}.is_delete = 0
</if>
</foreach>
<!-- 主表字典表 end -->
<!-- 联表字段 start -->
<if test="listJoinTableField != null and listJoinTableField.size > 0">
<foreach collection="listJoinTableField" index="index" item="item" open="" separator="" close="">
<if test="item.fieldType == 'leftJoin'">
@ -125,6 +128,7 @@
jt${index + 1}.is_delete = 0
</foreach>
</if>
<!-- 联表字段 end -->
WHERE
t1.is_delete = 0
GROUP BY

View File

@ -77,31 +77,33 @@
<div class="layui-form-item">
<label class="layui-form-label">关联表</label>
<div class="layui-input-block">
<input type="text" name="joinTable" placeholder="请选择关联表" class="layui-input">
<input type="text" id="joinTable" name="joinTable" placeholder="请选择关联表" class="layui-input" readonly style="cursor: pointer;">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">关联字段</label>
<div class="layui-input-block">
<input type="text" name="joinTableField" placeholder="请输入关联字段" class="layui-input">
<div id="joinFieldDetailBox" style="display: none;">
<div class="layui-form-item">
<label class="layui-form-label">关联字段</label>
<div class="layui-input-block">
<input type="text" id="joinTableField" name="joinTableField" placeholder="请输入关联字段" class="layui-input" readonly style="cursor: pointer;">
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">关联顺序</label>
<div class="layui-input-block">
<input type="number" name="joinTableSort" placeholder="请输入关联顺序" class="layui-input">
<div class="layui-form-item">
<label class="layui-form-label">关联顺序</label>
<div class="layui-input-block">
<input type="number" name="joinTableSort" placeholder="请输入关联顺序" class="layui-input" value="1">
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">连表列表</label>
<div class="layui-input-block">
<input type="text" name="joinTableListShow" placeholder="请输入连表列表显示" class="layui-input">
<div class="layui-form-item">
<label class="layui-form-label">列表显示</label>
<div class="layui-input-block">
<input type="text" id="joinTableListShow" name="joinTableListShow" placeholder="请选择关联表需要在列表中显示的字段,不包括被关联表中的关联字段" class="layui-input" readonly style="cursor: pointer;">
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">连表表单</label>
<div class="layui-input-block">
<input type="text" name="joinTableFormShow" placeholder="请输入连表表单显示" class="layui-input">
<div class="layui-form-item">
<label class="layui-form-label">表单显示</label>
<div class="layui-input-block">
<input type="text" id="joinTableFormShow" name="joinTableFormShow" placeholder="请选择关联表需要在表单中回显的字段,不包括被关联表中的关联字段" class="layui-input" readonly style="cursor: pointer;">
</div>
</div>
</div>
</div>
@ -141,19 +143,19 @@
<input type="text" name="verifyRegular" placeholder="请输入校验正则" class="layui-input">
</div>
</div>
<div class="layui-form-item" pane>
<label class="layui-form-label">列表显示 *</label>
<div class="layui-input-block">
<input type="radio" name="listShow" value="0" title="关闭">
<input type="radio" name="listShow" value="1" title="开启" checked>
</div>
</div>
<div class="layui-form-item" pane>
<label class="layui-form-label">列表显示 *</label>
<div class="layui-input-block">
<input type="radio" name="listShow" value="0" title="关闭">
<input type="radio" name="listShow" value="1" title="开启" checked>
</div>
<div class="layui-form-item" pane>
<label class="layui-form-label">表单显示 *</label>
<div class="layui-input-block">
<input type="radio" name="formShow" value="0" title="关闭">
<input type="radio" name="formShow" value="1" title="开启" checked>
</div>
</div>
<div class="layui-form-item" pane>
<label class="layui-form-label">表单显示 *</label>
<div class="layui-input-block">
<input type="radio" name="formShow" value="0" title="关闭">
<input type="radio" name="formShow" value="1" title="开启" checked>
</div>
</div>
<div class="layui-form-item">
@ -187,7 +189,9 @@
parent.layer.close(parent.layer.getFrameIndex(window.name));
}
// 初始化
function initData() {}
function initData() {
}
initData();
// 提交表单
@ -269,6 +273,125 @@
}
});
});
// 选择联表
$(document.body).on('click', '#joinTable', function() {
var joinTable = $('#joinTable').val();
top.dialog.tree({
title: '选择关联表',
apiUri: top.restAjax.path('api/dynamicconfigtable/listtable', []),
width: '250px',
height: '400px',
dataFilter: function(treeId, parentNode, childNodes) {
for(var i = 0, item = childNodes[i]; item = childNodes[i++];) {
item.name = item.tableName;
item.id = item.tableName;
item.title = item.tableName;
}
return childNodes;
},
selectedNodes: [{
id: joinTable,
name: joinTable,
title: joinTable
}],
onClose: function() {
var selectNodes = top.dialog.dialogTreeData.selectedNodes;
if(typeof(selectNodes) != 'undefined' && selectNodes != null) {
if(selectNodes.length > 0) {
$('#joinTable').val(selectNodes[0].id);
$('#joinTableField').val(selectNodes[0].id +'Id');
$('#joinFieldDetailBox').show();
} else {
$('#joinTable').val('');
$('#joinTableField').val('');
$('#joinFieldDetailBox').hide();
}
}
}
});
});
/**
* 选择字段
* @param isList 是否列表
*/
function selectJoinField(isList) {
var check = null;
var selectedNodes = [];
if(isList) {
check = {
enable: true,
selectType: 'checkbox',
checkboxType: {Y: 'ps', N: 'ps'},
radioType: 'level',
}
var joinTableListShow = $('#joinTableListShow').val();
if(joinTableListShow) {
var joinTableListShowArray = joinTableListShow.split(',');
for(var i = 0, item; item = joinTableListShowArray[i++];) {
selectedNodes.push({
id: item,
name: item,
title: item
})
}
}
} else {
var joinTableFormShow = $('#joinTableFormShow').val();
selectedNodes.push({
id: joinTableFormShow,
name: joinTableFormShow,
title: joinTableFormShow
});
}
top.dialog.tree({
title: '选择联表显示字段',
apiUri: top.restAjax.path('api/dynamicconfigtable/dynamicconfigform/listform/{tableName}', [$('#joinTable').val()]),
width: '250px',
height: '400px',
dataFilter: function(treeId, parentNode, childNodes) {
for(var i = 0, item = childNodes[i]; item = childNodes[i++];) {
item.name = item.fieldName;
item.id = item.fieldName;
item.title = item.fieldName;
}
return childNodes;
},
check: check,
selectedNodes: selectedNodes,
onClose: function() {
var selectNodes = top.dialog.dialogTreeData.selectedNodes;
if(typeof(selectNodes) != 'undefined' && selectNodes != null) {
if(selectNodes.length > 0) {
var selectNodeValue = '';
for(var j = 0, selectNode = selectNodes[j]; selectNode = selectNodes[j++];) {
if(selectNodeValue.length > 0) {
selectNodeValue += ',';
}
selectNodeValue += selectNode.id;
}
if(isList) {
$('#joinTableListShow').val(selectNodeValue);
} else {
$('#joinTableFormShow').val(selectNodeValue);
}
} else {
if(isList) {
$('#joinTableListShow').val('');
} else {
$('#joinTableFormShow').val('');
}
}
}
}
});
}
$(document.body).on('click', '#joinTableListShow', function() {
selectJoinField(true);
});
$(document.body).on('click', '#joinTableFormShow', function() {
selectJoinField(false);
});
$('.close').on('click', function() {
closeBox();
});

View File

@ -77,31 +77,33 @@
<div class="layui-form-item">
<label class="layui-form-label">关联表</label>
<div class="layui-input-block">
<input type="text" name="joinTable" placeholder="请选择关联表" class="layui-input">
<input type="text" id="joinTable" name="joinTable" placeholder="请选择关联表" class="layui-input" readonly style="cursor: pointer;">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">关联字段</label>
<div class="layui-input-block">
<input type="text" name="joinTableField" placeholder="请输入关联字段" class="layui-input">
<div id="joinFieldDetailBox" style="display: none;">
<div class="layui-form-item">
<label class="layui-form-label">关联字段</label>
<div class="layui-input-block">
<input type="text" id="joinTableField" name="joinTableField" placeholder="请输入关联字段" class="layui-input" readonly style="cursor: pointer;">
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">关联顺序</label>
<div class="layui-input-block">
<input type="number" name="joinTableSort" placeholder="请输入关联顺序" class="layui-input">
<div class="layui-form-item">
<label class="layui-form-label">关联顺序</label>
<div class="layui-input-block">
<input type="number" name="joinTableSort" placeholder="请输入关联顺序" class="layui-input" value="1">
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">连表列表</label>
<div class="layui-input-block">
<input type="text" name="joinTableListShow" placeholder="请输入连表列表显示" class="layui-input">
<div class="layui-form-item">
<label class="layui-form-label">列表显示</label>
<div class="layui-input-block">
<input type="text" id="joinTableListShow" name="joinTableListShow" placeholder="请选择关联表需要在列表中显示的字段,不包括被关联表中的关联字段" class="layui-input" readonly style="cursor: pointer;">
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">连表表单</label>
<div class="layui-input-block">
<input type="text" name="joinTableFormShow" placeholder="请输入连表表单显示" class="layui-input">
<div class="layui-form-item">
<label class="layui-form-label">表单显示</label>
<div class="layui-input-block">
<input type="text" id="joinTableFormShow" name="joinTableFormShow" placeholder="请选择关联表需要在表单中回显的字段,不包括被关联表中的关联字段" class="layui-input" readonly style="cursor: pointer;">
</div>
</div>
</div>
</div>
@ -141,19 +143,19 @@
<input type="text" name="verifyRegular" placeholder="请输入校验正则" class="layui-input">
</div>
</div>
<div class="layui-form-item" pane>
<label class="layui-form-label">列表显示 *</label>
<div class="layui-input-block">
<input type="radio" name="listShow" value="0" title="关闭">
<input type="radio" name="listShow" value="1" title="开启" checked>
</div>
</div>
<div class="layui-form-item" pane>
<label class="layui-form-label">列表显示 *</label>
<div class="layui-input-block">
<input type="radio" name="listShow" value="0" title="关闭">
<input type="radio" name="listShow" value="1" title="开启" checked>
</div>
<div class="layui-form-item" pane>
<label class="layui-form-label">表单显示 *</label>
<div class="layui-input-block">
<input type="radio" name="formShow" value="0" title="关闭">
<input type="radio" name="formShow" value="1" title="开启" checked>
</div>
</div>
<div class="layui-form-item" pane>
<label class="layui-form-label">表单显示 *</label>
<div class="layui-input-block">
<input type="radio" name="formShow" value="0" title="关闭">
<input type="radio" name="formShow" value="1" title="开启" checked>
</div>
</div>
<div class="layui-form-item">
@ -203,8 +205,8 @@
verifyType: data.verifyType,
verifyRegular: data.verifyRegular,
fieldSort: data.fieldSort,
listShow: data.listShow,
formShow: data.formShow,
listShow: data.listShow.toString(),
formShow: data.formShow.toString(),
joinTable: data.joinTable,
joinTableField: data.joinTableField,
joinTableSort: data.joinTableSort,
@ -215,6 +217,9 @@
if(data.fieldType === 'leftJoin' || data.fieldType === 'innerJoin' || data.fieldType === 'rightJoin') {
$('#normalFieldBox').hide();
$('#joinFieldBox').show();
if($('#joinTable').val()) {
$('#joinFieldDetailBox').show();
}
} else {
$('#joinFieldBox').hide();
$('#normalFieldBox').show();
@ -308,6 +313,125 @@
}
});
});
// 选择联表
$(document.body).on('click', '#joinTable', function() {
var joinTable = $('#joinTable').val();
top.dialog.tree({
title: '选择关联表',
apiUri: top.restAjax.path('api/dynamicconfigtable/listtable', []),
width: '250px',
height: '400px',
dataFilter: function(treeId, parentNode, childNodes) {
for(var i = 0, item = childNodes[i]; item = childNodes[i++];) {
item.name = item.tableName;
item.id = item.tableName;
item.title = item.tableName;
}
return childNodes;
},
selectedNodes: [{
id: joinTable,
name: joinTable,
title: joinTable
}],
onClose: function() {
var selectNodes = top.dialog.dialogTreeData.selectedNodes;
if(typeof(selectNodes) != 'undefined' && selectNodes != null) {
if(selectNodes.length > 0) {
$('#joinTable').val(selectNodes[0].id);
$('#joinTableField').val(selectNodes[0].id +'Id');
$('#joinFieldDetailBox').show();
} else {
$('#joinTable').val('');
$('#joinTableField').val('');
$('#joinFieldDetailBox').hide();
}
}
}
});
});
/**
* 选择字段
* @param isList 是否列表
*/
function selectJoinField(isList) {
var check = null;
var selectedNodes = [];
if(isList) {
check = {
enable: true,
selectType: 'checkbox',
checkboxType: {Y: 'ps', N: 'ps'},
radioType: 'level',
}
var joinTableListShow = $('#joinTableListShow').val();
if(joinTableListShow) {
var joinTableListShowArray = joinTableListShow.split(',');
for(var i = 0, item; item = joinTableListShowArray[i++];) {
selectedNodes.push({
id: item,
name: item,
title: item
})
}
}
} else {
var joinTableFormShow = $('#joinTableFormShow').val();
selectedNodes.push({
id: joinTableFormShow,
name: joinTableFormShow,
title: joinTableFormShow
});
}
top.dialog.tree({
title: '选择联表显示字段',
apiUri: top.restAjax.path('api/dynamicconfigtable/dynamicconfigform/listform/{tableName}', [$('#joinTable').val()]),
width: '250px',
height: '400px',
dataFilter: function(treeId, parentNode, childNodes) {
for(var i = 0, item = childNodes[i]; item = childNodes[i++];) {
item.name = item.fieldName;
item.id = item.fieldName;
item.title = item.fieldName;
}
return childNodes;
},
check: check,
selectedNodes: selectedNodes,
onClose: function() {
var selectNodes = top.dialog.dialogTreeData.selectedNodes;
if(typeof(selectNodes) != 'undefined' && selectNodes != null) {
if(selectNodes.length > 0) {
var selectNodeValue = '';
for(var j = 0, selectNode = selectNodes[j]; selectNode = selectNodes[j++];) {
if(selectNodeValue.length > 0) {
selectNodeValue += ',';
}
selectNodeValue += selectNode.id;
}
if(isList) {
$('#joinTableListShow').val(selectNodeValue);
} else {
$('#joinTableFormShow').val(selectNodeValue);
}
} else {
if(isList) {
$('#joinTableListShow').val('');
} else {
$('#joinTableFormShow').val('');
}
}
}
}
});
}
$(document.body).on('click', '#joinTableListShow', function() {
selectJoinField(true);
});
$(document.body).on('click', '#joinTableFormShow', function() {
selectJoinField(false);
});
$('.close').on('click', function() {
closeBox();
});

View File

@ -106,6 +106,7 @@
</script>
</div>
</div>
<!--/* 选择人员 */-->
<div class="layui-form-item" th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'selectUser'}">
<label class="layui-form-label" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></label>
<div class="layui-input-block">
@ -113,6 +114,7 @@
<input type="text" th:id="${dynamicFormFormShowFieldDTO.fieldName +'SelectUser'}" class="layui-input" th:placeholder="${'请选择'+ dynamicFormFormShowFieldDTO.fieldExplain}" th:attr="data-name=${dynamicFormFormShowFieldDTO.fieldName}" readonly style="cursor:pointer;">
</div>
</div>
<!--/* 选择部门 */-->
<div class="layui-form-item" th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'selectDepartment'}">
<label class="layui-form-label" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></label>
<div class="layui-input-block">
@ -120,6 +122,19 @@
<input type="text" th:id="${dynamicFormFormShowFieldDTO.fieldName +'SelectDepartment'}" class="layui-input" th:placeholder="${'请选择'+ dynamicFormFormShowFieldDTO.fieldExplain}" th:attr="data-name=${dynamicFormFormShowFieldDTO.fieldName}" readonly style="cursor:pointer;">
</div>
</div>
<!--/* 选择联表 */-->
<div class="layui-form-item" th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'leftJoin' or dynamicFormFormShowFieldDTO.fieldType eq 'innerJoin' or dynamicFormFormShowFieldDTO.fieldType eq 'rightJoin'}">
<label class="layui-form-label" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></label>
<div class="layui-input-block layui-form" th:id="${dynamicFormFormShowFieldDTO.fieldName} +'TemplateBox'" th:attr="lay-filter=${dynamicFormFormShowFieldDTO.fieldName} +'TemplateBox'"></div>
<script th:id="${dynamicFormFormShowFieldDTO.fieldName} +'Template'" type="text/html">
<select th:name="${dynamicFormFormShowFieldDTO.fieldName}">
<option value="" th:text="'选择'+ ${dynamicFormFormShowFieldDTO.fieldExplain}"></option>
{{# for(var i = 0, item; item = d[i++];) { }}
<option th:value="'{{item.'+ ${dynamicFormFormShowFieldDTO.joinTable} +'Id}}'" th:text="'{{item.'+ ${dynamicFormFormShowFieldDTO.joinTableFormShow} +'}}'"></option>
{{# } }}
</select>
</script>
</div>
</div>
<div class="layui-form-item layui-layout-admin">
@ -343,6 +358,15 @@
}
});
});
} else if(item.fieldType === 'leftJoin' || item.fieldType === 'innerJoin' || item.fieldType === 'rightJoin') {
top.restAjax.get(top.restAjax.path('api/dynamicdata/listdynamicdata/{tableName}', [item.joinTable]), {}, {fieldName: item.fieldName}, function(code, data, args) {
laytpl(document.getElementById(args.fieldName +'Template').innerHTML).render(data, function(html) {
document.getElementById(args.fieldName +'TemplateBox').innerHTML = html;
});
form.render('select', args.fieldName +'TemplateBox');
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
}
}

View File

@ -106,6 +106,7 @@
</script>
</div>
</div>
<!--/* 选择人员 */-->
<div class="layui-form-item" th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'selectUser'}">
<label class="layui-form-label" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></label>
<div class="layui-input-block">
@ -113,6 +114,7 @@
<input type="text" th:id="${dynamicFormFormShowFieldDTO.fieldName +'SelectUser'}" class="layui-input" th:placeholder="${'请选择'+ dynamicFormFormShowFieldDTO.fieldExplain}" th:attr="data-name=${dynamicFormFormShowFieldDTO.fieldName}" readonly style="cursor:pointer;">
</div>
</div>
<!--/* 选择部门 */-->
<div class="layui-form-item" th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'selectDepartment'}">
<label class="layui-form-label" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></label>
<div class="layui-input-block">
@ -120,6 +122,19 @@
<input type="text" th:id="${dynamicFormFormShowFieldDTO.fieldName +'SelectDepartment'}" class="layui-input" th:placeholder="${'请选择'+ dynamicFormFormShowFieldDTO.fieldExplain}" th:attr="data-name=${dynamicFormFormShowFieldDTO.fieldName}" readonly style="cursor:pointer;">
</div>
</div>
<!--/* 选择联表 */-->
<div class="layui-form-item" th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'leftJoin' or dynamicFormFormShowFieldDTO.fieldType eq 'innerJoin' or dynamicFormFormShowFieldDTO.fieldType eq 'rightJoin'}">
<label class="layui-form-label" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></label>
<div class="layui-input-block layui-form" th:id="${dynamicFormFormShowFieldDTO.fieldName} +'TemplateBox'" th:attr="lay-filter=${dynamicFormFormShowFieldDTO.fieldName} +'TemplateBox'"></div>
<script th:id="${dynamicFormFormShowFieldDTO.fieldName} +'Template'" type="text/html">
<select th:name="${dynamicFormFormShowFieldDTO.fieldName}">
<option value="" th:text="'选择'+ ${dynamicFormFormShowFieldDTO.fieldExplain}"></option>
{{# for(var i = 0, item; item = d[i++];) { }}
<option th:value="'{{item.'+ ${dynamicFormFormShowFieldDTO.joinTable} +'Id}}'" th:text="'{{item.'+ ${dynamicFormFormShowFieldDTO.joinTableFormShow} +'}}'"></option>
{{# } }}
</select>
</script>
</div>
</div>
<div class="layui-form-item layui-layout-admin">
@ -398,6 +413,20 @@
}
});
});
} else if(item.fieldType === 'leftJoin' || item.fieldType === 'innerJoin' || item.fieldType === 'rightJoin') {
top.restAjax.get(top.restAjax.path('api/dynamicdata/listdynamicdata/{tableName}', [item.joinTable]), {}, {fieldName: item.fieldName}, function(code, data, args) {
laytpl(document.getElementById(args.fieldName +'Template').innerHTML).render(data, function(html) {
document.getElementById(args.fieldName +'TemplateBox').innerHTML = html;
});
// 初始化选择
var formSelectData = {};
formSelectData[args.fieldName] = dataFormData[args.fieldName];
form.val('dataForm', formSelectData);
// 刷新
form.render('select', args.fieldName +'TemplateBox');
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
}
}, function(code, data) {

View File

@ -100,6 +100,7 @@
</script>
</div>
</div>
<!--/* 选择人员 */-->
<div class="layui-form-item" th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'selectUser'}">
<label class="layui-form-label" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></label>
<div class="layui-input-block">
@ -107,6 +108,7 @@
<input type="text" th:id="${dynamicFormFormShowFieldDTO.fieldName +'SelectUser'}" class="layui-input" th:placeholder="${'请选择'+ dynamicFormFormShowFieldDTO.fieldExplain}" th:attr="data-name=${dynamicFormFormShowFieldDTO.fieldName}" readonly style="cursor:pointer;">
</div>
</div>
<!--/* 选择部门 */-->
<div class="layui-form-item" th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'selectDepartment'}">
<label class="layui-form-label" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></label>
<div class="layui-input-block">
@ -114,6 +116,19 @@
<input type="text" th:id="${dynamicFormFormShowFieldDTO.fieldName +'SelectDepartment'}" class="layui-input" th:placeholder="${'请选择'+ dynamicFormFormShowFieldDTO.fieldExplain}" th:attr="data-name=${dynamicFormFormShowFieldDTO.fieldName}" readonly style="cursor:pointer;">
</div>
</div>
<!--/* 选择联表 */-->
<div class="layui-form-item" th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'leftJoin' or dynamicFormFormShowFieldDTO.fieldType eq 'innerJoin' or dynamicFormFormShowFieldDTO.fieldType eq 'rightJoin'}">
<label class="layui-form-label" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></label>
<div class="layui-input-block layui-form" th:id="${dynamicFormFormShowFieldDTO.fieldName} +'TemplateBox'" th:attr="lay-filter=${dynamicFormFormShowFieldDTO.fieldName} +'TemplateBox'"></div>
<script th:id="${dynamicFormFormShowFieldDTO.fieldName} +'Template'" type="text/html">
<select th:name="${dynamicFormFormShowFieldDTO.fieldName}">
<option value="" th:text="'选择'+ ${dynamicFormFormShowFieldDTO.fieldExplain}"></option>
{{# for(var i = 0, item; item = d[i++];) { }}
<option th:value="'{{item.'+ ${dynamicFormFormShowFieldDTO.joinTable} +'Id}}'" th:text="'{{item.'+ ${dynamicFormFormShowFieldDTO.joinTableFormShow} +'}}'"></option>
{{# } }}
</select>
</script>
</div>
</div>
<div class="layui-form-item layui-layout-admin">
@ -397,6 +412,20 @@
}
});
});
} else if(item.fieldType === 'leftJoin' || item.fieldType === 'innerJoin' || item.fieldType === 'rightJoin') {
top.restAjax.get(top.restAjax.path('api/dynamicdata/listdynamicdata/{tableName}', [item.joinTable]), {}, {fieldName: item.fieldName}, function(code, data, args) {
laytpl(document.getElementById(args.fieldName +'Template').innerHTML).render(data, function(html) {
document.getElementById(args.fieldName +'TemplateBox').innerHTML = html;
});
// 初始化选择
var formSelectData = {};
formSelectData[args.fieldName] = dataFormData[args.fieldName];
form.val('dataForm', formSelectData);
// 刷新
form.render('select', args.fieldName +'TemplateBox');
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
}
}, function(code, data) {