字典类型列表新增抽屉效果详细信息
parent
830b5b74b9
commit
266f935229
@ -1,148 +1,256 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
|
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
|
||||||
<head>
|
<head>
|
||||||
<th:block th:include="include :: header('字典类型列表')" />
|
<th:block th:include="include :: header('字典类型列表')" />
|
||||||
</head>
|
<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>
|
||||||
<body class="gray-bg">
|
</head>
|
||||||
<div class="container-div">
|
<body class="gray-bg">
|
||||||
<div class="row">
|
<div class="container-div">
|
||||||
<div class="col-sm-12 search-collapse">
|
<div class="row">
|
||||||
<form id="type-form">
|
<div class="col-sm-12 search-collapse">
|
||||||
<div class="select-list">
|
<form id="type-form">
|
||||||
<ul>
|
<div class="select-list">
|
||||||
<li>
|
<ul>
|
||||||
字典名称:<input type="text" name="dictName"/>
|
<li>
|
||||||
</li>
|
字典名称:<input type="text" name="dictName"/>
|
||||||
<li>
|
</li>
|
||||||
字典类型:<input type="text" name="dictType"/>
|
<li>
|
||||||
</li>
|
字典类型:<input type="text" name="dictType"/>
|
||||||
<li>
|
</li>
|
||||||
字典状态:<select name="status" th:with="type=${@dict.getType('sys_normal_disable')}">
|
<li>
|
||||||
<option value="">所有</option>
|
字典状态:<select name="status" th:with="type=${@dict.getType('sys_normal_disable')}">
|
||||||
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
|
<option value="">所有</option>
|
||||||
</select>
|
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
|
||||||
</li>
|
</select>
|
||||||
<li class="select-time">
|
</li>
|
||||||
<label>创建时间: </label>
|
<li class="select-time">
|
||||||
<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
|
<label>创建时间: </label>
|
||||||
<span>-</span>
|
<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
|
||||||
<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
|
<span>-</span>
|
||||||
</li>
|
<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>
|
<li>
|
||||||
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i> 重置</a>
|
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i> 搜索</a>
|
||||||
</li>
|
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i> 重置</a>
|
||||||
</ul>
|
</li>
|
||||||
</div>
|
</ul>
|
||||||
</form>
|
</div>
|
||||||
</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">
|
<div class="btn-group-sm" id="toolbar" role="group">
|
||||||
<i class="fa fa-plus"></i> 新增
|
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:dict:add">
|
||||||
</a>
|
<i class="fa fa-plus"></i> 新增
|
||||||
<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:dict:edit">
|
</a>
|
||||||
<i class="fa fa-edit"></i> 修改
|
<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:dict:edit">
|
||||||
</a>
|
<i class="fa fa-edit"></i> 修改
|
||||||
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:dict:remove">
|
</a>
|
||||||
<i class="fa fa-remove"></i> 删除
|
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:dict:remove">
|
||||||
</a>
|
<i class="fa fa-remove"></i> 删除
|
||||||
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:dict:export">
|
</a>
|
||||||
<i class="fa fa-download"></i> 导出
|
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:dict:export">
|
||||||
</a>
|
<i class="fa fa-download"></i> 导出
|
||||||
<a class="btn btn-danger" onclick="refreshCache()" shiro:hasPermission="system:dict:remove">
|
</a>
|
||||||
<i class="fa fa-refresh"></i> 刷新缓存
|
<a class="btn btn-danger" onclick="refreshCache()" shiro:hasPermission="system:dict:remove">
|
||||||
</a>
|
<i class="fa fa-refresh"></i> 刷新缓存
|
||||||
</div>
|
</a>
|
||||||
|
</div>
|
||||||
<div class="col-sm-12 select-table table-striped">
|
|
||||||
<table id="bootstrap-table"></table>
|
<div class="col-sm-12 select-table table-striped">
|
||||||
</div>
|
<table id="bootstrap-table"></table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<th:block th:include="include :: footer" />
|
</div>
|
||||||
<script th:inline="javascript">
|
|
||||||
var editFlag = [[${@permission.hasPermi('system:dict:edit')}]];
|
<!-- 抽屉遮罩 -->
|
||||||
var listFlag = [[${@permission.hasPermi('system:dict:list')}]];
|
<div class="drawer-mask" id="drawerMask" onclick="closeDrawer()"></div>
|
||||||
var removeFlag = [[${@permission.hasPermi('system:dict:remove')}]];
|
|
||||||
var datas = [[${@dict.getType('sys_normal_disable')}]];
|
<!-- 抽屉面板 -->
|
||||||
var prefix = ctx + "system/dict";
|
<div class="drawer-panel" id="drawerPanel">
|
||||||
|
<div class="drawer-head">
|
||||||
$(function() {
|
<div class="drawer-head-left">
|
||||||
var options = {
|
<i class="fa fa-list-ul" style="color:#5b9bd5;"></i>
|
||||||
url: prefix + "/list",
|
<span class="drawer-title" id="drawerTitle">字典数据</span>
|
||||||
createUrl: prefix + "/add",
|
<span class="drawer-subtitle" id="drawerSubtitle"></span>
|
||||||
updateUrl: prefix + "/edit/{id}",
|
</div>
|
||||||
removeUrl: prefix + "/remove",
|
<button class="drawer-close" onclick="closeDrawer()" title="关闭">✕</button>
|
||||||
exportUrl: prefix + "/export",
|
</div>
|
||||||
sortName: "dictId",
|
<div class="drawer-body" id="drawerBody">
|
||||||
sortOrder: "asc",
|
<div class="drawer-loading"><i class="fa fa-spinner fa-spin"></i> 加载中...</div>
|
||||||
modalName: "类型",
|
</div>
|
||||||
columns: [{
|
</div>
|
||||||
checkbox: true
|
|
||||||
},
|
<th:block th:include="include :: footer" />
|
||||||
{
|
<script th:inline="javascript">
|
||||||
field: 'dictId',
|
var editFlag = [[${@permission.hasPermi('system:dict:edit')}]];
|
||||||
title: '字典主键'
|
var listFlag = [[${@permission.hasPermi('system:dict:list')}]];
|
||||||
},
|
var removeFlag = [[${@permission.hasPermi('system:dict:remove')}]];
|
||||||
{
|
var datas = [[${@dict.getType('sys_normal_disable')}]];
|
||||||
field: 'dictName',
|
var prefix = ctx + "system/dict";
|
||||||
title: '字典名称',
|
|
||||||
sortable: true
|
$(function() {
|
||||||
},
|
var options = {
|
||||||
{
|
url: prefix + "/list",
|
||||||
field: 'dictType',
|
createUrl: prefix + "/add",
|
||||||
title: '字典类型',
|
updateUrl: prefix + "/edit/{id}",
|
||||||
sortable: true,
|
removeUrl: prefix + "/remove",
|
||||||
formatter: function(value, row, index) {
|
exportUrl: prefix + "/export",
|
||||||
return '<a href="javascript:void(0)" onclick="detail(\'' + row.dictId + '\')">' + value + '</a>';
|
sortName: "dictId",
|
||||||
}
|
sortOrder: "asc",
|
||||||
},
|
modalName: "类型",
|
||||||
{
|
columns: [{
|
||||||
field: 'status',
|
checkbox: true
|
||||||
title: '状态',
|
},
|
||||||
align: 'center',
|
{
|
||||||
formatter: function(value, row, index) {
|
field: 'dictId',
|
||||||
return $.table.selectDictLabel(datas, value);
|
title: '字典主键'
|
||||||
}
|
},
|
||||||
},
|
{
|
||||||
{
|
field: 'dictName',
|
||||||
field: 'remark',
|
title: '字典名称',
|
||||||
title: '备注',
|
sortable: true
|
||||||
formatter: function(value, row, index) {
|
},
|
||||||
return $.table.tooltip(value);
|
{
|
||||||
}
|
field: 'dictType',
|
||||||
},
|
title: '字典类型',
|
||||||
{
|
sortable: true,
|
||||||
field: 'createTime',
|
formatter: function(value, row, index) {
|
||||||
title: '创建时间',
|
return '<a href="javascript:void(0)" onclick="view(\'' + row.dictId + '\')">' + value + '</a>';
|
||||||
sortable: true
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '操作',
|
field: 'status',
|
||||||
align: 'center',
|
title: '状态',
|
||||||
formatter: function(value, row, index) {
|
align: 'center',
|
||||||
var actions = [];
|
formatter: function(value, row, index) {
|
||||||
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> ');
|
return $.table.selectDictLabel(datas, value);
|
||||||
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('');
|
{
|
||||||
}
|
field: 'remark',
|
||||||
}]
|
title: '备注',
|
||||||
};
|
formatter: function(value, row, index) {
|
||||||
$.table.init(options);
|
return $.table.tooltip(value);
|
||||||
});
|
}
|
||||||
|
},
|
||||||
/*字典列表-详细*/
|
{
|
||||||
function detail(dictId) {
|
field: 'createTime',
|
||||||
var url = prefix + '/detail/' + dictId;
|
title: '创建时间',
|
||||||
$.modal.openTab("字典数据", url);
|
sortable: true
|
||||||
}
|
},
|
||||||
|
{
|
||||||
/** 刷新字典缓存 */
|
title: '操作',
|
||||||
function refreshCache() {
|
align: 'center',
|
||||||
$.operate.get(prefix + "/refreshCache");
|
formatter: function(value, row, index) {
|
||||||
}
|
var actions = [];
|
||||||
</script>
|
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> ');
|
||||||
</body>
|
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>
|
</html>
|
||||||
Loading…
Reference in New Issue