字典类型列表新增抽屉效果详细信息
parent
830b5b74b9
commit
266f935229
@ -1,148 +1,256 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
|
||||
<head>
|
||||
<th:block th:include="include :: header('字典类型列表')" />
|
||||
</head>
|
||||
<body class="gray-bg">
|
||||
<div class="container-div">
|
||||
<div class="row">
|
||||
<div class="col-sm-12 search-collapse">
|
||||
<form id="type-form">
|
||||
<div class="select-list">
|
||||
<ul>
|
||||
<li>
|
||||
字典名称:<input type="text" name="dictName"/>
|
||||
</li>
|
||||
<li>
|
||||
字典类型:<input type="text" name="dictType"/>
|
||||
</li>
|
||||
<li>
|
||||
字典状态:<select name="status" th:with="type=${@dict.getType('sys_normal_disable')}">
|
||||
<option value="">所有</option>
|
||||
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
|
||||
</select>
|
||||
</li>
|
||||
<li class="select-time">
|
||||
<label>创建时间: </label>
|
||||
<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
|
||||
<span>-</span>
|
||||
<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
|
||||
</li>
|
||||
<li>
|
||||
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i> 搜索</a>
|
||||
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i> 重置</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="btn-group-sm" id="toolbar" role="group">
|
||||
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:dict:add">
|
||||
<i class="fa fa-plus"></i> 新增
|
||||
</a>
|
||||
<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:dict:edit">
|
||||
<i class="fa fa-edit"></i> 修改
|
||||
</a>
|
||||
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:dict:remove">
|
||||
<i class="fa fa-remove"></i> 删除
|
||||
</a>
|
||||
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:dict:export">
|
||||
<i class="fa fa-download"></i> 导出
|
||||
</a>
|
||||
<a class="btn btn-danger" onclick="refreshCache()" shiro:hasPermission="system:dict:remove">
|
||||
<i class="fa fa-refresh"></i> 刷新缓存
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12 select-table table-striped">
|
||||
<table id="bootstrap-table"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<th:block th:include="include :: footer" />
|
||||
<script th:inline="javascript">
|
||||
var editFlag = [[${@permission.hasPermi('system:dict:edit')}]];
|
||||
var listFlag = [[${@permission.hasPermi('system:dict:list')}]];
|
||||
var removeFlag = [[${@permission.hasPermi('system:dict:remove')}]];
|
||||
var datas = [[${@dict.getType('sys_normal_disable')}]];
|
||||
var prefix = ctx + "system/dict";
|
||||
|
||||
$(function() {
|
||||
var options = {
|
||||
url: prefix + "/list",
|
||||
createUrl: prefix + "/add",
|
||||
updateUrl: prefix + "/edit/{id}",
|
||||
removeUrl: prefix + "/remove",
|
||||
exportUrl: prefix + "/export",
|
||||
sortName: "dictId",
|
||||
sortOrder: "asc",
|
||||
modalName: "类型",
|
||||
columns: [{
|
||||
checkbox: true
|
||||
},
|
||||
{
|
||||
field: 'dictId',
|
||||
title: '字典主键'
|
||||
},
|
||||
{
|
||||
field: 'dictName',
|
||||
title: '字典名称',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
field: 'dictType',
|
||||
title: '字典类型',
|
||||
sortable: true,
|
||||
formatter: function(value, row, index) {
|
||||
return '<a href="javascript:void(0)" onclick="detail(\'' + row.dictId + '\')">' + value + '</a>';
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '状态',
|
||||
align: 'center',
|
||||
formatter: function(value, row, index) {
|
||||
return $.table.selectDictLabel(datas, value);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'remark',
|
||||
title: '备注',
|
||||
formatter: function(value, row, index) {
|
||||
return $.table.tooltip(value);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
align: 'center',
|
||||
formatter: function(value, row, index) {
|
||||
var actions = [];
|
||||
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.dictId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
|
||||
actions.push('<a class="btn btn-info btn-xs ' + listFlag + '" href="javascript:void(0)" onclick="detail(\'' + row.dictId + '\')"><i class="fa fa-list-ul"></i>列表</a> ');
|
||||
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.dictId + '\')"><i class="fa fa-remove"></i>删除</a>');
|
||||
return actions.join('');
|
||||
}
|
||||
}]
|
||||
};
|
||||
$.table.init(options);
|
||||
});
|
||||
|
||||
/*字典列表-详细*/
|
||||
function detail(dictId) {
|
||||
var url = prefix + '/detail/' + dictId;
|
||||
$.modal.openTab("字典数据", url);
|
||||
}
|
||||
|
||||
/** 刷新字典缓存 */
|
||||
function refreshCache() {
|
||||
$.operate.get(prefix + "/refreshCache");
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
|
||||
<head>
|
||||
<th:block th:include="include :: header('字典类型列表')" />
|
||||
<style>.drawer-mask{display:none;position:fixed;inset:0;background:rgba(0,0,0,0.18);z-index:1040}.drawer-panel{position:fixed;top:0;right:0;width:800px;max-width:95vw;height:100%;background:#fff;z-index:1050;box-shadow:-4px 0 24px rgba(0,0,0,0.13);transform:translateX(100%);transition:transform .28s cubic-bezier(.4,0,.2,1);display:flex;flex-direction:column}.drawer-panel.open{transform:translateX(0)}.drawer-head{display:flex;align-items:center;justify-content:space-between;padding:14px 20px;border-bottom:1px solid #e8ecf0;background:#f7f9fb;flex-shrink:0}.drawer-head-left{display:flex;align-items:center;gap:10px}.drawer-title{font-size:14px;font-weight:600;color:#2c3e50}.drawer-subtitle{font-size:12px;color:#95a5a6;font-family:monospace}.drawer-close{background:0;border:0;font-size:18px;color:#aaa;cursor:pointer;line-height:1;padding:2px 6px;border-radius:4px}.drawer-close:hover{background:#f0f2f5;color:#555}.drawer-body{flex:1;overflow-y:auto;padding:16px 20px}.drawer-loading{display:flex;align-items:center;justify-content:center;height:120px;color:#aaa;font-size:13px;gap:8px}.drawer-empty{text-align:center;color:#bbb;padding:40px 0;font-size:13px}.dict-card-wrap{border:1px solid #e8ecf0;border-radius:6px;overflow:hidden;margin-bottom:8px}.dict-card{display:grid;grid-template-columns:1fr 1fr 1fr}.dict-card-row{display:grid;grid-template-columns:82px 1fr;border-bottom:1px solid #f0f4f8;border-right:1px solid #f0f4f8}.dict-card-row:nth-child(3n){border-right:0}.dict-card-row:nth-last-child(-n+3){border-bottom:0}.dict-card-key{padding:9px 14px;font-size:12px;color:#888;background:#f7f9fb;border-right:1px solid #f0f4f8}.dict-card-val{padding:9px 14px;font-size:13px;color:#2c3e50;word-break:break-all}.dict-card-row.dict-card-full{grid-column:1 / -1;border-right:0;border-bottom:0}.dict-badge{display:inline-block;padding:2px 8px;border-radius:3px;font-size:11px;font-weight:600}.dict-badge-ok{background:#f0faf4;color:#27ae60;border:1px solid #b7dfca}.dict-badge-off{background:#fff5f5;color:#e74c3c;border:1px solid #f5c6c6}.drawer-stats{display:flex;gap:12px;margin-bottom:14px}.drawer-stat{flex:1;background:#f7f9fb;border:1px solid #e8ecf0;border-radius:6px;padding:10px 14px;text-align:center}.drawer-stat-num{font-size:20px;font-weight:700;color:#2c3e50}.drawer-stat-label{font-size:11px;color:#95a5a6;margin-top:2px}</style>
|
||||
</head>
|
||||
<body class="gray-bg">
|
||||
<div class="container-div">
|
||||
<div class="row">
|
||||
<div class="col-sm-12 search-collapse">
|
||||
<form id="type-form">
|
||||
<div class="select-list">
|
||||
<ul>
|
||||
<li>
|
||||
字典名称:<input type="text" name="dictName"/>
|
||||
</li>
|
||||
<li>
|
||||
字典类型:<input type="text" name="dictType"/>
|
||||
</li>
|
||||
<li>
|
||||
字典状态:<select name="status" th:with="type=${@dict.getType('sys_normal_disable')}">
|
||||
<option value="">所有</option>
|
||||
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
|
||||
</select>
|
||||
</li>
|
||||
<li class="select-time">
|
||||
<label>创建时间: </label>
|
||||
<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
|
||||
<span>-</span>
|
||||
<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
|
||||
</li>
|
||||
<li>
|
||||
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i> 搜索</a>
|
||||
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i> 重置</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="btn-group-sm" id="toolbar" role="group">
|
||||
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:dict:add">
|
||||
<i class="fa fa-plus"></i> 新增
|
||||
</a>
|
||||
<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:dict:edit">
|
||||
<i class="fa fa-edit"></i> 修改
|
||||
</a>
|
||||
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:dict:remove">
|
||||
<i class="fa fa-remove"></i> 删除
|
||||
</a>
|
||||
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:dict:export">
|
||||
<i class="fa fa-download"></i> 导出
|
||||
</a>
|
||||
<a class="btn btn-danger" onclick="refreshCache()" shiro:hasPermission="system:dict:remove">
|
||||
<i class="fa fa-refresh"></i> 刷新缓存
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12 select-table table-striped">
|
||||
<table id="bootstrap-table"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 抽屉遮罩 -->
|
||||
<div class="drawer-mask" id="drawerMask" onclick="closeDrawer()"></div>
|
||||
|
||||
<!-- 抽屉面板 -->
|
||||
<div class="drawer-panel" id="drawerPanel">
|
||||
<div class="drawer-head">
|
||||
<div class="drawer-head-left">
|
||||
<i class="fa fa-list-ul" style="color:#5b9bd5;"></i>
|
||||
<span class="drawer-title" id="drawerTitle">字典数据</span>
|
||||
<span class="drawer-subtitle" id="drawerSubtitle"></span>
|
||||
</div>
|
||||
<button class="drawer-close" onclick="closeDrawer()" title="关闭">✕</button>
|
||||
</div>
|
||||
<div class="drawer-body" id="drawerBody">
|
||||
<div class="drawer-loading"><i class="fa fa-spinner fa-spin"></i> 加载中...</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<th:block th:include="include :: footer" />
|
||||
<script th:inline="javascript">
|
||||
var editFlag = [[${@permission.hasPermi('system:dict:edit')}]];
|
||||
var listFlag = [[${@permission.hasPermi('system:dict:list')}]];
|
||||
var removeFlag = [[${@permission.hasPermi('system:dict:remove')}]];
|
||||
var datas = [[${@dict.getType('sys_normal_disable')}]];
|
||||
var prefix = ctx + "system/dict";
|
||||
|
||||
$(function() {
|
||||
var options = {
|
||||
url: prefix + "/list",
|
||||
createUrl: prefix + "/add",
|
||||
updateUrl: prefix + "/edit/{id}",
|
||||
removeUrl: prefix + "/remove",
|
||||
exportUrl: prefix + "/export",
|
||||
sortName: "dictId",
|
||||
sortOrder: "asc",
|
||||
modalName: "类型",
|
||||
columns: [{
|
||||
checkbox: true
|
||||
},
|
||||
{
|
||||
field: 'dictId',
|
||||
title: '字典主键'
|
||||
},
|
||||
{
|
||||
field: 'dictName',
|
||||
title: '字典名称',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
field: 'dictType',
|
||||
title: '字典类型',
|
||||
sortable: true,
|
||||
formatter: function(value, row, index) {
|
||||
return '<a href="javascript:void(0)" onclick="view(\'' + row.dictId + '\')">' + value + '</a>';
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '状态',
|
||||
align: 'center',
|
||||
formatter: function(value, row, index) {
|
||||
return $.table.selectDictLabel(datas, value);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'remark',
|
||||
title: '备注',
|
||||
formatter: function(value, row, index) {
|
||||
return $.table.tooltip(value);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
align: 'center',
|
||||
formatter: function(value, row, index) {
|
||||
var actions = [];
|
||||
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.dictId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
|
||||
actions.push('<a class="btn btn-info btn-xs ' + listFlag + '" href="javascript:void(0)" onclick="detail(\'' + row.dictId + '\')"><i class="fa fa-list-ul"></i>列表</a> ');
|
||||
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.dictId + '\')"><i class="fa fa-remove"></i>删除</a>');
|
||||
return actions.join('');
|
||||
}
|
||||
}]
|
||||
};
|
||||
$.table.init(options);
|
||||
});
|
||||
|
||||
/*字典列表-详细*/
|
||||
function detail(dictId) {
|
||||
var url = prefix + '/detail/' + dictId;
|
||||
$.modal.openTab("字典数据", url);
|
||||
}
|
||||
|
||||
/** 刷新字典缓存 */
|
||||
function refreshCache() {
|
||||
$.operate.get(prefix + "/refreshCache");
|
||||
}
|
||||
|
||||
/* 打开抽屉并加载字典数据 */
|
||||
function view(dictId) {
|
||||
var row = null;
|
||||
var $rows = $("#bootstrap-table").bootstrapTable('getData');
|
||||
for (var i = 0; i < $rows.length; i++) {
|
||||
if (String($rows[i].dictId) === String(dictId)) { row = $rows[i]; break; }
|
||||
}
|
||||
var typeName = row ? row.dictName : '字典数据';
|
||||
var typeKey = row ? row.dictType : '';
|
||||
|
||||
$("#drawerTitle").text(typeName);
|
||||
$("#drawerSubtitle").text(typeKey);
|
||||
$("#drawerBody").html('<div class="drawer-loading"><i class="fa fa-spinner fa-spin"></i> 加载中...</div>');
|
||||
|
||||
$("#drawerMask").show();
|
||||
$("#drawerPanel").addClass("open");
|
||||
$("body").css("overflow", "hidden");
|
||||
|
||||
// 请求字典数据列表
|
||||
$.ajax({
|
||||
url: ctx + "system/dict/data/list",
|
||||
type: "post",
|
||||
data: { dictType: typeKey, pageSize: 100, pageNum: 1 },
|
||||
dataType: "json",
|
||||
success: function(res) {
|
||||
var rows = (res && res.rows) ? res.rows : [];
|
||||
renderDrawer(rows);
|
||||
},
|
||||
error: function() {
|
||||
$("#drawerBody").html('<div class="drawer-empty"><i class="fa fa-exclamation-circle"></i><br>加载失败,请重试</div>');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* 渲染抽屉内容 */
|
||||
function renderDrawer(rows) {
|
||||
if (!rows || rows.length === 0) {
|
||||
$("#drawerBody").html('<div class="drawer-empty"><i class="fa fa-inbox fa-2x"></i><br><br>暂无字典数据</div>');
|
||||
return;
|
||||
}
|
||||
var okCount = rows.filter(function(r){ return r.status === '0'; }).length;
|
||||
var offCount = rows.length - okCount;
|
||||
|
||||
var html = '';
|
||||
// 统计
|
||||
html += '<div class="drawer-stats">';
|
||||
html += ' <div class="drawer-stat"><div class="drawer-stat-num">' + rows.length + '</div><div class="drawer-stat-label">共计条目</div></div>';
|
||||
html += ' <div class="drawer-stat"><div class="drawer-stat-num" style="color:#27ae60;">' + okCount + '</div><div class="drawer-stat-label">正常</div></div>';
|
||||
if (offCount > 0) {
|
||||
html += ' <div class="drawer-stat"><div class="drawer-stat-num" style="color:#e74c3c;">' + offCount + '</div><div class="drawer-stat-label">停用</div></div>';
|
||||
}
|
||||
html += '</div>';
|
||||
|
||||
// 数据卡片列表
|
||||
for (var i = 0; i < rows.length; i++) {
|
||||
var r = rows[i];
|
||||
var statusBadge = (r.status === '0')
|
||||
? '<span class="dict-badge dict-badge-ok">正常</span>'
|
||||
: '<span class="dict-badge dict-badge-off">停用</span>';
|
||||
|
||||
var labelHtml = r.dictLabel;
|
||||
if (r.listClass && r.listClass !== 'default') {
|
||||
labelHtml = '<span class="badge badge-' + r.listClass + '">' + r.dictLabel + '</span>';
|
||||
} else if (r.cssClass) {
|
||||
labelHtml = '<span class="' + r.cssClass + '">' + r.dictLabel + '</span>';
|
||||
}
|
||||
|
||||
html += '<div class="dict-card-wrap"><div class="dict-card">';
|
||||
html += ' <div class="dict-card-row"><div class="dict-card-key">标签</div><div class="dict-card-val">' + labelHtml + '</div></div>';
|
||||
html += ' <div class="dict-card-row"><div class="dict-card-key">键值</div><div class="dict-card-val"><code>' + r.dictValue + '</code></div></div>';
|
||||
html += ' <div class="dict-card-row"><div class="dict-card-key">状态</div><div class="dict-card-val">' + statusBadge + '</div></div>';
|
||||
html += '</div></div>';
|
||||
}
|
||||
$("#drawerBody").html(html);
|
||||
}
|
||||
|
||||
/* 关闭抽屉 */
|
||||
function closeDrawer() {
|
||||
$("#drawerPanel").removeClass("open");
|
||||
$("#drawerMask").hide();
|
||||
$("body").css("overflow", "");
|
||||
}
|
||||
|
||||
/* ESC 关闭 */
|
||||
$(document).on("keydown", function(e) {
|
||||
if (e.key === "Escape") closeDrawer();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in New Issue