完善表单

This commit is contained in:
jinqiming 2021-11-19 17:58:06 +08:00
parent c52bf46748
commit d367847719
10 changed files with 471 additions and 594 deletions

View File

@ -6,7 +6,7 @@ spring:
druid:
# 主库数据源
master:
url: jdbc:mysql://rm-bp1j1554xv1qs04295o.mysql.rds.aliyuncs.com:3306/snow?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8
url: jdbc:mysql://rm-bp1j1554xv1qs04295o.mysql.rds.aliyuncs.com:3306/snow-dev?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8
username: cloud_root
password: VXTvn41xh0+92G8KAdvjQct2ZZ+IhRGm2MqTA38kayy48QwO/vSbTnTeTMVQ6s3axHWhQi9l1ZD5dyJUOenyNA==
# 从库数据源

View File

@ -0,0 +1,39 @@
package com.snow.common.enums;
/**
* @author qimingjin
* @Title: 表单类型
* @Description:
* @date 2021/11/19 15:34
*/
public enum FormFieldTypeEnums {
input,
password,
textarea,
select,
radio,
CHECKBOX,
/**
* 开关
*/
SWITCH,
//滑块
SLIDER,
//日期
DATE,
//日期范围
dateRange,
//评分
rate,
//轮播图
carousel,
//颜色选择器
colorpicker,
//图片
image,
//文件
file;
}

View File

