fix del api

This commit is contained in:
2026-08-03 15:53:07 +08:00
parent 5edb0b2d69
commit 1f356af022
3 changed files with 64 additions and 11 deletions
+28 -11
View File
@@ -374,7 +374,8 @@ function requestModelName({
confirmLabel = "确认",
danger = false,
expectedValue = null,
expectedLabel = "输入内容"
expectedLabel = "输入内容",
ignoreCase = false
}) {
if (actionDialogState) closeActionDialog(null);
elements.actionDialogTitle.textContent = title;
@@ -391,7 +392,13 @@ function requestModelName({
elements.actionDialogInput.select();
});
return new Promise((resolve) => {
actionDialogState = { resolve, previousFocus, expectedValue, expectedLabel };
actionDialogState = {
resolve,
previousFocus,
expectedValue,
expectedLabel,
ignoreCase
};
});
}
@@ -400,17 +407,24 @@ elements.actionDialogForm.addEventListener("submit", (event) => {
const value = elements.actionDialogInput.value.trim();
const expectedValue = actionDialogState?.expectedValue;
const expectedLabel = actionDialogState?.expectedLabel || "输入内容";
const ignoreCase = actionDialogState?.ignoreCase === true;
if (!value) {
elements.actionDialogError.textContent = `${expectedLabel}不能为空`;
elements.actionDialogError.hidden = false;
elements.actionDialogInput.focus();
return;
}
if (expectedValue !== null && value !== expectedValue) {
elements.actionDialogError.textContent = `${expectedLabel}不匹配,请按提示完整输入`;
elements.actionDialogError.hidden = false;
elements.actionDialogInput.focus();
return;
if (expectedValue !== null) {
const expected = String(expectedValue).trim();
const matched = ignoreCase
? value.toLowerCase() === expected.toLowerCase()
: value === expected;
if (!matched) {
elements.actionDialogError.textContent = `${expectedLabel}不匹配,请按提示完整输入`;
elements.actionDialogError.hidden = false;
elements.actionDialogInput.focus();
return;
}
}
closeActionDialog(value);
});
@@ -708,7 +722,8 @@ document.querySelector("#delete-line").addEventListener("click", async () => {
confirmLabel: "删除产线",
danger: true,
expectedValue: line.deviceId,
expectedLabel: "deviceId"
expectedLabel: "deviceId",
ignoreCase: true
});
if (confirmation === null) return;
const result = await runBusy("正在删除产线", () => window.reinloop.deleteProductionLine({
@@ -734,7 +749,8 @@ document.querySelector("#delete-company").addEventListener("click", async () =>
confirmLabel: "删除公司",
danger: true,
expectedValue: company.code,
expectedLabel: "公司编码"
expectedLabel: "公司编码",
ignoreCase: true
});
if (confirmation === null) return;
const result = await runBusy("正在删除公司", () => window.reinloop.deleteCompany({
@@ -797,12 +813,13 @@ elements.licenseList.addEventListener("click", async (event) => {
if (deleteId) {
const confirmation = await requestModelName({
title: "确认删除许可证",
message: "已撤销许可证才能删除。请输入许可证 ID 以确认永久删除。",
message: `已撤销许可证才能删除。请输入许可证 ID 以确认永久删除。\n\n当前许可证 ID${deleteId}`,
value: "",
confirmLabel: "永久删除",
danger: true,
expectedValue: deleteId,
expectedLabel: "许可证ID"
expectedLabel: "许可证ID",
ignoreCase: true
});
if (confirmation === null) return;
button.disabled = true;