Browse Source

Pull request #3406: KERNEL-14108 refactor:componet/valuechooser文件es6化

Merge in VISUAL/fineui from ~JOKER.WANG/fineui:es6 to es6

* commit '853dc96cf489f9050032576761aacbd1fa1e481e':
  KERNEL-14108 refactor:避免循环依赖
  KERNEL-14108 refactor:处理文件引入后TODO项
  KERNEL-14108 refactor:componet/valuechooser文件es6化
es6
Joker.Wang-王顺 2 years ago
parent
commit
9faa7f1e80
  1. 4
      src/case/pager/pager.all.count.js
  2. 3
      src/component/index.js
  3. 142
      src/component/valuechooser/abstract.valuechooser.js
  4. 151
      src/component/valuechooser/combo.valuechooser.insert.js
  5. 155
      src/component/valuechooser/combo.valuechooser.js
  6. 140
      src/component/valuechooser/combo.valuechooser.nobar.js
  7. 5
      src/component/valuechooser/index.js
  8. 81
      src/component/valuechooser/pane.valuechooser.js
  9. 7
      src/widget/yearquarter/combo.yearquarter.js
  10. 5
      src/widget/yearquarter/popup.yearquarter.js
  11. 5
      src/widget/yearquarter/trigger.yearquarter.js

4
src/case/pager/pager.all.count.js

