Commit 930c5ec490066dfaf66674ada8ea197d39a2d443
1 parent
69a6aa25
BPM Form 表单的完善
Showing
22 changed files
with
340 additions
and
229 deletions
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/form/BpmFormController.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.bpm.controller.form; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.adminserver.modules.bpm.convert.form.BpmFormConvert; |
| 4 | -import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmForm; | |
| 4 | +import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO; | |
| 5 | 5 | import cn.iocoder.yudao.adminserver.modules.bpm.service.form.BpmFormService; |
| 6 | 6 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.*; |
| 7 | 7 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 8 | 8 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 9 | -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | |
| 10 | -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | |
| 11 | 9 | import io.swagger.annotations.Api; |
| 12 | 10 | import io.swagger.annotations.ApiImplicitParam; |
| 13 | 11 | import io.swagger.annotations.ApiOperation; |
| ... | ... | @@ -16,14 +14,11 @@ import org.springframework.validation.annotation.Validated; |
| 16 | 14 | import org.springframework.web.bind.annotation.*; |
| 17 | 15 | |
| 18 | 16 | import javax.annotation.Resource; |
| 19 | -import javax.servlet.http.HttpServletResponse; | |
| 20 | 17 | import javax.validation.Valid; |
| 21 | -import java.io.IOException; | |
| 22 | 18 | import java.util.Collection; |
| 23 | 19 | import java.util.List; |
| 24 | 20 | |
| 25 | 21 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 26 | -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; | |
| 27 | 22 | |
| 28 | 23 | @Api(tags = "动态表单") |
| 29 | 24 | @RestController |
| ... | ... | @@ -63,7 +58,7 @@ public class BpmFormController { |
| 63 | 58 | @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) |
| 64 | 59 | @PreAuthorize("@ss.hasPermission('bpm:form:query')") |
| 65 | 60 | public CommonResult<BpmFormRespVO> getForm(@RequestParam("id") Long id) { |
| 66 | - BpmForm form = formService.getForm(id); | |
| 61 | + BpmFormDO form = formService.getForm(id); | |
| 67 | 62 | return success(BpmFormConvert.INSTANCE.convert(form)); |
| 68 | 63 | } |
| 69 | 64 | |
| ... | ... | @@ -72,7 +67,7 @@ public class BpmFormController { |
| 72 | 67 | @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) |
| 73 | 68 | @PreAuthorize("@ss.hasPermission('bpm:form:query')") |
| 74 | 69 | public CommonResult<List<BpmFormRespVO>> getFormList(@RequestParam("ids") Collection<Long> ids) { |
| 75 | - List<BpmForm> list = formService.getFormList(ids); | |
| 70 | + List<BpmFormDO> list = formService.getFormList(ids); | |
| 76 | 71 | return success(BpmFormConvert.INSTANCE.convertList(list)); |
| 77 | 72 | } |
| 78 | 73 | |
| ... | ... | @@ -80,7 +75,7 @@ public class BpmFormController { |
| 80 | 75 | @ApiOperation("获得动态表单分页") |
| 81 | 76 | @PreAuthorize("@ss.hasPermission('bpm:form:query')") |
| 82 | 77 | public CommonResult<PageResult<BpmFormRespVO>> getFormPage(@Valid BpmFormPageReqVO pageVO) { |
| 83 | - PageResult<BpmForm> pageResult = formService.getFormPage(pageVO); | |
| 78 | + PageResult<BpmFormDO> pageResult = formService.getFormPage(pageVO); | |
| 84 | 79 | return success(BpmFormConvert.INSTANCE.convertPage(pageResult)); |
| 85 | 80 | } |
| 86 | 81 | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/form/vo/BpmFormBaseVO.java
| ... | ... | @@ -11,18 +11,15 @@ import javax.validation.constraints.*; |
| 11 | 11 | @Data |
| 12 | 12 | public class BpmFormBaseVO { |
| 13 | 13 | |
| 14 | - @ApiModelProperty(value = "表单名称", required = true) | |
| 14 | + @ApiModelProperty(value = "表单名称", required = true, example = "芋道") | |
| 15 | 15 | @NotNull(message = "表单名称不能为空") |
| 16 | 16 | private String name; |
| 17 | 17 | |
| 18 | - @ApiModelProperty(value = "商户状态", required = true) | |
| 19 | - @NotNull(message = "商户状态不能为空") | |
| 18 | + @ApiModelProperty(value = "表单状态", required = true, notes = "参见 CommonStatusEnum 枚举", example = "1") | |
| 19 | + @NotNull(message = "表单状态不能为空") | |
| 20 | 20 | private Integer status; |
| 21 | 21 | |
| 22 | - @ApiModelProperty(value = "表单JSON") | |
| 23 | - private String formJson; | |
| 24 | - | |
| 25 | - @ApiModelProperty(value = "备注") | |
| 22 | + @ApiModelProperty(value = "备注", example = "我是备注") | |
| 26 | 23 | private String remark; |
| 27 | 24 | |
| 28 | 25 | } | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/form/vo/BpmFormCreateReqVO.java
| ... | ... | @@ -3,10 +3,21 @@ package cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo; |
| 3 | 3 | import lombok.*; |
| 4 | 4 | import io.swagger.annotations.*; |
| 5 | 5 | |
| 6 | +import javax.validation.constraints.NotNull; | |
| 7 | +import java.util.List; | |
| 8 | + | |
| 6 | 9 | @ApiModel("动态表单创建 Request VO") |
| 7 | 10 | @Data |
| 8 | 11 | @EqualsAndHashCode(callSuper = true) |
| 9 | 12 | @ToString(callSuper = true) |
| 10 | 13 | public class BpmFormCreateReqVO extends BpmFormBaseVO { |
| 11 | 14 | |
| 15 | + @ApiModelProperty(value = "表单的配置", required = true, notes = "JSON 字符串") | |
| 16 | + @NotNull(message = "表单的配置不能为空") | |
| 17 | + private String conf; | |
| 18 | + | |
| 19 | + @ApiModelProperty(value = "表单项的数组", required = true, notes = "JSON 字符串的数组") | |
| 20 | + @NotNull(message = "表单项的数组不能为空") | |
| 21 | + private List<String> fields; | |
| 22 | + | |
| 12 | 23 | } | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/form/vo/BpmFormExcelVO.java deleted
| 1 | -package cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo; | |
| 2 | - | |
| 3 | -import com.alibaba.excel.annotation.ExcelProperty; | |
| 4 | -import lombok.Data; | |
| 5 | - | |
| 6 | -import java.util.Date; | |
| 7 | - | |
| 8 | -/** | |
| 9 | - * 动态表单 Excel VO | |
| 10 | - * | |
| 11 | - * @author 芋艿 | |
| 12 | - */ | |
| 13 | -@Data | |
| 14 | -public class BpmFormExcelVO { | |
| 15 | - | |
| 16 | - @ExcelProperty("表单编号") | |
| 17 | - private Long id; | |
| 18 | - | |
| 19 | - @ExcelProperty("表单名称") | |
| 20 | - private String name; | |
| 21 | - | |
| 22 | - @ExcelProperty("商户状态") | |
| 23 | - private Integer status; | |
| 24 | - | |
| 25 | - @ExcelProperty("表单JSON") | |
| 26 | - private String formJson; | |
| 27 | - | |
| 28 | - @ExcelProperty("备注") | |
| 29 | - private String remark; | |
| 30 | - | |
| 31 | - @ExcelProperty("创建时间") | |
| 32 | - private Date createTime; | |
| 33 | - | |
| 34 | -} |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/form/vo/BpmFormExportReqVO.java deleted
| 1 | -package cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo; | |
| 2 | - | |
| 3 | -import io.swagger.annotations.ApiModel; | |
| 4 | -import io.swagger.annotations.ApiModelProperty; | |
| 5 | -import lombok.Data; | |
| 6 | - | |
| 7 | -@ApiModel(value = "动态表单 Excel 导出 Request VO", description = "参数和 BpmFormPageReqVO 是一致的") | |
| 8 | -@Data | |
| 9 | -public class BpmFormExportReqVO { | |
| 10 | - | |
| 11 | - @ApiModelProperty(value = "表单名称") | |
| 12 | - private String name; | |
| 13 | - | |
| 14 | -} |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/form/vo/BpmFormPageReqVO.java
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/form/vo/BpmFormRespVO.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo; |
| 2 | 2 | |
| 3 | -import lombok.*; | |
| 4 | -import java.util.*; | |
| 5 | -import io.swagger.annotations.*; | |
| 3 | +import io.swagger.annotations.ApiModel; | |
| 4 | +import io.swagger.annotations.ApiModelProperty; | |
| 5 | +import lombok.Data; | |
| 6 | +import lombok.EqualsAndHashCode; | |
| 7 | +import lombok.ToString; | |
| 8 | + | |
| 9 | +import javax.validation.constraints.NotNull; | |
| 10 | +import java.util.Date; | |
| 11 | +import java.util.List; | |
| 6 | 12 | |
| 7 | 13 | @ApiModel("动态表单 Response VO") |
| 8 | 14 | @Data |
| ... | ... | @@ -10,8 +16,15 @@ import io.swagger.annotations.*; |
| 10 | 16 | @ToString(callSuper = true) |
| 11 | 17 | public class BpmFormRespVO extends BpmFormBaseVO { |
| 12 | 18 | |
| 13 | - @ApiModelProperty(value = "表单编号", required = true) | |
| 19 | + @ApiModelProperty(value = "表单编号", required = true, example = "1024") | |
| 14 | 20 | private Long id; |
| 21 | + @ApiModelProperty(value = "表单的配置", required = true, notes = "JSON 字符串") | |
| 22 | + @NotNull(message = "表单的配置不能为空") | |
| 23 | + private String conf; | |
| 24 | + | |
| 25 | + @ApiModelProperty(value = "表单项的数组", required = true, notes = "JSON 字符串的数组") | |
| 26 | + @NotNull(message = "表单项的数组不能为空") | |
| 27 | + private List<String> fields; | |
| 15 | 28 | |
| 16 | 29 | @ApiModelProperty(value = "创建时间", required = true) |
| 17 | 30 | private Date createTime; | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/form/vo/BpmFormUpdateReqVO.java
| ... | ... | @@ -3,6 +3,7 @@ package cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo; |
| 3 | 3 | import lombok.*; |
| 4 | 4 | import io.swagger.annotations.*; |
| 5 | 5 | import javax.validation.constraints.*; |
| 6 | +import java.util.List; | |
| 6 | 7 | |
| 7 | 8 | @ApiModel("动态表单更新 Request VO") |
| 8 | 9 | @Data |
| ... | ... | @@ -10,8 +11,16 @@ import javax.validation.constraints.*; |
| 10 | 11 | @ToString(callSuper = true) |
| 11 | 12 | public class BpmFormUpdateReqVO extends BpmFormBaseVO { |
| 12 | 13 | |
| 13 | - @ApiModelProperty(value = "表单编号", required = true) | |
| 14 | + @ApiModelProperty(value = "表单编号", required = true, example = "1024") | |
| 14 | 15 | @NotNull(message = "表单编号不能为空") |
| 15 | 16 | private Long id; |
| 16 | 17 | |
| 18 | + @ApiModelProperty(value = "表单的配置", required = true, notes = "JSON 字符串") | |
| 19 | + @NotNull(message = "表单的配置不能为空") | |
| 20 | + private String conf; | |
| 21 | + | |
| 22 | + @ApiModelProperty(value = "表单项的数组", required = true, notes = "JSON 字符串的数组") | |
| 23 | + @NotNull(message = "表单项的数组不能为空") | |
| 24 | + private List<String> fields; | |
| 25 | + | |
| 17 | 26 | } | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/form/BpmFormConvert.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.bpm.convert.form; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormCreateReqVO; |
| 4 | -import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormExcelVO; | |
| 5 | 4 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormRespVO; |
| 6 | 5 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormUpdateReqVO; |
| 7 | -import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmForm; | |
| 6 | +import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO; | |
| 8 | 7 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 9 | 8 | import org.mapstruct.Mapper; |
| 10 | 9 | import org.mapstruct.factory.Mappers; |
| ... | ... | @@ -21,16 +20,14 @@ public interface BpmFormConvert { |
| 21 | 20 | |
| 22 | 21 | BpmFormConvert INSTANCE = Mappers.getMapper(BpmFormConvert.class); |
| 23 | 22 | |
| 24 | - BpmForm convert(BpmFormCreateReqVO bean); | |
| 23 | + BpmFormDO convert(BpmFormCreateReqVO bean); | |
| 25 | 24 | |
| 26 | - BpmForm convert(BpmFormUpdateReqVO bean); | |
| 25 | + BpmFormDO convert(BpmFormUpdateReqVO bean); | |
| 27 | 26 | |
| 28 | - BpmFormRespVO convert(BpmForm bean); | |
| 27 | + BpmFormRespVO convert(BpmFormDO bean); | |
| 29 | 28 | |
| 30 | - List<BpmFormRespVO> convertList(List<BpmForm> list); | |
| 29 | + List<BpmFormRespVO> convertList(List<BpmFormDO> list); | |
| 31 | 30 | |
| 32 | - PageResult<BpmFormRespVO> convertPage(PageResult<BpmForm> page); | |
| 33 | - | |
| 34 | - List<BpmFormExcelVO> convertList02(List<BpmForm> list); | |
| 31 | + PageResult<BpmFormRespVO> convertPage(PageResult<BpmFormDO> page); | |
| 35 | 32 | |
| 36 | 33 | } | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/form/BpmForm.java renamed to yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/form/BpmFormDO.java
| ... | ... | @@ -22,7 +22,7 @@ import java.util.List; |
| 22 | 22 | @Builder |
| 23 | 23 | @NoArgsConstructor |
| 24 | 24 | @AllArgsConstructor |
| 25 | -public class BpmForm extends BaseDO { | |
| 25 | +public class BpmFormDO extends BaseDO { | |
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * 编号 |
| ... | ... | @@ -37,12 +37,12 @@ public class BpmForm extends BaseDO { |
| 37 | 37 | * 状态 |
| 38 | 38 | */ |
| 39 | 39 | private Integer status; |
| 40 | -// /** | |
| 41 | -// * 表单JSON | |
| 42 | -// */ | |
| 43 | -// private String formJson; | |
| 44 | 40 | /** |
| 45 | - * 表单配置 | |
| 41 | + * 表单的配置 | |
| 42 | + */ | |
| 43 | + private String conf; | |
| 44 | + /** | |
| 45 | + * 表单项的数组 | |
| 46 | 46 | * |
| 47 | 47 | * 目前直接将 https://github.com/JakHuang/form-generator 生成的 JSON 串,直接保存 |
| 48 | 48 | * 定义:https://github.com/JakHuang/form-generator/issues/46 | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/form/BpmFormData.java renamed to yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/form/BpmFormDataDO.java
| ... | ... | @@ -22,7 +22,7 @@ import java.util.Map; |
| 22 | 22 | @Builder |
| 23 | 23 | @NoArgsConstructor |
| 24 | 24 | @AllArgsConstructor |
| 25 | -public class BpmFormData extends BaseDO { | |
| 25 | +public class BpmFormDataDO extends BaseDO { | |
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * 编号 |
| ... | ... | @@ -31,7 +31,7 @@ public class BpmFormData extends BaseDO { |
| 31 | 31 | /** |
| 32 | 32 | * 表单编号 |
| 33 | 33 | * |
| 34 | - * 关联 {@link BpmForm#getId()} | |
| 34 | + * 关联 {@link BpmFormDO#getId()} | |
| 35 | 35 | */ |
| 36 | 36 | private Long formId; |
| 37 | 37 | /** |
| ... | ... | @@ -41,7 +41,7 @@ public class BpmFormData extends BaseDO { |
| 41 | 41 | /** |
| 42 | 42 | * 表单配置 |
| 43 | 43 | * |
| 44 | - * 冗余 {@link BpmForm#getFields()} | |
| 44 | + * 冗余 {@link BpmFormDO#getFields()} | |
| 45 | 45 | * 主要考虑,表单是可以修改的 |
| 46 | 46 | */ |
| 47 | 47 | @TableField(typeHandler = JacksonTypeHandler.class) | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/mysql/form/BpmFormMapper.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.form; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | -import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormExportReqVO; | |
| 5 | 4 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormPageReqVO; |
| 6 | -import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmForm; | |
| 5 | +import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO; | |
| 7 | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 8 | 7 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 9 | 8 | import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; |
| 10 | 9 | import org.apache.ibatis.annotations.Mapper; |
| 11 | 10 | |
| 12 | -import java.util.List; | |
| 13 | - | |
| 14 | 11 | /** |
| 15 | 12 | * 动态表单 Mapper |
| 16 | 13 | * |
| 17 | 14 | * @author 风里雾里 |
| 18 | 15 | */ |
| 19 | 16 | @Mapper |
| 20 | -public interface BpmFormMapper extends BaseMapperX<BpmForm> { | |
| 17 | +public interface BpmFormMapper extends BaseMapperX<BpmFormDO> { | |
| 21 | 18 | |
| 22 | - default PageResult<BpmForm> selectPage(BpmFormPageReqVO reqVO) { | |
| 23 | - return selectPage(reqVO, new QueryWrapperX<BpmForm>() | |
| 19 | + default PageResult<BpmFormDO> selectPage(BpmFormPageReqVO reqVO) { | |
| 20 | + return selectPage(reqVO, new QueryWrapperX<BpmFormDO>() | |
| 24 | 21 | .likeIfPresent("name", reqVO.getName()) |
| 25 | 22 | .orderByDesc("id")); |
| 26 | 23 | } | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/form/BpmFormService.java
| ... | ... | @@ -3,7 +3,7 @@ package cn.iocoder.yudao.adminserver.modules.bpm.service.form; |
| 3 | 3 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormCreateReqVO; |
| 4 | 4 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormPageReqVO; |
| 5 | 5 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormUpdateReqVO; |
| 6 | -import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmForm; | |
| 6 | +import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO; | |
| 7 | 7 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 8 | 8 | |
| 9 | 9 | import javax.validation.Valid; |
| ... | ... | @@ -46,7 +46,7 @@ public interface BpmFormService { |
| 46 | 46 | * @param id 编号 |
| 47 | 47 | * @return 动态表单 |
| 48 | 48 | */ |
| 49 | - BpmForm getForm(Long id); | |
| 49 | + BpmFormDO getForm(Long id); | |
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | 52 | * 获得动态表单列表 |
| ... | ... | @@ -54,7 +54,7 @@ public interface BpmFormService { |
| 54 | 54 | * @param ids 编号 |
| 55 | 55 | * @return 动态表单列表 |
| 56 | 56 | */ |
| 57 | - List<BpmForm> getFormList(Collection<Long> ids); | |
| 57 | + List<BpmFormDO> getFormList(Collection<Long> ids); | |
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | 60 | * 获得动态表单分页 |
| ... | ... | @@ -62,6 +62,6 @@ public interface BpmFormService { |
| 62 | 62 | * @param pageReqVO 分页查询 |
| 63 | 63 | * @return 动态表单分页 |
| 64 | 64 | */ |
| 65 | - PageResult<BpmForm> getFormPage(BpmFormPageReqVO pageReqVO); | |
| 65 | + PageResult<BpmFormDO> getFormPage(BpmFormPageReqVO pageReqVO); | |
| 66 | 66 | |
| 67 | 67 | } | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/form/BpmFormServiceImpl.java renamed to yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/form/impl/BpmFormServiceImpl.java
| 1 | -package cn.iocoder.yudao.adminserver.modules.bpm.service.form; | |
| 1 | +package cn.iocoder.yudao.adminserver.modules.bpm.service.form.impl; | |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormCreateReqVO; |
| 4 | -import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormExportReqVO; | |
| 5 | 4 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormPageReqVO; |
| 6 | 5 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormUpdateReqVO; |
| 7 | 6 | import cn.iocoder.yudao.adminserver.modules.bpm.convert.form.BpmFormConvert; |
| 8 | -import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmForm; | |
| 7 | +import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO; | |
| 9 | 8 | import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.form.BpmFormMapper; |
| 9 | +import cn.iocoder.yudao.adminserver.modules.bpm.service.form.BpmFormService; | |
| 10 | 10 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 11 | 11 | import org.springframework.stereotype.Service; |
| 12 | 12 | import org.springframework.validation.annotation.Validated; |
| ... | ... | @@ -33,7 +33,7 @@ public class BpmFormServiceImpl implements BpmFormService { |
| 33 | 33 | @Override |
| 34 | 34 | public Long createForm(BpmFormCreateReqVO createReqVO) { |
| 35 | 35 | // 插入 |
| 36 | - BpmForm form = BpmFormConvert.INSTANCE.convert(createReqVO); | |
| 36 | + BpmFormDO form = BpmFormConvert.INSTANCE.convert(createReqVO); | |
| 37 | 37 | formMapper.insert(form); |
| 38 | 38 | // 返回 |
| 39 | 39 | return form.getId(); |
| ... | ... | @@ -44,7 +44,7 @@ public class BpmFormServiceImpl implements BpmFormService { |
| 44 | 44 | // 校验存在 |
| 45 | 45 | this.validateFormExists(updateReqVO.getId()); |
| 46 | 46 | // 更新 |
| 47 | - BpmForm updateObj = BpmFormConvert.INSTANCE.convert(updateReqVO); | |
| 47 | + BpmFormDO updateObj = BpmFormConvert.INSTANCE.convert(updateReqVO); | |
| 48 | 48 | formMapper.updateById(updateObj); |
| 49 | 49 | } |
| 50 | 50 | |
| ... | ... | @@ -63,17 +63,17 @@ public class BpmFormServiceImpl implements BpmFormService { |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | @Override |
| 66 | - public BpmForm getForm(Long id) { | |
| 66 | + public BpmFormDO getForm(Long id) { | |
| 67 | 67 | return formMapper.selectById(id); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | @Override |
| 71 | - public List<BpmForm> getFormList(Collection<Long> ids) { | |
| 71 | + public List<BpmFormDO> getFormList(Collection<Long> ids) { | |
| 72 | 72 | return formMapper.selectBatchIds(ids); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | @Override |
| 76 | - public PageResult<BpmForm> getFormPage(BpmFormPageReqVO pageReqVO) { | |
| 76 | + public PageResult<BpmFormDO> getFormPage(BpmFormPageReqVO pageReqVO) { | |
| 77 | 77 | return formMapper.selectPage(pageReqVO); |
| 78 | 78 | } |
| 79 | 79 | ... | ... |
yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/bpm/service/form/BpmFormServiceTest.java
0 → 100644
| 1 | +package cn.iocoder.yudao.adminserver.modules.bpm.service.form; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.adminserver.BaseDbUnitTest; | |
| 4 | +import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormCreateReqVO; | |
| 5 | +import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormPageReqVO; | |
| 6 | +import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormUpdateReqVO; | |
| 7 | +import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO; | |
| 8 | +import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.form.BpmFormMapper; | |
| 9 | +import cn.iocoder.yudao.adminserver.modules.bpm.service.form.impl.BpmFormServiceImpl; | |
| 10 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 11 | +import org.junit.jupiter.api.Test; | |
| 12 | +import org.springframework.context.annotation.Import; | |
| 13 | + | |
| 14 | +import javax.annotation.Resource; | |
| 15 | + | |
| 16 | +import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.BPM_FORM_NOT_EXISTS; | |
| 17 | +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; | |
| 18 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | |
| 19 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; | |
| 20 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; | |
| 21 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; | |
| 22 | +import static org.junit.jupiter.api.Assertions.*; | |
| 23 | + | |
| 24 | +/** | |
| 25 | + * {@link BpmFormServiceImpl} 的单元测试类 | |
| 26 | + * | |
| 27 | + * @author 芋道源码 | |
| 28 | + */ | |
| 29 | +@Import(BpmFormServiceImpl.class) | |
| 30 | +public class BpmFormServiceTest extends BaseDbUnitTest { | |
| 31 | + | |
| 32 | + @Resource | |
| 33 | + private BpmFormServiceImpl formService; | |
| 34 | + | |
| 35 | + @Resource | |
| 36 | + private BpmFormMapper formMapper; | |
| 37 | + | |
| 38 | + @Test | |
| 39 | + public void testCreateForm_success() { | |
| 40 | + // 准备参数 | |
| 41 | + BpmFormCreateReqVO reqVO = randomPojo(BpmFormCreateReqVO.class); | |
| 42 | + | |
| 43 | + // 调用 | |
| 44 | + Long formId = formService.createForm(reqVO); | |
| 45 | + // 断言 | |
| 46 | + assertNotNull(formId); | |
| 47 | + // 校验记录的属性是否正确 | |
| 48 | + BpmFormDO form = formMapper.selectById(formId); | |
| 49 | + assertPojoEquals(reqVO, form); | |
| 50 | + } | |
| 51 | + | |
| 52 | + @Test | |
| 53 | + public void testUpdateForm_success() { | |
| 54 | + // mock 数据 | |
| 55 | + BpmFormDO dbForm = randomPojo(BpmFormDO.class); | |
| 56 | + formMapper.insert(dbForm);// @Sql: 先插入出一条存在的数据 | |
| 57 | + // 准备参数 | |
| 58 | + BpmFormUpdateReqVO reqVO = randomPojo(BpmFormUpdateReqVO.class, o -> { | |
| 59 | + o.setId(dbForm.getId()); // 设置更新的 ID | |
| 60 | + }); | |
| 61 | + | |
| 62 | + // 调用 | |
| 63 | + formService.updateForm(reqVO); | |
| 64 | + // 校验是否更新正确 | |
| 65 | + BpmFormDO form = formMapper.selectById(reqVO.getId()); // 获取最新的 | |
| 66 | + assertPojoEquals(reqVO, form); | |
| 67 | + } | |
| 68 | + | |
| 69 | + @Test | |
| 70 | + public void testUpdateForm_notExists() { | |
| 71 | + // 准备参数 | |
| 72 | + BpmFormUpdateReqVO reqVO = randomPojo(BpmFormUpdateReqVO.class); | |
| 73 | + | |
| 74 | + // 调用, 并断言异常 | |
| 75 | + assertServiceException(() -> formService.updateForm(reqVO), BPM_FORM_NOT_EXISTS); | |
| 76 | + } | |
| 77 | + | |
| 78 | + @Test | |
| 79 | + public void testDeleteForm_success() { | |
| 80 | + // mock 数据 | |
| 81 | + BpmFormDO dbForm = randomPojo(BpmFormDO.class); | |
| 82 | + formMapper.insert(dbForm);// @Sql: 先插入出一条存在的数据 | |
| 83 | + // 准备参数 | |
| 84 | + Long id = dbForm.getId(); | |
| 85 | + | |
| 86 | + // 调用 | |
| 87 | + formService.deleteForm(id); | |
| 88 | + // 校验数据不存在了 | |
| 89 | + assertNull(formMapper.selectById(id)); | |
| 90 | + } | |
| 91 | + | |
| 92 | + @Test | |
| 93 | + public void testDeleteForm_notExists() { | |
| 94 | + // 准备参数 | |
| 95 | + Long id = randomLongId(); | |
| 96 | + | |
| 97 | + // 调用, 并断言异常 | |
| 98 | + assertServiceException(() -> formService.deleteForm(id), BPM_FORM_NOT_EXISTS); | |
| 99 | + } | |
| 100 | + | |
| 101 | + @Test | |
| 102 | + public void testGetFormPage() { | |
| 103 | + // mock 数据 | |
| 104 | + BpmFormDO dbForm = randomPojo(BpmFormDO.class, o -> { // 等会查询到 | |
| 105 | + o.setName("芋道源码"); | |
| 106 | + }); | |
| 107 | + formMapper.insert(dbForm); | |
| 108 | + // 测试 name 不匹配 | |
| 109 | + formMapper.insert(cloneIgnoreId(dbForm, o -> o.setName("源码"))); | |
| 110 | + // 准备参数 | |
| 111 | + BpmFormPageReqVO reqVO = new BpmFormPageReqVO(); | |
| 112 | + reqVO.setName("芋道"); | |
| 113 | + | |
| 114 | + // 调用 | |
| 115 | + PageResult<BpmFormDO> pageResult = formService.getFormPage(reqVO); | |
| 116 | + // 断言 | |
| 117 | + assertEquals(1, pageResult.getTotal()); | |
| 118 | + assertEquals(1, pageResult.getList().size()); | |
| 119 | + assertPojoEquals(dbForm, pageResult.getList().get(0)); | |
| 120 | + } | |
| 121 | + | |
| 122 | +} | ... | ... |
yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/bpm/service/package-info.java
0 → 100644
| 1 | +package cn.iocoder.yudao.adminserver.modules.bpm.service; | ... | ... |
yudao-admin-server/src/test/resources/sql/clean.sql
yudao-admin-server/src/test/resources/sql/create_tables.sql
| ... | ... | @@ -472,3 +472,19 @@ CREATE TABLE IF NOT EXISTS "sys_tenant" ( |
| 472 | 472 | "deleted" bit NOT NULL DEFAULT FALSE, |
| 473 | 473 | PRIMARY KEY ("id") |
| 474 | 474 | ) COMMENT '租户'; |
| 475 | + | |
| 476 | + | |
| 477 | +CREATE TABLE IF NOT EXISTS "bpm_form" ( | |
| 478 | + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, | |
| 479 | + "name" varchar(63) NOT NULL, | |
| 480 | + "status" tinyint NOT NULL, | |
| 481 | + "fields" varchar(255) NOT NULL, | |
| 482 | + "conf" varchar(255) NOT NULL, | |
| 483 | + "remark" varchar(255), | |
| 484 | + "creator" varchar(64) DEFAULT '', | |
| 485 | + "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | |
| 486 | + "updater" varchar(64) DEFAULT '', | |
| 487 | + "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | |
| 488 | + "deleted" bit NOT NULL DEFAULT FALSE, | |
| 489 | + PRIMARY KEY ("id") | |
| 490 | +) COMMENT '动态表单'; | ... | ... |
yudao-admin-ui/src/utils/generator/drawingDefalut.js
| 1 | 1 | export default [ |
| 2 | 2 | { |
| 3 | - // layout: 'colFormItem', | |
| 4 | - // tagIcon: 'input', | |
| 5 | - // label: '手机号', | |
| 6 | - // vModel: 'mobile', | |
| 7 | - // formId: 6, | |
| 8 | - // tag: 'el-input', | |
| 9 | - // placeholder: '请输入手机号', | |
| 10 | - // defaultValue: '', | |
| 11 | - // span: 24, | |
| 12 | - // style: { width: '100%' }, | |
| 13 | - // clearable: true, | |
| 14 | - // prepend: '', | |
| 15 | - // append: '', | |
| 16 | - // 'prefix-icon': 'el-icon-mobile', | |
| 17 | - // 'suffix-icon': '', | |
| 18 | - // maxlength: 11, | |
| 19 | - // 'show-word-limit': true, | |
| 20 | - // readonly: false, | |
| 21 | - // disabled: false, | |
| 22 | - // required: true, | |
| 23 | - // changeTag: true, | |
| 24 | - // regList: [{ | |
| 25 | - // pattern: '/^1(3|4|5|7|8|9)\\d{9}$/', | |
| 26 | - // message: '手机号格式错误' | |
| 27 | - // }] | |
| 3 | + layout: 'colFormItem', | |
| 4 | + tagIcon: 'input', | |
| 5 | + label: '手机号', | |
| 6 | + vModel: 'mobile', | |
| 7 | + formId: 6, | |
| 8 | + tag: 'el-input', | |
| 9 | + placeholder: '请输入手机号', | |
| 10 | + defaultValue: '', | |
| 11 | + span: 24, | |
| 12 | + style: { width: '100%' }, | |
| 13 | + clearable: true, | |
| 14 | + prepend: '', | |
| 15 | + append: '', | |
| 16 | + 'prefix-icon': 'el-icon-mobile', | |
| 17 | + 'suffix-icon': '', | |
| 18 | + maxlength: 11, | |
| 19 | + 'show-word-limit': true, | |
| 20 | + readonly: false, | |
| 21 | + disabled: false, | |
| 22 | + required: true, | |
| 23 | + changeTag: true, | |
| 24 | + regList: [{ | |
| 25 | + pattern: '/^1(3|4|5|7|8|9)\\d{9}$/', | |
| 26 | + message: '手机号格式错误' | |
| 27 | + }] | |
| 28 | 28 | } |
| 29 | 29 | ] | ... | ... |
yudao-admin-ui/src/views/bpm/form/formEditor.vue
| ... | ... | @@ -32,7 +32,7 @@ |
| 32 | 32 | </div> |
| 33 | 33 | </draggable> |
| 34 | 34 | <div class="components-title"> |
| 35 | - <svg-icon icon-class="component" /> 布局型组件 | |
| 35 | + <svg-icon icon-class="component" />布局型组件 | |
| 36 | 36 | </div> |
| 37 | 37 | <draggable class="components-draggable" :list="layoutComponents" :group="{ name: 'componentsGroup', pull: 'clone', put: false }" |
| 38 | 38 | :clone="cloneComponent" draggable=".components-item" :sort="false" @end="onEnd"> |
| ... | ... | @@ -66,11 +66,10 @@ |
| 66 | 66 | <div class="center-board"> |
| 67 | 67 | <!-- 上面:操作按钮 --> |
| 68 | 68 | <div class="action-bar"> |
| 69 | - <el-button class="delete-btn" icon="el-icon-delete" type="text" @click="empty"> | |
| 70 | - 清空 | |
| 71 | - </el-button> | |
| 69 | + <el-button icon="el-icon-check" type="text" @click="save">保存</el-button> | |
| 70 | + <el-button class="delete-btn" icon="el-icon-delete" type="text" @click="empty">清空</el-button> | |
| 72 | 71 | </div> |
| 73 | - <!-- 中间,表单 --> | |
| 72 | + <!-- 中间,表单项 --> | |
| 74 | 73 | <el-scrollbar class="center-scrollbar"> |
| 75 | 74 | <el-row class="center-board-row" :gutter="formConf.gutter"> |
| 76 | 75 | <el-form :size="formConf.size" :label-position="formConf.labelPosition" :disabled="formConf.disabled" |
| ... | ... | @@ -102,6 +101,8 @@ import drawingDefalut from '@/utils/generator/drawingDefalut' |
| 102 | 101 | // import logo from '@/assets/logo/logo.png' |
| 103 | 102 | import DraggableItem from './../../tool/build/DraggableItem' |
| 104 | 103 | import RightPanel from './../../tool/build/RightPanel' |
| 104 | +import {createForm, getForm, updateForm} from "@/api/bpm/form"; | |
| 105 | +import {SysCommonStatusEnum} from "@/utils/constants"; | |
| 105 | 106 | |
| 106 | 107 | // const emptyActiveData = { style: {}, autosize: {} } |
| 107 | 108 | let oldActiveId |
| ... | ... | @@ -123,22 +124,25 @@ export default { |
| 123 | 124 | selectComponents, |
| 124 | 125 | layoutComponents, |
| 125 | 126 | labelWidth: 100, |
| 126 | - drawingList: drawingDefalut, // 表单项的数组 | |
| 127 | - drawingData: {}, | |
| 128 | - activeId: drawingDefalut[0].formId, | |
| 127 | + | |
| 128 | + drawingData: {}, // 生成后的表单数据 | |
| 129 | + | |
| 130 | + drawingList: [], // 表单项的数组 | |
| 131 | + activeId: 0, | |
| 132 | + activeData: {}, | |
| 129 | 133 | // drawerVisible: false, |
| 130 | 134 | // formData: {}, |
| 131 | 135 | // dialogVisible: false, |
| 132 | 136 | // showFileName: false, |
| 133 | - activeData: drawingDefalut[0], | |
| 134 | 137 | |
| 135 | 138 | // 表单参数 |
| 136 | - form: {}, | |
| 139 | + form: { | |
| 140 | + status: SysCommonStatusEnum.ENABLE, | |
| 141 | + }, | |
| 137 | 142 | // 表单校验 |
| 138 | 143 | rules: { |
| 139 | 144 | name: [{ required: true, message: "表单名不能为空", trigger: "blur" }], |
| 140 | 145 | status: [{ required: true, message: "开启状态不能为空", trigger: "blur" }], |
| 141 | - fields: [{ required: true, message: "表单配置不能为空", trigger: "blur" }], | |
| 142 | 146 | } |
| 143 | 147 | } |
| 144 | 148 | }, |
| ... | ... | @@ -161,6 +165,23 @@ export default { |
| 161 | 165 | immediate: true |
| 162 | 166 | } |
| 163 | 167 | }, |
| 168 | + created() { | |
| 169 | + // 读取表单配置 | |
| 170 | + const formId = this.$route.query && this.$route.query.formId | |
| 171 | + if (formId) { | |
| 172 | + getForm(formId).then(response => { | |
| 173 | + const data = response.data | |
| 174 | + this.form = { | |
| 175 | + id: data.id, | |
| 176 | + name: data.name, | |
| 177 | + status: data.status, | |
| 178 | + remark: data.remark | |
| 179 | + } | |
| 180 | + this.formConf = JSON.parse(data.conf) | |
| 181 | + this.drawingList = this.decodeFields(data.fields) | |
| 182 | + }); | |
| 183 | + } | |
| 184 | + }, | |
| 164 | 185 | methods: { |
| 165 | 186 | activeFormItem(element) { |
| 166 | 187 | this.activeData = element |
| ... | ... | @@ -202,6 +223,53 @@ export default { |
| 202 | 223 | ...this.formConf |
| 203 | 224 | } |
| 204 | 225 | }, |
| 226 | + save() { | |
| 227 | + // this.AssembleFormData() | |
| 228 | + // console.log(this.formData) | |
| 229 | + this.$refs["form"].validate(valid => { | |
| 230 | + if (!valid) { | |
| 231 | + return; | |
| 232 | + } | |
| 233 | + const form = { | |
| 234 | + conf: JSON.stringify(this.formConf), // 表单配置 | |
| 235 | + // fields: JSON.stringify(this.drawingList), // 表单项的数组 | |
| 236 | + fields: this.encodeFields(), // 表单项的数组 | |
| 237 | + ...this.form // 表单名等 | |
| 238 | + } | |
| 239 | + // 修改的提交 | |
| 240 | + if (this.form.id != null) { | |
| 241 | + updateForm(form).then(response => { | |
| 242 | + this.msgSuccess("修改成功"); | |
| 243 | + this.close() | |
| 244 | + }); | |
| 245 | + return; | |
| 246 | + } | |
| 247 | + // 添加的提交 | |
| 248 | + createForm(form).then(response => { | |
| 249 | + this.msgSuccess("新增成功"); | |
| 250 | + this.close() | |
| 251 | + }); | |
| 252 | + }); | |
| 253 | + }, | |
| 254 | + /** 关闭按钮 */ | |
| 255 | + close() { | |
| 256 | + this.$store.dispatch("tagsView/delView", this.$route); | |
| 257 | + this.$router.push({ path: "/bpm/manager/form", query: { t: Date.now()}}) | |
| 258 | + }, | |
| 259 | + encodeFields() { | |
| 260 | + const fields = [] | |
| 261 | + this.drawingList.forEach(item => { | |
| 262 | + fields.push(JSON.stringify(item)) | |
| 263 | + }) | |
| 264 | + return fields | |
| 265 | + }, | |
| 266 | + decodeFields(fields) { | |
| 267 | + const drawingList = [] | |
| 268 | + fields.forEach(item => { | |
| 269 | + drawingList.push(JSON.parse(item)) | |
| 270 | + }) | |
| 271 | + return drawingList | |
| 272 | + }, | |
| 205 | 273 | empty() { |
| 206 | 274 | this.$confirm('确定要清空所有组件吗?', '提示', { type: 'warning' }).then( |
| 207 | 275 | () => { | ... | ... |
yudao-admin-ui/src/views/bpm/form/index.vue
| ... | ... | @@ -30,7 +30,6 @@ |
| 30 | 30 | <span>{{ getDictDataLabel(DICT_TYPE.SYS_COMMON_STATUS, scope.row.status) }}</span> |
| 31 | 31 | </template> |
| 32 | 32 | </el-table-column> |
| 33 | - <el-table-column label="表单配置" align="center" prop="fields" /> | |
| 34 | 33 | <el-table-column label="备注" align="center" prop="remark" /> |
| 35 | 34 | <el-table-column label="创建时间" align="center" prop="createTime" width="180"> |
| 36 | 35 | <template slot-scope="scope"> |
| ... | ... | @@ -49,36 +48,11 @@ |
| 49 | 48 | <!-- 分页组件 --> |
| 50 | 49 | <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" |
| 51 | 50 | @pagination="getList"/> |
| 52 | - | |
| 53 | - <!-- 对话框(添加 / 修改) --> | |
| 54 | - <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> | |
| 55 | - <el-form ref="form" :model="form" :rules="rules" label-width="80px"> | |
| 56 | - <el-form-item label="表单名" prop="name"> | |
| 57 | - <el-input v-model="form.name" placeholder="请输入表单名" /> | |
| 58 | - </el-form-item> | |
| 59 | - <el-form-item label="开启状态" prop="status"> | |
| 60 | - <el-radio-group v-model="form.status"> | |
| 61 | - <el-radio v-for="dict in this.getDictDatas(DICT_TYPE.SYS_COMMON_STATUS)" | |
| 62 | - :key="dict.value" :label="parseInt(dict.value)">{{dict.label}}</el-radio> | |
| 63 | - </el-radio-group> | |
| 64 | - </el-form-item> | |
| 65 | - <el-form-item label="表单配置" prop="fields"> | |
| 66 | - <el-input v-model="form.fields" placeholder="请输入表单配置" /> | |
| 67 | - </el-form-item> | |
| 68 | - <el-form-item label="备注" prop="remark"> | |
| 69 | - <el-input v-model="form.remark" placeholder="请输入备注" /> | |
| 70 | - </el-form-item> | |
| 71 | - </el-form> | |
| 72 | - <div slot="footer" class="dialog-footer"> | |
| 73 | - <el-button type="primary" @click="submitForm">确 定</el-button> | |
| 74 | - <el-button @click="cancel">取 消</el-button> | |
| 75 | - </div> | |
| 76 | - </el-dialog> | |
| 77 | 51 | </div> |
| 78 | 52 | </template> |
| 79 | 53 | |
| 80 | 54 | <script> |
| 81 | -import { createForm, updateForm, deleteForm, getForm, getFormPage, exportFormExcel } from "@/api/bpm/form"; | |
| 55 | +import { deleteForm, getFormPage} from "@/api/bpm/form"; | |
| 82 | 56 | |
| 83 | 57 | export default { |
| 84 | 58 | name: "Form", |
| ... | ... | @@ -94,24 +68,12 @@ export default { |
| 94 | 68 | total: 0, |
| 95 | 69 | // 工作流的列表 |
| 96 | 70 | list: [], |
| 97 | - // 弹出层标题 | |
| 98 | - title: "", | |
| 99 | - // 是否显示弹出层 | |
| 100 | - open: false, | |
| 101 | 71 | // 查询参数 |
| 102 | 72 | queryParams: { |
| 103 | 73 | pageNo: 1, |
| 104 | 74 | pageSize: 10, |
| 105 | 75 | name: null, |
| 106 | 76 | }, |
| 107 | - // 表单参数 | |
| 108 | - form: {}, | |
| 109 | - // 表单校验 | |
| 110 | - rules: { | |
| 111 | - name: [{ required: true, message: "表单名不能为空", trigger: "blur" }], | |
| 112 | - status: [{ required: true, message: "开启状态不能为空", trigger: "blur" }], | |
| 113 | - fields: [{ required: true, message: "表单配置不能为空", trigger: "blur" }], | |
| 114 | - } | |
| 115 | 77 | }; |
| 116 | 78 | }, |
| 117 | 79 | created() { |
| ... | ... | @@ -130,22 +92,6 @@ export default { |
| 130 | 92 | this.loading = false; |
| 131 | 93 | }); |
| 132 | 94 | }, |
| 133 | - /** 取消按钮 */ | |
| 134 | - cancel() { | |
| 135 | - this.open = false; | |
| 136 | - this.reset(); | |
| 137 | - }, | |
| 138 | - /** 表单重置 */ | |
| 139 | - reset() { | |
| 140 | - this.form = { | |
| 141 | - id: undefined, | |
| 142 | - name: undefined, | |
| 143 | - status: undefined, | |
| 144 | - fields: undefined, | |
| 145 | - remark: undefined, | |
| 146 | - }; | |
| 147 | - this.resetForm("form"); | |
| 148 | - }, | |
| 149 | 95 | /** 搜索按钮操作 */ |
| 150 | 96 | handleQuery() { |
| 151 | 97 | this.queryParams.pageNo = 1; |
| ... | ... | @@ -158,41 +104,17 @@ export default { |
| 158 | 104 | }, |
| 159 | 105 | /** 新增按钮操作 */ |
| 160 | 106 | handleAdd() { |
| 161 | - this.reset(); | |
| 162 | - this.open = true; | |
| 163 | - this.title = "添加工作流的"; | |
| 107 | + this.$router.push({ | |
| 108 | + path:"/bpm/manager/form/edit" | |
| 109 | + }); | |
| 164 | 110 | }, |
| 165 | 111 | /** 修改按钮操作 */ |
| 166 | 112 | handleUpdate(row) { |
| 167 | - this.reset(); | |
| 168 | - const id = row.id; | |
| 169 | - getForm(id).then(response => { | |
| 170 | - this.form = response.data; | |
| 171 | - this.open = true; | |
| 172 | - this.title = "修改工作流的"; | |
| 173 | - }); | |
| 174 | - }, | |
| 175 | - /** 提交按钮 */ | |
| 176 | - submitForm() { | |
| 177 | - this.$refs["form"].validate(valid => { | |
| 178 | - if (!valid) { | |
| 179 | - return; | |
| 180 | - } | |
| 181 | - // 修改的提交 | |
| 182 | - if (this.form.id != null) { | |
| 183 | - updateForm(this.form).then(response => { | |
| 184 | - this.msgSuccess("修改成功"); | |
| 185 | - this.open = false; | |
| 186 | - this.getList(); | |
| 187 | - }); | |
| 188 | - return; | |
| 113 | + this.$router.push({ | |
| 114 | + path:"/bpm/manager/form/edit", | |
| 115 | + query:{ | |
| 116 | + formId: row.id | |
| 189 | 117 | } |
| 190 | - // 添加的提交 | |
| 191 | - createForm(this.form).then(response => { | |
| 192 | - this.msgSuccess("新增成功"); | |
| 193 | - this.open = false; | |
| 194 | - this.getList(); | |
| 195 | - }); | |
| 196 | 118 | }); |
| 197 | 119 | }, |
| 198 | 120 | /** 删除按钮操作 */ | ... | ... |
yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/util/RandomUtils.java
| ... | ... | @@ -31,6 +31,14 @@ public class RandomUtils { |
| 31 | 31 | // 字符串 |
| 32 | 32 | PODAM_FACTORY.getStrategy().addOrReplaceTypeManufacturer(String.class, |
| 33 | 33 | (dataProviderStrategy, attributeMetadata, map) -> randomString()); |
| 34 | + // Integer | |
| 35 | + PODAM_FACTORY.getStrategy().addOrReplaceTypeManufacturer(Integer.class, (dataProviderStrategy, attributeMetadata, map) -> { | |
| 36 | + // 如果是 status 的字段,返回 0 或 1 | |
| 37 | + if (attributeMetadata.getAttributeName().equals("status")) { | |
| 38 | + return RandomUtil.randomEle(CommonStatusEnum.values()).getStatus(); | |
| 39 | + } | |
| 40 | + return RandomUtil.randomInt(); | |
| 41 | + }); | |
| 34 | 42 | // Boolean |
| 35 | 43 | PODAM_FACTORY.getStrategy().addOrReplaceTypeManufacturer(Boolean.class, (dataProviderStrategy, attributeMetadata, map) -> { |
| 36 | 44 | // 如果是 deleted 的字段,返回非删除 | ... | ... |