()
| 870 | } |
| 871 | |
| 872 | async function deleteSelectedTemplate() { |
| 873 | const selectEl = document.getElementById("billing-template-select"); |
| 874 | if (!selectEl || !selectEl.value) { |
| 875 | toast.warning("请先选择模板"); |
| 876 | return; |
| 877 | } |
| 878 | |
| 879 | const templates = getBillingTemplates(); |
| 880 | const selected = templates.find((tpl) => tpl.id === selectEl.value); |
| 881 | if (!selected) { |
| 882 | toast.warning("模板不存在或已删除"); |
| 883 | refreshBillingTemplateSelect(); |
| 884 | return; |
| 885 | } |
| 886 | |
| 887 | const ok = await confirm(`确认删除模板「${selected.name}」吗?`, "删除模板"); |
| 888 | if (!ok) return; |
| 889 | |
| 890 | const next = templates.filter((tpl) => tpl.id !== selected.id); |
| 891 | saveBillingTemplates(next); |
| 892 | refreshBillingTemplateSelect(); |
| 893 | setInputValue("billing-template-name", ""); |
| 894 | toast.success(`模板已删除: ${selected.name}`); |
| 895 | } |
| 896 | |
| 897 | function saveBatchProfilesAsTemplates() { |
| 898 | if (!billingBatchProfiles.length) { |
nothing calls this directly
no test coverage detected