新增动态数据新增和列表页面

This commit is contained in:
wenc000 2019-12-05 23:19:02 +08:00
parent 1a4f53fb25
commit 5a660bb4e1
11 changed files with 518 additions and 48 deletions

View File

@ -2,7 +2,10 @@ package com.cm.common.plugin.controller.apis.dynamic.form;
import com.cm.common.base.AbstractController;
import com.cm.common.constants.ISystemConstant;
import com.cm.common.plugin.pojo.dtos.dynamic.DynamicFormFormShowFieldDTO;
import com.cm.common.plugin.pojo.dtos.dynamic.DynamicFormListShowFieldDTO;
import com.cm.common.plugin.service.dynamic.IDynamicDataService;
import com.cm.common.plugin.service.dynamic.IDynamicFormService;
import com.cm.common.pojo.ListPage;
import com.cm.common.result.ErrorResult;
import com.cm.common.result.SuccessResult;
@ -30,6 +33,8 @@ public class DynamicDataController extends AbstractController {
@Autowired
private IDynamicDataService dynamicDataService;
@Autowired
private IDynamicFormService dynamicFormService;
@ApiOperation(value = "保存动态数据", notes = "保存动态数据接口")
@ApiImplicitParams({
@ -97,4 +102,24 @@ public class DynamicDataController extends AbstractController {
return dynamicDataService.getDynamicData(tableName, id);
}
@ApiOperation(value = "列表显示的字段", notes = "列表显示的字段接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "tableName", value = "表名", paramType = "path"),
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listlistshowfieldofpage/{tableName}")
public List<DynamicFormListShowFieldDTO> listListShowFieldOfPage(@PathVariable("tableName") String tableName) {
return dynamicFormService.listListShowFieldOfPage(tableName);
}
@ApiOperation(value = "表单显示的字段", notes = "表单显示的字段接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "tableName", value = "表名", paramType = "path"),
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listformshowfieldofpage/{tableName}")
public List<DynamicFormFormShowFieldDTO> listFormShowFieldOfPage(@PathVariable("tableName") String tableName) {
return dynamicFormService.listFormShowFieldOfPage(tableName);
}
}

View File

@ -3,6 +3,7 @@ package com.cm.common.plugin.controller.apis.dynamic.form;
import com.cm.common.annotation.CheckRequestBodyAnnotation;
import com.cm.common.base.AbstractController;
import com.cm.common.constants.ISystemConstant;
import com.cm.common.plugin.pojo.dtos.dynamic.DynamicFormListShowFieldDTO;
import com.cm.common.plugin.pojo.vos.dynamicform.DynamicFormVO;
import com.cm.common.plugin.service.dynamic.IDynamicFormService;
import com.cm.common.result.ErrorResult;
@ -39,15 +40,4 @@ public class DynamicFormController extends AbstractController {
return dynamicFormService.saveDynamicForm(dynamicFormVO);
}
@ApiOperation(value = "列表显示的字段", notes = "列表显示的字段接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "tableName", value = "表名", paramType = "path"),
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listlistshowfield/{tableName}")
public List<String> listListShowFieldOfPage(@PathVariable("tableName") String tableName) {
// return dynamicFormService.listListShowFieldOfPage(tableName);
}
}

View File

@ -33,6 +33,19 @@ public class DynamicFormRouteController extends AbstractController {
@Autowired
private IDynamicFormService dynamicFormService;
@ApiOperation(value = "动态表单列表页面", notes = "动态表单列表页面接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "tableName", value = "表名", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("savedynamicform/{tableName}")
public ModelAndView saveDynamicForm(@PathVariable("tableName") String tableName) {
ModelAndView mv = new ModelAndView("dynamic/form/savedynamicform");
mv.addObject("tableName", tableName);
mv.addObject("dynamicFormFormShowFieldDTOList", dynamicFormService.listFormShowFieldOfPage(tableName));
return mv;
}
@ApiOperation(value = "动态表单列表页面", notes = "动态表单列表页面接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "tableName", value = "表名", paramType = "path")
@ -40,11 +53,9 @@ public class DynamicFormRouteController extends AbstractController {
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listdynamicform/{tableName}")
public ModelAndView listDynamicForm(@PathVariable("tableName") String tableName) {
ModelAndView mv = new ModelAndView("dynamic/form/list");
List<String> listShowFieldList = dynamicFormService.listListShowField(tableName);
ModelAndView mv = new ModelAndView("dynamic/form/listdynamicform");
mv.addObject("tableName", tableName);
mv.addObject("uuidField", String.format("%sId", tableName));
mv.addObject("listShowFieldList", listShowFieldList);
return mv;
}

View File

@ -0,0 +1,113 @@
package com.cm.common.plugin.pojo.dtos.dynamic;
import com.cm.common.annotation.CheckEmptyAnnotation;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: DynamicFormListShowFieldDTO
* @Description: 动态表单列表显示字段
* @Author: WangGeng
* @Date: 2019/12/5 18:35
* @Version: 1.0
**/
@ApiModel
public class DynamicFormFormShowFieldDTO {
@ApiModelProperty(name = "fieldName", value = "字段名称")
@CheckEmptyAnnotation(name = "字段名称")
private String fieldName;
@ApiModelProperty(name = "fieldExplain", value = "字段说明")
@CheckEmptyAnnotation(name = "字段说明")
private String fieldExplain;
@ApiModelProperty(name = "fieldType", value = "字段类型")
private String fieldType;
@ApiModelProperty(name = "fieldDefault", value = "字段默认值")
private String fieldDefault;
@ApiModelProperty(name = "dictionaryId", value = "字典ID")
private String dictionaryId;
@ApiModelProperty(name = "verifyType", value = "校验类型")
private String verifyType;
@ApiModelProperty(name = "verifyRegular", value = "校验正则")
private String verifyRegular;
public String getFieldName() {
return fieldName == null ? "" : fieldName.trim();
}
public void setFieldName(String fieldName) {
this.fieldName = fieldName;
}
public String getFieldExplain() {
return fieldExplain == null ? "" : fieldExplain.trim();
}
public void setFieldExplain(String fieldExplain) {
this.fieldExplain = fieldExplain;
}
public String getFieldType() {
return fieldType == null ? "" : fieldType.trim();
}
public void setFieldType(String fieldType) {
this.fieldType = fieldType;
}
public String getFieldDefault() {
return fieldDefault == null ? "" : fieldDefault.trim();
}
public void setFieldDefault(String fieldDefault) {
this.fieldDefault = fieldDefault;
}
public String getDictionaryId() {
return dictionaryId == null ? "" : dictionaryId.trim();
}
public void setDictionaryId(String dictionaryId) {
this.dictionaryId = dictionaryId;
}
public String getVerifyType() {
return verifyType == null ? "" : verifyType.trim();
}
public void setVerifyType(String verifyType) {
this.verifyType = verifyType;
}
public String getVerifyRegular() {
return verifyRegular == null ? "" : verifyRegular.trim();
}
public void setVerifyRegular(String verifyRegular) {
this.verifyRegular = verifyRegular;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("{");
sb.append("\"fieldName\":")
.append("\"").append(fieldName).append("\"");
sb.append(",\"fieldExplain\":")
.append("\"").append(fieldExplain).append("\"");
sb.append(",\"fieldType\":")
.append("\"").append(fieldType).append("\"");
sb.append(",\"fieldDefault\":")
.append("\"").append(fieldDefault).append("\"");
sb.append(",\"dictionaryId\":")
.append("\"").append(dictionaryId).append("\"");
sb.append(",\"verifyType\":")
.append("\"").append(verifyType).append("\"");
sb.append(",\"verifyRegular\":")
.append("\"").append(verifyRegular).append("\"");
sb.append('}');
return sb.toString();
}
}

View File

@ -1,5 +1,9 @@
package com.cm.common.plugin.pojo.dtos.dynamic;
import com.cm.common.annotation.CheckEmptyAnnotation;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
@ -10,5 +14,38 @@ package com.cm.common.plugin.pojo.dtos.dynamic;
* @Date: 2019/12/5 18:35
* @Version: 1.0
**/
@ApiModel
public class DynamicFormListShowFieldDTO {
@ApiModelProperty(name = "fieldName", value = "字段名称")
private String fieldName;
@ApiModelProperty(name = "fieldExplain", value = "字段说明")
private String fieldExplain;
public String getFieldName() {
return fieldName == null ? "" : fieldName.trim();
}
public void setFieldName(String fieldName) {
this.fieldName = fieldName;
}
public String getFieldExplain() {
return fieldExplain == null ? "" : fieldExplain.trim();
}
public void setFieldExplain(String fieldExplain) {
this.fieldExplain = fieldExplain;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("{");
sb.append("\"fieldName\":")
.append("\"").append(fieldName).append("\"");
sb.append(",\"fieldExplain\":")
.append("\"").append(fieldExplain).append("\"");
sb.append('}');
return sb.toString();
}
}

View File

@ -4,6 +4,7 @@ import com.cm.common.exception.RemoveException;
import com.cm.common.exception.SaveException;
import com.cm.common.exception.SearchException;
import com.cm.common.exception.UpdateException;
import com.cm.common.plugin.pojo.dtos.dynamic.DynamicFormListShowFieldDTO;
import com.cm.common.pojo.ListPage;
import com.cm.common.result.SuccessResult;
import com.cm.common.result.SuccessResultList;
@ -82,4 +83,5 @@ public interface IDynamicDataService {
* @throws SearchException
*/
Map<String, Object> getDynamicData(String tableName, String id) throws SearchException;
}

View File

@ -3,6 +3,8 @@ package com.cm.common.plugin.service.dynamic;
import com.cm.common.exception.SaveException;
import com.cm.common.exception.SearchException;
import com.cm.common.plugin.pojo.dtos.dynamic.DynamicFormDTO;
import com.cm.common.plugin.pojo.dtos.dynamic.DynamicFormFormShowFieldDTO;
import com.cm.common.plugin.pojo.dtos.dynamic.DynamicFormListShowFieldDTO;
import com.cm.common.plugin.pojo.vos.dynamicform.DynamicFormVO;
import com.cm.common.result.SuccessResult;
@ -56,4 +58,21 @@ public interface IDynamicFormService {
*/
List<String> listFormShowField(String tableName) throws SearchException;
/**
* 列表显示的字段
*
* @param tableName
* @return
* @throws SearchException
*/
List<DynamicFormListShowFieldDTO> listListShowFieldOfPage(String tableName) throws SearchException;
/**
* 表单显示的字段
*
* @param tableName
* @return
* @throws SearchException
*/
List<DynamicFormFormShowFieldDTO> listFormShowFieldOfPage(String tableName) throws SearchException;
}

View File

@ -9,6 +9,8 @@ import com.cm.common.plugin.enums.dynamic.FieldTypeEnum;
import com.cm.common.plugin.pojo.dtos.database.table.TableColumnDTO;
import com.cm.common.plugin.pojo.dtos.database.table.TableDTO;
import com.cm.common.plugin.pojo.dtos.dynamic.DynamicFormDTO;
import com.cm.common.plugin.pojo.dtos.dynamic.DynamicFormFormShowFieldDTO;
import com.cm.common.plugin.pojo.dtos.dynamic.DynamicFormListShowFieldDTO;
import com.cm.common.plugin.pojo.vos.database.table.TableColumnVO;
import com.cm.common.plugin.pojo.vos.database.table.TableVO;
import com.cm.common.plugin.pojo.vos.dynamicform.DynamicFormFieldVO;
@ -88,6 +90,40 @@ public class DynamicFormServiceImpl extends AbstractService implements IDynamicF
return listShowField;
}
@Override
public List<DynamicFormListShowFieldDTO> listListShowFieldOfPage(String tableName) throws SearchException {
List<DynamicFormDTO> dynamicFormDTOs = listDynamicForm(tableName);
List<DynamicFormListShowFieldDTO> dynamicFormListShowFieldDTOList = new ArrayList<>();
for (DynamicFormDTO dynamicFormDTO : dynamicFormDTOs) {
if (dynamicFormDTO.getListShow() == 1) {
DynamicFormListShowFieldDTO dynamicFormListShowFieldDTO = new DynamicFormListShowFieldDTO();
dynamicFormListShowFieldDTO.setFieldName(WStringUtil.lowerUpper2UnderLine(dynamicFormDTO.getFieldName()));
dynamicFormListShowFieldDTO.setFieldExplain(dynamicFormDTO.getFieldExplain());
dynamicFormListShowFieldDTOList.add(dynamicFormListShowFieldDTO);
}
}
return dynamicFormListShowFieldDTOList;
}
@Override
public List<DynamicFormFormShowFieldDTO> listFormShowFieldOfPage(String tableName) throws SearchException {
List<DynamicFormDTO> dynamicFormDTOs = listDynamicForm(tableName);
List<DynamicFormFormShowFieldDTO> dynamicFormFormShowFieldDTOList = new ArrayList<>();
for (DynamicFormDTO dynamicFormDTO : dynamicFormDTOs) {
if (dynamicFormDTO.getFormShow() == 1) {
DynamicFormFormShowFieldDTO dynamicFormFormShowFieldDTO = new DynamicFormFormShowFieldDTO();
dynamicFormFormShowFieldDTO.setFieldName(WStringUtil.lowerUpper2UnderLine(dynamicFormDTO.getFieldName()));
dynamicFormFormShowFieldDTO.setFieldExplain(dynamicFormDTO.getFieldExplain());
dynamicFormFormShowFieldDTO.setFieldDefault(dynamicFormDTO.getFieldDefault());
dynamicFormFormShowFieldDTO.setFieldType(dynamicFormDTO.getFieldType());
dynamicFormFormShowFieldDTO.setVerifyType(dynamicFormDTO.getVerifyType());
dynamicFormFormShowFieldDTO.setVerifyRegular(dynamicFormDTO.getVerifyRegular());
dynamicFormFormShowFieldDTOList.add(dynamicFormFormShowFieldDTO);
}
}
return dynamicFormFormShowFieldDTOList;
}
/**
* 保存动态表单信息
*

View File

@ -69,15 +69,18 @@
// 初始化表格
function initTable() {
top.restAjax.get(top.restAjax.path('api/dynamicform/listlistshowfield/{tableName}', [$('#tableName').val()]), {}, null, function(code, data) {
top.restAjax.get(top.restAjax.path('api/dynamicdata/listlistshowfieldofpage/{tableName}', [$('#tableName').val()]), {}, null, function(code, data) {
var autoCols = [
{type:'checkbox', fixed: 'left'},
{field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center'}
{field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'}
];
for(var i = 0, item = data[i]; item = data[i++];) {
autoCols.push({field: item.fieldName, width: 150, title: item.fieldExplain, align:'center'});
}
table.render({
elem: '#dataTable',
id: 'dataTable',
url: top.restAjax.path('api/user/listpageusers', []),
url: top.restAjax.path('api/dynamicdata/listpagedynamicdata/{tableName}', [$('#tableName').val()]),
width: admin.screen() > 1 ? '100%' : '',
height: $win.height() - 90,
limit: 20,
@ -87,11 +90,7 @@
pageName: 'page',
limitName: 'rows'
},
cols: [
[
]
],
cols: [autoCols],
page: true,
parseData: function(data) {
return {
@ -109,7 +108,7 @@
// 重载表格
function reloadTable() {
table.reload('dataTable', {
url: top.restAjax.path('api/user/listpageusers', []),
url: top.restAjax.path('api/dynamicdata/listpagedynamicdata/{tableName}', [$('#tableName').val()]),
where: {
keywords: $('#keywords').val(),
startTime: $('#startTime').val(),
@ -139,7 +138,7 @@
yes: function (index) {
top.dialog.close(index);
var layIndex;
top.restAjax.delete(top.restAjax.path('api/user/removeuser/{ids}', [ids]), {}, null, function (code, data) {
top.restAjax.delete(top.restAjax.path('api/dynamicdata/removedynamicdata/{tableName}/{ids}', [$('#tableName').val(), ids]), {}, null, function (code, data) {
top.dialog.msg(top.dataMessage.deleteSuccess, {time: 1000}, function () {
reloadTable();
});
@ -179,7 +178,7 @@
area: ['100%', '100%'],
shadeClose: true,
anim: 2,
content: top.restAjax.path('route/system/user/save.html', []),
content: top.restAjax.path('route/dynamicform/savedynamicform/{tableName}', [$('#tableName').val()]),
end: function() {
reloadTable();
}
@ -212,34 +211,12 @@
if(i > 1) {
ids += '_';
}
ids += item.userId;
ids += item[$('#uuidField').val()];
}
removeData(ids);
}
}
});
table.on('tool(dataTable)', function(obj) {
var layEvent = obj.event;
var data = obj.data;
if(layEvent === 'userDeviceEvent') {
top.dialog.open({
url: top.restAjax.path('route/system/user/list-device.html?userId={userId}', [data.userId]),
title: '设备列表',
width: '300px',
height: '150px'
});
}
});
// 事件-排序
table.on('sort(dataTable)', function(obj) {
table.reload('dataTable', {
initSort: obj,
where: {
sort: obj.field,
order: obj.type
}
});
});
});
</script>
</body>

View File

@ -0,0 +1,134 @@
<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<base th:href="${#httpServletRequest.getScheme() + '://' + #httpServletRequest.getServerName() + ':' + #request.getServerPort() + #request.getContextPath() + '/'} ">
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein">
<div class="layui-card">
<div class="layui-card-header">
<span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
<a class="close" href="javascript:void(0);">上级列表</a><span lay-separator="">/</span>
<a href="javascript:void(0);"><cite>新增内容</cite></a>
</span>
</div>
<div class="layui-card-body" style="padding: 15px;">
<form class="layui-form" lay-filter="dataForm">
<div class="layui-form-item" th:each="dynamicFormFormShowFieldDTO, state: ${dynamicFormFormShowFieldDTOList}">
<label class="layui-form-label" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></label>
<div class="layui-input-block" th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'string'}">
<input type="text" th:if="${dynamicFormFormShowFieldDTO.verifyType eq 'none'}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" class="layui-input" th:value="${dynamicFormFormShowFieldDTO.fieldDefault}" th:placeholder="${'请输入'+ dynamicFormFormShowFieldDTO.fieldExplain}">
<input type="text" th:if="${dynamicFormFormShowFieldDTO.verifyType eq 'required'}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" class="layui-input" th:value="${dynamicFormFormShowFieldDTO.fieldDefault}" th:placeholder="${'请输入'+ dynamicFormFormShowFieldDTO.fieldExplain}" th:attr="lay-verify=required">
<input type="text" th:if="${dynamicFormFormShowFieldDTO.verifyType eq 'phone'}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" class="layui-input" th:value="${dynamicFormFormShowFieldDTO.fieldDefault}" th:placeholder="${'请输入'+ dynamicFormFormShowFieldDTO.fieldExplain}" th:attr="lay-verify=phone">
<input type="text" th:if="${dynamicFormFormShowFieldDTO.verifyType eq 'email'}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" class="layui-input" th:value="${dynamicFormFormShowFieldDTO.fieldDefault}" th:placeholder="${'请输入'+ dynamicFormFormShowFieldDTO.fieldExplain}" th:attr="lay-verify=email">
<input type="text" th:if="${dynamicFormFormShowFieldDTO.verifyType eq 'url'}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" class="layui-input" th:value="${dynamicFormFormShowFieldDTO.fieldDefault}" th:placeholder="${'请输入'+ dynamicFormFormShowFieldDTO.fieldExplain}" th:attr="lay-verify=url">
<input type="text" th:if="${dynamicFormFormShowFieldDTO.verifyType eq 'number'}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" class="layui-input" th:value="${dynamicFormFormShowFieldDTO.fieldDefault}" th:placeholder="${'请输入'+ dynamicFormFormShowFieldDTO.fieldExplain}" th:attr="lay-verify=number">
<input type="text" th:if="${dynamicFormFormShowFieldDTO.verifyType eq 'date'}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" class="layui-input" th:value="${dynamicFormFormShowFieldDTO.fieldDefault}" th:placeholder="${'请输入'+ dynamicFormFormShowFieldDTO.fieldExplain}" th:attr="lay-verify=date">
<input type="text" th:if="${dynamicFormFormShowFieldDTO.verifyType eq 'identity'}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" class="layui-input" th:value="${dynamicFormFormShowFieldDTO.fieldDefault}" th:placeholder="${'请输入'+ dynamicFormFormShowFieldDTO.fieldExplain}" th:attr="lay-verify=identity">
<input type="text" th:if="${dynamicFormFormShowFieldDTO.verifyType eq 'custom'}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" class="layui-input" th:value="${dynamicFormFormShowFieldDTO.fieldDefault}" th:placeholder="${'请输入'+ dynamicFormFormShowFieldDTO.fieldExplain}" th:attr="lay-verify=custom">
</div>
<div class="layui-input-block" th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'number'}">
<input type="number" th:if="${dynamicFormFormShowFieldDTO.verifyType eq 'none'}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" class="layui-input" th:value="${dynamicFormFormShowFieldDTO.fieldDefault}" th:placeholder="${'请输入'+ dynamicFormFormShowFieldDTO.fieldExplain}">
<input type="number" th:if="${dynamicFormFormShowFieldDTO.verifyType eq 'number'}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" class="layui-input" th:value="${dynamicFormFormShowFieldDTO.fieldDefault}" th:placeholder="${'请输入'+ dynamicFormFormShowFieldDTO.fieldExplain}" th:attr="lay-verify=number">
<input type="number" th:if="${dynamicFormFormShowFieldDTO.verifyType eq 'custom'}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" class="layui-input" th:value="${dynamicFormFormShowFieldDTO.fieldDefault}" th:placeholder="${'请输入'+ dynamicFormFormShowFieldDTO.fieldExplain}" th:attr="lay-verify=custom">
</div>
</div>
<div class="layui-form-item layui-layout-admin">
<div class="layui-input-block">
<div class="layui-footer" style="left: 0;">
<button type="button" class="layui-btn" lay-submit lay-filter="submitForm">提交新增</button>
<button type="button" class="layui-btn layui-btn-primary close">返回上级</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<input type="hidden" id="tableName" th:value="${tableName}"/>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script>
layui.config({
base: 'assets/layuiadmin/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
}).use(['index', 'form', 'laydate'], function(){
var $ = layui.$;
var form = layui.form;
var dictionaryParentId = top.restAjax.params(window.location.href).dictionaryParentId;
function closeBox() {
parent.layer.close(parent.layer.getFrameIndex(window.name));
}
// 初始化
function initData() {
form.val('dataForm', {
dictionaryParentId: dictionaryParentId,
});
if(dictionaryParentId == 0) {
form.val('dataForm', {
dictionaryParentName: '根节点',
});
form.render(null, 'dataForm');
return;
}
var loadLayerIndex;
top.restAjax.get(top.restAjax.path('api/dictionary/getdictionarybyid/{dictionaryParentId}', [dictionaryParentId]), {}, null, function(code, data) {
form.val('dataForm', {
dictionaryParentName: data.dictionaryName
});
form.render(null, 'dataForm');
}, function(code, data) {
top.DialogBox.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
}
initData();
// 提交表单
form.on('submit(submitForm)', function(formData) {
top.dialog.confirm(top.dataMessage.commit, function(index) {
top.dialog.close(index);
var loadLayerIndex;
top.restAjax.post(top.restAjax.path('api/dictionary/savedictionary', []), formData.field, null, function(code, data) {
var layerIndex = top.dialog.msg(top.dataMessage.commitSuccess, {
time: 0,
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
shade: 0.3,
yes: function(index) {
top.dialog.close(index);
parent.parent.common.refreshTree('leftTree');
window.location.reload();
},
btn2: function() {
closeBox();
parent.parent.common.refreshTree('leftTree');
}
});
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
});
return false;
});
$('.close').on('click', function() {
closeBox();
});
});
</script>
</body>
</html>

View File

@ -0,0 +1,126 @@
<!doctype html>
<html lang="en">
<head>
<base href="/usercenter/">
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein" style="padding: 0;overflow: hidden;">
<div class="layui-card">
<div class="layui-card-header">
<span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
<a class="close" href="javascript:void(0);">上级列表</a><span lay-separator="">/</span>
<a href="javascript:void(0);"><cite>编辑内容</cite></a>
</span>
</div>
<div class="layui-card-body" style="padding: 15px;">
<form class="layui-form" lay-filter="dataForm">
<div class="layui-form-item">
<label class="layui-form-label">上级名称 *</label>
<div class="layui-input-block">
<input type="hidden" name="dictionaryParentId" lay-verify="required">
<input type="text" name="dictionaryParentName" class="layui-input" disabled>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">字典名称 *</label>
<div class="layui-input-block">
<input type="text" name="dictionaryName" lay-verify="required" placeholder="请输入字典名称" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">字典说明</label>
<div class="layui-input-block">
<input type="text" name="dictionarySummary" placeholder="请输入字典说明" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-layout-admin">
<div class="layui-input-block">
<div class="layui-footer" style="left: 0;">
<button type="button" class="layui-btn" lay-submit lay-filter="submitForm">提交编辑</button>
<button type="button" class="layui-btn layui-btn-primary close">返回上级</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script>
layui.config({
base: 'assets/layuiadmin/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
}).use(['index', 'form', 'laydate'], function(){
var $ = layui.$;
var form = layui.form;
var dictionaryId = top.restAjax.params(window.location.href).dictionaryId;
function closeBox() {
parent.layer.close(parent.layer.getFrameIndex(window.name));
}
// 初始化
function initData() {
var loadLayerIndex;
top.restAjax.get(top.restAjax.path('api/dictionary/getdictionarybyid/{dictionaryId}', [dictionaryId]), {}, null, function(code, data) {
form.val('dataForm', {
dictionaryParentName: data.dictionaryParentName == '' ? '根节点' : data.dictionaryParentName,
dictionaryParentId: data.dictionaryParentId,
dictionaryName: data.dictionaryName,
dictionarySummary: data.dictionarySummary,
});
form.render(null, 'dataForm');
}, function(code, data) {
top.DialogBox.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
}
initData();
// 提交表单
form.on('submit(submitForm)', function(formData) {
top.dialog.confirm(top.dataMessage.commit, function(index) {
top.dialog.close(index);
var loadLayerIndex;
top.restAjax.put(top.restAjax.path('api/dictionary/updatedictionary/{dictionaryId}', [dictionaryId]), formData.field, null, function(code, data) {
var layerIndex = top.dialog.msg(top.dataMessage.commitSuccess, {
time: 0,
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
shade: 0.3,
yes: function(index) {
top.dialog.close(index);
parent.parent.common.refreshTree('leftTree');
window.location.reload();
},
btn2: function() {
closeBox();
parent.parent.common.refreshTree('leftTree');
}
});
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
});
return false;
});
$('.close').on('click', function() {
closeBox();
});
});
</script>
</body>
</html>