@ -1,26 +1,23 @@
package com.snow.from.controller;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.snow.common.core.domain.AjaxResult;
import com.snow.common.utils.StringUtils;
import com.snow.framework.util.ShiroUtils;
import com.snow.from.domain.FieldContentDTO;
import com.snow.from.domain.FromInfoDTO;
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.FormRequest;
import com.snow.from.service.impl.SysFormFieldServiceImpl;
import com.snow.from.service.impl.SysFormInstanceServiceImpl;
import com.snow.system.domain.SysUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;
@ -65,13 +62,17 @@ public class FormController {
return "/editorMenu";
}
/**
* 保存表单数据
* @param formRequest 表单参数
* @return 是否成功
*/
@PostMapping("/form/saveForm")
@ResponseBody
@Transactional(rollbackFor = Exception.class)
public AjaxResult saveForm(FormRequest formRequest){
log.info("=====>{}", JSON.toJSONString(formRequest));
String formData = formRequest.getFormData();
if(StrUtil.isBlank(formData)){
return AjaxResult.error("还没有创建组件呢!");
}
@ -83,6 +84,7 @@ public class FormController {
if(StringUtils.isNotNull(sysFormInstanceName)){
return AjaxResult.error(String.format("表单名称:%已存在",formRequest.getFormName()));
}
//保存主表数据
SysFormInstance sysFormInstance=new SysFormInstance();
sysFormInstance.setFormCode(formRequest.getFormId());
sysFormInstance.setFormName(formRequest.getFormName());
@ -91,18 +93,39 @@ public class FormController {
sysFormInstance.setCreateBy(String.valueOf(ShiroUtils.getUserId()));
sysFormInstance.setUpdateTime(new Date());
sysFormInstanceService.insertSysFormInstance(sysFormInstance);
List<FormFieldRequest> fieldContentDTOS = JSON.parseArray(formData, FormFieldRequest.class);
for (int i=0;i<fieldContentDTOS.size();i++){
SysFormField sysFormField=new SysFormField();
sysFormField.setFromId(sysFormInstance.getId());
sysFormField.setFieldKey(fieldContentDTOS.get(i).getId());
sysFormField.setFieldName(fieldContentDTOS.get(i).getLabel());
sysFormField.setFieldType(fieldContentDTOS.get(i).getTag());
sysFormField.setFieldHtml(JSON.parseArray(formData).getString(i));
sysFormField.setRev(sysFormInstance.getRev());
sysFormFieldService.insertSysFormField(sysFormField);
}
//保存子表数据
saveFormField(sysFormInstance.getId(),formData);
return AjaxResult.success();
}
/**
* 预览
* @return 预览页
*/
@GetMapping("/fromPreview")
public String fromPreview(@RequestParam Long id, ModelMap mmap) {
SysFormInstance sysFormInstance = sysFormInstanceService.selectSysFormInstanceById(id);
mmap.put("formId",id);
mmap.put("name",sysFormInstance.getFormName());
return "/fromPreview";
}
/**
* 构建子表数据
* @param formId 表单id
* @param formData 表单数据
*/
private void saveFormField(Long formId,String formData ){
List<FormFieldRequest> formFieldRequestList = JSON.parseArray(formData, FormFieldRequest.class);
for (int i=0;i<formFieldRequestList.size();i++){
FormFieldRequest formFieldRequest = formFieldRequestList.get(i);
SysFormField sysFormField = BeanUtil.copyProperties(formFieldRequest, SysFormField.class,"id");
sysFormField.setFromId(formId);
sysFormField.setFieldKey(formFieldRequest.getId());
sysFormField.setFieldName(formFieldRequest.getLabel());
sysFormField.setFieldType(formFieldRequest.getTag());
sysFormField.setFieldHtml(JSON.parseArray(formData).getString(i));
sysFormFieldService.insertSysFormField(sysFormField);
}
}
}

View File

@ -1,10 +1,5 @@
package com.snow.from.controller;
import cn.hutool.cache.CacheUtil;
import cn.hutool.cache.impl.TimedCache;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.collection.ListUtil;
import com.alibaba.fastjson.JSON;
import com.snow.common.annotation.Log;
import com.snow.common.core.controller.BaseController;
import com.snow.common.core.domain.AjaxResult;
@ -12,26 +7,16 @@ import com.snow.common.core.page.TableDataInfo;
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.FieldContentDTO;
import com.snow.from.domain.FromInfoDTO;
import com.snow.from.domain.SysFormField;
import com.snow.from.domain.SysFormInstance;
import com.snow.from.service.ISysFormFieldService;
import com.snow.from.service.ISysFormInstanceService;
import com.snow.system.domain.SysUser;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* 单实例Controller
@ -86,58 +71,6 @@ public class SysFormInstanceController extends BaseController
return util.exportExcel(list, "instance");
}
/**
*
* 保存表单数据
* @param fromInfoDTO
* @return
*/
@PostMapping("/saveFromInfo")
@ResponseBody
@Transactional
public AjaxResult saveFromInfo(@RequestBody FromInfoDTO fromInfoDTO)
{
SysUser sysUser = ShiroUtils.getSysUser();
String contentHtml = fromInfoDTO.getContentHtml();
Object ortumJson = JSON.parseObject(contentHtml).get(FromInfoDTO.ORTUM_JSON);
List<FieldContentDTO> fieldContentDTOS = JSON.parseArray(JSON.toJSONString(ortumJson), FieldContentDTO.class);
if(fieldContentDTOS.size()==0){
return AjaxResult.error("还没有创建组件呢!");
}
SysFormInstance sysFormInstanceCode = sysFormInstanceService.selectSysFormInstanceByFormCode(fromInfoDTO.getFormCode());
if(StringUtils.isNotNull(sysFormInstanceCode)){
return AjaxResult.error(String.format("表单编号:%已存在",fromInfoDTO.getFormCode()));
}
SysFormInstance sysFormInstanceName = sysFormInstanceService.selectSysFormInstanceByFormCode(fromInfoDTO.getColumnName());
if(StringUtils.isNotNull(sysFormInstanceName)){
return AjaxResult.error(String.format("表单名称:%已存在",fromInfoDTO.getFormName()));
}
SysFormInstance sysFormInstance=new SysFormInstance();
sysFormInstance.setFormCode(fromInfoDTO.getFormCode());
sysFormInstance.setFormName(fromInfoDTO.getFormName());
sysFormInstance.setRev(Long.parseLong(fromInfoDTO.getVersion()));
sysFormInstance.setFromContentHtml(contentHtml);
sysFormInstance.setCreateBy(sysUser.getUserName());
sysFormInstance.setUpdateTime(new Date());
sysFormInstanceService.insertSysFormInstance(sysFormInstance);
fieldContentDTOS.stream().forEach(t->{
SysFormField sysFormField=new SysFormField();
sysFormField.setFromId(sysFormInstance.getId());
sysFormField.setFieldKey(t.getName());
sysFormField.setFieldName(t.getTitle());
sysFormField.setFieldType(t.getComponentKey());
sysFormField.setFieldHtml(t.getHtml());
sysFormField.setRev(sysFormInstance.getRev());
//组件属性
sysFormField.setRemark(t.getComponentProperties());
sysFormFieldService.insertSysFormField(sysFormField);
});
return AjaxResult.success(fromInfoDTO);
}
/**
* 预览
* @return
@ -146,36 +79,19 @@ public class SysFormInstanceController extends BaseController
public String fromPreview(@PathVariable("id") Long id,ModelMap mmap)
{
mmap.put("formId",id);
return prefix+"/fromPreview";
return "/fromPreview";
}
/**
* 获取表单内容
* @param formId
* @return
*/
@GetMapping("/getFromInfo/{formId}")
@PostMapping("/getFromInfo")
@ResponseBody
public AjaxResult getFromInfo(@PathVariable("formId")Long formId)
public AjaxResult getFromInfo(@RequestParam Long formId)
{
FromInfoDTO fromInfoDTO=new FromInfoDTO();
SysFormInstance sysFormInstance = sysFormInstanceService.selectSysFormInstanceById(formId);
fromInfoDTO.setFormCode(sysFormInstance.getFormCode());
fromInfoDTO.setFormName(sysFormInstance.getFormName());
fromInfoDTO.setVersion(String.valueOf(sysFormInstance.getRev()));
fromInfoDTO.setId(String.valueOf(sysFormInstance.getId()));
SysFormField sysFormField=new SysFormField();
sysFormField.setFromId(formId);
List<SysFormField> sysFormFieldList = sysFormFieldService.selectSysFormFieldList(sysFormField);
if(CollectionUtil.isNotEmpty(sysFormFieldList)){
String columnID = sysFormFieldList.stream().map(SysFormField::getFieldKey).collect(Collectors.joining(","));
String columnName = sysFormFieldList.stream().map(SysFormField::getFieldName).collect(Collectors.joining(","));
fromInfoDTO.setColumnID(columnID);
fromInfoDTO.setColumnName(columnName);
fromInfoDTO.setContentHtml(sysFormInstance.getFromContentHtml());
fromInfoDTO.setEditor(sysFormInstance.getCreateBy());
fromInfoDTO.setEditTime(sysFormInstance.getUpdateTime());
}
return AjaxResult.success(fromInfoDTO);
return AjaxResult.success(sysFormInstance.getFromContentHtml());
}
/**
* 新增单实例

View File

@ -1,11 +1,7 @@
package com.snow.from.domain;
import com.snow.common.annotation.Excel;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.snow.common.core.domain.BaseEntity;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* 单字段对象 sys_form_field
@ -22,31 +18,71 @@ public class SysFormField extends BaseEntity
private Long id;
/** 字段标识 */
@Excel(name = "字段标识")
private String fieldKey;
/** 字段名称 */
@Excel(name = "字段名称")
private String fieldName;
/** 字段类型 */
@Excel(name = "字段类型")
private String fieldType;
/** 字段html */
@Excel(name = "字段html")
private String fieldHtml;
/**
* 字段placeholder
*/
private String placeholder;
/** 乐观锁版本号 */
@Excel(name = "乐观锁版本号")
private Long rev;
/**
* 宽度
*/
private double labelWidth;
/** 租户ID */
@Excel(name = "租户ID")
private String tenantId;
/**
* 宽度百分比
*/
private String width;
/**
* 最大长度
*/
private String maxlength;
/**
* 是否只读
*/
private boolean readonly;
/**
* 是否禁用
*/
private boolean disabled;
/**
* 是否必填
*/
private boolean required;
/**
* 默认值
*/
private String defaultValue;
/**
* 验证表达式
*/
private String expression;
/**
* 帮助文档
*/
private String document;
/**
* 可选项
*/
private String options;
/** 删除标识0--正常1--删除) */
@Excel(name = "删除标识", readConverterExp = "0=--正常1--删除")
private Long isDelete;
private Long fromId;

