feat(admin): 新增后台文章列表销售数据列与快捷编辑配置项

「所有文章」列表此前只有互动数据列,缺少销售数据表头;快捷/批量编辑
展开后也只有原生三项。本次对照参考主题补齐这两处,不含专题链路。

- 新增 PostListEnhance:统管 sale/stats 两列、付费类型筛选、
  orderby=sales_volume 排序,以及四组快捷编辑字段的渲染与保存
- 新增 PostListEditFields:单独承载字段定义,主类职责保持单一
- 新增 admin-post-list.js:按 pay_type/pay_modo 勾选切换字段显隐
- 从 inc/core-hooks.php 迁出原有列实现(删 74 行),不再保留旧闭包
- 清理 admin-main.css 中确认无引用的 .aksrt-tab-pane 与 .aksrt-modal* 死块
- 新增 post-list-quick-edit-contract 测试,更新 stats/icon-picker 契约

快捷编辑锚点列用互动数据列而非参考主题的专题分类法列(本项目无专题)。
真实销量改为页面级批量查询,避免逐行查库。金额运算统一走 Ledger 的
「分」单位,不用裸浮点。保存走 edit_post 钩子,一次覆盖快捷与批量两条路径。
This commit is contained in:
2026-10-06 15:54:47 +08:00
parent 194280af72
commit ef718042d2
9 changed files with 1351 additions and 216 deletions
+8 -98
View File
@@ -668,95 +668,6 @@ code {
/**---------------------通知结束-------------**/
/**模态框------*/
.aksrt-modal-backdrop,
.aksrt-modal {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 100050;
opacity: 0;
transition: 0.3s;
}
.aksrt-modal {
display: none;
}
.aksrt-modal-backdrop {
background: rgba(0, 0, 0, 0.4);
z-index: 0;
}
.aksrt-modal.in {
opacity: 1;
overflow-x: hidden;
overflow-y: auto;
}
.aksrt-modal.in .aksrt-modal-backdrop {
opacity: 1;
}
.aksrt-modal-dialog {
max-width: calc(100% - 20px);
margin: 0;
transform: scale(0.9);
transition: transform 0.5s cubic-bezier(0.32, 0.85, 0.45, 1.18), width 0.3s;
}
.aksrt-modal-dialog.modal-mini {
width: 400px;
}
.aksrt-modal.in .aksrt-modal-dialog {
transform: scale(1);
position: relative;
}
.aksrt-modal .close.abs-close {
display: none;
}
.aksrt-modal .border-title {
padding-bottom: 12px;
margin-bottom: 12px;
border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.aksrt-modal-content {
max-height: calc(100vh - 20px);
overflow: hidden;
overflow-y: hidden;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
border-radius: 6px;
background: #fff;
border: none;
}
.aksrt-modal-body {
padding: 15px;
}
.aksrt-modal .loading-mask {
z-index: 1;
background: #fff;
border-radius: 6px;
}
.aksrt-modal .hide-btn {
position: absolute;
right: 10px;
top: 6px;
font-size: 25px;
opacity: 0.6;
cursor: pointer;
z-index: 9;
}
/**---------批量编辑------------**/
.aksrt-bulk-edit-box {
margin: -1px;
@@ -774,19 +685,18 @@ code {
margin-top: 6px;
}
/**---------------TAB-栏目------------**/
.aksrt-tab-pane {
display: none;
opacity: 0;
transition: 0.15s;
.aksrt-bulk-edit-box select,
.aksrt-bulk-edit-box input[type="text"] {
max-width: 100%;
margin-right: 4px;
}
.aksrt-tab-pane.active {
display: block;
.inline-edit-row fieldset .aksrt-bulk-edit-box {
min-width: 168px;
}
.aksrt-tab-pane.in {
opacity: 1;
.aksrt-bulk-edit-desc {
color: #787c82;
}
/**---------------后台设置项目-修改或隐藏-----------**/
+72
View File
@@ -0,0 +1,72 @@
/**
* Post list quick-edit dependency toggling.
*
* The pay quick-edit box hides fields whose dependency rules no longer match
* the selected 付费模式 / 支付类型, mirroring the reference theme's field
* visibility. Runs on the WP inline-edit row when it is opened or changed.
*/
(function () {
'use strict';
function readControl(row, fieldId) {
var input = row.querySelector(
'[name="aksrt_bulk_edit[pay][' + fieldId + ']"],' +
' [name="aksrt_bulk_edit[pay][' + fieldId + '][operation]"]'
);
if (!input) return null;
if (input.tagName === 'SELECT') return input.value;
var checked = row.querySelector(
'[name="aksrt_bulk_edit[pay][' + fieldId + ']"]:checked'
);
if (input.type === 'radio' && checked) return checked.value;
return input.value;
}
function compare(actual, operator, expected) {
if (actual === null) return true;
if (operator === '==') return actual === expected;
if (operator === '!=') return actual !== expected;
return true;
}
function updateRow(row) {
var boxes = row.querySelectorAll('.aksrt-bulk-edit-box[data-dependency]');
Array.prototype.forEach.call(boxes, function (box) {
var rules;
try {
rules = JSON.parse(box.getAttribute('data-dependency'));
} catch (e) {
return;
}
if (!Array.isArray(rules)) return;
var visible = rules.every(function (rule) {
return compare(readControl(row, rule[0]), rule[1], String(rule[2]));
});
box.style.display = visible ? '' : 'none';
});
}
function syncRows() {
var rows = document.querySelectorAll('.inline-edit-row, #bulk-edit-row');
Array.prototype.forEach.call(rows, function (row) {
if (row.querySelector('[data-dependency]')) updateRow(row);
});
}
document.addEventListener('change', function (event) {
var target = event.target;
if (!target || !target.name || target.name.indexOf('aksrt_bulk_edit[pay]') !== 0) return;
var row = target.closest('.inline-edit-row, #bulk-edit-row');
if (row) updateRow(row);
});
// WP swaps the inline-edit row without a change event.
document.addEventListener('click', function (event) {
var target = event.target;
if (!target || !target.closest) return;
if (target.closest('.editinline, .bulk-action')) window.setTimeout(syncRows, 50);
});
syncRows();
})();