|
|
|
@ -14,7 +14,7 @@ import {
|
|
|
|
|
SIZE_CONSANTS |
|
|
|
|
} from "@/core"; |
|
|
|
|
import { ButtonGroup, Loader } from "@/base"; |
|
|
|
|
import { SelectList, MultiSelectBar, MultiSelectItem } from "@/case"; |
|
|
|
|
import { SelectList, MultiSelectBar, MultiSelectItem, ListPane } from "@/case"; |
|
|
|
|
|
|
|
|
|
@shortcut() |
|
|
|
|
export class MultiSelectSearchLoader extends Widget { |
|
|
|
@ -29,18 +29,18 @@ export class MultiSelectSearchLoader extends Widget {
|
|
|
|
|
keywordGetter: emptyFn, |
|
|
|
|
valueFormatter: emptyFn, |
|
|
|
|
itemFormatter: emptyFn, |
|
|
|
|
allowSelectAll: true, |
|
|
|
|
itemHeight: 24, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_init() { |
|
|
|
|
super._init(...arguments); |
|
|
|
|
|
|
|
|
|
const self = this, |
|
|
|
|
opts = this.options; |
|
|
|
|
let hasNext = false; |
|
|
|
|
this.storeValue = deepClone(opts.value); |
|
|
|
|
this.button_group = createWidget({ |
|
|
|
|
this.button_group = createWidget(opts.allowSelectAll ? { |
|
|
|
|
type: SelectList.xtype, |
|
|
|
|
toolbar: { |
|
|
|
|
type: MultiSelectBar.xtype, |
|
|
|
@ -101,11 +101,58 @@ export class MultiSelectSearchLoader extends Widget {
|
|
|
|
|
hasNext() { |
|
|
|
|
return hasNext; |
|
|
|
|
}, |
|
|
|
|
} : { |
|
|
|
|
type: "bi.list_pane", |
|
|
|
|
logic: { |
|
|
|
|
dynamic: true, |
|
|
|
|
innerVgap: 5, |
|
|
|
|
rowSize: ["", "fill"], |
|
|
|
|
verticalAlign: BI.VerticalAlign.Stretch, |
|
|
|
|
}, |
|
|
|
|
element: this, |
|
|
|
|
el: { |
|
|
|
|
chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI, |
|
|
|
|
behaviors: { |
|
|
|
|
redmark () { |
|
|
|
|
return true; |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
layouts: [ |
|
|
|
|
{ |
|
|
|
|
type: "bi.vertical", |
|
|
|
|
} |
|
|
|
|
], |
|
|
|
|
}, |
|
|
|
|
itemsCreator (op, callback) { |
|
|
|
|
self.storeValue && (op = BI.extend(op || {}, { |
|
|
|
|
selectedValues: self.storeValue.value, |
|
|
|
|
})); |
|
|
|
|
opts.itemsCreator(op, ob => { |
|
|
|
|
const keyword = ob.keyword = opts.keywordGetter(); |
|
|
|
|
hasNext = ob.hasNext; |
|
|
|
|
let firstItems = []; |
|
|
|
|
if (op.times === 1 && self.storeValue) { |
|
|
|
|
const json = self._filterValues(self.storeValue); |
|
|
|
|
firstItems = self._createItems(json); |
|
|
|
|
} |
|
|
|
|
const context = { |
|
|
|
|
tipText: ob.tipText, |
|
|
|
|
}; |
|
|
|
|
callback(firstItems.concat(self._createItems(ob.items)), keyword, context); |
|
|
|
|
if (op.times === 1 && self.storeValue) { |
|
|
|
|
self.setValue(self.storeValue); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
value: opts.value, |
|
|
|
|
height: "fill", |
|
|
|
|
}); |
|
|
|
|
this.button_group.on(Controller.EVENT_CHANGE, function () { |
|
|
|
|
self.fireEvent(Controller.EVENT_CHANGE, arguments); |
|
|
|
|
}); |
|
|
|
|
this.button_group.on(SelectList.EVENT_CHANGE, function () { |
|
|
|
|
|
|
|
|
|
const searchLoaderEventChangeName = opts.allowSelectAll ? SelectList.EVENT_CHANGE : ListPane.EVENT_CHANGE; |
|
|
|
|
this.button_group.on(searchLoaderEventChangeName, function () { |
|
|
|
|
self.fireEvent(MultiSelectSearchLoader.EVENT_CHANGE, arguments); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
@ -131,7 +178,9 @@ export class MultiSelectSearchLoader extends Widget {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
isAllSelected() { |
|
|
|
|
return this.button_group.isAllSelected(); |
|
|
|
|
const o = this.options; |
|
|
|
|
|
|
|
|
|
return o.allowSelectAll ? this.button_group.isAllSelected() : false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_filterValues(src) { |
|
|
|
@ -161,13 +210,24 @@ export class MultiSelectSearchLoader extends Widget {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
setValue(v) { |
|
|
|
|
v || (v = {}); |
|
|
|
|
const o = this.options; |
|
|
|
|
// 暂存的值一定是新的值,不然v改掉后,storeValue也跟着改了
|
|
|
|
|
this.storeValue = deepClone(v); |
|
|
|
|
this.button_group.setValue(v); |
|
|
|
|
o.allowSelectAll ? (this.button_group.setValue(v)) : (this.button_group.setValue(v.value)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getValue() { |
|
|
|
|
return this.button_group.getValue(); |
|
|
|
|
const o = this.options; |
|
|
|
|
if (o.allowSelectAll) { |
|
|
|
|
return this.button_group.getValue(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
type: ButtonGroup.CHOOSE_TYPE_MULTI, |
|
|
|
|
value: this.button_group.getValue(), |
|
|
|
|
assist: this.button_group.getNotSelectedValue(), |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getAllButtons() { |
|
|
|
|