fourcal/src/main/resources/templates/admin/department_input.ftl

120 lines
5.0 KiB
Plaintext
Raw Normal View History

2022-09-09 08:02:55 +00:00
<#assign base=request.contextPath />
<#import "../common/defaultLayout.ftl" as defaultLayout>
<@defaultLayout.layout>
<link rel="stylesheet" href="${base}/assets/css/amazeui.switch.css"/>
<script type="text/javascript">
var base = '${base}';
</script>
<div class="admin-content">
<div class="admin-content-body">
<div class="am-cf am-padding">
<div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">配置管理</strong> /
<small>部门配置</small>
</div>
</div>
<form method="post" class="am-form" id="tmpForm"
action="${base}/department/save">
<input name="deptId" id="deptId" type="hidden" value="${deptId!}"/>
<div class="am-tabs am-margin" data-am-tabs>
<ul class="am-tabs-nav am-nav am-nav-tabs">
2022-09-26 06:17:31 +00:00
<li class="am-active"><a href="#tab1">新增/编辑</a></li>
2022-09-09 08:02:55 +00:00
</ul>
<div class="am-tabs-bd">
<div class="am-tab-panel am-fade am-in am-active" id="tab1">
<div class="am-g am-form-group am-margin-top" style="display: flex;">
<div class="am-u-sm-4 am-u-md-2 am-text-right">
<span style="color: red;">*</span>部门名称</div>
<div class="am-u-sm-6 am-u-md-6">
2022-09-26 06:17:31 +00:00
<input type="text" class="am-input" data-validate-async data-validation-message="请输入项目名称1000字符以内"
name="name" placeholder="请输入部门名称20字符以内" minlength="1" maxlength="20" id="name"
value="${department.name!}" required/>
2022-09-09 08:02:55 +00:00
</div>
<div class="am-u-sm-2 am-u-md-4 input-msg"></div>
</div>
<div class="am-g am-form-group am-margin-top">
<div class="am-u-sm-4 am-u-md-2 am-text-right">启用/禁用</div>
<div class="am-u-sm-12 am-u-md-4 switch-button" style="height: 25px;">
<input id="switch" name="switch" type="checkbox" data-size='xs'
data-am-switch data-off-text="禁用" data-on-text="启用"
<#if department.enabled==1 >checked</#if>
/>
<input type="hidden" class="am-input-sm" name="enabled" id="enabled"
value="${department.enabled!1}"/>
</div>
<div class="am-hide-sm-only am-u-md-1" style="color: red;"></div>
<div class="am-u-sm-2 am-u-md-5 input-msg"></div>
</div>
</div>
</div>
</div>
<!--选项卡tabsend-->
<div class="am-margin">
2022-09-26 06:17:31 +00:00
<button type="button" id="saveApprove" class="am-btn am-btn-primary am-btn-xs">提交保存</button>
2022-09-09 08:02:55 +00:00
<button type="button" class="am-btn am-btn-warning am-btn-xs"
onclick="javascript:history.go(-1);">返回上一级
</button>
</div>
</form>
</div>
</div>
</@defaultLayout.layout>
<script src="${base}/assets/js/amazeui.switch.js"></script>
<script>
var $mycheckbox = $('.switch-button');
2022-09-26 06:17:31 +00:00
var result = 0;
2022-09-09 08:02:55 +00:00
$mycheckbox.each(function () {
$("#switch").on({
'switchChange.bootstrapSwitch': function (event, state) {
if (state.toString() == "true") {
$("#enabled").val("1");
} else {
$("#enabled").val("0");
}
}
});
});
2022-09-26 06:17:31 +00:00
$(function () {
$("#saveApprove").click(function () {
var name = $("#name").val();
if (name.length == 0) {
window.confirm('部门名称不能为空');
return;
}
checkName();
if (result == 1) {
window.confirm('部门名称已存在');
return;
}
$("#tmpForm").attr("action","${base}/department/save");
$("#tmpForm").submit();
});
});
function checkName () {
var name = $("#name").val();
var id = $("#deptId").val();
$.ajax({
url: "${base}/department/checkName",
data: {name: name, id: id},
type: "post",
dataType: "json",
async: false,
success: function (data) {
console.log("data: " + data.status);
result = data.status;
}
});
}
2022-09-09 08:02:55 +00:00
</script>