初始提交:5G 基站退服时长智能分析与故障闭环管控系统
Flask + SQLite 后端,免构建 React + ECharts 前端,含合成样例数据。 测试参考数据(FOR-TEST-ONLY)与运行时数据库不入库。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
f8d1ccc526
39 files changed
+29010
No files matched your search
@@ -0,0 +1,34 @@
|
||||
import {GlassButton, GlassDialog, html, useState} from 'vendor';
|
||||
|
||||
/**
|
||||
* 表单弹窗:提交时把表单内所有带 name 的字段收集成对象,交给 onSubmit(data)。
|
||||
* onSubmit 抛出异常(校验失败、接口报错)时弹窗保持打开,成功则自动关闭。
|
||||
*/
|
||||
export function FormDialog({onClose, title, description = '', submitText = '保存', onSubmit, children}) {
|
||||
const [busy, setBusy] = useState(false);
|
||||
|
||||
const submit = async e => {
|
||||
e.preventDefault();
|
||||
const data = Object.fromEntries([...new FormData(e.currentTarget)].map(([k, v]) => [k, String(v).trim()]));
|
||||
setBusy(true);
|
||||
try {
|
||||
await onSubmit(data);
|
||||
onClose();
|
||||
} catch {
|
||||
// 错误已由 onSubmit 提示,弹窗保持打开
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
};
|
||||
|
||||
return html`
|
||||
<${GlassDialog} open onOpenChange=${o => !o && onClose()} title=${title} description=${description} className="form-dialog">
|
||||
<form onSubmit=${submit}>
|
||||
<div className="form-grid">${children}</div>
|
||||
<div className="dialog-actions">
|
||||
<${GlassButton} type="button" variant="gray" onClick=${onClose}>取消</${GlassButton}>
|
||||
<${GlassButton} type="submit" variant="glassProminent" loading=${busy}>${submitText}</${GlassButton}>
|
||||
</div>
|
||||
</form>
|
||||
</${GlassDialog}>`;
|
||||
}
|
||||
Reference in new issue
Block a user