@ -13,6 +13,7 @@ import {
isNotEmptyObject isNotEmptyObject
} from "@/core"; } from "@/core";
import { SmallTextEditor } from "@/widget/editor/editor.text.small"; import { SmallTextEditor } from "@/widget/editor/editor.text.small";
import { TextEditor } from "@/widget/editor/editor.text";
/** /**
* 有总页数和总行数的分页控件 * 有总页数和总行数的分页控件
@ -100,8 +101,7 @@ export class AllCountPager extends Widget {
invisible: pages <= 1, invisible: pages <= 1,
}); });
// TODO:需等到TextEditor 完成es6化后才可替换BI.TextEditor this.editor.on(TextEditor.EVENT_CONFIRM, () => {
this.editor.on(BI.TextEditor.EVENT_CONFIRM, () => {
this.pager.setValue(parseInt(this.editor.getValue())); this.pager.setValue(parseInt(this.editor.getValue()));
this.fireEvent(AllCountPager.EVENT_CHANGE); this.fireEvent(AllCountPager.EVENT_CHANGE);
}); });

3
src/component/index.js

@ -1,15 +1,18 @@
import * as allvaluechooser from "./allvaluechooser"; import * as allvaluechooser from "./allvaluechooser";
import * as form from "./form"; import * as form from "./form";
import * as valueChooser from "./valuechooser";
import { AllValueMultiTextValueCombo } from "./allvaluemultitextvaluecombo/allvalue.multitextvalue.combo"; import { AllValueMultiTextValueCombo } from "./allvaluemultitextvaluecombo/allvalue.multitextvalue.combo";
Object.assign(BI, { Object.assign(BI, {
...allvaluechooser, ...allvaluechooser,
...form, ...form,
...valueChooser,
AllValueMultiTextValueCombo, AllValueMultiTextValueCombo,
}); });
export * from "./allvaluechooser"; export * from "./allvaluechooser";
export * from "./form"; export * from "./form";
export * from "./valuechooser";
export { export {
AllValueMultiTextValueCombo AllValueMultiTextValueCombo
}; };

142
src/component/valuechooser/abstract.valuechooser.js

@ -1,110 +1,122 @@
/** import {
* 简单的复选下拉框控件, 适用于数据量少的情况 Widget,
* 封装了字段处理逻辑 extend,
* emptyFn,
* Created by GUY on 2015/10/29. isNotNull,
* @class BI.AbstractValueChooser some,
* @extends BI.Widget isNotEmptyArray,
*/ each,
BI.AbstractValueChooser = BI.inherit(BI.Widget, { Func,
uniq,
makeObject,
filter,
Selection,
difference,
map
} from "@/core";
import { MultiSelectCombo } from "@/widget";
_const: { export class AbstractValueChooser extends Widget {
perPage: 100 _const = { perPage: 100 };
},
_defaultConfig: function () { _defaultConfig() {
return BI.extend(BI.AbstractValueChooser.superclass._defaultConfig.apply(this, arguments), { return extend(super._defaultConfig(...arguments), {
items: null, items: null,
itemsCreator: BI.emptyFn, itemsCreator: emptyFn,
cache: true cache: true,
}); });
}, }
_valueFormatter: function (v) { _valueFormatter(v) {
var text = v; let text = v;
if (this.options.valueFormatter) { if (this.options.valueFormatter) {
return this.options.valueFormatter(v); return this.options.valueFormatter(v);
} }
if (BI.isNotNull(this.items)) { if (isNotNull(this.items)) {
BI.some(this.items, function (i, item) { some(this.items, (i, item) => {
// 把value都换成字符串 // 把value都换成字符串
if (item.value === v || item.value + "" === v) { if (item.value === v || `${item.value}` === v) {
text = item.text; text = item.text;
return true; return true;
} }
}); });
} }
return text; return text;
}, }
_getItemsByTimes: function (items, times) { _getItemsByTimes(items, times) {
var res = []; const res = [];
for (var i = (times - 1) * this._const.perPage; items[i] && i < times * this._const.perPage; i++) { for (let i = (times - 1) * this._const.perPage; items[i] && i < times * this._const.perPage; i++) {
res.push(items[i]); res.push(items[i]);
} }
return res; return res;
}, }
_hasNextByTimes: function (items, times) { _hasNextByTimes(items, times) {
return times * this._const.perPage < items.length; return times * this._const.perPage < items.length;
},
_itemsCreator: function (options, callback) {
var self = this, o = this.options;
if (!o.cache || !this.items) {
o.itemsCreator({}, function (items) {
self.items = items;
call(items);
});
} else {
call(this.items);
} }
function call (items) {
var keywords = (options.keywords || []).slice(); _itemsCreator(options, callback) {
var resultItems = items; const call = items => {
if(BI.isNotEmptyArray(keywords)) { const keywords = (options.keywords || []).slice();
let resultItems = items;
if (isNotEmptyArray(keywords)) {
resultItems = []; resultItems = [];
BI.each(keywords, function (i, kw) { each(keywords, (i, kw) => {
var search = BI.Func.getSearchResult(items, kw); const search = Func.getSearchResult(items, kw);
resultItems = resultItems.concat(search.match).concat(search.find); resultItems = resultItems.concat(search.match).concat(search.find);
}); });
resultItems = BI.uniq(resultItems); resultItems = uniq(resultItems);
} }
if (options.selectedValues) {// 过滤 if (options.selectedValues) {
var filter = BI.makeObject(options.selectedValues, true); // 过滤
resultItems = BI.filter(resultItems, function (i, ob) { const filterFunc = makeObject(options.selectedValues, true);
return !filter[ob.value]; resultItems = filter(resultItems, (i, ob) => !filterFunc[ob.value]);
});
} }
if (options.type === BI.MultiSelectCombo.REQ_GET_ALL_DATA) { if (options.type === MultiSelectCombo.REQ_GET_ALL_DATA) {
callback({ callback({
items: resultItems items: resultItems,
}); });
return; return;
} }
if (options.type === BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) { if (options.type === MultiSelectCombo.REQ_GET_DATA_LENGTH) {
callback({count: resultItems.length}); callback({ count: resultItems.length });
return; return;
} }
callback({ callback({
items: self._getItemsByTimes(resultItems, options.times), items: this._getItemsByTimes(resultItems, options.times),
hasNext: self._hasNextByTimes(resultItems, options.times) hasNext: this._hasNextByTimes(resultItems, options.times),
});
};
const o = this.options;
if (!o.cache || !this.items) {
o.itemsCreator({}, items => {
this.items = items;
call(items);
}); });
} else {
call(this.items);
}
} }
},
_assertValue: function (v) { _assertValue(v) {
v = v || {}; v = v || {};
var value = v; let value = v;
if (v.type === BI.Selection.Multi && BI.isNotNull(this.items)) { if (v.type === Selection.Multi && isNotNull(this.items)) {
var isAllSelect = BI.difference(BI.map(this.items, "value"), v.value).length === 0; const isAllSelect = difference(map(this.items, "value"), v.value).length === 0;
if (isAllSelect) { if (isAllSelect) {
value = { value = {
type: BI.Selection.All, type: Selection.All,
value: [], value: [],
}; };
} }
} }
return value; return value;
}, }
}); }

151
src/component/valuechooser/combo.valuechooser.insert.js

