53 lines
1.7 KiB
JavaScript
Executable File
53 lines
1.7 KiB
JavaScript
Executable File
function changePerPage(value) {
|
|
const currentUrl = new URL(window.location.href);
|
|
currentUrl.searchParams.set('per_page', value);
|
|
currentUrl.searchParams.set('page', '1');
|
|
window.location.href = currentUrl.toString();
|
|
}
|
|
|
|
function recallAllOrders() {
|
|
document.getElementById('confirmModal').style.display = 'block';
|
|
}
|
|
|
|
function closeModal() {
|
|
document.getElementById('confirmModal').style.display = 'none';
|
|
}
|
|
|
|
async function confirmRecall() {
|
|
try {
|
|
// 关闭确认模态框
|
|
closeModal();
|
|
|
|
const response = await fetch('/recall_all_orders', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
}
|
|
});
|
|
|
|
const data = await response.json();
|
|
if (data.success) {
|
|
document.getElementById('resultMessage').textContent = `成功追回 ${data.count} 个工单`;
|
|
document.getElementById('resultModal').style.display = 'block';
|
|
} else {
|
|
document.getElementById('resultMessage').textContent = '追回失败:' + data.message;
|
|
document.getElementById('resultModal').style.display = 'block';
|
|
}
|
|
} catch (error) {
|
|
document.getElementById('resultMessage').textContent = '操作失败,请重试';
|
|
document.getElementById('resultModal').style.display = 'block';
|
|
}
|
|
}
|
|
|
|
function closeResultModal() {
|
|
document.getElementById('resultModal').style.display = 'none';
|
|
window.location.reload();
|
|
}
|
|
|
|
// 添加点击模态框外部关闭功能
|
|
window.onclick = function(event) {
|
|
const modal = document.getElementById('confirmModal');
|
|
if (event.target == modal) {
|
|
closeModal();
|
|
}
|
|
} |