完善表单

This commit is contained in:
jinqiming 2021-11-23 19:09:35 +08:00
parent aca10c148a
commit df656f3df8
36 changed files with 1049 additions and 310 deletions

View File

@ -1,6 +1,7 @@
package com.snow.from.controller;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
@ -11,7 +12,6 @@ import com.snow.from.domain.SysFormDataRecord;
import com.snow.from.domain.SysFormField;
import com.snow.from.domain.SysFormInstance;
import com.snow.from.domain.request.FormFieldRequest;
import com.snow.from.domain.request.FormRecordRequest;
import com.snow.from.domain.request.FormRequest;
import com.snow.from.service.impl.SysFormDataRecordServiceImpl;
import com.snow.from.service.impl.SysFormFieldServiceImpl;
@ -79,18 +79,24 @@ public class FormController {
@ResponseBody
@Transactional(rollbackFor = Exception.class)
public AjaxResult saveForm(FormRequest formRequest){
log.info("=====>{}", JSON.toJSONString(formRequest));
log.info("@@保存设计的表单前端传入的数据:{}", JSON.toJSONString(formRequest));
String formData = formRequest.getFormData();
if(StrUtil.isBlank(formData)){
return AjaxResult.error("还没有创建组件呢!");
}
if(StringUtils.isEmpty(formRequest.getFormId())){
return AjaxResult.error("表单id必填项");
}
if(StringUtils.isEmpty(formRequest.getFormName())){
return AjaxResult.error("表单名称必填项");
}
SysFormInstance sysFormInstanceCode = sysFormInstanceService.selectSysFormInstanceByFormCode(formRequest.getFormId());
if(StringUtils.isNotNull(sysFormInstanceCode)){
return AjaxResult.error(String.format("表单编号:%已存在",formRequest.getFormId()));
return AjaxResult.error(StrUtil.format("表单编号:{}已存在",formRequest.getFormId()));
}
SysFormInstance sysFormInstanceName = sysFormInstanceService.selectSysFormInstanceByFormName(formRequest.getFormName());
if(StringUtils.isNotNull(sysFormInstanceName)){
return AjaxResult.error(String.format("表单名称:%已存在",formRequest.getFormName()));
return AjaxResult.error(StrUtil.format("表单名称:{}已存在",formRequest.getFormName()));
}
//保存主表数据
SysFormInstance sysFormInstance=new SysFormInstance();
@ -125,12 +131,14 @@ public class FormController {
@PostMapping("/form/saveFormRecord")
@ResponseBody
public AjaxResult saveFormRecord(@RequestParam String formId ,
@RequestParam String formData ){
@RequestParam String formData,
@RequestParam String formField){
Long userId = ShiroUtils.getUserId();
SysFormDataRecord sysFormDataRecord=new SysFormDataRecord();
sysFormDataRecord.setBelongUserId(String.valueOf(userId));
sysFormDataRecord.setFormData(formData);
sysFormDataRecord.setFormId(formId);
sysFormDataRecord.setFormField(formField);
sysFormDataRecord.setCreateBy(String.valueOf(userId));
//获取最大版本号
Integer maxVersion = sysFormDataRecordService.getMaxVersionByUsrId(userId);
@ -152,10 +160,11 @@ public class FormController {
SysFormInstance sysFormInstance = sysFormInstanceService.selectSysFormInstanceById(Long.valueOf(sysFormDataRecord.getFormId()));
map.put("id",id);
map.put("name",sysFormInstance.getFormName());
map.put("createTime", DateUtil.formatDateTime(sysFormInstance.getCreateTime()));
map.put("createTime",DateUtil.formatDateTime(sysFormInstance.getCreateTime()));
return "formDetail";
}
/**
* 表单详情
* @param id 表单记录id

View File

@ -1,123 +0,0 @@
package com.snow.from.controller;
import com.snow.common.annotation.Log;
import com.snow.common.core.controller.BaseController;
import com.snow.common.core.domain.AjaxResult;
import com.snow.common.core.page.TableDataInfo;
import com.snow.common.enums.BusinessType;
import com.snow.common.utils.poi.ExcelUtil;
import com.snow.from.domain.SysFormField;
import com.snow.from.service.ISysFormFieldService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 单字段Controller
*
* @author 没用的阿吉
* @date 2021-03-21
*/
@Controller
@RequestMapping("/system/field")
public class SysFormFieldController extends BaseController
{
private String prefix = "system/field";
@Autowired
private ISysFormFieldService sysFormFieldService;
@RequiresPermissions("system:field:view")
@GetMapping()
public String field()
{
return prefix + "/field";
}
/**
* 查询单字段列表
*/
@RequiresPermissions("system:field:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(SysFormField sysFormField)
{
startPage();
List<SysFormField> list = sysFormFieldService.selectSysFormFieldList(sysFormField);
return getDataTable(list);
}
/**
* 导出单字段列表
*/
@RequiresPermissions("system:field:export")
@Log(title = "单字段", businessType = BusinessType.EXPORT)
@PostMapping("/export")
@ResponseBody
public AjaxResult export(SysFormField sysFormField)
{
List<SysFormField> list = sysFormFieldService.selectSysFormFieldList(sysFormField);
ExcelUtil<SysFormField> util = new ExcelUtil<SysFormField>(SysFormField.class);
return util.exportExcel(list, "field");
}
/**
* 新增单字段
*/
@GetMapping("/add")
public String add()
{
return prefix + "/add";
}
/**
* 新增保存单字段
*/
@RequiresPermissions("system:field:add")
@Log(title = "单字段", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(SysFormField sysFormField)
{
return toAjax(sysFormFieldService.insertSysFormField(sysFormField));
}
/**
* 修改单字段
*/
@GetMapping("/edit/{id}")
public String edit(@PathVariable("id") Long id, ModelMap mmap)
{
SysFormField sysFormField = sysFormFieldService.selectSysFormFieldById(id);
mmap.put("sysFormField", sysFormField);
return prefix + "/edit";
}
/**
* 修改保存单字段
*/
@RequiresPermissions("system:field:edit")
@Log(title = "单字段", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(SysFormField sysFormField)
{
return toAjax(sysFormFieldService.updateSysFormField(sysFormField));
}
/**
* 删除单字段
*/
@RequiresPermissions("system:field:remove")
@Log(title = "单字段", businessType = BusinessType.DELETE)
@PostMapping( "/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
return toAjax(sysFormFieldService.deleteSysFormFieldByIds(ids));
}
}

View File

@ -1,18 +1,25 @@
package com.snow.from.controller;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.snow.common.annotation.Log;
import com.snow.common.core.controller.BaseController;
import com.snow.common.core.domain.AjaxResult;
import com.snow.common.core.page.TableDataInfo;
import com.snow.common.core.text.Convert;
import com.snow.common.enums.BusinessType;
import com.snow.common.utils.StringUtils;
import com.snow.common.utils.poi.ExcelUtil;
import com.snow.framework.util.ShiroUtils;
import com.snow.from.domain.SysFormDataRecord;
import com.snow.from.domain.SysFormInstance;
import com.snow.from.service.ISysFormFieldService;
import com.snow.from.domain.response.FormDataRecordResponse;
import com.snow.from.domain.response.FormInstanceResponse;
import com.snow.from.service.ISysFormInstanceService;
import com.snow.from.service.impl.SysFormDataRecordServiceImpl;
import com.snow.system.domain.SysUser;
import com.snow.system.service.impl.SysUserServiceImpl;
import org.apache.commons.compress.utils.Lists;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@ -39,11 +46,13 @@ public class SysFormInstanceController extends BaseController
@Autowired
private SysFormDataRecordServiceImpl sysFormDataRecordService;
@Autowired
private SysUserServiceImpl sysUserService;
@RequiresPermissions("system:instance:view")
@GetMapping()
public String instance()
{
public String instance() {
return prefix + "/instance";
}
@ -53,30 +62,16 @@ public class SysFormInstanceController extends BaseController
@RequiresPermissions("system:instance:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(SysFormInstance sysFormInstance)
{
public TableDataInfo list(SysFormInstance sysFormInstance) {
startPage();
if(!ShiroUtils.isAdmin()){
Long userId = ShiroUtils.getUserId();
sysFormInstance.setCreateBy(String.valueOf(userId));
}
List<SysFormInstance> list = sysFormInstanceService.selectSysFormInstanceList(sysFormInstance);
return getDataTable(list);
return getDataTable(warpSysFormInstanceRecord(list));
}
/**
* 导出单实例列表
*/
@RequiresPermissions("system:instance:export")
@Log(title = "单实例", businessType = BusinessType.EXPORT)
@PostMapping("/export")
@ResponseBody
public AjaxResult export(SysFormInstance sysFormInstance)
{
List<SysFormInstance> list = sysFormInstanceService.selectSysFormInstanceList(sysFormInstance);
ExcelUtil<SysFormInstance> util = new ExcelUtil<SysFormInstance>(SysFormInstance.class);
return util.exportExcel(list, "instance");
}
/**
* 预览
@ -100,33 +95,12 @@ public class SysFormInstanceController extends BaseController
SysFormInstance sysFormInstance = sysFormInstanceService.selectSysFormInstanceById(formId);
return AjaxResult.success(sysFormInstance.getFromContentHtml());
}
/**
* 新增单实例
*/
@GetMapping("/add")
public String add()
{
return prefix + "/add";
}
/**
* 新增保存单实例
*/
@RequiresPermissions("system:instance:add")
@Log(title = "单实例", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(SysFormInstance sysFormInstance)
{
return toAjax(sysFormInstanceService.insertSysFormInstance(sysFormInstance));
}
/**
* 修改单实例
*/
@GetMapping("/edit/{id}")
public String edit(@PathVariable("id") Long id, ModelMap mmap)
{
public String edit(@PathVariable("id") Long id, ModelMap mmap) {
SysFormInstance sysFormInstance = sysFormInstanceService.selectSysFormInstanceById(id);
mmap.put("sysFormInstance", sysFormInstance);
return prefix + "/edit";
@ -139,18 +113,27 @@ public class SysFormInstanceController extends BaseController
@Log(title = "单实例", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(SysFormInstance sysFormInstance)
{
SysFormInstance sysFormInstanceName = sysFormInstanceService.selectSysFormInstanceByFormCode(sysFormInstance.getFormName());
public AjaxResult editSave(SysFormInstance sysFormInstance) {
SysFormInstance sysFormInstanceName = sysFormInstanceService.selectSysFormInstanceByFormName(sysFormInstance.getFormName());
SysFormInstance sysFormInstanceCode = sysFormInstanceService.selectSysFormInstanceByFormCode(sysFormInstance.getFormName());
if(StringUtils.isNotNull(sysFormInstanceName)&&!sysFormInstanceName.getFormName().equals(sysFormInstance.getFormName())){
return AjaxResult.error(String.format("表单名称:%已存在",sysFormInstance.getFormName()));
return AjaxResult.error(StrUtil.format("表单名称{}已存在",sysFormInstance.getFormName()));
}
if(StringUtils.isNotNull(sysFormInstanceCode)&&!sysFormInstanceCode.getFormCode().equals(sysFormInstance.getFormCode())){
return AjaxResult.error(StrUtil.format("表单名称{}已存在",sysFormInstance.getFormCode()));
}
return toAjax(sysFormInstanceService.updateSysFormInstance(sysFormInstance));
}
/**
* 跳转表单记录
* @param id 记录id
* @param mmap 传给前端的数据
* @return 跳转的页面
*/
@RequiresPermissions("system:record:view")
@GetMapping("/formRecord")
public String record(@RequestParam Long id,ModelMap mmap)
public String formRecord(@RequestParam Long id,ModelMap mmap)
{
mmap.put("id",id);
return prefix + "/record";
@ -166,9 +149,21 @@ public class SysFormInstanceController extends BaseController
{
startPage();
List<SysFormDataRecord> list = sysFormDataRecordService.selectSysFormDataRecordList(sysFormDataRecord);
return getDataTable(list);
return getDataTable(warpSysFormDataRecord(list));
}
/**
* 删除表单记录
* @param ids 前端传入的id
* @return 返回是否成功
*/
@RequiresPermissions("system:record:remove")
@Log(title = "表单记录", businessType = BusinessType.DELETE)
@PostMapping( "/removeRecord")
@ResponseBody
public AjaxResult removeRecord(String ids) {
return toAjax(sysFormDataRecordService.deleteSysFormDataRecordByIds(ids));
}
/**
* 删除单实例
@ -177,8 +172,54 @@ public class SysFormInstanceController extends BaseController
@Log(title = "单实例", businessType = BusinessType.DELETE)
@PostMapping( "/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
public AjaxResult remove(String ids) {
SysFormDataRecord sysFormDataRecord = new SysFormDataRecord();
sysFormDataRecord.setFormIdList(Convert.toStrArray(ids));
List<SysFormDataRecord> sysFormDataRecords = sysFormDataRecordService.selectSysFormDataRecordList(sysFormDataRecord);
if(CollUtil.isNotEmpty(sysFormDataRecords)){
return AjaxResult.error("该表单已被填写,暂不能删除");
}
return toAjax(sysFormInstanceService.deleteSysFormInstanceByIds(ids));
}
/**
* 组装参数
* @param list 传入需要组装的参数list
*/
private List<FormDataRecordResponse> warpSysFormDataRecord(List<SysFormDataRecord> list ){
List<FormDataRecordResponse> formDataRecordResponseList= Lists.newArrayList();
if(CollUtil.isEmpty(list)){
return formDataRecordResponseList;
}
list.forEach(t->{
SysFormInstance sysFormInstance = sysFormInstanceService.selectSysFormInstanceById(Long.valueOf(t.getFormId()));
FormDataRecordResponse formDataRecordResponse =BeanUtil.copyProperties(t,FormDataRecordResponse.class);
SysUser sysUser = sysUserService.selectUserById(Long.parseLong(t.getBelongUserId()));
formDataRecordResponse.setFormName(sysFormInstance.getFormName());
formDataRecordResponse.setBelongUserName(sysUser.getUserName());
formDataRecordResponseList.add(formDataRecordResponse);
});
return formDataRecordResponseList;
}
/**
* 组装返回流程实例
* @param list 传入list
* @return 组装后的数据
*/
private List<FormInstanceResponse> warpSysFormInstanceRecord(List<SysFormInstance> list ){
List<FormInstanceResponse> formInstanceResponseList=Lists.newArrayList();
if(CollUtil.isEmpty(list)){
return formInstanceResponseList;
}
list.forEach(t->{
FormInstanceResponse formInstanceResponse = BeanUtil.copyProperties(t, FormInstanceResponse.class);
SysUser sysUser = sysUserService.selectUserById(Long.valueOf(t.getCreateBy()));
formInstanceResponse.setCreateByName(sysUser.getUserName());
formInstanceResponseList.add(formInstanceResponse);
});
return formInstanceResponseList;
}
}

View File

@ -0,0 +1,27 @@
package com.snow.from.domain.Field;
import lombok.Data;
import java.io.Serializable;
/**
* @author qimingjin
* @Title:
* @Description:
* @date 2021/11/23 16:32
*/
@Data
public class BaseField implements Serializable {
private static final long serialVersionUID = -6876233190306889953L;
private String id;
private String index;
private String label;
private String tag;
private String tagIcon;
}

View File

@ -0,0 +1,62 @@
package com.snow.from.domain.Field;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @author qimingjin
* @Title: 复选框
* @Description:
* @date 2021/11/23 17:00
*/
@Data
public class CheckboxField extends BaseField implements Serializable {
private static final long serialVersionUID = -4033182714436591774L;
/**
* 宽度
*/
private String labelWidth;
/**
* 是否只读
*/
private String disabled;
/**
* 是否必填
*/
private String required;
/**
* 帮助文档
*/
private String document;
/**
* 数据类型
*/
private String datasourceType;
/**
* 远程url
*/
private String remoteUrl;
/**
* 远程方法
*/
private String remoteMethod;
/**
* 映射到text
*/
private String remoteOptionText;
/**
* 映射到value
*/
private String remoteOptionValue;
/**
* 下拉框选项
*/
private List<OptionsField> options;
}

View File

@ -0,0 +1,54 @@
package com.snow.from.domain.Field;
import lombok.Data;
import java.io.Serializable;
/**
* @author qimingjin
* @Title: cron表达式
* @Description:
* @date 2021/11/23 17:16
*/
@Data
public class CronField extends BaseField implements Serializable {
private static final long serialVersionUID = -8279586363040232466L;
/**
* 宽度
*/
private String labelWidth;
/**
* 宽度百分比
*/
private String width;
/**
* 默认值
*/
private String defaultValue;
/**
* placeholder
*/
private String placeholder;
/**
* cronUrl
*/
private String cronUrl;
/**
* 是否只读
*/
private boolean disabled;
/**
* 是否必填
*/
private boolean required;
/**
* 帮助文档
*/
private String document;
}

View File

@ -0,0 +1,62 @@
package com.snow.from.domain.Field;
import lombok.Data;
import java.io.Serializable;
/**
* @author qimingjin
* @Title:
* @Description:
* @date 2021/11/23 17:22
*/
@Data
public class DateField extends BaseField implements Serializable {
private static final long serialVersionUID = 8453685053675545671L;
private String datetype;
private boolean rang;
private String dateformat;
private boolean isInitValue;
private String dataMaxValue;
private String dataMinValue;
private String trigger;
private String position;
private String theme;
private String mark;
private boolean showBottom;
private long zindex;
private boolean disabled;
private boolean required;
private String document;
/**
* 日期默认值
*/
private String dateDefaultValue;
private String labelWidth;
private String width;
private boolean clearable;
private String maxlength;
private String readonly;
}

View File

@ -0,0 +1,61 @@
package com.snow.from.domain.Field;
import lombok.Data;
import java.io.Serializable;
/**
* @author qimingjin
* @Title:
* @Description:
* @date 2021/11/23 17:27
*/
@Data
public class DateRangeField extends BaseField implements Serializable {
private static final long serialVersionUID = -2230998568274724840L;
private String datetype;
private boolean rang;
private String dateformat;
private boolean isInitValue;
private String dataMaxValue;
private String dataMinValue;
private String trigger;
private String position;
private String theme;
private String mark;
private boolean showBottom;
private long zindex;
private boolean disabled;
private boolean required;
private String document;
/**
* 日期默认值
*/
private String dateRangeDefaultValue;
private String labelWidth;
private String width;
private boolean clearable;
private String maxlength;
private String readonly;
}

View File

@ -0,0 +1,24 @@
package com.snow.from.domain.Field;
import lombok.Data;
import java.io.Serializable;
/**
* @author qimingjin
* @Title:
* @Description:
* @date 2021/11/23 17:36
*/
@Data
public class FileField extends BaseField implements Serializable {
private static final long serialVersionUID = 4329705307452431635L;
private String placeholder;
private String defaultValue;
private String width;
private boolean readonly;
private boolean disabled;
private boolean required;
private String document;
}

View File

@ -0,0 +1,41 @@
package com.snow.from.domain.Field;
import lombok.Data;
import java.io.Serializable;
/**
* @author qimingjin
* @Title: input输入框
* @Description:
* @date 2021/11/23 16:32
*/
@Data
public class InputField extends BaseField implements Serializable {
private static final long serialVersionUID = -2408672020265728342L;
private String placeholder;
private String defaultValue;
private String labelWidth;
private String width;
private boolean clearable;
private String maxlength;
private boolean showWordLimit;
private String readonly;
private String disabled;
private String required;
private String expression;
private String document;
}

View File

@ -0,0 +1,54 @@
package com.snow.from.domain.Field;
import lombok.Data;
import java.io.Serializable;
/**
* @author qimingjin
* @Title: 数字输入框
* @Description:
* @date 2021/11/23 17:11
*/
@Data
public class NumberInputField extends BaseField implements Serializable {
private static final long serialVersionUID = 8150151841198080579L;
/**
* 宽度
*/
private String labelWidth;
/**
* 宽度百分比
*/
private String width;
/**
* 开关值true-false-
*/
private Integer defaultValue;
/**
* 最大值
*/
private Integer maxValue;
/**
* 最小值
*/
private Integer minValue;
/**
* 步值
*/
private Integer stepValue;
/**
* 是否只读
*/
private boolean disabled;
/**
* 帮助文档
*/
private String document;
}

View File

@ -0,0 +1,29 @@
package com.snow.from.domain.Field;
import lombok.Data;
import java.io.Serializable;
/**
* @author qimingjin
* @Title:
* @Description:
* @date 2021/11/23 16:48
*/
@Data
public class OptionsField implements Serializable {
private static final long serialVersionUID = 975771972944583123L;
/**
* 文本
*/
private String text;
/**
*
*/
private String value;
/**
* 是否选中
*/
private boolean checked;
}

View File

@ -0,0 +1,40 @@
package com.snow.from.domain.Field;
import lombok.Data;
import java.io.Serializable;
/**
* @author qimingjin
* @Title: 密码输入框
* @Description:
* @date 2021/11/23 16:32
*/
@Data
public class PassWordField extends BaseField implements Serializable {
private static final long serialVersionUID = -4855880096097833482L;
private String placeholder;
private String defaultValue;
private String labelWidth;
private String width;
private String clearable;
private String maxlength;
private boolean showWordLimit;
private String readonly;
private String disabled;
private String required;
private String document;
}

View File

@ -0,0 +1,58 @@
package com.snow.from.domain.Field;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @author qimingjin
* @Title:
* @Description:
* @date 2021/11/23 16:53
*/
@Data
public class RadioField extends BaseField implements Serializable {
private static final long serialVersionUID = 7019933043982662705L;
/**
* 宽度
*/
private String labelWidth;
/**
* 是否只读
*/
private String disabled;
/**
* 帮助文档
*/
private String document;
/**
* 数据类型
*/
private String datasourceType;
/**
* 远程url
*/
private String remoteUrl;
/**
* 远程方法
*/
private String remoteMethod;
/**
* 映射到text
*/
private String remoteOptionText;
/**
* 映射到value
*/
private String remoteOptionValue;
/**
* 下拉框选项
*/
private List<OptionsField> options;
}

View File

@ -0,0 +1,31 @@
package com.snow.from.domain.Field;
import lombok.Data;
import java.io.Serializable;
/**
* @author qimingjin
* @Title: 评分
* @Description:
* @date 2021/11/23 17:30
*/
@Data
public class RateField extends BaseField implements Serializable {
private static final long serialVersionUID = -4822301448776454122L;
private int labelWidth;
/**
* 默认值
*/
private int defaultValue;
/**
* 星星长度
*/
private int rateLength;
private boolean half;
private boolean text;
private String theme;
private boolean showBottom;
private boolean readonly;
private String document;
}

View File

@ -0,0 +1,69 @@
package com.snow.from.domain.Field;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @author qimingjin
* @Title: 下拉框
* @Description:
* @date 2021/11/23 16:45
*/
@Data
public class SelectField extends BaseField implements Serializable {
private static final long serialVersionUID = -3434970624558260655L;
/**
* 宽度
*/
private String labelWidth;
/**
* 宽度百分比
*/
private String width;
/**
* 是否只读
*/
private String disabled;
/**
* 是否必填
*/
private String required;
/**
* 帮助文档
*/
private String document;
/**
* 数据类型
*/
private String datasourceType;
/**
* 远程url
*/
private String remoteUrl;
/**
* 远程方法
*/
private String remoteMethod;
/**
* 映射到text
*/
private String remoteOptionText;
/**
* 映射到value
*/
private String remoteOptionValue;
/**
* 表示对应的remoteOptionValue的值
*/
private String remoteDefaultValue;
/**
* 下拉框选项
*/
private List<OptionsField> options;
}

View File

@ -0,0 +1,45 @@
package com.snow.from.domain.Field;
import lombok.Data;
import java.io.Serializable;
/**
* @author qimingjin
* @Title: 签名组件
* @Description:
* @date 2021/11/23 17:13
*/
@Data
public class SignField extends BaseField implements Serializable {
private static final long serialVersionUID = 4503585715635964734L;
/**
* 宽度
*/
private String labelWidth;
/**
* 按钮值
*/
private String buttonVlaue;
/**
* 按钮icon
*/
private String buttonIcon;
/**
* data
*/
private String data;
/**
* 是否只读
*/
private boolean disabled;
/**
* 帮助文档
*/
private String document;
}

View File

@ -0,0 +1,54 @@
package com.snow.from.domain.Field;
import lombok.Data;
import java.io.Serializable;
/**
* @author qimingjin
* @Title: 滑块
* @Description:
* @date 2021/11/23 17:08
*/
@Data
public class SliderField extends BaseField implements Serializable {
private static final long serialVersionUID = -3032040915441717608L;
/**
* 宽度
*/
private String labelWidth;
/**
* 宽度百分比
*/
private String width;
/**
* 开关值true-false-
*/
private Integer defaultValue;
/**
* 最大值
*/
private Integer maxValue;
/**
* 最小值
*/
private Integer minValue;
/**
* 步值
*/
private Integer stepValue;
private boolean isInput;
/**
* 是否只读
*/
private boolean disabled;
/**
* 帮助文档
*/
private String document;
}

View File

@ -0,0 +1,40 @@
package com.snow.from.domain.Field;
import lombok.Data;
import java.io.Serializable;
/**
* @author qimingjin
* @Title: 开关
* @Description:
* @date 2021/11/23 17:02
*/
@Data
public class SwitchField extends BaseField implements Serializable {
private static final long serialVersionUID = 5405710592916631615L;
/**
* 宽度
*/
private String labelWidth;
/**
* 宽度百分比
*/
private String width;
/**
* 开关值true-false-
*/
private boolean switchValue;
private boolean showWordLimit;
/**
* 是否只读
*/
private boolean disabled;
/**
* 帮助文档
*/
private String document;
}

View File

@ -0,0 +1,24 @@
package com.snow.from.domain.Field;
import lombok.Data;
import java.io.Serializable;
/**
* @author qimingjin
* @Title:
* @Description:
* @date 2021/11/23 17:34
*/
@Data
public class TextareaField extends BaseField implements Serializable {
private static final long serialVersionUID = -2547979422890331700L;
private String placeholder;
private String defaultValue;
private String width;
private boolean readonly;
private boolean disabled;
private boolean required;
private String document;
}

View File

@ -1,42 +0,0 @@
package com.snow.from.domain;
import lombok.Data;
import java.io.Serializable;
/**
* @program: snow
* @description
* @author: 没用的阿吉
* @create: 2021-03-21 13:49
**/
@Data
public class FieldContentDTO implements Serializable {
private static final long serialVersionUID = 5539925619264110377L;
private String frame;
private String componentKey;
private String name;
private String title;
/**
* 组件属性
*/
private String componentProperties;
private String html;
private String[] children;
private Object ortumChildren;
private String script;
}

View File

@ -1,62 +0,0 @@
package com.snow.from.domain;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* @program: snow
* @description
* @author: 没用的阿吉
* @create: 2021-03-21 10:35
**/
@Data
public class FromInfoDTO implements Serializable {
private static final long serialVersionUID = -1727483907232851682L;
private String id;
/**
* 行id
*/
private String columnID;
/**
* 行名称
*/
private String columnName;
/**
* html内容
*/
private String contentHtml;
private String editor;
private Date editTime;
/**
* from表单code
*/
private String formCode;
/**
* from表单name
*/
private String formName;
/**
* 版本号
*/
private String version;
public static String ORTUM_JSON="ortumJson";
}

View File

@ -20,17 +20,28 @@ public class SysFormDataRecord extends BaseEntity
/** 表单定义code */
private String formId;
/**
* 表单id数组
*/
private String[] formIdList;
/**
* 表单内容
*/
private String formData;
/**
* 表单字典
*/
private String formField;
/** 表单url */
private String formUrl;
/** 表单操作人所属人id */
private String belongUserId;
/** 版本号 */
private Integer version;
}

View File

@ -21,4 +21,6 @@ public class FormRecordRequest implements Serializable {
@NotBlank(message = "表单数据不能为空")
private String formData;
private String formField;
}

View File

@ -0,0 +1,50 @@
package com.snow.from.domain.response;
import com.snow.common.core.domain.BaseEntity;
import lombok.Data;
import java.io.Serializable;
/**
* @author qimingjin
* @Title:
* @Description:
* @date 2021/11/23 9:26
*/
@Data
public class FormDataRecordResponse extends BaseEntity implements Serializable {
private static final long serialVersionUID = 5569500779097541889L;
/** 主键ID */
private Integer id;
/** 表单定义code */
private String formId;
/**
* 表单名称
*/
private String formName;
/**
* 表单内容
*/
private String formData;
/**
* 表单字典
*/
private String formField;
/** 表单url */
private String formUrl;
/** 表单操作人所属人id */
private String belongUserId;
/** 表单操作人所属人名称 */
private String belongUserName;
/** 版本号 */
private Integer version;
}

View File

@ -0,0 +1,40 @@
package com.snow.from.domain.response;
import com.snow.common.core.domain.BaseEntity;
import lombok.Data;
import java.io.Serializable;
/**
* @author qimingjin
* @Title: 表单实例返回
* @Description:
* @date 2021/11/23 10:45
*/
@Data
public class FormInstanceResponse extends BaseEntity implements Serializable {
private static final long serialVersionUID = 3712210141375254841L;
/** 主键ID */
private Long id;
/** 表单定义code */
private String formCode;
/** 表单名称 */
private String formName;
/**
* 表单内容
*/
private String fromContentHtml;
/** 表单url */
private String fromUrl;
/**
* 创建人名称
*/
private String createByName;
}

View File

@ -88,8 +88,7 @@ public class SysFormInstanceServiceImpl implements ISysFormInstanceService
* @return 结果
*/
@Override
public int deleteSysFormInstanceByIds(String ids)
{
public int deleteSysFormInstanceByIds(String ids) {
return sysFormInstanceMapper.deleteSysFormInstanceByIds(Convert.toStrArray(ids));
}

View File

@ -8,6 +8,7 @@
<result property="id" column="id" />
<result property="formId" column="form_id" />
<result property="formData" column="form_data" />
<result property="formField" column="form_field" />
<result property="formUrl" column="form_url" />
<result property="belongUserId" column="belong_user_id" />
<result property="createBy" column="create_by" />
@ -18,7 +19,7 @@
</resultMap>
<sql id="selectSysFormDataRecordVo">
select id, form_id, form_data, form_url, belong_user_id, create_by, create_time, update_time, update_by, version from sys_form_data_record
select id, form_id, form_data, form_field,form_url, belong_user_id, create_by, create_time, update_time, update_by, version from sys_form_data_record
</sql>
<select id="selectSysFormDataRecordList" parameterType="SysFormDataRecord" resultMap="SysFormDataRecordResult">
@ -28,6 +29,12 @@
<if test="formData != null and formData != ''"> and form_data = #{formData}</if>
<if test="formUrl != null and formUrl != ''"> and form_url = #{formUrl}</if>
<if test="belongUserId != null and belongUserId != ''"> and belong_user_id = #{belongUserId}</if>
<if test="formIdList != null">
and form_id in
<foreach item="formId" collection="array" open="(" separator="," close=")">
#{formId}
</foreach>
</if>
<if test="version != null "> and version = #{version}</if>
</where>
</select>
@ -37,6 +44,7 @@
where id = #{id}
</select>
<select id="getMaxVersionByUsrId" parameterType="Long" resultType="integer">
select max(version) from sys_form_data_record
where belong_user_id = #{belongUserId}
@ -47,6 +55,7 @@
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="formId != null and formId != ''">form_id,</if>
<if test="formData != null">form_data,</if>
<if test="formField != null">form_field,</if>
<if test="formUrl != null and formUrl != ''">form_url,</if>
<if test="belongUserId != null">belong_user_id,</if>
<if test="createBy != null">create_by,</if>
@ -58,6 +67,7 @@
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="formId != null and formId != ''">#{formId},</if>
<if test="formData != null">#{formData},</if>
<if test="formField != null">#{formField},</if>
<if test="formUrl != null and formUrl != ''">#{formUrl},</if>
<if test="belongUserId != null">#{belongUserId},</if>
<if test="createBy != null">#{createBy},</if>
@ -73,6 +83,7 @@
<trim prefix="SET" suffixOverrides=",">
<if test="formId != null and formId != ''">form_id = #{formId},</if>
<if test="formData != null">form_data = #{formData},</if>
<if test="formField != null">form_field=#{formField},</if>
<if test="formUrl != null and formUrl != ''">form_url = #{formUrl},</if>
<if test="belongUserId != null">belong_user_id = #{belongUserId},</if>
<if test="createBy != null">create_by = #{createBy},</if>

View File

@ -27,9 +27,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectSysFormInstanceList" parameterType="SysFormInstance" resultMap="SysFormInstanceResult">
<include refid="selectSysFormInstanceVo"/>
<where>
<if test="formCode != null and formCode != ''"> and form_code_ = #{formCode}</if>
<if test="formName != null and formName != ''"> and form_name_ = #{formName}</if>
<if test="fromUrl != null and fromUrl != ''"> and from_url_ = #{fromUrl}</if>
<if test="formCode != null and formCode != ''"> and form_code_ like concat('%', #{formCode}, '%')</if>
<if test="formName != null and formName != ''"> and form_name_ like concat('%', #{formName}, '%')</if>
<if test="rev != null "> and rev_ = #{rev}</if>
<if test="isDelete != null "> and is_delete = #{isDelete}</if>
<if test="tenantId != null and tenantId != ''"> and tenant_id_ = #{tenantId}</if>

View File

@ -224,7 +224,7 @@ layui.define(['layer'], function (exports) {
iconPicker: {
id:'-1',
index:'-1',
label: "图标选择器",
label: "图标选择器(暂无)",
tag: "iconPicker",
tagIcon: 'iconPicker',
labelWidth: 110,

View File

@ -121,8 +121,8 @@ layui.config({base: './ayq/modules/'}).define(['layer', 'laytpl', 'element', 'fo
}
, MOD_NAME = 'formPreview'
, ELEM = '.layui-form-designer'
, TPL_SUBMIT = ['<div class="layui-form-item">'
, '<div class="layui-input-block layui-col-md4 layui-col-md-offset5">'
, TPL_SUBMIT = ['<div class="layui-row">'
, '<div class="layui-input-block layui-col-md4 layui-col-md-offset8">'
, '<button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">提交</button>'
, '<button type="reset" class="layui-btn layui-btn-primary">重置</button>'
, '</div>'

View File

@ -13,13 +13,16 @@
<div >
<input type="hidden" name="id" id="id" th:value="${id}">
<div style="margin: 20px 20px;padding: 20px 20px;border: 1px solid #009688;">
<div style="margin-top: 20px">
<div style="margin-top: 20px" class="layui-row">
<h2 th:text="${name}" style="text-align: center"></h2>
</div>
<div style="margin-top: 20px" class="layui-col-md4 layui-col-md-offset4">
<span>填表时间:</span> <h5 th:text="${createTime}" style="text-align: center"></h5>
<div class="layui-row">
<div class="layui-col-md4 layui-col-md-offset8">
<h5>填表时间:[[${createTime}]]</h5>
</div>
</div>
<div id="testdemo" style="margin-top: 15px">
<br/>
<div id="testdemo" style="margin-top: 20px">
</div>
</div>

View File

@ -174,8 +174,30 @@
console.info("======>"+JSON.stringify(data))
var newData = render.getData();
var dataFrom=render.getFormData();
console.info("===dataFrom===>"+JSON.stringify(dataFrom))
$.each(newData,function(i,item){
item["defaultValue"]=dataFrom[item["id"]];
if(item["tag"]==="grid"){
var columns= item["columns"];
$.each(columns,function(j,items){
var list= items["list"];
$.each(list,function(k,newItem){
if(newItem["tag"]==="input"||item["tag"]==="textarea"||item["tag"]==="password"){
newItem["defaultValue"]=dataFrom[newItem["id"]];
}
if(newItem["tag"]==="date"){
newItem["dateDefaultValue"]=dataFrom[newItem["id"]];
}
});
});
}else {
if(item["tag"]==="input"||item["tag"]==="textarea"){
item["defaultValue"]=dataFrom[item["id"]];
}
if(item["tag"]==="date"){
item["dateDefaultValue"]=dataFrom[item["id"]];
}
}
});
// 再把数据提交到后台
var formId=$("#formId").val();
@ -184,6 +206,7 @@
type: "post",
dataType: "json",
data: {
"formField":JSON.stringify(dataFrom),
"formId":formId,
"formData":JSON.stringify(newData)
},

View File

@ -7,8 +7,9 @@
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-instance-edit" th:object="${sysFormInstance}">
<input name="id" th:field="*{id}" type="hidden">
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i>请注意: 表单修改目前只能修改基础属性</span>
<div class="form-group">
<label class="col-sm-3 control-label ">表单定义code</label>
<label class="col-sm-3 control-label ">表单code</label>
<div class="col-sm-8">
<input name="formCode" th:field="*{formCode}" class="form-control" type="text" disabled>
</div>

View File

@ -11,7 +11,7 @@
<div class="select-list">
<ul>
<li>
<label>code</label>
<label>表单ID</label>
<input type="text" name="formCode"/>
</li>
<li>
@ -52,7 +52,6 @@
$(function() {
var options = {
url: prefix + "/list",
createUrl: prefix + "/add",
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove",
modalName: "表单",
@ -66,13 +65,17 @@
},
{
field: 'formCode',
title: '表单定义code'
title: '表单ID'
},
{
field: 'formName',
title: '表单名称'
},
{
field: 'createByName',
title: '创建人'
},
{
title: '操作',
align: 'center',
formatter: function(value, row, index) {

View File

@ -13,7 +13,7 @@
<ul>
<li>
<label>版本号:</label>
<input type="text" name="version"/>
<input type="text" name="version" id="version"/>
</li>
<li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
@ -31,17 +31,12 @@
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
var editFlag = [[${@permission.hasPermi('system:record:edit')}]];
var removeFlag = [[${@permission.hasPermi('system:record:remove')}]];
var prefix = ctx + "/from/instance";
$(function() {
var options = {
url: "/from/instance/recordList",
createUrl: prefix + "/add",
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove",
exportUrl: prefix + "/export",
removeUrl: "/from/instance/removeRecord",
queryParams:queryParams,
modalName: "单数据记录",
columns: [{
@ -56,9 +51,13 @@
field: 'formId',
title: '表单ID'
},
{
field: 'formName',
title: '表单名称'
},
{
field: 'belongUserId',
title: '表单操作人所属人id'
field: 'belongUserName',
title: '填写人'
},
{
field: 'version',