This commit is contained in:
@@ -841,6 +841,50 @@
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.dashboard-review-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.dashboard-review-action {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 26px;
|
||||
padding: 4px 8px;
|
||||
color: var(--momo-text-secondary);
|
||||
background: var(--momo-bg-paper);
|
||||
border: 1px solid var(--momo-border);
|
||||
border-radius: 4px;
|
||||
font-size: 10px;
|
||||
font-weight: 800;
|
||||
line-height: 1.2;
|
||||
transition: var(--momo-transition-base);
|
||||
}
|
||||
|
||||
.dashboard-review-action:hover {
|
||||
color: var(--momo-text-primary);
|
||||
background: var(--momo-bg-subtle);
|
||||
}
|
||||
|
||||
.dashboard-review-action.is-accept {
|
||||
color: var(--momo-text-inverse);
|
||||
background: var(--momo-success);
|
||||
border-color: var(--momo-success);
|
||||
}
|
||||
|
||||
.dashboard-review-action.is-accept:hover {
|
||||
color: var(--momo-text-inverse);
|
||||
filter: brightness(0.94);
|
||||
}
|
||||
|
||||
.dashboard-review-action:disabled {
|
||||
cursor: wait;
|
||||
opacity: 0.58;
|
||||
}
|
||||
|
||||
.dashboard-history-button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -280,6 +280,43 @@ let priceChartInstance = null;
|
||||
button.addEventListener('click', () => runDashboardTask(button.dataset.dashboardTask));
|
||||
});
|
||||
|
||||
function runPchomeReviewDecision(button) {
|
||||
const sku = button.dataset.reviewSku || '';
|
||||
const action = button.dataset.reviewAction || '';
|
||||
if (!sku || !action) return;
|
||||
const confirmText = button.dataset.reviewConfirm || '確認寫入這筆覆核決策?';
|
||||
if (!confirm(confirmText)) return;
|
||||
const reason = prompt('補充覆核原因(可留空)', '') || '';
|
||||
const originalText = button.textContent;
|
||||
button.disabled = true;
|
||||
button.textContent = '寫入中';
|
||||
fetch(`/api/pchome-review/${encodeURIComponent(sku)}/decision`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRFToken': getCSRFToken()
|
||||
},
|
||||
body: JSON.stringify({ action, reason })
|
||||
})
|
||||
.then(response => response.json().then(data => ({ ok: response.ok, data })))
|
||||
.then(({ ok, data }) => {
|
||||
if (!ok || !data.success) {
|
||||
throw new Error(data.message || '覆核寫入失敗');
|
||||
}
|
||||
alert(data.message || '覆核已寫入');
|
||||
window.location.reload();
|
||||
})
|
||||
.catch(error => {
|
||||
alert('錯誤: ' + error.message);
|
||||
button.disabled = false;
|
||||
button.textContent = originalText;
|
||||
});
|
||||
}
|
||||
|
||||
document.querySelectorAll('[data-pchome-review-action]').forEach(button => {
|
||||
button.addEventListener('click', () => runPchomeReviewDecision(button));
|
||||
});
|
||||
|
||||
function trackMomoLinkClick(event) {
|
||||
const link = event.target.closest('.momo-tracked-link');
|
||||
if (!link) {
|
||||
|
||||
Reference in New Issue
Block a user