本次提交 生成代码模块 只读 默认字段

This commit is contained in:
lin 2020-12-14 17:50:05 +08:00
parent da030fca43
commit 75b5b5a6e1
19 changed files with 1442 additions and 641 deletions

View File

@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="renderer" content="webkit">
<title>若依系统首页</title>
<title>yds系统首页</title>
<!-- 避免IE使用兼容模式 -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link th:href="@{favicon.ico}" rel="shortcut icon"/>

View File

@ -1,135 +1,95 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('新增经济类型')" />
<th:block th:include="include :: header('新增经济类型')" />
<th:block th:include="include :: datetimepicker-css" />
<th:block th:include="include :: bootstrap-fileinput-css"/>
<th:block th:include="include :: jasny-bootstrap-css" />
<th:block th:include="include :: bootstrap-fileinput-css"/>
<style type="text/css">
.col-md-6 {
position: static;
float: left;
}
</style>
</head>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-econtype-add">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-econtype-add">
<div class="col-md-6" background="red">
<fieldset>
<div class="form-group">
<label class="col-sm-3 control-label is-required">名称:</label>
<div class="col-sm-8">
<input name="econName" class="form-control" type="text" required>
</div>
</div>
<div class="form-group">
<div class="form-group">
<label class="col-sm-3 control-label is-required">资料状态:</label>
<div class="col-sm-8">
<div class="radio-box" th:each="dict : ${@dict.getType('platf_doc_statu')}">
<input type="radio" th:id="${'status_' + dict.dictCode}" name="status" th:value="${dict.dictValue}" th:checked="${dict.default}" required>
<label th:for="${'status_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
<label class="col-sm-2 control-label is-required">名称:</label>
<div class="col-sm-3">
<input name="econName" class="form-control" type="text" required>
</div>
<label class="col-sm-2 control-label is-required">单据号:</label>
<div class="col-sm-3">
<input name="docNum" class="form-control" readonly="readonly" type="text" required>
</div>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label is-required">资料状态:</label>
<div class="col-sm-3">
<div class="radio-box" th:each="dict : ${@dict.getType('platf_doc_statu')}">
<input type="radio" th:id="${'status_' + dict.dictCode}" name="status" th:value="${dict.dictValue}" th:checked="${dict.default}" required>
<label th:for="${'status_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">制单时间:</label>
<div class="col-sm-8">
<div class="input-group date">
<input name="createTime" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">备注:</label>
<div class="col-sm-8">
<textarea name="remark" class="form-control"></textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label is-required">制单人:</label>
<div class="col-sm-3">
<input name="createBy" class="form-control" readonly="readonly" type="text" required>
</div>
<label class="col-sm-2 control-label is-required">制单时间:</label>
<div class="col-sm-3">
<div class="input-group date">
<input name="createTime" class="form-control" placeholder="yyyy-MM-dd" readonly="readonly" type="text" required>
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">修改时间:</label>
<div class="col-sm-8">
<div class="input-group date">
<input name="updateTime" class="form-control" placeholder="yyyy-MM-dd" type="text">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-6" background="yellow">
<label class="col-sm-2 control-label">修改人:</label>
<div class="col-sm-3">
<input name="updateBy" class="form-control" readonly="readonly" type="text">
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">单据号:</label>
<div class="col-sm-8">
<input name="docNum" class="form-control" type="text" required>
</div>
</div>
<label class="col-sm-2 control-label">修改时间:</label>
<div class="col-sm-3">
<div class="input-group date">
<input name="updateTime" class="form-control" placeholder="yyyy-MM-dd" readonly="readonly" type="text">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
</div>
</fieldset>
<div class="form-group">
<label class="col-sm-3 control-label">备注:</label>
<div class="col-sm-8">
<textarea name="remark" class="form-control"></textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">制单人:</label>
<div class="col-sm-8">
<input name="createBy" class="form-control" type="text" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">修改人:</label>
<div class="col-sm-8">
<input name="updateBy" class="form-control" type="text">
</div>
</div>
</div>
</form>
</form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<script th:inline="javascript">
<th:block th:include="include :: datetimepicker-js" />
<script th:inline="javascript">
var prefix = ctx + "platform/econtype"
$("#form-econtype-add").validate({
$("#form-econtype-add").validate({
focusCleanup: true
});
@ -139,17 +99,17 @@
}
}
$("input[name='createTime']").datetimepicker({
format: "yyyy-mm-dd",
minView: "month",
autoclose: true
});
$("input[name='createTime']").datetimepicker({
format: "yyyy-mm-dd",
minView: "month",
autoclose: true
});
$("input[name='updateTime']").datetimepicker({
format: "yyyy-mm-dd",
minView: "month",
autoclose: true
});
</script>
$("input[name='updateTime']").datetimepicker({
format: "yyyy-mm-dd",
minView: "month",
autoclose: true
});
</script>
</body>
</html>

View File

@ -8,48 +8,67 @@
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-econtype-edit" th:object="${econType}">
<input name="econId" th:field="*{econId}" type="hidden">
<div class="form-group">
<label class="col-sm-3 control-label is-required">名称:</label>
<div class="row">
<div class="col-sm-6">
<label class="col-sm-4 control-label is-required">名称:</label>
<div class="col-sm-8">
<input name="econName" th:field="*{econName}" class="form-control" type="text" required>
<input name="econName" class="form-control" readonly="false" type="text" required>
</div>
<label class="col-sm-4 control-label is-required">单据号:</label>
<div class="col-sm-8">
<input name="docNum" class="form-control" readonly="true" type="text" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">单据号:</label>
<div class="col-sm-8">
<input name="docNum" th:field="*{docNum}" class="form-control" type="text" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">资料状态:</label>
</div>
<div class="row">
<div class="col-sm-6">
<label class="col-sm-4 control-label is-required">资料状态:</label>
<div class="col-sm-8">
<div class="radio-box" th:each="dict : ${@dict.getType('platf_doc_statu')}">
<input type="radio" th:id="${'status_' + dict.dictCode}" name="status" th:value="${dict.dictValue}" th:field="*{status}" required>
<input type="radio" th:id="${'status_' + dict.dictCode}" name="status" th:value="${dict.dictValue}" th:checked="${dict.default}" required>
<label th:for="${'status_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">备注:</label>
<div class="col-sm-8">
<textarea name="remark" class="form-control">[[*{remark}]]</textarea>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label">备注_4</label>
<div class="col-sm-8">
<textarea name="remark" class="form-control"></textarea>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">修改人:</label>
</div>
<div class="row">
<div class="col-sm-6">
<label class="col-sm-4 control-label">修改人:</label>
<div class="col-sm-8">
<input name="updateBy" th:field="*{updateBy}" class="form-control" type="text">
<input name="updateBy" class="form-control" readonly="true" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">修改时间:</label>
<label class="col-sm-4 control-label">修改时间:</label>
<div class="col-sm-8">
<div class="input-group date">
<input name="updateTime" th:value="${#dates.format(econType.updateTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
<input name="updateTime" class="form-control" placeholder="yyyy-MM-dd" type="text">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />

View File

