feat(资产管理): 账号状态筛选(含「只看异常」)
This commit is contained in:
@@ -123,8 +123,8 @@ function afAssetBack() {
|
||||
|
||||
// 账号总表筛选(所属手机 / 昵称)—— 用户 2026-10-17:"方便我快速找出来我要管的账号"
|
||||
function afAccFilterSet(k, v, debounce) {
|
||||
const F = _af.accFilter = _af.accFilter || {device: '', q: ''};
|
||||
if (k === '__clear') { F.device = ''; F.q = ''; }
|
||||
const F = _af.accFilter = _af.accFilter || {device: '', q: '', status: ''};
|
||||
if (k === '__clear') { F.device = ''; F.q = ''; F.status = ''; }
|
||||
else F[k] = v;
|
||||
const redraw = function () {
|
||||
afRender();
|
||||
@@ -287,12 +287,16 @@ async function afDoSingleUpload() {
|
||||
// ---------- 一级:账号总表 ----------
|
||||
function afHtmlAsset() {
|
||||
if (_af.assetView === 'items' && _af.curAccount) return afHtmlAssetItems();
|
||||
// 账号总表的筛选:**所属手机** + 昵称搜索(用户 2026-10-17:"方便我快速找出来我要管的账号")
|
||||
const F = _af.accFilter || (_af.accFilter = {device: '', q: ''});
|
||||
// 账号总表的筛选:**所属手机** + **账号状态** + 昵称搜索
|
||||
// (用户 2026-10-17:"方便我快速找出来我要管的账号";2026-10-21 加状态筛选)
|
||||
const F = _af.accFilter || (_af.accFilter = {device: '', q: '', status: ''});
|
||||
const all = _af.accounts || [];
|
||||
let shown = all;
|
||||
if (F.device === '__none') shown = shown.filter(function (a) { return !a.device_name; });
|
||||
else if (F.device) shown = shown.filter(function (a) { return a.device_name === F.device; });
|
||||
if (F.status === '__none') shown = shown.filter(function (a) { return !(a.account_status || '').trim(); });
|
||||
else if (F.status === '__abnormal') shown = shown.filter(function (a) { return (a.account_status || '').indexOf('异常') >= 0; });
|
||||
else if (F.status) shown = shown.filter(function (a) { return (a.account_status || '') === F.status; });
|
||||
if (F.q) {
|
||||
const kw = F.q.toLowerCase();
|
||||
shown = shown.filter(function (a) {
|
||||
@@ -301,6 +305,18 @@ function afHtmlAsset() {
|
||||
}
|
||||
const devNames = Array.from(new Set(all.map(function (a) { return a.device_name; })
|
||||
.filter(Boolean))).sort();
|
||||
const statusNames = Array.from(new Set(all.map(function (a) {
|
||||
return (a.account_status || '').trim();
|
||||
}).filter(Boolean)));
|
||||
// 排序:正常 → 带「异常」的 → 其它(中文排序)
|
||||
statusNames.sort(function (a, b) {
|
||||
if (a === '正常') return -1;
|
||||
if (b === '正常') return 1;
|
||||
const ea = a.indexOf('异常') >= 0, eb = b.indexOf('异常') >= 0;
|
||||
if (ea && !eb) return -1;
|
||||
if (eb && !ea) return 1;
|
||||
return a.localeCompare(b, 'zh');
|
||||
});
|
||||
const rows = shown.map(function (a) {
|
||||
const devSel = afDevSelectHtml(a);
|
||||
return '<tr>' +
|
||||
@@ -354,12 +370,23 @@ function afHtmlAsset() {
|
||||
}).join('') +
|
||||
'<option value="__none"' + (F.device === '__none' ? ' selected' : '') + '>未登记</option>' +
|
||||
'</select>' +
|
||||
'<span style="font-size:12px">账号状态</span>' +
|
||||
'<select class="form-control" style="width:150px" onchange="afAccFilterSet(\'status\', this.value)">' +
|
||||
'<option value="">全部</option>' +
|
||||
'<option value="__abnormal"' + (F.status === '__abnormal' ? ' selected' : '') + '>只看异常</option>' +
|
||||
statusNames.map(function (s) {
|
||||
return '<option value="' + esc(s) + '"' + (F.status === s ? ' selected' : '') + '>' +
|
||||
esc(s) + '</option>';
|
||||
}).join('') +
|
||||
'<option value="__none"' + (F.status === '__none' ? ' selected' : '') + '>未设置</option>' +
|
||||
'</select>' +
|
||||
'<input class="form-control" style="width:200px" value="' + esc(F.q) + '" ' +
|
||||
'oninput="afAccFilterSet(\'q\', this.value, 1)" placeholder="搜账号昵称">' +
|
||||
((F.device || F.q)
|
||||
((F.device || F.q || F.status)
|
||||
? '<button class="btn btn-xs" onclick="afAccFilterSet(\'__clear\')">清除筛选</button>' : '') +
|
||||
'<span class="text-muted" style="font-size:12px">共 ' + all.length + ' 个' +
|
||||
(((F.device || F.q) && shown.length !== all.length) ? ',筛出 ' + shown.length + ' 个' : '') + '</span>' +
|
||||
(((F.device || F.q || F.status) && shown.length !== all.length)
|
||||
? ',筛出 ' + shown.length + ' 个' : '') + '</span>' +
|
||||
'</div>' +
|
||||
'<table class="table"><thead><tr>' +
|
||||
'<th style="width:230px">账号</th><th style="width:210px">所属手机</th>' +
|
||||
@@ -367,7 +394,7 @@ function afHtmlAsset() {
|
||||
'<th style="width:400px">素材库</th><th style="width:140px">最近发布</th><th style="width:190px">操作</th>' +
|
||||
'</tr></thead><tbody>' +
|
||||
(rows || '<tr><td colspan="6" class="empty">' +
|
||||
((F.device || F.q) ? '没有符合筛选条件的账号 —— 点「清除筛选」看全部'
|
||||
((F.device || F.q || F.status) ? '没有符合筛选条件的账号 —— 点「清除筛选」看全部'
|
||||
: '还没有账号 —— 先「导入/维护账号库」,再「批量上传素材」') +
|
||||
'</td></tr>') +
|
||||
'</tbody></table>';
|
||||
|
||||
Reference in New Issue
Block a user