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

303 lines
12 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" >
<head>
2019-08-08 08:53:12 +08:00
<th:block th:include="include :: header('新增${functionName}')" />
2020-12-10 18:02:39 +08:00
#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
2019-03-31 12:56:04 +08:00
</head>
2018-07-09 08:44:52 +08:00
<body class="white-bg">
2020-12-10 18:02:39 +08:00
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-${businessName}-add">
#if($table.sub)
2020-06-17 09:43:15 +08:00
<h4 class="form-header h4">${functionName}信息</h4>
2020-12-10 18:02:39 +08:00
#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)
2020-06-17 09:43:15 +08:00
<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>
2020-12-10 18:02:39 +08:00
#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">
2019-08-08 08:53:12 +08:00
2020-12-10 18:02:39 +08:00
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());
2019-08-08 08:53:12 +08:00
}
2020-12-10 18:02:39 +08:00
}
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "datetime")
2019-08-08 08:53:12 +08:00
2020-12-10 18:02:39 +08:00
$("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")
2020-07-07 17:08:31 +08:00
2020-12-10 18:02:39 +08:00
$(".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")
2020-08-07 09:27:11 +08:00
2020-12-10 18:02:39 +08:00
$(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("图片上传失败。");
}
});
}
2020-08-07 09:27:11 +08:00
}
2020-12-10 18:02:39 +08:00
});
2020-08-07 09:27:11 +08:00
});
2020-12-10 18:02:39 +08:00
#break
#end
#end
#if($table.tree)
2019-08-08 08:53:12 +08:00
/*${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);
2020-12-10 18:02:39 +08:00
$("#treeId").val(body.find('#treeId').val());
$("#treeName").val(body.find('#treeName').val());
layer.close(index);
2019-08-08 08:53:12 +08:00
}
2020-12-10 18:02:39 +08:00
#end
#if($table.sub)
2020-06-17 09:43:15 +08:00
$(function() {
var options = {
pagination: false,
showSearch: false,
showRefresh: false,
showToggle: false,
showColumns: false,
sidePagination: "client",
2020-12-10 18:02:39 +08:00
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) {
2020-12-10 18:02:39 +08:00
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
},
2020-12-10 18:02:39 +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) {
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
2020-12-10 18:02:39 +08:00
#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
2020-06-17 09:43:15 +08:00
2020-12-10 18:02:39 +08:00
#end
#end
}]
};
$.table.init(options);
2020-06-17 09:43:15 +08:00
});
function addColumn() {
var count = $("#" + table.options.id).bootstrapTable('getData').length;
sub.editColumn();
2020-12-10 18:02:39 +08:00
2020-06-17 09:43:15 +08:00
$("#" + table.options.id).bootstrapTable('insertRow', {
index: count,
row: {
index: $.table.serialNumber(count),
2020-12-10 18:02:39 +08:00
#foreach($column in $subTable.columns)
#set($javaField=$column.javaField)
#if($column.pk || $javaField == ${subTableFkclassName})
#else
2020-06-17 09:43:15 +08:00
${javaField}: ""#if($velocityCount != $subTable.columns.size()),#end
2020-12-10 18:02:39 +08:00
#end
#end
}
});
2020-06-17 09:43:15 +08:00
}
2020-12-10 18:02:39 +08:00
#end
</script>
2018-07-09 08:44:52 +08:00
</body>
2019-08-08 08:53:12 +08:00
</html>