someone-oa/pc/settings-param.html
2025-12-11 15:21:16 +08:00

332 lines
14 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>参数配置 - OA系统</title>
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
background: #f0f2f5;
overflow: hidden;
}
.layout-container {
height: 100vh;
display: flex;
flex-direction: column;
}
.main-container {
flex: 1;
display: flex;
overflow: hidden;
}
.app-main {
flex: 1;
overflow: hidden;
display: flex;
flex-direction: column;
background: #f0f2f5;
}
.sidebar {
width: 210px;
background: #fff;
border-right: 1px solid #e6e6e6;
overflow-y: auto;
}
.menu-item { padding: 12px 24px; cursor: pointer; transition: background 0.3s; color: #303133; }
.menu-item:hover {
background: #ecf5ff;
color: #409EFF;
}
.menu-item.active { background: #409EFF; color: #fff; }
.content {
flex: 1;
padding: 20px;
overflow-y: auto;
background: #fff;
margin: 10px;
border-radius: 4px;
}
.page-header {
margin-bottom: 24px;
padding-bottom: 16px;
border-bottom: 1px solid #f0f0f0;
display: flex;
justify-content: space-between;
align-items: center;
}
.page-title { font-size: 20px; font-weight: 500; color: #303133; }
.search-form {
background: #fafafa;
padding: 16px;
border-radius: 4px;
margin-bottom: 16px;
}
.form-row {
display: flex;
gap: 16px;
margin-bottom: 12px;
}
.form-item {
flex: 1;
}
.form-input {
width: 100%;
padding: 6px 12px;
border: 1px solid #dcdfe6;
border-radius: 4px;
font-size: 14px;
}
.btn {
padding: 6px 16px;
border: none;
border-radius: 4px;
font-size: 14px;
cursor: pointer;
transition: all 0.3s;
}
.btn-primary {
background: #409EFF;
color: white;
}
.btn-primary:hover {
background: #66b1ff;
}
.btn-default {
background: white;
color: #606266;
border: 1px solid #dcdfe6;
}
.btn-default:hover {
color: #409EFF;
border-color: #409EFF;
}
table {
width: 100%;
border-collapse: collapse;
}
th, td {
padding: 12px;
text-align: left;
border-bottom: 1px solid #f0f0f0;
}
th {
background: #fafafa;
font-weight: 500;
color: #303133;
}
.action-link {
color: #409EFF;
cursor: pointer;
margin-right: 12px;
}
</style>
<!-- Vue.js -->
<script src="https://unpkg.com/vue@2/dist/vue.js"></script>
<!-- Element UI JS -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
</head>
<body>
<div id="app">
<div class="layout-container">
<div class="main-container">
<div class="sidebar">
<div class="menu-item" onclick="window.location.href='settings-org.html'">组织架构</div>
<div class="menu-item" onclick="window.location.href='settings-user.html'">账号管理</div>
<div class="menu-item" onclick="window.location.href='settings-role.html'">权限配置</div>
<div class="menu-item" onclick="window.location.href='settings-workflow.html'">流程配置</div>
<div class="menu-item" onclick="window.location.href='settings-dict.html'">字典管理</div>
<div class="menu-item active" onclick="window.location.href='settings-param.html'">参数配置</div>
<div class="menu-item" onclick="window.location.href='settings-log.html'">操作日志</div>
</div>
<div class="app-main">
<div class="content">
<div class="page-header">
<div class="page-title">参数配置</div>
<button class="btn btn-primary" onclick="addParam()">+ 新增参数</button>
</div>
<div class="search-form">
<div class="form-row">
<div class="form-item">
<input type="text" class="form-input" placeholder="参数名称/参数键名">
</div>
<div class="form-item" style="display: flex; gap: 8px;">
<button class="btn btn-primary">查询</button>
<button class="btn btn-default">重置</button>
</div>
</div>
</div>
<table>
<thead>
<tr>
<th>参数名称</th>
<th>参数键名</th>
<th>参数值</th>
<th>参数说明</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<!-- 参数数据将动态渲染 -->
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<script src="common.js"></script>
<script>
// 参数数据
let params = [
{ id: 1, name: '主框架页-默认皮肤样式名称', key: 'sys.index.skinName', value: 'skin-blue', desc: '蓝色 skin-blue、绿色 skin-green等' },
{ id: 2, name: '用户管理-账号初始密码', key: 'sys.user.initPassword', value: '123456', desc: '初始化密码 123456' },
{ id: 3, name: '文件上传-文件大小限制MB', key: 'sys.upload.maxFileSize', value: '50', desc: '单个文件最大大小单位MB' },
{ id: 4, name: '审核超时-默认超时天数', key: 'sys.approval.timeoutDays', value: '3', desc: '审核默认超时天数(工作日)' },
{ id: 5, name: '项目编号-年份格式', key: 'sys.project.yearFormat', value: 'YY', desc: '项目编号年份格式YY表示两位年份' }
];
function renderParams() {
const tbody = document.querySelector('table tbody');
if (!tbody) return;
tbody.innerHTML = params.map(p => `
<tr>
<td>${p.name}</td>
<td>${p.key}</td>
<td>${p.value}</td>
<td>${p.desc}</td>
<td>
<span class="action-link" onclick="editParam(${p.id})">修改</span>
<span class="action-link" onclick="deleteParam(${p.id})" style="color: #f56c6c;">删除</span>
</td>
</tr>
`).join('');
}
function addParam() {
const content = `
<form style="padding: 10px 0;">
<div style="margin-bottom: 16px;">
<label style="display: block; margin-bottom: 8px; color: #606266;">参数名称 <span style="color: #f56c6c;">*</span></label>
<input type="text" id="param-name" class="form-input" placeholder="如:文件上传-文件大小限制" required>
</div>
<div style="margin-bottom: 16px;">
<label style="display: block; margin-bottom: 8px; color: #606266;">参数键名 <span style="color: #f56c6c;">*</span></label>
<input type="text" id="param-key" class="form-input" placeholder="如sys.upload.maxFileSize" required>
</div>
<div style="margin-bottom: 16px;">
<label style="display: block; margin-bottom: 8px; color: #606266;">参数值 <span style="color: #f56c6c;">*</span></label>
<input type="text" id="param-value" class="form-input" placeholder="如50" required>
</div>
<div style="margin-bottom: 16px;">
<label style="display: block; margin-bottom: 8px; color: #606266;">参数说明</label>
<input type="text" id="param-desc" class="form-input" placeholder="如单个文件最大大小单位MB">
</div>
</form>
`;
CommonUtils.createModal('新增参数', content, () => {
const name = document.getElementById('param-name').value.trim();
const key = document.getElementById('param-key').value.trim();
const value = document.getElementById('param-value').value.trim();
const desc = document.getElementById('param-desc').value.trim();
if (!name || !key || !value) {
CommonUtils.showMessage('请填写必填项', 'error');
return false;
}
const maxId = params.length > 0 ? Math.max(...params.map(p => p.id)) : 0;
params.push({ id: maxId + 1, name, key, value, desc });
renderParams();
localStorage.setItem('params', JSON.stringify(params));
CommonUtils.showMessage('参数添加成功');
return true;
});
}
function editParam(id) {
const param = params.find(p => p.id === id);
if (!param) return;
const content = `
<form style="padding: 10px 0;">
<div style="margin-bottom: 16px;">
<label style="display: block; margin-bottom: 8px; color: #606266;">参数名称 <span style="color: #f56c6c;">*</span></label>
<input type="text" id="param-name" class="form-input" value="${param.name}" required>
</div>
<div style="margin-bottom: 16px;">
<label style="display: block; margin-bottom: 8px; color: #606266;">参数键名 <span style="color: #f56c6c;">*</span></label>
<input type="text" id="param-key" class="form-input" value="${param.key}" required>
</div>
<div style="margin-bottom: 16px;">
<label style="display: block; margin-bottom: 8px; color: #606266;">参数值 <span style="color: #f56c6c;">*</span></label>
<input type="text" id="param-value" class="form-input" value="${param.value}" required>
</div>
<div style="margin-bottom: 16px;">
<label style="display: block; margin-bottom: 8px; color: #606266;">参数说明</label>
<input type="text" id="param-desc" class="form-input" value="${param.desc || ''}">
</div>
</form>
`;
CommonUtils.createModal('修改参数', content, () => {
const name = document.getElementById('param-name').value.trim();
const key = document.getElementById('param-key').value.trim();
const value = document.getElementById('param-value').value.trim();
const desc = document.getElementById('param-desc').value.trim();
if (!name || !key || !value) {
CommonUtils.showMessage('请填写必填项', 'error');
return false;
}
Object.assign(param, { name, key, value, desc });
renderParams();
localStorage.setItem('params', JSON.stringify(params));
CommonUtils.showMessage('参数更新成功');
return true;
});
}
function deleteParam(id) {
CommonUtils.createModal('确认删除', '确定要删除该参数吗?删除后无法恢复。', () => {
const index = params.findIndex(p => p.id === id);
if (index > -1) {
params.splice(index, 1);
renderParams();
localStorage.setItem('params', JSON.stringify(params));
CommonUtils.showMessage('参数已删除');
}
return true;
});
}
// 初始化
window.addEventListener('DOMContentLoaded', () => {
const saved = localStorage.getItem('params');
if (saved) {
try {
params = JSON.parse(saved);
} catch (e) {
console.error('加载参数失败', e);
}
}
renderParams();
});
</script>
<script src="layout.js"></script>
<script>
injectLayout('settings');
</script>
</body>
</html>