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

313 lines
14 KiB
Plaintext
Raw Normal View History

2021-10-28 08:09:50 +00:00
<#assign base=request.contextPath />
<#import "../common/defaultLayout.ftl" as defaultLayout>
<@defaultLayout.layout>
<link rel="stylesheet" href="../assets/css/amazeui.switch.css"/>
<div class="admin-content">
<div class="am-cf am-padding" style="padding:1rem 1.6rem 1.6rem 1rem;margin:0px;">
<!-- padding:1px 2px 3px 4px;上、右、下,和左 -->
<div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">系统管理</strong> /
<small>后端账号管理</small>
</div>
</div>
<div class="am-g">
<div class="am-u-sm-12">
<form class="am-form" id="listForm" action="${base}/account/list" method="POST">
<input type="hidden" id="keywords" name="keywords" value='${keywords!""}'/>
<table class="am-table am-table-bordered am-table-radius table-main" style="padding:0;">
<tbody>
<tr>
<th class="am-text-middle">登录名称</th>
<td>
<div class="am-u-sm-10">
<input type="text" id="userName" class="am-form-field am-input-sm"
value="${userName!}"/>
</div>
</td>
<th class="am-text-middle">账号角色</th>
<td>
<div class="am-u-sm-10">
<select data-am-selected id="roleId" name="roleId">
<option value="-1">全部</option>
<#list roleList as role>
<option value=${role.id!} <#if roleId! =="${role.id}" >
selected
</#if>>${role.name!}</option>
</#list>
</select>
</div>
</td>
</tr>
<tr>
<th class="am-text-middle">手机号</th>
<td>
<div class="am-u-sm-10">
<input type="text" id="telephone" class="am-form-field am-input-sm"
value="${telephone!}"/>
</div>
</td>
<th class="am-text-middle">所属区域</th>
<td>
<div class="am-u-sm-10">
<select id="regionId" name="regionId"
data-am-selected="{btnSize: 'sm',maxHeight: 200,searchBox: 1}">
<option value="-1">全部</option>
<#if regionList?exists>
<#list regionList as node>
<option value="${node.id!}" <#if regionId! == "${node.id}" >
selected </#if>>${node.name}</option>
</#list>
</#if>
</select>
</div>
</td>
</tr>
<tr>
<td colspan="4">
<div align='right'>
<button type="button" class="am-btn am-btn-default am-btn-sm am-text-secondary"
id="submit-btn">搜索
</button>
</div>
</td>
</tr>
</tbody>
</table>
</form>
</div>
<div class="am-u-sm-12 am-u-md-12" style="padding:0 1.6rem 1.6rem 1rem;margin:0;">
<div class="am-btn-toolbar" style="padding-left:.5rem;">
<div class="am-btn-group am-btn-group-xs">
<@shiro.hasPermission name="ACCOUNT_ADD">
<button type="button" class="am-btn am-btn-default"
onclick="location.href='${base}/account/add'">
<span class="am-icon-plus"></span> 新增
</button>
</@shiro.hasPermission>
</div>
</div>
</div>
</div>
<div class="am-g">
<div class="am-u-sm-12">
<div class="am-scrollable-horizontal">
<table class="am-table am-table-striped am-table-hover table-main">
<thead>
<tr class="am-text-nowrap">
<th class="table-title">登录名称</th>
<th class="table-title">账号名称</th>
<th class="table-title">手机号</th>
<th class="table-title">账号角色</th>
<th class="table-title">创建时间</th>
<th class="table-title">操作</th>
</tr>
</thead>
<tbody>
<#list pager.list as list>
<tr>
<td>${list.userName!}</td>
<td>${list.realName!}</td>
<td>${list.telephone!}</td>
<td>${list.roleName!}</td>
<td><#if list.createdTime??>${list.createdTime?datetime}</#if></td>
<td>
<div class="am-btn-toolbar">
<div class="am-btn-group am-btn-group-xs">
<@shiro.hasPermission name="ACCOUNT_EDIT">
<button type="button"
class="am-btn am-btn-default am-btn-xs am-text-secondary"
onclick="location.href='${base}/account/edit?userId=${list.id}'"><span
class="am-icon-pencil-square-o"></span>编辑
</button>
</@shiro.hasPermission>
<@shiro.hasPermission name="ACCOUNT_RESET">
<button type="button"
class="am-btn am-btn-default am-btn-xs am-text-secondary"
onclick="resetPassword('${base}/account/resetPassword?userId=${list.id}')"><span
class="am-icon-pencil-square-o"></span>密码重置
</button>
</@shiro.hasPermission>
<@shiro.hasPermission name="ACCOUNT_BINDING">
<#if (list.roleName) = "工地巡查员">
<button type="button"
class="am-btn am-btn-default am-btn-xs am-text-secondary"
onclick="location.href='${base}/binding/select?id=${list.id?c}&type=sys'">
<span class="am-icon-pencil-square-o"></span>
绑定工地
</button>
</#if>
</@shiro.hasPermission>
</div>
<div class="am-btn-group am-btn-group-xs">
<div class="switch-button">
<#--是否启用0禁用1启用-->
<input id="${list.id}" type="checkbox" data-size='xs'
data-am-switch data-off-text="已禁用" data-on-text="已启用"
<#if list.enabled==1 >checked</#if>/>
</div>
</div>
<div class="am-btn-group am-btn-group-xs">
<div class="switch-button">
<@shiro.hasPermission name="ACCOUNT_DELETE">
<button type="button"
class="am-btn am-btn-default am-btn-xs am-text-secondary"
onclick="deleteAll('${base}/account/delete?userId=${list.id}')">
<span class="am-icon-trash-o"></span> 删除
</button>
</@shiro.hasPermission>
</div>
</div>
</div>
</td>
</tr>
</#list>
</tbody>
</table>
</div>
<div class="am-cf">
<!-- 分页 -->
<#if (pager.list)?exists && (pager.list?size>0) >
<div class="am-fr">
<#include "../common/common_pager.ftl">
</div>
<#else>
<div class="am-kai" align="center">
<h3>没有找到任何记录!</h3>
</div>
</#if>
</div>
</div>
</div>
<footer class="admin-content-footer">
<hr>
</footer>
</div>
</@defaultLayout.layout>
<script src="../assets/js/amazeui.switch.js"></script>
<script type="text/javascript">
$(function () {
/**
* 为每个启用或禁用按钮增加事件
*/
$(function () {
var $mycheckbox = $('.switch-button').find("input[type='checkbox']");
$mycheckbox.each(function () {
var myid = $(this).attr("id");
var prop = $(this).attr("prop");
$(this).on({
'switchChange.bootstrapSwitch': function (event, state) {
toggle(myid, state ? 1 : 0);
}
});
});
});
var keywordsObj = {};
$("#submit-btn").on("click", function () {
$("#pageNumber").val(1);
if ($("#userName").val())
keywordsObj.userName = $("#userName").val();
if ($("#roleId").val())
keywordsObj.roleId = $("#roleId").val();
if ($("#telephone").val())
keywordsObj.telephone = parseInt($("#telephone").val());
if ($("#regionId").val())
keywordsObj.regionId = parseInt($("#regionId").val());
var keywords = "";
if (!$.isEmptyObject(keywordsObj)) {
keywords = JSON.stringify(keywordsObj);
}
console.log("keywords = " + keywords);
$("#keywords").val(keywords);
$("#listForm").submit();
});
});
var resetPassword = function (url) {
var params = {};
if (window.confirm('确定要重置密码吗?')) {
$.ajax({
url: url,
data: params,
dataType: "json",
async: false,
beforeSend: function (data) {
},
success: function (data) {
if (data.status == 0) {
alert("重置成功");
window.location.href = window.location.href;
} else if (data.status == 1) {
alert("重置失败");
}
}
});
}
}
//启用或者禁用
var toggle = function (id, status) {
$.ajax({
url: "${base}/account/changeStatus",
data: {id: id, enabled: status},
type: "post",
dataType: "json",
async: false,
success: function (data) {
parent.layer.msg(data.msg);
}
});
};
// 删除
var deleteAll = function (url) {
var params = {};
if (window.confirm('确定要删除吗?')) {
$.ajax({
url: url,
data: params,
dataType: "json",
async: false,
beforeSend: function (data) {
},
success: function (data) {
if (data.status == 0) {
alert("删除成功");
window.location.href = window.location.href;
} else if (data.status == 1) {
alert("删除失败");
}
}
});
}
}
</script>