@ -42,8 +42,11 @@ public class GenConstants
public static final String[] COLUMNTYPE_NUMBER = { "tinyint", "smallint", "mediumint", "int", "number", "integer",
"bit", "bigint", "float", "double", "decimal" };
/** 页面上 默认只读的字段 */
public static final String[] COLUMNNAME_INI_READONLY = { "doc_num", "create_by", "create_time", "update_by", "update_time", "del_flag" };
/** 页面不需要编辑字段 */
public static final String[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "del_flag" };
public static final String[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "update_by", "update_time", "del_flag" };
/** 页面不需要显示的列表字段 */
public static final String[] COLUMNNAME_NOT_LIST = { "id", "create_by", "create_time", "del_flag", "update_by",

View File

@ -64,6 +64,9 @@ public class GenTable extends BaseEntity
/** 生成代码方式0zip压缩包 1自定义路径 */
private String genType;
/** 界面上form的列数 1一列2二列3三列 4四列 */
private String formCols;
/** 生成路径(不填默认项目路径) */
private String genPath;
@ -225,6 +228,16 @@ public class GenTable extends BaseEntity
this.genType = genType;
}
public String getFormCols()
{
return formCols;
}
public void setFormCols(String formCols)
{
this.formCols = formCols;
}
public String getGenPath()
{
return genPath;

View File

@ -50,6 +50,9 @@ public class GenTableColumn extends BaseEntity
/** 是否编辑字段1是 */
private String isEdit;
/** 是否 只读字段1是 */
private String isReadonly;
/** 是否列表字段1是 */
private String isList;
@ -222,6 +225,25 @@ public class GenTableColumn extends BaseEntity
{
return isInsert != null && StringUtils.equals("1", isInsert);
}
public void setIsReadonly(String isReadonly)
{
this.isReadonly = isReadonly;
}
public String getIsReadonly()
{
return isReadonly;
}
public boolean isReadonly()
{
return isReadonly(this.isReadonly);
}
public boolean isReadonly(String isReadonly)
{
return isReadonly != null && StringUtils.equals("1", isReadonly);
}
public void setIsEdit(String isEdit)
{
@ -332,7 +354,7 @@ public class GenTableColumn extends BaseEntity
{
return StringUtils.equalsAnyIgnoreCase(javaField,
// BaseEntity
"remark",
"remark","delFlag",
// TreeEntity
"parentName", "parentId", "orderNum", "ancestors");
}

View File

@ -354,6 +354,15 @@ public class GenTableServiceImpl implements IGenTableService
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
for (String template : templates)
{
// form 2列
if (table.getFormCols().equals("2") ) {
if ( template.contains("add.html.vm") ) {
template = "vm/html/col2/add.html.vm";
} else if ( template.contains("edit.html.vm") ) {
template = "vm/html/col2/edit.html.vm";
}
}
// 渲染模板
StringWriter sw = new StringWriter();
Template tpl = Velocity.getTemplate(template, Constants.UTF8);

View File

@ -87,6 +87,15 @@ public class GenUtils
{
column.setIsEdit(GenConstants.REQUIRE);
}
// 只读字段
if ( arraysContains(GenConstants.COLUMNNAME_INI_READONLY, columnName) )
{
column.setIsReadonly("1");
} else {
column.setIsReadonly("0");
}
// 列表字段
if (!arraysContains(GenConstants.COLUMNNAME_NOT_LIST, columnName) && !column.isPk())
{
@ -98,6 +107,16 @@ public class GenUtils
column.setIsQuery(GenConstants.REQUIRE);
}
// 设置自定义编号 所有的选项都为0
if ( columnName.contains("_custom_num") ){
column.setIsInsert("0");
column.setIsEdit("0");
column.setIsQuery("0");
column.setIsList("0");
column.setIsRequired("0");
}
// 查询字段类型
if (StringUtils.endsWithIgnoreCase(columnName, "name"))
{

View File

@ -3,6 +3,7 @@ package com.ruoyi.generator.util;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import org.apache.velocity.VelocityContext;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.constant.GenConstants;
@ -12,18 +13,25 @@ import com.ruoyi.generator.config.GenConfig;
import com.ruoyi.generator.domain.GenTable;
import com.ruoyi.generator.domain.GenTableColumn;
public class VelocityUtils
{
/** 项目空间路径 */
public class VelocityUtils {
/**
* 项目空间路径
*/
private static final String PROJECT_PATH = "main/java";
/** mybatis空间路径 */
/**
* mybatis空间路径
*/
private static final String MYBATIS_PATH = "main/resources/mapper";
/** html空间路径 */
/**
* html空间路径
*/
private static final String TEMPLATES_PATH = "main/resources/templates";
/** 默认上级菜单,系统工具 */
/**
* 默认上级菜单系统工具
*/
private static final String DEFAULT_PARENT_MENU_ID = "3";
/**
@ -31,8 +39,7 @@ public class VelocityUtils
*
* @return 模板列表
*/
public static VelocityContext prepareContext(GenTable genTable)
{
public static VelocityContext prepareContext(GenTable genTable) {
String moduleName = genTable.getModuleName();
String businessName = genTable.getBusinessName();
String packageName = genTable.getPackageName();
@ -57,39 +64,36 @@ public class VelocityUtils
// 取出页面需要的字段ing
List<GenTableColumn> tempcolumns = genTable.getColumns();
List<GenTableColumn> effectivecols = new ArrayList<GenTableColumn> ();//定义一个list对象
for(GenTableColumn tcolumn : tempcolumns) {
List<GenTableColumn> effectivecols = new ArrayList<GenTableColumn>();//定义一个list对象
for (GenTableColumn tcolumn : tempcolumns) {
if (tcolumn.isInsert() && !tcolumn.isPk())
if (tcolumn.isUsableColumn() || !tcolumn.isSuperColumn())
effectivecols.add(tcolumn) ;
} ;
effectivecols.add(tcolumn);
}
;
velocityContext.put("effectivecols", effectivecols);
velocityContext.put("columns", genTable.getColumns());
velocityContext.put("table", genTable);
setMenuVelocityContext(velocityContext, genTable);
if (GenConstants.TPL_TREE.equals(tplCategory))
{
if (GenConstants.TPL_TREE.equals(tplCategory)) {
setTreeVelocityContext(velocityContext, genTable);
}
if (GenConstants.TPL_SUB.equals(tplCategory))
{
if (GenConstants.TPL_SUB.equals(tplCategory)) {
setSubVelocityContext(velocityContext, genTable);
}
return velocityContext;
}
public static void setMenuVelocityContext(VelocityContext context, GenTable genTable)
{
public static void setMenuVelocityContext(VelocityContext context, GenTable genTable) {
String options = genTable.getOptions();
JSONObject paramsObj = JSONObject.parseObject(options);
String parentMenuId = getParentMenuId(paramsObj);
context.put("parentMenuId", parentMenuId);
}
public static void setTreeVelocityContext(VelocityContext context, GenTable genTable)
{
public static void setTreeVelocityContext(VelocityContext context, GenTable genTable) {
String options = genTable.getOptions();
JSONObject paramsObj = JSONObject.parseObject(options);
String treeCode = getTreecode(paramsObj);
@ -100,18 +104,15 @@ public class VelocityUtils
context.put("treeParentCode", treeParentCode);
context.put("treeName", treeName);
context.put("expandColumn", getExpandColumn(genTable));
if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE))
{
if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE)) {
context.put("tree_parent_code", paramsObj.getString(GenConstants.TREE_PARENT_CODE));
}
if (paramsObj.containsKey(GenConstants.TREE_NAME))
{
if (paramsObj.containsKey(GenConstants.TREE_NAME)) {
context.put("tree_name", paramsObj.getString(GenConstants.TREE_NAME));
}
}
public static void setSubVelocityContext(VelocityContext context, GenTable genTable)
{
public static void setSubVelocityContext(VelocityContext context, GenTable genTable) {
GenTable subTable = genTable.getSubTable();
String subTableName = genTable.getSubTableName();
String subTableFkName = genTable.getSubTableFkName();
@ -133,8 +134,7 @@ public class VelocityUtils
*
* @return 模板列表
*/
public static List<String> getTemplateList(String tplCategory)
{
public static List<String> getTemplateList(String tplCategory) {
List<String> templates = new ArrayList<String>();
templates.add("vm/java/domain.java.vm");
templates.add("vm/java/mapper.java.vm");
@ -142,17 +142,12 @@ public class VelocityUtils
templates.add("vm/java/serviceImpl.java.vm");
templates.add("vm/java/controller.java.vm");
templates.add("vm/xml/mapper.xml.vm");
if (GenConstants.TPL_CRUD.equals(tplCategory))
{
if (GenConstants.TPL_CRUD.equals(tplCategory)) {
templates.add("vm/html/list.html.vm");
}
else if (GenConstants.TPL_TREE.equals(tplCategory))
{
} else if (GenConstants.TPL_TREE.equals(tplCategory)) {
templates.add("vm/html/tree.html.vm");
templates.add("vm/html/list-tree.html.vm");
}
else if (GenConstants.TPL_SUB.equals(tplCategory))
{
} else if (GenConstants.TPL_SUB.equals(tplCategory)) {
templates.add("vm/html/list.html.vm");
templates.add("vm/java/sub-domain.java.vm");
}
@ -165,8 +160,7 @@ public class VelocityUtils
/**
* 获取文件名
*/
public static String getFileName(String template, GenTable genTable)
{
public static String getFileName(String template, GenTable genTable) {
// 文件名称
String fileName = "";
// 包路径
@ -182,56 +176,32 @@ public class VelocityUtils
String mybatisPath = MYBATIS_PATH + "/" + moduleName;
String htmlPath = TEMPLATES_PATH + "/" + moduleName + "/" + businessName;
if (template.contains("domain.java.vm"))
{
if (template.contains("domain.java.vm")) {
fileName = StringUtils.format("{}/domain/{}.java", javaPath, className);
}
if (template.contains("sub-domain.java.vm") && StringUtils.equals(GenConstants.TPL_SUB, genTable.getTplCategory()))
{
if (template.contains("sub-domain.java.vm") && StringUtils.equals(GenConstants.TPL_SUB, genTable.getTplCategory())) {
fileName = StringUtils.format("{}/domain/{}.java", javaPath, genTable.getSubTable().getClassName());
}
else if (template.contains("mapper.java.vm"))
{
} else if (template.contains("mapper.java.vm")) {
fileName = StringUtils.format("{}/mapper/{}Mapper.java", javaPath, className);
}
else if (template.contains("service.java.vm"))
{
} else if (template.contains("service.java.vm")) {
fileName = StringUtils.format("{}/service/I{}Service.java", javaPath, className);
}
else if (template.contains("serviceImpl.java.vm"))
{
} else if (template.contains("serviceImpl.java.vm")) {
fileName = StringUtils.format("{}/service/impl/{}ServiceImpl.java", javaPath, className);
}
else if (template.contains("controller.java.vm"))
{
} else if (template.contains("controller.java.vm")) {
fileName = StringUtils.format("{}/controller/{}Controller.java", javaPath, className);
}
else if (template.contains("mapper.xml.vm"))
{
} else if (template.contains("mapper.xml.vm")) {
fileName = StringUtils.format("{}/{}Mapper.xml", mybatisPath, className);
}
else if (template.contains("list.html.vm"))
{
} else if (template.contains("list.html.vm")) {
fileName = StringUtils.format("{}/{}.html", htmlPath, businessName);
}
else if (template.contains("list-tree.html.vm"))
{
} else if (template.contains("list-tree.html.vm")) {
fileName = StringUtils.format("{}/{}.html", htmlPath, businessName);
}
else if (template.contains("tree.html.vm"))
{
} else if (template.contains("tree.html.vm")) {
fileName = StringUtils.format("{}/tree.html", htmlPath);
}
else if (template.contains("add.html.vm"))
{
} else if (template.contains("add.html.vm")) {
fileName = StringUtils.format("{}/add.html", htmlPath);
}
else if (template.contains("edit.html.vm"))
{
} else if (template.contains("edit.html.vm")) {
fileName = StringUtils.format("{}/edit.html", htmlPath);
}
else if (template.contains("sql.vm"))
{
} else if (template.contains("sql.vm")) {
fileName = businessName + "Menu.sql";
}
return fileName;
@ -242,8 +212,7 @@ public class VelocityUtils
*
* @return 路径
*/
public static String getProjectPath()
{
public static String getProjectPath() {
String packageName = GenConfig.getPackageName();
StringBuffer projectPath = new StringBuffer();
projectPath.append("main/java/");
@ -258,8 +227,7 @@ public class VelocityUtils
* @param packageName 包名称
* @return 包前缀名称
*/
public static String getPackagePrefix(String packageName)
{
public static String getPackagePrefix(String packageName) {
int lastIndex = packageName.lastIndexOf(".");
String basePackage = StringUtils.substring(packageName, 0, lastIndex);
return basePackage;
@ -271,23 +239,17 @@ public class VelocityUtils
* @param genTable 业务表对象
* @return 返回需要导入的包列表
*/
public static HashSet<String> getImportList(GenTable genTable)
{
public static HashSet<String> getImportList(GenTable genTable) {
List<GenTableColumn> columns = genTable.getColumns();
GenTable subGenTable = genTable.getSubTable();
HashSet<String> importList = new HashSet<String>();
if (StringUtils.isNotNull(subGenTable))
{
if (StringUtils.isNotNull(subGenTable)) {
importList.add("java.util.List");
}
for (GenTableColumn column : columns)
{
if (!column.isSuperColumn() && GenConstants.TYPE_DATE.equals(column.getJavaType()))
{
for (GenTableColumn column : columns) {
if (!column.isSuperColumn() && GenConstants.TYPE_DATE.equals(column.getJavaType())) {
importList.add("java.util.Date");
}
else if (!column.isSuperColumn() && GenConstants.TYPE_BIGDECIMAL.equals(column.getJavaType()))
{
} else if (!column.isSuperColumn() && GenConstants.TYPE_BIGDECIMAL.equals(column.getJavaType())) {
importList.add("java.math.BigDecimal");
}
}
@ -297,12 +259,11 @@ public class VelocityUtils
/**
* 获取权限前缀
*
* @param moduleName 模块名称
* @param moduleName 模块名称
* @param businessName 业务名称
* @return 返回权限前缀
*/
public static String getPermissionPrefix(String moduleName, String businessName)
{
public static String getPermissionPrefix(String moduleName, String businessName) {
return StringUtils.format("{}:{}", moduleName, businessName);
}
@ -312,10 +273,8 @@ public class VelocityUtils
* @param options 生成其他选项
* @return 上级菜单ID字段
*/
public static String getParentMenuId(JSONObject paramsObj)
{
if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID))
{
public static String getParentMenuId(JSONObject paramsObj) {
if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID)) {
return paramsObj.getString(GenConstants.PARENT_MENU_ID);
}
return DEFAULT_PARENT_MENU_ID;
@ -327,10 +286,8 @@ public class VelocityUtils
* @param options 生成其他选项
* @return 树编码
*/
public static String getTreecode(JSONObject paramsObj)
{
if (paramsObj.containsKey(GenConstants.TREE_CODE))
{
public static String getTreecode(JSONObject paramsObj) {
if (paramsObj.containsKey(GenConstants.TREE_CODE)) {
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_CODE));
}
return StringUtils.EMPTY;
@ -342,10 +299,8 @@ public class VelocityUtils
* @param options 生成其他选项
* @return 树父编码
*/
public static String getTreeParentCode(JSONObject paramsObj)
{
if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE))
{
public static String getTreeParentCode(JSONObject paramsObj) {
if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE)) {
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_PARENT_CODE));
}
return StringUtils.EMPTY;
@ -357,10 +312,8 @@ public class VelocityUtils
* @param options 生成其他选项
* @return 树名称
*/
public static String getTreeName(JSONObject paramsObj)
{
if (paramsObj.containsKey(GenConstants.TREE_NAME))
{
public static String getTreeName(JSONObject paramsObj) {
if (paramsObj.containsKey(GenConstants.TREE_NAME)) {
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_NAME));
}
return StringUtils.EMPTY;
@ -372,20 +325,16 @@ public class VelocityUtils
* @param genTable 业务表对象
* @return 展开按钮列序号
*/
public static int getExpandColumn(GenTable genTable)
{
public static int getExpandColumn(GenTable genTable) {
String options = genTable.getOptions();
JSONObject paramsObj = JSONObject.parseObject(options);
String treeName = paramsObj.getString(GenConstants.TREE_NAME);
int num = 0;
for (GenTableColumn column : genTable.getColumns())
{
if (column.isList())
{
for (GenTableColumn column : genTable.getColumns()) {
if (column.isList()) {
num++;
String columnName = column.getColumnName();
if (columnName.equals(treeName))
{
if (columnName.equals(treeName)) {
break;
}
}

View File

@ -15,6 +15,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="isPk" column="is_pk" />
<result property="isIncrement" column="is_increment" />
<result property="isRequired" column="is_required" />
<result property="isReadonly" column="is_readonly" />
<result property="isInsert" column="is_insert" />
<result property="isEdit" column="is_edit" />
<result property="isList" column="is_list" />
@ -30,7 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectGenTableColumnVo">
select column_id, table_id, column_name, column_comment, column_type, java_type, java_field, is_pk, is_increment, is_required, is_insert, is_edit, is_list, is_query, query_type, html_type, dict_type, sort, create_by, create_time, update_by, update_time from gen_table_column
select column_id, table_id, column_name, column_comment, column_type, java_type, java_field, is_pk, is_increment, is_required, is_insert, is_edit,is_readonly, is_list, is_query, query_type, html_type, dict_type, sort, create_by, create_time, update_by, update_time from gen_table_column
</sql>
<select id="selectGenTableColumnListByTableId" parameterType="GenTableColumn" resultMap="GenTableColumnResult">
@ -56,7 +57,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="isPk != null and isPk != ''">is_pk,</if>
<if test="isIncrement != null and isIncrement != ''">is_increment,</if>
<if test="isRequired != null and isRequired != ''">is_required,</if>
<if test="isInsert != null and isInsert != ''">is_insert,</if>
<if test="isReadonly != null and isReadonly != ''">is_readonly,</if>
<if test="isInsert != null and isInsert != ''">is_insert,</if>
<if test="isEdit != null and isEdit != ''">is_edit,</if>
<if test="isList != null and isList != ''">is_list,</if>
<if test="isQuery != null and isQuery != ''">is_query,</if>
@ -76,7 +78,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="isPk != null and isPk != ''">#{isPk},</if>
<if test="isIncrement != null and isIncrement != ''">#{isIncrement},</if>
<if test="isRequired != null and isRequired != ''">#{isRequired},</if>
<if test="isInsert != null and isInsert != ''">#{isInsert},</if>
<if test="isReadonly != null and isReadonly != ''">#{isReadonly},</if>
<if test="isInsert != null and isInsert != ''">#{isInsert},</if>
<if test="isEdit != null and isEdit != ''">#{isEdit},</if>
<if test="isList != null and isList != ''">#{isList},</if>
<if test="isQuery != null and isQuery != ''">#{isQuery},</if>
@ -100,6 +103,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
is_list = #{isList},
is_query = #{isQuery},
is_required = #{isRequired},
is_readonly = #{isReadonly},
query_type = #{queryType},
html_type = #{htmlType},
dict_type = #{dictType},

View File

@ -25,6 +25,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="formCols" column="form_cols" />
<collection property="columns" javaType="java.util.List" resultMap="GenTableColumnResult" />
</resultMap>
@ -39,6 +40,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="isPk" column="is_pk" />
<result property="isIncrement" column="is_increment" />
<result property="isRequired" column="is_required" />
<result property="isReadonly" column="is_readonly" />
<result property="isInsert" column="is_insert" />
<result property="isEdit" column="is_edit" />
<result property="isList" column="is_list" />
@ -54,7 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectGenTableVo">
select table_id, table_name, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options, create_by, create_time, update_by, update_time, remark from gen_table
select table_id, table_name, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options, create_by, create_time, update_by, update_time, remark,form_cols from gen_table
</sql>
<select id="selectGenTableList" parameterType="GenTable" resultMap="GenTableResult">
@ -98,24 +100,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult">
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,t.form_cols,
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_readonly,c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
FROM gen_table t
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
where t.table_id = #{tableId} order by c.sort
</select>
<select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,t.form_cols,
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_readonly, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
FROM gen_table t
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
where t.table_name = #{tableName} order by c.sort
</select>
<select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult">
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,t.form_cols,
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_readonly,c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
FROM gen_table t
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
order by c.sort
@ -135,7 +137,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="genType != null and genType != ''">gen_type,</if>
<if test="genPath != null and genPath != ''">gen_path,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="formCols != null and formCols != ''">form_cols,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)values(
<if test="tableName != null">#{tableName},</if>
@ -150,7 +153,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="genType != null and genType != ''">#{genType},</if>
<if test="genPath != null and genPath != ''">#{genPath},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="formCols != null and formCols != ''">#{formCols},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate()
)
</insert>
@ -174,7 +178,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="options != null and options != ''">options = #{options},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if>
update_time = sysdate()
<if test="formCols != null and formCols != ''">form_cols = #{formCols},</if>
update_time = sysdate()
</set>
where table_id = #{tableId}
</update>

View File

@ -30,7 +30,7 @@
<div class="row mt20">
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label is-required">表名称:</label>
<label class="col-sm-4 control-label is-required">表名称A</label>
<div class="col-sm-8">
<input name="tableName" class="form-control" type="text" placeholder="请输入表名称" maxlength="200" th:field="*{tableName}" required>
</div>
@ -73,6 +73,21 @@
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="form-group">
<label class="col-xs-2 control-label" title="">Form列数</label>
<div class="col-xs-10">
<label class="radio-box"> <input type="radio" name="formCols" value="1" th:field="*{formCols}" /> 单列 </label>
<label class="radio-box"> <input type="radio" name="formCols" value="2" th:field="*{formCols}" checked="checked" /> 两列 </label>
<label class="radio-box"> <input type="radio" name="formCols" value="3" th:field="*{formCols}" /> 三列 </label>
<label class="radio-box"> <input type="radio" name="formCols" value="4" th:field="*{formCols}" /> 四列 </label>
</div>
</div>
</div>
</div>
</div>
<!-- 字段信息 -->
@ -301,7 +316,7 @@
onReorderRow: onReorderRow,
columns: [{
title: "序号",
width: "5%",
width: "6%",
formatter: function (value, row, index) {
// 编号隐藏域
var columnIdHtml = $.common.sprintf("<input type='hidden' name='columns[%s].columnId' value='%s'>", index, row.columnId);
@ -361,7 +376,7 @@
{
field: 'isInsert',
title: '插入',
width: "5%",
width: "6%",
formatter: function (value, row, index) {
var isCheck = value == 1 ? 'checked' : '';
var html = $.common.sprintf("<label class='check-box'><input type='checkbox' name='columns[%s].isInsert' value='1' %s></label>", index, isCheck);
@ -371,7 +386,7 @@
{
field: 'isEdit',
title: '编辑',
width: "5%",
width: "6%",
formatter: function (value, row, index) {
var isCheck = value == 1 ? 'checked' : '';
var html = $.common.sprintf("<label class='check-box'><input type='checkbox' name='columns[%s].isEdit' value='1' %s></label>", index, isCheck);
@ -381,7 +396,7 @@
{
field: 'isList',
title: '列表',
width: "5%",
width: "6%",
formatter: function (value, row, index) {
var isCheck = value == 1 ? 'checked' : '';
var html = $.common.sprintf("<label class='check-box'><input type='checkbox' name='columns[%s].isList' value='1' %s></label>", index, isCheck);
@ -391,7 +406,7 @@
{
field: 'isQuery',
title: '查询',
width: "5%",
width: "6%",
formatter: function (value, row, index) {
var isCheck = value == 1 ? 'checked' : '';
var html = $.common.sprintf("<label class='check-box'><input type='checkbox' name='columns[%s].isQuery' value='1' %s></label>", index, isCheck);
@ -410,17 +425,27 @@
{
field: 'isRequired',
title: '必填',
width: "5%",
width: "6%",
formatter: function (value, row, index) {
var isCheck = value == 1 ? 'checked' : '';
var html = $.common.sprintf("<label class='check-box'><input type='checkbox' name='columns[%s].isRequired' value='1' %s></label>", index, isCheck);
return html;
}
},
{
field: 'isReadonly',
title: '只读',
width: "6%",
formatter: function (value, row, index) {
var isCheck = value == 1 ? 'checked' : '';
var html = $.common.sprintf("<label class='check-box'><input type='checkbox' name='columns[%s].isReadonly' value='1' %s></label>", index, isCheck);
return html;
}
},
{
field: 'htmlType',
title: '显示类型',
width: "12%",
width: "11%",
formatter: function (value, row, index) {
var data = [{ index: index, htmlType: value }];
return $("#htmlTypeTpl").tmpl(data).html();

View File

@ -2,85 +2,161 @@
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('新增${functionName}')" />
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "datetime")
<th:block th:include="include :: datetimepicker-css" />
#break
#end
#end
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "upload")
<th:block th:include="include :: bootstrap-fileinput-css"/>
#break
#end
#end
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "summernote")
<th:block th:include="include :: summernote-css" />
#break
#end
#end
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "datetime")
<th:block th:include="include :: datetimepicker-css" />
#break
#end
#end
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "upload")
<th:block th:include="include :: bootstrap-fileinput-css"/>
#break
#end
#end
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "summernote")
<th:block th:include="include :: summernote-css" />
#break
#end
#end
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-${businessName}-add">
#if($table.sub)
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-${businessName}-add">
#if($table.sub)
<h4 class="form-header h4">${functionName}信息</h4>
#end
#set($cumvar=0)
#set($field=$column.javaField)
<div class="col-md-6">
#foreach($column in $effectivecols)
#set($field=$column.javaField)
##if($column.insert && !$column.pk)
##if(($column.usableColumn) || (!$column.superColumn))
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
#set($dictType=$column.dictType)
#set($cumvar=$cumvar+1)
#if($cumvar%2==1)
#parse("vm/html/formtpl.vm")
#end
##end
##end
#end
</div>
#set($cumvar=0)
#set($field=$column.javaField)
<div class="col-md-6">
#foreach($column in $effectivecols)
#set($field=$column.javaField)
##if($column.insert && !$column.pk)
##if(($column.usableColumn) || (!$column.superColumn))
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
#set($dictType=$column.dictType)
#set($cumvar=$cumvar+1)
#if($cumvar%2==0)
#parse("vm/html/formtpl.vm")
#end
##end
##end
#end
</div>
#if($table.sub)
#end
#foreach($column in $columns)
#set($field=$column.javaField)
#if($column.insert && !$column.pk)
#if(($column.usableColumn) || (!$column.superColumn))
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
#set($dictType=$column.dictType)
#if("" != $treeParentCode && $column.javaField == $treeParentCode)
<div class="form-group">
<label class="col-sm-3 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8">
<div class="input-group">
#set($BusinessName=$businessName.substring(0,1).toUpperCase() + ${businessName.substring(1)})
#set($treeId = "${className}?.${treeCode}")
<input id="treeId" name="${treeParentCode}" type="hidden" th:value="${${treeId}}"/>
<input class="form-control" type="text" onclick="select${BusinessName}Tree()" id="treeName" readonly="true" th:value="${${treeName}}"#if($column.required) required#end>
<span class="input-group-addon"><i class="fa fa-search"></i></span>
</div>
</div>
</div>
#elseif($column.htmlType == "input")
<div class="form-group">
<label class="col-sm-3 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8">
<input name="${field}" class="form-control" type="text"#if($column.required) required#end>
</div>
</div>
#elseif($column.htmlType == "upload")
<div class="form-group">
<label class="col-sm-3 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8">
<input type="hidden" name="${field}">
<div class="file-loading">
<input class="form-control file-upload" id="${field}" name="file" type="file">
</div>
</div>
</div>
#elseif($column.htmlType == "summernote")
<div class="form-group">
<label class="col-sm-3 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8">
<input type="hidden" class="form-control" name="${field}">
<div class="summernote" id="${field}"></div>
</div>
</div>
#elseif($column.htmlType == "select" && "" != $dictType)
<div class="form-group">
<label class="col-sm-3 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8">
<select name="${field}" class="form-control m-b" th:with="type=${@dict.getType('${dictType}')}"#if($column.required) required#end>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>
#elseif($column.htmlType == "select" && $dictType)
<div class="form-group">
<label class="col-sm-3 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8">
<select name="${field}" class="form-control m-b"#if($column.required) required#end>
<option value="">所有</option>
</select>
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
</div>
</div>
#elseif($column.htmlType == "checkbox" && "" != $dictType)
<div class="form-group">
<label class="col-sm-3 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8" th:with="type=${@dict.getType('${dictType}')}">
<label th:each="dict : ${type}" class="check-box">
<input name="${field}" type="checkbox" th:value="${dict.dictValue}" th:text="${dict.dictLabel}"#if($column.required) required#end>
</label>
</div>
</div>
#elseif($column.htmlType == "checkbox" && $dictType)
<div class="form-group">
<label class="col-sm-3 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8">
<label class="check-box">
<input name="${field}" type="checkbox"#if($column.required) required#end> 无
</label>
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
</div>
</div>
#elseif($column.htmlType == "radio" && "" != $dictType)
<div class="form-group">
<label class="col-sm-3 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8">
<div class="radio-box" th:each="dict : ${@dict.getType('${dictType}')}">
<input type="radio" th:id="${'${field}_' + dict.dictCode}" name="${field}" th:value="${dict.dictValue}" th:checked="${dict.default}"#if($column.required) required#end>
<label th:for="${'${field}_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
</div>
</div>
</div>
#elseif($column.htmlType == "radio" && $dictType)
<div class="form-group">
<label class="col-sm-3 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8">
<div class="radio-box">
<input type="radio" name="${field}" value=""#if($column.required) required#end>
<label th:for="${field}" th:text="未知"></label>
</div>
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
</div>
</div>
#elseif($column.htmlType == "datetime")
<div class="form-group">
<label class="col-sm-3 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8">
<div class="input-group date">
<input name="${field}" class="form-control" placeholder="yyyy-MM-dd" type="text"#if($column.required) required#end>
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
</div>
#elseif($column.htmlType == "textarea")
<div class="form-group">
<label class="col-sm-3 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8">
<textarea name="${field}" class="form-control"#if($column.required) required#end></textarea>
</div>
</div>
#end
#end
#end
#end
#if($table.sub)
<h4 class="form-header h4">${subTable.functionName}信息</h4>
<div class="row">
<div class="col-sm-12">
@ -91,113 +167,112 @@
</div>
</div>
</div>
#end
</form>
</div>
<th:block th:include="include :: footer" />
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "datetime")
<th:block th:include="include :: datetimepicker-js" />
#break
#end
#end
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "upload")
<th:block th:include="include :: bootstrap-fileinput-js"/>
#break
#end
#end
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "summernote")
<th:block th:include="include :: summernote-js" />
#break
#end
#end
<script th:inline="javascript">
#end
</form>
</div>
<th:block th:include="include :: footer" />
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "datetime")
<th:block th:include="include :: datetimepicker-js" />
#break
#end
#end
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "upload")
<th:block th:include="include :: bootstrap-fileinput-js"/>
#break
#end
#end
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "summernote")
<th:block th:include="include :: summernote-js" />
#break
#end
#end
<script th:inline="javascript">
var prefix = ctx + "${moduleName}/${businessName}"
#if($table.sub)
#foreach($column in $subTable.columns)
#if(${column.dictType} != '')
var ${column.javaField}Datas = [[${@dict.getType('${column.dictType}')}]];
#end
#end
#end
$("#form-${businessName}-add").validate({
focusCleanup: true
});
var prefix = ctx + "${moduleName}/${businessName}"
#if($table.sub)
#foreach($column in $subTable.columns)
#if(${column.dictType} != '')
var ${column.javaField}Datas = [[${@dict.getType('${column.dictType}')}]];
#end
#end
#end
$("#form-${businessName}-add").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/add", $('#form-${businessName}-add').serialize());
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/add", $('#form-${businessName}-add').serialize());
}
}
}
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "datetime")
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "datetime")
$("input[name='$column.javaField']").datetimepicker({
format: "yyyy-mm-dd",
minView: "month",
autoclose: true
});
#end
#end
#foreach($column in $columns)
#if($column.edit && !$column.superColumn && !$column.pk && $column.htmlType == "upload")
$("input[name='$column.javaField']").datetimepicker({
format: "yyyy-mm-dd",
minView: "month",
autoclose: true
});
#end
#end
#foreach($column in $columns)
#if($column.edit && !$column.superColumn && !$column.pk && $column.htmlType == "upload")
$(".file-upload").fileinput({
uploadUrl: ctx + 'common/upload',
maxFileCount: 1,
autoReplace: true
}).on('fileuploaded', function (event, data, previewId, index) {
$("input[name='" + event.currentTarget.id + "']").val(data.response.url)
}).on('fileremoved', function (event, id, index) {
$("input[name='" + event.currentTarget.id + "']").val('')
})
#break
#end
#end
#foreach($column in $columns)
#if($column.edit && !$column.superColumn && !$column.pk && $column.htmlType == "summernote")
$(".file-upload").fileinput({
uploadUrl: ctx + 'common/upload',
maxFileCount: 1,
autoReplace: true
}).on('fileuploaded', function (event, data, previewId, index) {
$("input[name='" + event.currentTarget.id + "']").val(data.response.url)
}).on('fileremoved', function (event, id, index) {
$("input[name='" + event.currentTarget.id + "']").val('')
})
#break
#end
#end
#foreach($column in $columns)
#if($column.edit && !$column.superColumn && !$column.pk && $column.htmlType == "summernote")
$(function() {
$('.summernote').summernote({
lang: 'zh-CN',
callbacks: {
onChange: function(contents, $edittable) {
$("input[name='" + this.id + "']").val(contents);
},
onImageUpload: function(files) {
var obj = this;
var data = new FormData();
data.append("file", files[0]);
$.ajax({
type: "post",
url: ctx + "common/upload",
data: data,
cache: false,
contentType: false,
processData: false,
dataType: 'json',
success: function(result) {
if (result.code == web_status.SUCCESS) {
$('#' + obj.id).summernote('insertImage', result.url);
} else {
$.modal.alertError(result.msg);
}
},
error: function(error) {
$.modal.alertWarning("图片上传失败。");
}
});
}
$(function() {
$('.summernote').summernote({
lang: 'zh-CN',
callbacks: {
onChange: function(contents, $edittable) {
$("input[name='" + this.id + "']").val(contents);
},
onImageUpload: function(files) {
var obj = this;
var data = new FormData();
data.append("file", files[0]);
$.ajax({
type: "post",
url: ctx + "common/upload",
data: data,
cache: false,
contentType: false,
processData: false,
dataType: 'json',
success: function(result) {
if (result.code == web_status.SUCCESS) {
$('#' + obj.id).summernote('insertImage', result.url);
} else {
$.modal.alertError(result.msg);
}
},
error: function(error) {
$.modal.alertWarning("图片上传失败。");
}
});
}
});
}
});
#break
#end
#end
#if($table.tree)
});
#break
#end
#end
#if($table.tree)
/*${functionName}-新增-选择父部门树*/
function select${BusinessName}Tree() {
@ -212,12 +287,12 @@
function doSubmit(index, layero){
var body = layer.getChildFrame('body', index);
$("#treeId").val(body.find('#treeId').val());
$("#treeName").val(body.find('#treeName').val());
layer.close(index);
$("#treeId").val(body.find('#treeId').val());
$("#treeName").val(body.find('#treeName').val());
layer.close(index);
}
#end
#if($table.sub)
#end
#if($table.sub)
$(function() {
var options = {
@ -227,7 +302,7 @@
showToggle: false,
showColumns: false,
sidePagination: "client",
columns: [{
columns: [{
checkbox: true
},
{
@ -235,47 +310,47 @@
align: 'center',
title: "序号",
formatter: function (value, row, index) {
var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
return columnIndex + $.table.serialNumber(index);
var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
return columnIndex + $.table.serialNumber(index);
}
},
#foreach($column in $subTable.columns)
#set($dictType=$column.dictType)
#set($javaField=$column.javaField)
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
#if($column.pk || $javaField == ${subTableFkclassName})
#elseif($column.list && "" != $dictType)
{
field: '${javaField}',
align: 'center',
title: '${comment}',
formatter: function(value, row, index) {
var name = $.common.sprintf("${subclassName}List[%s].${javaField}", index);
return $.common.dictToSelect(${javaField}Datas, value, name);
}
#if($velocityCount != $subTable.columns.size())},#end
#foreach($column in $subTable.columns)
#set($dictType=$column.dictType)
#set($javaField=$column.javaField)
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
#if($column.pk || $javaField == ${subTableFkclassName})
#elseif($column.list && "" != $dictType)
{
field: '${javaField}',
align: 'center',
title: '${comment}',
formatter: function(value, row, index) {
var name = $.common.sprintf("${subclassName}List[%s].${javaField}", index);
return $.common.dictToSelect(${javaField}Datas, value, name);
}
#if($velocityCount != $subTable.columns.size())},#end
#else
{
field: '${javaField}',
align: 'center',
title: '${comment}',
formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='${subclassName}List[%s].${javaField}' value='%s'>", index, value);
return html;
}
#if($velocityCount != $subTable.columns.size())},#end
#else
{
field: '${javaField}',
align: 'center',
title: '${comment}',
formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='${subclassName}List[%s].${javaField}' value='%s'>", index, value);
return html;
}
#if($velocityCount != $subTable.columns.size())},#end
#end
#end
}]
};
$.table.init(options);
#end
#end
}]
};
$.table.init(options);
});
function addColumn() {
@ -286,18 +361,18 @@
index: count,
row: {
index: $.table.serialNumber(count),
#foreach($column in $subTable.columns)
#set($javaField=$column.javaField)
#if($column.pk || $javaField == ${subTableFkclassName})
#else
#foreach($column in $subTable.columns)
#set($javaField=$column.javaField)
#if($column.pk || $javaField == ${subTableFkclassName})
#else
${javaField}: ""#if($velocityCount != $subTable.columns.size()),#end
#end
#end
#end
#end
}
});
}
});
}
#end
</script>
#end
</script>
</body>
</html>

View File

@ -0,0 +1,312 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('新增${functionName}')" />
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "datetime")
<th:block th:include="include :: datetimepicker-css" />
#break
#end
#end
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "upload")
<th:block th:include="include :: bootstrap-fileinput-css"/>
#break
#end
#end
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "summernote")
<th:block th:include="include :: summernote-css" />
#break
#end
#end
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-${businessName}-add">
#if($table.sub)
<h4 class="form-header h4">${functionName}信息</h4>
#end
<fieldset>
#set($cumvar=0)
#set($field=$column.javaField)
#set($colcount=$effectivecols.size())
#foreach($column in $effectivecols)
#set($field=$column.javaField)
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
#set($dictType=$column.dictType)
#set($cumvar=$cumvar+1)
#if($column.htmlType == "textarea")
#if($cumvar%2==0)
</div>
#end
<div class="form-group">
<label class="col-sm-2 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8">
<textarea name="${field}" class="form-control"#if($column.required) required#end></textarea>
</div>
</div>
#else
#if($cumvar%2==1)
<div class="form-group">
#end
#parse("\vm\html\col2\formtpl.vm")
#if($cumvar%2==0 || ($cumvar>=$colcount))
</div>
#end
#end
#end
</fieldset>
#*
<div class="row"> ## col-md-6
#foreach($column in $effectivecols)
#set($field=$column.javaField)
##if($column.insert && !$column.pk)
##if(($column.usableColumn) || (!$column.superColumn))
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
#set($dictType=$column.dictType)
##set($cumvar=$cumvar+1)
##if($cumvar%2==1)
#parse("vm/html/formtpl.vm")
##end
##end
##end
#end
*#
#if($table.sub)
<h4 class="form-header h4">${subTable.functionName}信息</h4>
<div class="row">
<div class="col-sm-12">
<button type="button" class="btn btn-white btn-sm" onclick="addColumn()"><i class="fa fa-plus"> 增加</i></button>
<button type="button" class="btn btn-white btn-sm" onclick="sub.delColumn()"><i class="fa fa-minus"> 删除</i></button>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table>
</div>
</div>
</div>
#end
</form>
</div>
<th:block th:include="include :: footer" />
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "datetime")
<th:block th:include="include :: datetimepicker-js" />
#break
#end
#end
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "upload")
<th:block th:include="include :: bootstrap-fileinput-js"/>
#break
#end
#end
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "summernote")
<th:block th:include="include :: summernote-js" />
#break
#end
#end
<script th:inline="javascript">
var prefix = ctx + "${moduleName}/${businessName}"
#if($table.sub)
#foreach($column in $subTable.columns)
#if(${column.dictType} != '')
var ${column.javaField}Datas = [[${@dict.getType('${column.dictType}')}]];
#end
#end
#end
$("#form-${businessName}-add").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/add", $('#form-${businessName}-add').serialize());
}
}
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "datetime")
$("input[name='$column.javaField']").datetimepicker({
format: "yyyy-mm-dd",
minView: "month",
autoclose: true
});
#end
#end
#foreach($column in $columns)
#if($column.edit && !$column.superColumn && !$column.pk && $column.htmlType == "upload")
$(".file-upload").fileinput({
uploadUrl: ctx + 'common/upload',
maxFileCount: 1,
autoReplace: true
}).on('fileuploaded', function (event, data, previewId, index) {
$("input[name='" + event.currentTarget.id + "']").val(data.response.url)
}).on('fileremoved', function (event, id, index) {
$("input[name='" + event.currentTarget.id + "']").val('')
})
#break
#end
#end
#foreach($column in $columns)
#if($column.edit && !$column.superColumn && !$column.pk && $column.htmlType == "summernote")
$(function() {
$('.summernote').summernote({
lang: 'zh-CN',
callbacks: {
onChange: function(contents, $edittable) {
$("input[name='" + this.id + "']").val(contents);
},
onImageUpload: function(files) {
var obj = this;
var data = new FormData();
data.append("file", files[0]);
$.ajax({
type: "post",
url: ctx + "common/upload",
data: data,
cache: false,
contentType: false,
processData: false,
dataType: 'json',
success: function(result) {
if (result.code == web_status.SUCCESS) {
$('#' + obj.id).summernote('insertImage', result.url);
} else {
$.modal.alertError(result.msg);
}
},
error: function(error) {
$.modal.alertWarning("图片上传失败。");
}
});
}
}
});
});
#break
#end
#end
#if($table.tree)
/*${functionName}-新增-选择父部门树*/
function select${BusinessName}Tree() {
var options = {
title: '${functionName}选择',
width: "380",
url: prefix + "/select${BusinessName}Tree/" + $("#treeId").val(),
callBack: doSubmit
};
$.modal.openOptions(options);
}
function doSubmit(index, layero){
var body = layer.getChildFrame('body', index);
$("#treeId").val(body.find('#treeId').val());
$("#treeName").val(body.find('#treeName').val());
layer.close(index);
}
#end
#if($table.sub)
$(function() {
var options = {
pagination: false,
showSearch: false,
showRefresh: false,
showToggle: false,
showColumns: false,
sidePagination: "client",
columns: [{
checkbox: true
},
{
field: 'index',
align: 'center',
title: "序号",
formatter: function (value, row, index) {
var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
return columnIndex + $.table.serialNumber(index);
}
},
#foreach($column in $subTable.columns)
#set($dictType=$column.dictType)
#set($javaField=$column.javaField)
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
#if($column.pk || $javaField == ${subTableFkclassName})
#elseif($column.list && "" != $dictType)
{
field: '${javaField}',
align: 'center',
title: '${comment}',
formatter: function(value, row, index) {
var name = $.common.sprintf("${subclassName}List[%s].${javaField}", index);
return $.common.dictToSelect(${javaField}Datas, value, name);
}
#if($velocityCount != $subTable.columns.size())},#end
#else
{
field: '${javaField}',
align: 'center',
title: '${comment}',
formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='${subclassName}List[%s].${javaField}' value='%s'>", index, value);
return html;
}
#if($velocityCount != $subTable.columns.size())},#end
#end
#end
}]
};
$.table.init(options);
});
function addColumn() {
var count = $("#" + table.options.id).bootstrapTable('getData').length;
sub.editColumn();
$("#" + table.options.id).bootstrapTable('insertRow', {
index: count,
row: {
index: $.table.serialNumber(count),
#foreach($column in $subTable.columns)
#set($javaField=$column.javaField)
#if($column.pk || $javaField == ${subTableFkclassName})
#else
${javaField}: ""#if($velocityCount != $subTable.columns.size()),#end
#end
#end
}
});
}
#end
</script>
</body>
</html>

View File

@ -0,0 +1,307 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('修改${functionName}')" />
#foreach($column in $columns)
#if($column.edit && !$column.superColumn && !$column.pk && $column.htmlType == "datetime")
<th:block th:include="include :: datetimepicker-css" />
#break
#end
#end
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "upload")
<th:block th:include="include :: bootstrap-fileinput-css"/>
#break
#end
#end
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "summernote")
<th:block th:include="include :: summernote-css" />
#break
#end
#end
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-${businessName}-edit" th:object="${${className}}">
#if($table.sub)
<h4 class="form-header h4">${functionName}信息</h4>
#end
<input name="${pkColumn.javaField}" th:field="*{${pkColumn.javaField}}" type="hidden">
#set($cumvar=0)
#set($colcount=$effectivecols.size())
#foreach($column in $effectivecols)
#if($column.edit && !$column.pk)
#if(($column.usableColumn) || (!$column.superColumn))
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
#set($field=$column.javaField)
#set($dictType=$column.dictType)
#set($cumvar=$cumvar+1)
#if($column.htmlType == "textarea")
#if($cumvar%2==0)
</div>
</div>
#end
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label#if($column.required) is-required#end">${comment}_${cumvar}</label>
<div class="col-sm-8">
<textarea name="${field}" class="form-control"#if($column.required) required#end></textarea>
</div>
</div>
</div>
</div>
#else
#if($cumvar%2==1)
<div class="row">
<div class="col-sm-6">
#end
#parse("\vm\html\col2\formedittpl.vm")
#if($cumvar%2==0 || ($cumvar>=$colcount))
</div>
</div>
#end
#end
#end
#end
#end
#if($table.sub)
<h4 class="form-header h4">${subTable.functionName}信息</h4>
<div class="row">
<div class="col-sm-12">
<button type="button" class="btn btn-white btn-sm" onclick="addColumn()"><i class="fa fa-plus"> 增加</i></button>
<button type="button" class="btn btn-white btn-sm" onclick="sub.delColumn()"><i class="fa fa-minus"> 删除</i></button>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table>
</div>
</div>
</div>
#end
</form>
</div>
<th:block th:include="include :: footer" />
#foreach($column in $columns)
#if($column.edit && !$column.superColumn && !$column.pk && $column.htmlType == "datetime")
<th:block th:include="include :: datetimepicker-js" />
#break
#end
#end
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "upload")
<th:block th:include="include :: bootstrap-fileinput-js"/>
#break
#end
#end
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "summernote")
<th:block th:include="include :: summernote-js" />
#break
#end
#end
<script th:inline="javascript">
var prefix = ctx + "${moduleName}/${businessName}";
#if($table.sub)
#foreach($column in $subTable.columns)
#if(${column.dictType} != '')
var ${column.javaField}Datas = [[${@dict.getType('${column.dictType}')}]];
#end
#end
#end
$("#form-${businessName}-edit").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/edit", $('#form-${businessName}-edit').serialize());
}
}
#foreach($column in $columns)
#if($column.edit && !$column.superColumn && !$column.pk && $column.htmlType == "datetime")
$("input[name='$column.javaField']").datetimepicker({
format: "yyyy-mm-dd",
minView: "month",
autoclose: true
});
#end
#end
#foreach($column in $columns)
#if($column.edit && !$column.superColumn && !$column.pk && $column.htmlType == "upload")
$(".file-upload").each(function (i) {
var val = $("input[name='" + this.id + "']").val()
$(this).fileinput({
'uploadUrl': ctx + 'common/upload',
initialPreviewAsData: true,
initialPreview: [val],
maxFileCount: 1,
autoReplace: true
}).on('fileuploaded', function (event, data, previewId, index) {
$("input[name='" + event.currentTarget.id + "']").val(data.response.url)
}).on('fileremoved', function (event, id, index) {
$("input[name='" + event.currentTarget.id + "']").val('')
})
$(this).fileinput('_initFileActions');
});
#break
#end
#end
#foreach($column in $columns)
#if($column.edit && !$column.superColumn && !$column.pk && $column.htmlType == "summernote")
$(function() {
$('.summernote').each(function(i) {
$('#' + this.id).summernote({
lang: 'zh-CN',
callbacks: {
onChange: function(contents, $edittable) {
$("input[name='" + this.id + "']").val(contents);
},
onImageUpload: function(files) {
var obj = this;
var data = new FormData();
data.append("file", files[0]);
$.ajax({
type: "post",
url: ctx + "common/upload",
data: data,
cache: false,
contentType: false,
processData: false,
dataType: 'json',
success: function(result) {
if (result.code == web_status.SUCCESS) {
$('#' + obj.id).summernote('insertImage', result.url);
} else {
$.modal.alertError(result.msg);
}
},
error: function(error) {
$.modal.alertWarning("图片上传失败。");
}
});
}
}
});
var content = $("input[name='" + this.id + "']").val();
$('#' + this.id).summernote('code', content);
})
});
#break
#end
#end
#if($table.tree)
/*${functionName}-新增-选择父部门树*/
function select${BusinessName}Tree() {
var options = {
title: '${functionName}选择',
width: "380",
url: prefix + "/select${BusinessName}Tree/" + $("#treeId").val(),
callBack: doSubmit
};
$.modal.openOptions(options);
}
function doSubmit(index, layero){
var body = layer.getChildFrame('body', index);
$("#treeId").val(body.find('#treeId').val());
$("#treeName").val(body.find('#treeName').val());
layer.close(index);
}
#end
#if($table.sub)
$(function() {
var options = {
data: [[${${className}.${subclassName}List}]],
pagination: false,
showSearch: false,
showRefresh: false,
showToggle: false,
showColumns: false,
sidePagination: "client",
columns: [{
checkbox: true
},
{
field: 'index',
align: 'center',
title: "序号",
formatter: function (value, row, index) {
var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
return columnIndex + $.table.serialNumber(index);
}
},
#foreach($column in $subTable.columns)
#set($dictType=$column.dictType)
#set($javaField=$column.javaField)
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
#if($column.pk || $javaField == ${subTableFkclassName})
#elseif($column.list && "" != $dictType)
{
field: '${javaField}',
align: 'center',
title: '${comment}',
formatter: function(value, row, index) {
var name = $.common.sprintf("${subclassName}List[%s].${javaField}", index);
return $.common.dictToSelect(${javaField}Datas, value, name);
}
#if($velocityCount != $subTable.columns.size())},#end
#else
{
field: '${javaField}',
align: 'center',
title: '${comment}',
formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='${subclassName}List[%s].${javaField}' value='%s'>", index, value);
return html;
}
#if($velocityCount != $subTable.columns.size())},#end
#end
#end
}]
};
$.table.init(options);
});
function addColumn() {
var count = $("#" + table.options.id).bootstrapTable('getData').length;
sub.editColumn();
$("#" + table.options.id).bootstrapTable('insertRow', {
index: count,
row: {
index: $.table.serialNumber(count),
#foreach($column in $subTable.columns)
#set($javaField=$column.javaField)
#if($column.pk || $javaField == ${subTableFkclassName})
#else
${javaField}: ""#if($velocityCount != $subTable.columns.size()),#end
#end
#end
}
});
}
#end
</script>
</body>
</html>

View File

@ -0,0 +1,87 @@
#if("" != $treeParentCode && $column.javaField == $treeParentCode)
<label class="col-sm-4 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8">
<div class="input-group">
#set($BusinessName=$businessName.substring(0,1).toUpperCase() + ${businessName.substring(1)})
#set($treeId = "${className}?.${treeCode}")
<input id="treeId" name="${treeParentCode}" type="hidden" th:value="${${treeId}}"/>
<input class="form-control" type="text" onclick="select${BusinessName}Tree()" id="treeName" readonly="true" th:value="${${treeName}}"#if($column.required) required#end>
<span class="input-group-addon"><i class="fa fa-search"></i></span>
</div>
</div>
#elseif($column.htmlType == "input")
<label class="col-sm-4 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8">
<input name="${field}" class="form-control" readonly="${column.readonly}" type="text"#if($column.required) required#end>
</div>
#elseif($column.htmlType == "upload")
<label class="col-sm-4 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8">
<input type="hidden" name="${field}">
<div class="file-loading">
<input class="form-control file-upload" id="${field}" name="file" type="file">
</div>
</div>
#elseif($column.htmlType == "summernote")
<label class="col-sm-4 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8">
<input type="hidden" class="form-control" name="${field}">
<div class="summernote" id="${field}"></div>
</div>
#elseif($column.htmlType == "select" && "" != $dictType)
<label class="col-sm-4 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8">
<select name="${field}" class="form-control m-b" th:with="type=${@dict.getType('${dictType}')}"#if($column.required) required#end>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
#elseif($column.htmlType == "select" && $dictType)
<label class="col-sm-4 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8">
<select name="${field}" class="form-control m-b"#if($column.required) required#end>
<option value="">所有</option>
</select>
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
</div>
#elseif($column.htmlType == "checkbox" && "" != $dictType)
<label class="col-sm-4 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8" th:with="type=${@dict.getType('${dictType}')}">
<label th:each="dict : ${type}" class="check-box">
<input name="${field}" type="checkbox" th:value="${dict.dictValue}" th:text="${dict.dictLabel}"#if($column.required) required#end>
</label>
</div>
#elseif($column.htmlType == "checkbox" && $dictType)
<label class="col-sm-4 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8">
<label class="check-box">
<input name="${field}" type="checkbox"#if($column.required) required#end> 无
</label>
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
</div>
#elseif($column.htmlType == "radio" && "" != $dictType)
<label class="col-sm-4 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8">
<div class="radio-box" th:each="dict : ${@dict.getType('${dictType}')}">
<input type="radio" th:id="${'${field}_' + dict.dictCode}" name="${field}" th:value="${dict.dictValue}" th:checked="${dict.default}"#if($column.required) required#end>
<label th:for="${'${field}_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
</div>
</div>
#elseif($column.htmlType == "radio" && $dictType)
<label class="col-sm-4 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8">
<div class="radio-box">
<input type="radio" name="${field}" value=""#if($column.required) required#end>
<label th:for="${field}" th:text="未知"></label>
</div>
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
</div>
#elseif($column.htmlType == "datetime")
<label class="col-sm-4 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8">
<div class="input-group date">
<input name="${field}" class="form-control" placeholder="yyyy-MM-dd" type="text"#if($column.required) required#end>
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
#end

View File

@ -0,0 +1,104 @@
#if("" != $treeParentCode && $column.javaField == $treeParentCode)
<label class="col-sm-2 control-label#if($column.required) is-required#end">${comment}_${cumvar}</label>
<div class="col-sm-3">
<div class="input-group">
#set($BusinessName=$businessName.substring(0,1).toUpperCase() + ${businessName.substring(1)})
#set($treeId = "${className}?.${treeCode}")
<input id="treeId" name="${treeParentCode}" type="hidden" th:value="${${treeId}}"/>
<input class="form-control" type="text" onclick="select${BusinessName}Tree()" id="treeName" #if($column.readonly) readonly="readonly" #end th:value="${${treeName}}"#if($column.required) required#end>
<span class="input-group-addon"><i class="fa fa-search"></i></span>
</div>
</div>
#elseif($column.htmlType == "input")
<label class="col-sm-2 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-3">
<input name="${field}" class="form-control" #if($column.readonly) readonly="readonly" #end type="text"#if($column.required) required#end>
</div>
#elseif($column.htmlType == "upload")
<label class="col-sm-2 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-3">
<input type="hidden" name="${field}">
<div class="file-loading">
<input class="form-control file-upload" id="${field}" name="file" type="file">
</div>
</div>
#elseif($column.htmlType == "summernote")
<label class="col-sm-2 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-3">
<input type="hidden" class="form-control" name="${field}">
<div class="summernote" id="${field}"></div>
</div>
#elseif($column.htmlType == "select" && "" != $dictType)
<label class="col-sm-2 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-3">
<select name="${field}" class="form-control m-b" th:with="type=${@dict.getType('${dictType}')}"#if($column.required) required#end>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
#elseif($column.htmlType == "select" && $dictType)
<label class="col-sm-2 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-3">
<select name="${field}" class="form-control m-b"#if($column.required) required#end>
<option value="">所有</option>
</select>
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
</div>
#elseif($column.htmlType == "checkbox" && "" != $dictType)
<label class="col-sm-2 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-3" th:with="type=${@dict.getType('${dictType}')}">
<label th:each="dict : ${type}" class="check-box">
<input name="${field}" type="checkbox" th:value="${dict.dictValue}" th:text="${dict.dictLabel}"#if($column.required) required#end>
</label>
</div>
#elseif($column.htmlType == "checkbox" && $dictType)
<label class="col-sm-2 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-3">
<label class="check-box">
<input name="${field}" type="checkbox"#if($column.required) required#end> 无
</label>
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
</div>
#elseif($column.htmlType == "radio" && "" != $dictType)
<label class="col-sm-2 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-3">
<div class="radio-box" th:each="dict : ${@dict.getType('${dictType}')}">
<input type="radio" th:id="${'${field}_' + dict.dictCode}" name="${field}" th:value="${dict.dictValue}" th:checked="${dict.default}"#if($column.required) required#end>
<label th:for="${'${field}_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
</div>
</div>
#elseif($column.htmlType == "radio" && $dictType)
<label class="col-sm-2 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-3">
<div class="radio-box">
<input type="radio" name="${field}" value=""#if($column.required) required#end>
<label th:for="${field}" th:text="未知"></label>
</div>
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
</div>
#elseif($column.htmlType == "datetime")
<label class="col-sm-2 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-3">
<div class="input-group date">
<input name="${field}" class="form-control" placeholder="yyyy-MM-dd" #if($column.readonly) readonly="readonly" #end type="text"#if($column.required) required#end>
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
#end

View File

@ -1,115 +0,0 @@
#if("" != $treeParentCode && $column.javaField == $treeParentCode)
<div class="form-group">
<label class="col-sm-3 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8">
<div class="input-group">
#set($BusinessName=$businessName.substring(0,1).toUpperCase() + ${businessName.substring(1)})
#set($treeId = "${className}?.${treeCode}")
<input id="treeId" name="${treeParentCode}" type="hidden" th:value="${${treeId}}"/>
<input class="form-control" type="text" onclick="select${BusinessName}Tree()" id="treeName" readonly="true" th:value="${${treeName}}"#if($column.required) required#end>
<span class="input-group-addon"><i class="fa fa-search"></i></span>
</div>
</div>
</div>
#elseif($column.htmlType == "input")
<div class="form-group">
<label class="col-sm-3 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8">
<input name="${field}" class="form-control" type="text"#if($column.required) required#end>
</div>
</div>
#elseif($column.htmlType == "upload")
<div class="form-group">
<label class="col-sm-3 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8">
<input type="hidden" name="${field}">
<div class="file-loading">
<input class="form-control file-upload" id="${field}" name="file" type="file">
</div>
</div>
</div>
#elseif($column.htmlType == "summernote")
<div class="form-group">
<label class="col-sm-3 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8">
<input type="hidden" class="form-control" name="${field}">
<div class="summernote" id="${field}"></div>
</div>
</div>
#elseif($column.htmlType == "select" && "" != $dictType)
<div class="form-group">
<label class="col-sm-3 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8">
<select name="${field}" class="form-control m-b" th:with="type=${@dict.getType('${dictType}')}"#if($column.required) required#end>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>
#elseif($column.htmlType == "select" && $dictType)
<div class="form-group">
<label class="col-sm-3 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8">
<select name="${field}" class="form-control m-b"#if($column.required) required#end>
<option value="">所有</option>
</select>
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
</div>
</div>
#elseif($column.htmlType == "checkbox" && "" != $dictType)
<div class="form-group">
<label class="col-sm-3 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8" th:with="type=${@dict.getType('${dictType}')}">
<label th:each="dict : ${type}" class="check-box">
<input name="${field}" type="checkbox" th:value="${dict.dictValue}" th:text="${dict.dictLabel}"#if($column.required) required#end>
</label>
</div>
</div>
#elseif($column.htmlType == "checkbox" && $dictType)
<div class="form-group">
<label class="col-sm-3 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8">
<label class="check-box">
<input name="${field}" type="checkbox"#if($column.required) required#end> 无
</label>
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
</div>
</div>
#elseif($column.htmlType == "radio" && "" != $dictType)
<div class="form-group">
<label class="col-sm-3 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8">
<div class="radio-box" th:each="dict : ${@dict.getType('${dictType}')}">
<input type="radio" th:id="${'${field}_' + dict.dictCode}" name="${field}" th:value="${dict.dictValue}" th:checked="${dict.default}"#if($column.required) required#end>
<label th:for="${'${field}_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
</div>
</div>
</div>
#elseif($column.htmlType == "radio" && $dictType)
<div class="form-group">
<label class="col-sm-3 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8">
<div class="radio-box">
<input type="radio" name="${field}" value=""#if($column.required) required#end>
<label th:for="${field}" th:text="未知"></label>
</div>
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
</div>
</div>
#elseif($column.htmlType == "datetime")
<div class="form-group">
<label class="col-sm-3 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8">
<div class="input-group date">
<input name="${field}" class="form-control" placeholder="yyyy-MM-dd" type="text"#if($column.required) required#end>
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
</div>
#elseif($column.htmlType == "textarea")
<div class="form-group">
<label class="col-sm-3 control-label#if($column.required) is-required#end">${comment}</label>
<div class="col-sm-8">
<textarea name="${field}" class="form-control"#if($column.required) required#end></textarea>
</div>
</div>
#end

View File

@ -0,0 +1,3 @@
-- 生成代码
alter table gen_table add form_cols char(1) default '2' COMMENT '表单列示 1单列 2两列 3三列 4四列' ;
alter table gen_table_column add `is_readonly` char(1) DEFAULT 0 COMMENT '是否自读字段0否 1是' ;