@ -1,105 +1,114 @@
/** import { shortcut, extend, emptyFn, isNotNull, createWidget, bind, Selection, difference, map } from "@/core";
* 简单的复选下拉框控件, 适用于数据量少的情况 import { AbstractValueChooser } from "./abstract.valuechooser";
* 封装了字段处理逻辑 import { MultiSelectCombo, MultiSelectInsertCombo } from "@/widget";
*/
BI.ValueChooserInsertCombo = BI.inherit(BI.AbstractValueChooser, {
_defaultConfig: function () { @shortcut()
return BI.extend(BI.ValueChooserInsertCombo.superclass._defaultConfig.apply(this, arguments), { export class ValueChooserInsertCombo extends AbstractValueChooser {
static xtype = "bi.value_chooser_insert_combo";
static EVENT_BLUR = "EVENT_BLUR";
static EVENT_FOCUS = "EVENT_FOCUS";
static EVENT_STOP = "EVENT_STOP";
static EVENT_SEARCHING = "EVENT_SEARCHING";
static EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM";
static EVENT_CONFIRM = "EVENT_CONFIRM";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
baseCls: "bi-value-chooser-insert-combo", baseCls: "bi-value-chooser-insert-combo",
width: 200, width: 200,
height: 24, height: 24,
items: null, items: null,
itemsCreator: BI.emptyFn, itemsCreator: emptyFn,
cache: true cache: true,
}); });
}, }
_init: function () { _init() {
BI.ValueChooserInsertCombo.superclass._init.apply(this, arguments); super._init(...arguments);
var self = this, o = this.options; const o = this.options;
if (BI.isNotNull(o.items)) { if (isNotNull(o.items)) {
this.items = o.items; this.items = o.items;
} }
this.combo = BI.createWidget({ this.combo = createWidget({
type: "bi.multi_select_insert_combo", type: MultiSelectInsertCombo.xtype,
simple: o.simple, simple: o.simple,
element: this, element: this,
allowEdit: o.allowEdit, allowEdit: o.allowEdit,
text: o.text, text: o.text,
value: this._assertValue(o.value), value: this._assertValue(o.value),
itemsCreator: BI.bind(this._itemsCreator, this), itemsCreator: bind(this._itemsCreator, this),
valueFormatter: BI.bind(this._valueFormatter, this), valueFormatter: bind(this._valueFormatter, this),
width: o.width, width: o.width,
height: o.height, height: o.height,
listeners: [{ listeners: [
eventName: BI.MultiSelectCombo.EVENT_FOCUS, {
action: function () { eventName: MultiSelectCombo.EVENT_FOCUS,
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_FOCUS); action: () => {
} this.fireEvent(ValueChooserInsertCombo.EVENT_FOCUS);
}, { },
eventName: BI.MultiSelectCombo.EVENT_BLUR, },
action: function () { {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_BLUR); eventName: MultiSelectCombo.EVENT_BLUR,
} action: () => {
}, { this.fireEvent(ValueChooserInsertCombo.EVENT_BLUR);
eventName: BI.MultiSelectCombo.EVENT_STOP, },
action: function () { },
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_STOP); {
} eventName: MultiSelectCombo.EVENT_STOP,
}, { action: () => {
eventName: BI.MultiSelectCombo.EVENT_CLICK_ITEM, this.fireEvent(ValueChooserInsertCombo.EVENT_STOP);
action: function () { },
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_CLICK_ITEM); },
} {
}, { eventName: MultiSelectCombo.EVENT_CLICK_ITEM,
eventName: BI.MultiSelectCombo.EVENT_SEARCHING, action: () => {
action: function () { this.fireEvent(ValueChooserInsertCombo.EVENT_CLICK_ITEM);
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_SEARCHING); },
} },
}, { {
eventName: BI.MultiSelectCombo.EVENT_CONFIRM, eventName: MultiSelectCombo.EVENT_SEARCHING,
action: function () { action: () => {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_CONFIRM); this.fireEvent(ValueChooserInsertCombo.EVENT_SEARCHING);
},
},
{
eventName: MultiSelectCombo.EVENT_CONFIRM,
action: () => {
this.fireEvent(ValueChooserInsertCombo.EVENT_CONFIRM);
},
} }
}] ],
}); });
}, }
setValue: function (v) { setValue(v) {
this.combo.setValue(this._assertValue(v)); this.combo.setValue(this._assertValue(v));
}, }
getValue() {
const val = this.combo.getValue() || {};
getValue: function () {
var val = this.combo.getValue() || {};
return { return {
type: val.type, type: val.type,
value: val.value value: val.value,
}; };
}, }
getAllValue: function() { getAllValue() {
var val = this.combo.getValue() || {}; const val = this.combo.getValue() || {};
if (val.type === BI.Selection.Multi) { if (val.type === Selection.Multi) {
return val.value || []; return val.value || [];
} }
return BI.difference(BI.map(this.items, "value"), val.value || []); return difference(map(this.items, "value"), val.value || []);
}, }
populate: function (items) { populate(items) {
// 直接用combo的populate不会作用到AbstractValueChooser上 // 直接用combo的populate不会作用到AbstractValueChooser上
if (BI.isNotNull(items)) { if (isNotNull(items)) {
this.items = items; this.items = items;
} }
this.combo.populate(); this.combo.populate();
} }
}); }
BI.ValueChooserInsertCombo.EVENT_BLUR = "EVENT_BLUR";
BI.ValueChooserInsertCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.ValueChooserInsertCombo.EVENT_STOP = "EVENT_STOP";
BI.ValueChooserInsertCombo.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.ValueChooserInsertCombo.EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM";
BI.ValueChooserInsertCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.value_chooser_insert_combo", BI.ValueChooserInsertCombo);

