From 54aadf93d8b11f5e480479668d42b97d4f3178fe Mon Sep 17 00:00:00 2001 From: Claire <1119518763@qq.com> Date: Tue, 1 Mar 2022 16:36:18 +0800 Subject: [PATCH] =?UTF-8?q?BI-95364=20fix:=E6=8F=90=E4=BE=9Bcheckvalid?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/component/form/form.js | 8 ++++++++ typescript/component/form/form.ts | 15 +++++++++++++++ typescript/index.ts | 3 +++ 3 files changed, 26 insertions(+) create mode 100644 typescript/component/form/form.ts diff --git a/src/component/form/form.js b/src/component/form/form.js index 87cd64236..748b6a65f 100644 --- a/src/component/form/form.js +++ b/src/component/form/form.js @@ -35,6 +35,7 @@ }, _createItems: function () { + var self = this; var o = this.options; return BI.map(o.items, function (idx, item) { @@ -51,6 +52,11 @@ eventName: "EVENT_CHANGE", action: function () { this.validate(); + if (self.isAllValid()) { + self.fireEvent("EVENT_VALID"); + } else { + self.fireEvent("EVENT_ERROR"); + } } }] }; @@ -88,4 +94,6 @@ } }); +BI.Form.EVENT_VALID = "EVENT_VALID"; +BI.Form.EVENT_ERROR = "EVENT_ERROR"; BI.shortcut("bi.custom_form", BI.Form); diff --git a/typescript/component/form/form.ts b/typescript/component/form/form.ts new file mode 100644 index 000000000..c802c6362 --- /dev/null +++ b/typescript/component/form/form.ts @@ -0,0 +1,15 @@ +import { Widget } from "../../core/widget"; + +export declare class Form extends Widget { + static xtype: string; + static EVENT_VALID: string; + static EVENT_ERROR: string; + + isAllValid(): boolean; + + validateWithNoTip(): boolean[]; + + validate(): boolean[]; + + getValue(): T[]; +} \ No newline at end of file diff --git a/typescript/index.ts b/typescript/index.ts index 619ab72ce..efecf3fec 100644 --- a/typescript/index.ts +++ b/typescript/index.ts @@ -25,6 +25,7 @@ import { SearchTextValueCombo } from "./case/combo/searchtextvaluecombo/combo.se import { SignEditor } from "./case/editor/editor.sign"; import { StateEditor } from './case/editor/editor.state'; import { AllValueMultiTextValueCombo } from "./component/allvaluemultitextvaluecombo/allvalue.multitextvalue.combo"; +import { Form } from './component/form/form'; import { AbstractTreeValueChooser } from "./component/treevaluechooser/abstract.treevaluechooser"; import { AbstractListTreeValueChooser } from "./component/treevaluechooser/abstract.treevaluechooser.list"; import { Action, ActionFactory } from "./core/action/action"; @@ -216,6 +217,7 @@ export interface BI extends _func, _i18n, _base, _inject, _var, _web, _utils { SmallTextValueCombo: typeof SmallTextValueCombo; BubbleCombo: typeof BubbleCombo; AllValueMultiTextValueCombo: typeof AllValueMultiTextValueCombo; + Form: typeof Form; IconTextItem: typeof IconTextItem; MultiSelectItem: typeof MultiSelectItem; AbstractLabel: typeof AbstractLabel; @@ -508,6 +510,7 @@ export { Switch, HorizontalLayout, ShelterEditor, + Form, TextTrigger, SelectTextTrigger, DateInterval,