From c829658a1ec06e03e9aaa2b3f153fde6a1cb0906 Mon Sep 17 00:00:00 2001 From: zsmj Date: Mon, 8 Aug 2022 14:06:32 +0800 Subject: [PATCH 1/3] =?UTF-8?q?JSY-20326=20fix:=20=E3=80=90=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E9=97=AE=E9=A2=98=E3=80=91=E5=B8=A6=E6=B8=85=E9=99=A4?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E7=9A=84=E5=8D=95=E9=80=89=E4=B8=8B=E6=8B=89?= =?UTF-8?q?=E6=A1=86=EF=BC=8C=E6=B8=85=E9=99=A4=E5=90=8E=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E6=81=A2=E5=A4=8D=E5=88=B0=E9=BB=98=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/js/case/combo/demo.text_value_combo.js | 196 +++++++++++++----- .../combo/textvaluecombo/combo.textvalue.js | 7 +- src/case/trigger/trigger.text.js | 38 +++- src/case/trigger/trigger.text.select.js | 24 ++- 4 files changed, 203 insertions(+), 62 deletions(-) diff --git a/demo/js/case/combo/demo.text_value_combo.js b/demo/js/case/combo/demo.text_value_combo.js index 9e2c0d6f3..77414af38 100644 --- a/demo/js/case/combo/demo.text_value_combo.js +++ b/demo/js/case/combo/demo.text_value_combo.js @@ -7,57 +7,159 @@ Demo.TextValueCombo = BI.inherit(BI.Widget, { }, render: function () { var combo, wrapper; + + var items = [{ + text: "MVC-1", + iconCls: "date-font", + value: 1 + }, { + text: "MVC-2", + iconCls: "search-font", + value: 2 + }, { + text: "MVC-3", + iconCls: "pull-right-font", + value: 3 + }]; + + // 创建下拉框各种场景用例 return { - type: "bi.button_group", - items: [{ - type: "bi.text_value_combo", - ref: function () { - combo = this; - }, - text: "默认值", - value: 22, - width: 300, - items: [{ - text: "MVC-1", - iconCls: "date-font", - value: 1 - }, { - text: "MVC-2", - iconCls: "search-font", - value: 2 + type: "bi.vertical", + vgap: 20, + hgap: 20, + items: [ + this.createCombo("无初始值,带提示文字", { + type: "bi.text_value_combo", + ref: function () { + combo = this; + }, + defaultText: "请选择", + width: 300, + items: items, + listeners: [ + { + eventName: BI.TextValueCombo.EVENT_CHANGE, + action: function () { + console.log(this.getValue()); + } + } + ] + }), + this.createCombo("自动根据value匹配text", { + type: "bi.text_value_combo", + ref: function () { + combo = this; + }, + defaultText: "请选择", + width: 300, + value: 1, + items: items, + listeners: [ + { + eventName: BI.TextValueCombo.EVENT_CHANGE, + action: function () { + console.log(this.getValue()); + } + } + ] + }), + this.createCombo("无初始值,可以清空", { + type: "bi.text_value_combo", + ref: function () { + combo = this; + }, + defaultText: "请选择", + width: 300, + items: items, + allowClear: true, + listeners: [ + { + eventName: BI.TextValueCombo.EVENT_CHANGE, + action: function () { + console.log(this.getValue()); + } + } + ] + }), + this.createCombo("有初始值,可以清空", { + type: "bi.text_value_combo", + ref: function () { + combo = this; + }, + defaultText: "请选择", + width: 300, + value: 1, + items: items, + allowClear: true, + listeners: [ + { + eventName: BI.TextValueCombo.EVENT_CHANGE, + action: function () { + console.log(this.getValue()); + } + } + ] + }), + this.createCombo("有初始值,value不匹配,自动标红,可以清空", { + type: "bi.text_value_combo", + ref: function () { + combo = this; + }, + defaultText: "请选择", + width: 300, + value: 111, + items: items, + allowClear: true, + listeners: [ + { + eventName: BI.TextValueCombo.EVENT_CHANGE, + action: function () { + console.log(this.getValue()); + } + } + ] + }), + this.createCombo("有初始值,value不匹配,自动标红,指定标红文字", { + type: "bi.text_value_combo", + ref: function () { + combo = this; + }, + width: 300, + text: "MVC-111", + value: 111, + items: items, + allowClear: true, + defaultText: "df", + listeners: [ + { + eventName: BI.TextValueCombo.EVENT_CHANGE, + action: function () { + console.log(this.getValue()); + } + } + ] + }) + ] + }; + }, + + createCombo: function (text, combo) { + return { + type: "bi.vertical", + items: [ + { + el: { + type: "bi.label", + textAlign: "left", + text, + }, + bgap: 10 }, { - text: "MVC-3", - iconCls: "pull-right-font", - value: 3 - }] - }, { - type: "bi.search_multi_text_value_combo", - items: Demo.CONSTANTS.ITEMS, - width: 200, - value: { - type: 1, - value: ["1", "2", "3"] - } - }, { - type: "bi.button", - width: 90, - height: 25, - handler: function () { - wrapper.populate(); + el: combo } - }, { - type: 'bi.label', - height: 1000 - }], - ref: function () { - wrapper = this; - }, - layouts: [{ - type: "bi.vertical", - vgap: 20 - }] + ] }; } }); -BI.shortcut("demo.text_value_combo", Demo.TextValueCombo); \ No newline at end of file +BI.shortcut("demo.text_value_combo", Demo.TextValueCombo); diff --git a/src/case/combo/textvaluecombo/combo.textvalue.js b/src/case/combo/textvaluecombo/combo.textvalue.js index 633656464..e29d6c094 100644 --- a/src/case/combo/textvaluecombo/combo.textvalue.js +++ b/src/case/combo/textvaluecombo/combo.textvalue.js @@ -12,6 +12,7 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, text: "", value: "", + defaultText: "", allowClear: false, }); }, @@ -36,6 +37,7 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { value: o.value, warningTitle: o.warningTitle, allowClear: o.allowClear, + defaultText: o.defaultText, listeners: [ { eventName: BI.SelectTextTrigger.EVENT_CLEAR, @@ -79,7 +81,10 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { }, _clear: function () { - this.setValue(); + this.trigger.setValue(); + this.popup.setValue(); + this.element.removeClass("error"); + this.trigger.element.removeClass("error"); }, _checkError: function (v) { diff --git a/src/case/trigger/trigger.text.js b/src/case/trigger/trigger.text.js index 8acee1c78..fe72fde60 100644 --- a/src/case/trigger/trigger.text.js +++ b/src/case/trigger/trigger.text.js @@ -17,21 +17,28 @@ BI.TextTrigger = BI.inherit(BI.Trigger, { allowClear: false, title: function () { return self.text.getText(); - } + }, + defaultText: "", + text: "", }; }, render: function () { var self = this, o = this.options, c = this._const; - var text = { + + var text = this.getText(); + + var defaultText = this.getDefaultText(); + + var label = { type: "bi.label", ref: function (_ref) { self.text = _ref; }, - cls: "select-text-label" + (BI.isKey(o.textCls) ? (" " + o.textCls) : ""), + cls: `select-text-label ${o.textCls} ${!BI.isNotEmptyString(text) && BI.isNotEmptyString(defaultText) ? "bi-tips" : ""}`, textAlign: "left", height: o.height, - text: o.text, + text: text || o.defaultText, tipType: o.tipType, warningTitle: o.warningTitle, hgap: o.textHgap, @@ -56,7 +63,7 @@ BI.TextTrigger = BI.inherit(BI.Trigger, { columnSize: ["fill", o.triggerWidth || o.height], items: [ { - el: text, + el: label, width: "fill" }, { el: o.allowClear ? { @@ -89,6 +96,16 @@ BI.TextTrigger = BI.inherit(BI.Trigger, { }); }, + getText: function () { + var o = this.options; + return BI.isFunction(o.text) ? o.text() : o.text; + }, + + getDefaultText: function () { + var o = this.options; + return BI.isFunction(o.defaultText) ? o.defaultText() : o.defaultText; + }, + getTextor: function () { return this.text; }, @@ -101,10 +118,19 @@ BI.TextTrigger = BI.inherit(BI.Trigger, { }, setText: function (text) { - this.text.setText(text); if (this.options.allowClear) { this.clearBtn.setVisible(BI.isNotEmptyString(text)); } + if (BI.isKey(text)) { + this.text.setText(text); + this.text.element.removeClass("bi-tips"); + } else if (BI.isKey(this.options.defaultText)) { + this.text.setText(this.options.defaultText); + this.text.element.addClass("bi-tips"); + } else { + this.text.setText(""); + this.text.element.removeClass("bi-tips"); + } }, setTipType: function (v) { diff --git a/src/case/trigger/trigger.text.select.js b/src/case/trigger/trigger.text.select.js index 4ec177764..1a74e7130 100644 --- a/src/case/trigger/trigger.text.select.js +++ b/src/case/trigger/trigger.text.select.js @@ -13,6 +13,7 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { height: 24, allowClear: false, valueFormatter: BI.emptyFn, + defaultText: "", }); }, @@ -26,6 +27,7 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { height: o.height, readonly: o.readonly, text: obj.text, + defaultText: o.defaultText, textCls: obj.textCls, textHgap: o.textHgap, textVgap: o.textVgap, @@ -48,13 +50,13 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { }); }, - _digest: function (vals, items) { + _digest: function (val, items) { var o = this.options; - vals = BI.isArray(vals) ? vals : [vals]; + val = BI.isArray(val) ? val[0] : val; var result = []; var formatItems = BI.Tree.transformToArrayFormat(items); BI.each(formatItems, function (i, item) { - if (BI.deepContains(vals, item.value) && !BI.contains(result, item.text || item.value)) { + if (val === item.value && !BI.contains(result, item.text || item.value)) { result.push(item.text || item.value); } }); @@ -62,12 +64,18 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { if (result.length > 0) { return { textCls: "", - text: o.valueFormatter(vals[0]) || result.join(","), // 只保留单个value的场景,后续会把BI.isArray(vals) ? vals : [vals];这种都去掉 + text: o.valueFormatter(val) || result.join(","), }; } else { + var text = BI.isFunction(o.text) ? o.text() : o.text; + if (BI.isEmptyString(text)) { + return { + textCls: "bi-tips", + text: "" + }; + } return { - textCls: "bi-water-mark", - text: BI.isFunction(o.text) ? o.text() : o.text + text: o.text }; } }, @@ -77,8 +85,8 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { this.trigger.setText(text); }, - setValue: function (vals) { - var formatValue = this._digest(vals, this.options.items); + setValue: function (val) { + var formatValue = this._digest(val, this.options.items); this.trigger.setTextCls(formatValue.textCls); this.trigger.setText(formatValue.text); }, From a99e4d759d05f82ae6c98fe68382695ecfde758b Mon Sep 17 00:00:00 2001 From: zsmj Date: Mon, 8 Aug 2022 14:12:17 +0800 Subject: [PATCH 2/3] =?UTF-8?q?JSY-20326=20fix:=20=E3=80=90=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E9=97=AE=E9=A2=98=E3=80=91=E5=B8=A6=E6=B8=85=E9=99=A4?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E7=9A=84=E5=8D=95=E9=80=89=E4=B8=8B=E6=8B=89?= =?UTF-8?q?=E6=A1=86=EF=BC=8C=E6=B8=85=E9=99=A4=E5=90=8E=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E6=81=A2=E5=A4=8D=E5=88=B0=E9=BB=98=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/js/widget/singletree/demo.single_tree_combo.js | 4 ++-- src/widget/singletree/singletree.combo.js | 1 + src/widget/singletree/singletree.trigger.js | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/demo/js/widget/singletree/demo.single_tree_combo.js b/demo/js/widget/singletree/demo.single_tree_combo.js index 087b28888..d3c94508e 100644 --- a/demo/js/widget/singletree/demo.single_tree_combo.js +++ b/demo/js/widget/singletree/demo.single_tree_combo.js @@ -16,7 +16,7 @@ Demo.SingleTreeCombo = BI.inherit(BI.Widget, { ref: function (_ref) { self.tree = _ref; }, - text: "默认值", + defaultText: "请选择", items: items, width: 300, value: "11" @@ -40,4 +40,4 @@ Demo.SingleTreeCombo = BI.inherit(BI.Widget, { } }); -BI.shortcut("demo.single_tree_combo", Demo.SingleTreeCombo); \ No newline at end of file +BI.shortcut("demo.single_tree_combo", Demo.SingleTreeCombo); diff --git a/src/widget/singletree/singletree.combo.js b/src/widget/singletree/singletree.combo.js index ad6b85268..c42392db8 100644 --- a/src/widget/singletree/singletree.combo.js +++ b/src/widget/singletree/singletree.combo.js @@ -25,6 +25,7 @@ BI.SingleTreeCombo = BI.inherit(BI.Widget, { this.trigger = BI.createWidget(BI.extend({ type: "bi.single_tree_trigger", text: o.text, + defaultText: o.defaultText, height: o.height, items: o.items, value: o.value, diff --git a/src/widget/singletree/singletree.trigger.js b/src/widget/singletree/singletree.trigger.js index 8c5193d2d..221c8b069 100644 --- a/src/widget/singletree/singletree.trigger.js +++ b/src/widget/singletree/singletree.trigger.js @@ -26,6 +26,7 @@ BI.SingleTreeTrigger = BI.inherit(BI.Trigger, { type: "bi.select_text_trigger", element: this, text: o.text, + defaultText: o.defaultText, items: o.items, height: o.height, warningTitle: o.warningTitle, From fac7bc4b2dcd7ff67bec613a9b5edd1a490a4ef3 Mon Sep 17 00:00:00 2001 From: zsmj Date: Mon, 8 Aug 2022 14:13:02 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=97=A0JIRA=20=E6=95=B4=E7=90=86=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/case/button/treeitem/treeitem.js | 4 ---- src/case/layer/pane.list.js | 1 + 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/case/button/treeitem/treeitem.js b/src/case/button/treeitem/treeitem.js index b7858459f..dd7e008f6 100644 --- a/src/case/button/treeitem/treeitem.js +++ b/src/case/button/treeitem/treeitem.js @@ -9,9 +9,6 @@ BI.BasicTreeItem = BI.inherit(BI.NodeButton, { readonly: true, isFirstNode: false, isLastNode: false, - switcherIcon: {}, - selectable: true, - disabled: false, // disabled不会影响展开收起功能 }); }, @@ -25,7 +22,6 @@ BI.BasicTreeItem = BI.inherit(BI.NodeButton, { { el: { type: "bi.layout", - width: 24, height: o.height, width: o.height, cls: this.getLineCls(), diff --git a/src/case/layer/pane.list.js b/src/case/layer/pane.list.js index 26be09624..d4b774d00 100644 --- a/src/case/layer/pane.list.js +++ b/src/case/layer/pane.list.js @@ -38,6 +38,7 @@ BI.ListPane = BI.inherit(BI.Pane, { chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, behaviors: {}, items: o.items, + value: o.value, itemsCreator: function (op, calback) { if (op.times === 1) { self.empty();