<th:block th:include=“include :: select2-css” />
<th:block th:include=“include :: select2-js” />
引入这个 js css 导致 格式变宽大小不统一
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('新增汇率')" />
<th:block th:include="include :: datetimepicker-css" />
<th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-rate-add">
<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="years" id="years" class="form-control" autocomplete="off" placeholder="yyyy-MM" 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-3 control-label is-required">币种:</label>
<div class="col-sm-8">
<select name="currency" class="form-control" th:with="type=${@dict.getType('sem_exchange_currency')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">汇率:</label>
<div class="col-sm-8">
<input name="exchangeRate" class="form-control" type="number" step="0.1" placeholder="请输入保留四位小数" required onkeyup="this.value= this.value.match(/\d+(\.\d{0,4})?/) ? this.value.match(/\d+(\.\d{0,4})?/)[0] : ''" >
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<th:block th:include="include :: select2-js" />
<script th:inline="javascript">
var prefix = ctx + "commerce/rate"
/*$("#form-rate-add").validate({
years: false,
rules:{
/!*years:{
minlength: 2,
maxlength: 20,
remote: {
url: prefix + "/checkYearsUnique",
type: "post",
dataType: "json",
data: {
"years": function() {
return $.common.trim($("#years").val());
}
},
dataFilter: function(data, type) {
return $.validate.unique(data);
}
}
},
currency:{
/!* currency:true,*!/
remote: {
url: prefix + "/checkCurrencyUnique",
type: "post",
dataType: "json",
data: {
"currency": function () {
return $.common.trim($("#currency").val());
}
},
dataFilter: function (data, type) {
return $.validate.unique(data);
}
}
},*!/
},
messages: {
"years": {
remote: "年月已经存在"
},
"currency": {
remote: "币种已经存在"
},
},
focusCleanup: true
});*/
$("#form-rate-add").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/add", $('#form-rate-add').serialize());
}
}
$("input[name='years']").datetimepicker({
format: "yyyy-mm",
minView: 4,
startView: 3,
autoclose: true
});
</script>
</body>
</html>
修改
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('修改汇率')" />
<th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-rate-edit" th:object="${semExchangeRate}">
<input name="id" th:field="*{id}" type="hidden">
<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="years" th:value="${semExchangeRate.years}" class="form-control" placeholder="yyyy-MM" 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-3 control-label is-required">币种:</label>
<div class="col-sm-8">
<select name="currency" class="form-control" th:with="type=${@dict.getType('sem_exchange_currency')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{currency}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">汇率:</label>
<div class="col-sm-8">
<input name="exchangeRate" th:field="*{exchangeRate}" class="form-control" type="text" required>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<script th:inline="javascript">
var prefix = ctx + "commerce/rate";
$("#form-rate-edit").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/edit", $('#form-rate-edit').serialize());
}
}
$("input[name='years']").datetimepicker({
format: "yyyy-mm",
minView: 3,
startView: 3,
autoclose: true
});
</script>
</body>
</html>