RuoYi/ruoyi-generator/src/main/resources/vm/html/edit.html.vm

388 lines
16 KiB
Plaintext
Raw Normal View History

2019-03-31 12:56:04 +08:00
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
2019-03-31 12:56:04 +08:00
<head>
#set($isUpload = false)
#set($isSummernote = false)
#set($isDateTime = false)
<th:block th:include="include :: header('修改${functionName}')"/>
2019-08-08 08:53:12 +08:00
#foreach($column in $columns)
#if($column.edit && !$column.superColumn && !$column.pk && $column.htmlType == "datetime")
#set($isDateTime = true)
<th:block th:include="include :: datetimepicker-css"/>
#break
#end
#end
#foreach($column in $columns)
#if($column.edit && !$column.superColumn && !$column.pk && $column.htmlType == "upload")
#set($isUpload = true)
<th:block th:include="include :: bootstrap-fileinput-css"/>
#break
#end
#end
#foreach($column in $columns)
#if($column.edit && !$column.superColumn && !$column.pk && $column.htmlType == "summernote")
#set($isSummernote = true)
<th:block th:include="include :: summernote-css"/>
2019-08-08 08:53:12 +08:00
#break
#end
#end
2019-03-31 12:56:04 +08:00
</head>
2018-07-09 08:44:52 +08:00
<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}}">
2020-06-17 09:43:15 +08:00
#if($table.sub)
<h4 class="form-header h4">${functionName}信息</h4>
2020-06-17 09:43:15 +08:00
#end
<input name="${pkColumn.javaField}" th:field="*{${pkColumn.javaField}}" type="hidden">
2018-07-09 08:44:52 +08:00
#foreach($column in $columns)
#if($column.edit && !$column.pk)
#if(($column.usableColumn) || (!$column.superColumn))
2019-08-08 08:53:12 +08:00
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
2018-11-21 23:37:09 +08:00
#else
2019-08-08 08:53:12 +08:00
#set($comment=$column.columnComment)
#end
#set($field=$column.javaField)
#set($dictType=$column.dictType)
#if("" != $treeParentCode && $column.javaField == $treeParentCode)
<div class="form-group">
<label class="col-sm-3 control-label">${comment}</label>
<div class="col-sm-8">
<div class="input-group">
2019-08-08 08:53:12 +08:00
#set($BusinessName=$businessName.substring(0,1).toUpperCase() + ${businessName.substring(1)})
<input id="treeId" name="${treeParentCode}" type="hidden"
th:field="*{${treeParentCode}}"/>
<input class="form-control" type="text" onclick="select${BusinessName}Tree()"
id="treeName" readonly="true" th:field="*{parentName}"#if($column.required)
required#end>
<span class="input-group-addon"><i class="fa fa-search"></i></span>
2019-08-08 08:53:12 +08:00
</div>
</div>
</div>
2019-08-08 08:53:12 +08:00
#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}" th:field="*{${field}}" class="form-control"
type="text"#if($column.required) required#end>
2019-08-08 08:53:12 +08:00
</div>
</div>
2019-08-08 08:53:12 +08:00
#elseif($column.htmlType == "select" && "" != $dictType)
<div class="form-group">
<label class="col-sm-3 control-label">${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}" th:field="*{${field}}"></option>
</select>
2019-08-08 08:53:12 +08:00
</div>
</div>
2019-08-08 08:53:12 +08:00
#elseif($column.htmlType == "select" && $dictType)
<div class="form-group">
<label class="col-sm-3 control-label">${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>
2019-08-08 08:53:12 +08:00
</div>
</div>
#elseif($column.htmlType == "checkbox" && "" != $dictType)
<div class="form-group">
<label class="col-sm-3 control-label">${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}"
th:attr="checked=${${className}.${field}.contains(dict.dictValue)?true:false}"#if($column.required)
required#end>
</label>
</div>
</div>
#elseif($column.htmlType == "checkbox" && $dictType)
<div class="form-group">
<label class="col-sm-3 control-label">${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>
2019-08-08 08:53:12 +08:00
#elseif($column.htmlType == "radio" && "" != $dictType)
<div class="form-group">
<label class="col-sm-3 control-label">${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:field="*{${field}}"#if($column.required)
required#end>
<label th:for="${'${field}_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
2019-08-08 08:53:12 +08:00
</div>
</div>
</div>
2019-08-08 08:53:12 +08:00
#elseif($column.htmlType == "radio" && $dictType)
<div class="form-group">
<label class="col-sm-3 control-label">${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>
2019-08-08 08:53:12 +08:00
</div>
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
2019-08-08 08:53:12 +08:00
</div>
</div>
2019-08-08 08:53:12 +08:00
#elseif($column.htmlType == "datetime")
<div class="form-group">
<label class="col-sm-3 control-label">${comment}</label>
<div class="col-sm-8">
<div class="input-group date">
<input name="${field}"
th:value="${#dates.format(${className}.${field}, 'yyyy-MM-dd')}"
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>
2019-08-08 08:53:12 +08:00
</div>
</div>
</div>
2019-08-08 08:53:12 +08:00
#elseif($column.htmlType == "textarea")
<div class="form-group">
<label class="col-sm-3 control-label">${comment}</label>
<div class="col-sm-8">
<textarea name="${field}" class="form-control"#if($column.required)
required#end>[[*{${field}}]]</textarea>
</div>
</div>
#elseif($column.htmlType == "upload" || $column.htmlType == "uploads")
<div class="form-group">
<label class="col-sm-3 control-label">${comment}</label>
<div class="col-sm-8">
<div class="file-loading">
<input type="hidden" th:field="*{${field}}">
<input class="form-control file-upload" name="file" id="${field}"
type="file" #if($column.htmlType == "uploads")
multiple#end #if($column.required) required#end>
2019-08-08 08:53:12 +08:00
</div>
</div>
</div>
#elseif($column.htmlType == "summernote" )
<div class="form-group">
<label class="col-sm-3 control-label">${comment}</label>
<div class="col-sm-8">
<input type="hidden" class="form-control" th:field="*{${field}}">
<div class="summernote" id="${field}"></div>
</div>
</div>
2019-08-08 08:53:12 +08:00
#end
#end
#end
2020-06-17 09:43:15 +08:00
#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>
2020-06-17 09:43:15 +08:00
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table>
</div>
</div>
</div>
2019-08-08 08:53:12 +08:00
#end
</form>
</div>
<th:block th:include="include :: footer"/>
#if($isDateTime)
<th:block th:include="include :: datetimepicker-js"/>
#end
#if($isUpload)
<th:block th:include="include :: bootstrap-fileinput-js"/>
2019-08-08 08:53:12 +08:00
#end
#if($isSummernote)
<th:block th:include="include :: summernote-js"/>
2019-08-08 08:53:12 +08:00
#end
<script th:inline="javascript">
var prefix = ctx + "${moduleName}/${businessName}";
2020-06-17 09:43:15 +08:00
#if($table.sub)
#foreach($column in $subTable.columns)
#if(${column.dictType} != '')
var ${column.javaField}Datas = [[${@dict.getType('${column.dictType}')}]];
2020-06-17 09:43:15 +08:00
#end
#end
#end
$("#form-${businessName}-edit").validate({
focusCleanup: true
});
2019-08-08 08:53:12 +08:00
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/edit", $('#form-${businessName}-edit').serialize());
2019-08-08 08:53:12 +08:00
}
}
#if($isDateTime)
2019-08-08 08:53:12 +08:00
#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
});
2019-08-08 08:53:12 +08:00
#end
#end
#end
#if($isUpload)
// 文件上传
$(".file-upload").each(function (i) {
var val = $("input[name='" + this.id + "']").val()
$(this).fileinput({
'theme': 'explorer-fas',
'uploadUrl': '/common/upload',
overwriteInitial: false,
initialPreviewAsData: true,
initialPreview: [val], // 预览图片
maxFileCount: 1, // 最大上传数
autoReplace: true, // 自动替换预览图maxFileCount 是前置条件)
overwriteInitial: true, // 选择文件后覆盖预览图
layoutTemplates :{
actionDelete:'', //去除上传预览的缩略图中的删除图标
actionDrag:'' // 去除预览图拖拽图标
}
}).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');
});
#end
#if($isSummernote)
$(function () {
$('.summernote').each(function (i) {
var content = $("input[name='" + this.id + "']").val()
content = window.atob(content);
this.innerHTML = content;
$(this).summernote({
height: 100,
lang: 'zh-CN',
callbacks: {
onChange: function (contents, $edittable) {
$("input[name='" + this.id + "']").val(window.btoa(contents))
}
}
});
})
});
#end
2019-08-08 08:53:12 +08:00
#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);
}
2019-08-08 08:53:12 +08:00
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);
}
2020-06-17 09:43:15 +08:00
#end
#if($table.sub)
$(function () {
var options = {
data: [[${${className}.${subclassName}List}]],
pagination: false,
showSearch: false,
showRefresh: false,
showToggle: false,
showColumns: false,
columns: [
{
2020-06-17 09:43:15 +08:00
checkbox: true
},
{
field: 'index',
align: 'center',
2020-06-21 23:04:09 +08:00
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);
2020-06-21 23:04:09 +08:00
}
2020-06-17 09:43:15 +08:00
},
#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) {
2020-06-17 09:43:15 +08:00
var name = $.common.sprintf("${subclassName}List[%s].${javaField}", index);
return $.common.dictToSelect(${javaField}Datas, value, name);
}
#if($velocityCount != $subTable.columns.size())
},
#end
2020-06-17 09:43:15 +08:00
#else
{
field: '${javaField}',
align: 'center',
title: '${comment}',
formatter: function (value, row, index) {
2020-06-17 09:43:15 +08:00
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())
},
2020-06-17 09:43:15 +08:00
#end
#end
#end
}]
};
$.table.init(options);
}) ;
function addColumn() {
var count = $("#" + table.options.id).bootstrapTable('getData').length;
sub.editColumn();
2020-06-17 09:43:15 +08:00
$("#" + table.options.id).bootstrapTable('insertRow', {
index: count,
row: {
index: $.table.serialNumber(count),
2020-06-17 09:43:15 +08:00
#foreach($column in $subTable.columns)
#set($javaField=$column.javaField)
#if($column.pk || $javaField == ${subTableFkclassName})
#else
${javaField}: ""#if($velocityCount != $subTable.columns.size()),#end
2020-06-17 09:43:15 +08:00
#end
2019-08-08 08:53:12 +08:00
#end
}
});
}
#end
</script>
2018-07-09 08:44:52 +08:00
</body>
2019-08-08 08:53:12 +08:00
</html>