Files
ctbjrj/会员服务器/www/xiangmu-cloud.html
T

111 lines
4.8 KiB
HTML

<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<title>项目云管理</title>
<style>
body { font-family: "Microsoft YaHei UI", "Microsoft YaHei", sans-serif; font-size: 14px; margin: 20px; background: #f5f6f8; }
h2 { margin: 0 0 14px; }
table { border-collapse: collapse; width: 100%; background: #fff; }
th, td { border: 1px solid #d0d4da; padding: 6px 10px; text-align: left; }
th { background: #eef1f5; }
tr:hover td { background: #f4f8ff; }
.bar { margin-bottom: 12px; }
button { padding: 5px 14px; cursor: pointer; }
input { padding: 4px 8px; }
.op button { margin-right: 4px; padding: 2px 8px; font-size: 12px; }
.del { color: #c33; }
#tip { color: #2a7; margin-left: 10px; }
.nav { margin-bottom: 16px; }
.nav a { margin-right: 14px; color: #247; text-decoration: none; font-weight: 700; }
.nav a.cur { color: #f60; }
</style>
</head>
<body>
<div class="nav"><a href="/admin.html">会员管理</a><a class="cur" href="/xiangmu-cloud.html">项目云管理</a><a href="/lib-cloud.html">库备份管理</a></div>
<h2>项目云管理(按手机号查看名下云上项目)</h2>
<div class="bar">
手机号: <select id="c手机号sel" onchange="同步手机号()" style="width:150px"><option value="">-- 选择会员 --</option></select>
或输入: <input id="c手机号" style="width:130px" placeholder="手动输入">
<button onclick="云查询()">查看云上项目</button>
<span id="tip"></span>
</div>
<table id="云tbl">
<thead>
<tr><th style="width:40px"></th><th>项目编号</th><th>项目名称</th><th>上传时间</th><th>大小</th><th>操作</th></tr>
</thead>
<tbody></tbody>
</table>
<script>
function 提示(s, ok) {
var t = document.getElementById('tip');
t.textContent = s; t.style.color = ok ? '#2a7' : '#c33';
}
// 下拉选会员:从 /api/list 拉全部手机号填充;选中即同步到输入框(输入框仍可手改)
function 加载会员下拉() {
fetch('/api/list').then(r => r.json()).then(function (j) {
var sel = document.getElementById('c手机号sel');
var cur = sel.value;
sel.innerHTML = '<option value="">-- 选择会员 --</option>';
(j['会员'] || []).forEach(function (m) {
var p = m['手机号'] || '';
if (!p) return;
var op = document.createElement('option');
op.value = p;
op.textContent = p + (m['会员类型'] ? ' (' + m['会员类型'] + ')' : '');
sel.appendChild(op);
});
if (cur) sel.value = cur;
}).catch(function () {});
}
function 同步手机号() {
var v = document.getElementById('c手机号sel').value;
if (v) document.getElementById('c手机号').value = v;
}
function 格式大小(b) {
if (b >= 1048576) return (b / 1048576).toFixed(1) + 'M';
if (b >= 1024) return (b / 1024).toFixed(1) + 'K';
return b + 'B';
}
function 云查询() {
var p = document.getElementById('c手机号').value.trim();
if (!p) { 提示('请输入手机号', false); return; }
fetch('/api/proj/list?手机号=' + encodeURIComponent(p)).then(r => r.json()).then(function (j) {
var tb = document.getElementById('云tbl').getElementsByTagName('tbody')[0];
tb.innerHTML = '';
if (!j.ok) { 提示(j.msg || '查询失败', false); return; }
var list = (j['项目'] || []).filter(function (pr) { return (pr.编号 || '').indexOf('LIB_') !== 0; }); // 库备份在 lib-cloud.html,这里只显示项目
if (!list.length) { 提示('该手机号云上暂无项目', true); return; }
提示('共 ' + list.length + ' 个项目', true);
list.forEach(function (pr) {
var tr = tb.insertRow();
tr.insertCell().innerHTML = '<input type="checkbox" class="云sel">';
tr.insertCell().textContent = pr.编号 || '';
tr.insertCell().textContent = pr.名称 || '';
tr.insertCell().textContent = pr.时间 || '';
tr.insertCell().textContent = 格式大小(pr.大小 || 0);
var op = tr.insertCell(); op.className = 'op';
var del = document.createElement('button');
del.textContent = '删除'; del.className = 'del';
del.onclick = function () {
if (!confirm('确定删除云端项目 ' + (pr.名称 || pr.编号) + ' ?')) return;
fetch('/api/proj/delete', { method:'POST', headers:{'Content-Type':'application/json'},
body: JSON.stringify({ 手机号: p, 编号: pr.编号 }) })
.then(r => r.json()).then(function (d) { 提示(d.ok ? '已删除' : '删除失败:'+(d.msg||''), d.ok); 云查询(); });
};
op.appendChild(del);
var dl = document.createElement('button');
dl.textContent = '下载';
dl.onclick = function () {
location.href = '/api/proj/download?手机号=' + encodeURIComponent(p) + '&编号=' + encodeURIComponent(pr.编号);
};
op.appendChild(dl);
});
}).catch(function (e) { 提示('请求失败: ' + e, false); });
}
加载会员下拉();
</script>
</body>
</html>