更新地址 更新后端
This commit is contained in:
@@ -3420,6 +3420,34 @@
|
||||
renderProductCategoryRows();
|
||||
}
|
||||
|
||||
function exportProductCategories() {
|
||||
var keyword = (document.getElementById('productCategoryKeyword').value || '').trim();
|
||||
var url = '/api/admin/product-categories/export' + (keyword ? ('?keyword=' + encodeURIComponent(keyword)) : '');
|
||||
fetch(url)
|
||||
.then(function (response) {
|
||||
var contentType = response.headers.get('content-type') || '';
|
||||
if (!response.ok || contentType.indexOf('application/json') >= 0) {
|
||||
return response.json().then(function (res) {
|
||||
throw new Error((res && (res.error || res.msg)) || '导出失败');
|
||||
}).catch(function (err) {
|
||||
throw err instanceof Error ? err : new Error('导出失败');
|
||||
});
|
||||
}
|
||||
return response.blob().then(function (blob) {
|
||||
return {
|
||||
blob: blob,
|
||||
filename: extractDownloadFilename(response.headers.get('content-disposition'), 'product-categories.xlsx')
|
||||
};
|
||||
});
|
||||
})
|
||||
.then(function (payload) {
|
||||
triggerBrowserDownload(payload.blob, payload.filename);
|
||||
})
|
||||
.catch(function (err) {
|
||||
alert(err.message || '导出失败');
|
||||
});
|
||||
}
|
||||
|
||||
document.getElementById('btnCancelProductCategoryEdit').onclick = function () {
|
||||
resetProductCategoryForm();
|
||||
};
|
||||
@@ -3435,6 +3463,10 @@
|
||||
loadProductCategories();
|
||||
};
|
||||
|
||||
document.getElementById('btnExportProductCategory').onclick = function () {
|
||||
exportProductCategories();
|
||||
};
|
||||
|
||||
document.getElementById('productCategoryKeyword').onkeydown = function (event) {
|
||||
if (event.key === 'Enter') {
|
||||
event.preventDefault();
|
||||
@@ -3976,4 +4008,3 @@
|
||||
loadAdminMenus();
|
||||
});
|
||||
}) ();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user