155
src/component/valuechooser/combo.valuechooser.js

@ -1,110 +1,115 @@
/** import { shortcut, extend, emptyFn, isNotNull, createWidget, bind, Selection, difference, map } from "@/core";
* 简单的复选下拉框控件, 适用于数据量少的情况 import { AbstractValueChooser } from "./abstract.valuechooser";
* 封装了字段处理逻辑 import { MultiSelectCombo } from "@/widget";
*
* Created by GUY on 2015/10/29.
* @class BI.ValueChooserCombo
* @extends BI.Widget
*/
BI.ValueChooserCombo = BI.inherit(BI.AbstractValueChooser, {
_defaultConfig: function () { @shortcut()
return BI.extend(BI.ValueChooserCombo.superclass._defaultConfig.apply(this, arguments), { export class ValueChooserCombo extends AbstractValueChooser {
static xtype = "bi.value_chooser_combo";
static EVENT_BLUR = "EVENT_BLUR";
static EVENT_FOCUS = "EVENT_FOCUS";
static EVENT_STOP = "EVENT_STOP";
static EVENT_SEARCHING = "EVENT_SEARCHING";
static EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM";
static EVENT_CONFIRM = "EVENT_CONFIRM";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
baseCls: "bi-value-chooser-combo", baseCls: "bi-value-chooser-combo",
width: 200, width: 200,
height: 24, height: 24,
items: null, items: null,
itemsCreator: BI.emptyFn, itemsCreator: emptyFn,
cache: true cache: true,
}); });
}, }
_init: function () { _init() {
BI.ValueChooserCombo.superclass._init.apply(this, arguments); super._init(...arguments);
var self = this, o = this.options; const o = this.options;
if (BI.isNotNull(o.items)) { if (isNotNull(o.items)) {
this.items = o.items; this.items = o.items;
} }
this.combo = BI.createWidget({ this.combo = createWidget({
type: "bi.multi_select_combo", type: MultiSelectCombo.xtype,
simple: o.simple, simple: o.simple,
element: this, element: this,
allowEdit: o.allowEdit, allowEdit: o.allowEdit,
text: o.text, text: o.text,
defaultText: o.defaultText, defaultText: o.defaultText,
value: this._assertValue(o.value), value: this._assertValue(o.value),
itemsCreator: BI.bind(this._itemsCreator, this), itemsCreator: bind(this._itemsCreator, this),
valueFormatter: BI.bind(this._valueFormatter, this), valueFormatter: bind(this._valueFormatter, this),
width: o.width, width: o.width,
height: o.height, height: o.height,
listeners: [{ listeners: [
eventName: BI.MultiSelectCombo.EVENT_FOCUS, {
action: function () { eventName: MultiSelectCombo.EVENT_FOCUS,
self.fireEvent(BI.ValueChooserCombo.EVENT_FOCUS); action: () => {
} this.fireEvent(ValueChooserCombo.EVENT_FOCUS);
}, { },
eventName: BI.MultiSelectCombo.EVENT_BLUR, },
action: function () { {
self.fireEvent(BI.ValueChooserCombo.EVENT_BLUR); eventName: MultiSelectCombo.EVENT_BLUR,
} action: () => {
}, { this.fireEvent(ValueChooserCombo.EVENT_BLUR);
eventName: BI.MultiSelectCombo.EVENT_STOP, },
action: function () { },
self.fireEvent(BI.ValueChooserCombo.EVENT_STOP); {
} eventName: MultiSelectCombo.EVENT_STOP,
}, { action: () => {
eventName: BI.MultiSelectCombo.EVENT_CLICK_ITEM, this.fireEvent(ValueChooserCombo.EVENT_STOP);
action: function () { },
self.fireEvent(BI.ValueChooserCombo.EVENT_CLICK_ITEM); },
} {
}, { eventName: MultiSelectCombo.EVENT_CLICK_ITEM,
eventName: BI.MultiSelectCombo.EVENT_SEARCHING, action: () => {
action: function () { this.fireEvent(ValueChooserCombo.EVENT_CLICK_ITEM);
self.fireEvent(BI.ValueChooserCombo.EVENT_SEARCHING); },
} },
}, { {
eventName: BI.MultiSelectCombo.EVENT_CONFIRM, eventName: MultiSelectCombo.EVENT_SEARCHING,
action: function () { action: () => {
self.fireEvent(BI.ValueChooserCombo.EVENT_CONFIRM); this.fireEvent(ValueChooserCombo.EVENT_SEARCHING);
},
},
{
eventName: MultiSelectCombo.EVENT_CONFIRM,
action: () => {
this.fireEvent(ValueChooserCombo.EVENT_CONFIRM);
},
} }
}] ],
}); });
}, }
setValue: function (v) { setValue(v) {
this.combo.setValue(this._assertValue(v)); this.combo.setValue(this._assertValue(v));
}, }
getValue() {
const val = this.combo.getValue() || {};
getValue: function () {
var val = this.combo.getValue() || {};
return { return {
type: val.type, type: val.type,
value: val.value value: val.value,
}; };
}, }
getAllValue: function () { getAllValue() {
var val = this.combo.getValue() || {}; const val = this.combo.getValue() || {};
if (val.type === BI.Selection.Multi) { if (val.type === Selection.Multi) {
return val.value || []; return val.value || [];
} }
return BI.difference(BI.map(this.items, "value"), val.value || []); return difference(map(this.items, "value"), val.value || []);
}, }
populate: function (items) { populate(items) {
// 直接用combo的populate不会作用到AbstractValueChooser上 // 直接用combo的populate不会作用到AbstractValueChooser上
if (BI.isNotNull(items)) { if (isNotNull(items)) {
this.items = items; this.items = items;
} }
this.combo.populate(); this.combo.populate();
} }
}); }
BI.ValueChooserCombo.EVENT_BLUR = "EVENT_BLUR";
BI.ValueChooserCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.ValueChooserCombo.EVENT_STOP = "EVENT_STOP";
BI.ValueChooserCombo.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.ValueChooserCombo.EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM";
BI.ValueChooserCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.value_chooser_combo", BI.ValueChooserCombo);

