diff --git a/cloud-common-plugin/src/main/java/com/cm/common/plugin/controller/apis/dynamic/form/DynamicDataController.java b/cloud-common-plugin/src/main/java/com/cm/common/plugin/controller/apis/dynamic/form/DynamicDataController.java index 576f14a..9ae29a5 100644 --- a/cloud-common-plugin/src/main/java/com/cm/common/plugin/controller/apis/dynamic/form/DynamicDataController.java +++ b/cloud-common-plugin/src/main/java/com/cm/common/plugin/controller/apis/dynamic/form/DynamicDataController.java @@ -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 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 listFormShowFieldOfPage(@PathVariable("tableName") String tableName) { + return dynamicFormService.listFormShowFieldOfPage(tableName); + } + } diff --git a/cloud-common-plugin/src/main/java/com/cm/common/plugin/controller/apis/dynamic/form/DynamicFormController.java b/cloud-common-plugin/src/main/java/com/cm/common/plugin/controller/apis/dynamic/form/DynamicFormController.java index 60b9bb4..9f60135 100644 --- a/cloud-common-plugin/src/main/java/com/cm/common/plugin/controller/apis/dynamic/form/DynamicFormController.java +++ b/cloud-common-plugin/src/main/java/com/cm/common/plugin/controller/apis/dynamic/form/DynamicFormController.java @@ -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 listListShowFieldOfPage(@PathVariable("tableName") String tableName) { - // return dynamicFormService.listListShowFieldOfPage(tableName); - } - - } diff --git a/cloud-common-plugin/src/main/java/com/cm/common/plugin/controller/routes/dynamic/form/DynamicFormRouteController.java b/cloud-common-plugin/src/main/java/com/cm/common/plugin/controller/routes/dynamic/form/DynamicFormRouteController.java index e7f0bcb..7188ff6 100644 --- a/cloud-common-plugin/src/main/java/com/cm/common/plugin/controller/routes/dynamic/form/DynamicFormRouteController.java +++ b/cloud-common-plugin/src/main/java/com/cm/common/plugin/controller/routes/dynamic/form/DynamicFormRouteController.java @@ -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 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; } diff --git a/cloud-common-plugin/src/main/java/com/cm/common/plugin/pojo/dtos/dynamic/DynamicFormFormShowFieldDTO.java b/cloud-common-plugin/src/main/java/com/cm/common/plugin/pojo/dtos/dynamic/DynamicFormFormShowFieldDTO.java new file mode 100644 index 0000000..485afb7 --- /dev/null +++ b/cloud-common-plugin/src/main/java/com/cm/common/plugin/pojo/dtos/dynamic/DynamicFormFormShowFieldDTO.java @@ -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(); + } +} diff --git a/cloud-common-plugin/src/main/java/com/cm/common/plugin/pojo/dtos/dynamic/DynamicFormListShowFieldDTO.java b/cloud-common-plugin/src/main/java/com/cm/common/plugin/pojo/dtos/dynamic/DynamicFormListShowFieldDTO.java index a836698..62ba281 100644 --- a/cloud-common-plugin/src/main/java/com/cm/common/plugin/pojo/dtos/dynamic/DynamicFormListShowFieldDTO.java +++ b/cloud-common-plugin/src/main/java/com/cm/common/plugin/pojo/dtos/dynamic/DynamicFormListShowFieldDTO.java @@ -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(); + } } diff --git a/cloud-common-plugin/src/main/java/com/cm/common/plugin/service/dynamic/IDynamicDataService.java b/cloud-common-plugin/src/main/java/com/cm/common/plugin/service/dynamic/IDynamicDataService.java index b752123..e0a1284 100644 --- a/cloud-common-plugin/src/main/java/com/cm/common/plugin/service/dynamic/IDynamicDataService.java +++ b/cloud-common-plugin/src/main/java/com/cm/common/plugin/service/dynamic/IDynamicDataService.java @@ -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 getDynamicData(String tableName, String id) throws SearchException; + } diff --git a/cloud-common-plugin/src/main/java/com/cm/common/plugin/service/dynamic/IDynamicFormService.java b/cloud-common-plugin/src/main/java/com/cm/common/plugin/service/dynamic/IDynamicFormService.java index 49875e1..4c36020 100644 --- a/cloud-common-plugin/src/main/java/com/cm/common/plugin/service/dynamic/IDynamicFormService.java +++ b/cloud-common-plugin/src/main/java/com/cm/common/plugin/service/dynamic/IDynamicFormService.java @@ -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 listFormShowField(String tableName) throws SearchException; + /** + * 列表显示的字段 + * + * @param tableName + * @return + * @throws SearchException + */ + List listListShowFieldOfPage(String tableName) throws SearchException; + + /** + * 表单显示的字段 + * + * @param tableName + * @return + * @throws SearchException + */ + List listFormShowFieldOfPage(String tableName) throws SearchException; } diff --git a/cloud-common-plugin/src/main/java/com/cm/common/plugin/service/dynamic/impl/DynamicFormServiceImpl.java b/cloud-common-plugin/src/main/java/com/cm/common/plugin/service/dynamic/impl/DynamicFormServiceImpl.java index 102dec2..c133a5f 100644 --- a/cloud-common-plugin/src/main/java/com/cm/common/plugin/service/dynamic/impl/DynamicFormServiceImpl.java +++ b/cloud-common-plugin/src/main/java/com/cm/common/plugin/service/dynamic/impl/DynamicFormServiceImpl.java @@ -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 listListShowFieldOfPage(String tableName) throws SearchException { + List dynamicFormDTOs = listDynamicForm(tableName); + List 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 listFormShowFieldOfPage(String tableName) throws SearchException { + List dynamicFormDTOs = listDynamicForm(tableName); + List 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; + } + /** * 保存动态表单信息 * diff --git a/cloud-common-plugin/src/main/resources/templates/dynamic/form/list.html b/cloud-common-plugin/src/main/resources/templates/dynamic/form/listdynamicform.html similarity index 85% rename from cloud-common-plugin/src/main/resources/templates/dynamic/form/list.html rename to cloud-common-plugin/src/main/resources/templates/dynamic/form/listdynamicform.html index ed05e91..bc90c43 100644 --- a/cloud-common-plugin/src/main/resources/templates/dynamic/form/list.html +++ b/cloud-common-plugin/src/main/resources/templates/dynamic/form/listdynamicform.html @@ -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: '{{d.LAY_INDEX}}'} ]; + 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 - } - }); - }); }); diff --git a/cloud-common-plugin/src/main/resources/templates/dynamic/form/savedynamicform.html b/cloud-common-plugin/src/main/resources/templates/dynamic/form/savedynamicform.html new file mode 100644 index 0000000..80ab72a --- /dev/null +++ b/cloud-common-plugin/src/main/resources/templates/dynamic/form/savedynamicform.html @@ -0,0 +1,134 @@ + + + + + + + + + + + + + +
+
+ +
+
+
+ +
+ + + + + + + + + +
+
+ + + +
+
+ +
+
+ +
+
+
+
+
+
+ + + + + \ No newline at end of file diff --git a/cloud-common-plugin/src/main/resources/templates/dynamic/form/update.html b/cloud-common-plugin/src/main/resources/templates/dynamic/form/update.html new file mode 100644 index 0000000..7ac841d --- /dev/null +++ b/cloud-common-plugin/src/main/resources/templates/dynamic/form/update.html @@ -0,0 +1,126 @@ + + + + + + + + + + + + + +
+
+ +
+
+
+ +
+ + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+
+ +
+
+
+
+
+
+ + + + \ No newline at end of file