forked from fanruan/fineui
Browse Source
# Conflicts: # src/case/button/index.js # src/case/button/node/node.first.plus.js # src/case/button/node/node.last.plus.js # src/case/button/node/node.mid.plus.js # src/case/button/node/treenode.js # src/case/button/treeitem/treeitem.jses6
61 changed files with 3498 additions and 4383 deletions
@ -1,31 +1,27 @@ |
|||||||
export { MultiSelectItem } from "./item.multiselect"; |
export { MultiSelectItem } from "./item.multiselect"; |
||||||
export { SingleSelectIconTextItem } from "./item.singleselect.icontext"; |
export { SingleSelectIconTextItem } from "./item.singleselect.icontext"; |
||||||
export { SingleSelectItem } from "./item.singleselect"; |
export { SingleSelectItem } from "./item.singleselect"; |
||||||
export { SingleSelectRadioItem } from "./item.singleselect.radio"; |
export { SingleSelectRadioItem } from "./item.singleselect.radio"; |
||||||
export { Switch } from "./switch"; |
export { Switch } from "./switch"; |
||||||
|
|
||||||
export { IconChangeButton } from "./icon/icon.change"; |
export { IconChangeButton } from "./icon/icon.change"; |
||||||
export { TriggerIconButton } from "./icon/icon.trigger"; |
export { TriggerIconButton } from "./icon/icon.trigger"; |
||||||
export { HalfIconButton } from "./icon/iconhalf/icon.half.image"; |
export { HalfIconButton } from "./icon/iconhalf/icon.half.image"; |
||||||
export { HalfButton } from "./icon/iconhalf/icon.half"; |
export { HalfButton } from "./icon/iconhalf/icon.half"; |
||||||
|
|
||||||
export { ArrowNode } from "./node/node.arrow"; |
export { ArrowNode } from "./node/node.arrow"; |
||||||
export { FirstPlusGroupNode } from "./node/node.first.plus"; |
export { IconArrowNode } from "./node/node.icon.arrow"; |
||||||
export { IconArrowNode } from "./node/node.icon.arrow"; |
export { MultiLayerIconArrowNode } from "./node/node.multilayer.icon.arrow"; |
||||||
export { LastPlusGroupNode } from "./node/node.last.plus"; |
export { PlusGroupNode } from "./node/node.plus"; |
||||||
export { MidPlusGroupNode } from "./node/node.mid.plus"; |
export { TreeNodeSwitcher } from "./node/siwtcher.tree.node"; |
||||||
export { MultiLayerIconArrowNode } from "./node/node.multilayer.icon.arrow"; |
export { BasicTreeNode } from "./node/treenode"; |
||||||
export { PlusGroupNode } from "./node/node.plus"; |
|
||||||
export { TreeNodeSwitcher } from "./node/siwtcher.tree.node"; |
export { IconTreeLeafItem } from "./treeitem/item.icon.treeleaf"; |
||||||
export { BasicTreeNode } from "./node/treenode"; |
export { MultiLayerIconTreeLeafItem } from "./treeitem/item.multilayer.icon.treeleaf"; |
||||||
|
|
||||||
export { IconTreeLeafItem } from "./treeitem/item.icon.treeleaf"; |
|
||||||
export { MultiLayerIconTreeLeafItem } from "./treeitem/item.multilayer.icon.treeleaf"; |
export { |
||||||
|
BasicTreeItem, FirstTreeLeafItem, MidTreeLeafItem, LastTreeLeafItem, RootTreeLeafItem |
||||||
export { |
} from "./treeitem/treeitem"; |
||||||
BasicTreeItem, |
|
||||||
FirstTreeLeafItem, |
export * from "./node/treenode"; |
||||||
MidTreeLeafItem, |
|
||||||
LastTreeLeafItem, |
|
||||||
RootTreeLeafItem |
|
||||||
} from "./treeitem/treeitem"; |
|
||||||
|
@ -1,103 +0,0 @@ |
|||||||
import { FirstTreeNodeCheckbox } from "../../checkbox"; |
|
||||||
import { Label, NodeButton } from "@/base"; |
|
||||||
import { shortcut, extend, createWidget, Controller } from "@/core"; |
|
||||||
|
|
||||||
/** |
|
||||||
* 加号表示的组节点 |
|
||||||
* Created by GUY on 2015/9/6. |
|
||||||
* @class FirstPlusGroupNode |
|
||||||
* @extends NodeButton |
|
||||||
*/ |
|
||||||
@shortcut() |
|
||||||
export class FirstPlusGroupNode extends NodeButton { |
|
||||||
static xtype = "bi.first_plus_group_node"; |
|
||||||
|
|
||||||
_defaultConfig() { |
|
||||||
const conf = super._defaultConfig(...arguments); |
|
||||||
|
|
||||||
return extend(conf, { |
|
||||||
baseCls: `${conf.baseCls || ""} bi-first-plus-group-node bi-list-item`, |
|
||||||
logic: { |
|
||||||
dynamic: false, |
|
||||||
}, |
|
||||||
id: "", |
|
||||||
pId: "", |
|
||||||
open: false, |
|
||||||
height: 24, |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
_init() { |
|
||||||
super._init.apply(this, arguments); |
|
||||||
const o = this.options; |
|
||||||
this.checkbox = createWidget({ |
|
||||||
type: FirstTreeNodeCheckbox.xtype, |
|
||||||
stopPropagation: true, |
|
||||||
iconHeight: o.height, |
|
||||||
iconWidth: o.height, |
|
||||||
}); |
|
||||||
this.text = createWidget({ |
|
||||||
type: Label.xtype, |
|
||||||
textAlign: "left", |
|
||||||
whiteSpace: "nowrap", |
|
||||||
textHeight: o.height, |
|
||||||
height: o.height, |
|
||||||
hgap: o.hgap, |
|
||||||
text: o.text, |
|
||||||
value: o.value, |
|
||||||
py: o.py, |
|
||||||
keyword: o.keyword, |
|
||||||
}); |
|
||||||
this.checkbox.on(Controller.EVENT_CHANGE, function (type) { |
|
||||||
if (type === BI.Events.CLICK) { |
|
||||||
if (this.isSelected()) { |
|
||||||
self.triggerExpand(); |
|
||||||
} else { |
|
||||||
self.triggerCollapse(); |
|
||||||
} |
|
||||||
} |
|
||||||
}); |
|
||||||
const type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); |
|
||||||
const items = BI.LogicFactory.createLogicItemsByDirection( |
|
||||||
BI.Direction.Left, |
|
||||||
{ |
|
||||||
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, |
|
||||||
el: this.checkbox, |
|
||||||
}, |
|
||||||
this.text |
|
||||||
); |
|
||||||
BI.createWidget( |
|
||||||
BI.extend( |
|
||||||
{ |
|
||||||
element: this, |
|
||||||
}, |
|
||||||
BI.LogicFactory.createLogic( |
|
||||||
type, |
|
||||||
BI.extend(o.logic, { |
|
||||||
items, |
|
||||||
}) |
|
||||||
) |
|
||||||
) |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
doRedMark() { |
|
||||||
this.text.doRedMark(...arguments); |
|
||||||
} |
|
||||||
|
|
||||||
unRedMark() { |
|
||||||
this.text.unRedMark(...arguments); |
|
||||||
} |
|
||||||
|
|
||||||
doClick() { |
|
||||||
super.doClick(...arguments); |
|
||||||
this.checkbox.setSelected(this.isSelected()); |
|
||||||
} |
|
||||||
|
|
||||||
setOpened(v) { |
|
||||||
super.setOpened(...arguments); |
|
||||||
if (BI.isNotNull(this.checkbox)) { |
|
||||||
this.checkbox.setSelected(v); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,102 +0,0 @@ |
|||||||
import { LastTreeNodeCheckbox } from "../../checkbox"; |
|
||||||
import { Label, NodeButton } from "@/base"; |
|
||||||
import { shortcut, extend, createWidget, isNotNull, Controller } from "@/core"; |
|
||||||
|
|
||||||
/** |
|
||||||
* 加号表示的组节点 |
|
||||||
* Created by GUY on 2015/9/6. |
|
||||||
* @class LastPlusGroupNode |
|
||||||
* @extends NodeButton |
|
||||||
*/ |
|
||||||
@shortcut() |
|
||||||
export class LastPlusGroupNode extends NodeButton { |
|
||||||
static xtype = "bi.last_plus_group_node"; |
|
||||||
|
|
||||||
_defaultConfig() { |
|
||||||
const conf = super._defaultConfig(...arguments); |
|
||||||
|
|
||||||
return extend(conf, { |
|
||||||
baseCls: `${conf.baseCls || ""} bi-last-plus-group-node bi-list-item`, |
|
||||||
logic: { |
|
||||||
dynamic: false, |
|
||||||
}, |
|
||||||
id: "", |
|
||||||
pId: "", |
|
||||||
open: false, |
|
||||||
height: 24, |
|
||||||
}); |
|
||||||
} |
|
||||||
_init() { |
|
||||||
BI.LastPlusGroupNode.superclass._init.apply(this, arguments); |
|
||||||
const o = this.options; |
|
||||||
this.checkbox = createWidget({ |
|
||||||
type: LastTreeNodeCheckbox.xtype, |
|
||||||
stopPropagation: true, |
|
||||||
iconHeight: o.height, |
|
||||||
iconWidth: o.height, |
|
||||||
}); |
|
||||||
this.text = createWidget({ |
|
||||||
type: Label.xtype, |
|
||||||
textAlign: "left", |
|
||||||
whiteSpace: "nowrap", |
|
||||||
textHeight: o.height, |
|
||||||
height: o.height, |
|
||||||
hgap: o.hgap, |
|
||||||
text: o.text, |
|
||||||
value: o.value, |
|
||||||
py: o.py, |
|
||||||
keyword: o.keyword, |
|
||||||
}); |
|
||||||
this.checkbox.on(Controller.EVENT_CHANGE, (type) => { |
|
||||||
if (type === BI.Events.CLICK) { |
|
||||||
if (this.checkbox.isSelected()) { |
|
||||||
this.triggerExpand(); |
|
||||||
} else { |
|
||||||
this.triggerCollapse(); |
|
||||||
} |
|
||||||
} |
|
||||||
}); |
|
||||||
const type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); |
|
||||||
const items = BI.LogicFactory.createLogicItemsByDirection( |
|
||||||
BI.Direction.Left, |
|
||||||
{ |
|
||||||
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, |
|
||||||
el: this.checkbox, |
|
||||||
}, |
|
||||||
this.text |
|
||||||
); |
|
||||||
createWidget( |
|
||||||
extend( |
|
||||||
{ |
|
||||||
element: this, |
|
||||||
}, |
|
||||||
BI.LogicFactory.createLogic( |
|
||||||
type, |
|
||||||
extend(o.logic, { |
|
||||||
items, |
|
||||||
}) |
|
||||||
) |
|
||||||
) |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
doRedMark() { |
|
||||||
this.text.doRedMark(...arguments); |
|
||||||
} |
|
||||||
|
|
||||||
unRedMark() { |
|
||||||
this.text.unRedMark(...arguments); |
|
||||||
} |
|
||||||
|
|
||||||
doClick() { |
|
||||||
super.doClick(...arguments); |
|
||||||
this.checkbox.setSelected(this.isSelected()); |
|
||||||
} |
|
||||||
|
|
||||||
setOpened(v) { |
|
||||||
super.setOpened(...arguments); |
|
||||||
if (isNotNull(this.checkbox)) { |
|
||||||
this.checkbox.setSelected(v); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,103 +0,0 @@ |
|||||||
import { MidTreeNodeCheckbox } from "../../checkbox"; |
|
||||||
import { Label, NodeButton } from "@/base"; |
|
||||||
import { shortcut, extend, createWidget, Controller } from "@/core"; |
|
||||||
|
|
||||||
/** |
|
||||||
* 加号表示的组节点 |
|
||||||
* Created by GUY on 2015/9/6. |
|
||||||
* @class BI.MidPlusGroupNode |
|
||||||
* @extends BI.NodeButton |
|
||||||
*/ |
|
||||||
@shortcut |
|
||||||
export class MidPlusGroupNode extends NodeButton { |
|
||||||
static xtype = "bi.mid_plus_group_node"; |
|
||||||
|
|
||||||
_defaultConfig() { |
|
||||||
const conf = super._defaultConfig(...arguments); |
|
||||||
|
|
||||||
return extend(conf, { |
|
||||||
baseCls: `${conf.baseCls || ""} bi-mid-plus-group-node bi-list-item`, |
|
||||||
logic: { |
|
||||||
dynamic: false, |
|
||||||
}, |
|
||||||
id: "", |
|
||||||
pId: "", |
|
||||||
open: false, |
|
||||||
height: 24, |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
_init() { |
|
||||||
super._init(...arguments); |
|
||||||
const o = this.options; |
|
||||||
this.checkbox = createWidget({ |
|
||||||
type: MidTreeNodeCheckbox.xtype, |
|
||||||
stopPropagation: true, |
|
||||||
iconHeight: o.height, |
|
||||||
iconWidth: o.height, |
|
||||||
}); |
|
||||||
this.text = createWidget({ |
|
||||||
type: Label.xtype, |
|
||||||
textAlign: "left", |
|
||||||
whiteSpace: "nowrap", |
|
||||||
textHeight: o.height, |
|
||||||
height: o.height, |
|
||||||
hgap: o.hgap, |
|
||||||
text: o.text, |
|
||||||
value: o.value, |
|
||||||
py: o.py, |
|
||||||
keyword: o.keyword, |
|
||||||
}); |
|
||||||
this.checkbox.on(Controller.EVENT_CHANGE, (type) => { |
|
||||||
if (type === BI.Events.CLICK) { |
|
||||||
if (this.checkbox.isSelected()) { |
|
||||||
this.triggerExpand(); |
|
||||||
} else { |
|
||||||
this.triggerCollapse(); |
|
||||||
} |
|
||||||
} |
|
||||||
}); |
|
||||||
const type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); |
|
||||||
const items = BI.LogicFactory.createLogicItemsByDirection( |
|
||||||
BI.Direction.Left, |
|
||||||
{ |
|
||||||
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, |
|
||||||
el: this.checkbox, |
|
||||||
}, |
|
||||||
this.text |
|
||||||
); |
|
||||||
createWidget( |
|
||||||
extend( |
|
||||||
{ |
|
||||||
element: this, |
|
||||||
}, |
|
||||||
BI.LogicFactory.createLogic( |
|
||||||
type, |
|
||||||
extend(o.logic, { |
|
||||||
items, |
|
||||||
}) |
|
||||||
) |
|
||||||
) |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
doRedMark() { |
|
||||||
this.text.doRedMark(...arguments); |
|
||||||
} |
|
||||||
|
|
||||||
unRedMark() { |
|
||||||
this.text.unRedMark(...arguments); |
|
||||||
} |
|
||||||
|
|
||||||
doClick() { |
|
||||||
super.doClick(...arguments); |
|
||||||
this.checkbox.setSelected(this.isSelected()); |
|
||||||
} |
|
||||||
|
|
||||||
setOpened(v) { |
|
||||||
super.setOpened(...arguments); |
|
||||||
if (BI.isNotNull(this.checkbox)) { |
|
||||||
this.checkbox.setSelected(v); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,77 +1,77 @@ |
|||||||
/** |
import { shortcut, extend, emptyFn, isNotNull, createWidget, bind, Selection, difference, map } from "@/core"; |
||||||
* 简单的复选下拉框控件, 适用于数据量少的情况, 与valuechooser的区别是allvaluechooser setValue和getValue返回的是所有值 |
import { AbstractAllValueChooser } from "./abstract.allvaluechooser"; |
||||||
* 封装了字段处理逻辑 |
import { MultiSelectCombo } from "@/widget"; |
||||||
* |
|
||||||
* Created by GUY on 2015/10/29. |
|
||||||
* @class BI.AllValueChooserCombo |
|
||||||
* @extends BI.AbstractAllValueChooser |
|
||||||
*/ |
|
||||||
BI.AllValueChooserCombo = BI.inherit(BI.AbstractAllValueChooser, { |
|
||||||
|
|
||||||
_defaultConfig: function () { |
@shortcut() |
||||||
return BI.extend(BI.AllValueChooserCombo.superclass._defaultConfig.apply(this, arguments), { |
export class AllValueChooserCombo extends AbstractAllValueChooser { |
||||||
|
static xtype = "bi.all_value_chooser_combo"; |
||||||
|
|
||||||
|
static EVENT_CONFIRM = "EVENT_CONFIRM"; |
||||||
|
|
||||||
|
_defaultConfig() { |
||||||
|
return extend(super._defaultConfig(...arguments), { |
||||||
baseCls: "bi-all-value-chooser-combo", |
baseCls: "bi-all-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.AllValueChooserCombo.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, |
||||||
text: o.text, |
text: o.text, |
||||||
element: this, |
element: this, |
||||||
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, |
||||||
value: this._assertValue({ |
value: this._assertValue({ |
||||||
type: BI.Selection.Multi, |
type: Selection.Multi, |
||||||
value: o.value || [] |
value: o.value || [], |
||||||
}) |
}), |
||||||
}); |
}); |
||||||
|
|
||||||
this.combo.on(BI.MultiSelectCombo.EVENT_CONFIRM, function () { |
this.combo.on(MultiSelectCombo.EVENT_CONFIRM, () => { |
||||||
self.fireEvent(BI.AllValueChooserCombo.EVENT_CONFIRM); |
this.fireEvent(AllValueChooserCombo.EVENT_CONFIRM); |
||||||
}); |
}); |
||||||
}, |
} |
||||||
|
|
||||||
setValue: function (v) { |
setValue(v) { |
||||||
this.combo.setValue(this._assertValue({ |
this.combo.setValue( |
||||||
type: BI.Selection.Multi, |
this._assertValue({ |
||||||
value: v || [] |
type: Selection.Multi, |
||||||
})); |
value: v || [], |
||||||
}, |
}) |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
getValue: function () { |
getValue() { |
||||||
return this.getAllValue(); |
return this.getAllValue(); |
||||||
}, |
} |
||||||
|
|
||||||
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.AllValueChooserCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; |
|
||||||
BI.shortcut("bi.all_value_chooser_combo", BI.AllValueChooserCombo); |
|
||||||
|
@ -0,0 +1,3 @@ |
|||||||
|
export { AbstractAllValueChooser } from "./abstract.allvaluechooser"; |
||||||
|
export { AllValueChooserCombo } from "./combo.allvaluechooser"; |
||||||
|
export { AllValueChooserPane } from "./pane.allvaluechooser"; |
@ -1,69 +1,67 @@ |
|||||||
/** |
import { shortcut, extend, emptyFn, createWidget, bind, isNotNull, Selection, difference, map } from "@/core"; |
||||||
* 简单的复选面板, 适用于数据量少的情况, 与valuechooser的区别是allvaluechooser setValue和getValue返回的是所有值 |
import { AbstractAllValueChooser } from "./abstract.allvaluechooser"; |
||||||
* 封装了字段处理逻辑 |
import { MultiSelectList } from "@/widget"; |
||||||
* |
|
||||||
* Created by GUY on 2015/10/29. |
|
||||||
* @class BI.AllValueChooserPane |
|
||||||
* @extends BI.AbstractAllValueChooser |
|
||||||
*/ |
|
||||||
BI.AllValueChooserPane = BI.inherit(BI.AbstractAllValueChooser, { |
|
||||||
|
|
||||||
_defaultConfig: function () { |
@shortcut() |
||||||
return BI.extend(BI.AllValueChooserPane.superclass._defaultConfig.apply(this, arguments), { |
export class AllValueChooserPane extends AbstractAllValueChooser { |
||||||
|
static xtype = "bi.all_value_chooser_pane"; |
||||||
|
|
||||||
|
static EVENT_CHANGE = "EVENT_CHANGE"; |
||||||
|
|
||||||
|
_defaultConfig() { |
||||||
|
return extend(super._defaultConfig(...arguments), { |
||||||
baseCls: "bi-all-value-chooser-pane", |
baseCls: "bi-all-value-chooser-pane", |
||||||
width: 200, |
width: 200, |
||||||
height: 30, |
height: 30, |
||||||
items: null, |
items: null, |
||||||
itemsCreator: BI.emptyFn, |
itemsCreator: emptyFn, |
||||||
cache: true |
cache: true, |
||||||
}); |
}); |
||||||
}, |
} |
||||||
|
|
||||||
_init: function () { |
_init() { |
||||||
BI.AllValueChooserPane.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, |
||||||
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, |
||||||
}); |
}); |
||||||
|
|
||||||
this.list.on(BI.MultiSelectList.EVENT_CHANGE, function () { |
this.list.on(MultiSelectList.EVENT_CHANGE, () => { |
||||||
self.fireEvent(BI.AllValueChooserPane.EVENT_CHANGE); |
this.fireEvent(AllValueChooserPane.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({ |
this.list.setValue({ |
||||||
type: BI.Selection.Multi, |
type: Selection.Multi, |
||||||
value: v || [] |
value: v || [], |
||||||
}); |
}); |
||||||
}, |
} |
||||||
|
|
||||||
getValue: function () { |
getValue() { |
||||||
var val = this.list.getValue() || {}; |
const val = this.list.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.AllValueChooserPane.EVENT_CHANGE = "EVENT_CHANGE"; |
|
||||||
BI.shortcut("bi.all_value_chooser_pane", BI.AllValueChooserPane); |
|
||||||
|
@ -1,66 +1,72 @@ |
|||||||
BI.AllValueMultiTextValueCombo = BI.inherit(BI.Widget, { |
import { shortcut, Widget, Selection, each, contains } from "@/core"; |
||||||
|
import { SearchMultiTextValueCombo } from "@/widget"; |
||||||
|
|
||||||
props: { |
@shortcut() |
||||||
baseCls: "bi-all-value-multi-text-value-combo", |
export class AllValueMultiTextValueCombo extends Widget { |
||||||
width: 200, |
static xtype = "bi.all_value_multi_text_value_combo"; |
||||||
height: 24, |
|
||||||
items: [] |
|
||||||
}, |
|
||||||
|
|
||||||
render: function () { |
props = { baseCls: "bi-all-value-multi-text-value-combo", width: 200, height: 24, items: [] }; |
||||||
var self = this, o = this.options; |
|
||||||
var value = this._digestValue(o.value); |
static EVENT_CONFIRM = "EVENT_CONFIRM"; |
||||||
|
|
||||||
|
render() { |
||||||
|
const self = this, |
||||||
|
o = this.options; |
||||||
|
const value = this._digestValue(o.value); |
||||||
|
|
||||||
return { |
return { |
||||||
type: "bi.search_multi_text_value_combo", |
type: "bi.search_multi_text_value_combo", |
||||||
simple: o.simple, |
simple: o.simple, |
||||||
text: o.text, |
text: o.text, |
||||||
height: o.height, |
height: o.height, |
||||||
items: o.items, |
items: o.items, |
||||||
value: value, |
value, |
||||||
numOfPage: 100, |
numOfPage: 100, |
||||||
valueFormatter: o.valueFormatter, |
valueFormatter: o.valueFormatter, |
||||||
warningTitle: o.warningTitle, |
warningTitle: o.warningTitle, |
||||||
listeners: [{ |
listeners: [ |
||||||
eventName: BI.SearchMultiTextValueCombo.EVENT_CONFIRM, |
{ |
||||||
action: function () { |
eventName: SearchMultiTextValueCombo.EVENT_CONFIRM, |
||||||
self.fireEvent(BI.AllValueMultiTextValueCombo.EVENT_CONFIRM); |
action () { |
||||||
|
self.fireEvent(AllValueMultiTextValueCombo.EVENT_CONFIRM); |
||||||
|
}, |
||||||
} |
} |
||||||
}], |
], |
||||||
ref: function () { |
ref () { |
||||||
self.combo = this; |
self.combo = this; |
||||||
} |
}, |
||||||
}; |
}; |
||||||
}, |
} |
||||||
|
|
||||||
setValue: function (v) { |
setValue(v) { |
||||||
var value = this._digestValue(v); |
const value = this._digestValue(v); |
||||||
this.combo.setValue(value); |
this.combo.setValue(value); |
||||||
}, |
} |
||||||
|
|
||||||
getValue: function () { |
getValue() { |
||||||
var obj = this.combo.getValue() || {}; |
const obj = this.combo.getValue() || {}; |
||||||
obj.value = obj.value || []; |
obj.value = obj.value || []; |
||||||
if(obj.type === BI.Selection.All) { |
if (obj.type === Selection.All) { |
||||||
var values = []; |
const values = []; |
||||||
BI.each(this.options.items, function (idx, item) { |
each(this.options.items, (idx, item) => { |
||||||
!BI.contains(obj.value, item.value) && values.push(item.value); |
!contains(obj.value, item.value) && values.push(item.value); |
||||||
}); |
}); |
||||||
|
|
||||||
return values; |
return values; |
||||||
} |
} |
||||||
|
|
||||||
return obj.value || []; |
return obj.value || []; |
||||||
}, |
} |
||||||
|
|
||||||
populate: function (items) { |
populate(items) { |
||||||
this.options.items = items; |
this.options.items = items; |
||||||
this.combo.populate.apply(this.combo, arguments); |
this.combo.populate(...arguments); |
||||||
}, |
} |
||||||
|
|
||||||
_digestValue: function (v) { |
_digestValue(v) { |
||||||
return { |
return { |
||||||
type: BI.Selection.Multi, |
type: Selection.Multi, |
||||||
value: v || [] |
value: v || [], |
||||||
}; |
}; |
||||||
} |
} |
||||||
}); |
} |
||||||
BI.AllValueMultiTextValueCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; |
|
||||||
BI.shortcut("bi.all_value_multi_text_value_combo", BI.AllValueMultiTextValueCombo); |
|
||||||
|
@ -1,98 +1,111 @@ |
|||||||
/** |
|
||||||
* @author windy |
|
||||||
* @version 2.0 |
|
||||||
* Created by windy on 2022/1/11 |
|
||||||
*/ |
|
||||||
BI.FormField = BI.inherit(BI.Widget, { |
|
||||||
|
|
||||||
props: { |
import { shortcut, Widget, extend, concat, isKey, VerticalAlign } from "@/core"; |
||||||
|
|
||||||
|
@shortcut() |
||||||
|
export class FormField extends Widget { |
||||||
|
static xtype = "bi.form_field"; |
||||||
|
|
||||||
|
props = { |
||||||
baseCls: "bi-form-field", |
baseCls: "bi-form-field", |
||||||
label: "", |
label: "", |
||||||
el: {}, |
el: {}, |
||||||
headerCls: "", |
headerCls: "", |
||||||
labelAlign: "right", // 文字默认右对齐
|
labelAlign: "right", // 文字默认右对齐
|
||||||
validate: function () { |
validate () { |
||||||
return true; |
return true; |
||||||
} // 默认返回true
|
}, // 默认返回true
|
||||||
}, |
} |
||||||
|
|
||||||
render: function () { |
render () { |
||||||
var self = this, o = this.options; |
const self = this, |
||||||
|
o = this.options; |
||||||
|
|
||||||
var field = { |
const field = { |
||||||
type: "bi.absolute", |
type: "bi.absolute", |
||||||
items: [{ |
items: [ |
||||||
el: BI.extend({}, o.el, { |
{ |
||||||
ref: function (_ref) { |
el: extend({}, o.el, { |
||||||
self.field = _ref; |
ref (_ref) { |
||||||
o.el.ref && o.el.ref.call(this, _ref); |
self.field = _ref; |
||||||
}, |
o.el.ref && o.el.ref.call(this, _ref); |
||||||
height: o.el.height || 28, |
}, |
||||||
listeners: BI.concat(o.el.listeners, [{ |
height: o.el.height || 28, |
||||||
eventName: "EVENT_CHANGE", |
listeners: concat(o.el.listeners, [ |
||||||
action: function () { |
{ |
||||||
self.fireEvent("EVENT_CHANGE"); |
eventName: "EVENT_CHANGE", |
||||||
} |
action () { |
||||||
}, { |
self.fireEvent("EVENT_CHANGE"); |
||||||
eventName: "EVENT_CONFIRM", |
}, |
||||||
action: function () { |
}, |
||||||
self.fireEvent("EVENT_CONFIRM"); |
{ |
||||||
} |
eventName: "EVENT_CONFIRM", |
||||||
}]) |
action () { |
||||||
}), |
self.fireEvent("EVENT_CONFIRM"); |
||||||
left: 0, |
}, |
||||||
bottom: 0, |
} |
||||||
right: 0, |
]), |
||||||
top: 0 |
}), |
||||||
}, { |
left: 0, |
||||||
el: { |
bottom: 0, |
||||||
type: "bi.label", |
right: 0, |
||||||
cls: "error-tip bi-error", |
top: 0, |
||||||
ref: function (_ref) { |
|
||||||
self.error = _ref; |
|
||||||
}, |
|
||||||
invisible: true |
|
||||||
}, |
}, |
||||||
bottom: -20, |
{ |
||||||
left: 0, |
el: { |
||||||
right: 0, |
type: "bi.label", |
||||||
height: 20 |
cls: "error-tip bi-error", |
||||||
}] |
ref (_ref) { |
||||||
|
self.error = _ref; |
||||||
|
}, |
||||||
|
invisible: true, |
||||||
|
}, |
||||||
|
bottom: -20, |
||||||
|
left: 0, |
||||||
|
right: 0, |
||||||
|
height: 20, |
||||||
|
} |
||||||
|
], |
||||||
}; |
}; |
||||||
|
|
||||||
return { |
return { |
||||||
type: "bi.vertical_adapt", |
type: "bi.vertical_adapt", |
||||||
columnSize: ["auto", "fill"], |
columnSize: ["auto", "fill"], |
||||||
verticalAlign: BI.VerticalAlign.Stretch, |
verticalAlign: VerticalAlign.Stretch, |
||||||
items: BI.isKey(o.label) ? [{ |
items: isKey(o.label) |
||||||
el: { |
? [ |
||||||
type: "bi.label", |
{ |
||||||
textAlign: o.labelAlign, |
el: { |
||||||
text: o.label, |
type: "bi.label", |
||||||
width: o.labelWidth, |
textAlign: o.labelAlign, |
||||||
cls: o.headerCls, |
text: o.label, |
||||||
rgap: 20 // 表单文字与右侧输入间距均为20px
|
width: o.labelWidth, |
||||||
} |
cls: o.headerCls, |
||||||
}, field] : [field] |
rgap: 20, // 表单文字与右侧输入间距均为20px
|
||||||
|
}, |
||||||
|
}, |
||||||
|
field |
||||||
|
] |
||||||
|
: [field], |
||||||
}; |
}; |
||||||
}, |
} |
||||||
|
|
||||||
getValue: function () { |
getValue () { |
||||||
return this.field.getValue(); |
return this.field.getValue(); |
||||||
}, |
} |
||||||
|
|
||||||
validate: function () { |
validate () { |
||||||
var isValid = this.validateWithNoTip(); |
const isValid = this.validateWithNoTip(); |
||||||
!isValid && this.error.setText(this.options.tip(this.field.getValue(), this.field)); |
!isValid && |
||||||
|
this.error.setText( |
||||||
|
this.options.tip(this.field.getValue(), this.field) |
||||||
|
); |
||||||
this.error.setVisible(!isValid); |
this.error.setVisible(!isValid); |
||||||
this.field.element[isValid ? "removeClass" : "addClass"]("bi-error"); |
this.field.element[isValid ? "removeClass" : "addClass"]("bi-error"); |
||||||
|
|
||||||
return isValid; |
return isValid; |
||||||
}, |
} |
||||||
|
|
||||||
validateWithNoTip: function () { |
validateWithNoTip () { |
||||||
return this.options.validate(this.field.getValue(), this.field); |
return this.options.validate(this.field.getValue(), this.field); |
||||||
} |
} |
||||||
}); |
} |
||||||
|
|
||||||
BI.shortcut("bi.form_field", BI.FormField); |
|
||||||
|
@ -0,0 +1,2 @@ |
|||||||
|
export { Form } from "./form"; |
||||||
|
export { FormField } from "./form.field"; |
@ -0,0 +1,15 @@ |
|||||||
|
import * as allvaluechooser from "./allvaluechooser"; |
||||||
|
import * as form from "./form"; |
||||||
|
import { AllValueMultiTextValueCombo } from "./allvaluemultitextvaluecombo/allvalue.multitextvalue.combo"; |
||||||
|
|
||||||
|
Object.assign(BI, { |
||||||
|
...allvaluechooser, |
||||||
|
...form, |
||||||
|
AllValueMultiTextValueCombo, |
||||||
|
}); |
||||||
|
|
||||||
|
export * from "./allvaluechooser"; |
||||||
|
export * from "./form"; |
||||||
|
export { |
||||||
|
AllValueMultiTextValueCombo |
||||||
|
}; |
@ -0,0 +1,2 @@ |
|||||||
|
export { MultiLayerSelectTreeCombo } from "./multilayerselecttree.combo"; |
||||||
|
export { MultiLayerSelectLevelTree } from "./multilayerselecttree.leveltree"; |
@ -1,92 +1,119 @@ |
|||||||
/** |
import { |
||||||
* Created by GUY on 2016/1/26. |
shortcut, |
||||||
* |
Widget, |
||||||
* @class BI.MultiLayerSelectTreeInsertSearchPane |
i18nText, |
||||||
* @extends BI.Pane |
emptyFn, |
||||||
*/ |
createWidget, |
||||||
|
Controller, |
||||||
|
VerticalLayout, |
||||||
|
isEmptyArray, |
||||||
|
isArray |
||||||
|
} from "@/core"; |
||||||
|
import { MultiLayerSelectLevelTree } from "./multilayerselecttree.leveltree"; |
||||||
|
import { TextButton } from "@/base"; |
||||||
|
|
||||||
BI.MultiLayerSelectTreeInsertSearchPane = BI.inherit(BI.Widget, { |
@shortcut() |
||||||
|
export class MultiLayerSelectTreeInsertSearchPane extends Widget { |
||||||
|
static xtype = "bi.multilayer_select_tree_insert_search_pane"; |
||||||
|
|
||||||
props: function() { |
static EVENT_ADD_ITEM = "EVENT_ADD_ITEM"; |
||||||
|
static EVENT_CHANGE = "EVENT_CHANGE"; |
||||||
|
|
||||||
|
props() { |
||||||
return { |
return { |
||||||
baseCls: "bi-multilayer-select-tree-popup", |
baseCls: "bi-multilayer-select-tree-popup", |
||||||
tipText: BI.i18nText("BI-No_Selected_Item"), |
tipText: i18nText("BI-No_Selected_Item"), |
||||||
isDefaultInit: false, |
isDefaultInit: false, |
||||||
itemsCreator: BI.emptyFn, |
itemsCreator: emptyFn, |
||||||
items: [], |
items: [], |
||||||
value: "" |
value: "", |
||||||
}; |
}; |
||||||
}, |
} |
||||||
|
|
||||||
render: function() { |
render() { |
||||||
var self = this, o = this.options; |
const self = this, |
||||||
this.tree = BI.createWidget({ |
o = this.options; |
||||||
type: "bi.multilayer_select_level_tree", |
this.tree = createWidget({ |
||||||
|
type: MultiLayerSelectLevelTree.xtype, |
||||||
isDefaultInit: o.isDefaultInit, |
isDefaultInit: o.isDefaultInit, |
||||||
items: o.items, |
items: o.items, |
||||||
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) { |
itemsCreator: |
||||||
o.itemsCreator(op, function (res) { |
o.itemsCreator === emptyFn |
||||||
callback(res); |
? emptyFn |
||||||
self.setKeyword(o.keywordGetter()); |
: function (op, callback) { |
||||||
}); |
o.itemsCreator(op, res => { |
||||||
}, |
callback(res); |
||||||
|
self.setKeyword(o.keywordGetter()); |
||||||
|
}); |
||||||
|
}, |
||||||
keywordGetter: o.keywordGetter, |
keywordGetter: o.keywordGetter, |
||||||
value: o.value, |
value: o.value, |
||||||
scrollable: null, |
scrollable: null, |
||||||
listeners: [{ |
listeners: [ |
||||||
eventName: BI.Controller.EVENT_CHANGE, |
{ |
||||||
action: function () { |
eventName: Controller.EVENT_CHANGE, |
||||||
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
action() { |
||||||
} |
self.fireEvent(Controller.EVENT_CHANGE, arguments); |
||||||
}, { |
}, |
||||||
eventName: BI.MultiLayerSelectLevelTree.EVENT_CHANGE, |
}, |
||||||
action: function () { |
{ |
||||||
self.fireEvent(BI.MultiLayerSelectTreeInsertSearchPane.EVENT_CHANGE); |
eventName: MultiLayerSelectLevelTree.EVENT_CHANGE, |
||||||
|
action() { |
||||||
|
self.fireEvent( |
||||||
|
MultiLayerSelectTreeInsertSearchPane.EVENT_CHANGE |
||||||
|
); |
||||||
|
}, |
||||||
} |
} |
||||||
}] |
], |
||||||
}); |
}); |
||||||
|
|
||||||
return { |
return { |
||||||
type: "bi.vertical", |
type: VerticalLayout.xtype, |
||||||
scrolly: false, |
scrolly: false, |
||||||
scrollable: true, |
scrollable: true, |
||||||
vgap: 5, |
vgap: 5, |
||||||
items: [{ |
items: [ |
||||||
type: "bi.text_button", |
{ |
||||||
invisible: true, |
type: TextButton.xtype, |
||||||
text: BI.i18nText("BI-Basic_Click_To_Add_Text", ""), |
invisible: true, |
||||||
height: 24, |
text: i18nText("BI-Basic_Click_To_Add_Text", ""), |
||||||
cls: "bi-high-light", |
height: 24, |
||||||
hgap: 5, |
cls: "bi-high-light", |
||||||
ref: function (_ref) { |
hgap: 5, |
||||||
self.addNotMatchTip = _ref; |
ref(_ref) { |
||||||
|
self.addNotMatchTip = _ref; |
||||||
|
}, |
||||||
|
handler() { |
||||||
|
self.fireEvent( |
||||||
|
MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM, |
||||||
|
o.keywordGetter() |
||||||
|
); |
||||||
|
}, |
||||||
}, |
}, |
||||||
handler: function () { |
this.tree |
||||||
self.fireEvent(BI.MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM, o.keywordGetter()); |
], |
||||||
} |
|
||||||
}, this.tree] |
|
||||||
}; |
}; |
||||||
}, |
} |
||||||
|
|
||||||
setKeyword: function (keyword) { |
setKeyword(keyword) { |
||||||
var showTip = BI.isEmptyArray(this.tree.getAllLeaves()); |
const showTip = isEmptyArray(this.tree.getAllLeaves()); |
||||||
this.addNotMatchTip.setVisible(showTip); |
this.addNotMatchTip.setVisible(showTip); |
||||||
showTip && this.addNotMatchTip.setText(BI.i18nText("BI-Basic_Click_To_Add_Text", keyword)); |
showTip && |
||||||
}, |
this.addNotMatchTip.setText( |
||||||
|
i18nText("BI-Basic_Click_To_Add_Text", keyword) |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
getValue: function () { |
getValue() { |
||||||
return this.tree.getValue(); |
return this.tree.getValue(); |
||||||
}, |
} |
||||||
|
|
||||||
setValue: function (v) { |
setValue(v) { |
||||||
v = BI.isArray(v) ? v : [v]; |
v = isArray(v) ? v : [v]; |
||||||
this.tree.setValue(v); |
this.tree.setValue(v); |
||||||
}, |
} |
||||||
|
|
||||||
populate: function (items) { |
populate(items) { |
||||||
this.tree.populate(items); |
this.tree.populate(items); |
||||||
} |
} |
||||||
}); |
} |
||||||
|
|
||||||
BI.MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM = "EVENT_ADD_ITEM"; |
|
||||||
BI.MultiLayerSelectTreeInsertSearchPane.EVENT_CHANGE = "EVENT_CHANGE"; |
|
||||||
BI.shortcut("bi.multilayer_select_tree_insert_search_pane", BI.MultiLayerSelectTreeInsertSearchPane); |
|
||||||
|
@ -1,77 +1,85 @@ |
|||||||
/** |
import { |
||||||
* Created by GUY on 2016/1/26. |
shortcut, |
||||||
* |
Widget, |
||||||
* @class BI.MultiLayerSelectTreePopup |
extend, |
||||||
* @extends BI.Pane |
i18nText, |
||||||
*/ |
emptyFn, |
||||||
|
createWidget, |
||||||
|
Controller, |
||||||
|
VerticalLayout, |
||||||
|
isArray |
||||||
|
} from "@/core"; |
||||||
|
import { MultiLayerSelectLevelTree } from "./multilayerselecttree.leveltree"; |
||||||
|
|
||||||
BI.MultiLayerSelectTreePopup = BI.inherit(BI.Widget, { |
@shortcut() |
||||||
|
export class MultiLayerSelectTreePopup extends Widget { |
||||||
|
static xtype = "bi.multilayer_select_tree_popup"; |
||||||
|
|
||||||
_defaultConfig: function () { |
static EVENT_CHANGE = "EVENT_CHANGE"; |
||||||
return BI.extend(BI.MultiLayerSelectTreePopup.superclass._defaultConfig.apply(this, arguments), { |
|
||||||
|
_defaultConfig() { |
||||||
|
return extend(super._defaultConfig(...arguments), { |
||||||
baseCls: "bi-multilayer-select-tree-popup", |
baseCls: "bi-multilayer-select-tree-popup", |
||||||
tipText: BI.i18nText("BI-No_Selected_Item"), |
tipText: i18nText("BI-No_Selected_Item"), |
||||||
isDefaultInit: false, |
isDefaultInit: false, |
||||||
itemsCreator: BI.emptyFn, |
itemsCreator: emptyFn, |
||||||
items: [], |
items: [], |
||||||
value: "", |
value: "", |
||||||
onLoaded: BI.emptyFn, |
onLoaded: emptyFn, |
||||||
minHeight: 240 |
minHeight: 240, |
||||||
}); |
}); |
||||||
}, |
} |
||||||
|
|
||||||
_init: function () { |
_init() { |
||||||
BI.MultiLayerSelectTreePopup.superclass._init.apply(this, arguments); |
super._init(...arguments); |
||||||
|
|
||||||
var self = this, o = this.options; |
const self = this, |
||||||
|
o = this.options; |
||||||
|
|
||||||
this.tree = BI.createWidget({ |
this.tree = createWidget({ |
||||||
type: "bi.multilayer_select_level_tree", |
type: MultiLayerSelectLevelTree.xtype, |
||||||
isDefaultInit: o.isDefaultInit, |
isDefaultInit: o.isDefaultInit, |
||||||
items: o.items, |
items: o.items, |
||||||
itemsCreator: o.itemsCreator, |
itemsCreator: o.itemsCreator, |
||||||
keywordGetter: o.keywordGetter, |
keywordGetter: o.keywordGetter, |
||||||
value: o.value, |
value: o.value, |
||||||
scrollable: null, |
scrollable: null, |
||||||
onLoaded: function () { |
onLoaded() { |
||||||
self.tree.check(); |
self.tree.check(); |
||||||
o.onLoaded(); |
o.onLoaded(); |
||||||
} |
}, |
||||||
}); |
}); |
||||||
|
|
||||||
BI.createWidget({ |
createWidget({ |
||||||
type: "bi.vertical", |
type: VerticalLayout.xtype, |
||||||
scrolly: false, |
scrolly: false, |
||||||
scrollable: true, |
scrollable: true, |
||||||
element: this, |
element: this, |
||||||
vgap: 5, |
vgap: 5, |
||||||
items: [this.tree] |
items: [this.tree], |
||||||
}); |
}); |
||||||
|
|
||||||
this.tree.on(BI.Controller.EVENT_CHANGE, function () { |
this.tree.on(Controller.EVENT_CHANGE, function () { |
||||||
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
self.fireEvent(Controller.EVENT_CHANGE, arguments); |
||||||
}); |
}); |
||||||
|
|
||||||
this.tree.on(BI.MultiLayerSelectLevelTree.EVENT_CHANGE, function () { |
this.tree.on(MultiLayerSelectLevelTree.EVENT_CHANGE, () => { |
||||||
self.fireEvent(BI.MultiLayerSelectTreePopup.EVENT_CHANGE); |
self.fireEvent(MultiLayerSelectTreePopup.EVENT_CHANGE); |
||||||
}); |
}); |
||||||
|
|
||||||
this.tree.css("min-height", BI.pixFormat(o.minHeight - 10)); |
this.tree.css("min-height", BI.pixFormat(o.minHeight - 10)); |
||||||
}, |
} |
||||||
|
|
||||||
getValue: function () { |
getValue() { |
||||||
return this.tree.getValue(); |
return this.tree.getValue(); |
||||||
}, |
} |
||||||
|
|
||||||
setValue: function (v) { |
setValue(v) { |
||||||
v = BI.isArray(v) ? v : [v]; |
v = isArray(v) ? v : [v]; |
||||||
this.tree.setValue(v); |
this.tree.setValue(v); |
||||||
}, |
} |
||||||
|
|
||||||
populate: function (items) { |
populate(items) { |
||||||
this.tree.populate(items); |
this.tree.populate(items); |
||||||
} |
} |
||||||
}); |
} |
||||||
|
|
||||||
BI.MultiLayerSelectTreePopup.EVENT_CHANGE = "EVENT_CHANGE"; |
|
||||||
BI.shortcut("bi.multilayer_select_tree_popup", BI.MultiLayerSelectTreePopup); |
|
||||||
|
@ -1,237 +1,301 @@ |
|||||||
/** |
import { |
||||||
* Created by Windy on 2018/2/2. |
shortcut, |
||||||
*/ |
emptyFn, |
||||||
BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { |
i18nText, |
||||||
|
isNotNull, |
||||||
|
isKey, |
||||||
|
HorizontalFillLayout, |
||||||
|
Tree, |
||||||
|
deepClone, |
||||||
|
Func, |
||||||
|
concat, |
||||||
|
isNotEmptyArray, |
||||||
|
each, |
||||||
|
uniqBy, |
||||||
|
map, |
||||||
|
isFunction, |
||||||
|
find |
||||||
|
} from "@/core"; |
||||||
|
import { Trigger, Searcher } from "@/base"; |
||||||
|
import { StateEditor, DefaultTextEditor } from "@/case"; |
||||||
|
import { MultiLayerSelectTreeInsertSearchPane } from "./multilayerselecttree.insert.search.pane"; |
||||||
|
import { MultiLayerSelectTreePopup } from "./multilayerselecttree.popup"; |
||||||
|
|
||||||
props: function () { |
@shortcut() |
||||||
|
export class MultiLayerSelectTreeTrigger extends Trigger { |
||||||
|
static xtype = "bi.multilayer_select_tree_trigger"; |
||||||
|
|
||||||
|
static EVENT_FOCUS = "EVENT_FOCUS"; |
||||||
|
static EVENT_BLUR = "EVENT_BLUR"; |
||||||
|
static EVENT_SEARCHING = "EVENT_SEARCHING"; |
||||||
|
static EVENT_STOP = "EVENT_STOP"; |
||||||
|
static EVENT_START = "EVENT_START"; |
||||||
|
static EVENT_CHANGE = "EVENT_CHANGE"; |
||||||
|
static EVENT_ADD_ITEM = "EVENT_ADD_ITEM"; |
||||||
|
|
||||||
|
props() { |
||||||
return { |
return { |
||||||
extraCls: "bi-multi-layer-select-tree-trigger", |
extraCls: "bi-multi-layer-select-tree-trigger", |
||||||
height: 24, |
height: 24, |
||||||
itemsCreator: BI.emptyFn, |
itemsCreator: emptyFn, |
||||||
watermark: BI.i18nText("BI-Basic_Search"), |
watermark: i18nText("BI-Basic_Search"), |
||||||
allowSearchValue: false, |
allowSearchValue: false, |
||||||
title: BI.bind(this._getShowText, this) |
title: () => this._getShowText(), |
||||||
}; |
}; |
||||||
}, |
} |
||||||
|
|
||||||
render: function () { |
render() { |
||||||
var self = this, o = this.options; |
const self = this, |
||||||
|
o = this.options; |
||||||
if (o.itemsCreator === BI.emptyFn) { |
if (o.itemsCreator === BI.emptyFn) { |
||||||
this._initData(); |
this._initData(); |
||||||
} |
} |
||||||
|
|
||||||
return { |
return { |
||||||
type: "bi.horizontal_fill", |
type: HorizontalFillLayout.xtype, |
||||||
items: [ |
items: [ |
||||||
{ |
{ |
||||||
el: { |
el: { |
||||||
type: "bi.searcher", |
type: Searcher.xtype, |
||||||
ref: function () { |
ref() { |
||||||
self.searcher = this; |
self.searcher = this; |
||||||
}, |
}, |
||||||
masker: BI.isNotNull(o.container) ? { |
masker: isNotNull(o.container) |
||||||
offset: {}, |
? { |
||||||
container: o.container |
offset: {}, |
||||||
} : { |
container: o.container, |
||||||
offset: {} |
} |
||||||
}, |
: { |
||||||
|
offset: {}, |
||||||
|
}, |
||||||
isAutoSearch: false, |
isAutoSearch: false, |
||||||
el: { |
el: { |
||||||
type: "bi.default_text_editor", |
type: DefaultTextEditor.xtype, |
||||||
ref: function () { |
ref() { |
||||||
self.editor = this; |
self.editor = this; |
||||||
}, |
}, |
||||||
defaultText: o.defaultText, |
defaultText: o.defaultText, |
||||||
text: BI.isKey(o.value) ? this._digest(o.value) : o.text, |
text: isKey(o.value) |
||||||
|
? this._digest(o.value) |
||||||
|
: o.text, |
||||||
value: o.value, |
value: o.value, |
||||||
height: o.height, |
height: o.height, |
||||||
tipText: "", |
tipText: "", |
||||||
watermark: o.watermark, |
watermark: o.watermark, |
||||||
listeners: [{ |
listeners: [ |
||||||
eventName: BI.StateEditor.EVENT_FOCUS, |
{ |
||||||
action: function () { |
eventName: StateEditor.EVENT_FOCUS, |
||||||
self.fireEvent(BI.MultiLayerSelectTreeTrigger.EVENT_FOCUS); |
action() { |
||||||
} |
self.fireEvent( |
||||||
}, { |
MultiLayerSelectTreeTrigger.EVENT_FOCUS |
||||||
eventName: BI.StateEditor.EVENT_BLUR, |
); |
||||||
action: function () { |
}, |
||||||
self.fireEvent(BI.MultiLayerSelectTreeTrigger.EVENT_BLUR); |
}, |
||||||
|
{ |
||||||
|
eventName: StateEditor.EVENT_BLUR, |
||||||
|
action() { |
||||||
|
self.fireEvent( |
||||||
|
MultiLayerSelectTreeTrigger.EVENT_BLUR |
||||||
|
); |
||||||
|
}, |
||||||
|
}, |
||||||
|
{ |
||||||
|
eventName: StateEditor.EVENT_CHANGE, |
||||||
|
action() { |
||||||
|
self.fireEvent( |
||||||
|
MultiLayerSelectTreeTrigger.EVENT_SEARCHING |
||||||
|
); |
||||||
|
}, |
||||||
} |
} |
||||||
}, { |
], |
||||||
eventName: BI.StateEditor.EVENT_CHANGE, |
|
||||||
action: function () { |
|
||||||
self.fireEvent(BI.MultiLayerSelectTreeTrigger.EVENT_SEARCHING); |
|
||||||
} |
|
||||||
}] |
|
||||||
}, |
}, |
||||||
popup: { |
popup: { |
||||||
type: o.allowInsertValue ? "bi.multilayer_select_tree_insert_search_pane" : "bi.multilayer_select_tree_popup", |
type: o.allowInsertValue |
||||||
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) { |
? MultiLayerSelectTreeInsertSearchPane.xtype |
||||||
op.keyword = self.editor.getValue(); |
: MultiLayerSelectTreePopup.xtype, |
||||||
o.itemsCreator(op, callback); |
itemsCreator: |
||||||
}, |
o.itemsCreator === emptyFn |
||||||
keywordGetter: function () { |
? emptyFn |
||||||
|
: function (op, callback) { |
||||||
|
op.keyword = self.editor.getValue(); |
||||||
|
o.itemsCreator(op, callback); |
||||||
|
}, |
||||||
|
keywordGetter() { |
||||||
return self.editor.getValue(); |
return self.editor.getValue(); |
||||||
}, |
}, |
||||||
cls: "bi-card", |
cls: "bi-card", |
||||||
listeners: [{ |
listeners: [ |
||||||
eventName: BI.MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM, |
{ |
||||||
action: function () { |
eventName: |
||||||
self.options.text = self.getSearcher().getKeyword(); |
MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM, |
||||||
self.fireEvent(BI.MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM); |
action() { |
||||||
|
self.options.text = self |
||||||
|
.getSearcher() |
||||||
|
.getKeyword(); |
||||||
|
self.fireEvent( |
||||||
|
MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM |
||||||
|
); |
||||||
|
}, |
||||||
} |
} |
||||||
}], |
], |
||||||
ref: function (_ref) { |
ref(_ref) { |
||||||
self.popup = _ref; |
self.popup = _ref; |
||||||
} |
}, |
||||||
}, |
}, |
||||||
onSearch: function (obj, callback) { |
onSearch(obj, callback) { |
||||||
var keyword = obj.keyword; |
const keyword = obj.keyword; |
||||||
if (o.itemsCreator === BI.emptyFn) { |
if (o.itemsCreator === BI.emptyFn) { |
||||||
callback(self._getSearchItems(keyword)); |
callback(self._getSearchItems(keyword)); |
||||||
o.allowInsertValue && self.popup.setKeyword(keyword); |
o.allowInsertValue && |
||||||
|
self.popup.setKeyword(keyword); |
||||||
} else { |
} else { |
||||||
callback(); |
callback(); |
||||||
} |
} |
||||||
}, |
}, |
||||||
listeners: [{ |
listeners: [ |
||||||
eventName: BI.Searcher.EVENT_CHANGE, |
{ |
||||||
action: function () { |
eventName: Searcher.EVENT_CHANGE, |
||||||
self.fireEvent(BI.MultiLayerSelectTreeTrigger.EVENT_CHANGE); |
action() { |
||||||
|
self.fireEvent( |
||||||
|
MultiLayerSelectTreeTrigger.EVENT_CHANGE |
||||||
|
); |
||||||
|
}, |
||||||
} |
} |
||||||
}] |
], |
||||||
}, |
}, |
||||||
width: "fill", |
width: "fill", |
||||||
rgap: 24 |
rgap: 24, |
||||||
}, |
} |
||||||
] |
], |
||||||
}; |
}; |
||||||
}, |
} |
||||||
|
|
||||||
_initData: function () { |
_initData() { |
||||||
var o = this.options; |
const o = this.options; |
||||||
this.tree = new BI.Tree(); |
this.tree = new Tree(); |
||||||
this.nodes = BI.Tree.treeFormat(BI.deepClone(o.items)); |
this.nodes = Tree.treeFormat(deepClone(o.items)); |
||||||
this.tree.initTree(this.nodes); |
this.tree.initTree(this.nodes); |
||||||
}, |
} |
||||||
|
|
||||||
_getSearchItems: function (keyword) { |
_getSearchItems(keyword) { |
||||||
var self = this, o = this.options; |
const self = this, |
||||||
|
o = this.options; |
||||||
// 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索
|
// 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索
|
||||||
var items = []; |
const items = []; |
||||||
this.tree.traverse(function (node) { |
this.tree.traverse(node => { |
||||||
var find = BI.Func.getSearchResult(self.tree.isRoot(node) ? [] : BI.concat([node.text], (o.allowSearchValue ? [node.value] : [])), keyword); |
const find = Func.getSearchResult( |
||||||
|
self.tree.isRoot(node) |
||||||
|
? [] |
||||||
|
: concat( |
||||||
|
[node.text], |
||||||
|
o.allowSearchValue ? [node.value] : [] |
||||||
|
), |
||||||
|
keyword |
||||||
|
); |
||||||
if (find.find.length > 0 || find.match.length > 0) { |
if (find.find.length > 0 || find.match.length > 0) { |
||||||
items.push(node); |
items.push(node); |
||||||
|
|
||||||
return true; |
return true; |
||||||
} |
} |
||||||
}); |
}); |
||||||
|
|
||||||
return this._fillTreeStructure4Search(items, "id"); |
return this._fillTreeStructure4Search(items, "id"); |
||||||
}, |
} |
||||||
|
|
||||||
_createJson: function (node, open) { |
_createJson(node, open) { |
||||||
return { |
return { |
||||||
id: node.id, |
id: node.id, |
||||||
pId: node.pId, |
pId: node.pId, |
||||||
text: node.text, |
text: node.text, |
||||||
value: node.value, |
value: node.value, |
||||||
isParent: BI.isNotEmptyArray(node.children), |
isParent: isNotEmptyArray(node.children), |
||||||
open: open |
open, |
||||||
}; |
}; |
||||||
}, |
} |
||||||
|
|
||||||
_getChildren: function (node) { |
_getChildren(node) { |
||||||
var self = this; |
const self = this; |
||||||
node.children = node.children || []; |
node.children = node.children || []; |
||||||
var nodes = []; |
let nodes = []; |
||||||
BI.each(node.children, function (idx, child) { |
each(node.children, (idx, child) => { |
||||||
var children = self._getChildren(child); |
const children = self._getChildren(child); |
||||||
nodes = nodes.concat(children); |
nodes = nodes.concat(children); |
||||||
}); |
}); |
||||||
|
|
||||||
return node.children.concat(nodes); |
return node.children.concat(nodes); |
||||||
}, |
} |
||||||
|
|
||||||
// 将搜索到的节点进行补充,构造成一棵完整的树
|
_fillTreeStructure4Search(leaves) { |
||||||
_fillTreeStructure4Search: function (leaves) { |
const self = this; |
||||||
var self = this; |
let result = []; |
||||||
var result = []; |
const queue = []; |
||||||
var queue = []; |
each(leaves, (idx, node) => { |
||||||
BI.each(leaves, function (idx, node) { |
|
||||||
queue.push({ pId: node.pId }); |
queue.push({ pId: node.pId }); |
||||||
result.push(node); |
result.push(node); |
||||||
result = result.concat(self._getChildren(node)); |
result = result.concat(self._getChildren(node)); |
||||||
}); |
}); |
||||||
queue.reverse(); |
queue.reverse(); |
||||||
while (BI.isNotEmptyArray(queue)) { |
while (isNotEmptyArray(queue)) { |
||||||
var node = queue.pop(); |
const node = queue.pop(); |
||||||
var pNode = this.tree.search(this.tree.getRoot(), node.pId, "id"); |
const pNode = this.tree.search(this.tree.getRoot(), node.pId, "id"); |
||||||
if (pNode != null) { |
if (pNode != null) { |
||||||
pNode.open = true; |
pNode.open = true; |
||||||
queue.push({ pId: pNode.pId }); |
queue.push({ pId: pNode.pId }); |
||||||
result.push(pNode); |
result.push(pNode); |
||||||
} |
} |
||||||
} |
} |
||||||
return BI.uniqBy(BI.map(result, function (idx, node) { |
|
||||||
return self._createJson(node, node.open); |
return uniqBy( |
||||||
}), "id"); |
map(result, (idx, node) => self._createJson(node, node.open)), |
||||||
}, |
"id" |
||||||
|
); |
||||||
_digest: function (v) { |
} |
||||||
var o = this.options; |
|
||||||
if (BI.isFunction(o.valueFormatter)) { |
_digest(v) { |
||||||
|
const o = this.options; |
||||||
|
if (isFunction(o.valueFormatter)) { |
||||||
return o.valueFormatter(v); |
return o.valueFormatter(v); |
||||||
} |
} |
||||||
|
|
||||||
var result = BI.find(o.items, function (i, item) { |
const result = find(o.items, (i, item) => item.value === v); |
||||||
return item.value === v; |
|
||||||
}); |
|
||||||
|
|
||||||
return BI.isNotNull(result) ? result.text : (o.text ?? v); |
return isNotNull(result) ? result.text : o.text ?? v; |
||||||
}, |
} |
||||||
|
|
||||||
_getShowText: function () { |
_getShowText() { |
||||||
return this.editor.getText(); |
return this.editor.getText(); |
||||||
}, |
} |
||||||
|
|
||||||
stopEditing: function () { |
stopEditing() { |
||||||
this.searcher.stopSearch(); |
this.searcher.stopSearch(); |
||||||
}, |
} |
||||||
|
|
||||||
getSearcher: function () { |
getSearcher() { |
||||||
return this.searcher; |
return this.searcher; |
||||||
}, |
} |
||||||
|
|
||||||
populate: function (items) { |
populate(items) { |
||||||
this.options.items = items; |
this.options.items = items; |
||||||
this._initData(items); |
this._initData(items); |
||||||
}, |
} |
||||||
|
|
||||||
setValue: function (v) { |
setValue(v) { |
||||||
this.editor.setState(this._digest(v[0])); |
this.editor.setState(this._digest(v[0])); |
||||||
}, |
} |
||||||
|
|
||||||
getValue: function () { |
getValue() { |
||||||
return this.searcher.getValue(); |
return this.searcher.getValue(); |
||||||
}, |
} |
||||||
|
|
||||||
focus: function () { |
focus() { |
||||||
this.searcher.focus(); |
this.searcher.focus(); |
||||||
}, |
} |
||||||
|
|
||||||
blur: function () { |
blur() { |
||||||
this.searcher.blur(); |
this.searcher.blur(); |
||||||
}, |
} |
||||||
|
|
||||||
setWaterMark: function (v) { |
setWaterMark(v) { |
||||||
this.searcher.setWaterMark(v); |
this.searcher.setWaterMark(v); |
||||||
} |
} |
||||||
}); |
} |
||||||
|
|
||||||
BI.MultiLayerSelectTreeTrigger.EVENT_FOCUS = "EVENT_FOCUS"; |
|
||||||
BI.MultiLayerSelectTreeTrigger.EVENT_BLUR = "EVENT_BLUR"; |
|
||||||
BI.MultiLayerSelectTreeTrigger.EVENT_SEARCHING = "EVENT_SEARCHING"; |
|
||||||
BI.MultiLayerSelectTreeTrigger.EVENT_STOP = "EVENT_STOP"; |
|
||||||
BI.MultiLayerSelectTreeTrigger.EVENT_START = "EVENT_START"; |
|
||||||
BI.MultiLayerSelectTreeTrigger.EVENT_CHANGE = "EVENT_CHANGE"; |
|
||||||
BI.MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM = "EVENT_ADD_ITEM"; |
|
||||||
BI.shortcut("bi.multilayer_select_tree_trigger", BI.MultiLayerSelectTreeTrigger); |
|
||||||
|
@ -1,99 +0,0 @@ |
|||||||
/** |
|
||||||
* 加号表示的组节点 |
|
||||||
* |
|
||||||
* Created by GUY on 2016/1/27. |
|
||||||
* @class BI.MultiLayerSelectTreeFirstPlusGroupNode |
|
||||||
* @extends BI.NodeButton |
|
||||||
*/ |
|
||||||
BI.MultiLayerSelectTreeFirstPlusGroupNode = BI.inherit(BI.NodeButton, { |
|
||||||
_defaultConfig: function () { |
|
||||||
var conf = BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass._defaultConfig.apply(this, arguments); |
|
||||||
return BI.extend(conf, { |
|
||||||
extraCls: "bi-multilayer-select-tree-first-plus-group-node bi-list-item-active", |
|
||||||
layer: 0, // 第几层级
|
|
||||||
id: "", |
|
||||||
pId: "", |
|
||||||
readonly: true, |
|
||||||
open: false, |
|
||||||
height: 24 |
|
||||||
}); |
|
||||||
}, |
|
||||||
_init: function () { |
|
||||||
BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass._init.apply(this, arguments); |
|
||||||
var self = this, o = this.options; |
|
||||||
this.node = BI.createWidget({ |
|
||||||
type: "bi.select_tree_first_plus_group_node", |
|
||||||
cls: "bi-list-item-none", |
|
||||||
stopPropagation: true, |
|
||||||
logic: { |
|
||||||
dynamic: true |
|
||||||
}, |
|
||||||
id: o.id, |
|
||||||
pId: o.pId, |
|
||||||
keyword: o.keyword, |
|
||||||
open: o.open, |
|
||||||
height: o.height, |
|
||||||
hgap: o.hgap, |
|
||||||
text: o.text, |
|
||||||
value: o.value, |
|
||||||
py: o.py |
|
||||||
}); |
|
||||||
this.node.on(BI.Controller.EVENT_CHANGE, function (type) { |
|
||||||
self.setSelected(self.isSelected()); |
|
||||||
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
|
||||||
}); |
|
||||||
|
|
||||||
var items = []; |
|
||||||
// BI.count(0, o.layer, function (index) {
|
|
||||||
// items.push({
|
|
||||||
// type: "bi.layout",
|
|
||||||
// cls: BI.contains(needBlankLayers, index) ? "" : "base-line-conn-background",
|
|
||||||
// width: 12,
|
|
||||||
// height: o.height
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
items.push({ |
|
||||||
el: this.node, |
|
||||||
lgap: o.layer * BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2 |
|
||||||
}); |
|
||||||
BI.createWidget({ |
|
||||||
type: "bi.horizontal_adapt", |
|
||||||
element: this, |
|
||||||
columnSize: BI.makeArray(o.layer, BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2), |
|
||||||
items: items |
|
||||||
}); |
|
||||||
}, |
|
||||||
|
|
||||||
isOnce: function () { |
|
||||||
return true; |
|
||||||
}, |
|
||||||
|
|
||||||
doRedMark: function () { |
|
||||||
this.node.doRedMark.apply(this.node, arguments); |
|
||||||
}, |
|
||||||
|
|
||||||
unRedMark: function () { |
|
||||||
this.node.unRedMark.apply(this.node, arguments); |
|
||||||
}, |
|
||||||
|
|
||||||
isSelected: function () { |
|
||||||
return this.node.isSelected(); |
|
||||||
}, |
|
||||||
|
|
||||||
setSelected: function (b) { |
|
||||||
BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass.setSelected.apply(this, arguments); |
|
||||||
this.node.setSelected(b); |
|
||||||
}, |
|
||||||
|
|
||||||
doClick: function () { |
|
||||||
BI.NodeButton.superclass.doClick.apply(this, arguments); |
|
||||||
this.node.setSelected(this.isSelected()); |
|
||||||
}, |
|
||||||
|
|
||||||
setOpened: function (v) { |
|
||||||
BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass.setOpened.apply(this, arguments); |
|
||||||
this.node.setOpened(v); |
|
||||||
} |
|
||||||
}); |
|
||||||
|
|
||||||
BI.shortcut("bi.multilayer_select_tree_first_plus_group_node", BI.MultiLayerSelectTreeFirstPlusGroupNode); |
|
@ -1,88 +0,0 @@ |
|||||||
/** |
|
||||||
* 加号表示的组节点 |
|
||||||
* |
|
||||||
* Created by GUY on 2016/1/27. |
|
||||||
* @class BI.MultiLayerSelectTreeLastPlusGroupNode |
|
||||||
* @extends BI.NodeButton |
|
||||||
*/ |
|
||||||
BI.MultiLayerSelectTreeLastPlusGroupNode = BI.inherit(BI.NodeButton, { |
|
||||||
_defaultConfig: function () { |
|
||||||
var conf = BI.MultiLayerSelectTreeLastPlusGroupNode.superclass._defaultConfig.apply(this, arguments); |
|
||||||
return BI.extend(conf, { |
|
||||||
extraCls: "bi-multilayer-select-tree-last-plus-group-node bi-list-item-active", |
|
||||||
layer: 0, // 第几层级
|
|
||||||
id: "", |
|
||||||
pId: "", |
|
||||||
readonly: true, |
|
||||||
open: false, |
|
||||||
height: 24 |
|
||||||
}); |
|
||||||
}, |
|
||||||
_init: function () { |
|
||||||
BI.MultiLayerSelectTreeLastPlusGroupNode.superclass._init.apply(this, arguments); |
|
||||||
var self = this, o = this.options; |
|
||||||
this.node = BI.createWidget({ |
|
||||||
type: "bi.select_tree_last_plus_group_node", |
|
||||||
cls: "bi-list-item-none", |
|
||||||
stopPropagation: true, |
|
||||||
logic: { |
|
||||||
dynamic: true |
|
||||||
}, |
|
||||||
id: o.id, |
|
||||||
pId: o.pId, |
|
||||||
keyword: o.keyword, |
|
||||||
open: o.open, |
|
||||||
height: o.height, |
|
||||||
hgap: o.hgap, |
|
||||||
text: o.text, |
|
||||||
value: o.value, |
|
||||||
py: o.py |
|
||||||
}); |
|
||||||
this.node.on(BI.Controller.EVENT_CHANGE, function (type) { |
|
||||||
self.setSelected(self.isSelected()); |
|
||||||
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
|
||||||
}); |
|
||||||
|
|
||||||
var items = []; |
|
||||||
|
|
||||||
items.push({ |
|
||||||
el: this.node, |
|
||||||
lgap: o.layer * BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2 |
|
||||||
}); |
|
||||||
BI.createWidget({ |
|
||||||
type: "bi.horizontal_adapt", |
|
||||||
element: this, |
|
||||||
columnSize: BI.makeArray(o.layer, BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2), |
|
||||||
items: items |
|
||||||
}); |
|
||||||
}, |
|
||||||
|
|
||||||
doRedMark: function () { |
|
||||||
this.node.doRedMark.apply(this.node, arguments); |
|
||||||
}, |
|
||||||
|
|
||||||
unRedMark: function () { |
|
||||||
this.node.unRedMark.apply(this.node, arguments); |
|
||||||
}, |
|
||||||
|
|
||||||
isSelected: function () { |
|
||||||
return this.node.isSelected(); |
|
||||||
}, |
|
||||||
|
|
||||||
setSelected: function (b) { |
|
||||||
BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.setSelected.apply(this, arguments); |
|
||||||
this.node.setSelected(b); |
|
||||||
}, |
|
||||||
|
|
||||||
doClick: function () { |
|
||||||
BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.doClick.apply(this, arguments); |
|
||||||
this.node.setSelected(this.isSelected()); |
|
||||||
}, |
|
||||||
|
|
||||||
setOpened: function (v) { |
|
||||||
BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.setOpened.apply(this, arguments); |
|
||||||
this.node.setOpened(v); |
|
||||||
} |
|
||||||
}); |
|
||||||
|
|
||||||
BI.shortcut("bi.multilayer_select_tree_last_plus_group_node", BI.MultiLayerSelectTreeLastPlusGroupNode); |
|
@ -1,88 +0,0 @@ |
|||||||
/** |
|
||||||
* 加号表示的组节点 |
|
||||||
* |
|
||||||
* Created by GUY on 2016/1/27. |
|
||||||
* @class BI.MultiLayerSelectTreeMidPlusGroupNode |
|
||||||
* @extends BI.NodeButton |
|
||||||
*/ |
|
||||||
BI.MultiLayerSelectTreeMidPlusGroupNode = BI.inherit(BI.NodeButton, { |
|
||||||
_defaultConfig: function () { |
|
||||||
var conf = BI.MultiLayerSelectTreeMidPlusGroupNode.superclass._defaultConfig.apply(this, arguments); |
|
||||||
return BI.extend(conf, { |
|
||||||
extraCls: "bi-multilayer-select-tree-mid-plus-group-node bi-list-item-active", |
|
||||||
layer: 0, // 第几层级
|
|
||||||
id: "", |
|
||||||
pId: "", |
|
||||||
readonly: true, |
|
||||||
open: false, |
|
||||||
height: 24 |
|
||||||
}); |
|
||||||
}, |
|
||||||
_init: function () { |
|
||||||
BI.MultiLayerSelectTreeMidPlusGroupNode.superclass._init.apply(this, arguments); |
|
||||||
var self = this, o = this.options; |
|
||||||
this.node = BI.createWidget({ |
|
||||||
type: "bi.select_tree_mid_plus_group_node", |
|
||||||
cls: "bi-list-item-none", |
|
||||||
stopPropagation: true, |
|
||||||
logic: { |
|
||||||
dynamic: true |
|
||||||
}, |
|
||||||
id: o.id, |
|
||||||
pId: o.pId, |
|
||||||
keyword: o.keyword, |
|
||||||
open: o.open, |
|
||||||
height: o.height, |
|
||||||
hgap: o.hgap, |
|
||||||
text: o.text, |
|
||||||
value: o.value, |
|
||||||
py: o.py |
|
||||||
}); |
|
||||||
this.node.on(BI.Controller.EVENT_CHANGE, function (type) { |
|
||||||
self.setSelected(self.isSelected()); |
|
||||||
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
|
||||||
}); |
|
||||||
|
|
||||||
var items = []; |
|
||||||
|
|
||||||
items.push({ |
|
||||||
el: this.node, |
|
||||||
lgap: o.layer * BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2 |
|
||||||
}); |
|
||||||
BI.createWidget({ |
|
||||||
type: "bi.horizontal_adapt", |
|
||||||
element: this, |
|
||||||
columnSize: BI.makeArray(o.layer, BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2), |
|
||||||
items: items |
|
||||||
}); |
|
||||||
}, |
|
||||||
|
|
||||||
doRedMark: function () { |
|
||||||
this.node.doRedMark.apply(this.node, arguments); |
|
||||||
}, |
|
||||||
|
|
||||||
unRedMark: function () { |
|
||||||
this.node.unRedMark.apply(this.node, arguments); |
|
||||||
}, |
|
||||||
|
|
||||||
isSelected: function () { |
|
||||||
return this.node.isSelected(); |
|
||||||
}, |
|
||||||
|
|
||||||
setSelected: function (b) { |
|
||||||
BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.setSelected.apply(this, arguments); |
|
||||||
this.node.setSelected(b); |
|
||||||
}, |
|
||||||
|
|
||||||
doClick: function () { |
|
||||||
BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.doClick.apply(this, arguments); |
|
||||||
this.node.setSelected(this.isSelected()); |
|
||||||
}, |
|
||||||
|
|
||||||
setOpened: function (v) { |
|
||||||
BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.setOpened.apply(this, arguments); |
|
||||||
this.node.setOpened(v); |
|
||||||
} |
|
||||||
}); |
|
||||||
|
|
||||||
BI.shortcut("bi.multilayer_select_tree_mid_plus_group_node", BI.MultiLayerSelectTreeMidPlusGroupNode); |
|
@ -1,92 +0,0 @@ |
|||||||
/** |
|
||||||
* 加号表示的组节点 |
|
||||||
* |
|
||||||
* Created by GUY on 2016/1/27. |
|
||||||
* @class BI.MultiLayerSelectTreePlusGroupNode |
|
||||||
* @extends BI.NodeButton |
|
||||||
*/ |
|
||||||
BI.MultiLayerSelectTreePlusGroupNode = BI.inherit(BI.NodeButton, { |
|
||||||
_defaultConfig: function () { |
|
||||||
var conf = BI.MultiLayerSelectTreePlusGroupNode.superclass._defaultConfig.apply(this, arguments); |
|
||||||
return BI.extend(conf, { |
|
||||||
extraCls: "bi-multilayer-select-tree-first-plus-group-node bi-list-item-active", |
|
||||||
layer: 0, // 第几层级
|
|
||||||
id: "", |
|
||||||
pId: "", |
|
||||||
readonly: true, |
|
||||||
open: false, |
|
||||||
height: 24 |
|
||||||
}); |
|
||||||
}, |
|
||||||
_init: function () { |
|
||||||
BI.MultiLayerSelectTreePlusGroupNode.superclass._init.apply(this, arguments); |
|
||||||
var self = this, o = this.options; |
|
||||||
this.node = BI.createWidget({ |
|
||||||
type: "bi.select_tree_plus_group_node", |
|
||||||
cls: "bi-list-item-none", |
|
||||||
stopPropagation: true, |
|
||||||
logic: { |
|
||||||
dynamic: true |
|
||||||
}, |
|
||||||
id: o.id, |
|
||||||
pId: o.pId, |
|
||||||
keyword: o.keyword, |
|
||||||
open: o.open, |
|
||||||
height: o.height, |
|
||||||
hgap: o.hgap, |
|
||||||
text: o.text, |
|
||||||
value: o.value, |
|
||||||
py: o.py |
|
||||||
}); |
|
||||||
this.node.on(BI.Controller.EVENT_CHANGE, function (type) { |
|
||||||
self.setSelected(self.isSelected()); |
|
||||||
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
|
||||||
}); |
|
||||||
|
|
||||||
var items = []; |
|
||||||
|
|
||||||
items.push({ |
|
||||||
el: this.node, |
|
||||||
lgap: o.layer * BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2 |
|
||||||
}); |
|
||||||
BI.createWidget({ |
|
||||||
type: "bi.horizontal_adapt", |
|
||||||
element: this, |
|
||||||
columnSize: BI.makeArray(o.layer, BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2), |
|
||||||
items: items |
|
||||||
}); |
|
||||||
}, |
|
||||||
|
|
||||||
isOnce: function () { |
|
||||||
return true; |
|
||||||
}, |
|
||||||
|
|
||||||
doRedMark: function () { |
|
||||||
this.node.doRedMark.apply(this.node, arguments); |
|
||||||
}, |
|
||||||
|
|
||||||
unRedMark: function () { |
|
||||||
this.node.unRedMark.apply(this.node, arguments); |
|
||||||
}, |
|
||||||
|
|
||||||
isSelected: function () { |
|
||||||
return this.node.isSelected(); |
|
||||||
}, |
|
||||||
|
|
||||||
setSelected: function (b) { |
|
||||||
BI.MultiLayerSelectTreePlusGroupNode.superclass.setSelected.apply(this, arguments); |
|
||||||
this.node.setSelected(b); |
|
||||||
}, |
|
||||||
|
|
||||||
doClick: function () { |
|
||||||
BI.NodeButton.superclass.doClick.apply(this, arguments); |
|
||||||
this.node.setSelected(this.isSelected()); |
|
||||||
}, |
|
||||||
|
|
||||||
setOpened: function (v) { |
|
||||||
BI.MultiLayerSelectTreePlusGroupNode.superclass.setOpened.apply(this, arguments); |
|
||||||
this.node.setOpened(v); |
|
||||||
} |
|
||||||
}); |
|
||||||
|
|
||||||
BI.shortcut("bi.multilayer_select_tree_plus_group_node", BI.MultiLayerSelectTreePlusGroupNode); |
|
@ -1,4 +0,0 @@ |
|||||||
export { MultiLayerSingleTreeFirstPlusGroupNode } from "./node.first.plus"; |
|
||||||
export { MultiLayerSingleTreeLastPlusGroupNode } from "./node.last.plus"; |
|
||||||
export { MultiLayerSingleTreeMidPlusGroupNode } from "./node.mid.plus"; |
|
||||||
export { MultiLayerSingleTreePlusGroupNode } from "./node.plus"; |
|
@ -1,104 +0,0 @@ |
|||||||
import { |
|
||||||
shortcut, |
|
||||||
extend, |
|
||||||
createWidget, |
|
||||||
makeArray, |
|
||||||
HorizontalAdaptLayout, |
|
||||||
isNotNull, |
|
||||||
Controller, |
|
||||||
Events |
|
||||||
} from "@/core"; |
|
||||||
import { NodeButton } from "@/base"; |
|
||||||
import { FirstPlusGroupNode } from "@/case"; |
|
||||||
|
|
||||||
@shortcut() |
|
||||||
export class MultiLayerSingleTreeFirstPlusGroupNode extends NodeButton { |
|
||||||
static xtype = "bi.multilayer_single_tree_first_plus_group_node"; |
|
||||||
|
|
||||||
_defaultConfig() { |
|
||||||
const conf = super._defaultConfig(...arguments); |
|
||||||
|
|
||||||
return extend(conf, { |
|
||||||
extraCls: "bi-multilayer-single-tree-first-plus-group-node bi-list-item", |
|
||||||
layer: 0, // 第几层级
|
|
||||||
id: "", |
|
||||||
pId: "", |
|
||||||
open: false, |
|
||||||
height: 24, |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
_init() { |
|
||||||
super._init(...arguments); |
|
||||||
const o = this.options; |
|
||||||
this.node = this._createNode(); |
|
||||||
|
|
||||||
const items = []; |
|
||||||
|
|
||||||
items.push({ |
|
||||||
el: this.node, |
|
||||||
lgap: (o.layer * BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT) / 2, |
|
||||||
}); |
|
||||||
createWidget({ |
|
||||||
type: HorizontalAdaptLayout.xtype, |
|
||||||
element: this, |
|
||||||
columnSize: makeArray(o.layer, BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2), |
|
||||||
items, |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
doRedMark() { |
|
||||||
this.node.doRedMark(...arguments); |
|
||||||
} |
|
||||||
|
|
||||||
unRedMark() { |
|
||||||
this.node.unRedMark(...arguments); |
|
||||||
} |
|
||||||
|
|
||||||
doClick() { |
|
||||||
super.doClick(...arguments); |
|
||||||
this.node.setSelected(this.isSelected()); |
|
||||||
} |
|
||||||
|
|
||||||
setOpened(v) { |
|
||||||
super.setOpened(...arguments); |
|
||||||
if (isNotNull(this.node)) { |
|
||||||
this.node.setOpened(v); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
_createNode() { |
|
||||||
const o = this.options; |
|
||||||
|
|
||||||
return createWidget({ |
|
||||||
type: FirstPlusGroupNode.xtype, |
|
||||||
cls: "bi-list-item-none", |
|
||||||
logic: { |
|
||||||
dynamic: true, |
|
||||||
}, |
|
||||||
id: o.id, |
|
||||||
pId: o.pId, |
|
||||||
open: o.open, |
|
||||||
isLastNode: o.isLastNode, |
|
||||||
height: o.height, |
|
||||||
hgap: o.hgap, |
|
||||||
text: o.text, |
|
||||||
value: o.value, |
|
||||||
py: o.py, |
|
||||||
keyword: o.keyword, |
|
||||||
listeners: [ |
|
||||||
{ |
|
||||||
eventName: Controller.EVENT_CHANGE, |
|
||||||
action: (...args) => { |
|
||||||
const [type] = args; |
|
||||||
if (type === Events.CLICK) { |
|
||||||
// 本身实现click功能
|
|
||||||
return; |
|
||||||
} |
|
||||||
this.fireEvent(Controller.EVENT_CHANGE, ...args); |
|
||||||
}, |
|
||||||
} |
|
||||||
], |
|
||||||
}); |
|
||||||
} |
|
||||||
} |
|
@ -1,103 +0,0 @@ |
|||||||
import { |
|
||||||
shortcut, |
|
||||||
extend, |
|
||||||
createWidget, |
|
||||||
makeArray, |
|
||||||
HorizontalAdaptLayout, |
|
||||||
isNotNull, |
|
||||||
Controller, |
|
||||||
Events |
|
||||||
} from "@/core"; |
|
||||||
import { NodeButton } from "@/base"; |
|
||||||
import { LastPlusGroupNode } from "@/case"; |
|
||||||
|
|
||||||
@shortcut() |
|
||||||
export class MultiLayerSingleTreeLastPlusGroupNode extends NodeButton { |
|
||||||
static xtype = "bi.multilayer_single_tree_last_plus_group_node"; |
|
||||||
|
|
||||||
_defaultConfig() { |
|
||||||
const conf = super._defaultConfig(...arguments); |
|
||||||
|
|
||||||
return extend(conf, { |
|
||||||
extraCls: "bi-multilayer-single-tree-last-plus-group-node bi-list-item", |
|
||||||
layer: 0, // 第几层级
|
|
||||||
id: "", |
|
||||||
pId: "", |
|
||||||
open: false, |
|
||||||
height: 24, |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
_init() { |
|
||||||
super._init(...arguments); |
|
||||||
const o = this.options; |
|
||||||
this.node = this._createNode(); |
|
||||||
|
|
||||||
const items = []; |
|
||||||
|
|
||||||
items.push({ |
|
||||||
el: this.node, |
|
||||||
lgap: (o.layer * BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT) / 2, |
|
||||||
}); |
|
||||||
createWidget({ |
|
||||||
type: HorizontalAdaptLayout.xtype, |
|
||||||
element: this, |
|
||||||
columnSize: makeArray(o.layer, BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2), |
|
||||||
items, |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
doRedMark() { |
|
||||||
this.node.doRedMark(...arguments); |
|
||||||
} |
|
||||||
|
|
||||||
unRedMark() { |
|
||||||
this.node.unRedMark(...arguments); |
|
||||||
} |
|
||||||
|
|
||||||
doClick() { |
|
||||||
super.doClick(...arguments); |
|
||||||
this.node.setSelected(this.isSelected()); |
|
||||||
} |
|
||||||
|
|
||||||
setOpened(v) { |
|
||||||
super.setOpened(...arguments); |
|
||||||
if (isNotNull(this.node)) { |
|
||||||
this.node.setOpened(v); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
_createNode() { |
|
||||||
const o = this.options; |
|
||||||
|
|
||||||
return createWidget({ |
|
||||||
type: LastPlusGroupNode.xtype, |
|
||||||
cls: "bi-list-item-none", |
|
||||||
logic: { |
|
||||||
dynamic: true, |
|
||||||
}, |
|
||||||
id: o.id, |
|
||||||
pId: o.pId, |
|
||||||
open: o.open, |
|
||||||
height: o.height, |
|
||||||
hgap: o.hgap, |
|
||||||
text: o.text, |
|
||||||
value: o.value, |
|
||||||
py: o.py, |
|
||||||
keyword: o.keyword, |
|
||||||
listeners: [ |
|
||||||
{ |
|
||||||
eventName: Controller.EVENT_CHANGE, |
|
||||||
action: (...args) => { |
|
||||||
const [type] = args; |
|
||||||
if (type === Events.CLICK) { |
|
||||||
// 本身实现click功能
|
|
||||||
return; |
|
||||||
} |
|
||||||
this.fireEvent(Controller.EVENT_CHANGE, ...args); |
|
||||||
}, |
|
||||||
} |
|
||||||
], |
|
||||||
}); |
|
||||||
} |
|
||||||
} |
|
@ -1,103 +0,0 @@ |
|||||||
import { |
|
||||||
shortcut, |
|
||||||
extend, |
|
||||||
createWidget, |
|
||||||
makeArray, |
|
||||||
HorizontalAdaptLayout, |
|
||||||
isNotNull, |
|
||||||
Controller, |
|
||||||
Events |
|
||||||
} from "@/core"; |
|
||||||
import { NodeButton } from "@/base"; |
|
||||||
import { MidPlusGroupNode } from "@/case"; |
|
||||||
|
|
||||||
@shortcut() |
|
||||||
export class MultiLayerSingleTreeMidPlusGroupNode extends NodeButton { |
|
||||||
static xtype = "bi.multilayer_single_tree_mid_plus_group_node"; |
|
||||||
|
|
||||||
_defaultConfig() { |
|
||||||
const conf = super._defaultConfig(...arguments); |
|
||||||
|
|
||||||
return extend(conf, { |
|
||||||
extraCls: "bi-multilayer-single-tree-mid-plus-group-node bi-list-item", |
|
||||||
layer: 0, // 第几层级
|
|
||||||
id: "", |
|
||||||
pId: "", |
|
||||||
open: false, |
|
||||||
height: 24, |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
_init() { |
|
||||||
super._init(...arguments); |
|
||||||
const o = this.options; |
|
||||||
this.node = this._createNode(); |
|
||||||
|
|
||||||
const items = []; |
|
||||||
|
|
||||||
items.push({ |
|
||||||
el: this.node, |
|
||||||
lgap: (o.layer * BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT) / 2, |
|
||||||
}); |
|
||||||
createWidget({ |
|
||||||
type: HorizontalAdaptLayout.xtype, |
|
||||||
element: this, |
|
||||||
columnSize: makeArray(o.layer, 12), |
|
||||||
items, |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
doRedMark() { |
|
||||||
this.node.doRedMark(...arguments); |
|
||||||
} |
|
||||||
|
|
||||||
unRedMark() { |
|
||||||
this.node.unRedMark(...arguments); |
|
||||||
} |
|
||||||
|
|
||||||
doClick() { |
|
||||||
super.doClick(...arguments); |
|
||||||
this.node.setSelected(this.isSelected()); |
|
||||||
} |
|
||||||
|
|
||||||
setOpened(v) { |
|
||||||
super.setOpened(...arguments); |
|
||||||
if (isNotNull(this.node)) { |
|
||||||
this.node.setOpened(v); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
_createNode() { |
|
||||||
const o = this.options; |
|
||||||
|
|
||||||
return createWidget({ |
|
||||||
type: MidPlusGroupNode.xtype, |
|
||||||
cls: "bi-list-item-none", |
|
||||||
logic: { |
|
||||||
dynamic: true, |
|
||||||
}, |
|
||||||
id: o.id, |
|
||||||
pId: o.pId, |
|
||||||
open: o.open, |
|
||||||
height: o.height, |
|
||||||
hgap: o.hgap, |
|
||||||
text: o.text, |
|
||||||
value: o.value, |
|
||||||
py: o.py, |
|
||||||
keyword: o.keyword, |
|
||||||
listeners: [ |
|
||||||
{ |
|
||||||
eventName: Controller.EVENT_CHANGE, |
|
||||||
action: (...args) => { |
|
||||||
const [type] = args; |
|
||||||
if (type === Events.CLICK) { |
|
||||||
// 本身实现click功能
|
|
||||||
return; |
|
||||||
} |
|
||||||
this.fireEvent(Controller.EVENT_CHANGE, ...args); |
|
||||||
}, |
|
||||||
} |
|
||||||
], |
|
||||||
}); |
|
||||||
} |
|
||||||
} |
|
@ -1,120 +0,0 @@ |
|||||||
import { |
|
||||||
shortcut, |
|
||||||
extend, |
|
||||||
count, |
|
||||||
contains, |
|
||||||
createWidget, |
|
||||||
makeArray, |
|
||||||
Layout, |
|
||||||
HorizontalAdaptLayout, |
|
||||||
isNotNull, |
|
||||||
Controller, |
|
||||||
Events |
|
||||||
} from "@/core"; |
|
||||||
import { NodeButton } from "@/base"; |
|
||||||
import { PlusGroupNode } from "@/case"; |
|
||||||
|
|
||||||
@shortcut() |
|
||||||
export class MultiLayerSingleTreePlusGroupNode extends NodeButton { |
|
||||||
static xtype = "bi.multilayer_single_tree_plus_group_node"; |
|
||||||
|
|
||||||
_defaultConfig() { |
|
||||||
const conf = super._defaultConfig(...arguments); |
|
||||||
|
|
||||||
return extend(conf, { |
|
||||||
extraCls: "bi-multilayer-single-tree-plus-group-node bi-list-item", |
|
||||||
layer: 0, // 第几层级
|
|
||||||
id: "", |
|
||||||
pId: "", |
|
||||||
open: false, |
|
||||||
height: 24, |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
_init() { |
|
||||||
super._init(...arguments); |
|
||||||
const o = this.options; |
|
||||||
this.node = this._createNode(); |
|
||||||
|
|
||||||
const needBlankLayers = []; |
|
||||||
let pNode = o.pNode; |
|
||||||
while (pNode) { |
|
||||||
if (pNode.isLastNode) { |
|
||||||
needBlankLayers.push(pNode.layer); |
|
||||||
} |
|
||||||
pNode = pNode.pNode; |
|
||||||
} |
|
||||||
|
|
||||||
const items = []; |
|
||||||
count(0, o.layer, index => { |
|
||||||
items.push({ |
|
||||||
type: Layout.xtype, |
|
||||||
cls: contains(needBlankLayers, index) ? "" : "base-line-conn-background", |
|
||||||
width: 12, |
|
||||||
height: o.height, |
|
||||||
}); |
|
||||||
}); |
|
||||||
items.push(this.node); |
|
||||||
createWidget({ |
|
||||||
type: HorizontalAdaptLayout.xtype, |
|
||||||
element: this, |
|
||||||
columnSize: makeArray(o.layer, 12), |
|
||||||
items, |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
doRedMark() { |
|
||||||
this.node.doRedMark(...arguments); |
|
||||||
} |
|
||||||
|
|
||||||
unRedMark() { |
|
||||||
this.node.unRedMark(...arguments); |
|
||||||
} |
|
||||||
|
|
||||||
doClick() { |
|
||||||
super.doClick(...arguments); |
|
||||||
this.node.setSelected(this.isSelected()); |
|
||||||
} |
|
||||||
|
|
||||||
setOpened(v) { |
|
||||||
super.setOpened(...arguments); |
|
||||||
if (isNotNull(this.node)) { |
|
||||||
this.node.setOpened(v); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
_createNode() { |
|
||||||
const o = this.options; |
|
||||||
|
|
||||||
return createWidget({ |
|
||||||
type: PlusGroupNode.xtype, |
|
||||||
cls: "bi-list-item-none", |
|
||||||
logic: { |
|
||||||
dynamic: true, |
|
||||||
}, |
|
||||||
id: o.id, |
|
||||||
pId: o.pId, |
|
||||||
open: o.open, |
|
||||||
isLastNode: o.isLastNode, |
|
||||||
height: o.height, |
|
||||||
hgap: o.hgap, |
|
||||||
text: o.text, |
|
||||||
value: o.value, |
|
||||||
py: o.py, |
|
||||||
keyword: o.keyword, |
|
||||||
listeners: [ |
|
||||||
{ |
|
||||||
eventName: Controller.EVENT_CHANGE, |
|
||||||
action: (...args) => { |
|
||||||
const [type] = args; |
|
||||||
if (type === Events.CLICK) { |
|
||||||
// 本身实现click功能
|
|
||||||
return; |
|
||||||
} |
|
||||||
this.fireEvent(Controller.EVENT_CHANGE, ...args); |
|
||||||
}, |
|
||||||
} |
|
||||||
], |
|
||||||
}); |
|
||||||
} |
|
||||||
} |
|
@ -1,3 +0,0 @@ |
|||||||
export { MultiLayerSingleTreeFirstTreeLeafItem } from "./item.first.treeleaf"; |
|
||||||
export { MultiLayerSingleTreeLastTreeLeafItem } from "./item.last.treeleaf"; |
|
||||||
export { MultiLayerSingleTreeMidTreeLeafItem } from "./item.mid.treeleaf"; |
|
@ -1,87 +0,0 @@ |
|||||||
import { shortcut, extend, createWidget, Controller, Events, makeArray, HorizontalAdaptLayout } from "@/core"; |
|
||||||
import { BasicButton } from "@/base"; |
|
||||||
|
|
||||||
@shortcut() |
|
||||||
export class MultiLayerSingleTreeFirstTreeLeafItem extends BasicButton { |
|
||||||
static xtype = "bi.multilayer_single_tree_first_tree_leaf_item"; |
|
||||||
|
|
||||||
_defaultConfig() { |
|
||||||
return extend(super._defaultConfig(...arguments), { |
|
||||||
extraCls: "bi-multilayer-single-tree-first-tree-leaf-item bi-list-item-active", |
|
||||||
logic: { |
|
||||||
dynamic: false, |
|
||||||
}, |
|
||||||
layer: 0, |
|
||||||
id: "", |
|
||||||
pId: "", |
|
||||||
height: 24, |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
_init() { |
|
||||||
super._init(...arguments); |
|
||||||
const self = this, |
|
||||||
o = this.options; |
|
||||||
this.item = createWidget({ |
|
||||||
type: "bi.first_tree_leaf_item", |
|
||||||
cls: "bi-list-item-none", |
|
||||||
logic: { |
|
||||||
dynamic: true, |
|
||||||
}, |
|
||||||
id: o.id, |
|
||||||
pId: o.pId, |
|
||||||
height: o.height, |
|
||||||
hgap: o.hgap, |
|
||||||
text: o.text, |
|
||||||
value: o.value, |
|
||||||
py: o.py, |
|
||||||
keyword: o.keyword, |
|
||||||
}); |
|
||||||
this.item.on(Controller.EVENT_CHANGE, function (type) { |
|
||||||
if (type === Events.CLICK) { |
|
||||||
// 本身实现click功能
|
|
||||||
return; |
|
||||||
} |
|
||||||
self.fireEvent(Controller.EVENT_CHANGE, arguments); |
|
||||||
}); |
|
||||||
|
|
||||||
const items = []; |
|
||||||
|
|
||||||
items.push({ |
|
||||||
el: this.item, |
|
||||||
lgap: (o.layer * BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT) / 2, |
|
||||||
}); |
|
||||||
createWidget({ |
|
||||||
type: HorizontalAdaptLayout.xtype, |
|
||||||
element: this, |
|
||||||
columnSize: makeArray(o.layer, BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2), |
|
||||||
items, |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
doHighLight() { |
|
||||||
this.item.doHighLight(...arguments); |
|
||||||
} |
|
||||||
|
|
||||||
unHighLight() { |
|
||||||
this.item.unHighLight(...arguments); |
|
||||||
} |
|
||||||
|
|
||||||
getId() { |
|
||||||
return this.options.id; |
|
||||||
} |
|
||||||
|
|
||||||
getPId() { |
|
||||||
return this.options.pId; |
|
||||||
} |
|
||||||
|
|
||||||
doClick() { |
|
||||||
super.doClick(...arguments); |
|
||||||
this.item.setSelected(this.isSelected()); |
|
||||||
} |
|
||||||
|
|
||||||
setSelected(v) { |
|
||||||
super.setSelected(...arguments); |
|
||||||
this.item.setSelected(v); |
|
||||||
} |
|
||||||
} |
|
@ -1,87 +0,0 @@ |
|||||||
import { shortcut, extend, createWidget, Controller, Events, makeArray, HorizontalAdaptLayout } from "@/core"; |
|
||||||
import { BasicButton } from "@/base"; |
|
||||||
|
|
||||||
@shortcut() |
|
||||||
export class MultiLayerSingleTreeLastTreeLeafItem extends BasicButton { |
|
||||||
static xtype = "bi.multilayer_single_tree_last_tree_leaf_item"; |
|
||||||
|
|
||||||
_defaultConfig() { |
|
||||||
return extend(super._defaultConfig(...arguments), { |
|
||||||
extraCls: "bi-multilayer-single-tree-last-tree-leaf-item bi-list-item-active", |
|
||||||
logic: { |
|
||||||
dynamic: false, |
|
||||||
}, |
|
||||||
layer: 0, |
|
||||||
id: "", |
|
||||||
pId: "", |
|
||||||
height: 24, |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
_init() { |
|
||||||
super._init(...arguments); |
|
||||||
const self = this, |
|
||||||
o = this.options; |
|
||||||
this.item = createWidget({ |
|
||||||
type: "bi.last_tree_leaf_item", |
|
||||||
cls: "bi-list-item-none", |
|
||||||
logic: { |
|
||||||
dynamic: true, |
|
||||||
}, |
|
||||||
id: o.id, |
|
||||||
pId: o.pId, |
|
||||||
height: o.height, |
|
||||||
hgap: o.hgap, |
|
||||||
text: o.text, |
|
||||||
value: o.value, |
|
||||||
py: o.py, |
|
||||||
keyword: o.keyword, |
|
||||||
}); |
|
||||||
this.item.on(Controller.EVENT_CHANGE, function (type) { |
|
||||||
if (type === Events.CLICK) { |
|
||||||
// 本身实现click功能
|
|
||||||
return; |
|
||||||
} |
|
||||||
self.fireEvent(Controller.EVENT_CHANGE, arguments); |
|
||||||
}); |
|
||||||
|
|
||||||
const items = []; |
|
||||||
|
|
||||||
items.push({ |
|
||||||
el: this.item, |
|
||||||
lgap: (o.layer * BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT) / 2, |
|
||||||
}); |
|
||||||
createWidget({ |
|
||||||
type: HorizontalAdaptLayout.xtype, |
|
||||||
element: this, |
|
||||||
columnSize: makeArray(o.layer, BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2), |
|
||||||
items, |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
doHighLight() { |
|
||||||
this.item.doHighLight(...arguments); |
|
||||||
} |
|
||||||
|
|
||||||
unHighLight() { |
|
||||||
this.item.unHighLight(...arguments); |
|
||||||
} |
|
||||||
|
|
||||||
getId() { |
|
||||||
return this.options.id; |
|
||||||
} |
|
||||||
|
|
||||||
getPId() { |
|
||||||
return this.options.pId; |
|
||||||
} |
|
||||||
|
|
||||||
doClick() { |
|
||||||
super.doClick(...arguments); |
|
||||||
this.item.setSelected(this.isSelected()); |
|
||||||
} |
|
||||||
|
|
||||||
setSelected(v) { |
|
||||||
super.setSelected(...arguments); |
|
||||||
this.item.setSelected(v); |
|
||||||
} |
|
||||||
} |
|
@ -1,87 +0,0 @@ |
|||||||
import { shortcut, extend, createWidget, Controller, Events, makeArray, HorizontalAdaptLayout } from "@/core"; |
|
||||||
import { BasicButton } from "@/base"; |
|
||||||
|
|
||||||
@shortcut() |
|
||||||
export class MultiLayerSingleTreeMidTreeLeafItem extends BasicButton { |
|
||||||
static xtype = "bi.multilayer_single_tree_mid_tree_leaf_item"; |
|
||||||
|
|
||||||
_defaultConfig() { |
|
||||||
return extend(super._defaultConfig(...arguments), { |
|
||||||
extraCls: "bi-multilayer-single-tree-mid-tree-leaf-item bi-list-item-active", |
|
||||||
logic: { |
|
||||||
dynamic: false, |
|
||||||
}, |
|
||||||
layer: 0, |
|
||||||
id: "", |
|
||||||
pId: "", |
|
||||||
height: 24, |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
_init() { |
|
||||||
super._init(...arguments); |
|
||||||
const self = this, |
|
||||||
o = this.options; |
|
||||||
this.item = createWidget({ |
|
||||||
type: "bi.mid_tree_leaf_item", |
|
||||||
cls: "bi-list-item-none", |
|
||||||
logic: { |
|
||||||
dynamic: true, |
|
||||||
}, |
|
||||||
id: o.id, |
|
||||||
pId: o.pId, |
|
||||||
height: o.height, |
|
||||||
hgap: o.hgap, |
|
||||||
text: o.text, |
|
||||||
value: o.value, |
|
||||||
py: o.py, |
|
||||||
keyword: o.keyword, |
|
||||||
}); |
|
||||||
this.item.on(Controller.EVENT_CHANGE, function (type) { |
|
||||||
if (type === Events.CLICK) { |
|
||||||
// 本身实现click功能
|
|
||||||
return; |
|
||||||
} |
|
||||||
self.fireEvent(Controller.EVENT_CHANGE, arguments); |
|
||||||
}); |
|
||||||
|
|
||||||
const items = []; |
|
||||||
|
|
||||||
items.push({ |
|
||||||
el: this.item, |
|
||||||
lgap: (o.layer * BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT) / 2, |
|
||||||
}); |
|
||||||
createWidget({ |
|
||||||
type: HorizontalAdaptLayout.xtype, |
|
||||||
element: this, |
|
||||||
columnSize: makeArray(o.layer, BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2), |
|
||||||
items, |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
doHighLight() { |
|
||||||
this.item.doHighLight(...arguments); |
|
||||||
} |
|
||||||
|
|
||||||
unHighLight() { |
|
||||||
this.item.unHighLight(...arguments); |
|
||||||
} |
|
||||||
|
|
||||||
getId() { |
|
||||||
return this.options.id; |
|
||||||
} |
|
||||||
|
|
||||||
getPId() { |
|
||||||
return this.options.pId; |
|
||||||
} |
|
||||||
|
|
||||||
doClick() { |
|
||||||
super.doClick(...arguments); |
|
||||||
this.item.setSelected(this.isSelected()); |
|
||||||
} |
|
||||||
|
|
||||||
setSelected(v) { |
|
||||||
super.setSelected(...arguments); |
|
||||||
this.item.setSelected(v); |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,5 @@ |
|||||||
|
export { SearchMultiTextValueCombo } from "./multitextvalue.combo.search"; |
||||||
|
export { SearchMultiSelectPopupView } from "./multitextvalue.popup.view.search"; |
||||||
|
export { SearchMultiSelectTrigger } from "./multitextvalue.combo.trigger.search"; |
||||||
|
export { SearchMultiSelectLoader } from "./multitextvalue.loader.search"; |
||||||
|
export { SearchMultiSelectSearcher } from "./trigger/searcher.multitextvalue"; |
@ -1,184 +1,202 @@ |
|||||||
/** |
import { shortcut, Widget, extend, emptyFn, createWidget, isKey, Selection, map, contains, remove, pushDistinct, Controller, VerticalLayout, createItems, delay, isNotNull } from "@/core"; |
||||||
* 多选加载数据面板 |
import { ButtonGroup, Loader } from "@/base"; |
||||||
* Created by guy on 15/11/2. |
import { SelectList, MultiSelectBar, MultiSelectItem } from "@/case"; |
||||||
* @class BI.SearchMultiSelectLoader |
|
||||||
* @extends Widget |
@shortcut() |
||||||
*/ |
export class SearchMultiSelectLoader extends Widget { |
||||||
BI.SearchMultiSelectLoader = BI.inherit(BI.Widget, { |
static xtype = "bi.search_multi_select_loader"; |
||||||
|
|
||||||
_defaultConfig: function () { |
static EVENT_CHANGE = "EVENT_CHANGE"; |
||||||
return BI.extend(BI.SearchMultiSelectLoader.superclass._defaultConfig.apply(this, arguments), { |
|
||||||
|
_defaultConfig() { |
||||||
|
return extend(super._defaultConfig(...arguments), { |
||||||
baseCls: "bi-multi-select-loader", |
baseCls: "bi-multi-select-loader", |
||||||
logic: { |
logic: { |
||||||
dynamic: true |
dynamic: true, |
||||||
}, |
}, |
||||||
el: { |
el: { |
||||||
height: 400 |
height: 400, |
||||||
}, |
}, |
||||||
valueFormatter: BI.emptyFn, |
valueFormatter: emptyFn, |
||||||
itemsCreator: BI.emptyFn, |
itemsCreator: emptyFn, |
||||||
itemHeight: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, |
itemHeight: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, |
||||||
onLoaded: BI.emptyFn |
onLoaded: emptyFn, |
||||||
}); |
}); |
||||||
}, |
} |
||||||
|
|
||||||
_init: function () { |
_init() { |
||||||
BI.SearchMultiSelectLoader.superclass._init.apply(this, arguments); |
super._init(...arguments); |
||||||
|
|
||||||
var self = this, opts = this.options; |
const opts = this.options; |
||||||
var hasNext = false; |
let hasNext = false; |
||||||
|
|
||||||
this.storeValue = opts.value || {}; |
this.storeValue = opts.value || {}; |
||||||
this._assertValue(this.storeValue); |
this._assertValue(this.storeValue); |
||||||
|
|
||||||
this.button_group = BI.createWidget({ |
this.button_group = createWidget({ |
||||||
type: "bi.select_list", |
type: SelectList.xtype, |
||||||
element: this, |
element: this, |
||||||
logic: opts.logic, |
logic: opts.logic, |
||||||
toolbar: { |
toolbar: { |
||||||
type: "bi.multi_select_bar", |
type: MultiSelectBar.xtype, |
||||||
cls: "bi-list-item-active", |
cls: "bi-list-item-active", |
||||||
height: this.options.itemHeight, |
height: this.options.itemHeight, |
||||||
iconWrapperWidth: 36 |
iconWrapperWidth: 36, |
||||||
}, |
}, |
||||||
el: BI.extend({ |
el: extend( |
||||||
onLoaded: opts.onLoaded, |
{ |
||||||
el: { |
onLoaded: opts.onLoaded, |
||||||
type: "bi.loader", |
|
||||||
isDefaultInit: false, |
|
||||||
logic: { |
|
||||||
dynamic: true, |
|
||||||
scrolly: true |
|
||||||
}, |
|
||||||
el: { |
el: { |
||||||
chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI, |
type: Loader.xtype, |
||||||
behaviors: { |
isDefaultInit: false, |
||||||
redmark: function () { |
logic: { |
||||||
return true; |
dynamic: true, |
||||||
} |
scrolly: true, |
||||||
}, |
}, |
||||||
layouts: [{ |
el: { |
||||||
type: "bi.vertical" |
chooseType: ButtonGroup.CHOOSE_TYPE_MULTI, |
||||||
}] |
behaviors: { |
||||||
} |
redmark: () => true, |
||||||
} |
}, |
||||||
}, opts.el), |
layouts: [ |
||||||
itemsCreator: function (op, callback) { |
{ |
||||||
var startValue = self._startValue; |
type: VerticalLayout.xtype, |
||||||
self.storeValue && (op = BI.extend(op || {}, { |
} |
||||||
selectedValues: BI.isKey(startValue) && self.storeValue.type === BI.Selection.Multi |
], |
||||||
? self.storeValue.value.concat(startValue) : self.storeValue.value |
}, |
||||||
})); |
}, |
||||||
opts.itemsCreator(op, function (ob) { |
}, |
||||||
|
opts.el |
||||||
|
), |
||||||
|
itemsCreator: (op, callback) => { |
||||||
|
const startValue = this._startValue; |
||||||
|
this.storeValue && |
||||||
|
(op = extend(op || {}, { |
||||||
|
selectedValues: |
||||||
|
isKey(startValue) && |
||||||
|
this.storeValue.type === Selection.Multi |
||||||
|
? this.storeValue.value.concat(startValue) |
||||||
|
: this.storeValue.value, |
||||||
|
})); |
||||||
|
opts.itemsCreator(op, ob => { |
||||||
hasNext = ob.hasNext; |
hasNext = ob.hasNext; |
||||||
var firstItems = []; |
let firstItems = []; |
||||||
if (op.times === 1 && self.storeValue) { |
if (op.times === 1 && this.storeValue) { |
||||||
var json = BI.map(self.storeValue.value, function (i, v) { |
const json = map(this.storeValue.value, (i, v) => { |
||||||
var txt = opts.valueFormatter(v) || v; |
const txt = opts.valueFormatter(v) || v; |
||||||
|
|
||||||
return { |
return { |
||||||
text: txt, |
text: txt, |
||||||
value: v, |
value: v, |
||||||
title: txt, |
title: txt, |
||||||
selected: self.storeValue.type === BI.Selection.Multi |
selected: |
||||||
|
this.storeValue.type === Selection.Multi, |
||||||
}; |
}; |
||||||
}); |
}); |
||||||
if (BI.isKey(self._startValue) && !BI.contains(self.storeValue.value, self._startValue)) { |
if ( |
||||||
var txt = opts.valueFormatter(startValue) || startValue; |
isKey(this._startValue) && |
||||||
|
!contains(this.storeValue.value, this._startValue) |
||||||
|
) { |
||||||
|
const txt = |
||||||
|
opts.valueFormatter(startValue) || startValue; |
||||||
json.unshift({ |
json.unshift({ |
||||||
text: txt, |
text: txt, |
||||||
value: startValue, |
value: startValue, |
||||||
title: txt, |
title: txt, |
||||||
selected: true |
selected: true, |
||||||
}); |
}); |
||||||
} |
} |
||||||
firstItems = self._createItems(json); |
firstItems = this._createItems(json); |
||||||
} |
} |
||||||
callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || ""); |
callback( |
||||||
if (op.times === 1 && self.storeValue) { |
firstItems.concat(this._createItems(ob.items)), |
||||||
BI.isKey(startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, startValue) : BI.pushDistinct(self.storeValue.value, startValue)); |
ob.keyword || "" |
||||||
self.setValue(self.storeValue); |
); |
||||||
|
if (op.times === 1 && this.storeValue) { |
||||||
|
isKey(startValue) && |
||||||
|
(this.storeValue.type === Selection.All |
||||||
|
? remove(this.storeValue.value, startValue) |
||||||
|
: pushDistinct( |
||||||
|
this.storeValue.value, |
||||||
|
startValue |
||||||
|
)); |
||||||
|
this.setValue(this.storeValue); |
||||||
} |
} |
||||||
(op.times === 1) && self._scrollToTop(); |
op.times === 1 && this._scrollToTop(); |
||||||
}); |
}); |
||||||
}, |
}, |
||||||
hasNext: function () { |
hasNext: () => hasNext, |
||||||
return hasNext; |
value: this.storeValue, |
||||||
}, |
|
||||||
value: this.storeValue |
|
||||||
}); |
}); |
||||||
this.button_group.on(BI.Controller.EVENT_CHANGE, function () { |
this.button_group.on(Controller.EVENT_CHANGE, () => { |
||||||
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); |
this.fireEvent(Controller.EVENT_CHANGE, arguments); |
||||||
}); |
}); |
||||||
this.button_group.on(BI.SelectList.EVENT_CHANGE, function () { |
this.button_group.on(SelectList.EVENT_CHANGE, () => { |
||||||
self.fireEvent(BI.SearchMultiSelectLoader.EVENT_CHANGE, arguments); |
this.fireEvent(SearchMultiSelectLoader.EVENT_CHANGE, ...arguments); |
||||||
}); |
}); |
||||||
}, |
} |
||||||
|
|
||||||
_createItems: function (items) { |
_createItems(items) { |
||||||
return BI.createItems(items, { |
return createItems(items, { |
||||||
type: "bi.multi_select_item", |
type: MultiSelectItem.xtype, |
||||||
logic: this.options.logic, |
logic: this.options.logic, |
||||||
cls: "bi-list-item-active", |
cls: "bi-list-item-active", |
||||||
height: this.options.itemHeight, |
height: this.options.itemHeight, |
||||||
selected: this.isAllSelected(), |
selected: this.isAllSelected(), |
||||||
iconWrapperWidth: 36 |
iconWrapperWidth: 36, |
||||||
}); |
}); |
||||||
}, |
} |
||||||
|
|
||||||
_scrollToTop: function () { |
_scrollToTop() { |
||||||
var self = this; |
delay(() => { |
||||||
BI.delay(function () { |
this.button_group.element.scrollTop(0); |
||||||
self.button_group.element.scrollTop(0); |
|
||||||
}, 30); |
}, 30); |
||||||
}, |
} |
||||||
|
|
||||||
isAllSelected: function () { |
isAllSelected() { |
||||||
return this.button_group.isAllSelected(); |
return this.button_group.isAllSelected(); |
||||||
}, |
} |
||||||
|
|
||||||
_assertValue: function (val) { |
_assertValue(val) { |
||||||
val || (val = {}); |
val || (val = {}); |
||||||
val.type || (val.type = BI.Selection.Multi); |
val.type || (val.type = Selection.Multi); |
||||||
val.value || (val.value = []); |
val.value || (val.value = []); |
||||||
}, |
} |
||||||
|
|
||||||
setStartValue: function (v) { |
setStartValue(v) { |
||||||
this._startValue = v; |
this._startValue = v; |
||||||
}, |
} |
||||||
|
|
||||||
setValue: function (v) { |
setValue(v) { |
||||||
this.storeValue = v || {}; |
this.storeValue = v || {}; |
||||||
this._assertValue(this.storeValue); |
this._assertValue(this.storeValue); |
||||||
this.button_group.setValue(this.storeValue); |
this.button_group.setValue(this.storeValue); |
||||||
}, |
} |
||||||
|
|
||||||
getValue: function () { |
getValue() { |
||||||
return this.button_group.getValue(); |
return this.button_group.getValue(); |
||||||
}, |
} |
||||||
|
|
||||||
getAllButtons: function () { |
getAllButtons() { |
||||||
return this.button_group.getAllButtons(); |
return this.button_group.getAllButtons(); |
||||||
}, |
} |
||||||
|
|
||||||
empty: function () { |
empty() { |
||||||
this.button_group.empty(); |
this.button_group.empty(); |
||||||
}, |
} |
||||||
|
|
||||||
populate: function (items) { |
populate(items) { |
||||||
if (BI.isNotNull(items)) { |
if (isNotNull(items)) { |
||||||
arguments[0] = this._createItems(items); |
arguments[0] = this._createItems(items); |
||||||
} |
} |
||||||
this.button_group.populate.apply(this.button_group, arguments); |
this.button_group.populate(...arguments); |
||||||
}, |
} |
||||||
|
|
||||||
resetHeight: function (h) { |
resetHeight(h) { |
||||||
this.button_group.resetHeight(h); |
this.button_group.resetHeight(h); |
||||||
}, |
} |
||||||
|
|
||||||
resetWidth: function (w) { |
resetWidth(w) { |
||||||
this.button_group.resetWidth(w); |
this.button_group.resetWidth(w); |
||||||
} |
} |
||||||
}); |
} |
||||||
|
|
||||||
BI.SearchMultiSelectLoader.EVENT_CHANGE = "EVENT_CHANGE"; |
|
||||||
BI.shortcut("bi.search_multi_select_loader", BI.SearchMultiSelectLoader); |
|
||||||
|
@ -1,92 +1,104 @@ |
|||||||
BI.SearchMultiSelectPopupView = BI.inherit(BI.Widget, { |
import { shortcut, Widget, extend, emptyFn, createWidget, i18nText } from "@/core"; |
||||||
|
import { MultiPopupView } from "@/case"; |
||||||
|
import { SearchMultiSelectLoader } from "@/widget"; |
||||||
|
|
||||||
_defaultConfig: function () { |
@shortcut() |
||||||
return BI.extend(BI.SearchMultiSelectPopupView.superclass._defaultConfig.apply(this, arguments), { |
export class SearchMultiSelectPopupView extends Widget { |
||||||
|
static xtype = "bi.search_multi_select_popup_view"; |
||||||
|
|
||||||
|
static EVENT_CHANGE = "EVENT_CHANGE"; |
||||||
|
static EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM"; |
||||||
|
static EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR"; |
||||||
|
|
||||||
|
_defaultConfig() { |
||||||
|
return extend(super._defaultConfig(...arguments), { |
||||||
baseCls: "bi-multi-select-popup-view", |
baseCls: "bi-multi-select-popup-view", |
||||||
maxWidth: "auto", |
maxWidth: "auto", |
||||||
minWidth: 135, |
minWidth: 135, |
||||||
maxHeight: 400, |
maxHeight: 400, |
||||||
valueFormatter: BI.emptyFn, |
valueFormatter: emptyFn, |
||||||
itemsCreator: BI.emptyFn, |
itemsCreator: emptyFn, |
||||||
onLoaded: BI.emptyFn |
onLoaded: emptyFn, |
||||||
}); |
}); |
||||||
}, |
} |
||||||
|
|
||||||
_init: function () { |
_init() { |
||||||
BI.SearchMultiSelectPopupView.superclass._init.apply(this, arguments); |
super._init(...arguments); |
||||||
var self = this, opts = this.options; |
const opts = this.options; |
||||||
|
|
||||||
this.loader = BI.createWidget({ |
this.loader = createWidget({ |
||||||
type: "bi.search_multi_select_loader", |
type: SearchMultiSelectLoader.xtype, |
||||||
itemsCreator: opts.itemsCreator, |
itemsCreator: opts.itemsCreator, |
||||||
valueFormatter: opts.valueFormatter, |
valueFormatter: opts.valueFormatter, |
||||||
onLoaded: opts.onLoaded, |
onLoaded: opts.onLoaded, |
||||||
value: opts.value |
value: opts.value, |
||||||
}); |
}); |
||||||
|
|
||||||
this.popupView = BI.createWidget({ |
this.popupView = createWidget({ |
||||||
type: "bi.multi_popup_view", |
type: MultiPopupView.xtype, |
||||||
stopPropagation: false, |
stopPropagation: false, |
||||||
maxWidth: opts.maxWidth, |
maxWidth: opts.maxWidth, |
||||||
minWidth: opts.minWidth, |
minWidth: opts.minWidth, |
||||||
maxHeight: opts.maxHeight, |
maxHeight: opts.maxHeight, |
||||||
element: this, |
element: this, |
||||||
buttons: [BI.i18nText("BI-Basic_Clears"), BI.i18nText("BI-Basic_OK")], |
buttons: [i18nText("BI-Basic_Clears"), i18nText("BI-Basic_OK")], |
||||||
el: this.loader, |
el: this.loader, |
||||||
value: opts.value |
value: opts.value, |
||||||
}); |
}); |
||||||
|
|
||||||
this.popupView.on(BI.MultiPopupView.EVENT_CHANGE, function () { |
this.popupView.on(MultiPopupView.EVENT_CHANGE, () => { |
||||||
self.fireEvent(BI.SearchMultiSelectPopupView.EVENT_CHANGE); |
this.fireEvent(SearchMultiSelectPopupView.EVENT_CHANGE); |
||||||
}); |
}); |
||||||
this.popupView.on(BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, function (index) { |
this.popupView.on( |
||||||
switch (index) { |
MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, |
||||||
|
index => { |
||||||
|
switch (index) { |
||||||
case 0: |
case 0: |
||||||
self.fireEvent(BI.SearchMultiSelectPopupView.EVENT_CLICK_CLEAR); |
this.fireEvent( |
||||||
|
SearchMultiSelectPopupView.EVENT_CLICK_CLEAR |
||||||
|
); |
||||||
break; |
break; |
||||||
case 1: |
case 1: |
||||||
self.fireEvent(BI.SearchMultiSelectPopupView.EVENT_CLICK_CONFIRM); |
this.fireEvent( |
||||||
|
SearchMultiSelectPopupView.EVENT_CLICK_CONFIRM |
||||||
|
); |
||||||
break; |
break; |
||||||
|
default: |
||||||
|
break; |
||||||
|
} |
||||||
} |
} |
||||||
}); |
); |
||||||
}, |
} |
||||||
|
|
||||||
isAllSelected: function () { |
isAllSelected() { |
||||||
return this.loader.isAllSelected(); |
return this.loader.isAllSelected(); |
||||||
}, |
} |
||||||
|
|
||||||
setStartValue: function (v) { |
setStartValue(v) { |
||||||
this.loader.setStartValue(v); |
this.loader.setStartValue(v); |
||||||
}, |
} |
||||||
|
|
||||||
setValue: function (v) { |
setValue(v) { |
||||||
this.popupView.setValue(v); |
this.popupView.setValue(v); |
||||||
}, |
} |
||||||
|
|
||||||
getValue: function () { |
getValue() { |
||||||
return this.popupView.getValue(); |
return this.popupView.getValue(); |
||||||
}, |
} |
||||||
|
|
||||||
populate: function (items) { |
populate(items) { |
||||||
this.popupView.populate.apply(this.popupView, arguments); |
this.popupView.populate(...arguments); |
||||||
}, |
} |
||||||
|
|
||||||
resetHeight: function (h) { |
resetHeight(h) { |
||||||
this.popupView.resetHeight(h); |
this.popupView.resetHeight(h); |
||||||
}, |
} |
||||||
|
|
||||||
resetWidth: function (w) { |
resetWidth(w) { |
||||||
this.popupView.resetWidth(w); |
this.popupView.resetWidth(w); |
||||||
}, |
} |
||||||
|
|
||||||
setDirection: function (direction, position) { |
setDirection(direction, position) { |
||||||
this.popupView.setDirection(direction, position); |
this.popupView.setDirection(direction, position); |
||||||
}, |
} |
||||||
}); |
} |
||||||
|
|
||||||
BI.SearchMultiSelectPopupView.EVENT_CHANGE = "EVENT_CHANGE"; |
|
||||||
BI.SearchMultiSelectPopupView.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM"; |
|
||||||
BI.SearchMultiSelectPopupView.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR"; |
|
||||||
|
|
||||||
|
|
||||||
BI.shortcut("bi.search_multi_select_popup_view", BI.SearchMultiSelectPopupView); |
|
||||||
|
@ -1,175 +1,179 @@ |
|||||||
BI.SearchMultiSelectSearcher = BI.inherit(BI.Widget, { |
import { shortcut, Widget, extend, emptyFn, createWidget, isNotNull, Selection, size, each } from "@/core"; |
||||||
|
import { Searcher } from "@/base"; |
||||||
_defaultConfig: function () { |
import { MultiSelectEditor, MultiSelectSearchPane } from "@/widget"; |
||||||
return BI.extend(BI.SearchMultiSelectSearcher.superclass._defaultConfig.apply(this, arguments), { |
|
||||||
|
@shortcut() |
||||||
|
export class SearchMultiSelectSearcher extends Widget { |
||||||
|
static xtype = "bi.search_multi_select_searcher"; |
||||||
|
|
||||||
|
static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; |
||||||
|
static EVENT_CHANGE = "EVENT_CHANGE"; |
||||||
|
static EVENT_START = "EVENT_START"; |
||||||
|
static EVENT_STOP = "EVENT_STOP"; |
||||||
|
static EVENT_PAUSE = "EVENT_PAUSE"; |
||||||
|
static EVENT_SEARCHING = "EVENT_SEARCHING"; |
||||||
|
|
||||||
|
_defaultConfig() { |
||||||
|
return extend(super._defaultConfig(...arguments), { |
||||||
baseCls: "bi-multi-select-searcher", |
baseCls: "bi-multi-select-searcher", |
||||||
itemsCreator: BI.emptyFn, |
itemsCreator: emptyFn, |
||||||
el: {}, |
el: {}, |
||||||
popup: {}, |
popup: {}, |
||||||
valueFormatter: BI.emptyFn, |
valueFormatter: emptyFn, |
||||||
adapter: null, |
adapter: null, |
||||||
masker: {} |
masker: {}, |
||||||
}); |
}); |
||||||
}, |
} |
||||||
|
|
||||||
_init: function () { |
_init() { |
||||||
BI.SearchMultiSelectSearcher.superclass._init.apply(this, arguments); |
super._init(...arguments); |
||||||
var self = this, o = this.options; |
const o = this.options; |
||||||
this.editor = BI.createWidget(o.el, { |
this.editor = createWidget(o.el, { |
||||||
type: "bi.multi_select_editor", |
type: MultiSelectEditor.xtype, |
||||||
height: o.height, |
height: o.height, |
||||||
text: o.text, |
text: o.text, |
||||||
tipType: o.tipType, |
tipType: o.tipType, |
||||||
warningTitle: o.warningTitle |
warningTitle: o.warningTitle, |
||||||
}); |
}); |
||||||
|
|
||||||
this.searcher = BI.createWidget({ |
this.searcher = createWidget({ |
||||||
type: "bi.searcher", |
type: Searcher.xtype, |
||||||
element: this, |
element: this, |
||||||
height: o.height, |
height: o.height, |
||||||
isAutoSearch: false, |
isAutoSearch: false, |
||||||
isAutoSync: false, |
isAutoSync: false, |
||||||
onSearch: function (op, callback) { |
onSearch: (op, callback) => { |
||||||
callback(); |
callback(); |
||||||
}, |
}, |
||||||
el: this.editor, |
el: this.editor, |
||||||
|
|
||||||
popup: BI.extend({ |
popup: extend( |
||||||
type: "bi.multi_select_search_pane", |
{ |
||||||
valueFormatter: o.valueFormatter, |
type: MultiSelectSearchPane.xtype, |
||||||
keywordGetter: function () { |
valueFormatter: o.valueFormatter, |
||||||
return self.editor.getValue(); |
keywordGetter: () => this.editor.getValue(), |
||||||
}, |
itemsCreator: (op, callback) => { |
||||||
itemsCreator: function (op, callback) { |
const keyword = this.editor.getValue(); |
||||||
var keyword = self.editor.getValue(); |
op.keywords = [keyword]; |
||||||
op.keywords = [keyword]; |
o.itemsCreator(op, callback); |
||||||
o.itemsCreator(op, callback); |
}, |
||||||
|
value: o.value, |
||||||
}, |
}, |
||||||
value: o.value |
o.popup |
||||||
}, o.popup), |
), |
||||||
|
|
||||||
adapter: o.adapter, |
adapter: o.adapter, |
||||||
masker: o.masker |
masker: o.masker, |
||||||
}); |
}); |
||||||
this.searcher.on(BI.Searcher.EVENT_START, function () { |
this.searcher.on(Searcher.EVENT_START, () => { |
||||||
self.fireEvent(BI.SearchMultiSelectSearcher.EVENT_START); |
this.fireEvent(SearchMultiSelectSearcher.EVENT_START); |
||||||
}); |
}); |
||||||
this.searcher.on(BI.Searcher.EVENT_PAUSE, function () { |
this.searcher.on(Searcher.EVENT_PAUSE, () => { |
||||||
if (this.hasMatched()) { |
this.fireEvent(SearchMultiSelectSearcher.EVENT_PAUSE); |
||||||
|
|
||||||
} |
|
||||||
self.fireEvent(BI.SearchMultiSelectSearcher.EVENT_PAUSE); |
|
||||||
}); |
}); |
||||||
this.searcher.on(BI.Searcher.EVENT_STOP, function () { |
this.searcher.on(Searcher.EVENT_STOP, () => { |
||||||
self.fireEvent(BI.SearchMultiSelectSearcher.EVENT_STOP); |
this.fireEvent(SearchMultiSelectSearcher.EVENT_STOP); |
||||||
}); |
}); |
||||||
this.searcher.on(BI.Searcher.EVENT_CHANGE, function () { |
this.searcher.on(Searcher.EVENT_CHANGE, () => { |
||||||
self.fireEvent(BI.SearchMultiSelectSearcher.EVENT_CHANGE, arguments); |
this.fireEvent(SearchMultiSelectSearcher.EVENT_CHANGE, ...arguments); |
||||||
}); |
}); |
||||||
this.searcher.on(BI.Searcher.EVENT_SEARCHING, function () { |
this.searcher.on(Searcher.EVENT_SEARCHING, () => { |
||||||
var keywords = this.getKeywords(); |
const keywords = this.getKeywords(); |
||||||
self.fireEvent(BI.SearchMultiSelectSearcher.EVENT_SEARCHING, keywords); |
this.fireEvent(SearchMultiSelectSearcher.EVENT_SEARCHING, keywords); |
||||||
}); |
}); |
||||||
if(BI.isNotNull(o.value)) { |
if (isNotNull(o.value)) { |
||||||
this.setState(o.value); |
this.setState(o.value); |
||||||
} |
} |
||||||
}, |
} |
||||||
|
|
||||||
adjustView: function () { |
adjustView() { |
||||||
this.searcher.adjustView(); |
this.searcher.adjustView(); |
||||||
}, |
} |
||||||
|
|
||||||
isSearching: function () { |
isSearching() { |
||||||
return this.searcher.isSearching(); |
return this.searcher.isSearching(); |
||||||
}, |
} |
||||||
|
|
||||||
stopSearch: function () { |
stopSearch() { |
||||||
this.searcher.stopSearch(); |
this.searcher.stopSearch(); |
||||||
}, |
} |
||||||
|
|
||||||
getKeyword: function () { |
getKeyword() { |
||||||
return this.editor.getValue(); |
return this.editor.getValue(); |
||||||
}, |
} |
||||||
|
|
||||||
hasMatched: function () { |
hasMatched() { |
||||||
return this.searcher.hasMatched(); |
return this.searcher.hasMatched(); |
||||||
}, |
} |
||||||
|
|
||||||
hasChecked: function () { |
hasChecked() { |
||||||
return this.searcher.getView() && this.searcher.getView().hasChecked(); |
return this.searcher.getView() && this.searcher.getView().hasChecked(); |
||||||
}, |
} |
||||||
|
|
||||||
setAdapter: function (adapter) { |
setAdapter(adapter) { |
||||||
this.searcher.setAdapter(adapter); |
this.searcher.setAdapter(adapter); |
||||||
}, |
} |
||||||
|
|
||||||
setState: function (obj) { |
setState(obj) { |
||||||
var o = this.options; |
let state; |
||||||
var ob = {}; |
const o = this.options; |
||||||
|
const ob = {}; |
||||||
ob.type = obj.type; |
ob.type = obj.type; |
||||||
ob.value = o.allValueGetter() || []; |
ob.value = o.allValueGetter() || []; |
||||||
ob.assist = obj.assist; |
ob.assist = obj.assist; |
||||||
if (ob.type === BI.Selection.All) { |
if (ob.type === Selection.All) { |
||||||
if (ob.value.length === 0) { |
if (ob.value.length === 0) { |
||||||
this.editor.setState(BI.Selection.All); |
this.editor.setState(Selection.All); |
||||||
} else if (BI.size(ob.assist) <= 20) { |
} else if (size(ob.assist) <= 20) { |
||||||
var state = ""; |
state = ""; |
||||||
BI.each(ob.assist, function (i, v) { |
each(ob.assist, (i, v) => { |
||||||
if (i === 0) { |
if (i === 0) { |
||||||
state += "" + (o.valueFormatter(v + "") || v); |
state += `${o.valueFormatter(`${v}`) || v}`; |
||||||
} else { |
} else { |
||||||
state += "," + (o.valueFormatter(v + "") || v); |
state += `,${o.valueFormatter(`${v}`) || v}`; |
||||||
} |
} |
||||||
}); |
}); |
||||||
this.editor.setState(state); |
this.editor.setState(state); |
||||||
} else { |
} else { |
||||||
this.editor.setState(BI.Selection.Multi); |
this.editor.setState(Selection.Multi); |
||||||
} |
} |
||||||
} else { |
} else { |
||||||
if (ob.value.length === 0) { |
if (ob.value.length === 0) { |
||||||
this.editor.setState(BI.Selection.None); |
this.editor.setState(Selection.None); |
||||||
} else if (BI.size(ob.value) <= 20) { |
} else if (size(ob.value) <= 20) { |
||||||
var state = ""; |
state = ""; |
||||||
BI.each(ob.value, function (i, v) { |
each(ob.value, (i, v) => { |
||||||
if (i === 0) { |
if (i === 0) { |
||||||
state += "" + (o.valueFormatter(v + "") || v); |
state += `${o.valueFormatter(`${v}`) || v}`; |
||||||
} else { |
} else { |
||||||
state += "," + (o.valueFormatter(v + "") || v); |
state += `,${o.valueFormatter(`${v}`) || v}`; |
||||||
} |
} |
||||||
}); |
}); |
||||||
this.editor.setState(state); |
this.editor.setState(state); |
||||||
} else { |
} else { |
||||||
this.editor.setState(BI.Selection.Multi); |
this.editor.setState(Selection.Multi); |
||||||
} |
} |
||||||
} |
} |
||||||
}, |
} |
||||||
|
|
||||||
setTipType: function (v) { |
setTipType(v) { |
||||||
this.editor.setTipType(v); |
this.editor.setTipType(v); |
||||||
}, |
} |
||||||
|
|
||||||
setValue: function (ob) { |
setValue(ob) { |
||||||
this.setState(ob); |
this.setState(ob); |
||||||
this.searcher.setValue(ob); |
this.searcher.setValue(ob); |
||||||
}, |
} |
||||||
|
|
||||||
getKey: function () { |
getKey() { |
||||||
return this.editor.getValue(); |
return this.editor.getValue(); |
||||||
}, |
} |
||||||
|
|
||||||
getValue: function () { |
getValue() { |
||||||
return this.searcher.getValue(); |
return this.searcher.getValue(); |
||||||
}, |
} |
||||||
|
|
||||||
populate: function (items) { |
populate(items) { |
||||||
this.searcher.populate.apply(this.searcher, arguments); |
this.searcher.populate(...arguments); |
||||||
} |
} |
||||||
}); |
} |
||||||
|
|
||||||
BI.SearchMultiSelectSearcher.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; |
|
||||||
BI.SearchMultiSelectSearcher.EVENT_CHANGE = "EVENT_CHANGE"; |
|
||||||
BI.SearchMultiSelectSearcher.EVENT_START = "EVENT_START"; |
|
||||||
BI.SearchMultiSelectSearcher.EVENT_STOP = "EVENT_STOP"; |
|
||||||
BI.SearchMultiSelectSearcher.EVENT_PAUSE = "EVENT_PAUSE"; |
|
||||||
BI.SearchMultiSelectSearcher.EVENT_SEARCHING = "EVENT_SEARCHING"; |
|
||||||
BI.shortcut("bi.search_multi_select_searcher", BI.SearchMultiSelectSearcher); |
|
||||||
|
@ -1,109 +0,0 @@ |
|||||||
import { |
|
||||||
shortcut, |
|
||||||
extend, |
|
||||||
createWidget, |
|
||||||
Controller, |
|
||||||
Events, |
|
||||||
isNotNull, LogicFactory, Direction |
|
||||||
} from "@/core"; |
|
||||||
import { NodeButton, Label } from "@/base"; |
|
||||||
import { FirstTreeNodeCheckbox } from "@/case"; |
|
||||||
|
|
||||||
@shortcut() |
|
||||||
export class SelectTreeFirstPlusGroupNode extends NodeButton { |
|
||||||
static xtype = "bi.select_tree_first_plus_group_node"; |
|
||||||
|
|
||||||
_defaultConfig() { |
|
||||||
const conf = super._defaultConfig(...arguments); |
|
||||||
|
|
||||||
return extend(conf, { |
|
||||||
baseCls: |
|
||||||
`${conf.baseCls || "" |
|
||||||
} bi-select-tree-first-plus-group-node bi-list-item-active`,
|
|
||||||
logic: { |
|
||||||
dynamic: false, |
|
||||||
}, |
|
||||||
id: "", |
|
||||||
pId: "", |
|
||||||
readonly: true, |
|
||||||
open: false, |
|
||||||
height: 24, |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
_init() { |
|
||||||
super._init(...arguments); |
|
||||||
const self = this, |
|
||||||
o = this.options; |
|
||||||
this.checkbox = createWidget({ |
|
||||||
type: FirstTreeNodeCheckbox.xtype, |
|
||||||
stopPropagation: true, |
|
||||||
iconHeight: o.height, |
|
||||||
iconWidth: o.height, |
|
||||||
}); |
|
||||||
this.text = createWidget({ |
|
||||||
type: Label.xtype, |
|
||||||
textAlign: "left", |
|
||||||
whiteSpace: "nowrap", |
|
||||||
textHeight: o.height, |
|
||||||
height: o.height, |
|
||||||
hgap: o.hgap, |
|
||||||
text: o.text, |
|
||||||
value: o.value, |
|
||||||
keyword: o.keyword, |
|
||||||
py: o.py, |
|
||||||
}); |
|
||||||
this.checkbox.on(Controller.EVENT_CHANGE, function (type) { |
|
||||||
if (type === Events.CLICK) { |
|
||||||
if (this.isSelected()) { |
|
||||||
self.triggerExpand(); |
|
||||||
} else { |
|
||||||
self.triggerCollapse(); |
|
||||||
} |
|
||||||
} |
|
||||||
}); |
|
||||||
const type = LogicFactory.createLogicTypeByDirection( |
|
||||||
Direction.Left |
|
||||||
); |
|
||||||
const items = LogicFactory.createLogicItemsByDirection( |
|
||||||
Direction.Left, |
|
||||||
{ |
|
||||||
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, |
|
||||||
el: this.checkbox, |
|
||||||
}, |
|
||||||
this.text |
|
||||||
); |
|
||||||
createWidget( |
|
||||||
extend( |
|
||||||
{ |
|
||||||
element: this, |
|
||||||
}, |
|
||||||
LogicFactory.createLogic( |
|
||||||
type, |
|
||||||
extend(o.logic, { |
|
||||||
items, |
|
||||||
}) |
|
||||||
) |
|
||||||
) |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
isOnce() { |
|
||||||
return true; |
|
||||||
} |
|
||||||
|
|
||||||
doRedMark() { |
|
||||||
this.text.doRedMark(...arguments); |
|
||||||
} |
|
||||||
|
|
||||||
unRedMark() { |
|
||||||
this.text.unRedMark(...arguments); |
|
||||||
} |
|
||||||
|
|
||||||
setOpened(v) { |
|
||||||
super.setOpened(...arguments); |
|
||||||
if (isNotNull(this.checkbox)) { |
|
||||||
this.checkbox.setSelected(v); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,109 +0,0 @@ |
|||||||
import { |
|
||||||
shortcut, |
|
||||||
extend, |
|
||||||
createWidget, |
|
||||||
Controller, |
|
||||||
Events, |
|
||||||
isNotNull, LogicFactory, Direction |
|
||||||
} from "@/core"; |
|
||||||
import { NodeButton, Label } from "@/base"; |
|
||||||
import { LastTreeNodeCheckbox } from "@/case"; |
|
||||||
|
|
||||||
@shortcut() |
|
||||||
export class SelectTreeLastPlusGroupNode extends NodeButton { |
|
||||||
static xtype = "bi.select_tree_last_plus_group_node"; |
|
||||||
|
|
||||||
_defaultConfig() { |
|
||||||
const conf = super._defaultConfig(...arguments); |
|
||||||
|
|
||||||
return extend(conf, { |
|
||||||
baseCls: |
|
||||||
`${conf.baseCls || "" |
|
||||||
} bi-select-tree-last-plus-group-node bi-list-item-active`,
|
|
||||||
logic: { |
|
||||||
dynamic: false, |
|
||||||
}, |
|
||||||
id: "", |
|
||||||
pId: "", |
|
||||||
readonly: true, |
|
||||||
open: false, |
|
||||||
height: 24, |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
_init() { |
|
||||||
super._init(...arguments); |
|
||||||
const self = this, |
|
||||||
o = this.options; |
|
||||||
this.checkbox = createWidget({ |
|
||||||
type: LastTreeNodeCheckbox.xtype, |
|
||||||
stopPropagation: true, |
|
||||||
iconHeight: o.height, |
|
||||||
iconWidth: o.height, |
|
||||||
}); |
|
||||||
this.text = createWidget({ |
|
||||||
type: Label.xtype, |
|
||||||
textAlign: "left", |
|
||||||
whiteSpace: "nowrap", |
|
||||||
textHeight: o.height, |
|
||||||
height: o.height, |
|
||||||
hgap: o.hgap, |
|
||||||
text: o.text, |
|
||||||
value: o.value, |
|
||||||
keyword: o.keyword, |
|
||||||
py: o.py, |
|
||||||
}); |
|
||||||
this.checkbox.on(Controller.EVENT_CHANGE, function (type) { |
|
||||||
if (type === Events.CLICK) { |
|
||||||
if (this.isSelected()) { |
|
||||||
self.triggerExpand(); |
|
||||||
} else { |
|
||||||
self.triggerCollapse(); |
|
||||||
} |
|
||||||
} |
|
||||||
}); |
|
||||||
const type = LogicFactory.createLogicTypeByDirection( |
|
||||||
Direction.Left |
|
||||||
); |
|
||||||
const items = LogicFactory.createLogicItemsByDirection( |
|
||||||
Direction.Left, |
|
||||||
{ |
|
||||||
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, |
|
||||||
el: this.checkbox, |
|
||||||
}, |
|
||||||
this.text |
|
||||||
); |
|
||||||
createWidget( |
|
||||||
extend( |
|
||||||
{ |
|
||||||
element: this, |
|
||||||
}, |
|
||||||
LogicFactory.createLogic( |
|
||||||
type, |
|
||||||
extend(o.logic, { |
|
||||||
items, |
|
||||||
}) |
|
||||||
) |
|
||||||
) |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
isOnce() { |
|
||||||
return true; |
|
||||||
} |
|
||||||
|
|
||||||
doRedMark() { |
|
||||||
this.text.doRedMark(...arguments); |
|
||||||
} |
|
||||||
|
|
||||||
unRedMark() { |
|
||||||
this.text.unRedMark(...arguments); |
|
||||||
} |
|
||||||
|
|
||||||
setOpened(v) { |
|
||||||
super.setOpened(...arguments); |
|
||||||
if (isNotNull(this.checkbox)) { |
|
||||||
this.checkbox.setSelected(v); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,109 +0,0 @@ |
|||||||
import { |
|
||||||
shortcut, |
|
||||||
extend, |
|
||||||
createWidget, |
|
||||||
Controller, |
|
||||||
Events, |
|
||||||
isNotNull, Direction, LogicFactory |
|
||||||
} from "@/core"; |
|
||||||
import { NodeButton, Label } from "@/base"; |
|
||||||
import { MidTreeNodeCheckbox } from "@/case"; |
|
||||||
|
|
||||||
@shortcut() |
|
||||||
export class SelectTreeMidPlusGroupNode extends NodeButton { |
|
||||||
static xtype = "bi.select_tree_mid_plus_group_node"; |
|
||||||
|
|
||||||
_defaultConfig() { |
|
||||||
const conf = super._defaultConfig(...arguments); |
|
||||||
|
|
||||||
return extend(conf, { |
|
||||||
baseCls: |
|
||||||
`${conf.baseCls || "" |
|
||||||
} bi-select-tree-mid-plus-group-node bi-list-item-active`,
|
|
||||||
logic: { |
|
||||||
dynamic: false, |
|
||||||
}, |
|
||||||
id: "", |
|
||||||
pId: "", |
|
||||||
readonly: true, |
|
||||||
open: false, |
|
||||||
height: 24, |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
_init() { |
|
||||||
super._init(...arguments); |
|
||||||
const self = this, |
|
||||||
o = this.options; |
|
||||||
this.checkbox = createWidget({ |
|
||||||
type: MidTreeNodeCheckbox.xtype, |
|
||||||
stopPropagation: true, |
|
||||||
iconHeight: o.height, |
|
||||||
iconWidth: o.height, |
|
||||||
}); |
|
||||||
this.text = createWidget({ |
|
||||||
type: Label.xtype, |
|
||||||
textAlign: "left", |
|
||||||
whiteSpace: "nowrap", |
|
||||||
textHeight: o.height, |
|
||||||
height: o.height, |
|
||||||
hgap: o.hgap, |
|
||||||
text: o.text, |
|
||||||
value: o.value, |
|
||||||
keyword: o.keyword, |
|
||||||
py: o.py, |
|
||||||
}); |
|
||||||
this.checkbox.on(Controller.EVENT_CHANGE, function (type) { |
|
||||||
if (type === Events.CLICK) { |
|
||||||
if (this.isSelected()) { |
|
||||||
self.triggerExpand(); |
|
||||||
} else { |
|
||||||
self.triggerCollapse(); |
|
||||||
} |
|
||||||
} |
|
||||||
}); |
|
||||||
const type = LogicFactory.createLogicTypeByDirection( |
|
||||||
Direction.Left |
|
||||||
); |
|
||||||
const items = LogicFactory.createLogicItemsByDirection( |
|
||||||
Direction.Left, |
|
||||||
{ |
|
||||||
width: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, |
|
||||||
el: this.checkbox, |
|
||||||
}, |
|
||||||
this.text |
|
||||||
); |
|
||||||
createWidget( |
|
||||||
extend( |
|
||||||
{ |
|
||||||
element: this, |
|
||||||
}, |
|
||||||
LogicFactory.createLogic( |
|
||||||
type, |
|
||||||
extend(o.logic, { |
|
||||||
items, |
|
||||||
}) |
|
||||||
) |
|
||||||
) |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
isOnce() { |
|
||||||
return true; |
|
||||||
} |
|
||||||
|
|
||||||
doRedMark() { |
|
||||||
this.text.doRedMark(...arguments); |
|
||||||
} |
|
||||||
|
|
||||||
unRedMark() { |
|
||||||
this.text.unRedMark(...arguments); |
|
||||||
} |
|
||||||
|
|
||||||
setOpened(v) { |
|
||||||
super.setOpened(...arguments); |
|
||||||
if (isNotNull(this.checkbox)) { |
|
||||||
this.checkbox.setSelected(v); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,109 +0,0 @@ |
|||||||
import { |
|
||||||
shortcut, |
|
||||||
extend, |
|
||||||
createWidget, |
|
||||||
Controller, |
|
||||||
Events, |
|
||||||
isNotNull, LogicFactory |
|
||||||
} from "@/core"; |
|
||||||
import { NodeButton, Label } from "@/base"; |
|
||||||
import { TreeNodeCheckbox } from "@/case"; |
|
||||||
|
|
||||||
@shortcut() |
|
||||||
export class SelectTreePlusGroupNode extends NodeButton { |
|
||||||
static xtype = "bi.select_tree_plus_group_node"; |
|
||||||
|
|
||||||
_defaultConfig() { |
|
||||||
const conf = super._defaultConfig(...arguments); |
|
||||||
|
|
||||||
return extend(conf, { |
|
||||||
baseCls: |
|
||||||
`${conf.baseCls || "" |
|
||||||
} bi-select-tree-plus-group-node bi-list-item-active`,
|
|
||||||
logic: { |
|
||||||
dynamic: false, |
|
||||||
}, |
|
||||||
id: "", |
|
||||||
pId: "", |
|
||||||
readonly: true, |
|
||||||
open: false, |
|
||||||
height: 24, |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
_init() { |
|
||||||
super._init(...arguments); |
|
||||||
const self = this, |
|
||||||
o = this.options; |
|
||||||
this.checkbox = createWidget({ |
|
||||||
type: TreeNodeCheckbox.xtype, |
|
||||||
stopPropagation: true, |
|
||||||
iconHeight: o.height, |
|
||||||
iconWidth: o.iconWrapperWidth || o.height, |
|
||||||
}); |
|
||||||
this.text = createWidget({ |
|
||||||
type: Label.xtype, |
|
||||||
textAlign: "left", |
|
||||||
whiteSpace: "nowrap", |
|
||||||
textHeight: o.height, |
|
||||||
height: o.height, |
|
||||||
hgap: o.hgap, |
|
||||||
text: o.text, |
|
||||||
value: o.value, |
|
||||||
keyword: o.keyword, |
|
||||||
py: o.py, |
|
||||||
}); |
|
||||||
this.checkbox.on(Controller.EVENT_CHANGE, function (type) { |
|
||||||
if (type === Events.CLICK) { |
|
||||||
if (this.isSelected()) { |
|
||||||
self.triggerExpand(); |
|
||||||
} else { |
|
||||||
self.triggerCollapse(); |
|
||||||
} |
|
||||||
} |
|
||||||
}); |
|
||||||
const type = LogicFactory.createLogicTypeByDirection( |
|
||||||
BI.Direction.Left |
|
||||||
); |
|
||||||
const items = LogicFactory.createLogicItemsByDirection( |
|
||||||
BI.Direction.Left, |
|
||||||
{ |
|
||||||
width: 24, |
|
||||||
el: this.checkbox, |
|
||||||
}, |
|
||||||
this.text |
|
||||||
); |
|
||||||
createWidget( |
|
||||||
extend( |
|
||||||
{ |
|
||||||
element: this, |
|
||||||
}, |
|
||||||
LogicFactory.createLogic( |
|
||||||
type, |
|
||||||
extend(o.logic, { |
|
||||||
items, |
|
||||||
}) |
|
||||||
) |
|
||||||
) |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
isOnce() { |
|
||||||
return true; |
|
||||||
} |
|
||||||
|
|
||||||
doRedMark() { |
|
||||||
this.text.doRedMark(...arguments); |
|
||||||
} |
|
||||||
|
|
||||||
unRedMark() { |
|
||||||
this.text.unRedMark(...arguments); |
|
||||||
} |
|
||||||
|
|
||||||
setOpened(v) { |
|
||||||
super.setOpened(...arguments); |
|
||||||
if (isNotNull(this.checkbox)) { |
|
||||||
this.checkbox.setSelected(v); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,166 +1,213 @@ |
|||||||
/** |
import { |
||||||
* 年季度展示面板 |
shortcut, |
||||||
* |
Widget, |
||||||
* Created by GUY on 2015/9/2. |
i18nText, |
||||||
* @class BI.YearCard |
bind, |
||||||
* @extends BI.Trigger |
VerticalLayout, |
||||||
*/ |
parseDateTime, |
||||||
BI.DynamicYearQuarterCard = BI.inherit(BI.Widget, { |
extend, |
||||||
|
checkDateVoid, |
||||||
props: { |
isNotEmptyString, |
||||||
baseCls: "bi-year-quarter-card" |
getQuarter |
||||||
}, |
} from "@/core"; |
||||||
|
import { DynamicDateCard, DynamicDateParamItem, DynamicDateHelper } from "../dynamicdate"; |
||||||
render: function () { |
import { Label, Bubbles } from "@/base"; |
||||||
var self = this; |
|
||||||
|
@shortcut() |
||||||
|
export class DynamicYearQuarterCard extends Widget { |
||||||
|
static xtype = "bi.dynamic_year_quarter_card"; |
||||||
|
|
||||||
|
props = { baseCls: "bi-year-quarter-card" }; |
||||||
|
|
||||||
|
static EVENT_CHANGE = "EVENT_CHANGE"; |
||||||
|
|
||||||
|
render() { |
||||||
return { |
return { |
||||||
type: "bi.vertical", |
type: VerticalLayout.xtype, |
||||||
items: [{ |
items: [ |
||||||
type: "bi.label", |
{ |
||||||
text: BI.i18nText("BI-Multi_Date_Relative_Current_Time"), |
type: Label.xtype, |
||||||
textAlign: "left", |
text: i18nText("BI-Multi_Date_Relative_Current_Time"), |
||||||
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, |
textAlign: "left", |
||||||
}, { |
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, |
||||||
type: "bi.vertical", |
|
||||||
ref: function (_ref) { |
|
||||||
self.wrapper = _ref; |
|
||||||
}, |
}, |
||||||
items: [{ |
{ |
||||||
el: { |
type: VerticalLayout.xtype, |
||||||
type: "bi.dynamic_date_param_item", |
ref: _ref => { |
||||||
validationChecker: BI.bind(self._checkDate, self), |
this.wrapper = _ref; |
||||||
ref: function () { |
|
||||||
self.year = this; |
|
||||||
}, |
|
||||||
listeners: [{ |
|
||||||
eventName: "EVENT_CHANGE", |
|
||||||
action: function () { |
|
||||||
self.fireEvent("EVENT_CHANGE"); |
|
||||||
} |
|
||||||
}, { |
|
||||||
eventName: "EVENT_INPUT_CHANGE", |
|
||||||
action: function () { |
|
||||||
BI.Bubbles.hide("dynamic-year-quarter-error"); |
|
||||||
} |
|
||||||
}] |
|
||||||
}, |
|
||||||
bgap: 10 |
|
||||||
}, { |
|
||||||
type: "bi.dynamic_date_param_item", |
|
||||||
dateType: BI.DynamicDateCard.TYPE.QUARTER, |
|
||||||
ref: function () { |
|
||||||
self.quarter = this; |
|
||||||
}, |
}, |
||||||
listeners: [{ |
items: [ |
||||||
eventName: "EVENT_CHANGE", |
{ |
||||||
action: function () { |
el: { |
||||||
self.fireEvent("EVENT_CHANGE"); |
type: DynamicDateParamItem.xtype, |
||||||
} |
validationChecker: bind(this._checkDate, this), |
||||||
}, { |
ref: _ref => { |
||||||
eventName: "EVENT_INPUT_CHANGE", |
this.year = _ref; |
||||||
action: function () { |
}, |
||||||
BI.Bubbles.hide("dynamic-year-quarter-error"); |
listeners: [ |
||||||
|
{ |
||||||
|
eventName: "EVENT_CHANGE", |
||||||
|
action: () => { |
||||||
|
this.fireEvent("EVENT_CHANGE"); |
||||||
|
}, |
||||||
|
}, |
||||||
|
{ |
||||||
|
eventName: "EVENT_INPUT_CHANGE", |
||||||
|
action: () => { |
||||||
|
Bubbles.hide( |
||||||
|
"dynamic-year-quarter-error" |
||||||
|
); |
||||||
|
}, |
||||||
|
} |
||||||
|
], |
||||||
|
}, |
||||||
|
bgap: 10, |
||||||
|
}, |
||||||
|
{ |
||||||
|
type: DynamicDateParamItem.xtype, |
||||||
|
dateType: DynamicDateCard.TYPE.QUARTER, |
||||||
|
ref: _ref => { |
||||||
|
this.quarter = _ref; |
||||||
|
}, |
||||||
|
listeners: [ |
||||||
|
{ |
||||||
|
eventName: "EVENT_CHANGE", |
||||||
|
action: () => { |
||||||
|
this.fireEvent("EVENT_CHANGE"); |
||||||
|
}, |
||||||
|
}, |
||||||
|
{ |
||||||
|
eventName: "EVENT_INPUT_CHANGE", |
||||||
|
action: () => { |
||||||
|
Bubbles.hide( |
||||||
|
"dynamic-year-quarter-error" |
||||||
|
); |
||||||
|
}, |
||||||
|
} |
||||||
|
], |
||||||
} |
} |
||||||
}] |
], |
||||||
}] |
} |
||||||
}], |
], |
||||||
vgap: 10, |
vgap: 10, |
||||||
hgap: 10 |
hgap: 10, |
||||||
}; |
}; |
||||||
}, |
} |
||||||
|
|
||||||
_getErrorText: function () { |
_getErrorText() { |
||||||
var o = this.options; |
const o = this.options; |
||||||
var start = BI.parseDateTime(o.min, "%Y-%X-%d"); |
const start = parseDateTime(o.min, "%Y-%X-%d"); |
||||||
var end = BI.parseDateTime(o.max, "%Y-%X-%d"); |
const end = parseDateTime(o.max, "%Y-%X-%d"); |
||||||
return BI.i18nText("BI-Basic_Year_Quarter_Range_Error", |
|
||||||
|
return i18nText( |
||||||
|
"BI-Basic_Year_Quarter_Range_Error", |
||||||
start.getFullYear(), |
start.getFullYear(), |
||||||
BI.getQuarter(start), |
getQuarter(start), |
||||||
end.getFullYear(), |
end.getFullYear(), |
||||||
BI.getQuarter(end) |
getQuarter(end) |
||||||
); |
); |
||||||
}, |
} |
||||||
|
|
||||||
_checkDate: function (obj) { |
_checkDate(obj) { |
||||||
var o = this.options; |
const o = this.options; |
||||||
var date = BI.DynamicDateHelper.getCalculation(BI.extend(this._getValue(), this._digestDateTypeValue(obj))); |
const date = DynamicDateHelper.getCalculation( |
||||||
|
extend(this._getValue(), this._digestDateTypeValue(obj)) |
||||||
|
); |
||||||
|
|
||||||
return !BI.checkDateVoid(date.getFullYear(), date.getMonth() + 1, date.getDate(), o.min, o.max)[0]; |
return !checkDateVoid( |
||||||
}, |
date.getFullYear(), |
||||||
|
date.getMonth() + 1, |
||||||
|
date.getDate(), |
||||||
|
o.min, |
||||||
|
o.max |
||||||
|
)[0]; |
||||||
|
} |
||||||
|
|
||||||
_digestDateTypeValue: function (value) { |
_digestDateTypeValue(value) { |
||||||
var valueMap = {}; |
const valueMap = {}; |
||||||
switch (value.dateType) { |
switch (value.dateType) { |
||||||
case BI.DynamicDateCard.TYPE.YEAR: |
case DynamicDateCard.TYPE.YEAR: |
||||||
valueMap.year = (value.offset === 0 ? -value.value : +value.value); |
valueMap.year = |
||||||
break; |
value.offset === 0 ? -value.value : +value.value; |
||||||
case BI.DynamicDateCard.TYPE.QUARTER: |
break; |
||||||
valueMap.quarter = (value.offset === 0 ? -value.value : +value.value); |
case DynamicDateCard.TYPE.QUARTER: |
||||||
break; |
valueMap.quarter = |
||||||
default: |
value.offset === 0 ? -value.value : +value.value; |
||||||
break; |
break; |
||||||
|
default: |
||||||
|
break; |
||||||
} |
} |
||||||
|
|
||||||
return valueMap; |
return valueMap; |
||||||
}, |
} |
||||||
|
|
||||||
_createValue: function (type, v) { |
_createValue(type, v) { |
||||||
return { |
return { |
||||||
dateType: type, |
dateType: type, |
||||||
value: Math.abs(v), |
value: Math.abs(v), |
||||||
offset: v > 0 ? 1 : 0 |
offset: v > 0 ? 1 : 0, |
||||||
}; |
}; |
||||||
}, |
} |
||||||
|
|
||||||
setMinDate: function(minDate) { |
setMinDate(minDate) { |
||||||
if (BI.isNotEmptyString(this.options.min)) { |
if (isNotEmptyString(this.options.min)) { |
||||||
this.options.min = minDate; |
this.options.min = minDate; |
||||||
} |
} |
||||||
}, |
} |
||||||
|
|
||||||
setMaxDate: function (maxDate) { |
setMaxDate(maxDate) { |
||||||
if (BI.isNotEmptyString(this.options.max)) { |
if (isNotEmptyString(this.options.max)) { |
||||||
this.options.max = maxDate; |
this.options.max = maxDate; |
||||||
} |
} |
||||||
}, |
} |
||||||
|
|
||||||
setValue: function (v) { |
setValue(v) { |
||||||
v = v || {year: 0, quarter: 0}; |
v = v || { year: 0, quarter: 0 }; |
||||||
this.year.setValue(this._createValue(BI.DynamicDateCard.TYPE.YEAR, v.year)); |
this.year.setValue( |
||||||
this.quarter.setValue(this._createValue(BI.DynamicDateCard.TYPE.QUARTER, v.quarter)); |
this._createValue(DynamicDateCard.TYPE.YEAR, v.year) |
||||||
}, |
); |
||||||
|
this.quarter.setValue( |
||||||
|
this._createValue(DynamicDateCard.TYPE.QUARTER, v.quarter) |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
_getValue: function () { |
_getValue() { |
||||||
var year = this.year.getValue(); |
const year = this.year.getValue(); |
||||||
var quarter = this.quarter.getValue(); |
const quarter = this.quarter.getValue(); |
||||||
|
|
||||||
return { |
return { |
||||||
year: (year.offset === 0 ? -year.value : year.value), |
year: year.offset === 0 ? -year.value : year.value, |
||||||
quarter: (quarter.offset === 0 ? -quarter.value : quarter.value) |
quarter: quarter.offset === 0 ? -quarter.value : quarter.value, |
||||||
}; |
}; |
||||||
}, |
} |
||||||
|
|
||||||
getInputValue: function () { |
getInputValue() { |
||||||
return this._getValue(); |
return this._getValue(); |
||||||
}, |
} |
||||||
|
|
||||||
getValue: function () { |
getValue() { |
||||||
return this.checkValidation() ? this._getValue() : {}; |
return this.checkValidation() ? this._getValue() : {}; |
||||||
}, |
} |
||||||
|
|
||||||
checkValidation: function (show) { |
checkValidation(show) { |
||||||
var errorText; |
let errorText; |
||||||
var yearInvalid = !this.year.checkValidation(); |
const yearInvalid = !this.year.checkValidation(); |
||||||
var quarterInvalid = !this.quarter.checkValidation(); |
const quarterInvalid = !this.quarter.checkValidation(); |
||||||
var invalid = yearInvalid || quarterInvalid; |
let invalid = yearInvalid || quarterInvalid; |
||||||
if (invalid) { |
if (invalid) { |
||||||
errorText = BI.i18nText("BI-Please_Input_Natural_Number"); |
errorText = i18nText("BI-Please_Input_Natural_Number"); |
||||||
} else { |
} else { |
||||||
invalid = !this._checkDate(this._getValue()); |
invalid = !this._checkDate(this._getValue()); |
||||||
errorText = this._getErrorText(); |
errorText = this._getErrorText(); |
||||||
} |
} |
||||||
invalid && show && BI.Bubbles.show("dynamic-year-quarter-error", errorText, this.wrapper); |
invalid && |
||||||
|
show && |
||||||
|
Bubbles.show( |
||||||
|
"dynamic-year-quarter-error", |
||||||
|
errorText, |
||||||
|
this.wrapper |
||||||
|
); |
||||||
|
|
||||||
return !invalid; |
return !invalid; |
||||||
}, |
} |
||||||
}); |
} |
||||||
BI.DynamicYearQuarterCard.EVENT_CHANGE = "EVENT_CHANGE"; |
|
||||||
BI.shortcut("bi.dynamic_year_quarter_card", BI.DynamicYearQuarterCard); |
|
||||||
|
@ -1,152 +1,190 @@ |
|||||||
BI.StaticYearQuarterCard = BI.inherit(BI.Widget, { |
import { |
||||||
|
shortcut, |
||||||
|
Widget, |
||||||
|
map, |
||||||
|
extend, |
||||||
|
VerticalLayout, |
||||||
|
parseDateTime, |
||||||
|
parseInt, |
||||||
|
each, |
||||||
|
checkDateVoid, |
||||||
|
getDate, |
||||||
|
getQuarterName, |
||||||
|
getQuarter |
||||||
|
} from "@/core"; |
||||||
|
import { TextItem, ButtonGroup } from "@/base"; |
||||||
|
import { YearPicker } from "../date/calendar"; |
||||||
|
|
||||||
props: { |
@shortcut() |
||||||
baseCls: "bi-static-year-quarter-card", |
export class StaticYearQuarterCard extends Widget { |
||||||
behaviors: {} |
static xtype = "bi.static_year_quarter_card"; |
||||||
}, |
|
||||||
|
|
||||||
_createQuarter: function () { |
props = { baseCls: "bi-static-year-quarter-card", behaviors: {} }; |
||||||
var self = this; |
|
||||||
var items = [{ |
static EVENT_CHANGE = "EVENT_CHANGE"; |
||||||
text: BI.getQuarterName(1), |
|
||||||
value: 1 |
_createQuarter() { |
||||||
}, { |
const items = [ |
||||||
text: BI.getQuarterName(2), |
{ |
||||||
value: 2 |
text: getQuarterName(1), |
||||||
}, { |
value: 1, |
||||||
text: BI.getQuarterName(3), |
}, |
||||||
value: 3 |
{ |
||||||
}, { |
text: getQuarterName(2), |
||||||
text: BI.getQuarterName(4), |
value: 2, |
||||||
value: 4 |
}, |
||||||
}]; |
{ |
||||||
return BI.map(items, function (j, item) { |
text: getQuarterName(3), |
||||||
return BI.extend(item, { |
value: 3, |
||||||
type: "bi.text_item", |
}, |
||||||
cls: "bi-border-radius bi-list-item-select", |
{ |
||||||
textAlign: "center", |
text: getQuarterName(4), |
||||||
whiteSpace: "nowrap", |
value: 4, |
||||||
once: false, |
} |
||||||
forceSelected: true, |
]; |
||||||
height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, |
|
||||||
ref: function (_ref) { |
return map(items, (j, item) => extend(item, { |
||||||
self.quarterMap[j + 1] = _ref; |
type: TextItem.xtype, |
||||||
} |
cls: "bi-border-radius bi-list-item-select", |
||||||
}); |
textAlign: "center", |
||||||
}); |
whiteSpace: "nowrap", |
||||||
}, |
once: false, |
||||||
|
forceSelected: true, |
||||||
|
height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, |
||||||
|
ref: _ref => { |
||||||
|
this.quarterMap[j + 1] = _ref; |
||||||
|
}, |
||||||
|
})); |
||||||
|
} |
||||||
|
|
||||||
render: function () { |
render() { |
||||||
var self = this, o = this.options; |
const o = this.options; |
||||||
this.quarterMap = {}; |
this.quarterMap = {}; |
||||||
|
|
||||||
return { |
return { |
||||||
type: "bi.vertical", |
type: VerticalLayout.xtype, |
||||||
items: [{ |
items: [ |
||||||
type: "bi.year_picker", |
{ |
||||||
cls: "bi-split-bottom", |
type: YearPicker.xtype, |
||||||
ref: function () { |
cls: "bi-split-bottom", |
||||||
self.yearPicker = this; |
ref: _ref => { |
||||||
}, |
this.yearPicker = _ref; |
||||||
min: o.min, |
|
||||||
max: o.max, |
|
||||||
behaviors: o.behaviors, |
|
||||||
height: 30, |
|
||||||
listeners: [{ |
|
||||||
eventName: BI.YearPicker.EVENT_CHANGE, |
|
||||||
action: function () { |
|
||||||
var value = this.getValue(); |
|
||||||
self._checkQuarterStatus(value); |
|
||||||
self.setValue({ |
|
||||||
year: value, |
|
||||||
quarter: self.selectedQuarter |
|
||||||
}); |
|
||||||
} |
|
||||||
}] |
|
||||||
}, { |
|
||||||
el: { |
|
||||||
type: "bi.button_group", |
|
||||||
behaviors: o.behaviors, |
|
||||||
ref: function () { |
|
||||||
self.quarter = this; |
|
||||||
}, |
}, |
||||||
items: this._createQuarter(), |
min: o.min, |
||||||
layouts: [{ |
max: o.max, |
||||||
type: "bi.vertical", |
behaviors: o.behaviors, |
||||||
vgap: 10, |
height: 30, |
||||||
hgap: 12, |
listeners: [ |
||||||
}], |
{ |
||||||
value: o.value, |
eventName: YearPicker.EVENT_CHANGE, |
||||||
listeners: [{ |
action: () => { |
||||||
eventName: BI.ButtonGroup.EVENT_CHANGE, |
const value = this.yearPicker.getValue(); |
||||||
action: function () { |
this._checkQuarterStatus(value); |
||||||
self.selectedYear = self.yearPicker.getValue(); |
this.setValue({ |
||||||
self.selectedQuarter = this.getValue()[0]; |
year: value, |
||||||
self.fireEvent(BI.StaticYearQuarterCard.EVENT_CHANGE); |
quarter: this.selectedQuarter, |
||||||
|
}); |
||||||
|
}, |
||||||
} |
} |
||||||
}] |
], |
||||||
}, |
}, |
||||||
vgap: 5 |
{ |
||||||
}] |
el: { |
||||||
|
type: ButtonGroup.xtype, |
||||||
|
behaviors: o.behaviors, |
||||||
|
ref: _ref => { |
||||||
|
this.quarter = _ref; |
||||||
|
}, |
||||||
|
items: this._createQuarter(), |
||||||
|
layouts: [ |
||||||
|
{ |
||||||
|
type: VerticalLayout.xtype, |
||||||
|
vgap: 10, |
||||||
|
hgap: 12, |
||||||
|
} |
||||||
|
], |
||||||
|
value: o.value, |
||||||
|
listeners: [ |
||||||
|
{ |
||||||
|
eventName: ButtonGroup.EVENT_CHANGE, |
||||||
|
action: () => { |
||||||
|
this.selectedYear = |
||||||
|
this.yearPicker.getValue(); |
||||||
|
this.selectedQuarter = this.quarter.getValue()[0]; |
||||||
|
this.fireEvent( |
||||||
|
StaticYearQuarterCard.EVENT_CHANGE |
||||||
|
); |
||||||
|
}, |
||||||
|
} |
||||||
|
], |
||||||
|
}, |
||||||
|
vgap: 5, |
||||||
|
} |
||||||
|
], |
||||||
}; |
}; |
||||||
}, |
} |
||||||
|
|
||||||
_checkQuarterStatus: function (year) { |
_checkQuarterStatus(year) { |
||||||
var o = this.options; |
const o = this.options; |
||||||
var minDate = BI.parseDateTime(o.min, "%Y-%X-%d"), maxDate = BI.parseDateTime(o.max, "%Y-%X-%d"); |
const minDate = parseDateTime(o.min, "%Y-%X-%d"), |
||||||
var minYear = minDate.getFullYear(), maxYear = maxDate.getFullYear(); |
maxDate = parseDateTime(o.max, "%Y-%X-%d"); |
||||||
var minQuarter = 1; var maxQuarter = 4; |
const minYear = minDate.getFullYear(), |
||||||
minYear === year && (minQuarter = BI.parseInt(BI.getQuarter(minDate))); |
maxYear = maxDate.getFullYear(); |
||||||
maxYear === year && (maxQuarter = BI.parseInt(BI.getQuarter(maxDate))); |
let minQuarter = 1; |
||||||
var yearInvalid = year < minYear || year > maxYear; |
let maxQuarter = 4; |
||||||
BI.each(this.quarterMap, function (quarter, obj) { |
minYear === year && (minQuarter = parseInt(getQuarter(minDate))); |
||||||
var quarterInvalid = quarter < minQuarter || quarter > maxQuarter; |
maxYear === year && (maxQuarter = parseInt(getQuarter(maxDate))); |
||||||
|
const yearInvalid = year < minYear || year > maxYear; |
||||||
|
each(this.quarterMap, (quarter, obj) => { |
||||||
|
const quarterInvalid = quarter < minQuarter || quarter > maxQuarter; |
||||||
obj.setEnable(!yearInvalid && !quarterInvalid); |
obj.setEnable(!yearInvalid && !quarterInvalid); |
||||||
}); |
}); |
||||||
}, |
} |
||||||
|
|
||||||
setMinDate: function (minDate) { |
setMinDate(minDate) { |
||||||
if (this.options.min !== minDate) { |
if (this.options.min !== minDate) { |
||||||
this.options.min = minDate; |
this.options.min = minDate; |
||||||
this.yearPicker.setMinDate(minDate); |
this.yearPicker.setMinDate(minDate); |
||||||
this._checkQuarterStatus(this.selectedYear); |
this._checkQuarterStatus(this.selectedYear); |
||||||
} |
} |
||||||
}, |
} |
||||||
|
|
||||||
setMaxDate: function (maxDate) { |
setMaxDate(maxDate) { |
||||||
if (this.options.max !== maxDate) { |
if (this.options.max !== maxDate) { |
||||||
this.options.max = maxDate; |
this.options.max = maxDate; |
||||||
this.yearPicker.setMaxDate(maxDate); |
this.yearPicker.setMaxDate(maxDate); |
||||||
this._checkQuarterStatus(this.selectedYear); |
this._checkQuarterStatus(this.selectedYear); |
||||||
} |
} |
||||||
}, |
} |
||||||
|
|
||||||
|
|
||||||
getValue: function () { |
getValue() { |
||||||
return { |
return { |
||||||
year: this.selectedYear, |
year: this.selectedYear, |
||||||
quarter: this.selectedQuarter |
quarter: this.selectedQuarter, |
||||||
}; |
}; |
||||||
}, |
} |
||||||
|
|
||||||
setValue: function (obj) { |
setValue(obj) { |
||||||
var o = this.options; |
const o = this.options; |
||||||
var newObj = {}; |
const newObj = {}; |
||||||
newObj.year = obj.year || 0; |
newObj.year = obj.year || 0; |
||||||
newObj.quarter = obj.quarter || 0; |
newObj.quarter = obj.quarter || 0; |
||||||
if (newObj.quarter === 0 || newObj.year === 0 || BI.checkDateVoid(newObj.year, newObj.quarter, 1, o.min, o.max)[0]) { |
if ( |
||||||
var year = newObj.year || BI.getDate().getFullYear(); |
newObj.quarter === 0 || |
||||||
|
newObj.year === 0 || |
||||||
|
checkDateVoid(newObj.year, newObj.quarter, 1, o.min, o.max)[0] |
||||||
|
) { |
||||||
|
const year = newObj.year || getDate().getFullYear(); |
||||||
this.selectedYear = year; |
this.selectedYear = year; |
||||||
this.selectedQuarter = ""; |
this.selectedQuarter = ""; |
||||||
this.yearPicker.setValue(year); |
this.yearPicker.setValue(year); |
||||||
this.quarter.setValue(); |
this.quarter.setValue(); |
||||||
} else { |
} else { |
||||||
this.selectedYear = BI.parseInt(newObj.year); |
this.selectedYear = parseInt(newObj.year); |
||||||
this.selectedQuarter = BI.parseInt(newObj.quarter); |
this.selectedQuarter = parseInt(newObj.quarter); |
||||||
this.yearPicker.setValue(this.selectedYear); |
this.yearPicker.setValue(this.selectedYear); |
||||||
this.quarter.setValue(this.selectedQuarter); |
this.quarter.setValue(this.selectedQuarter); |
||||||
} |
} |
||||||
this._checkQuarterStatus(this.selectedYear); |
this._checkQuarterStatus(this.selectedYear); |
||||||
} |
} |
||||||
}); |
} |
||||||
BI.StaticYearQuarterCard.EVENT_CHANGE = "EVENT_CHANGE"; |
|
||||||
BI.shortcut("bi.static_year_quarter_card", BI.StaticYearQuarterCard); |
|
||||||
|
@ -0,0 +1,6 @@ |
|||||||
|
export { DynamicYearQuarterCard } from "./card.dynamic.yearquarter"; |
||||||
|
export { StaticYearQuarterCard } from "./card.static.yearquarter"; |
||||||
|
export { DynamicYearQuarterCombo } from "./combo.yearquarter"; |
||||||
|
export { DynamicYearQuarterPopup } from "./popup.yearquarter"; |
||||||
|
export { DynamicYearQuarterTrigger } from "./trigger.yearquarter"; |
||||||
|
|
@ -1,235 +1,328 @@ |
|||||||
BI.DynamicYearQuarterPopup = BI.inherit(BI.Widget, { |
import { |
||||||
constants: { |
shortcut, |
||||||
tabHeight: 40, |
Widget, |
||||||
buttonHeight: 24 |
toPix, |
||||||
}, |
i18nText, |
||||||
|
VerticalLayout, |
||||||
|
GridLayout, |
||||||
|
print, |
||||||
|
getDate, |
||||||
|
checkDateVoid, |
||||||
|
createItems, |
||||||
|
getQuarter |
||||||
|
} from "@/core"; |
||||||
|
import { DynamicYearQuarterCombo } from "./combo.yearquarter"; |
||||||
|
import { TextButton, Tab } from "@/base"; |
||||||
|
import { DynamicDateCombo, DynamicDatePopup, DynamicDateHelper } from "../dynamicdate"; |
||||||
|
// TODO:需要等待year完成才能将BI.DynamicYearCard替换
|
||||||
|
// import { DynamicYearCard } from "../year/card.dynamic.year";
|
||||||
|
import { LinearSegment } from "@/case"; |
||||||
|
import { DynamicYearQuarterCard } from "./card.dynamic.yearquarter"; |
||||||
|
import { StaticYearQuarterCard } from "./card.static.yearquarter"; |
||||||
|
|
||||||
props: { |
@shortcut() |
||||||
|
export class DynamicYearQuarterPopup extends Widget { |
||||||
|
static xtype = "bi.dynamic_year_quarter_popup"; |
||||||
|
|
||||||
|
constants = { tabHeight: 40, buttonHeight: 24 }; |
||||||
|
props = { |
||||||
baseCls: "bi-year-quarter-popup", |
baseCls: "bi-year-quarter-popup", |
||||||
behaviors: {}, |
behaviors: {}, |
||||||
min: "1900-01-01", // 最小日期
|
min: "1900-01-01", |
||||||
max: "2099-12-31", // 最大日期,
|
max: "2099-12-31", |
||||||
width: 180, |
width: 180, |
||||||
supportDynamic: true, |
supportDynamic: true, |
||||||
}, |
}; |
||||||
|
|
||||||
|
static BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE"; |
||||||
|
static BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE"; |
||||||
|
static BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE"; |
||||||
|
static EVENT_CHANGE = "EVENT_CHANGE"; |
||||||
|
|
||||||
render: function () { |
render() { |
||||||
var self = this, opts = this.options, c = this.constants; |
this.storeValue = { type: DynamicYearQuarterCombo.Static }; |
||||||
this.storeValue = {type: BI.DynamicYearQuarterCombo.Static}; |
|
||||||
return { |
return { |
||||||
type: "bi.vertical", |
type: VerticalLayout.xtype, |
||||||
items: [{ |
items: [ |
||||||
el: this._getTabJson() |
{ |
||||||
}, { |
el: this._getTabJson(), |
||||||
el: { |
|
||||||
type: "bi.grid", |
|
||||||
items: [[{ |
|
||||||
type: "bi.text_button", |
|
||||||
cls: "bi-split-top bi-high-light", |
|
||||||
shadow: true, |
|
||||||
textHeight: BI.toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1), |
|
||||||
text: BI.i18nText("BI-Basic_Clear"), |
|
||||||
listeners: [{ |
|
||||||
eventName: BI.TextButton.EVENT_CHANGE, |
|
||||||
action: function () { |
|
||||||
self.fireEvent(BI.DynamicYearQuarterPopup.BUTTON_CLEAR_EVENT_CHANGE); |
|
||||||
} |
|
||||||
}] |
|
||||||
}, { |
|
||||||
type: "bi.text_button", |
|
||||||
cls: "bi-split-left bi-split-right bi-high-light bi-split-top", |
|
||||||
textHeight: BI.toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1), |
|
||||||
shadow: true, |
|
||||||
text: BI.i18nText("BI-Basic_Current_Quarter"), |
|
||||||
disabled: this._checkTodayValid(), |
|
||||||
ref: function () { |
|
||||||
self.textButton = this; |
|
||||||
}, |
|
||||||
listeners: [{ |
|
||||||
eventName: BI.TextButton.EVENT_CHANGE, |
|
||||||
action: function () { |
|
||||||
self.fireEvent(BI.DynamicYearQuarterPopup.BUTTON_lABEL_EVENT_CHANGE); |
|
||||||
} |
|
||||||
}] |
|
||||||
}, { |
|
||||||
type: "bi.text_button", |
|
||||||
cls: "bi-split-top bi-high-light", |
|
||||||
shadow: true, |
|
||||||
textHeight: BI.toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1), |
|
||||||
text: BI.i18nText("BI-Basic_OK"), |
|
||||||
listeners: [{ |
|
||||||
eventName: BI.TextButton.EVENT_CHANGE, |
|
||||||
action: function () { |
|
||||||
var type = self.dateTab.getSelect(); |
|
||||||
if (type === BI.DynamicDateCombo.Dynamic) { |
|
||||||
self.dynamicPane.checkValidation(true) && self.fireEvent(BI.DynamicDatePopup.BUTTON_OK_EVENT_CHANGE); |
|
||||||
} else { |
|
||||||
self.fireEvent(BI.DynamicYearQuarterPopup.BUTTON_OK_EVENT_CHANGE); |
|
||||||
} |
|
||||||
} |
|
||||||
}] |
|
||||||
}]], |
|
||||||
height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT |
|
||||||
}, |
}, |
||||||
}] |
{ |
||||||
|
el: { |
||||||
|
type: GridLayout.xtype, |
||||||
|
items: [ |
||||||
|
[ |
||||||
|
{ |
||||||
|
type: TextButton.xtype, |
||||||
|
cls: "bi-split-top bi-high-light", |
||||||
|
shadow: true, |
||||||
|
textHeight: toPix( |
||||||
|
BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, |
||||||
|
1 |
||||||
|
), |
||||||
|
text: i18nText("BI-Basic_Clear"), |
||||||
|
listeners: [ |
||||||
|
{ |
||||||
|
eventName: TextButton.EVENT_CHANGE, |
||||||
|
action: () => { |
||||||
|
this.fireEvent( |
||||||
|
DynamicYearQuarterPopup.BUTTON_CLEAR_EVENT_CHANGE |
||||||
|
); |
||||||
|
}, |
||||||
|
} |
||||||
|
], |
||||||
|
}, |
||||||
|
{ |
||||||
|
type: TextButton.xtype, |
||||||
|
cls: "bi-split-left bi-split-right bi-high-light bi-split-top", |
||||||
|
textHeight: toPix( |
||||||
|
BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, |
||||||
|
1 |
||||||
|
), |
||||||
|
shadow: true, |
||||||
|
text: i18nText("BI-Basic_Current_Quarter"), |
||||||
|
disabled: this._checkTodayValid(), |
||||||
|
ref: _ref => { |
||||||
|
this.textButton = _ref; |
||||||
|
}, |
||||||
|
listeners: [ |
||||||
|
{ |
||||||
|
eventName: TextButton.EVENT_CHANGE, |
||||||
|
action: () => { |
||||||
|
this.fireEvent( |
||||||
|
DynamicYearQuarterPopup.BUTTON_lABEL_EVENT_CHANGE |
||||||
|
); |
||||||
|
}, |
||||||
|
} |
||||||
|
], |
||||||
|
}, |
||||||
|
{ |
||||||
|
type: TextButton.xtype, |
||||||
|
cls: "bi-split-top bi-high-light", |
||||||
|
shadow: true, |
||||||
|
textHeight: toPix( |
||||||
|
BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, |
||||||
|
1 |
||||||
|
), |
||||||
|
text: i18nText("BI-Basic_OK"), |
||||||
|
listeners: [ |
||||||
|
{ |
||||||
|
eventName: TextButton.EVENT_CHANGE, |
||||||
|
action: () => { |
||||||
|
const type = |
||||||
|
this.dateTab.getSelect(); |
||||||
|
if ( |
||||||
|
type === |
||||||
|
DynamicDateCombo.Dynamic |
||||||
|
) { |
||||||
|
this.dynamicPane.checkValidation( |
||||||
|
true |
||||||
|
) && |
||||||
|
this.fireEvent( |
||||||
|
DynamicDatePopup.BUTTON_OK_EVENT_CHANGE |
||||||
|
); |
||||||
|
} else { |
||||||
|
this.fireEvent(DynamicYearQuarterPopup |
||||||
|
.BUTTON_OK_EVENT_CHANGE |
||||||
|
); |
||||||
|
} |
||||||
|
}, |
||||||
|
} |
||||||
|
], |
||||||
|
} |
||||||
|
] |
||||||
|
], |
||||||
|
height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, |
||||||
|
}, |
||||||
|
} |
||||||
|
], |
||||||
}; |
}; |
||||||
}, |
} |
||||||
|
|
||||||
_setInnerValue: function () { |
_setInnerValue() { |
||||||
if (this.dateTab.getSelect() === BI.DynamicYearQuarterCombo.Static) { |
if (this.dateTab.getSelect() === DynamicYearQuarterCombo.Static) { |
||||||
this.textButton.setValue(BI.i18nText("BI-Basic_Current_Quarter")); |
this.textButton.setValue(i18nText("BI-Basic_Current_Quarter")); |
||||||
this.textButton.setEnable(!this._checkTodayValid()); |
this.textButton.setEnable(!this._checkTodayValid()); |
||||||
} else { |
} else { |
||||||
var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getInputValue()); |
let date = DynamicDateHelper.getCalculation( |
||||||
date = BI.print(date, "%Y-%Q"); |
this.dynamicPane.getInputValue() |
||||||
|
); |
||||||
|
date = print(date, "%Y-%Q"); |
||||||
this.textButton.setValue(date); |
this.textButton.setValue(date); |
||||||
this.textButton.setEnable(false); |
this.textButton.setEnable(false); |
||||||
} |
} |
||||||
}, |
} |
||||||
|
|
||||||
_checkTodayValid: function () { |
_checkTodayValid() { |
||||||
var o = this.options; |
const o = this.options; |
||||||
var today = BI.getDate(); |
const today = getDate(); |
||||||
return !!BI.checkDateVoid(today.getFullYear(), today.getMonth() + 1, today.getDate(), o.min, o.max)[0]; |
|
||||||
}, |
return !!checkDateVoid( |
||||||
|
today.getFullYear(), |
||||||
|
today.getMonth() + 1, |
||||||
|
today.getDate(), |
||||||
|
o.min, |
||||||
|
o.max |
||||||
|
)[0]; |
||||||
|
} |
||||||
|
|
||||||
_getTabJson: function () { |
_getTabJson() { |
||||||
var self = this, o = this.options; |
const o = this.options; |
||||||
|
|
||||||
return { |
return { |
||||||
type: "bi.tab", |
type: Tab.xtype, |
||||||
logic: { |
logic: { |
||||||
dynamic: true |
dynamic: true, |
||||||
}, |
}, |
||||||
ref: function () { |
ref: _ref => { |
||||||
self.dateTab = this; |
this.dateTab = _ref; |
||||||
}, |
}, |
||||||
tab: { |
tab: { |
||||||
type: "bi.linear_segment", |
type: LinearSegment.xtype, |
||||||
cls: "bi-split-bottom", |
cls: "bi-split-bottom", |
||||||
invisible: !o.supportDynamic, |
invisible: !o.supportDynamic, |
||||||
height: this.constants.tabHeight, |
height: this.constants.tabHeight, |
||||||
items: BI.createItems([{ |
items: createItems( |
||||||
text: BI.i18nText("BI-Basic_Year_Quarter"), |
[ |
||||||
value: BI.DynamicYearQuarterCombo.Static |
{ |
||||||
}, { |
text: i18nText("BI-Basic_Year_Quarter"), |
||||||
text: BI.i18nText("BI-Basic_Dynamic_Title"), |
value: DynamicYearQuarterCombo.Static, |
||||||
value: BI.DynamicYearQuarterCombo.Dynamic |
}, |
||||||
}], { |
{ |
||||||
textAlign: "center" |
text: i18nText("BI-Basic_Dynamic_Title"), |
||||||
}) |
value: DynamicYearQuarterCombo.Dynamic, |
||||||
|
} |
||||||
|
], |
||||||
|
{ |
||||||
|
textAlign: "center", |
||||||
|
} |
||||||
|
), |
||||||
}, |
}, |
||||||
cardCreator: function (v) { |
cardCreator: v => { |
||||||
switch (v) { |
switch (v) { |
||||||
case BI.DynamicYearQuarterCombo.Dynamic: |
case DynamicYearQuarterCombo.Dynamic: |
||||||
return { |
return { |
||||||
type: "bi.dynamic_year_quarter_card", |
type: DynamicYearQuarterCard.xtype, |
||||||
cls: "dynamic-year-quarter-pane", |
cls: "dynamic-year-quarter-pane", |
||||||
min: self.options.min, |
min: this.options.min, |
||||||
max: self.options.max, |
max: this.options.max, |
||||||
listeners: [{ |
listeners: [ |
||||||
|
{ |
||||||
eventName: "EVENT_CHANGE", |
eventName: "EVENT_CHANGE", |
||||||
action: function () { |
action: () => { |
||||||
self._setInnerValue(self.year, v); |
this._setInnerValue(this.year, v); |
||||||
} |
}, |
||||||
}], |
|
||||||
ref: function () { |
|
||||||
self.dynamicPane = this; |
|
||||||
} |
} |
||||||
}; |
], |
||||||
case BI.DynamicYearQuarterCombo.Static: |
ref: _ref => { |
||||||
default: |
this.dynamicPane = _ref; |
||||||
return { |
}, |
||||||
type: "bi.static_year_quarter_card", |
}; |
||||||
behaviors: o.behaviors, |
case DynamicYearQuarterCombo.Static: |
||||||
min: self.options.min, |
default: |
||||||
max: self.options.max, |
return { |
||||||
listeners: [{ |
type: StaticYearQuarterCard.xtype, |
||||||
|
behaviors: o.behaviors, |
||||||
|
min: this.options.min, |
||||||
|
max: this.options.max, |
||||||
|
listeners: [ |
||||||
|
{ |
||||||
eventName: BI.DynamicYearCard.EVENT_CHANGE, |
eventName: BI.DynamicYearCard.EVENT_CHANGE, |
||||||
action: function () { |
action: () => { |
||||||
self.fireEvent(BI.DynamicYearQuarterPopup.EVENT_CHANGE); |
this.fireEvent( |
||||||
} |
DynamicYearQuarterPopup.EVENT_CHANGE |
||||||
}], |
); |
||||||
ref: function () { |
}, |
||||||
self.year = this; |
|
||||||
} |
} |
||||||
}; |
], |
||||||
|
ref: _ref => { |
||||||
|
this.year = _ref; |
||||||
|
}, |
||||||
|
}; |
||||||
} |
} |
||||||
}, |
}, |
||||||
listeners: [{ |
listeners: [ |
||||||
eventName: BI.Tab.EVENT_CHANGE, |
{ |
||||||
action: function () { |
eventName: Tab.EVENT_CHANGE, |
||||||
var v = self.dateTab.getSelect(); |
action: () => { |
||||||
switch (v) { |
const v = this.dateTab.getSelect(); |
||||||
case BI.DynamicYearQuarterCombo.Static: |
let date; |
||||||
var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue()); |
switch (v) { |
||||||
self.year.setValue({year: date.getFullYear(), quarter: BI.getQuarter(date)}); |
case DynamicYearQuarterCombo.Static: |
||||||
self._setInnerValue(); |
date = DynamicDateHelper.getCalculation( |
||||||
|
this.dynamicPane.getValue() |
||||||
|
); |
||||||
|
this.year.setValue({ |
||||||
|
year: date.getFullYear(), |
||||||
|
quarter: getQuarter(date), |
||||||
|
}); |
||||||
|
this._setInnerValue(); |
||||||
break; |
break; |
||||||
case BI.DynamicYearQuarterCombo.Dynamic: |
case DynamicYearQuarterCombo.Dynamic: |
||||||
default: |
default: |
||||||
if(self.storeValue && self.storeValue.type === BI.DynamicYearQuarterCombo.Dynamic) { |
if ( |
||||||
self.dynamicPane.setValue(self.storeValue.value); |
this.storeValue && |
||||||
}else{ |
this.storeValue.type === |
||||||
self.dynamicPane.setValue({ |
DynamicYearQuarterCombo.Dynamic |
||||||
year: 0 |
) { |
||||||
|
this.dynamicPane.setValue( |
||||||
|
this.storeValue.value |
||||||
|
); |
||||||
|
} else { |
||||||
|
this.dynamicPane.setValue({ |
||||||
|
year: 0, |
||||||
}); |
}); |
||||||
} |
} |
||||||
self._setInnerValue(); |
this._setInnerValue(); |
||||||
break; |
break; |
||||||
} |
} |
||||||
|
}, |
||||||
} |
} |
||||||
}] |
], |
||||||
}; |
}; |
||||||
}, |
} |
||||||
|
|
||||||
setMinDate: function (minDate) { |
setMinDate(minDate) { |
||||||
if (this.options.min !== minDate) { |
if (this.options.min !== minDate) { |
||||||
this.options.min = minDate; |
this.options.min = minDate; |
||||||
this.year && this.year.setMinDate(minDate); |
this.year && this.year.setMinDate(minDate); |
||||||
this.dynamicPane && this.dynamicPane.setMinDate(minDate); |
this.dynamicPane && this.dynamicPane.setMinDate(minDate); |
||||||
} |
} |
||||||
}, |
} |
||||||
|
|
||||||
setMaxDate: function (maxDate) { |
setMaxDate(maxDate) { |
||||||
if (this.options.max !== maxDate) { |
if (this.options.max !== maxDate) { |
||||||
this.options.max = maxDate; |
this.options.max = maxDate; |
||||||
this.year && this.year.setMaxDate(maxDate); |
this.year && this.year.setMaxDate(maxDate); |
||||||
this.dynamicPane && this.dynamicPane.setMaxDate(maxDate); |
this.dynamicPane && this.dynamicPane.setMaxDate(maxDate); |
||||||
} |
} |
||||||
}, |
} |
||||||
|
|
||||||
setValue: function (v) { |
setValue(v) { |
||||||
this.storeValue = v; |
this.storeValue = v; |
||||||
var self = this; |
|
||||||
var type, value; |
|
||||||
v = v || {}; |
v = v || {}; |
||||||
type = v.type || BI.DynamicDateCombo.Static; |
const type = v.type || DynamicDateCombo.Static; |
||||||
value = v.value || v; |
const value = v.value || v; |
||||||
this.dateTab.setSelect(type); |
this.dateTab.setSelect(type); |
||||||
switch (type) { |
switch (type) { |
||||||
case BI.DynamicDateCombo.Dynamic: |
case DynamicDateCombo.Dynamic: |
||||||
this.dynamicPane.setValue(value); |
this.dynamicPane.setValue(value); |
||||||
self._setInnerValue(); |
this._setInnerValue(); |
||||||
break; |
break; |
||||||
case BI.DynamicDateCombo.Static: |
case DynamicDateCombo.Static: |
||||||
default: |
default: |
||||||
this.year.setValue(value); |
this.year.setValue(value); |
||||||
this.textButton.setValue(BI.i18nText("BI-Basic_Current_Quarter")); |
this.textButton.setValue(i18nText("BI-Basic_Current_Quarter")); |
||||||
this.textButton.setEnable(!this._checkTodayValid()); |
this.textButton.setEnable(!this._checkTodayValid()); |
||||||
break; |
break; |
||||||
} |
} |
||||||
}, |
} |
||||||
|
|
||||||
getValue: function () { |
getValue() { |
||||||
return { |
return { |
||||||
type: this.dateTab.getSelect(), |
type: this.dateTab.getSelect(), |
||||||
value: this.dateTab.getValue() |
value: this.dateTab.getValue(), |
||||||
}; |
}; |
||||||
} |
} |
||||||
|
} |
||||||
}); |
|
||||||
BI.DynamicYearQuarterPopup.BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE"; |
|
||||||
BI.DynamicYearQuarterPopup.BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE"; |
|
||||||
BI.DynamicYearQuarterPopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE"; |
|
||||||
BI.DynamicYearQuarterPopup.EVENT_CHANGE = "EVENT_CHANGE"; |
|
||||||
BI.shortcut("bi.dynamic_year_quarter_popup", BI.DynamicYearQuarterPopup); |
|
||||||
|
@ -1,277 +1,374 @@ |
|||||||
BI.DynamicYearQuarterTrigger = BI.inherit(BI.Trigger, { |
import { |
||||||
_const: { |
shortcut, |
||||||
hgap: 4, |
i18nText, |
||||||
vgap: 2, |
createWidget, |
||||||
iconWidth: 24 |
HTapeLayout, |
||||||
}, |
CenterLayout, |
||||||
|
HorizontalFillLayout, |
||||||
|
isEmptyString, |
||||||
|
parseDateTime, |
||||||
|
isPositiveInteger, |
||||||
|
checkDateVoid, |
||||||
|
isNotEmptyString, |
||||||
|
isNotNull, |
||||||
|
print, |
||||||
|
checkDateLegal, |
||||||
|
isNull, |
||||||
|
parseInt, |
||||||
|
getDate, |
||||||
|
getQuarter |
||||||
|
} from "@/core"; |
||||||
|
import { Trigger, TextButton } from "@/base"; |
||||||
|
import { TriggerIconButton, SignEditor } from "@/case"; |
||||||
|
import { DynamicDateHelper } from "../dynamicdate"; |
||||||
|
// TODO:需要等待yearmonth完成才能将BI.DynamicYearMonthTrigger替换
|
||||||
|
// import { DynamicYearMonthTrigger } from "../yearmonth/trigger.yearmonth";
|
||||||
|
import { DynamicYearQuarterCombo } from "./combo.yearquarter"; |
||||||
|
|
||||||
props: () => ({ |
@shortcut() |
||||||
extraCls: "bi-year-quarter-trigger", |
export class DynamicYearQuarterTrigger extends Trigger { |
||||||
min: "1900-01-01", // 最小日期
|
static xtype = "bi.dynamic_year_quarter_trigger"; |
||||||
max: "2099-12-31", // 最大日期
|
|
||||||
height: 24, |
|
||||||
watermark: { |
|
||||||
year: BI.i18nText("BI-Basic_Unrestricted"), |
|
||||||
quarter: BI.i18nText("BI-Basic_Unrestricted"), |
|
||||||
}, |
|
||||||
}), |
|
||||||
|
|
||||||
_init: function () { |
_const = { hgap: 4, vgap: 2, iconWidth: 24 }; |
||||||
BI.DynamicYearQuarterTrigger.superclass._init.apply(this, arguments); |
|
||||||
var o = this.options; |
static EVENT_FOCUS = "EVENT_FOCUS"; |
||||||
|
static EVENT_ERROR = "EVENT_ERROR"; |
||||||
|
static EVENT_START = "EVENT_START"; |
||||||
|
static EVENT_CONFIRM = "EVENT_CONFIRM"; |
||||||
|
static EVENT_STOP = "EVENT_STOP"; |
||||||
|
static EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; |
||||||
|
static EVENT_VALID = "EVENT_VALID"; |
||||||
|
|
||||||
|
props() { |
||||||
|
return { |
||||||
|
extraCls: "bi-year-quarter-trigger", |
||||||
|
min: "1900-01-01", // 最小日期
|
||||||
|
max: "2099-12-31", // 最大日期
|
||||||
|
height: 24, |
||||||
|
watermark: { |
||||||
|
year: i18nText("BI-Basic_Unrestricted"), |
||||||
|
quarter: i18nText("BI-Basic_Unrestricted"), |
||||||
|
}, |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
_init() { |
||||||
|
super._init(...arguments); |
||||||
|
const o = this.options; |
||||||
this.yearEditor = this._createEditor(true); |
this.yearEditor = this._createEditor(true); |
||||||
this.quarterEditor = this._createEditor(false); |
this.quarterEditor = this._createEditor(false); |
||||||
|
|
||||||
// 暂时的解决方法
|
// 暂时的解决方法
|
||||||
var height = o.height + 2; |
// const height = o.height + 2;
|
||||||
|
|
||||||
BI.createWidget({ |
createWidget({ |
||||||
element: this, |
element: this, |
||||||
type: "bi.htape", |
type: HTapeLayout.xtype, |
||||||
items: [{ |
items: [ |
||||||
type: "bi.center", |
{ |
||||||
items: [{ |
type: CenterLayout.xtype, |
||||||
type: "bi.horizontal_fill", |
items: [ |
||||||
columnSize: ["fill", ""], |
{ |
||||||
items: [this.yearEditor, { |
type: HorizontalFillLayout.xtype, |
||||||
el: { |
columnSize: ["fill", ""], |
||||||
type: "bi.text_button", |
items: [ |
||||||
text: BI.i18nText("BI-Multi_Date_Year"), |
this.yearEditor, |
||||||
}, |
{ |
||||||
}] |
el: { |
||||||
}, { |
type: TextButton.xtype, |
||||||
type: "bi.horizontal_fill", |
text: i18nText("BI-Multi_Date_Year"), |
||||||
columnSize: ["fill", ""], |
}, |
||||||
items: [this.quarterEditor, { |
} |
||||||
el: { |
], |
||||||
type: "bi.text_button", |
|
||||||
text: BI.i18nText("BI-Multi_Date_Quarter"), |
|
||||||
}, |
}, |
||||||
}] |
{ |
||||||
}] |
type: HorizontalFillLayout.xtype, |
||||||
}, { |
columnSize: ["fill", ""], |
||||||
el: { |
items: [ |
||||||
type: "bi.trigger_icon_button", |
this.quarterEditor, |
||||||
width: this._const.iconWidth, |
{ |
||||||
|
el: { |
||||||
|
type: TextButton.xtype, |
||||||
|
text: i18nText("BI-Multi_Date_Quarter"), |
||||||
|
}, |
||||||
|
} |
||||||
|
], |
||||||
|
} |
||||||
|
], |
||||||
}, |
}, |
||||||
width: this._const.iconWidth, |
{ |
||||||
}] |
el: { |
||||||
|
type: TriggerIconButton.xtype, |
||||||
|
width: this._const.iconWidth, |
||||||
|
}, |
||||||
|
width: this._const.iconWidth, |
||||||
|
} |
||||||
|
], |
||||||
}); |
}); |
||||||
this.setValue(o.value); |
this.setValue(o.value); |
||||||
}, |
} |
||||||
|
|
||||||
_createEditor: function (isYear) { |
_createEditor(isYear) { |
||||||
var self = this, o = this.options, c = this._const; |
const o = this.options, |
||||||
var editor = BI.createWidget({ |
c = this._const; |
||||||
type: "bi.sign_editor", |
const editor = createWidget({ |
||||||
|
type: SignEditor.xtype, |
||||||
simple: o.simple, |
simple: o.simple, |
||||||
height: o.height, |
height: o.height, |
||||||
validationChecker: function (v) { |
validationChecker: v => { |
||||||
if(isYear) { |
if (isYear) { |
||||||
var month = self.quarterEditor.getValue(); |
let month = this.quarterEditor.getValue(); |
||||||
if(BI.isEmptyString(month)) { |
if (isEmptyString(month)) { |
||||||
month = parseInt(v, 10) === BI.parseDateTime(o.min, "%Y-%X-%d").getFullYear() ? BI.parseDateTime(o.min, "%Y-%X-%d").getMonth() + 1 : 1; |
month = |
||||||
|
parseInt(v, 10) === |
||||||
|
parseDateTime(o.min, "%Y-%X-%d").getFullYear() |
||||||
|
? parseDateTime(o.min, "%Y-%X-%d").getMonth() + |
||||||
|
1 |
||||||
|
: 1; |
||||||
} else { |
} else { |
||||||
month = (parseInt(month, 10) - 1) * 3 + 1; |
month = (parseInt(month, 10) - 1) * 3 + 1; |
||||||
} |
} |
||||||
return v === "" || (BI.isPositiveInteger(v) && !BI.checkDateVoid(v, month, 1, o.min, o.max)[0]); |
|
||||||
|
return ( |
||||||
|
v === "" || |
||||||
|
(isPositiveInteger(v) && |
||||||
|
!checkDateVoid(v, month, 1, o.min, o.max)[0]) |
||||||
|
); |
||||||
} |
} |
||||||
var year = self.yearEditor.getValue(); |
const year = this.yearEditor.getValue(); |
||||||
|
|
||||||
return v === "" || ((BI.isPositiveInteger(v) && v >= 1 && v <= 4) && (BI.isEmptyString(year) ? true : !BI.checkDateVoid(self.yearEditor.getValue(), (v - 1) * 3 + 1, 1, o.min, o.max)[0])); |
return ( |
||||||
}, |
v === "" || |
||||||
quitChecker: function () { |
(isPositiveInteger(v) && |
||||||
return false; |
v >= 1 && |
||||||
|
v <= 4 && |
||||||
|
(isEmptyString(year) |
||||||
|
? true |
||||||
|
: !checkDateVoid( |
||||||
|
this.yearEditor.getValue(), |
||||||
|
(v - 1) * 3 + 1, |
||||||
|
1, |
||||||
|
o.min, |
||||||
|
o.max |
||||||
|
)[0])) |
||||||
|
); |
||||||
}, |
}, |
||||||
errorText: function (v) { |
quitChecker: () => false, |
||||||
var year = isYear ? v : self.yearEditor.getValue(); |
errorText: v => { |
||||||
var quarter = isYear ? self.quarterEditor.getValue() : v; |
const year = isYear ? v : this.yearEditor.getValue(); |
||||||
if (!BI.isPositiveInteger(year) || !BI.isPositiveInteger(quarter) || quarter > 4) { |
const quarter = isYear ? this.quarterEditor.getValue() : v; |
||||||
return BI.i18nText("BI-Year_Trigger_Invalid_Text"); |
if ( |
||||||
|
!isPositiveInteger(year) || |
||||||
|
!isPositiveInteger(quarter) || |
||||||
|
quarter > 4 |
||||||
|
) { |
||||||
|
return i18nText("BI-Year_Trigger_Invalid_Text"); |
||||||
} |
} |
||||||
|
|
||||||
var start = BI.parseDateTime(o.min, "%Y-%X-%d"); |
const start = parseDateTime(o.min, "%Y-%X-%d"); |
||||||
var end = BI.parseDateTime(o.max, "%Y-%X-%d"); |
const end = parseDateTime(o.max, "%Y-%X-%d"); |
||||||
|
|
||||||
return BI.i18nText("BI-Basic_Year_Quarter_Range_Error", |
return i18nText( |
||||||
|
"BI-Basic_Year_Quarter_Range_Error", |
||||||
start.getFullYear(), |
start.getFullYear(), |
||||||
BI.getQuarter(start), |
getQuarter(start), |
||||||
end.getFullYear(), |
end.getFullYear(), |
||||||
BI.getQuarter(end) |
getQuarter(end) |
||||||
); |
); |
||||||
}, |
}, |
||||||
watermark: isYear ? o.watermark?.year : o.watermark?.quarter, |
watermark: isYear ? o.watermark?.year : o.watermark?.quarter, |
||||||
hgap: c.hgap, |
hgap: c.hgap, |
||||||
vgap: c.vgap, |
vgap: c.vgap, |
||||||
allowBlank: true |
allowBlank: true, |
||||||
}); |
}); |
||||||
editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () { |
editor.on(SignEditor.EVENT_KEY_DOWN, () => { |
||||||
self.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_KEY_DOWN); |
this.fireEvent(DynamicYearQuarterTrigger.EVENT_KEY_DOWN); |
||||||
}); |
}); |
||||||
editor.on(BI.SignEditor.EVENT_FOCUS, function () { |
editor.on(SignEditor.EVENT_FOCUS, () => { |
||||||
self.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_FOCUS); |
this.fireEvent(DynamicYearQuarterTrigger.EVENT_FOCUS); |
||||||
}); |
}); |
||||||
editor.on(BI.SignEditor.EVENT_STOP, function () { |
editor.on(SignEditor.EVENT_STOP, () => { |
||||||
self.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_STOP); |
this.fireEvent(DynamicYearQuarterTrigger.EVENT_STOP); |
||||||
}); |
}); |
||||||
editor.on(BI.SignEditor.EVENT_CONFIRM, function () { |
editor.on(SignEditor.EVENT_CONFIRM, () => { |
||||||
self._doEditorConfirm(editor); |
this._doEditorConfirm(editor); |
||||||
self.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_CONFIRM); |
this.fireEvent(DynamicYearQuarterTrigger.EVENT_CONFIRM); |
||||||
}); |
}); |
||||||
editor.on(BI.SignEditor.EVENT_SPACE, function () { |
editor.on(SignEditor.EVENT_SPACE, () => { |
||||||
if (editor.isValid()) { |
if (editor.isValid()) { |
||||||
editor.blur(); |
editor.blur(); |
||||||
} |
} |
||||||
}); |
}); |
||||||
editor.on(BI.SignEditor.EVENT_START, function () { |
editor.on(SignEditor.EVENT_START, () => { |
||||||
self.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_START); |
this.fireEvent(DynamicYearQuarterTrigger.EVENT_START); |
||||||
}); |
}); |
||||||
editor.on(BI.SignEditor.EVENT_ERROR, function () { |
editor.on(SignEditor.EVENT_ERROR, () => { |
||||||
self.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_ERROR); |
this.fireEvent(DynamicYearQuarterTrigger.EVENT_ERROR); |
||||||
}); |
}); |
||||||
editor.on(BI.SignEditor.EVENT_VALID, function () { |
editor.on(SignEditor.EVENT_VALID, () => { |
||||||
var year = self.yearEditor.getValue(); |
const year = this.yearEditor.getValue(); |
||||||
var quarter = self.quarterEditor.getValue(); |
const quarter = this.quarterEditor.getValue(); |
||||||
if(BI.isNotEmptyString(year) && BI.isNotEmptyString(quarter)) { |
if (isNotEmptyString(year) && isNotEmptyString(quarter)) { |
||||||
if(BI.isPositiveInteger(year) && quarter >= 1 && quarter <= 4 && !BI.checkDateVoid(year, (quarter - 1) * 3 + 1, 1, o.min, o.max)[0]) { |
if ( |
||||||
self.fireEvent(BI.DynamicYearMonthTrigger.EVENT_VALID); |
isPositiveInteger(year) && |
||||||
|
quarter >= 1 && |
||||||
|
quarter <= 4 && |
||||||
|
!checkDateVoid( |
||||||
|
year, |
||||||
|
(quarter - 1) * 3 + 1, |
||||||
|
1, |
||||||
|
o.min, |
||||||
|
o.max |
||||||
|
)[0] |
||||||
|
) { |
||||||
|
this.fireEvent(BI.DynamicYearMonthTrigger.EVENT_VALID); |
||||||
} |
} |
||||||
} |
} |
||||||
}); |
}); |
||||||
editor.on(BI.SignEditor.EVENT_CHANGE, function () { |
editor.on(SignEditor.EVENT_CHANGE, () => { |
||||||
if(isYear) { |
if (isYear) { |
||||||
self._autoSwitch(editor); |
this._autoSwitch(editor); |
||||||
} |
} |
||||||
}); |
}); |
||||||
|
|
||||||
return editor; |
return editor; |
||||||
}, |
} |
||||||
|
|
||||||
_doEditorConfirm: function (editor) { |
_doEditorConfirm(editor) { |
||||||
var value = editor.getValue(); |
const value = editor.getValue(); |
||||||
if (BI.isNotNull(value)) { |
if (isNotNull(value)) { |
||||||
editor.setValue(value); |
editor.setValue(value); |
||||||
} |
} |
||||||
var quarterValue = this.quarterEditor.getValue(); |
const quarterValue = this.quarterEditor.getValue(); |
||||||
this.storeValue = { |
this.storeValue = { |
||||||
type: BI.DynamicYearQuarterCombo.Static, |
type: DynamicYearQuarterCombo.Static, |
||||||
value: { |
value: { |
||||||
year: this.yearEditor.getValue(), |
year: this.yearEditor.getValue(), |
||||||
quarter: BI.isEmptyString(this.quarterEditor.getValue()) ? "" : quarterValue |
quarter: isEmptyString(this.quarterEditor.getValue()) |
||||||
} |
? "" |
||||||
|
: quarterValue, |
||||||
|
}, |
||||||
}; |
}; |
||||||
this.setTitle(this._getStaticTitle(this.storeValue.value)); |
this.setTitle(this._getStaticTitle(this.storeValue.value)); |
||||||
}, |
} |
||||||
|
|
||||||
_yearCheck: function (v) { |
_yearCheck(v) { |
||||||
var date = BI.print(BI.parseDateTime(v, "%Y-%X-%d"), "%Y-%X-%d"); |
const date = print(parseDateTime(v, "%Y-%X-%d"), "%Y-%X-%d"); |
||||||
return BI.print(BI.parseDateTime(v, "%Y"), "%Y") === v && date >= this.options.min && date <= this.options.max; |
|
||||||
}, |
return ( |
||||||
|
print(parseDateTime(v, "%Y"), "%Y") === v && |
||||||
|
date >= this.options.min && |
||||||
|
date <= this.options.max |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
_autoSwitch: function (editor) { |
_autoSwitch(editor) { |
||||||
var v = editor.getValue(); |
const v = editor.getValue(); |
||||||
if (BI.isNotEmptyString(v) && BI.checkDateLegal(v)) { |
if (isNotEmptyString(v) && checkDateLegal(v)) { |
||||||
if (v.length === 4 && this._yearCheck(v)) { |
if (v.length === 4 && this._yearCheck(v)) { |
||||||
this._doEditorConfirm(editor); |
this._doEditorConfirm(editor); |
||||||
this.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_CONFIRM); |
this.fireEvent(DynamicYearQuarterTrigger.EVENT_CONFIRM); |
||||||
this.quarterEditor.focus(); |
this.quarterEditor.focus(); |
||||||
} |
} |
||||||
} |
} |
||||||
}, |
} |
||||||
|
|
||||||
_getStaticTitle: function (value) { |
_getStaticTitle(value) { |
||||||
value = value || {}; |
value = value || {}; |
||||||
var hasYear = !(BI.isNull(value.year) || BI.isEmptyString(value.year)); |
const hasYear = !(isNull(value.year) || isEmptyString(value.year)); |
||||||
var hasMonth = !(BI.isNull(value.quarter) || BI.isEmptyString(value.quarter)); |
const hasMonth = !(isNull(value.quarter) || isEmptyString(value.quarter)); |
||||||
switch ((hasYear << 1) | hasMonth) { |
switch ((hasYear << 1) | hasMonth) { |
||||||
// !hasYear && !hasMonth
|
// !hasYear && !hasMonth
|
||||||
case 0: |
case 0: |
||||||
return ""; |
return ""; |
||||||
// !hasYear && hasMonth
|
// !hasYear && hasMonth
|
||||||
case 1: |
case 1: |
||||||
return value.quarter; |
return value.quarter; |
||||||
// hasYear && !hasMonth
|
// hasYear && !hasMonth
|
||||||
case 2: |
case 2: |
||||||
return value.year; |
return value.year; |
||||||
// hasYear && hasMonth
|
// hasYear && hasMonth
|
||||||
case 3: |
case 3: |
||||||
default: |
default: |
||||||
return value.year + "-" + value.quarter; |
return `${value.year}-${value.quarter}`; |
||||||
} |
} |
||||||
}, |
} |
||||||
|
|
||||||
_getText: function (obj) { |
_getText(obj) { |
||||||
var value = ""; |
let value = ""; |
||||||
if(BI.isNotNull(obj.year) && BI.parseInt(obj.year) !== 0) { |
if (isNotNull(obj.year) && parseInt(obj.year) !== 0) { |
||||||
value += Math.abs(obj.year) + BI.i18nText("BI-Basic_Year") + (obj.year < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); |
value += |
||||||
|
Math.abs(obj.year) + |
||||||
|
i18nText("BI-Basic_Year") + |
||||||
|
(obj.year < 0 |
||||||
|
? i18nText("BI-Basic_Front") |
||||||
|
: i18nText("BI-Basic_Behind")); |
||||||
} |
} |
||||||
if(BI.isNotNull(obj.quarter) && BI.parseInt(obj.quarter) !== 0) { |
if (isNotNull(obj.quarter) && parseInt(obj.quarter) !== 0) { |
||||||
value += Math.abs(obj.quarter) + BI.i18nText("BI-Basic_Single_Quarter") + (obj.quarter < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); |
value += |
||||||
|
Math.abs(obj.quarter) + |
||||||
|
i18nText("BI-Basic_Single_Quarter") + |
||||||
|
(obj.quarter < 0 |
||||||
|
? i18nText("BI-Basic_Front") |
||||||
|
: i18nText("BI-Basic_Behind")); |
||||||
} |
} |
||||||
|
|
||||||
return value; |
return value; |
||||||
}, |
} |
||||||
|
|
||||||
_setInnerValue: function (date, text) { |
_setInnerValue(date, text) { |
||||||
var dateStr = BI.print(date, "%Y-%Q"); |
const dateStr = print(date, "%Y-%Q"); |
||||||
this.yearEditor.setValue(date.getFullYear()); |
this.yearEditor.setValue(date.getFullYear()); |
||||||
this.quarterEditor.setValue(BI.getQuarter(date)); |
this.quarterEditor.setValue(getQuarter(date)); |
||||||
this.setTitle(BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr)); |
this.setTitle(isEmptyString(text) ? dateStr : `${text}:${dateStr}`); |
||||||
}, |
} |
||||||
|
|
||||||
setMinDate: function (minDate) { |
setMinDate(minDate) { |
||||||
if (BI.isNotEmptyString(this.options.min)) { |
if (isNotEmptyString(this.options.min)) { |
||||||
this.options.min = minDate; |
this.options.min = minDate; |
||||||
} |
} |
||||||
}, |
} |
||||||
|
|
||||||
setMaxDate: function (maxDate) { |
setMaxDate(maxDate) { |
||||||
if (BI.isNotEmptyString(this.options.max)) { |
if (isNotEmptyString(this.options.max)) { |
||||||
this.options.max = maxDate; |
this.options.max = maxDate; |
||||||
} |
} |
||||||
}, |
} |
||||||
|
|
||||||
setValue: function (v) { |
setValue(v) { |
||||||
var type, value; |
let type, value, text, quarter; |
||||||
var date = BI.getDate(); |
let date = getDate(); |
||||||
this.storeValue = v; |
this.storeValue = v; |
||||||
if (BI.isNotNull(v)) { |
if (isNotNull(v)) { |
||||||
type = v.type || BI.DynamicYearQuarterCombo.Static; |
type = v.type || DynamicYearQuarterCombo.Static; |
||||||
value = v.value || v; |
value = v.value || v; |
||||||
} |
} |
||||||
switch (type) { |
switch (type) { |
||||||
case BI.DynamicYearQuarterCombo.Dynamic: |
case DynamicYearQuarterCombo.Dynamic: |
||||||
var text = this._getText(value); |
text = this._getText(value); |
||||||
date = BI.DynamicDateHelper.getCalculation(value); |
date = DynamicDateHelper.getCalculation(value); |
||||||
this._setInnerValue(date, text); |
this._setInnerValue(date, text); |
||||||
break; |
break; |
||||||
case BI.DynamicYearQuarterCombo.Static: |
case DynamicYearQuarterCombo.Static: |
||||||
default: |
default: |
||||||
value = value || {}; |
value = value || {}; |
||||||
var quarter = BI.isNull(value.quarter) ? null : value.quarter; |
quarter = isNull(value.quarter) ? null : value.quarter; |
||||||
this.yearEditor.setValue(value.year); |
this.yearEditor.setValue(value.year); |
||||||
this.quarterEditor.setValue(quarter); |
this.quarterEditor.setValue(quarter); |
||||||
this.setTitle(this._getStaticTitle(value)); |
this.setTitle(this._getStaticTitle(value)); |
||||||
break; |
break; |
||||||
} |
} |
||||||
}, |
} |
||||||
|
|
||||||
getValue: function () { |
getValue() { |
||||||
return this.storeValue; |
return this.storeValue; |
||||||
}, |
} |
||||||
|
|
||||||
getKey: function () { |
getKey() { |
||||||
return this.yearEditor.getValue() + "-" + this.quarterEditor.getValue(); |
return `${this.yearEditor.getValue()}-${this.quarterEditor.getValue()}`; |
||||||
}, |
} |
||||||
|
|
||||||
isStateValid: function () { |
isStateValid() { |
||||||
return this.yearEditor.isValid() && this.quarterEditor.isValid(); |
return this.yearEditor.isValid() && this.quarterEditor.isValid(); |
||||||
} |
} |
||||||
}); |
} |
||||||
BI.DynamicYearQuarterTrigger.EVENT_FOCUS = "EVENT_FOCUS"; |
|
||||||
BI.DynamicYearQuarterTrigger.EVENT_ERROR = "EVENT_ERROR"; |
|
||||||
BI.DynamicYearQuarterTrigger.EVENT_START = "EVENT_START"; |
|
||||||
BI.DynamicYearQuarterTrigger.EVENT_CONFIRM = "EVENT_CONFIRM"; |
|
||||||
BI.DynamicYearQuarterTrigger.EVENT_STOP = "EVENT_STOP"; |
|
||||||
BI.DynamicYearQuarterTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; |
|
||||||
BI.DynamicYearQuarterTrigger.EVENT_VALID = "EVENT_VALID"; |
|
||||||
BI.shortcut("bi.dynamic_year_quarter_trigger", BI.DynamicYearQuarterTrigger); |
|
||||||
|
@ -1,193 +1,248 @@ |
|||||||
/** |
import { |
||||||
* @author windy |
shortcut, |
||||||
* @version 2.0 |
HorizontalFillLayout, |
||||||
* Created by windy on 2021/1/25 |
createWidget, |
||||||
*/ |
i18nText, |
||||||
BI.YearQuarterInterval = BI.inherit(BI.Single, { |
print, |
||||||
constants: { |
parseDateTime, |
||||||
|
checkDateVoid, |
||||||
|
isNotNull, |
||||||
|
checkDateLegal |
||||||
|
} from "@/core"; |
||||||
|
import { Single, Label, Bubbles } from "@/base"; |
||||||
|
import { DynamicYearQuarterCombo } from "../yearquarter"; |
||||||
|
|
||||||
|
@shortcut() |
||||||
|
export class YearQuarterInterval extends Single { |
||||||
|
static xtype = "bi.year_quarter_interval"; |
||||||
|
|
||||||
|
constants = { |
||||||
height: 24, |
height: 24, |
||||||
width: 25, |
width: 25, |
||||||
lgap: 15, |
lgap: 15, |
||||||
offset: -15, |
offset: -15, |
||||||
timeErrorCls: "time-error" |
timeErrorCls: "time-error", |
||||||
}, |
}; |
||||||
|
props = { |
||||||
props: { |
|
||||||
extraCls: "bi-year-quarter-interval", |
extraCls: "bi-year-quarter-interval", |
||||||
minDate: "1900-01-01", |
minDate: "1900-01-01", |
||||||
maxDate: "2099-12-31", |
maxDate: "2099-12-31", |
||||||
supportDynamic: true, |
supportDynamic: true, |
||||||
}, |
}; |
||||||
|
|
||||||
|
static EVENT_VALID = "EVENT_VALID"; |
||||||
|
static EVENT_ERROR = "EVENT_ERROR"; |
||||||
|
static EVENT_CHANGE = "EVENT_CHANGE"; |
||||||
|
static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; |
||||||
|
|
||||||
render: function () { |
render() { |
||||||
var self = this, o = this.options; |
const o = this.options; |
||||||
|
|
||||||
o.value = o.value || {}; |
o.value = o.value || {}; |
||||||
this.left = this._createCombo(o.value.start, o.watermark?.start); |
this.left = this._createCombo(o.value.start, o.watermark?.start); |
||||||
this.right = this._createCombo(o.value.end, o.watermark?.end); |
this.right = this._createCombo(o.value.end, o.watermark?.end); |
||||||
|
|
||||||
|
|
||||||
return { |
return { |
||||||
type: "bi.horizontal_fill", |
type: HorizontalFillLayout.xtype, |
||||||
columnSize: ["fill", "", "fill"], |
columnSize: ["fill", "", "fill"], |
||||||
items: [{ |
items: [ |
||||||
el: self.left |
{ |
||||||
}, { |
el: this.left, |
||||||
el: { |
}, |
||||||
type: "bi.label", |
{ |
||||||
height: o.height, |
el: { |
||||||
hgap: 5, |
type: Label.xtype, |
||||||
text: "-", |
height: o.height, |
||||||
ref: function (_ref) { |
hgap: 5, |
||||||
self.label = _ref; |
text: "-", |
||||||
} |
ref: _ref => { |
||||||
|
this.label = _ref; |
||||||
|
}, |
||||||
|
}, |
||||||
|
}, |
||||||
|
{ |
||||||
|
el: this.right, |
||||||
} |
} |
||||||
}, { |
], |
||||||
el: self.right |
|
||||||
}] |
|
||||||
}; |
}; |
||||||
}, |
} |
||||||
|
|
||||||
_createCombo: function (v, watermark) { |
_createCombo(v, watermark) { |
||||||
var self = this, o = this.options; |
const o = this.options; |
||||||
var combo = BI.createWidget({ |
const combo = createWidget({ |
||||||
type: "bi.dynamic_year_quarter_combo", |
type: DynamicYearQuarterCombo.xtype, |
||||||
supportDynamic: o.supportDynamic, |
supportDynamic: o.supportDynamic, |
||||||
minDate: o.minDate, |
minDate: o.minDate, |
||||||
maxDate: o.maxDate, |
maxDate: o.maxDate, |
||||||
behaviors: o.behaviors, |
behaviors: o.behaviors, |
||||||
value: v, |
value: v, |
||||||
height: o.height, |
height: o.height, |
||||||
watermark: watermark, |
watermark, |
||||||
listeners: [{ |
listeners: [ |
||||||
eventName: BI.DynamicYearQuarterCombo.EVENT_BEFORE_POPUPVIEW, |
{ |
||||||
action: function () { |
eventName: DynamicYearQuarterCombo.EVENT_BEFORE_POPUPVIEW, |
||||||
self.fireEvent(BI.YearQuarterInterval.EVENT_BEFORE_POPUPVIEW); |
action: () => { |
||||||
|
this.fireEvent( |
||||||
|
YearQuarterInterval.EVENT_BEFORE_POPUPVIEW |
||||||
|
); |
||||||
|
}, |
||||||
} |
} |
||||||
}] |
], |
||||||
}); |
}); |
||||||
combo.on(BI.DynamicYearQuarterCombo.EVENT_ERROR, function () { |
combo.on(DynamicYearQuarterCombo.EVENT_ERROR, () => { |
||||||
self._clearTitle(); |
this._clearTitle(); |
||||||
BI.Bubbles.hide("error"); |
Bubbles.hide("error"); |
||||||
self.element.removeClass(self.constants.timeErrorCls); |
this.element.removeClass(this.constants.timeErrorCls); |
||||||
self.fireEvent(BI.YearQuarterInterval.EVENT_ERROR); |
this.fireEvent(YearQuarterInterval.EVENT_ERROR); |
||||||
}); |
}); |
||||||
|
|
||||||
combo.on(BI.DynamicYearQuarterCombo.EVENT_VALID, function () { |
combo.on(DynamicYearQuarterCombo.EVENT_VALID, () => { |
||||||
self._checkValid(); |
this._checkValid(); |
||||||
}); |
}); |
||||||
|
|
||||||
combo.on(BI.DynamicYearQuarterCombo.EVENT_FOCUS, function () { |
combo.on(DynamicYearQuarterCombo.EVENT_FOCUS, () => { |
||||||
self._checkValid(); |
this._checkValid(); |
||||||
}); |
}); |
||||||
|
|
||||||
combo.on(BI.DynamicYearQuarterCombo.EVENT_CONFIRM, function () { |
combo.on(DynamicYearQuarterCombo.EVENT_CONFIRM, () => { |
||||||
BI.Bubbles.hide("error"); |
Bubbles.hide("error"); |
||||||
var smallDate = self.left.getKey(), bigDate = self.right.getKey(); |
const smallDate = this.left.getKey(), |
||||||
if (self.left.isStateValid() && self.right.isStateValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { |
bigDate = this.right.getKey(); |
||||||
self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); |
if ( |
||||||
self.element.addClass(self.constants.timeErrorCls); |
this.left.isStateValid() && |
||||||
self.fireEvent(BI.YearQuarterInterval.EVENT_ERROR); |
this.right.isStateValid() && |
||||||
}else{ |
this._check(smallDate, bigDate) && |
||||||
self._clearTitle(); |
this._compare(smallDate, bigDate) |
||||||
self.element.removeClass(self.constants.timeErrorCls); |
) { |
||||||
self.fireEvent(BI.YearQuarterInterval.EVENT_CHANGE); |
this._setTitle(i18nText("BI-Time_Interval_Error_Text")); |
||||||
|
this.element.addClass(this.constants.timeErrorCls); |
||||||
|
this.fireEvent(YearQuarterInterval.EVENT_ERROR); |
||||||
|
} else { |
||||||
|
this._clearTitle(); |
||||||
|
this.element.removeClass(this.constants.timeErrorCls); |
||||||
|
this.fireEvent(YearQuarterInterval.EVENT_CHANGE); |
||||||
} |
} |
||||||
}); |
}); |
||||||
|
|
||||||
return combo; |
return combo; |
||||||
}, |
} |
||||||
|
|
||||||
|
|
||||||
_dateCheck: function (date) { |
|
||||||
return BI.print(BI.parseDateTime(date, "%Y-%Q"), "%Y-%Q") === date || BI.print(BI.parseDateTime(date, "%Y-%q"), "%Y-%q") === date; |
|
||||||
}, |
|
||||||
|
|
||||||
|
_dateCheck(date) { |
||||||
|
return ( |
||||||
|
print(parseDateTime(date, "%Y-%Q"), "%Y-%Q") === date || |
||||||
|
print(parseDateTime(date, "%Y-%q"), "%Y-%q") === date |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
// 判是否在最大最小之间
|
_checkVoid(obj) { |
||||||
_checkVoid: function (obj) { |
const o = this.options; |
||||||
var o = this.options; |
|
||||||
return !BI.checkDateVoid(obj.year, (obj.quarter - 1) * 3 + 1, 1, o.minDate, o.maxDate)[0]; |
return !checkDateVoid( |
||||||
}, |
obj.year, |
||||||
|
(obj.quarter - 1) * 3 + 1, |
||||||
|
1, |
||||||
|
o.minDate, |
||||||
|
o.maxDate |
||||||
|
)[0]; |
||||||
|
} |
||||||
|
|
||||||
// 判格式合法
|
_check(smallDate, bigDate) { |
||||||
_check: function (smallDate, bigDate) { |
const smallObj = smallDate.match(/\d+/g), |
||||||
var smallObj = smallDate.match(/\d+/g), bigObj = bigDate.match(/\d+/g); |
bigObj = bigDate.match(/\d+/g); |
||||||
|
|
||||||
var smallDate4Check = ""; |
let smallDate4Check = ""; |
||||||
if (BI.isNotNull(smallObj)) { |
if (isNotNull(smallObj)) { |
||||||
smallDate4Check = (smallObj[0] || "") + "-" + (smallObj[1] || 1); |
smallDate4Check = `${smallObj[0] || ""}-${smallObj[1] || 1}`; |
||||||
} |
} |
||||||
|
|
||||||
var bigDate4Check = ""; |
let bigDate4Check = ""; |
||||||
if (BI.isNotNull(bigObj)) { |
if (isNotNull(bigObj)) { |
||||||
bigDate4Check = (bigObj[0] || "") + "-" + (bigObj[1] || 1); |
bigDate4Check = `${bigObj[0] || ""}-${bigObj[1] || 1}`; |
||||||
} |
} |
||||||
|
|
||||||
return this._dateCheck(smallDate4Check) && BI.checkDateLegal(smallDate4Check) && this._checkVoid({ |
return ( |
||||||
year: smallObj[0], |
this._dateCheck(smallDate4Check) && |
||||||
quarter: smallObj[1] || 1 |
checkDateLegal(smallDate4Check) && |
||||||
}) && this._dateCheck(bigDate4Check) && BI.checkDateLegal(bigDate4Check) && this._checkVoid({ |
this._checkVoid({ |
||||||
year: bigObj[0], |
year: smallObj[0], |
||||||
quarter: bigObj[1] || 1 |
quarter: smallObj[1] || 1, |
||||||
}); |
}) && |
||||||
}, |
this._dateCheck(bigDate4Check) && |
||||||
|
checkDateLegal(bigDate4Check) && |
||||||
_compare: function (smallDate, bigDate) { |
this._checkVoid({ |
||||||
smallDate = BI.print(BI.parseDateTime(smallDate, "%Y-%Q"), "%Y-%Q"); |
year: bigObj[0], |
||||||
bigDate = BI.print(BI.parseDateTime(bigDate, "%Y-%Q"), "%Y-%Q"); |
quarter: bigObj[1] || 1, |
||||||
return BI.isNotNull(smallDate) && BI.isNotNull(bigDate) && smallDate > bigDate; |
}) |
||||||
}, |
); |
||||||
_setTitle: function (v) { |
} |
||||||
|
|
||||||
|
_compare(smallDate, bigDate) { |
||||||
|
smallDate = print(parseDateTime(smallDate, "%Y-%Q"), "%Y-%Q"); |
||||||
|
bigDate = print(parseDateTime(bigDate, "%Y-%Q"), "%Y-%Q"); |
||||||
|
|
||||||
|
return ( |
||||||
|
isNotNull(smallDate) && isNotNull(bigDate) && smallDate > bigDate |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
_setTitle(v) { |
||||||
this.setTitle(v); |
this.setTitle(v); |
||||||
}, |
} |
||||||
_clearTitle: function () { |
|
||||||
|
_clearTitle() { |
||||||
this.setTitle(""); |
this.setTitle(""); |
||||||
}, |
} |
||||||
_checkValid: function () { |
|
||||||
var self = this; |
_checkValid() { |
||||||
|
Bubbles.hide("error"); |
||||||
BI.Bubbles.hide("error"); |
const smallDate = this.left.getKey(), |
||||||
var smallDate = self.left.getKey(), bigDate = self.right.getKey(); |
bigDate = this.right.getKey(); |
||||||
if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { |
if ( |
||||||
self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); |
this.left.isValid() && |
||||||
self.element.addClass(self.constants.timeErrorCls); |
this.right.isValid() && |
||||||
BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, { |
this._check(smallDate, bigDate) && |
||||||
offsetStyle: "center" |
this._compare(smallDate, bigDate) |
||||||
}); |
) { |
||||||
self.fireEvent(BI.YearQuarterInterval.EVENT_ERROR); |
this._setTitle(i18nText("BI-Time_Interval_Error_Text")); |
||||||
|
this.element.addClass(this.constants.timeErrorCls); |
||||||
|
Bubbles.show( |
||||||
|
"error", |
||||||
|
i18nText("BI-Time_Interval_Error_Text"), |
||||||
|
this, |
||||||
|
{ |
||||||
|
offsetStyle: "center", |
||||||
|
} |
||||||
|
); |
||||||
|
this.fireEvent(YearQuarterInterval.EVENT_ERROR); |
||||||
} else { |
} else { |
||||||
self._clearTitle(); |
this._clearTitle(); |
||||||
self.element.removeClass(self.constants.timeErrorCls); |
this.element.removeClass(this.constants.timeErrorCls); |
||||||
} |
} |
||||||
}, |
} |
||||||
|
|
||||||
setMinDate: function (minDate) { |
setMinDate(minDate) { |
||||||
var o = this.options; |
const o = this.options; |
||||||
o.minDate = minDate; |
o.minDate = minDate; |
||||||
this.left.setMinDate(minDate); |
this.left.setMinDate(minDate); |
||||||
this.right.setMinDate(minDate); |
this.right.setMinDate(minDate); |
||||||
}, |
} |
||||||
|
|
||||||
setMaxDate: function (maxDate) { |
setMaxDate(maxDate) { |
||||||
var o = this.options; |
const o = this.options; |
||||||
o.maxDate = maxDate; |
o.maxDate = maxDate; |
||||||
this.left.setMaxDate(maxDate); |
this.left.setMaxDate(maxDate); |
||||||
this.right.setMaxDate(maxDate); |
this.right.setMaxDate(maxDate); |
||||||
}, |
} |
||||||
|
|
||||||
setValue: function (date) { |
setValue(date) { |
||||||
date = date || {}; |
date = date || {}; |
||||||
this.left.setValue(date.start); |
this.left.setValue(date.start); |
||||||
this.right.setValue(date.end); |
this.right.setValue(date.end); |
||||||
|
|
||||||
this._checkValid(); |
this._checkValid(); |
||||||
}, |
|
||||||
getValue: function () { |
|
||||||
return {start: this.left.getValue(), end: this.right.getValue()}; |
|
||||||
} |
} |
||||||
}); |
|
||||||
BI.YearQuarterInterval.EVENT_VALID = "EVENT_VALID"; |
getValue() { |
||||||
BI.YearQuarterInterval.EVENT_ERROR = "EVENT_ERROR"; |
return { start: this.left.getValue(), end: this.right.getValue() }; |
||||||
BI.YearQuarterInterval.EVENT_CHANGE = "EVENT_CHANGE"; |
} |
||||||
BI.YearQuarterInterval.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; |
} |
||||||
BI.shortcut("bi.year_quarter_interval", BI.YearQuarterInterval); |
|
||||||
|
Loading…
Reference in new issue