134 lines
7.4 KiB
HTML
134 lines
7.4 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="zh-CN">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>{% if plan %}编辑{% else %}添加{% endif %}方案 - 后台</title>
|
||
<link rel="stylesheet" href="/static/css/style.css">
|
||
<link rel="stylesheet" href="/static/css/admin.css">
|
||
</head>
|
||
<body class="admin-page">
|
||
<header class="admin-header">
|
||
<h1>{% if plan %}编辑配置{% else %}添加配置{% endif %}</h1>
|
||
<nav>
|
||
{% if preselected_provider_id %}
|
||
<a href="{{ url_for('admin_provider_detail', provider_id=preselected_provider_id) }}">← 返回厂商</a>
|
||
{% else %}
|
||
<a href="{{ url_for('admin_dashboard') }}">← 返回列表</a>
|
||
{% endif %}
|
||
<a href="{{ url_for('admin_users') }}">用户管理</a>
|
||
<a href="{{ url_for('admin_forum_posts') }}">帖子管理</a>
|
||
<a href="{{ url_for('admin_forum_comments') }}">评论管理</a>
|
||
<a href="{{ url_for('admin_forum_categories') }}">论坛分类</a>
|
||
<a href="{{ url_for('admin_forum_reports') }}">举报审核</a>
|
||
<a href="{{ url_for('admin_logout') }}">退出</a>
|
||
</nav>
|
||
</header>
|
||
<main class="admin-main">
|
||
{% if error %}
|
||
<p class="error">{{ error }}</p>
|
||
{% endif %}
|
||
{% if not providers %}
|
||
<p class="error">请先 <a href="{{ url_for('admin_provider_new') }}">添加厂商</a>,再添加配置。</p>
|
||
{% else %}
|
||
<form method="post" class="admin-form">
|
||
{% if preselected_provider_id %}
|
||
<input type="hidden" name="from_provider_id" value="{{ preselected_provider_id }}">
|
||
{% endif %}
|
||
<div class="form-group">
|
||
<label for="provider_id">厂商 *</label>
|
||
<select id="provider_id" name="provider_id" required>
|
||
<option value="">请选择厂商</option>
|
||
{% for p in providers %}
|
||
<option value="{{ p.id }}" {{ 'selected' if (preselected_provider_id == p.id or (plan and plan.provider_id == p.id)) else '' }}>{{ p.name }}</option>
|
||
{% endfor %}
|
||
</select>
|
||
</div>
|
||
<div class="form-group">
|
||
<label>国家(可多选,点击标签)</label>
|
||
<div class="country-tags" id="country-tags">
|
||
{% for tag in country_tags %}
|
||
<label class="tag-chip"><input type="checkbox" name="country_tag" value="{{ tag }}"> {{ tag }}</label>
|
||
{% endfor %}
|
||
</div>
|
||
<input type="hidden" name="countries" id="countries" value="{{ (plan.countries or '') if plan else '' }}">
|
||
<span class="hint">勾选的国家会合并为一行显示。</span>
|
||
</div>
|
||
<div class="form-row">
|
||
<div class="form-group">
|
||
<label for="vcpu">vCPU(可选)</label>
|
||
<input type="number" id="vcpu" name="vcpu" min="0" value="{{ plan.vcpu if plan and plan.vcpu is not none else '' }}" placeholder="留空不显示">
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="memory_gb">内存 GB(可选)</label>
|
||
<input type="number" id="memory_gb" name="memory_gb" min="0" value="{{ plan.memory_gb if plan and plan.memory_gb is not none else '' }}" placeholder="留空不显示">
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="storage_gb">存储 GB(可选)</label>
|
||
<input type="number" id="storage_gb" name="storage_gb" min="0" value="{{ plan.storage_gb if plan and plan.storage_gb is not none else '' }}" placeholder="留空不显示">
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="bandwidth_mbps">带宽 Mbps(可选)</label>
|
||
<input type="number" id="bandwidth_mbps" name="bandwidth_mbps" min="0" value="{{ plan.bandwidth_mbps if plan and plan.bandwidth_mbps is not none else '' }}" placeholder="留空不显示">
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="traffic">流量(可选)</label>
|
||
<input type="text" id="traffic" name="traffic" value="{{ (plan.traffic or '') if plan else '' }}" placeholder="如:1TB、不限">
|
||
</div>
|
||
</div>
|
||
<div class="form-row">
|
||
<div class="form-group">
|
||
<label for="price_cny">月付 人民币 ¥(可选)</label>
|
||
<input type="number" id="price_cny" name="price_cny" step="0.01" min="0" value="{{ plan.price_cny if plan and plan.price_cny is not none else '' }}" placeholder="留空不显示">
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="price_usd">月付 美元 $(可选)</label>
|
||
<input type="number" id="price_usd" name="price_usd" step="0.01" min="0" value="{{ plan.price_usd if plan and plan.price_usd is not none else '' }}" placeholder="留空不显示">
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="currency">货币</label>
|
||
<select id="currency" name="currency">
|
||
<option value="CNY" {{ 'selected' if plan and plan.currency == 'CNY' else '' }}>CNY</option>
|
||
<option value="USD" {{ 'selected' if plan and plan.currency == 'USD' else '' }}>USD</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="official_url">官网/详情页链接(可选)</label>
|
||
<input type="url" id="official_url" name="official_url" value="{{ plan.official_url or '' }}" placeholder="https://...">
|
||
</div>
|
||
<div class="form-actions">
|
||
<button type="submit">保存</button>
|
||
{% if preselected_provider_id %}
|
||
<a href="{{ url_for('admin_provider_detail', provider_id=preselected_provider_id) }}" class="btn-cancel">取消</a>
|
||
{% else %}
|
||
<a href="{{ url_for('admin_dashboard') }}" class="btn-cancel">取消</a>
|
||
{% endif %}
|
||
</div>
|
||
</form>
|
||
{% endif %}
|
||
</main>
|
||
<script>
|
||
(function() {
|
||
var tags = document.getElementById('country-tags');
|
||
var hidden = document.getElementById('countries');
|
||
var saved = (hidden.value || '').split(',').map(function(s) { return s.trim(); }).filter(Boolean);
|
||
tags.querySelectorAll('input[type=checkbox]').forEach(function(cb) {
|
||
if (saved.indexOf(cb.value) !== -1) cb.checked = true;
|
||
cb.addEventListener('change', function() {
|
||
var vals = [];
|
||
tags.querySelectorAll('input[type=checkbox]:checked').forEach(function(c) { vals.push(c.value); });
|
||
hidden.value = vals.join(',');
|
||
});
|
||
});
|
||
function syncHidden() {
|
||
var vals = [];
|
||
tags.querySelectorAll('input[type=checkbox]:checked').forEach(function(c) { vals.push(c.value); });
|
||
hidden.value = vals.join(',');
|
||
}
|
||
tags.querySelectorAll('input[type=checkbox]').forEach(function(c) { c.addEventListener('change', syncHidden); });
|
||
})();
|
||
</script>
|
||
</body>
|
||
</html>
|