|
|
@ -14,7 +14,7 @@ import { |
|
|
|
SIZE_CONSANTS |
|
|
|
SIZE_CONSANTS |
|
|
|
} from "@/core"; |
|
|
|
} from "@/core"; |
|
|
|
import { ButtonGroup, Loader } from "@/base"; |
|
|
|
import { ButtonGroup, Loader } from "@/base"; |
|
|
|
import { SelectList, MultiSelectBar, MultiSelectItem } from "@/case"; |
|
|
|
import { SelectList, MultiSelectBar, MultiSelectItem, ListPane } from "@/case"; |
|
|
|
|
|
|
|
|
|
|
|
@shortcut() |
|
|
|
@shortcut() |
|
|
|
export class MultiSelectSearchLoader extends Widget { |
|
|
|
export class MultiSelectSearchLoader extends Widget { |
|
|
@ -29,18 +29,18 @@ export class MultiSelectSearchLoader extends Widget { |
|
|
|
keywordGetter: emptyFn, |
|
|
|
keywordGetter: emptyFn, |
|
|
|
valueFormatter: emptyFn, |
|
|
|
valueFormatter: emptyFn, |
|
|
|
itemFormatter: emptyFn, |
|
|
|
itemFormatter: emptyFn, |
|
|
|
|
|
|
|
allowSelectAll: true, |
|
|
|
itemHeight: 24, |
|
|
|
itemHeight: 24, |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_init() { |
|
|
|
_init() { |
|
|
|
super._init(...arguments); |
|
|
|
super._init(...arguments); |
|
|
|
|
|
|
|
|
|
|
|
const self = this, |
|
|
|
const self = this, |
|
|
|
opts = this.options; |
|
|
|
opts = this.options; |
|
|
|
let hasNext = false; |
|
|
|
let hasNext = false; |
|
|
|
this.storeValue = deepClone(opts.value); |
|
|
|
this.storeValue = deepClone(opts.value); |
|
|
|
this.button_group = createWidget({ |
|
|
|
this.button_group = createWidget(opts.allowSelectAll ? { |
|
|
|
type: SelectList.xtype, |
|
|
|
type: SelectList.xtype, |
|
|
|
toolbar: { |
|
|
|
toolbar: { |
|
|
|
type: MultiSelectBar.xtype, |
|
|
|
type: MultiSelectBar.xtype, |
|
|
@ -101,11 +101,58 @@ export class MultiSelectSearchLoader extends Widget { |
|
|
|
hasNext() { |
|
|
|
hasNext() { |
|
|
|
return 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 () { |
|
|
|
this.button_group.on(Controller.EVENT_CHANGE, function () { |
|
|
|
self.fireEvent(Controller.EVENT_CHANGE, arguments); |
|
|
|
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); |
|
|
|
self.fireEvent(MultiSelectSearchLoader.EVENT_CHANGE, arguments); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
@ -131,7 +178,9 @@ export class MultiSelectSearchLoader extends Widget { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
isAllSelected() { |
|
|
|
isAllSelected() { |
|
|
|
return this.button_group.isAllSelected(); |
|
|
|
const o = this.options; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return o.allowSelectAll ? this.button_group.isAllSelected() : false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_filterValues(src) { |
|
|
|
_filterValues(src) { |
|
|
@ -161,15 +210,26 @@ export class MultiSelectSearchLoader extends Widget { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
setValue(v) { |
|
|
|
setValue(v) { |
|
|
|
|
|
|
|
v || (v = {}); |
|
|
|
|
|
|
|
const o = this.options; |
|
|
|
// 暂存的值一定是新的值,不然v改掉后,storeValue也跟着改了
|
|
|
|
// 暂存的值一定是新的值,不然v改掉后,storeValue也跟着改了
|
|
|
|
this.storeValue = deepClone(v); |
|
|
|
this.storeValue = deepClone(v); |
|
|
|
this.button_group.setValue(v); |
|
|
|
o.allowSelectAll ? (this.button_group.setValue(v)) : (this.button_group.setValue(v.value)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
getValue() { |
|
|
|
getValue() { |
|
|
|
|
|
|
|
const o = this.options; |
|
|
|
|
|
|
|
if (o.allowSelectAll) { |
|
|
|
return this.button_group.getValue(); |
|
|
|
return this.button_group.getValue(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
|
|
|
type: ButtonGroup.CHOOSE_TYPE_MULTI, |
|
|
|
|
|
|
|
value: this.button_group.getValue(), |
|
|
|
|
|
|
|
assist: this.button_group.getNotSelectedValue(), |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
getAllButtons() { |
|
|
|
getAllButtons() { |
|
|
|
return this.button_group.getAllButtons(); |
|
|
|
return this.button_group.getAllButtons(); |
|
|
|
} |
|
|
|
} |
|
|
|