140
src/component/valuechooser/combo.valuechooser.nobar.js

@ -1,98 +1,98 @@
/** import { shortcut, isNotNull, bind } from "@/core";
* @author windy import { AbstractValueChooser } from "./abstract.valuechooser";
* @version 2.0 import { MultiSelectCombo, MultiSelectNoBarCombo } from "@/widget";
* Created by windy on 2020/12/31
*/
BI.ValueChooserNoBarCombo = BI.inherit(BI.AbstractValueChooser, {
props: { @shortcut()
baseCls: "bi-value-chooser-combo", export class ValueChooserNoBarCombo extends AbstractValueChooser {
width: 200, static xtype = "bi.value_chooser_no_bar_combo";
height: 24,
items: null, props = { baseCls: "bi-value-chooser-combo", width: 200, height: 24, items: null, cache: true };
itemsCreator: BI.emptyFn,
cache: true
},
render: function () { static EVENT_BLUR = "EVENT_BLUR";
var self = this, o = this.options; static EVENT_FOCUS = "EVENT_FOCUS";
if (BI.isNotNull(o.items)) { static EVENT_STOP = "EVENT_STOP";
static EVENT_SEARCHING = "EVENT_SEARCHING";
static EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM";
static EVENT_CONFIRM = "EVENT_CONFIRM";
render() {
const o = this.options;
if (isNotNull(o.items)) {
this.items = o.items; this.items = o.items;
} }
return { return {
type: "bi.multi_select_no_bar_combo", type: MultiSelectNoBarCombo.xtype,
simple: o.simple, simple: o.simple,
allowEdit: o.allowEdit, allowEdit: o.allowEdit,
text: o.text, text: o.text,
defaultText: o.defaultText, defaultText: o.defaultText,
value: this._assertValue(o.value), value: this._assertValue(o.value),
itemsCreator: BI.bind(this._itemsCreator, this), itemsCreator: bind(this._itemsCreator, this),
valueFormatter: BI.bind(this._valueFormatter, this), valueFormatter: bind(this._valueFormatter, this),
width: o.width, width: o.width,
height: o.height, height: o.height,
ref: function (_ref) { ref: _ref => {
self.combo = _ref; this.combo = _ref;
},
listeners: [
{
eventName: MultiSelectCombo.EVENT_FOCUS,
action: () => {
this.fireEvent(ValueChooserNoBarCombo.EVENT_FOCUS);
},
},
{
eventName: MultiSelectCombo.EVENT_BLUR,
action: () => {
this.fireEvent(ValueChooserNoBarCombo.EVENT_BLUR);
},
},
{
eventName: MultiSelectCombo.EVENT_STOP,
action: () => {
this.fireEvent(ValueChooserNoBarCombo.EVENT_STOP);
},
},
{
eventName: MultiSelectCombo.EVENT_CLICK_ITEM,
action: () => {
this.fireEvent(ValueChooserNoBarCombo.EVENT_CLICK_ITEM);
},
},
{
eventName: MultiSelectCombo.EVENT_SEARCHING,
action: () => {
this.fireEvent(ValueChooserNoBarCombo.EVENT_SEARCHING);
},
},
{
eventName: MultiSelectCombo.EVENT_CONFIRM,
action: () => {
this.fireEvent(ValueChooserNoBarCombo.EVENT_CONFIRM);
}, },
listeners: [{
eventName: BI.MultiSelectCombo.EVENT_FOCUS,
action: function () {
self.fireEvent(BI.ValueChooserNoBarCombo.EVENT_FOCUS);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_BLUR,
action: function () {
self.fireEvent(BI.ValueChooserNoBarCombo.EVENT_BLUR);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_STOP,
action: function () {
self.fireEvent(BI.ValueChooserNoBarCombo.EVENT_STOP);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_CLICK_ITEM,
action: function () {
self.fireEvent(BI.ValueChooserNoBarCombo.EVENT_CLICK_ITEM);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_SEARCHING,
action: function () {
self.fireEvent(BI.ValueChooserNoBarCombo.EVENT_SEARCHING);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_CONFIRM,
action: function () {
self.fireEvent(BI.ValueChooserNoBarCombo.EVENT_CONFIRM);
} }
}] ],
}; };
}, }
setValue: function (v) { setValue(v) {
this.combo.setValue(v); this.combo.setValue(v);
}, }
getValue: function () { getValue() {
return this.combo.getValue(); return this.combo.getValue();
}, }
getAllValue: function () { getAllValue() {
return this.getValue(); return this.getValue();
}, }
populate: function (items) { populate(items) {
// 直接用combo的populate不会作用到AbstractValueChooser上 // 直接用combo的populate不会作用到AbstractValueChooser上
if (BI.isNotNull(items)) { if (isNotNull(items)) {
this.items = items; this.items = items;
} }
this.combo.populate(); this.combo.populate();
} }
}); }
BI.ValueChooserNoBarCombo.EVENT_BLUR = "EVENT_BLUR";
BI.ValueChooserNoBarCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.ValueChooserNoBarCombo.EVENT_STOP = "EVENT_STOP";
BI.ValueChooserNoBarCombo.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.ValueChooserNoBarCombo.EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM";
BI.ValueChooserNoBarCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.value_chooser_no_bar_combo", BI.ValueChooserNoBarCombo);

5
src/component/valuechooser/index.js

@ -0,0 +1,5 @@
export { ValueChooserInsertCombo } from "./combo.valuechooser.insert";
export { ValueChooserCombo } from "./combo.valuechooser";
export { ValueChooserNoBarCombo } from "./combo.valuechooser.nobar";
export { AbstractValueChooser } from "./abstract.valuechooser";
export { ValueChooserPane } from "./pane.valuechooser";

81
src/component/valuechooser/pane.valuechooser.js

@ -1,70 +1,69 @@
/** import { shortcut, extend, emptyFn, createWidget, bind, isNotNull, Selection, difference, map } from "@/core";
* 简单的复选面板, 适用于数据量少的情况 import { AbstractValueChooser } from "./abstract.valuechooser";
* 封装了字段处理逻辑 import { MultiSelectList } from "@/widget";
*
* Created by GUY on 2015/10/29.
* @class BI.ValueChooserPane
* @extends BI.Widget
*/
BI.ValueChooserPane = BI.inherit(BI.AbstractValueChooser, {
_defaultConfig: function () { @shortcut()
return BI.extend(BI.ValueChooserPane.superclass._defaultConfig.apply(this, arguments), { export class ValueChooserPane extends AbstractValueChooser {
static xtype = "bi.value_chooser_pane";
static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
baseCls: "bi-value-chooser-pane", baseCls: "bi-value-chooser-pane",
items: null, items: null,
itemsCreator: BI.emptyFn, itemsCreator: emptyFn,
cache: true cache: true,
}); });
}, }
_init: function () { _init() {
BI.ValueChooserPane.superclass._init.apply(this, arguments); super._init(...arguments);
var self = this, o = this.options; const o = this.options;
this.list = BI.createWidget({ this.list = createWidget({
type: "bi.multi_select_list", type: MultiSelectList.xtype,
element: this, element: this,
value: o.value, value: o.value,
itemsCreator: BI.bind(this._itemsCreator, this), itemsCreator: bind(this._itemsCreator, this),
valueFormatter: BI.bind(this._valueFormatter, this) valueFormatter: bind(this._valueFormatter, this),
}); });
this.list.on(BI.MultiSelectList.EVENT_CHANGE, function () { this.list.on(MultiSelectList.EVENT_CHANGE, () => {
self.fireEvent(BI.ValueChooserPane.EVENT_CHANGE); this.fireEvent(ValueChooserPane.EVENT_CHANGE);
}); });
if (BI.isNotNull(o.items)) { if (isNotNull(o.items)) {
this.items = o.items; this.items = o.items;
this.list.populate(); this.list.populate();
} }
}, }
setValue: function (v) { setValue(v) {
this.list.setValue(v); this.list.setValue(v);
}, }
getValue() {
const val = this.list.getValue() || {};
getValue: function () {
var val = this.list.getValue() || {};
return { return {
type: val.type, type: val.type,
value: val.value value: val.value,
}; };
}, }
getAllValue: function() { getAllValue() {
var val = this.combo.getValue() || {}; const val = this.combo.getValue() || {};
if (val.type === BI.Selection.Multi) { if (val.type === Selection.Multi) {
return val.value || []; return val.value || [];
} }
return BI.difference(BI.map(this.items, "value"), val.value || []); return difference(map(this.items, "value"), val.value || []);
}, }
populate: function (items) { populate(items) {
// 直接用combo的populate不会作用到AbstractValueChooser上 // 直接用combo的populate不会作用到AbstractValueChooser上
if (BI.isNotNull(items)) { if (isNotNull(items)) {
this.items = items; this.items = items;
} }
this.list.populate(); this.list.populate();
} }
}); }
BI.ValueChooserPane.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);

7
src/widget/yearquarter/combo.yearquarter.js

@ -14,8 +14,7 @@ import {
getQuarter getQuarter
} from "@/core"; } from "@/core";
import { DynamicYearQuarterTrigger } from "./trigger.yearquarter"; import { DynamicYearQuarterTrigger } from "./trigger.yearquarter";
// TODO:需要等待yearmonth完成才能将BI.DynamicYearMonthTrigger替换 import { DynamicYearMonthCombo } from "../yearmonth/combo.yearmonth";
// import { DynamicYearMonthCombo } from "../yearmonth/combo.yearmonth";
import { DynamicYearQuarterPopup } from "./popup.yearquarter"; import { DynamicYearQuarterPopup } from "./popup.yearquarter";
import { DynamicDateCombo } from "../dynamicdate"; import { DynamicDateCombo } from "../dynamicdate";
import { Combo, IconButton } from "@/base"; import { Combo, IconButton } from "@/base";
@ -75,7 +74,7 @@ export class DynamicYearQuarterCombo extends Widget {
}); });
this.trigger.on(DynamicYearQuarterTrigger.EVENT_VALID, () => { this.trigger.on(DynamicYearQuarterTrigger.EVENT_VALID, () => {
this.comboWrapper.element.removeClass("error"); this.comboWrapper.element.removeClass("error");
this.fireEvent(BI.DynamicYearMonthCombo.EVENT_VALID); this.fireEvent(DynamicYearMonthCombo.EVENT_VALID);
}); });
this.trigger.on(DynamicYearQuarterTrigger.EVENT_CONFIRM, () => { this.trigger.on(DynamicYearQuarterTrigger.EVENT_CONFIRM, () => {
const dateStore = this.storeTriggerValue; const dateStore = this.storeTriggerValue;
@ -142,7 +141,7 @@ export class DynamicYearQuarterCombo extends Widget {
action: () => { action: () => {
const date = getDate(); const date = getDate();
this.setValue({ this.setValue({
type: BI.DynamicYearMonthCombo.Static, type: DynamicYearMonthCombo.Static,
value: { value: {
year: date.getFullYear(), year: date.getFullYear(),
quarter: getQuarter(date), quarter: getQuarter(date),

5
src/widget/yearquarter/popup.yearquarter.js

@ -14,8 +14,7 @@ import {
import { DynamicYearQuarterCombo } from "./combo.yearquarter"; import { DynamicYearQuarterCombo } from "./combo.yearquarter";
import { TextButton, Tab } from "@/base"; import { TextButton, Tab } from "@/base";
import { DynamicDateCombo, DynamicDatePopup, DynamicDateHelper } from "../dynamicdate"; import { DynamicDateCombo, DynamicDatePopup, DynamicDateHelper } from "../dynamicdate";
// TODO:需要等待year完成才能将BI.DynamicYearCard替换 import { DynamicYearCard } from "../year/card.dynamic.year";
// import { DynamicYearCard } from "../year/card.dynamic.year";
import { LinearSegment } from "@/case"; import { LinearSegment } from "@/case";
import { DynamicYearQuarterCard } from "./card.dynamic.yearquarter"; import { DynamicYearQuarterCard } from "./card.dynamic.yearquarter";
import { StaticYearQuarterCard } from "./card.static.yearquarter"; import { StaticYearQuarterCard } from "./card.static.yearquarter";
@ -228,7 +227,7 @@ export class DynamicYearQuarterPopup extends Widget {
max: this.options.max, max: this.options.max,
listeners: [ listeners: [
{ {
eventName: BI.DynamicYearCard.EVENT_CHANGE, eventName: DynamicYearCard.EVENT_CHANGE,
action: () => { action: () => {
this.fireEvent( this.fireEvent(
DynamicYearQuarterPopup.EVENT_CHANGE DynamicYearQuarterPopup.EVENT_CHANGE

5
src/widget/yearquarter/trigger.yearquarter.js

@ -21,8 +21,7 @@ import {
import { Trigger, TextButton } from "@/base"; import { Trigger, TextButton } from "@/base";
import { TriggerIconButton, SignEditor } from "@/case"; import { TriggerIconButton, SignEditor } from "@/case";
import { DynamicDateHelper } from "../dynamicdate"; import { DynamicDateHelper } from "../dynamicdate";
// TODO:需要等待yearmonth完成才能将BI.DynamicYearMonthTrigger替换 import { DynamicYearMonthTrigger } from "../yearmonth/trigger.yearmonth";
// import { DynamicYearMonthTrigger } from "../yearmonth/trigger.yearmonth";
import { DynamicYearQuarterCombo } from "./combo.yearquarter"; import { DynamicYearQuarterCombo } from "./combo.yearquarter";
@shortcut() @shortcut()
@ -221,7 +220,7 @@ export class DynamicYearQuarterTrigger extends Trigger {
o.max o.max
)[0] )[0]
) { ) {
this.fireEvent(BI.DynamicYearMonthTrigger.EVENT_VALID); this.fireEvent(DynamicYearMonthTrigger.EVENT_VALID);
} }
} }
}); });

Loading…
Cancel
Save