View File

@ -13,27 +13,80 @@ import java.io.Serializable;
@Data
public class FormFieldRequest implements Serializable {
private static final long serialVersionUID = 3395398845419106008L;
/**
* 字段表示
*/
private String id;
/**
* 字段name
*/
private String label;
/**
* 字段类型
*/
private String tag;
/**
* 字段类型
*/
private String tagIcon;
private boolean readonly;
/**
* 字段placeholder
*/
private String placeholder;
private Boolean disabled;
/**
* 宽度
*/
private double labelWidth;
private Boolean required;
/**
* 宽度百分比
*/
private String width;
/**
* 最大长度
*/
private String maxlength;
/**
* 是否只读
*/
private boolean readonly;
/**
* 是否禁用
*/
private boolean disabled;
/**
* 是否必填
*/
private boolean required;
/**
* 默认值
*/
private String defaultValue;
/**
* 验证表达式
*/
private String expression;
/**
* 帮助文档
*/
private String document;
/**
* 可选项
*/
private String options;
}

View File

@ -3,109 +3,152 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.snow.from.mapper.SysFormFieldMapper">
<resultMap type="SysFormField" id="SysFormFieldResult">
<result property="id" column="id_" />
<result property="fieldKey" column="field_key_" />
<result property="fieldName" column="field_name_" />
<result property="fieldType" column="field_type_" />
<result property="fieldHtml" column="field_html_" />
<result property="remark" column="remark_" />
<result property="id" column="id" />
<result property="fieldKey" column="field_key" />
<result property="fieldName" column="field_name" />
<result property="fieldType" column="field_type" />
<result property="options" column="options" />
<result property="document" column="document" />
<result property="expression" column="expression" />
<result property="defaultValue" column="defaultValue" />
<result property="required" column="required" />
<result property="disabled" column="disabled" />
<result property="readonly" column="readonly" />
<result property="maxlength" column="maxlength" />
<result property="width" column="width" />
<result property="labelWidth" column="label_width" />
<result property="placeholder" column="placeholder" />
<result property="fieldHtml" column="field_html" />
<result property="remark" column="remark" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
<result property="rev" column="rev_" />
<result property="tenantId" column="tenant_id_" />
<result property="isDelete" column="is_delete" />
<result property="fromId" column="from_id" />
</resultMap>
<sql id="selectSysFormFieldVo">
select id_, field_key_, field_name_, field_type_, from_id,field_html_, remark_, create_by, create_time, update_time, update_by, rev_, tenant_id_, is_delete from sys_form_field
select id, field_key, field_name, field_type, options, document, expression, defaultValue, required, disabled, readonly, maxlength, width, label_width, placeholder, field_html, remark, create_by, create_time, update_time, update_by, is_delete, from_id from sys_form_field
</sql>
<select id="selectSysFormFieldList" parameterType="SysFormField" resultMap="SysFormFieldResult">
<include refid="selectSysFormFieldVo"/>
<where>
<if test="fieldKey != null and fieldKey != ''"> and field_key_ = #{fieldKey}</if>
<if test="fieldName != null and fieldName != ''"> and field_name_ = #{fieldName}</if>
<if test="fieldType != null and fieldType != ''"> and field_type_ = #{fieldType}</if>
<if test="fieldHtml != null and fieldHtml != ''"> and field_html_ = #{fieldHtml}</if>
<if test="remark != null and remark != ''"> and remark_ = #{remark}</if>
<if test="rev != null "> and rev_ = #{rev}</if>
<if test="tenantId != null and tenantId != ''"> and tenant_id_ = #{tenantId}</if>
<where>
<if test="fieldKey != null and fieldKey != ''"> and field_key = #{fieldKey}</if>
<if test="fieldName != null and fieldName != ''"> and field_name like concat('%', #{fieldName}, '%')</if>
<if test="fieldType != null and fieldType != ''"> and field_type = #{fieldType}</if>
<if test="options != null and options != ''"> and options = #{options}</if>
<if test="document != null and document != ''"> and document = #{document}</if>
<if test="expression != null and expression != ''"> and expression = #{expression}</if>
<if test="defaultValue != null and defaultValue != ''"> and defaultValue = #{defaultValue}</if>
<if test="required != null and required != ''"> and required = #{required}</if>
<if test="disabled != null and disabled != ''"> and disabled = #{disabled}</if>
<if test="readonly != null and readonly != ''"> and readonly = #{readonly}</if>
<if test="maxlength != null and maxlength != ''"> and maxlength = #{maxlength}</if>
<if test="width != null and width != ''"> and width = #{width}</if>
<if test="labelWidth != null "> and label_width = #{labelWidth}</if>
<if test="placeholder != null and placeholder != ''"> and placeholder = #{placeholder}</if>
<if test="fieldHtml != null and fieldHtml != ''"> and field_html = #{fieldHtml}</if>
<if test="isDelete != null "> and is_delete = #{isDelete}</if>
<if test="fromId != null "> and from_id = #{fromId}</if>
</where>
</select>
<select id="selectSysFormFieldById" parameterType="Long" resultMap="SysFormFieldResult">
<select id="selectSysFormFieldById" parameterType="Integer" resultMap="SysFormFieldResult">
<include refid="selectSysFormFieldVo"/>
where id_ = #{id}
where id = #{id}
</select>
<insert id="insertSysFormField" parameterType="SysFormField" useGeneratedKeys="true" keyProperty="id">
insert into sys_form_field
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="fieldKey != null and fieldKey != ''">field_key_,</if>
<if test="fieldName != null and fieldName != ''">field_name_,</if>
<if test="fieldType != null and fieldType != ''">field_type_,</if>
<if test="fieldHtml != null and fieldHtml != ''">field_html_,</if>
<if test="remark != null">remark_,</if>
<if test="fieldKey != null and fieldKey != ''">field_key,</if>
<if test="fieldName != null and fieldName != ''">field_name,</if>
<if test="fieldType != null and fieldType != ''">field_type,</if>
<if test="options != null">options,</if>
<if test="document != null">document,</if>
<if test="expression != null">expression,</if>
<if test="defaultValue != null">defaultValue,</if>
<if test="required != null">required,</if>
<if test="disabled != null">disabled,</if>
<if test="readonly != null">readonly,</if>
<if test="maxlength != null">maxlength,</if>
<if test="width != null">width,</if>
<if test="labelWidth != null">label_width,</if>
<if test="placeholder != null">placeholder,</if>
<if test="fieldHtml != null and fieldHtml != ''">field_html,</if>
<if test="remark != null">remark,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="rev != null">rev_,</if>
<if test="tenantId != null">tenant_id_,</if>
<if test="isDelete != null">is_delete,</if>
<if test="fromId != null ">from_id ,</if>
</trim>
<if test="fromId != null">from_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="fieldKey != null and fieldKey != ''">#{fieldKey},</if>
<if test="fieldName != null and fieldName != ''">#{fieldName},</if>
<if test="fieldType != null and fieldType != ''">#{fieldType},</if>
<if test="options != null">#{options},</if>
<if test="document != null">#{document},</if>
<if test="expression != null">#{expression},</if>
<if test="defaultValue != null">#{defaultValue},</if>
<if test="required != null">#{required},</if>
<if test="disabled != null">#{disabled},</if>
<if test="readonly != null">#{readonly},</if>
<if test="maxlength != null">#{maxlength},</if>
<if test="width != null">#{width},</if>
<if test="labelWidth != null">#{labelWidth},</if>
<if test="placeholder != null">#{placeholder},</if>
<if test="fieldHtml != null and fieldHtml != ''">#{fieldHtml},</if>
<if test="remark != null">#{remark},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="rev != null">#{rev},</if>
<if test="tenantId != null">#{tenantId},</if>
<if test="isDelete != null">#{isDelete},</if>
<if test="fromId != null "> #{fromId}</if>
</trim>
<if test="fromId != null">#{fromId},</if>
</trim>
</insert>
<update id="updateSysFormField" parameterType="SysFormField">
update sys_form_field
<trim prefix="SET" suffixOverrides=",">
<if test="fieldKey != null and fieldKey != ''">field_key_ = #{fieldKey},</if>
<if test="fieldName != null and fieldName != ''">field_name_ = #{fieldName},</if>
<if test="fieldType != null and fieldType != ''">field_type_ = #{fieldType},</if>
<if test="fieldHtml != null and fieldHtml != ''">field_html_ = #{fieldHtml},</if>
<if test="remark != null">remark_ = #{remark},</if>
<if test="fieldKey != null and fieldKey != ''">field_key = #{fieldKey},</if>
<if test="fieldName != null and fieldName != ''">field_name = #{fieldName},</if>
<if test="fieldType != null and fieldType != ''">field_type = #{fieldType},</if>
<if test="options != null">options = #{options},</if>
<if test="document != null">document = #{document},</if>
<if test="expression != null">expression = #{expression},</if>
<if test="defaultValue != null">defaultValue = #{defaultValue},</if>
<if test="required != null">required = #{required},</if>
<if test="disabled != null">disabled = #{disabled},</if>
<if test="readonly != null">readonly = #{readonly},</if>
<if test="maxlength != null">maxlength = #{maxlength},</if>
<if test="width != null">width = #{width},</if>
<if test="labelWidth != null">label_width = #{labelWidth},</if>
<if test="placeholder != null">placeholder = #{placeholder},</if>
<if test="fieldHtml != null and fieldHtml != ''">field_html = #{fieldHtml},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="rev != null">rev_ = #{rev},</if>
<if test="tenantId != null">tenant_id_ = #{tenantId},</if>
<if test="isDelete != null">is_delete = #{isDelete},</if>
<if test="fromId != null "> from_id = #{fromId},</if>
<if test="fromId != null">from_id = #{fromId},</if>
</trim>
where id_ = #{id}
where id = #{id}
</update>
<delete id="deleteSysFormFieldById" parameterType="Long">
delete from sys_form_field where id_ = #{id}
<delete id="deleteSysFormFieldById" parameterType="Integer">
delete from sys_form_field where id = #{id}
</delete>
<delete id="deleteSysFormFieldByIds" parameterType="String">
delete from sys_form_field where id_ in
delete from sys_form_field where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>

View File

@ -0,0 +1,181 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<th:block th:include="include :: header('自定义页面展示')" />
<link rel="stylesheet" href="./layui/css/layui.css" />
<link rel="stylesheet" href="./ayq/modules/formDesigner.css" />
<link rel="stylesheet" href="./ayq/modules/cron.css" />
<link rel="stylesheet" href="./ayq/modules/labelGeneration.css" />
<link rel="stylesheet" href="./ayq/modules/formPreview.css" />
</head>
<body >
<div >
<input type="hidden" name="formId" id="formId" th:value="${formId}">
<div style="margin: 20px 20px;padding: 20px 20px;border: 1px solid #009688;">
<div style="margin-top: 20px">
<h2 th:text="${name}" style="text-align: center"></h2>
</div>
<div id="testdemo" style="margin-top: 15px">
</div>
</div>
</div>
<div class="importjsoncodeview" style="display: none;">
<textarea class="site-demo-text" id="import-json-code-view"></textarea>
<a href="javascript:;" class="layui-btn layui-btn-normal" style="margin-right:20px;" id="import-json-code">导入数据</a>
</div>
<div class="getFormData" style="display: none;">
<textarea class="site-demo-text" id="get-form-data"></textarea>
</div>
<script th:src="@{/js/jquery.min.js}"></script>
<script type="text/javascript" src="./layui/layui.js"></script>
<script type="text/javascript" src="./ayq/modules/Sortable/Sortable.js"> </script>
<script type="text/javascript" src="./ayq/modules/iceEditor/iceEditor.js"></script>
<script type="text/javascript" src="./ayq/modules/formPreview.js"></script>
<script>
var demojs = [];
//JavaScript代码区域
layui.config(
{base: './ayq/modules/'}).use(['formPreview', 'form','layer','upload'], function () {
var layer = layui.layer;
var $ = layui.jquery;
var upload = layui.upload;
var index = layui.index;
var formPreview = layui.formPreview;
var form = layui.form;
var render;
if (window.localStorage.getItem('layui_form_json') !== undefined) {
var formId=$("#formId").val();
var config = {
url: "/from/instance/getFromInfo",
type: "post",
dataType: "json",
data: {
"formId":formId
},
beforeSend: function () {
layer.msg("正在处理中,请稍后...",{icon: 1});
},
success: function(result) {
if (result.code === 0) {
demojs = JSON.parse(result.msg);
render = formPreview.render({
elem: '#testdemo',
data: demojs,
});
var images = render.getImages();
for (var i = 0; i < images.length; i++) {
upload.render({
elem: '#' + images[i].select
, url: '' + images[i].uploadUrl + ''
, multiple: true
, before: function (obj) {
layer.msg('图片上传中...', {
icon: 16,
shade: 0.01,
time: 0
})
}
, done: function (res) {
layer.close(layer.msg());//关闭上传提示窗口
//上传完毕
$('#uploader-list-' + item.id).append(
'<div id="" class="file-iteme">' +
'<div class="handle"><i class="layui-icon layui-icon-delete"></i></div>' +
'<img style="width: 100px;height: 100px;" src=' + res.data.src + '>' +
'<div class="info">' + res.data.title + '</div>' +
'</div>'
);
}
});
}
var filesData = render.getFiles();
for (var i = 0; i < filesData.length; i++) {
upload.render({
elem: '#' + filesData[i].select
, elemList: $('#list-' + filesData[i].select) //列表元素对象
, url: '' + filesData[i].uploadUrl + ''
, accept: 'file'
, multiple: true
, number: 3
, auto: false
, bindAction: '#listAction-' + filesData[i].select
, choose: function (obj) {
var that = this;
var files = this.files = obj.pushFile(); //将每次选择的文件追加到文件队列
//读取本地文件
obj.preview(function (index, file, result) {
var tr = $(['<tr id="upload-' + index + '">'
, '<td>' + file.name + '</td>'
, '<td>' + (file.size / 1014).toFixed(1) + 'kb</td>'
, '<td><div class="layui-progress" lay-filter="progress-demo-' + index + '"><div class="layui-progress-bar" lay-percent=""></div></div></td>'
, '<td>'
, '<button class="layui-btn layui-btn-xs demo-reload layui-hide">重传</button>'
, '<button class="layui-btn layui-btn-xs layui-btn-danger demo-delete">删除</button>'
, '</td>'
, '</tr>'].join(''));
//单个重传
tr.find('.demo-reload').on('click', function () {
obj.upload(index, file);
});
//删除
tr.find('.demo-delete').on('click', function () {
delete files[index]; //删除对应的文件
tr.remove();
uploadListIns.config.elem.next()[0].value = ''; //清空 input file 值,以免删除后出现同名文件不可选
});
that.elemList.append(tr);
element.render('progress'); //渲染新加的进度条组件
});
}
, done: function (res, index, upload) { //成功的回调
var that = this;
//if(res.code == 0){ //上传成功
var tr = that.elemList.find('tr#upload-' + index)
, tds = tr.children();
tds.eq(3).html(''); //清空操作
delete this.files[index]; //删除文件队列已经上传成功的文件
return;
//}
this.error(index, upload);
}
, allDone: function (obj) { //多文件上传完毕后的状态回调
console.log(obj)
}
, error: function (index, upload) { //错误回调
var that = this;
var tr = that.elemList.find('tr#upload-' + index)
, tds = tr.children();
tds.eq(3).find('.demo-reload').removeClass('layui-hide'); //显示重传
}
, progress: function (n, elem, e, index) {
element.progress('progress-demo-' + index, n + '%'); //执行进度条。n 即为返回的进度百分比
}
});
}
} else {
layer.msg(result.msg, {icon: 2});
}
}
};
$.ajax(config);
}
});
function getSubmitData(){
var data=$('#testdemo').form[0].serialize();
console.log(data);
return data;
}
</script>
</body>
</html>

View File

@ -1,414 +0,0 @@
<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>ortum</title>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="stylesheet" th:href="@{../../..//css/index.css}">
<link rel="stylesheet" th:href="@{../../../css/bootstrap.css}">
<link rel="stylesheet" th:href="@{../../../css/custom.css}">
<link rel="stylesheet" th:href="@{../../../css/iconfont/iconfont.css}">
<!-- 滚动条样式 -->
<link rel="stylesheet" th:href="@{../../../lib/mCustonScrollbar/jquery.mCustomScrollbar.css}">
<!-- 引入bootstrap css-->
<link rel="stylesheet" th:href="@{https://cdn.jsdelivr.net/npm/bootstrap@4.5.0/dist/css/bootstrap.min.css}" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<script th:src="@{../../../lib/jquery.min.js}"></script>
<script th:src="@{../../../lib/axios.min.js}"></script>
<!-- 滚动条js -->
<script th:src="@{../../../lib/mCustonScrollbar/jquery.mCustomScrollbar.concat.min.js}"></script>
<!-- 引入bootstrap js -->
<!--<script src="https://cdn.jsdelivr.net/npm/popper.js"></script>-->
<script th:src="@{https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js}" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script th:src="@{https://cdn.jsdelivr.net/npm/bootstrap@4.5.0/dist/js/bootstrap.min.js}" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
<script th:src="@{../../../lib/ortumReq.js}"></script>
<style>
#ortum_form_Modal_body input::-webkit-input-placeholder,#ortum_form_Modal_body textarea::-webkit-input-placeholder {
color: #77777773;
font-size: 14px;
}
#ortum_form_Modal_body input,#ortum_form_Modal_body select,#ortum_form_Modal_body textarea{
font-size: 14px;
padding-left: 10px;
}
#ortum_form_Modal_body input:disabled,#ortum_form_Modal_body select:disabled{
color: black;
}
/* 表头样式 */
#ortum_form_Modal_body #ortum_field_preview>.ortum_bootstrap_h:nth-child(1) .ortum_bootstrap_hDom {
background: #224F85 !important;
color: #fff !important;
height: 40px;
line-height: 40px;
padding: 0px;
font-size: 16px;
}
.row .ortum_boot_col_default {
border-right: 1px solid #fff;
}
/* label样式 */
.ortum_bootstrap_label_cssClass {
padding-left: 15px;
}
/* input */
.ortum_bootstrap_grid .ortum_boot_col_default .ortum_bootstrap_input{
width: 90%;
}
.ortum_bootstrap_grid .ortum_boot_col_default .form-control {
border-radius: 0 !important;
margin: 3.5px 0!important;
height: 30px;
line-height: 30px;
}
/* select样式 */
.ortum_bootstrap_grid .ortum_boot_col_default .ortum_bootstrap_select {
width: 90%;
}
.ortum_bootstrap_grid .ortum_boot_col_default .ortum_bootstrap_select .custom-select {
border-radius: 0px !important;
height: 30px;
line-height: 30px;
font-size: 16px;
padding: 0px;
margin:3.5px 0;
}
/* textarea */
.ortum_bootstrap_grid .ortum_boot_col_default .ortum_bootstrap_textarea{
width: 96%;
}
.ortum_bootstrap_grid .ortum_boot_col_default .ortum_bootstrap_textarea textarea{
height: auto!important;
}
.ortum_bootstrap_td #ortum_form_Modal_body #ortum_field_preview>.ortum_item {
margin-top: 2px !important;
margin-bottom: 2px !important;
}
#ortum_form_Modal_body #ortum_field_preview>.ortum_item:nth-child(2n) {
background: #fafafa !important;
}
#ortum_form_Modal_body #ortum_field_preview>.ortum_item:nth-child(2n+1) {
background: rgba(245, 244, 244, 1) !important;
}
/* 表格样式 */
.ortum_bootstrap_table .ortum_bootstrap_th {
border-color: #fff;
}
.ortum_bootstrap_table .ortum_bootstrap_td {
border-color: #fff;
}
.ortum_bootstrap_table .form-control {
border-radius: 0px !important;
height: 30px;
width: 90%;
}
.ortum_bootstrap_table .ortum_bootstrap_thead tr th span {
font-size: 16px;
font-weight: 500;
color: #000;
}
.ortum_bootstrap_table .ortum_bootstrap_thead tr th:nth-child(1) {
min-width: 40px;
}
/* 提交按钮样式 */
#ortum_preview_submit {
background: #007bff;
color: #fff;
border-radius: 0px;
}
.col,
.col-2 {
padding-right: 0px;
padding-left: 0px;
}
/*option意见*/
.optionContainer{
background-color:rgba(245,244,244,1);
}
.optionContainer > .row{
margin: 0;
}
.optionTitle{border: 2px solid white;display: flex;align-items: center;}
.optionContent{padding: 0 10px;border: 1px solid white;}
.optionText{line-height: 30px;height: 90px}
.optionSpan{display: block;white-space: pre-line;word-break: break-all;word-wrap: break-word;}
.optionTimeAndName{display: flex;flex-direction: column;justify-content: center;align-items: flex-end;border-bottom: 2px solid white;}
.optionContent .optionTimeAndName:last-of-type{
border-bottom:none;
}
</style>
</head>
<body>
<!--<div class="dropdown">
<span class="dropdown-toggle" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">交换</span>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</div>-->
<input type="hidden" id="formId" th:value="${formId}" name="formId">
<div id="ortum_form_Modal_body" class="container" style="margin: auto">
</div>
<div style="text-align: center" class="p-2">
<button type="button" class="btn btn-outline-primary" id="ortum_preview_submit">提交</button>
</div>
<script>
let getDomContextFormData = function(domId,settings={id:true,dataset:true,}){
let formData = {}
let form = document.getElementById(domId);
let elements = new Array();
let inputElements = form.getElementsByTagName('input');
let selectElements = form.getElementsByTagName('select');
let textareaElements = form.getElementsByTagName('textarea');
let includeId = false;//表单有id包含id的key
let includeDataSet = false;//包含data属性
if(Object.prototype.toString.call(settings).slice(8,-1) === "Object"){
settings.id && (includeId = true);
settings.dataset && (includeDataSet = true);
}
Array.prototype.forEach.call(inputElements,(item)=>{
if(!item.name)return;//不存在name不进行赋值
if(includeDataSet){
for(let dataKey in item.dataset){
if(item.dataset.hasOwnProperty(dataKey)){
formData[item.name+"_"+dataKey] = item.dataset[dataKey];
};
}
};
let type = item.type.toLowerCase();
switch (type){
case "radio":
includeId && item.checked && item.id && (formData[item.id] = item.value);
item.checked && item.name && (formData[item.name] = item.value);
break;
case "checkbox":
if(item.name && item.name.indexOf("switch") != -1){
includeId && item.checked && item.id && (formData[item.id] = item.value);
item.checked && (formData[item.name] = true);
!item.checked && (formData[item.name] = false);
}else{
item.name && item.checked && (formData[item.name] ? formData[item.name].push(item.value) : formData[item.name]=[item.value]);
includeId && item.id && item.checked && (formData[item.id] ? formData[item.id].push(item.value) : formData[item.id]=[item.value]);
};
break;
default:
includeId && item.id && (formData[item.id] = item.value);
item.name && (formData[item.name] = item.value);
break;
}
})
Array.prototype.forEach.call(selectElements,(item)=>{
includeId && item.id && (formData[item.id] = item.value);
if(!item.name)return;//不存在name不进行赋值
if(includeDataSet){
for(let dataKey in item.dataset){
if(item.dataset.hasOwnProperty(dataKey)){
formData[item.name+"_"+dataKey] = item.dataset[dataKey];
}
}
};
formData[item.name] = item.value;
})
Array.prototype.forEach.call(textareaElements,(item)=>{
includeId && item.id && (formData[item.id] = item.value);
if(!item.name)return;//不存在name不进行赋值
if(includeDataSet){
for(let dataKey in item.dataset){
if(item.dataset.hasOwnProperty(dataKey)){
formData[item.name+"_"+dataKey] = item.dataset[dataKey];
}
}
};
formData[item.name] = item.value;
})
return formData;
};
$("#ortum_preview_submit").on('click',function(e){
let formData = getDomContextFormData("ortum_form_Modal_body");
// console.log(formData)
alert(JSON.stringify(formData))
return false;
});
</script>
<script>
var formId=$("#formId").val();
axios.get("/from/instance/getFromInfo/"+formId)
.then(function (res) {
// console.log("=========getFromInfo=========>"+JSON.stringify(res))
if(res.data.code==0){
let prevArrJSON= JSON.parse(res.data.data.contentHtml).ortumJson;
console.log("========后端返回的prevArrJSON======="+JSON.stringify(prevArrJSON));
setPrevArrJSON(prevArrJSON);
}else{
Assist.dangerTip(res.data.message)
}
})
.catch(function (error) {
if(!error || !error.noShowTip){
// Assist.dangerTip("保存失败");
}
console.error(error);
});
function setPrevArrJSON(prevArrJSON) {
let prevDom = $('<div id="ortum_field_preview"></div>');
let cssDomSet = [];
let scriptDomSet = [];
//待渲染权限的树
let rendPowerArr = [];
//从json渲染成dom
function renderJson(prevArrJSON,parentDom,way="append") {
for(let item of prevArrJSON){
let domItem = item;
let htmlDom;
if(item.childrenType == "choose" && item.chooseFun){
(typeof item.chooseFun !=="function") && (item.chooseFun = Function('return ' + item.chooseFun)());
domItem = item.chooseFun(parentDom);
};
htmlDom = $(domItem.html);
if(domItem.children && domItem.children.length){
renderJson(domItem.children,htmlDom,"replace");
};
//特殊处理Bootstrap_tableDom
if(domItem.frame == "Bootstrap" && (domItem.componentKey == "tableDom" || domItem.componentKey == "newTableDom")){
$(htmlDom).prop("ortum-childrenArr-info",domItem.children);//tr中组件的信息
$(htmlDom).prop("ortum_tbodyTr_info",domItem.ortum_tbodyTr_info);//tr信息
};
switch (way) {
case "replace":
if(parentDom.find("ortum_children").length && /[\d]+$/.test(domItem.ortumChildren)){
parentDom.find("ortum_children[data-order="+ domItem.ortumChildren +"]").eq(0).replaceWith(htmlDom);
}else if(parentDom.find("ortum_children").length){
parentDom.find("ortum_children").eq(0).replaceWith(htmlDom);
};
break;
default:
parentDom.append(htmlDom);
break;
};
rendPowerArr.push({
dom:htmlDom,
name:domItem.name
})
domItem.css && cssDomSet.push(domItem.css);
if(domItem.script){
domItem.script.babel ? scriptDomSet.push(domItem.script.babel) : scriptDomSet.push(domItem.script)
}
}
}
renderJson(prevArrJSON,prevDom);
$("#ortum_form_Modal_body").html(prevDom);
cssDomSet.forEach((item,index)=>{
$(document.head).append(item);
})
scriptDomSet.forEach((item,index)=>{
$(document.body).append(item);
});
let purviewJson={
"checkbox_21561456456456456":1,
"radio_1252314543323":4,
"table_1605100578804af1b_tfoot_1":3,
"table_1605100578804af1b_tfoot_2":3,
"table_1605100578804af1b_tfoot_4":1,
"table_1605100578804af1b_1_1":1,
"table_1605100578804af1b_2_1":0,
"table_1605100578804af1b_3_1":1,
"table_1605100578804af1b_4_1":3,
"table_1605100578804af1b_5_1":4,
"table_1605100578804af1b_6_1":1,
"table_1605100578804af1b_7_1":2,
"table_1605100578804af1b_8_1":1,
"table_1605100578804af1b_9_1":3,
"table_1605100578804af1b_10_1":3,
"table_1605100578804af1b_11_1":2,
};
let priArr = {
0:"hide",
1:"read",
2:"edit",
3:"required",
4:"readAndReq",
};
function setDomQ(outDom,formDom,name,priVal){
//TODO 完善ortum_bindcomponentname关联组件的权限控制
switch (priVal) {
case "hide":
$(outDom).hide();
$("*[ortum_bindcomponentname="+ name +"]").parents(".ortum_item").eq(0).hide();
//特殊处理table
if(/^table/.test(name)){
let cellIndex = outDom.parents("td")[0].cellIndex;
$(outDom).parents("table").eq(0).find("tr td:nth-of-type("+ (cellIndex+1) +")").hide();
$(outDom).parents("table").eq(0).find("tr th:nth-of-type("+ (cellIndex+1) +")").hide();
};
break;
case "read":
$(formDom).attr("disabled","disabled");
$("*[ortum_bindcomponentname="+ name +"]").parents(".ortum_item").eq(0).show();
break;
case "edit":
$(formDom).removeAttr("disabled");
$("*[ortum_bindcomponentname="+ name +"]").parents(".ortum_item").eq(0).show();
break;
case "required":
$(formDom).attr("ortum_verify","required");
$("*[ortum_bindcomponentname="+ name +"]").parents(".ortum_item").eq(0).show();
break;
case "readAndReq":
$(formDom).attr("disabled","disabled");
$(formDom).attr("ortum_verify","required");
$("*[ortum_bindcomponentname="+ name +"]").parents(".ortum_item").eq(0).show();
break;
default:
break;
}
}
function setQ(dom,name,priJson) {
let hasNameDom = $(dom).find("*[name="+ name +"]");
if(priJson.hasOwnProperty(name)){
$(dom).attr("ortum_authority",priJson[name]);//绑定权限值
setDomQ(dom,hasNameDom,name,priArr[priJson[name]])
};
};
//开始渲染权限
rendPowerArr.forEach(function(item){
setQ(item.dom,item.name,purviewJson)
});
}
</script>
</body>
</html>

View File

@ -88,7 +88,7 @@
});
function fromDetail(id) {
var detailUrl="/from/instance/fromPreview/"+id;
var detailUrl="/fromPreview?id="+id;
$.modal.openTab("详情", detailUrl);
}