Browse Source
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
11 changed files with 364 additions and 334 deletions
@ -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 |
||||||
}; |
}; |
||||||
|
@ -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) { |
_itemsCreator(options, callback) { |
||||||
var self = this, o = this.options; |
const call = items => { |
||||||
if (!o.cache || !this.items) { |
const keywords = (options.keywords || []).slice(); |
||||||
o.itemsCreator({}, function (items) { |
let resultItems = items; |
||||||
self.items = items; |
if (isNotEmptyArray(keywords)) { |
||||||
call(items); |
|
||||||
}); |
|
||||||
} else { |
|
||||||
call(this.items); |
|
||||||
} |
|
||||||
function call (items) { |
|
||||||
var keywords = (options.keywords || []).slice(); |
|
||||||
var resultItems = items; |
|
||||||
if(BI.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; |
||||||
}, |
} |
||||||
}); |
} |
||||||
|
@ -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: MultiSelectCombo.EVENT_SEARCHING, |
||||||
|
action: () => { |
||||||
|
this.fireEvent(ValueChooserInsertCombo.EVENT_SEARCHING); |
||||||
|
}, |
||||||
|
}, |
||||||
|
{ |
||||||
|
eventName: MultiSelectCombo.EVENT_CONFIRM, |
||||||
|
action: () => { |
||||||
|
this.fireEvent(ValueChooserInsertCombo.EVENT_CONFIRM); |
||||||
|
}, |
||||||
} |
} |
||||||
}, { |
], |
||||||
eventName: BI.MultiSelectCombo.EVENT_CONFIRM, |
|
||||||
action: function () { |
|
||||||
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_CONFIRM); |
|
||||||
} |
|
||||||
}] |
|
||||||
}); |
}); |
||||||
}, |
} |
||||||
|
|
||||||
setValue: function (v) { |
setValue(v) { |
||||||
this.combo.setValue(this._assertValue(v)); |
this.combo.setValue(this._assertValue(v)); |
||||||
}, |
} |
||||||
|
|
||||||
getValue: function () { |
getValue() { |
||||||
var val = this.combo.getValue() || {}; |
const 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); |
|
||||||
|
@ -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: MultiSelectCombo.EVENT_SEARCHING, |
||||||
|
action: () => { |
||||||
|
this.fireEvent(ValueChooserCombo.EVENT_SEARCHING); |
||||||
|
}, |
||||||
|
}, |
||||||
|
{ |
||||||
|
eventName: MultiSelectCombo.EVENT_CONFIRM, |
||||||
|
action: () => { |
||||||
|
this.fireEvent(ValueChooserCombo.EVENT_CONFIRM); |
||||||
|
}, |
||||||
} |
} |
||||||
}, { |
], |
||||||
eventName: BI.MultiSelectCombo.EVENT_CONFIRM, |
|
||||||
action: function () { |
|
||||||
self.fireEvent(BI.ValueChooserCombo.EVENT_CONFIRM); |
|
||||||
} |
|
||||||
}] |
|
||||||
}); |
}); |
||||||
}, |
} |
||||||
|
|
||||||
setValue: function (v) { |
setValue(v) { |
||||||
this.combo.setValue(this._assertValue(v)); |
this.combo.setValue(this._assertValue(v)); |
||||||
}, |
} |
||||||
|
|
||||||
getValue: function () { |
getValue() { |
||||||
var val = this.combo.getValue() || {}; |
const 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); |
|
||||||
|
@ -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, |
|
||||||
itemsCreator: BI.emptyFn, |
|
||||||
cache: true |
|
||||||
}, |
|
||||||
|
|
||||||
render: function () { |
props = { baseCls: "bi-value-chooser-combo", width: 200, height: 24, items: null, cache: true }; |
||||||
var self = this, o = this.options; |
|
||||||
if (BI.isNotNull(o.items)) { |
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"; |
||||||
|
|
||||||
|
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: [{ |
listeners: [ |
||||||
eventName: BI.MultiSelectCombo.EVENT_FOCUS, |
{ |
||||||
action: function () { |
eventName: MultiSelectCombo.EVENT_FOCUS, |
||||||
self.fireEvent(BI.ValueChooserNoBarCombo.EVENT_FOCUS); |
action: () => { |
||||||
} |
this.fireEvent(ValueChooserNoBarCombo.EVENT_FOCUS); |
||||||
}, { |
}, |
||||||
eventName: BI.MultiSelectCombo.EVENT_BLUR, |
}, |
||||||
action: function () { |
{ |
||||||
self.fireEvent(BI.ValueChooserNoBarCombo.EVENT_BLUR); |
eventName: MultiSelectCombo.EVENT_BLUR, |
||||||
} |
action: () => { |
||||||
}, { |
this.fireEvent(ValueChooserNoBarCombo.EVENT_BLUR); |
||||||
eventName: BI.MultiSelectCombo.EVENT_STOP, |
}, |
||||||
action: function () { |
}, |
||||||
self.fireEvent(BI.ValueChooserNoBarCombo.EVENT_STOP); |
{ |
||||||
} |
eventName: MultiSelectCombo.EVENT_STOP, |
||||||
}, { |
action: () => { |
||||||
eventName: BI.MultiSelectCombo.EVENT_CLICK_ITEM, |
this.fireEvent(ValueChooserNoBarCombo.EVENT_STOP); |
||||||
action: function () { |
}, |
||||||
self.fireEvent(BI.ValueChooserNoBarCombo.EVENT_CLICK_ITEM); |
}, |
||||||
} |
{ |
||||||
}, { |
eventName: MultiSelectCombo.EVENT_CLICK_ITEM, |
||||||
eventName: BI.MultiSelectCombo.EVENT_SEARCHING, |
action: () => { |
||||||
action: function () { |
this.fireEvent(ValueChooserNoBarCombo.EVENT_CLICK_ITEM); |
||||||
self.fireEvent(BI.ValueChooserNoBarCombo.EVENT_SEARCHING); |
}, |
||||||
|
}, |
||||||
|
{ |
||||||
|
eventName: MultiSelectCombo.EVENT_SEARCHING, |
||||||
|
action: () => { |
||||||
|
this.fireEvent(ValueChooserNoBarCombo.EVENT_SEARCHING); |
||||||
|
}, |
||||||
|
}, |
||||||
|
{ |
||||||
|
eventName: MultiSelectCombo.EVENT_CONFIRM, |
||||||
|
action: () => { |
||||||
|
this.fireEvent(ValueChooserNoBarCombo.EVENT_CONFIRM); |
||||||
|
}, |
||||||
} |
} |
||||||
}, { |
], |
||||||
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); |
|
||||||
|
@ -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"; |
@ -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: function () { |
getValue() { |
||||||
var val = this.list.getValue() || {}; |
const 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); |
|
||||||
|
Loading…
Reference in new issue