From 1344d9febc79b46c81f2f443c72bea45c3e53ff4 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Thu, 27 May 2021 16:59:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B0=B4=E5=8D=B0=E6=8F=90=E7=A4=BA=E6=96=87?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../singleselct/demo.single_select_combo.js | 2 +- i18n/i18n.cn.js | 1 + src/base/single/editor/editor.textarea.js | 3 +- .../trigger/searcher.multiselect.insert.js | 3 +- .../multiselectlist/multiselectlist.insert.js | 1 + .../multiselectlist.insert.nobar.js | 1 + src/widget/singleselect/singleselect.combo.js | 17 +--- .../singleselect/singleselect.insert.combo.js | 44 +---------- .../singleselect/singleselect.trigger.js | 1 + .../singleselect/singleselectlist.insert.js | 79 +++++-------------- .../trigger/editor.singleselect.js | 5 +- .../trigger/searcher.singleselect.js | 1 + 12 files changed, 39 insertions(+), 119 deletions(-) diff --git a/demo/js/widget/singleselct/demo.single_select_combo.js b/demo/js/widget/singleselct/demo.single_select_combo.js index 7a9b78fc5..1fc68fb6b 100644 --- a/demo/js/widget/singleselct/demo.single_select_combo.js +++ b/demo/js/widget/singleselct/demo.single_select_combo.js @@ -9,7 +9,7 @@ Demo.SingleSelectCombo = BI.inherit(BI.Widget, { _createSingleSelectCombo: function () { var self = this; var widget = BI.createWidget({ - type: "bi.single_select_insert_combo", + type: "bi.single_select_combo", itemsCreator: BI.bind(this._itemsCreator, this), width: 200, ref: function () { diff --git a/i18n/i18n.cn.js b/i18n/i18n.cn.js index e95750867..7ddf7b225 100644 --- a/i18n/i18n.cn.js +++ b/i18n/i18n.cn.js @@ -195,4 +195,5 @@ BI.i18n = { "BI-Basic_Year_Range_Error": "请选择{R1}年-{R2}年的日期", "BI-Basic_Year_Month_Range_Error": "请选择{R1}年{R2}月-{R3}年{R4}月的日期", "BI-Basic_Year_Quarter_Range_Error": "请选择{R1}年{R2}季度-{R3}年{R4}季度的日期", + "BI-Basic_Search_And_Patch_Paste": "搜索,支持批量粘贴、粘贴值通过换行识别" }; \ No newline at end of file diff --git a/src/base/single/editor/editor.textarea.js b/src/base/single/editor/editor.textarea.js index af38cb243..0c646d693 100644 --- a/src/base/single/editor/editor.textarea.js +++ b/src/base/single/editor/editor.textarea.js @@ -107,7 +107,8 @@ BI.TextAreaEditor = BI.inherit(BI.Single, { type: "bi.label", cls: "bi-water-mark textarea-watermark", textAlign: "left", - whiteSpace: "normal", + whiteSpace: o.scrolly ? "normal" : "nowrap", + title: o.watermark, text: o.watermark, invalid: o.invalid, disabled: o.disabled, diff --git a/src/widget/multiselect/trigger/searcher.multiselect.insert.js b/src/widget/multiselect/trigger/searcher.multiselect.insert.js index d5c151a85..8a4f561ae 100644 --- a/src/widget/multiselect/trigger/searcher.multiselect.insert.js +++ b/src/widget/multiselect/trigger/searcher.multiselect.insert.js @@ -16,7 +16,8 @@ BI.MultiSelectInsertSearcher = BI.inherit(BI.Widget, { valueFormatter: BI.emptyFn, adapter: null, masker: {}, - text: BI.i18nText("BI-Basic_Please_Select") + text: BI.i18nText("BI-Basic_Please_Select"), + watermark: BI.i18nText("BI-Basic_Search_And_Patch_Paste"), }); }, diff --git a/src/widget/multiselectlist/multiselectlist.insert.js b/src/widget/multiselectlist/multiselectlist.insert.js index 5b4d1e354..568ea43cb 100644 --- a/src/widget/multiselectlist/multiselectlist.insert.js +++ b/src/widget/multiselectlist/multiselectlist.insert.js @@ -66,6 +66,7 @@ BI.MultiSelectInsertList = BI.inherit(BI.Single, { type: "bi.select_patch_editor", el: { type: "bi.search_editor", + watermark: BI.i18nText("BI-Basic_Search_And_Patch_Paste"), }, ref: function (ref) { self.editor = ref; diff --git a/src/widget/multiselectlist/multiselectlist.insert.nobar.js b/src/widget/multiselectlist/multiselectlist.insert.nobar.js index 67fe5a357..34576be60 100644 --- a/src/widget/multiselectlist/multiselectlist.insert.nobar.js +++ b/src/widget/multiselectlist/multiselectlist.insert.nobar.js @@ -70,6 +70,7 @@ BI.MultiSelectInsertNoBarList = BI.inherit(BI.Single, { type: "bi.select_patch_editor", el: { type: "bi.search_editor", + watermark: BI.i18nText("BI-Basic_Search_And_Patch_Paste"), }, ref: function (ref) { self.editor = ref; diff --git a/src/widget/singleselect/singleselect.combo.js b/src/widget/singleselect/singleselect.combo.js index 8d29064c6..a30c52cf5 100644 --- a/src/widget/singleselect/singleselect.combo.js +++ b/src/widget/singleselect/singleselect.combo.js @@ -63,22 +63,7 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, { self._setStartValue(); self.fireEvent(BI.SingleSelectCombo.EVENT_STOP); }); - this.trigger.on(BI.SingleSelectTrigger.EVENT_SEARCHING, function (keywords) { - var last = BI.last(keywords); - keywords = BI.initial(keywords || []); - if (keywords.length > 0) { - self._joinKeywords(keywords, function () { - if (BI.endWith(last, BI.BlankSplitChar)) { - self.combo.setValue(self.storeValue); - assertShowValue(); - self.combo.populate(); - self._setStartValue(); - } else { - self.combo.setValue(self.storeValue); - assertShowValue(); - } - }); - } + this.trigger.on(BI.SingleSelectTrigger.EVENT_SEARCHING, function () { self.fireEvent(BI.SingleSelectCombo.EVENT_SEARCHING); }); diff --git a/src/widget/singleselect/singleselect.insert.combo.js b/src/widget/singleselect/singleselect.insert.combo.js index 33f6dd458..d94f97197 100644 --- a/src/widget/singleselect/singleselect.insert.combo.js +++ b/src/widget/singleselect/singleselect.insert.combo.js @@ -12,7 +12,8 @@ BI.SingleSelectInsertCombo = BI.inherit(BI.Single, { itemsCreator: BI.emptyFn, valueFormatter: BI.emptyFn, height: 24, - allowEdit: true + allowEdit: true, + watermark: BI.i18nText("BI-Basic_Search_And_Patch_Paste"), }); }, @@ -29,6 +30,7 @@ BI.SingleSelectInsertCombo = BI.inherit(BI.Single, { this.trigger = BI.createWidget({ type: "bi.single_select_trigger", + watermark: o.watermark, height: o.height - 2, allowNoSelect: o.allowNoSelect, allowEdit: o.allowEdit, @@ -72,22 +74,7 @@ BI.SingleSelectInsertCombo = BI.inherit(BI.Single, { assertShowValue(); self._defaultState(); }); - this.trigger.on(BI.SingleSelectTrigger.EVENT_SEARCHING, function (keywords) { - var last = BI.last(keywords); - keywords = BI.initial(keywords || []); - if (keywords.length > 0) { - self._joinKeywords(keywords, function () { - if (BI.endWith(last, BI.BlankSplitChar)) { - self.combo.setValue(self.storeValue); - assertShowValue(); - self.combo.populate(); - self._setStartValue(); - } else { - self.combo.setValue(self.storeValue); - assertShowValue(); - } - }); - } + this.trigger.on(BI.SingleSelectTrigger.EVENT_SEARCHING, function () { self.fireEvent(BI.SingleSelectInsertCombo.EVENT_SEARCHING); }); @@ -204,29 +191,6 @@ BI.SingleSelectInsertCombo = BI.inherit(BI.Single, { return BI.makeObject(values || []); }, - _joinKeywords: function (keywords, callback) { - var self = this, o = this.options; - this._assertValue(this.storeValue); - this.requesting = true; - o.itemsCreator({ - type: BI.SingleSelectInsertCombo.REQ_GET_ALL_DATA, - keywords: keywords - }, function (ob) { - var values = BI.map(ob.items, "value"); - digest(values); - }); - - function digest (items) { - var selectedMap = self._makeMap(items); - BI.each(keywords, function (i, val) { - if (BI.isNotNull(selectedMap[val])) { - BI.remove(self.storeValue.value, val); - } - }); - self._adjust(callback); - } - }, - _adjust: function (callback) { var self = this, o = this.options; adjust(); diff --git a/src/widget/singleselect/singleselect.trigger.js b/src/widget/singleselect/singleselect.trigger.js index 44b6f6f02..35c6c0349 100644 --- a/src/widget/singleselect/singleselect.trigger.js +++ b/src/widget/singleselect/singleselect.trigger.js @@ -35,6 +35,7 @@ BI.SingleSelectTrigger = BI.inherit(BI.Trigger, { this.searcher = BI.createWidget(o.searcher, { type: "bi.single_select_searcher", + watermark: o.watermark, allowNoSelect: o.allowNoSelect, text: o.text, height: o.height, diff --git a/src/widget/singleselect/singleselectlist.insert.js b/src/widget/singleselect/singleselectlist.insert.js index e0e913d29..db1722abc 100644 --- a/src/widget/singleselect/singleselectlist.insert.js +++ b/src/widget/singleselect/singleselectlist.insert.js @@ -9,7 +9,8 @@ BI.SingleSelectInsertList = BI.inherit(BI.Single, { baseCls: "bi-multi-select-insert-list", allowNoSelect: false, itemsCreator: BI.emptyFn, - valueFormatter: BI.emptyFn + valueFormatter: BI.emptyFn, + searcherHeight: 24, }); }, _init: function () { @@ -60,6 +61,17 @@ BI.SingleSelectInsertList = BI.inherit(BI.Single, { this.trigger = BI.createWidget({ type: "bi.searcher", + el: { + type: "bi.select_patch_editor", + el: { + type: "bi.search_editor", + watermark: BI.i18nText("BI-Basic_Search_And_Patch_Paste"), + }, + ref: function (ref) { + self.editor = ref; + }, + height: o.searcherHeight, + }, isAutoSearch: false, isAutoSync: false, onSearch: function (op, callback) { @@ -90,40 +102,16 @@ BI.SingleSelectInsertList = BI.inherit(BI.Single, { eventName: BI.Searcher.EVENT_PAUSE, action: function () { var keyword = this.getKeyword(); - if (this.hasMatched()) { - self.storeValue = keyword; - self._showAdapter(); - self.adapter.setValue(self.storeValue); - self._setStartValue(keyword); - assertShowValue(); - self.adapter.populate(); - self._setStartValue(); - self.fireEvent(BI.SingleSelectInsertList.EVENT_CHANGE); - } else { - self._showAdapter(); - } + self.storeValue = keyword; + self._showAdapter(); + self.adapter.setValue(self.storeValue); + self._setStartValue(keyword); + assertShowValue(); + self.adapter.populate(); + self._setStartValue(); + self.fireEvent(BI.SingleSelectInsertList.EVENT_CHANGE); } - }, { - eventName: BI.Searcher.EVENT_SEARCHING, - action: function () { - var keywords = this.getKeyword(); - var last = BI.last(keywords); - keywords = BI.initial(keywords || []); - if (keywords.length > 0) { - self._joinKeywords(keywords, function () { - if (BI.endWith(last, BI.BlankSplitChar)) { - self.adapter.setValue(self.storeValue); - assertShowValue(); - self.adapter.populate(); - self._setStartValue(); - } else { - self.adapter.setValue(self.storeValue); - assertShowValue(); - } - }); - } - } }, { eventName: BI.Searcher.EVENT_CHANGE, action: function () { @@ -177,31 +165,6 @@ BI.SingleSelectInsertList = BI.inherit(BI.Single, { return BI.makeObject(values || []); }, - _joinKeywords: function (keywords, callback) { - var self = this, o = this.options; - this._assertValue(this.storeValue); - if (!this._allData) { - o.itemsCreator({ - type: BI.SingleSelectInsertList.REQ_GET_ALL_DATA - }, function (ob) { - self._allData = BI.map(ob.items, "value"); - digest(self._allData); - }); - } else { - digest(this._allData); - } - - function digest (items) { - var selectedMap = self._makeMap(items); - BI.each(keywords, function (i, val) { - if (BI.isNotNull(selectedMap[val])) { - BI.pushDistinct(self.storeValue.value, val) - } - }); - callback(); - } - }, - _setStartValue: function (value) { this._startValue = value; this.adapter.setStartValue(value); diff --git a/src/widget/singleselect/trigger/editor.singleselect.js b/src/widget/singleselect/trigger/editor.singleselect.js index ef5fa3cc2..881f60b45 100644 --- a/src/widget/singleselect/trigger/editor.singleselect.js +++ b/src/widget/singleselect/trigger/editor.singleselect.js @@ -10,7 +10,8 @@ BI.SingleSelectEditor = BI.inherit(BI.Widget, { return BI.extend(BI.SingleSelectEditor.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-single-select-editor", el: {}, - text: BI.i18nText("BI-Basic_Please_Select") + text: BI.i18nText("BI-Basic_Please_Select"), + watermark: BI.i18nText("BI-Basic_Search"), }); }, @@ -21,7 +22,7 @@ BI.SingleSelectEditor = BI.inherit(BI.Widget, { type: "bi.select_patch_editor", element: this, height: o.height, - watermark: BI.i18nText("BI-Basic_Search"), + watermark: o.watermark, allowBlank: true, value: o.value, defaultText: o.text, diff --git a/src/widget/singleselect/trigger/searcher.singleselect.js b/src/widget/singleselect/trigger/searcher.singleselect.js index f0851985a..f49188e41 100644 --- a/src/widget/singleselect/trigger/searcher.singleselect.js +++ b/src/widget/singleselect/trigger/searcher.singleselect.js @@ -25,6 +25,7 @@ BI.SingleSelectSearcher = BI.inherit(BI.Widget, { this.editor = BI.createWidget(o.el, { type: "bi.single_select_editor", height: o.height, + watermark: o.watermark, text: o.text, listeners: [{ eventName: BI.SingleSelectEditor.EVENT_FOCUS,