From 12198d5def84bd3bbbd8d7cff330b79f3b0cda82 Mon Sep 17 00:00:00 2001 From: Claire <1119518763@qq.com> Date: Mon, 21 Feb 2022 21:04:21 +0800 Subject: [PATCH] =?UTF-8?q?BI-95364=20feat:=E8=A1=A8=E5=8D=95=E6=9B=B4?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/component/form/form.field.js | 26 ++++++++++++++++---------- src/component/form/form.js | 4 +++- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/component/form/form.field.js b/src/component/form/form.field.js index ab7e98ffc..e6c11a924 100644 --- a/src/component/form/form.field.js +++ b/src/component/form/form.field.js @@ -3,13 +3,16 @@ * @version 2.0 * Created by windy on 2022/1/11 */ -BI.FormField = BI.inherit(BI.Widget, { + BI.FormField = BI.inherit(BI.Widget, { props: { baseCls: "bi-form-field", label: "", el: {}, - validate: BI.emptyFn + labelAlign: "right", // 文字默认右对齐 + validate: function () { + return true; + } // 默认返回true }, render: function () { @@ -24,7 +27,7 @@ BI.FormField = BI.inherit(BI.Widget, { o.el.ref && o.el.ref.call(this, _ref); }, height: o.el.height || 28, - listeners: [{ + listeners: BI.concat(o.el.listeners, [{ eventName: "EVENT_CHANGE", action: function () { self.fireEvent("EVENT_CHANGE"); @@ -32,9 +35,9 @@ BI.FormField = BI.inherit(BI.Widget, { }, { eventName: "EVENT_CONFIRM", action: function () { - self.fireEvent("EVENT_CHANGE"); + self.fireEvent("EVENT_CONFIRM"); } - }] + }]) }), left: 0, bottom: 0, @@ -60,11 +63,14 @@ BI.FormField = BI.inherit(BI.Widget, { type: "bi.vertical_adapt", columnSize: ["auto", "fill"], verticalAlign: BI.VerticalAlign.Stretch, - hgap: 5, items: BI.isKey(o.label) ? [{ - type: "bi.label", - text: o.label + ":", - width: o.labelWidth + el: { + type: "bi.label", + textAlign: o.labelAlign, + text: o.label, + width: o.labelWidth, + rgap: 20 // 表单文字与右侧输入间距均为20px + } }, field] : [field] }; }, @@ -77,7 +83,7 @@ BI.FormField = BI.inherit(BI.Widget, { var isValid = this.validateWithNoTip(); !isValid && this.error.setText(this.options.tip(this.field.getValue(), this.field)); this.error.setVisible(!isValid); - this.element[isValid ? "removeClass" : "addClass"]("error"); + this.field.element[isValid ? "removeClass" : "addClass"]("bi-error"); return isValid; }, diff --git a/src/component/form/form.js b/src/component/form/form.js index 12d1a651b..87cd64236 100644 --- a/src/component/form/form.js +++ b/src/component/form/form.js @@ -3,10 +3,11 @@ * @version 2.0 * Created by windy on 2022/1/11 */ -BI.Form = BI.inherit(BI.Widget, { + BI.Form = BI.inherit(BI.Widget, { props: { baseCls: "bi-form", + labelAlign: "right", layout: { type: "bi.vertical", vgap: 20 @@ -40,6 +41,7 @@ BI.Form = BI.inherit(BI.Widget, { return { type: "bi.form_field", height: item.el.height || 28, + labelAlign: o.labelAlign, labelWidth: o.labelWidth, el: item.el, label: item.label,