");
+ html.push(
+ ""
+ );
html.push(content);
html.push("
");
},
makeUlLineClass: function (setting, node) {
- return ((setting.view.showLine && !node.isLastNode) ? consts.line.LINE : "");
+ return setting.view.showLine && !node.isLastNode ? consts.line.LINE : "";
},
removeChildNodes: function (setting, node) {
if (!node) return;
@@ -1455,11 +1611,15 @@
return;
}
// support IE 7 / 8
- if (typeof Element === 'undefined' || typeof HTMLElement === 'undefined') {
+ if (typeof Element === "undefined" || typeof HTMLElement === "undefined") {
var contRect = setting.treeObj.get(0).getBoundingClientRect(),
findMeRect = dom.getBoundingClientRect();
- if (findMeRect.top < contRect.top || findMeRect.bottom > contRect.bottom
- || findMeRect.right > contRect.right || findMeRect.left < contRect.left) {
+ if (
+ findMeRect.top < contRect.top ||
+ findMeRect.bottom > contRect.bottom ||
+ findMeRect.right > contRect.right ||
+ findMeRect.left < contRect.left
+ ) {
dom.scrollIntoView();
}
return;
@@ -1470,29 +1630,23 @@
"use strict";
function makeRange(start, length) {
- return { "start": start, "length": length, "end": start + length };
+ return { start: start, length: length, end: start + length };
}
function coverRange(inner, outer) {
- if (
- false === centerIfNeeded ||
- (outer.start < inner.end && inner.start < outer.end)
- ) {
- return Math.max(
- inner.end - outer.length,
- Math.min(outer.start, inner.start)
- );
+ if (false === centerIfNeeded || (outer.start < inner.end && inner.start < outer.end)) {
+ return Math.max(inner.end - outer.length, Math.min(outer.start, inner.start));
}
return (inner.start + inner.end - outer.length) / 2;
}
function makePoint(x, y) {
return {
- "x": x,
- "y": y,
- "translate": function translate(dX, dY) {
+ x: x,
+ y: y,
+ translate: function translate(dX, dY) {
return makePoint(x + dX, y + dY);
- }
+ },
};
}
@@ -1543,7 +1697,7 @@
},
removeNode: function (setting, node) {
var root = data.getRoot(setting),
- parentNode = (node.parentTId) ? node.getParentNode() : root;
+ parentNode = node.parentTId ? node.getParentNode() : root;
node.isFirstNode = false;
node.isLastNode = false;
@@ -1572,7 +1726,9 @@
view.setFirstNode(setting, parentNode);
view.setLastNode(setting, parentNode);
- var tmp_ulObj, tmp_switchObj, tmp_icoObj,
+ var tmp_ulObj,
+ tmp_switchObj,
+ tmp_icoObj,
childLength = children.length;
//repair nodes old parent
@@ -1587,7 +1743,6 @@
view.replaceSwitchClass(parentNode, tmp_switchObj, consts.folder.DOCU);
view.replaceIcoClass(parentNode, tmp_icoObj, consts.folder.DOCU);
tmp_ulObj.css("display", "none");
-
} else if (setting.view.showLine && childLength > 0) {
//old parentNode has child nodes
var newLast = children[childLength - 1];
@@ -1667,11 +1822,11 @@
setNodeClasses: function (setting, treeNode) {
var aObj = $$(treeNode, consts.id.A, setting),
classes = view.makeNodeClasses(setting, treeNode);
- if ('add' in classes && classes.add.length) {
- aObj.addClass(classes.add.join(' '));
+ if ("add" in classes && classes.add.length) {
+ aObj.addClass(classes.add.join(" "));
}
- if ('remove' in classes && classes.remove.length) {
- aObj.removeClass(classes.remove.join(' '));
+ if ("remove" in classes && classes.remove.length) {
+ aObj.removeClass(classes.remove.join(" "));
}
},
setNodeLineIcos: function (setting, node) {
@@ -1733,7 +1888,7 @@
} else if (node) {
view.expandCollapseNode(setting, node, !node.open);
}
- }
+ },
};
// zTree defind
$.fn.zTree = {
@@ -1742,7 +1897,7 @@
tools: tools,
view: view,
event: event,
- data: data
+ data: data,
},
getZTreeObj: function (treeId) {
var o = data.getZTreeTools(treeId);
@@ -1800,11 +1955,10 @@
}
if (!newNodes) return null;
-
var xNewNodes = tools.clone(tools.isArray(newNodes) ? newNodes : [newNodes]);
function addCallback() {
- view.addNodes(setting, parentNode, index, xNewNodes, (isSilent == true));
+ view.addNodes(setting, parentNode, index, xNewNodes, isSilent == true);
}
if (tools.canAsync(setting, parentNode)) {
@@ -1832,9 +1986,17 @@
}
callbackFlag = !!callbackFlag;
- if (callbackFlag && expandFlag && (tools.apply(setting.callback.beforeExpand, [setting.treeId, node], true) == false)) {
+ if (
+ callbackFlag &&
+ expandFlag &&
+ tools.apply(setting.callback.beforeExpand, [setting.treeId, node], true) == false
+ ) {
return null;
- } else if (callbackFlag && !expandFlag && (tools.apply(setting.callback.beforeCollapse, [setting.treeId, node], true) == false)) {
+ } else if (
+ callbackFlag &&
+ !expandFlag &&
+ tools.apply(setting.callback.beforeCollapse, [setting.treeId, node], true) == false
+ ) {
return null;
}
if (expandFlag && node.parentTId) {
@@ -1866,27 +2028,48 @@
},
getNodeByParam: function (key, value, parentNode) {
if (!key) return null;
- return data.getNodeByParam(setting, parentNode ? data.nodeChildren(setting, parentNode) : data.getNodes(setting), key, value);
+ return data.getNodeByParam(
+ setting,
+ parentNode ? data.nodeChildren(setting, parentNode) : data.getNodes(setting),
+ key,
+ value
+ );
},
getNodeByTId: function (tId) {
return data.getNodeCache(setting, tId);
},
getNodesByParam: function (key, value, parentNode) {
if (!key) return null;
- return data.getNodesByParam(setting, parentNode ? data.nodeChildren(setting, parentNode) : data.getNodes(setting), key, value);
+ return data.getNodesByParam(
+ setting,
+ parentNode ? data.nodeChildren(setting, parentNode) : data.getNodes(setting),
+ key,
+ value
+ );
},
getNodesByParamFuzzy: function (key, value, parentNode) {
if (!key) return null;
- return data.getNodesByParamFuzzy(setting, parentNode ? data.nodeChildren(setting, parentNode) : data.getNodes(setting), key, value);
+ return data.getNodesByParamFuzzy(
+ setting,
+ parentNode ? data.nodeChildren(setting, parentNode) : data.getNodes(setting),
+ key,
+ value
+ );
},
getNodesByFilter: function (filter, isSingle, parentNode, invokeParam) {
isSingle = !!isSingle;
- if (!filter || (typeof filter != "function")) return (isSingle ? null : []);
- return data.getNodesByFilter(setting, parentNode ? data.nodeChildren(setting, parentNode) : data.getNodes(setting), filter, isSingle, invokeParam);
+ if (!filter || typeof filter != "function") return isSingle ? null : [];
+ return data.getNodesByFilter(
+ setting,
+ parentNode ? data.nodeChildren(setting, parentNode) : data.getNodes(setting),
+ filter,
+ isSingle,
+ invokeParam
+ );
},
getNodeIndex: function (node) {
if (!node) return null;
- var parentNode = (node.parentTId) ? node.getParentNode() : data.getRoot(setting);
+ var parentNode = node.parentTId ? node.getParentNode() : data.getRoot(setting);
var children = data.nodeChildren(setting, parentNode);
for (var i = 0, l = children.length; i < l; i++) {
if (children[i] == node) return i;
@@ -1894,7 +2077,8 @@
return -1;
},
getSelectedNodes: function () {
- var r = [], list = data.getRoot(setting).curSelectedList;
+ var r = [],
+ list = data.getRoot(setting).curSelectedList;
for (var i = 0, l = list.length; i < l; i++) {
r.push(list[i]);
}
@@ -1955,7 +2139,11 @@
removeNode: function (node, callbackFlag) {
if (!node) return;
callbackFlag = !!callbackFlag;
- if (callbackFlag && tools.apply(setting.callback.beforeRemove, [setting.treeId, node], true) == false) return;
+ if (
+ callbackFlag &&
+ tools.apply(setting.callback.beforeRemove, [setting.treeId, node], true) == false
+ )
+ return;
view.removeNode(setting, node);
if (callbackFlag) {
this.setting.treeObj.trigger(consts.event.REMOVE, [setting.treeId, node]);
@@ -1970,8 +2158,7 @@
} else if (!isSilent) {
try {
$$(node, setting).focus().blur();
- } catch (e) {
- }
+ } catch (e) {}
}
view.selectNode(setting, node, addFlag);
}
@@ -2001,18 +2188,18 @@
view.setNodeFontCss(setting, node);
view.setNodeClasses(setting, node);
}
- }
+ },
};
root.treeTools = zTreeTools;
data.setZTreeTools(setting, zTreeTools);
var children = data.nodeChildren(setting, root);
if (children && children.length > 0) {
view.createNodes(setting, 0, children, null, -1);
- } else if (setting.async.enable && setting.async.url && setting.async.url !== '') {
+ } else if (setting.async.enable && setting.async.url && setting.async.url !== "") {
view.asyncNode(setting);
}
return zTreeTools;
- }
+ },
};
var zt = $.fn.zTree,
diff --git a/src/case/ztree/jquery.ztree.excheck-3.5.js b/src/case/ztree/jquery.ztree.excheck-3.5.js
index ea1f6a945..685938c55 100644
--- a/src/case/ztree/jquery.ztree.excheck-3.5.js
+++ b/src/case/ztree/jquery.ztree.excheck-3.5.js
@@ -12,640 +12,710 @@
* Date: 2015-06-18
*/
(function ($) {
- //default consts of excheck
- var _consts = {
- event: {
- CHECK: "ztree_check"
- },
- id: {
- CHECK: "_check"
- },
- checkbox: {
- STYLE: "checkbox",
- DEFAULT: "chk",
- DISABLED: "disable",
- FALSE: "false",
- TRUE: "true",
- FULL: "full",
- PART: "part",
- FOCUS: "focus"
- },
- radio: {
- STYLE: "radio",
- TYPE_ALL: "all",
- TYPE_LEVEL: "level"
- }
- },
- //default setting of excheck
- _setting = {
- check: {
- enable: false,
- autoCheckTrigger: false,
- chkStyle: _consts.checkbox.STYLE,
- nocheckInherit: false,
- chkDisabledInherit: false,
- radioType: _consts.radio.TYPE_LEVEL,
- chkboxType: {
- "Y": "ps",
- "N": "ps"
- }
- },
- data: {
- key: {
- checked: "checked"
- }
- },
- callback: {
- beforeCheck: null,
- onCheck: null
- }
- },
- //default root of excheck
- _initRoot = function (setting) {
- var r = data.getRoot(setting);
- r.radioCheckedList = [];
- },
- //default cache of excheck
- _initCache = function (treeId) {
- },
- //default bind event of excheck
- _bindEvent = function (setting) {
- var o = setting.treeObj,
- c = consts.event;
- o.bind(c.CHECK, function (event, srcEvent, treeId, node) {
- event.srcEvent = srcEvent;
- tools.apply(setting.callback.onCheck, [event, treeId, node]);
- });
- },
- _unbindEvent = function (setting) {
- var o = setting.treeObj,
- c = consts.event;
- o.unbind(c.CHECK);
- },
- //default event proxy of excheck
- _eventProxy = function (e) {
- var target = e.target,
- setting = data.getSetting(e.data.treeId),
- tId = "", node = null,
- nodeEventType = "", treeEventType = "",
- nodeEventCallback = null, treeEventCallback = null;
+ //default consts of excheck
+ var _consts = {
+ event: {
+ CHECK: "ztree_check",
+ },
+ id: {
+ CHECK: "_check",
+ },
+ checkbox: {
+ STYLE: "checkbox",
+ DEFAULT: "chk",
+ DISABLED: "disable",
+ FALSE: "false",
+ TRUE: "true",
+ FULL: "full",
+ PART: "part",
+ FOCUS: "focus",
+ },
+ radio: {
+ STYLE: "radio",
+ TYPE_ALL: "all",
+ TYPE_LEVEL: "level",
+ },
+ },
+ //default setting of excheck
+ _setting = {
+ check: {
+ enable: false,
+ autoCheckTrigger: false,
+ chkStyle: _consts.checkbox.STYLE,
+ nocheckInherit: false,
+ chkDisabledInherit: false,
+ radioType: _consts.radio.TYPE_LEVEL,
+ chkboxType: {
+ Y: "ps",
+ N: "ps",
+ },
+ },
+ data: {
+ key: {
+ checked: "checked",
+ },
+ },
+ callback: {
+ beforeCheck: null,
+ onCheck: null,
+ },
+ },
+ //default root of excheck
+ _initRoot = function (setting) {
+ var r = data.getRoot(setting);
+ r.radioCheckedList = [];
+ },
+ //default cache of excheck
+ _initCache = function (treeId) {},
+ //default bind event of excheck
+ _bindEvent = function (setting) {
+ var o = setting.treeObj,
+ c = consts.event;
+ o.bind(c.CHECK, function (event, srcEvent, treeId, node) {
+ event.srcEvent = srcEvent;
+ tools.apply(setting.callback.onCheck, [event, treeId, node]);
+ });
+ },
+ _unbindEvent = function (setting) {
+ var o = setting.treeObj,
+ c = consts.event;
+ o.unbind(c.CHECK);
+ },
+ //default event proxy of excheck
+ _eventProxy = function (e) {
+ var target = e.target,
+ setting = data.getSetting(e.data.treeId),
+ tId = "",
+ node = null,
+ nodeEventType = "",
+ treeEventType = "",
+ nodeEventCallback = null,
+ treeEventCallback = null;
- if (tools.eqs(e.type, "mouseover")) {
- if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode" + consts.id.CHECK) !== null) {
- tId = tools.getNodeMainDom(target).id;
- nodeEventType = "mouseoverCheck";
- }
- } else if (tools.eqs(e.type, "mouseout")) {
- if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode" + consts.id.CHECK) !== null) {
- tId = tools.getNodeMainDom(target).id;
- nodeEventType = "mouseoutCheck";
- }
- } else if (tools.eqs(e.type, "click")) {
- if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode" + consts.id.CHECK) !== null) {
- tId = tools.getNodeMainDom(target).id;
- nodeEventType = "checkNode";
- }
- }
- if (tId.length > 0) {
- node = data.getNodeCache(setting, tId);
- switch (nodeEventType) {
- case "checkNode" :
- nodeEventCallback = _handler.onCheckNode;
- break;
- case "mouseoverCheck" :
- nodeEventCallback = _handler.onMouseoverCheck;
- break;
- case "mouseoutCheck" :
- nodeEventCallback = _handler.onMouseoutCheck;
- break;
- }
- }
- var proxyResult = {
- stop: nodeEventType === "checkNode",
- node: node,
- nodeEventType: nodeEventType,
- nodeEventCallback: nodeEventCallback,
- treeEventType: treeEventType,
- treeEventCallback: treeEventCallback
- };
- return proxyResult;
- },
- //default init node of excheck
- _initNode = function (setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) {
- if (!n) return;
- var checkedKey = setting.data.key.checked;
- if (typeof n[checkedKey] == "string") n[checkedKey] = tools.eqs(n[checkedKey], "true");
- n[checkedKey] = !!n[checkedKey];
- n.checkedOld = n[checkedKey];
- if (typeof n.nocheck == "string") n.nocheck = tools.eqs(n.nocheck, "true");
- n.nocheck = !!n.nocheck || (setting.check.nocheckInherit && parentNode && !!parentNode.nocheck);
- if (typeof n.chkDisabled == "string") n.chkDisabled = tools.eqs(n.chkDisabled, "true");
- n.chkDisabled = !!n.chkDisabled || (setting.check.chkDisabledInherit && parentNode && !!parentNode.chkDisabled);
- if (typeof n.halfCheck == "string") n.halfCheck = tools.eqs(n.halfCheck, "true");
- n.halfCheck = !!n.halfCheck;
- n.check_Child_State = -1;
- n.check_Focus = false;
- n.getCheckStatus = function () {
- return data.getCheckStatus(setting, n);
- };
+ if (tools.eqs(e.type, "mouseover")) {
+ if (
+ setting.check.enable &&
+ tools.eqs(target.tagName, "span") &&
+ target.getAttribute("treeNode" + consts.id.CHECK) !== null
+ ) {
+ tId = tools.getNodeMainDom(target).id;
+ nodeEventType = "mouseoverCheck";
+ }
+ } else if (tools.eqs(e.type, "mouseout")) {
+ if (
+ setting.check.enable &&
+ tools.eqs(target.tagName, "span") &&
+ target.getAttribute("treeNode" + consts.id.CHECK) !== null
+ ) {
+ tId = tools.getNodeMainDom(target).id;
+ nodeEventType = "mouseoutCheck";
+ }
+ } else if (tools.eqs(e.type, "click")) {
+ if (
+ setting.check.enable &&
+ tools.eqs(target.tagName, "span") &&
+ target.getAttribute("treeNode" + consts.id.CHECK) !== null
+ ) {
+ tId = tools.getNodeMainDom(target).id;
+ nodeEventType = "checkNode";
+ }
+ }
+ if (tId.length > 0) {
+ node = data.getNodeCache(setting, tId);
+ switch (nodeEventType) {
+ case "checkNode":
+ nodeEventCallback = _handler.onCheckNode;
+ break;
+ case "mouseoverCheck":
+ nodeEventCallback = _handler.onMouseoverCheck;
+ break;
+ case "mouseoutCheck":
+ nodeEventCallback = _handler.onMouseoutCheck;
+ break;
+ }
+ }
+ var proxyResult = {
+ stop: nodeEventType === "checkNode",
+ node: node,
+ nodeEventType: nodeEventType,
+ nodeEventCallback: nodeEventCallback,
+ treeEventType: treeEventType,
+ treeEventCallback: treeEventCallback,
+ };
+ return proxyResult;
+ },
+ //default init node of excheck
+ _initNode = function (setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) {
+ if (!n) return;
+ var checkedKey = setting.data.key.checked;
+ if (typeof n[checkedKey] == "string") n[checkedKey] = tools.eqs(n[checkedKey], "true");
+ n[checkedKey] = !!n[checkedKey];
+ n.checkedOld = n[checkedKey];
+ if (typeof n.nocheck == "string") n.nocheck = tools.eqs(n.nocheck, "true");
+ n.nocheck = !!n.nocheck || (setting.check.nocheckInherit && parentNode && !!parentNode.nocheck);
+ if (typeof n.chkDisabled == "string") n.chkDisabled = tools.eqs(n.chkDisabled, "true");
+ n.chkDisabled =
+ !!n.chkDisabled || (setting.check.chkDisabledInherit && parentNode && !!parentNode.chkDisabled);
+ if (typeof n.halfCheck == "string") n.halfCheck = tools.eqs(n.halfCheck, "true");
+ n.halfCheck = !!n.halfCheck;
+ n.check_Child_State = -1;
+ n.check_Focus = false;
+ n.getCheckStatus = function () {
+ return data.getCheckStatus(setting, n);
+ };
- if (setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL && n[checkedKey]) {
- var r = data.getRoot(setting);
- r.radioCheckedList.push(n);
- }
- },
- //add dom for check
- _beforeA = function (setting, node, html) {
- var checkedKey = setting.data.key.checked;
- if (setting.check.enable) {
- data.makeChkFlag(setting, node);
- html.push("");
- }
- },
- //update zTreeObj, add method of check
- _zTreeTools = function (setting, zTreeTools) {
- zTreeTools.checkNode = function (node, checked, checkTypeFlag, callbackFlag) {
- var checkedKey = this.setting.data.key.checked;
- if (node.chkDisabled === true) return;
- if (checked !== true && checked !== false) {
- checked = !node[checkedKey];
- }
- callbackFlag = !!callbackFlag;
+ if (
+ setting.check.chkStyle == consts.radio.STYLE &&
+ setting.check.radioType == consts.radio.TYPE_ALL &&
+ n[checkedKey]
+ ) {
+ var r = data.getRoot(setting);
+ r.radioCheckedList.push(n);
+ }
+ },
+ //add dom for check
+ _beforeA = function (setting, node, html) {
+ var checkedKey = setting.data.key.checked;
+ if (setting.check.enable) {
+ data.makeChkFlag(setting, node);
+ html.push(
+ ""
+ );
+ }
+ },
+ //update zTreeObj, add method of check
+ _zTreeTools = function (setting, zTreeTools) {
+ zTreeTools.checkNode = function (node, checked, checkTypeFlag, callbackFlag) {
+ var checkedKey = this.setting.data.key.checked;
+ if (node.chkDisabled === true) return;
+ if (checked !== true && checked !== false) {
+ checked = !node[checkedKey];
+ }
+ callbackFlag = !!callbackFlag;
- if (node[checkedKey] === checked && !checkTypeFlag) {
- return;
- } else if (callbackFlag && tools.apply(this.setting.callback.beforeCheck, [this.setting.treeId, node], true) == false) {
- return;
- }
- if (tools.uCanDo(this.setting) && this.setting.check.enable && node.nocheck !== true) {
- node[checkedKey] = checked;
- var checkObj = $$(node, consts.id.CHECK, this.setting);
- if (checkTypeFlag || this.setting.check.chkStyle === consts.radio.STYLE) view.checkNodeRelation(this.setting, node);
- view.setChkClass(this.setting, checkObj, node);
- view.repairParentChkClassWithSelf(this.setting, node);
- if (callbackFlag) {
- this.setting.treeObj.trigger(consts.event.CHECK, [null, this.setting.treeId, node]);
- }
- }
- };
+ if (node[checkedKey] === checked && !checkTypeFlag) {
+ return;
+ } else if (
+ callbackFlag &&
+ tools.apply(this.setting.callback.beforeCheck, [this.setting.treeId, node], true) == false
+ ) {
+ return;
+ }
+ if (tools.uCanDo(this.setting) && this.setting.check.enable && node.nocheck !== true) {
+ node[checkedKey] = checked;
+ var checkObj = $$(node, consts.id.CHECK, this.setting);
+ if (checkTypeFlag || this.setting.check.chkStyle === consts.radio.STYLE)
+ view.checkNodeRelation(this.setting, node);
+ view.setChkClass(this.setting, checkObj, node);
+ view.repairParentChkClassWithSelf(this.setting, node);
+ if (callbackFlag) {
+ this.setting.treeObj.trigger(consts.event.CHECK, [null, this.setting.treeId, node]);
+ }
+ }
+ };
- zTreeTools.checkAllNodes = function (checked) {
- view.repairAllChk(this.setting, !!checked);
- };
+ zTreeTools.checkAllNodes = function (checked) {
+ view.repairAllChk(this.setting, !!checked);
+ };
- zTreeTools.getCheckedNodes = function (checked) {
- var childKey = this.setting.data.key.children;
- checked = (checked !== false);
- return data.getTreeCheckedNodes(this.setting, data.getRoot(this.setting)[childKey], checked);
- };
+ zTreeTools.getCheckedNodes = function (checked) {
+ var childKey = this.setting.data.key.children;
+ checked = checked !== false;
+ return data.getTreeCheckedNodes(this.setting, data.getRoot(this.setting)[childKey], checked);
+ };
- zTreeTools.getChangeCheckedNodes = function () {
- var childKey = this.setting.data.key.children;
- return data.getTreeChangeCheckedNodes(this.setting, data.getRoot(this.setting)[childKey]);
- };
+ zTreeTools.getChangeCheckedNodes = function () {
+ var childKey = this.setting.data.key.children;
+ return data.getTreeChangeCheckedNodes(this.setting, data.getRoot(this.setting)[childKey]);
+ };
- zTreeTools.setChkDisabled = function (node, disabled, inheritParent, inheritChildren) {
- disabled = !!disabled;
- inheritParent = !!inheritParent;
- inheritChildren = !!inheritChildren;
- view.repairSonChkDisabled(this.setting, node, disabled, inheritChildren);
- view.repairParentChkDisabled(this.setting, node.getParentNode(), disabled, inheritParent);
- };
+ zTreeTools.setChkDisabled = function (node, disabled, inheritParent, inheritChildren) {
+ disabled = !!disabled;
+ inheritParent = !!inheritParent;
+ inheritChildren = !!inheritChildren;
+ view.repairSonChkDisabled(this.setting, node, disabled, inheritChildren);
+ view.repairParentChkDisabled(this.setting, node.getParentNode(), disabled, inheritParent);
+ };
- var _updateNode = zTreeTools.updateNode;
- zTreeTools.updateNode = function (node, checkTypeFlag) {
- if (_updateNode) _updateNode.apply(zTreeTools, arguments);
- if (!node || !this.setting.check.enable) return;
- var nObj = $$(node, this.setting);
- if (nObj.get(0) && tools.uCanDo(this.setting)) {
- var checkObj = $$(node, consts.id.CHECK, this.setting);
- if (checkTypeFlag == true || this.setting.check.chkStyle === consts.radio.STYLE) view.checkNodeRelation(this.setting, node);
- view.setChkClass(this.setting, checkObj, node);
- view.repairParentChkClassWithSelf(this.setting, node);
- }
- };
- },
- //method of operate data
- _data = {
- getRadioCheckedList: function (setting) {
- var checkedList = data.getRoot(setting).radioCheckedList;
- for (var i = 0, j = checkedList.length; i < j; i++) {
- if (!data.getNodeCache(setting, checkedList[i].tId)) {
- checkedList.splice(i, 1);
- i--;
- j--;
- }
- }
- return checkedList;
- },
- getCheckStatus: function (setting, node) {
- if (!setting.check.enable || node.nocheck || node.chkDisabled) return null;
- var checkedKey = setting.data.key.checked,
- r = {
- checked: node[checkedKey],
- half: node.halfCheck ? node.halfCheck : (setting.check.chkStyle == consts.radio.STYLE ? (node.check_Child_State === 2) : (node[checkedKey] ? (node.check_Child_State > -1 && node.check_Child_State < 2) : (node.check_Child_State > 0)))
- };
- return r;
- },
- getTreeCheckedNodes: function (setting, nodes, checked, results) {
- if (!nodes) return [];
- var childKey = setting.data.key.children,
- checkedKey = setting.data.key.checked,
- onlyOne = (checked && setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL);
- results = !results ? [] : results;
- for (var i = 0, l = nodes.length; i < l; i++) {
- if (nodes[i].nocheck !== true && nodes[i].chkDisabled !== true && nodes[i][checkedKey] == checked) {
- results.push(nodes[i]);
- if (onlyOne) {
- break;
- }
- }
- data.getTreeCheckedNodes(setting, nodes[i][childKey], checked, results);
- if (onlyOne && results.length > 0) {
- break;
- }
- }
- return results;
- },
- getTreeChangeCheckedNodes: function (setting, nodes, results) {
- if (!nodes) return [];
- var childKey = setting.data.key.children,
- checkedKey = setting.data.key.checked;
- results = !results ? [] : results;
- for (var i = 0, l = nodes.length; i < l; i++) {
- if (nodes[i].nocheck !== true && nodes[i].chkDisabled !== true && nodes[i][checkedKey] != nodes[i].checkedOld) {
- results.push(nodes[i]);
- }
- data.getTreeChangeCheckedNodes(setting, nodes[i][childKey], results);
- }
- return results;
- },
- makeChkFlag: function (setting, node) {
- if (!node) return;
- var childKey = setting.data.key.children,
- checkedKey = setting.data.key.checked,
- chkFlag = -1;
- if (node[childKey]) {
- for (var i = 0, l = node[childKey].length; i < l; i++) {
- var cNode = node[childKey][i];
- var tmp = -1;
- if (setting.check.chkStyle == consts.radio.STYLE) {
- if (cNode.nocheck === true || cNode.chkDisabled === true) {
- tmp = cNode.check_Child_State;
- } else if (cNode.halfCheck === true) {
- tmp = 2;
- } else if (cNode[checkedKey]) {
- tmp = 2;
- } else {
- tmp = cNode.check_Child_State > 0 ? 2 : 0;
- }
- if (tmp == 2) {
- chkFlag = 2;
- break;
- } else if (tmp == 0) {
- chkFlag = 0;
- }
- } else if (setting.check.chkStyle == consts.checkbox.STYLE) {
- if (cNode.nocheck === true || cNode.chkDisabled === true) {
- tmp = cNode.check_Child_State;
- } else if (cNode.halfCheck === true) {
- tmp = 1;
- } else if (cNode[checkedKey]) {
- tmp = (cNode.check_Child_State === -1 || cNode.check_Child_State === 2) ? 2 : 1;
- } else {
- tmp = (cNode.check_Child_State > 0) ? 1 : 0;
- }
- if (tmp === 1) {
- chkFlag = 1;
- break;
- } else if (tmp === 2 && chkFlag > -1 && i > 0 && tmp !== chkFlag) {
- chkFlag = 1;
- break;
- } else if (chkFlag === 2 && tmp > -1 && tmp < 2) {
- chkFlag = 1;
- break;
- } else if (tmp > -1) {
- chkFlag = tmp;
- }
- }
- }
- }
- node.check_Child_State = chkFlag;
- }
- },
- //method of event proxy
- _event = {},
- //method of event handler
- _handler = {
- onCheckNode: function (event, node) {
- if (node.chkDisabled === true) return false;
- var setting = data.getSetting(event.data.treeId),
- checkedKey = setting.data.key.checked;
- if (tools.apply(setting.callback.beforeCheck, [setting.treeId, node], true) == false) return true;
- node[checkedKey] = !node[checkedKey];
- view.checkNodeRelation(setting, node);
- var checkObj = $$(node, consts.id.CHECK, setting);
- view.setChkClass(setting, checkObj, node);
- view.repairParentChkClassWithSelf(setting, node);
- setting.treeObj.trigger(consts.event.CHECK, [event, setting.treeId, node]);
- return true;
- },
- onMouseoverCheck: function (event, node) {
- if (node.chkDisabled === true) return false;
- var setting = data.getSetting(event.data.treeId),
- checkObj = $$(node, consts.id.CHECK, setting);
- node.check_Focus = true;
- view.setChkClass(setting, checkObj, node);
- return true;
- },
- onMouseoutCheck: function (event, node) {
- if (node.chkDisabled === true) return false;
- var setting = data.getSetting(event.data.treeId),
- checkObj = $$(node, consts.id.CHECK, setting);
- node.check_Focus = false;
- view.setChkClass(setting, checkObj, node);
- return true;
- }
- },
- //method of tools for zTree
- _tools = {},
- //method of operate ztree dom
- _view = {
- checkNodeRelation: function (setting, node) {
- var pNode, i, l,
- childKey = setting.data.key.children,
- checkedKey = setting.data.key.checked,
- r = consts.radio;
- if (setting.check.chkStyle == r.STYLE) {
- var checkedList = data.getRadioCheckedList(setting);
- if (node[checkedKey]) {
- if (setting.check.radioType == r.TYPE_ALL) {
- for (i = checkedList.length - 1; i >= 0; i--) {
- pNode = checkedList[i];
- if (pNode[checkedKey] && pNode != node) {
- pNode[checkedKey] = false;
- checkedList.splice(i, 1);
+ var _updateNode = zTreeTools.updateNode;
+ zTreeTools.updateNode = function (node, checkTypeFlag) {
+ if (_updateNode) _updateNode.apply(zTreeTools, arguments);
+ if (!node || !this.setting.check.enable) return;
+ var nObj = $$(node, this.setting);
+ if (nObj.get(0) && tools.uCanDo(this.setting)) {
+ var checkObj = $$(node, consts.id.CHECK, this.setting);
+ if (checkTypeFlag == true || this.setting.check.chkStyle === consts.radio.STYLE)
+ view.checkNodeRelation(this.setting, node);
+ view.setChkClass(this.setting, checkObj, node);
+ view.repairParentChkClassWithSelf(this.setting, node);
+ }
+ };
+ },
+ //method of operate data
+ _data = {
+ getRadioCheckedList: function (setting) {
+ var checkedList = data.getRoot(setting).radioCheckedList;
+ for (var i = 0, j = checkedList.length; i < j; i++) {
+ if (!data.getNodeCache(setting, checkedList[i].tId)) {
+ checkedList.splice(i, 1);
+ i--;
+ j--;
+ }
+ }
+ return checkedList;
+ },
+ getCheckStatus: function (setting, node) {
+ if (!setting.check.enable || node.nocheck || node.chkDisabled) return null;
+ var checkedKey = setting.data.key.checked,
+ r = {
+ checked: node[checkedKey],
+ half: node.halfCheck
+ ? node.halfCheck
+ : setting.check.chkStyle == consts.radio.STYLE
+ ? node.check_Child_State === 2
+ : node[checkedKey]
+ ? node.check_Child_State > -1 && node.check_Child_State < 2
+ : node.check_Child_State > 0,
+ };
+ return r;
+ },
+ getTreeCheckedNodes: function (setting, nodes, checked, results) {
+ if (!nodes) return [];
+ var childKey = setting.data.key.children,
+ checkedKey = setting.data.key.checked,
+ onlyOne =
+ checked &&
+ setting.check.chkStyle == consts.radio.STYLE &&
+ setting.check.radioType == consts.radio.TYPE_ALL;
+ results = !results ? [] : results;
+ for (var i = 0, l = nodes.length; i < l; i++) {
+ if (nodes[i].nocheck !== true && nodes[i].chkDisabled !== true && nodes[i][checkedKey] == checked) {
+ results.push(nodes[i]);
+ if (onlyOne) {
+ break;
+ }
+ }
+ data.getTreeCheckedNodes(setting, nodes[i][childKey], checked, results);
+ if (onlyOne && results.length > 0) {
+ break;
+ }
+ }
+ return results;
+ },
+ getTreeChangeCheckedNodes: function (setting, nodes, results) {
+ if (!nodes) return [];
+ var childKey = setting.data.key.children,
+ checkedKey = setting.data.key.checked;
+ results = !results ? [] : results;
+ for (var i = 0, l = nodes.length; i < l; i++) {
+ if (
+ nodes[i].nocheck !== true &&
+ nodes[i].chkDisabled !== true &&
+ nodes[i][checkedKey] != nodes[i].checkedOld
+ ) {
+ results.push(nodes[i]);
+ }
+ data.getTreeChangeCheckedNodes(setting, nodes[i][childKey], results);
+ }
+ return results;
+ },
+ makeChkFlag: function (setting, node) {
+ if (!node) return;
+ var childKey = setting.data.key.children,
+ checkedKey = setting.data.key.checked,
+ chkFlag = -1;
+ if (node[childKey]) {
+ for (var i = 0, l = node[childKey].length; i < l; i++) {
+ var cNode = node[childKey][i];
+ var tmp = -1;
+ if (setting.check.chkStyle == consts.radio.STYLE) {
+ if (cNode.nocheck === true || cNode.chkDisabled === true) {
+ tmp = cNode.check_Child_State;
+ } else if (cNode.halfCheck === true) {
+ tmp = 2;
+ } else if (cNode[checkedKey]) {
+ tmp = 2;
+ } else {
+ tmp = cNode.check_Child_State > 0 ? 2 : 0;
+ }
+ if (tmp == 2) {
+ chkFlag = 2;
+ break;
+ } else if (tmp == 0) {
+ chkFlag = 0;
+ }
+ } else if (setting.check.chkStyle == consts.checkbox.STYLE) {
+ if (cNode.nocheck === true || cNode.chkDisabled === true) {
+ tmp = cNode.check_Child_State;
+ } else if (cNode.halfCheck === true) {
+ tmp = 1;
+ } else if (cNode[checkedKey]) {
+ tmp = cNode.check_Child_State === -1 || cNode.check_Child_State === 2 ? 2 : 1;
+ } else {
+ tmp = cNode.check_Child_State > 0 ? 1 : 0;
+ }
+ if (tmp === 1) {
+ chkFlag = 1;
+ break;
+ } else if (tmp === 2 && chkFlag > -1 && i > 0 && tmp !== chkFlag) {
+ chkFlag = 1;
+ break;
+ } else if (chkFlag === 2 && tmp > -1 && tmp < 2) {
+ chkFlag = 1;
+ break;
+ } else if (tmp > -1) {
+ chkFlag = tmp;
+ }
+ }
+ }
+ }
+ node.check_Child_State = chkFlag;
+ },
+ },
+ //method of event proxy
+ _event = {},
+ //method of event handler
+ _handler = {
+ onCheckNode: function (event, node) {
+ if (node.chkDisabled === true) return false;
+ var setting = data.getSetting(event.data.treeId),
+ checkedKey = setting.data.key.checked;
+ if (tools.apply(setting.callback.beforeCheck, [setting.treeId, node], true) == false) return true;
+ node[checkedKey] = !node[checkedKey];
+ view.checkNodeRelation(setting, node);
+ var checkObj = $$(node, consts.id.CHECK, setting);
+ view.setChkClass(setting, checkObj, node);
+ view.repairParentChkClassWithSelf(setting, node);
+ setting.treeObj.trigger(consts.event.CHECK, [event, setting.treeId, node]);
+ return true;
+ },
+ onMouseoverCheck: function (event, node) {
+ if (node.chkDisabled === true) return false;
+ var setting = data.getSetting(event.data.treeId),
+ checkObj = $$(node, consts.id.CHECK, setting);
+ node.check_Focus = true;
+ view.setChkClass(setting, checkObj, node);
+ return true;
+ },
+ onMouseoutCheck: function (event, node) {
+ if (node.chkDisabled === true) return false;
+ var setting = data.getSetting(event.data.treeId),
+ checkObj = $$(node, consts.id.CHECK, setting);
+ node.check_Focus = false;
+ view.setChkClass(setting, checkObj, node);
+ return true;
+ },
+ },
+ //method of tools for zTree
+ _tools = {},
+ //method of operate ztree dom
+ _view = {
+ checkNodeRelation: function (setting, node) {
+ var pNode,
+ i,
+ l,
+ childKey = setting.data.key.children,
+ checkedKey = setting.data.key.checked,
+ r = consts.radio;
+ if (setting.check.chkStyle == r.STYLE) {
+ var checkedList = data.getRadioCheckedList(setting);
+ if (node[checkedKey]) {
+ if (setting.check.radioType == r.TYPE_ALL) {
+ for (i = checkedList.length - 1; i >= 0; i--) {
+ pNode = checkedList[i];
+ if (pNode[checkedKey] && pNode != node) {
+ pNode[checkedKey] = false;
+ checkedList.splice(i, 1);
- view.setChkClass(setting, $$(pNode, consts.id.CHECK, setting), pNode);
- if (pNode.parentTId != node.parentTId) {
- view.repairParentChkClassWithSelf(setting, pNode);
- }
- }
- }
- checkedList.push(node);
- } else {
- var parentNode = (node.parentTId) ? node.getParentNode() : data.getRoot(setting);
- for (i = 0, l = parentNode[childKey].length; i < l; i++) {
- pNode = parentNode[childKey][i];
- if (pNode[checkedKey] && pNode != node) {
- pNode[checkedKey] = false;
- view.setChkClass(setting, $$(pNode, consts.id.CHECK, setting), pNode);
- }
- }
- }
- } else if (setting.check.radioType == r.TYPE_ALL) {
- for (i = 0, l = checkedList.length; i < l; i++) {
- if (node == checkedList[i]) {
- checkedList.splice(i, 1);
- break;
- }
- }
- }
+ view.setChkClass(setting, $$(pNode, consts.id.CHECK, setting), pNode);
+ if (pNode.parentTId != node.parentTId) {
+ view.repairParentChkClassWithSelf(setting, pNode);
+ }
+ }
+ }
+ checkedList.push(node);
+ } else {
+ var parentNode = node.parentTId ? node.getParentNode() : data.getRoot(setting);
+ for (i = 0, l = parentNode[childKey].length; i < l; i++) {
+ pNode = parentNode[childKey][i];
+ if (pNode[checkedKey] && pNode != node) {
+ pNode[checkedKey] = false;
+ view.setChkClass(setting, $$(pNode, consts.id.CHECK, setting), pNode);
+ }
+ }
+ }
+ } else if (setting.check.radioType == r.TYPE_ALL) {
+ for (i = 0, l = checkedList.length; i < l; i++) {
+ if (node == checkedList[i]) {
+ checkedList.splice(i, 1);
+ break;
+ }
+ }
+ }
+ } else {
+ if (
+ node[checkedKey] &&
+ (!node[childKey] || node[childKey].length == 0 || setting.check.chkboxType.Y.indexOf("s") > -1)
+ ) {
+ view.setSonNodeCheckBox(setting, node, true);
+ }
+ if (
+ !node[checkedKey] &&
+ (!node[childKey] || node[childKey].length == 0 || setting.check.chkboxType.N.indexOf("s") > -1)
+ ) {
+ view.setSonNodeCheckBox(setting, node, false);
+ }
+ if (node[checkedKey] && setting.check.chkboxType.Y.indexOf("p") > -1) {
+ view.setParentNodeCheckBox(setting, node, true);
+ }
+ if (!node[checkedKey] && setting.check.chkboxType.N.indexOf("p") > -1) {
+ view.setParentNodeCheckBox(setting, node, false);
+ }
+ }
+ },
+ makeChkClass: function (setting, node) {
+ var checkedKey = setting.data.key.checked,
+ c = consts.checkbox,
+ r = consts.radio,
+ checkboxType = setting.check.chkboxType;
+ var notEffectByOtherNode = checkboxType.Y === "" && checkboxType.N === "";
+ fullStyle = "";
+ if (node.chkDisabled === true) {
+ fullStyle = c.DISABLED;
+ } else if (node.halfCheck) {
+ fullStyle = c.PART;
+ } else if (setting.check.chkStyle == r.STYLE) {
+ fullStyle = node.check_Child_State < 1 ? c.FULL : c.PART;
+ } else {
+ fullStyle = node[checkedKey]
+ ? node.check_Child_State === 2 || node.check_Child_State === -1 || notEffectByOtherNode
+ ? c.FULL
+ : c.PART
+ : node.check_Child_State < 1 || notEffectByOtherNode
+ ? c.FULL
+ : c.PART;
+ }
+ var chkName = setting.check.chkStyle + "_" + (node[checkedKey] ? c.TRUE : c.FALSE) + "_" + fullStyle;
+ chkName = node.check_Focus && node.chkDisabled !== true ? chkName + "_" + c.FOCUS : chkName;
+ var chClass = consts.className.BUTTON + " " + c.DEFAULT + " " + chkName;
+ switch (chkName) {
+ case "checkbox_true_part":
+ case "checkbox_true_part_focus":
+ chClass += " bi-half-button bi-high-light-border";
+ break;
+ case "checkbox_true_full":
+ case "checkbox_true_full_focus":
+ chClass += " bi-checkbox checkbox-content bi-high-light-background active";
+ break;
+ case "checkbox_false_full":
+ case "checkbox_false_full_focus":
+ default:
+ chClass += " bi-checkbox checkbox-content";
+ break;
+ }
+ return chClass + (node.disabled ? " disabled" : "");
+ },
+ repairAllChk: function (setting, checked) {
+ if (setting.check.enable && setting.check.chkStyle === consts.checkbox.STYLE) {
+ var checkedKey = setting.data.key.checked,
+ childKey = setting.data.key.children,
+ root = data.getRoot(setting);
+ for (var i = 0, l = root[childKey].length; i < l; i++) {
+ var node = root[childKey][i];
+ if (node.nocheck !== true && node.chkDisabled !== true) {
+ node[checkedKey] = checked;
+ }
+ view.setSonNodeCheckBox(setting, node, checked);
+ }
+ }
+ },
+ repairChkClass: function (setting, node) {
+ if (!node) return;
+ data.makeChkFlag(setting, node);
+ if (node.nocheck !== true) {
+ var checkObj = $$(node, consts.id.CHECK, setting);
+ view.setChkClass(setting, checkObj, node);
+ }
+ },
+ repairParentChkClass: function (setting, node) {
+ if (!node || !node.parentTId) return;
+ var pNode = node.getParentNode();
+ view.repairChkClass(setting, pNode);
+ view.repairParentChkClass(setting, pNode);
+ },
+ repairParentChkClassWithSelf: function (setting, node) {
+ if (!node) return;
+ var childKey = setting.data.key.children;
+ if (node[childKey] && node[childKey].length > 0) {
+ view.repairParentChkClass(setting, node[childKey][0]);
+ } else {
+ view.repairParentChkClass(setting, node);
+ }
+ },
+ repairSonChkDisabled: function (setting, node, chkDisabled, inherit) {
+ if (!node) return;
+ var childKey = setting.data.key.children;
+ if (node.chkDisabled != chkDisabled) {
+ node.chkDisabled = chkDisabled;
+ }
+ view.repairChkClass(setting, node);
+ if (node[childKey] && inherit) {
+ for (var i = 0, l = node[childKey].length; i < l; i++) {
+ var sNode = node[childKey][i];
+ view.repairSonChkDisabled(setting, sNode, chkDisabled, inherit);
+ }
+ }
+ },
+ repairParentChkDisabled: function (setting, node, chkDisabled, inherit) {
+ if (!node) return;
+ if (node.chkDisabled != chkDisabled && inherit) {
+ node.chkDisabled = chkDisabled;
+ }
+ view.repairChkClass(setting, node);
+ view.repairParentChkDisabled(setting, node.getParentNode(), chkDisabled, inherit);
+ },
+ setChkClass: function (setting, obj, node) {
+ if (!obj) return;
+ if (node.nocheck === true) {
+ obj.hide();
+ } else {
+ obj.show();
+ }
+ obj.attr("class", view.makeChkClass(setting, node));
+ },
+ setParentNodeCheckBox: function (setting, node, value, srcNode) {
+ var childKey = setting.data.key.children,
+ checkedKey = setting.data.key.checked,
+ checkObj = $$(node, consts.id.CHECK, setting);
+ if (!srcNode) srcNode = node;
+ data.makeChkFlag(setting, node);
+ if (node.nocheck !== true && node.chkDisabled !== true) {
+ node[checkedKey] = value;
+ view.setChkClass(setting, checkObj, node);
+ if (setting.check.autoCheckTrigger && node != srcNode) {
+ setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]);
+ }
+ }
+ if (node.parentTId) {
+ var pSign = true;
+ if (!value) {
+ var pNodes = node.getParentNode()[childKey];
+ for (var i = 0, l = pNodes.length; i < l; i++) {
+ if (
+ (pNodes[i].nocheck !== true &&
+ pNodes[i].chkDisabled !== true &&
+ pNodes[i][checkedKey]) ||
+ ((pNodes[i].nocheck === true || pNodes[i].chkDisabled === true) &&
+ pNodes[i].check_Child_State > 0)
+ ) {
+ pSign = false;
+ break;
+ }
+ }
+ }
+ if (pSign) {
+ view.setParentNodeCheckBox(setting, node.getParentNode(), value, srcNode);
+ }
+ }
+ },
+ setSonNodeCheckBox: function (setting, node, value, srcNode) {
+ if (!node) return;
+ var childKey = setting.data.key.children,
+ checkedKey = setting.data.key.checked,
+ checkObj = $$(node, consts.id.CHECK, setting);
+ if (!srcNode) srcNode = node;
- } else {
- if (node[checkedKey] && (!node[childKey] || node[childKey].length == 0 || setting.check.chkboxType.Y.indexOf("s") > -1)) {
- view.setSonNodeCheckBox(setting, node, true);
- }
- if (!node[checkedKey] && (!node[childKey] || node[childKey].length == 0 || setting.check.chkboxType.N.indexOf("s") > -1)) {
- view.setSonNodeCheckBox(setting, node, false);
- }
- if (node[checkedKey] && setting.check.chkboxType.Y.indexOf("p") > -1) {
- view.setParentNodeCheckBox(setting, node, true);
- }
- if (!node[checkedKey] && setting.check.chkboxType.N.indexOf("p") > -1) {
- view.setParentNodeCheckBox(setting, node, false);
- }
- }
- },
- makeChkClass: function (setting, node) {
- var checkedKey = setting.data.key.checked,
- c = consts.checkbox, r = consts.radio,
- checkboxType = setting.check.chkboxType;
- var notEffectByOtherNode = (checkboxType.Y === "" && checkboxType.N === "");
- fullStyle = "";
- if (node.chkDisabled === true) {
- fullStyle = c.DISABLED;
- } else if (node.halfCheck) {
- fullStyle = c.PART;
- } else if (setting.check.chkStyle == r.STYLE) {
- fullStyle = (node.check_Child_State < 1) ? c.FULL : c.PART;
- } else {
- fullStyle = node[checkedKey] ? ((node.check_Child_State === 2 || node.check_Child_State === -1) || notEffectByOtherNode ? c.FULL : c.PART) : ((node.check_Child_State < 1 || notEffectByOtherNode) ? c.FULL : c.PART);
- }
- var chkName = setting.check.chkStyle + "_" + (node[checkedKey] ? c.TRUE : c.FALSE) + "_" + fullStyle;
- chkName = (node.check_Focus && node.chkDisabled !== true) ? chkName + "_" + c.FOCUS : chkName;
- var chClass = consts.className.BUTTON + " " + c.DEFAULT + " " + chkName;
- switch (chkName) {
- case 'checkbox_true_part':
- case 'checkbox_true_part_focus':
- chClass += ' bi-half-button bi-high-light-border';
- break;
- case 'checkbox_true_full':
- case 'checkbox_true_full_focus':
- chClass += ' bi-checkbox checkbox-content bi-high-light-background active';
- break;
- case 'checkbox_false_full':
- case 'checkbox_false_full_focus':
- default:
- chClass += ' bi-checkbox checkbox-content';
- break;
- }
- return chClass + (node.disabled ? " disabled" : "");
- },
- repairAllChk: function (setting, checked) {
- if (setting.check.enable && setting.check.chkStyle === consts.checkbox.STYLE) {
- var checkedKey = setting.data.key.checked,
- childKey = setting.data.key.children,
- root = data.getRoot(setting);
- for (var i = 0, l = root[childKey].length; i < l; i++) {
- var node = root[childKey][i];
- if (node.nocheck !== true && node.chkDisabled !== true) {
- node[checkedKey] = checked;
- }
- view.setSonNodeCheckBox(setting, node, checked);
- }
- }
- },
- repairChkClass: function (setting, node) {
- if (!node) return;
- data.makeChkFlag(setting, node);
- if (node.nocheck !== true) {
- var checkObj = $$(node, consts.id.CHECK, setting);
- view.setChkClass(setting, checkObj, node);
- }
- },
- repairParentChkClass: function (setting, node) {
- if (!node || !node.parentTId) return;
- var pNode = node.getParentNode();
- view.repairChkClass(setting, pNode);
- view.repairParentChkClass(setting, pNode);
- },
- repairParentChkClassWithSelf: function (setting, node) {
- if (!node) return;
- var childKey = setting.data.key.children;
- if (node[childKey] && node[childKey].length > 0) {
- view.repairParentChkClass(setting, node[childKey][0]);
- } else {
- view.repairParentChkClass(setting, node);
- }
- },
- repairSonChkDisabled: function (setting, node, chkDisabled, inherit) {
- if (!node) return;
- var childKey = setting.data.key.children;
- if (node.chkDisabled != chkDisabled) {
- node.chkDisabled = chkDisabled;
- }
- view.repairChkClass(setting, node);
- if (node[childKey] && inherit) {
- for (var i = 0, l = node[childKey].length; i < l; i++) {
- var sNode = node[childKey][i];
- view.repairSonChkDisabled(setting, sNode, chkDisabled, inherit);
- }
- }
- },
- repairParentChkDisabled: function (setting, node, chkDisabled, inherit) {
- if (!node) return;
- if (node.chkDisabled != chkDisabled && inherit) {
- node.chkDisabled = chkDisabled;
- }
- view.repairChkClass(setting, node);
- view.repairParentChkDisabled(setting, node.getParentNode(), chkDisabled, inherit);
- },
- setChkClass: function (setting, obj, node) {
- if (!obj) return;
- if (node.nocheck === true) {
- obj.hide();
- } else {
- obj.show();
- }
- obj.attr('class', view.makeChkClass(setting, node));
- },
- setParentNodeCheckBox: function (setting, node, value, srcNode) {
- var childKey = setting.data.key.children,
- checkedKey = setting.data.key.checked,
- checkObj = $$(node, consts.id.CHECK, setting);
- if (!srcNode) srcNode = node;
- data.makeChkFlag(setting, node);
- if (node.nocheck !== true && node.chkDisabled !== true) {
- node[checkedKey] = value;
- view.setChkClass(setting, checkObj, node);
- if (setting.check.autoCheckTrigger && node != srcNode) {
- setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]);
- }
- }
- if (node.parentTId) {
- var pSign = true;
- if (!value) {
- var pNodes = node.getParentNode()[childKey];
- for (var i = 0, l = pNodes.length; i < l; i++) {
- if ((pNodes[i].nocheck !== true && pNodes[i].chkDisabled !== true && pNodes[i][checkedKey])
- || ((pNodes[i].nocheck === true || pNodes[i].chkDisabled === true) && pNodes[i].check_Child_State > 0)) {
- pSign = false;
- break;
- }
- }
- }
- if (pSign) {
- view.setParentNodeCheckBox(setting, node.getParentNode(), value, srcNode);
- }
- }
- },
- setSonNodeCheckBox: function (setting, node, value, srcNode) {
- if (!node) return;
- var childKey = setting.data.key.children,
- checkedKey = setting.data.key.checked,
- checkObj = $$(node, consts.id.CHECK, setting);
- if (!srcNode) srcNode = node;
+ var hasDisable = false;
+ if (node[childKey]) {
+ for (var i = 0, l = node[childKey].length; i < l && node.chkDisabled !== true; i++) {
+ var sNode = node[childKey][i];
+ view.setSonNodeCheckBox(setting, sNode, value, srcNode);
+ if (sNode.chkDisabled === true) hasDisable = true;
+ }
+ }
- var hasDisable = false;
- if (node[childKey]) {
- for (var i = 0, l = node[childKey].length; i < l && node.chkDisabled !== true; i++) {
- var sNode = node[childKey][i];
- view.setSonNodeCheckBox(setting, sNode, value, srcNode);
- if (sNode.chkDisabled === true) hasDisable = true;
- }
- }
+ if (node != data.getRoot(setting) && node.chkDisabled !== true) {
+ if (hasDisable && node.nocheck !== true) {
+ data.makeChkFlag(setting, node);
+ }
+ if (node.nocheck !== true && node.chkDisabled !== true) {
+ node[checkedKey] = value;
+ if (!hasDisable)
+ node.check_Child_State = node[childKey] && node[childKey].length > 0 ? (value ? 2 : 0) : -1;
+ } else {
+ node.check_Child_State = -1;
+ }
+ view.setChkClass(setting, checkObj, node);
+ if (
+ setting.check.autoCheckTrigger &&
+ node != srcNode &&
+ node.nocheck !== true &&
+ node.chkDisabled !== true
+ ) {
+ setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]);
+ }
+ }
+ },
+ },
+ _z = {
+ tools: _tools,
+ view: _view,
+ event: _event,
+ data: _data,
+ };
+ $.extend(true, $.fn.zTree.consts, _consts);
+ $.extend(true, $.fn.zTree._z, _z);
- if (node != data.getRoot(setting) && node.chkDisabled !== true) {
- if (hasDisable && node.nocheck !== true) {
- data.makeChkFlag(setting, node);
- }
- if (node.nocheck !== true && node.chkDisabled !== true) {
- node[checkedKey] = value;
- if (!hasDisable) node.check_Child_State = (node[childKey] && node[childKey].length > 0) ? (value ? 2 : 0) : -1;
- } else {
- node.check_Child_State = -1;
- }
- view.setChkClass(setting, checkObj, node);
- if (setting.check.autoCheckTrigger && node != srcNode && node.nocheck !== true && node.chkDisabled !== true) {
- setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]);
- }
- }
+ var zt = $.fn.zTree,
+ tools = zt._z.tools,
+ consts = zt.consts,
+ view = zt._z.view,
+ data = zt._z.data,
+ event = zt._z.event,
+ $$ = tools.$;
- }
- },
+ data.exSetting(_setting);
+ data.addInitBind(_bindEvent);
+ data.addInitUnBind(_unbindEvent);
+ data.addInitCache(_initCache);
+ data.addInitNode(_initNode);
+ data.addInitProxy(_eventProxy, true);
+ data.addInitRoot(_initRoot);
+ data.addBeforeA(_beforeA);
+ data.addZTreeTools(_zTreeTools);
- _z = {
- tools: _tools,
- view: _view,
- event: _event,
- data: _data
- };
- $.extend(true, $.fn.zTree.consts, _consts);
- $.extend(true, $.fn.zTree._z, _z);
+ var _createNodes = view.createNodes;
+ view.createNodes = function (setting, level, nodes, parentNode) {
+ if (_createNodes) _createNodes.apply(view, arguments);
+ if (!nodes) return;
+ view.repairParentChkClassWithSelf(setting, parentNode);
+ };
+ var _removeNode = view.removeNode;
+ view.removeNode = function (setting, node) {
+ var parentNode = node.getParentNode();
+ if (_removeNode) _removeNode.apply(view, arguments);
+ if (!node || !parentNode) return;
+ view.repairChkClass(setting, parentNode);
+ view.repairParentChkClass(setting, parentNode);
+ };
- var zt = $.fn.zTree,
- tools = zt._z.tools,
- consts = zt.consts,
- view = zt._z.view,
- data = zt._z.data,
- event = zt._z.event,
- $$ = tools.$;
-
- data.exSetting(_setting);
- data.addInitBind(_bindEvent);
- data.addInitUnBind(_unbindEvent);
- data.addInitCache(_initCache);
- data.addInitNode(_initNode);
- data.addInitProxy(_eventProxy, true);
- data.addInitRoot(_initRoot);
- data.addBeforeA(_beforeA);
- data.addZTreeTools(_zTreeTools);
-
- var _createNodes = view.createNodes;
- view.createNodes = function (setting, level, nodes, parentNode) {
- if (_createNodes) _createNodes.apply(view, arguments);
- if (!nodes) return;
- view.repairParentChkClassWithSelf(setting, parentNode);
- };
- var _removeNode = view.removeNode;
- view.removeNode = function (setting, node) {
- var parentNode = node.getParentNode();
- if (_removeNode) _removeNode.apply(view, arguments);
- if (!node || !parentNode) return;
- view.repairChkClass(setting, parentNode);
- view.repairParentChkClass(setting, parentNode);
- };
-
- var _appendNodes = view.appendNodes;
- view.appendNodes = function (setting, level, nodes, parentNode, initFlag, openFlag) {
- var html = "";
- if (_appendNodes) {
- html = _appendNodes.apply(view, arguments);
- }
- if (parentNode) {
- data.makeChkFlag(setting, parentNode);
- }
- return html;
- };
+ var _appendNodes = view.appendNodes;
+ view.appendNodes = function (setting, level, nodes, parentNode, initFlag, openFlag) {
+ var html = "";
+ if (_appendNodes) {
+ html = _appendNodes.apply(view, arguments);
+ }
+ if (parentNode) {
+ data.makeChkFlag(setting, parentNode);
+ }
+ return html;
+ };
})(BI.jQuery);
diff --git a/src/case/ztree/list/listasynctree.js b/src/case/ztree/list/listasynctree.js
index 019e7f4be..3ace3c8a7 100644
--- a/src/case/ztree/list/listasynctree.js
+++ b/src/case/ztree/list/listasynctree.js
@@ -1,3 +1,6 @@
+import { Listtreeview } from "./listtreeview";
+import { cjkEncodeDO, delay, isEmpty, shortcut, extend } from "@/core";
+
/**
* author: windy
* 继承自treeView, 此树的父子节点的勾选状态互不影响, 此树不会有半选节点
@@ -6,9 +9,6 @@
* @extends TreeView
*/
-import { Listtreeview } from "./listtreeview";
-import { cjkEncodeDO, delay, isEmpty, shortcut, extend } from "@/core";
-
@shortcut()
export class Listasynctree extends Listtreeview {
static xtype = "bi.list_async_tree";
@@ -72,7 +72,8 @@ export class Listasynctree extends Listtreeview {
// 展开节点
_beforeExpandNode(treeId, treeNode) {
- const self = this, o = this.options;
+ const self = this,
+ o = this.options;
const parentValues = treeNode.parentValues || self._getParentValues(treeNode);
const op = extend({}, o.paras, {
id: treeNode.id,
@@ -85,7 +86,7 @@ export class Listasynctree extends Listtreeview {
if (nodes.length > 0) {
callback(self._dealWidthNodes(nodes), !!d.hasNext);
}
- };
+ }
let times = 1;
function callback(nodes, hasNext) {
@@ -119,4 +120,3 @@ export class Listasynctree extends Listtreeview {
this._initTree(setting);
}
}
-
diff --git a/src/case/ztree/list/listparttree.js b/src/case/ztree/list/listparttree.js
index dd908c36f..19a97b4c6 100644
--- a/src/case/ztree/list/listparttree.js
+++ b/src/case/ztree/list/listparttree.js
@@ -1,3 +1,7 @@
+import { Listasynctree } from "./listasynctree";
+import { shortcut, extend, Events, delay } from "@/core";
+import { TreeView } from "../treeview";
+
/**
* guy
* 局部树,两个请求树, 第一个请求构造树,第二个请求获取节点
@@ -5,24 +9,21 @@
* @extends Asynctree
*/
-
-import { Listasynctree } from "./listasynctree";
-import { shortcut, extend, Events, delay } from "@/core";
-import { TreeView } from "../treeview";
-
@shortcut()
export class ListPartTree extends Listasynctree {
static xtype = "bi.list_part_tree";
_loadMore() {
- const self = this, o = this.options;
+ const self = this,
+ o = this.options;
const op = extend({}, o.paras, {
type: TreeView.REQ_TYPE_INIT_DATA,
times: ++this.times,
});
this.tip.setLoading();
o.itemsCreator(op, d => {
- const hasNext = !!d.hasNext, nodes = d.items || [];
+ const hasNext = !!d.hasNext,
+ nodes = d.items || [];
o.paras.lastSearchValue = d.lastSearchValue;
if (self._stop === true) {
return;
@@ -39,7 +40,8 @@ export class ListPartTree extends Listasynctree {
}
_initTree(setting, keyword) {
- const self = this, o = this.options;
+ const self = this,
+ o = this.options;
this.times = 1;
const tree = this.tree;
tree.empty();
@@ -54,7 +56,8 @@ export class ListPartTree extends Listasynctree {
if (self._stop === true || keyword !== o.paras.keyword) {
return;
}
- const hasNext = !!d.hasNext, nodes = d.items || [];
+ const hasNext = !!d.hasNext,
+ nodes = d.items || [];
o.paras.lastSearchValue = d.lastSearchValue;
// 没有请求到数据也要初始化空树, 如果不初始化, 树就是上一次构造的树, 节点信息都是过期的
callback(nodes.length > 0 ? self._dealWidthNodes(nodes) : []);
diff --git a/src/case/ztree/list/listtreeview.js b/src/case/ztree/list/listtreeview.js
index b31e93869..96d731f08 100644
--- a/src/case/ztree/list/listtreeview.js
+++ b/src/case/ztree/list/listtreeview.js
@@ -1,3 +1,6 @@
+import { TreeView } from "../treeview";
+import { extend, isNotNull, concat, each, shortcut } from "@/core";
+
/**
* author: windy
* 继承自treeView, 此树的父子节点的勾选状态互不影响, 此树不会有半选节点
@@ -6,9 +9,6 @@
* @extends BI.TreeView
*/
-import { TreeView } from "../treeview";
-import { extend, isNotNull, concat, each, shortcut } from "@/core";
-
@shortcut()
export class Listtreeview extends TreeView {
static xtype = "bi.list_tree_view";
diff --git a/src/case/ztree/parttree.js b/src/case/ztree/parttree.js
index f66c14920..dce82a093 100644
--- a/src/case/ztree/parttree.js
+++ b/src/case/ztree/parttree.js
@@ -1,12 +1,13 @@
+import { isEmpty, shortcut, extend, deepClone, each, isNotEmptyArray, Events, delay, isNull } from "@/core";
+import { Asynctree } from "./asynctree";
+import { TreeView } from "./treeview";
+
/**
* guy
* 局部树,两个请求树, 第一个请求构造树,第二个请求获取节点
* @class BI.PartTree
* @extends BI.AsyncTree
*/
-import { isEmpty, shortcut, extend, deepClone, each, isNotEmptyArray, Events, delay, isNull } from "@/core";
-import { Asynctree } from "./asynctree";
-import { TreeView } from "./treeview";
@shortcut()
export class PartTree extends Asynctree {
@@ -20,14 +21,16 @@ export class PartTree extends Asynctree {
}
_loadMore() {
- const self = this, o = this.options;
+ const self = this,
+ o = this.options;
const op = extend({}, o.paras, {
type: TreeView.REQ_TYPE_INIT_DATA,
times: ++this.times,
});
this.tip.setLoading();
o.itemsCreator(op, d => {
- const hasNext = !!d.hasNext, nodes = d.items || [];
+ const hasNext = !!d.hasNext,
+ nodes = d.items || [];
o.paras.lastSearchValue = d.lastSearchValue;
if (self._stop === true) {
return;
@@ -44,7 +47,8 @@ export class PartTree extends Asynctree {
}
_selectTreeNode(...args) {
- const self = this, o = this.options;
+ const self = this,
+ o = this.options;
const [treeId, treeNode] = args;
const parentValues = deepClone(treeNode.parentValues || self._getParentValues(treeNode));
const name = this._getNodeValue(treeNode);
@@ -52,14 +56,17 @@ export class PartTree extends Asynctree {
if (treeNode.checked === true) {
this.options.paras.selectedValues = this._getUnionValue();
// this._buildTree(self.options.paras.selectedValues, concat(parentValues, name));
- o.itemsCreator(extend({}, o.paras, {
- type: TreeView.REQ_TYPE_ADJUST_DATA,
- curSelectedValue: name,
- parentValues,
- }), function (res) {
- self.options.paras.selectedValues = res;
- this.seMethos(...args);
- });
+ o.itemsCreator(
+ extend({}, o.paras, {
+ type: TreeView.REQ_TYPE_ADJUST_DATA,
+ curSelectedValue: name,
+ parentValues,
+ }),
+ function (res) {
+ self.options.paras.selectedValues = res;
+ this.seMethos(...args);
+ }
+ );
} else {
// 如果选中的值中不存在该值不处理
// 因为反正是不选中,没必要管
@@ -75,14 +82,17 @@ export class PartTree extends Asynctree {
break;
}
}
- o.itemsCreator(extend({}, o.paras, {
- type: TreeView.REQ_TYPE_SELECT_DATA,
- notSelectedValue: name,
- parentValues,
- }), new_values => {
- self.options.paras.selectedValues = new_values;
- this.seMethos(...args);
- });
+ o.itemsCreator(
+ extend({}, o.paras, {
+ type: TreeView.REQ_TYPE_SELECT_DATA,
+ notSelectedValue: name,
+ parentValues,
+ }),
+ new_values => {
+ self.options.paras.selectedValues = new_values;
+ this.seMethos(...args);
+ }
+ );
}
}
@@ -120,7 +130,8 @@ export class PartTree extends Asynctree {
}
_initTree(setting, keyword) {
- const self = this, o = this.options;
+ const self = this,
+ o = this.options;
this.times = 1;
const tree = this.tree;
tree.empty();
@@ -135,7 +146,8 @@ export class PartTree extends Asynctree {
if (self._stop === true || keyword !== o.paras.keyword) {
return;
}
- const hasNext = !!d.hasNext, nodes = d.items || [];
+ const hasNext = !!d.hasNext,
+ nodes = d.items || [];
o.paras.lastSearchValue = d.lastSearchValue;
// 没有请求到数据也要初始化空树, 如果不初始化, 树就是上一次构造的树, 节点信息都是过期的
callback(nodes.length > 0 ? self._dealWidthNodes(nodes) : []);
diff --git a/src/case/ztree/tree.display.js b/src/case/ztree/tree.display.js
index a385d58c6..fe8f274fc 100644
--- a/src/case/ztree/tree.display.js
+++ b/src/case/ztree/tree.display.js
@@ -1,3 +1,6 @@
+import { extend, shortcut } from "@/core";
+import { TreeView } from "./treeview";
+
/**
* guy
* 异步树
@@ -5,9 +8,7 @@
* @extends BI.TreeView
*/
-import { extend } from "@/core";
-import { TreeView } from "./treeview";
-
+@shortcut()
export class DisplayTree extends TreeView {
static xtype = "bi.display_tree";
static EVENT_CHANGE = "EVENT_CHANGE";
@@ -53,7 +54,9 @@ export class DisplayTree extends TreeView {
node.isParent = node.isParent || node.parent;
if (node.text == null) {
if (node.count > 0) {
- node.text = `${node.value}(${BI.i18nText("BI-Basic_Altogether")}${node.count}${BI.i18nText("BI-Basic_Count")})`;
+ node.text = `${node.value}(${BI.i18nText("BI-Basic_Altogether")}${node.count}${BI.i18nText(
+ "BI-Basic_Count"
+ )})`;
}
}
});
diff --git a/src/case/ztree/tree.list.display.js b/src/case/ztree/tree.list.display.js
index a3769e898..918d451c8 100644
--- a/src/case/ztree/tree.list.display.js
+++ b/src/case/ztree/tree.list.display.js
@@ -1,11 +1,12 @@
+import { Listtreeview } from "./list/listtreeview";
+import { each, shortcut } from "@/core";
+
/**
* guy
* 异步树
* @class BI.ListListDisplayTree
* @extends BI.TreeView
*/
-import { Listtreeview } from "./list/listtreeview";
-import { each, shortcut } from "@/core";
@shortcut()
export class ListDisplayTree extends Listtreeview {
@@ -58,7 +59,9 @@ export class ListDisplayTree extends Listtreeview {
node.isParent = node.isParent || node.parent;
if (node.text == null) {
if (node.count > 0) {
- node.text = `${node.value}(${BI.i18nText("BI-Basic_Altogether")}${node.count}${BI.i18nText("BI-Basic_Count")})`;
+ node.text = `${node.value}(${BI.i18nText("BI-Basic_Altogether")}${node.count}${BI.i18nText(
+ "BI-Basic_Count"
+ )})`;
}
}
});
diff --git a/src/case/ztree/tree.simple.js b/src/case/ztree/tree.simple.js
index 1483a27a7..8740aaab7 100644
--- a/src/case/ztree/tree.simple.js
+++ b/src/case/ztree/tree.simple.js
@@ -1,10 +1,3 @@
-/**
- * 简单的多选树
- *
- * Created by GUY on 2016/2/16.
- * @class SimpleTreeView
- * @extends Widget
- */
import {
shortcut,
Widget,
@@ -19,6 +12,14 @@ import {
} from "@/core";
import { TreeView } from "./treeview";
+/**
+ * 简单的多选树
+ *
+ * Created by GUY on 2016/2/16.
+ * @class SimpleTreeView
+ * @extends Widget
+ */
+
@shortcut()
export class SimpleTreeView extends Widget {
static xtype = "bi.simple_tree";
@@ -35,7 +36,8 @@ export class SimpleTreeView extends Widget {
_init() {
super._init(...arguments);
- const self = this, o = this.options;
+ const self = this,
+ o = this.options;
this.structure = new Tree();
this.tree = createWidget({
type: TreeView.xtype,
@@ -46,7 +48,7 @@ export class SimpleTreeView extends Widget {
items,
});
self.structure.initTree(Tree.transformToTreeFormat(items));
- };
+ }
if (isNotNull(o.items)) {
fn(o.items);
} else {
@@ -76,7 +78,8 @@ export class SimpleTreeView extends Widget {
_digest(v) {
v || (v = []);
- const self = this, map = {};
+ const self = this,
+ map = {};
const selected = [];
each(v, (i, val) => {
const node = self.structure.search(val, "value");
@@ -111,7 +114,8 @@ export class SimpleTreeView extends Widget {
}
_getValue() {
- const result = [], val = this.tree.getValue();
+ const result = [],
+ val = this.tree.getValue();
function track(nodes) {
each(nodes, (key, node) => {
@@ -121,7 +125,7 @@ export class SimpleTreeView extends Widget {
track(node);
}
});
- };
+ }
track(val);
return result;
@@ -132,7 +136,9 @@ export class SimpleTreeView extends Widget {
}
getValue() {
- const self = this, result = [], val = this._getValue();
+ const self = this,
+ result = [],
+ val = this._getValue();
each(val, (i, key) => {
const target = self.structure.search(key, "value");
if (target) {
diff --git a/src/case/ztree/treerender.page.service.js b/src/case/ztree/treerender.page.service.js
index 56112c217..799829a93 100644
--- a/src/case/ztree/treerender.page.service.js
+++ b/src/case/ztree/treerender.page.service.js
@@ -1,3 +1,6 @@
+import { createWidget, debounce, has, OB, size, each, VerticalLayout } from "@/core";
+import { LoadingBar } from "@/base";
+
/**
* @author windy
* @version 2.0
@@ -5,9 +8,6 @@
* 提供节点分页加载方式
*/
-import { createWidget, debounce, has, OB, size, each, VerticalLayout } from "@/core";
-import { LoadingBar } from "@/base";
-
export class TreeRenderPageService extends OB {
nodeLists = {};
diff --git a/src/case/ztree/treerender.scroll.service.js b/src/case/ztree/treerender.scroll.service.js
index ffd5ea289..fed397a9c 100644
--- a/src/case/ztree/treerender.scroll.service.js
+++ b/src/case/ztree/treerender.scroll.service.js
@@ -1,3 +1,5 @@
+import { debounce, each, has, isNotNull, OB, size } from "@/core";
+
/**
* @author windy
* @version 2.0
@@ -5,8 +7,6 @@
* 提供节点滚动加载方式
*/
-import { debounce, each, has, isNotNull, OB, size } from "@/core";
-
export class TreeRenderScrollService extends OB {
_init() {
this.nodeLists = {};
@@ -51,7 +51,7 @@ export class TreeRenderScrollService extends OB {
// 是否需要继续加载,只需要看子节点列表的下边界与container是否无交集
const bounds = this._getNodeListBounds(tId);
const containerBounds = this._getTreeContainerBounds(tId);
-
+
// ul底部是不是漏出来了
return bounds.top + bounds.height < containerBounds.top + containerBounds.height;
}
@@ -80,9 +80,13 @@ export class TreeRenderScrollService extends OB {
if (!this.hasBinded) {
// console.log("绑定事件");
this.hasBinded = true;
- this.container && this.container.on("scroll", debounce(() => {
- self.refreshAllNodes();
- }, 30));
+ this.container &&
+ this.container.on(
+ "scroll",
+ debounce(() => {
+ self.refreshAllNodes();
+ }, 30)
+ );
}
}
diff --git a/src/case/ztree/treeview.js b/src/case/ztree/treeview.js
index 33ee57363..195c31e4d 100644
--- a/src/case/ztree/treeview.js
+++ b/src/case/ztree/treeview.js
@@ -8,9 +8,20 @@ import {
UUID,
isNotNull,
jsonEncode,
- delay, each, replaceAll,
- isUndefined, isNotEmptyArray, deepClone, map, Tree,
- isNull, shortcut, VerticalLayout, Layout, DefaultLayout
+ delay,
+ each,
+ replaceAll,
+ isUndefined,
+ isNotEmptyArray,
+ deepClone,
+ map,
+ Tree,
+ isNull,
+ shortcut,
+ VerticalLayout,
+ Layout,
+ DefaultLayout,
+ some
} from "@/core";
import { Msg, Pane, LoadingBar, Text } from "@/base";
@@ -69,7 +80,9 @@ export class TreeView extends Pane {
}
this.tree = createWidget({
type: Layout.xtype,
- element: ``,
+ element: ``,
});
createWidget({
type: DefaultLayout.xtype,
@@ -126,7 +139,8 @@ export class TreeView extends Pane {
onClick,
},
};
- const className = "dark", perTime = 100;
+ const className = "dark",
+ perTime = 100;
function onClick(event, treeId, treeNode) {
// 当前点击节点的状态是半选,且为true_part, 则将其改为false_part,使得点击半选后切换到的是全选
@@ -142,10 +156,9 @@ export class TreeView extends Pane {
function getUrl(treeId, treeNode) {
const parentNode = self._getParentValues(treeNode);
treeNode.times = treeNode.times || 1;
- const param = `id=${treeNode.id
- }×=${treeNode.times++
- }&parentValues= ${_global.encodeURIComponent(jsonEncode(parentNode))
- }&checkState=${_global.encodeURIComponent(jsonEncode(treeNode.getCheckStatus()))}`;
+ const param = `id=${treeNode.id}×=${treeNode.times++}&parentValues= ${_global.encodeURIComponent(
+ jsonEncode(parentNode)
+ )}&checkState=${_global.encodeURIComponent(jsonEncode(treeNode.getCheckStatus()))}`;
return `&${param}`;
}
@@ -247,8 +260,7 @@ export class TreeView extends Pane {
treeNode.halfCheck = false;
}
- function onCollapse(event, treeId, treeNode) {
- }
+ function onCollapse(event, treeId, treeNode) {}
return setting;
}
@@ -362,7 +374,8 @@ export class TreeView extends Pane {
// 处理节点
_dealWidthNodes(nodes) {
- const self = this, o = this.options;
+ const self = this,
+ o = this.options;
const ns = Tree.arrayFormat(nodes);
return map(ns, (i, n) => {
@@ -379,16 +392,22 @@ export class TreeView extends Pane {
if (newNode.disabled) {
newNode.title = newNode.warningTitle || newNode.title;
}
- const text = createWidget(extend({
- cls: "tree-node-text",
- tagName: "span",
- whiteSpace: "nowrap",
- root: true,
- keyword: o.paras.keyword,
- }, newNode, {
- type: Text.xtype,
- text: replaceAll(newNode.text, "\n", " "),
- }));
+ const text = createWidget(
+ extend(
+ {
+ cls: "tree-node-text",
+ tagName: "span",
+ whiteSpace: "nowrap",
+ root: true,
+ keyword: o.paras.keyword,
+ },
+ newNode,
+ {
+ type: Text.xtype,
+ text: replaceAll(newNode.text, "\n", " "),
+ }
+ )
+ );
const fragment = BI.Widget._renderEngine.createElement("");
fragment.append(text.element[0]);
newNode.text = fragment.html();
@@ -406,7 +425,8 @@ export class TreeView extends Pane {
}
_loadMore() {
- const self = this, o = this.options;
+ const self = this,
+ o = this.options;
this.tip.setLoading();
const op = extend({}, o.paras, {
times: ++this.times,
@@ -415,7 +435,8 @@ export class TreeView extends Pane {
if (self._stop === true) {
return;
}
- const hasNext = !!res.hasNext, nodes = res.items || [];
+ const hasNext = !!res.hasNext,
+ nodes = res.items || [];
if (!hasNext) {
self.tip.setEnd();
@@ -430,7 +451,8 @@ export class TreeView extends Pane {
// 生成树内部方法
_initTree(setting) {
- const self = this, o = this.options;
+ const self = this,
+ o = this.options;
self.fireEvent(Events.INIT);
this.times = 1;
const tree = this.tree;
@@ -453,7 +475,8 @@ export class TreeView extends Pane {
if (self._stop === true) {
return;
}
- const hasNext = !!res.hasNext, nodes = res.items || [];
+ const hasNext = !!res.hasNext,
+ nodes = res.items || [];
if (nodes.length > 0) {
callback(self._dealWidthNodes(nodes));
}
@@ -590,4 +613,3 @@ export class TreeView extends Pane {
this.nodes && this.nodes.destroy();
}
}
-
diff --git a/src/component/allvaluechooser/abstract.allvaluechooser.js b/src/component/allvaluechooser/abstract.allvaluechooser.js
index c13d8a30f..1673d2866 100644
--- a/src/component/allvaluechooser/abstract.allvaluechooser.js
+++ b/src/component/allvaluechooser/abstract.allvaluechooser.js
@@ -1,61 +1,74 @@
-/**
- * 简单的复选下拉框控件, 适用于数据量少的情况, 与valuechooser的区别是allvaluechooser setValue和getValue返回的是所有值
- * 封装了字段处理逻辑
- *
- * Created by GUY on 2015/10/29.
- * @class BI.AbstractAllValueChooser
- * @extends BI.Widget
- */
-BI.AbstractAllValueChooser = BI.inherit(BI.Widget, {
+import {
+ shortcut,
+ Widget,
+ extend,
+ emptyFn,
+ isNotNull,
+ some,
+ isNotEmptyArray,
+ each,
+ Func,
+ uniq,
+ makeObject,
+ filter,
+ difference,
+ map,
+ Selection
+} from "@/core";
+import { MultiSelectCombo } from "@/widget";
- _const: {
- perPage: 100
- },
+@shortcut()
+export class AbstractAllValueChooser extends Widget {
+ _const = { perPage: 100 };
- _defaultConfig: function () {
- return BI.extend(BI.AbstractAllValueChooser.superclass._defaultConfig.apply(this, arguments), {
+ _defaultConfig() {
+ return extend(super._defaultConfig(...arguments), {
width: 200,
height: 30,
items: null,
- itemsCreator: BI.emptyFn,
- cache: true
+ itemsCreator: emptyFn,
+ cache: true,
});
- },
+ }
- _valueFormatter: function (v) {
- var text = v;
+ _valueFormatter(v) {
+ let text = v;
if (this.options.valueFormatter) {
return this.options.valueFormatter(v);
}
- if (BI.isNotNull(this.items)) {
- BI.some(this.items, function (i, item) {
+ if (isNotNull(this.items)) {
+ some(this.items, (i, item) => {
// 把value都换成字符串
// 需要考虑到value也可能是数字
- if (item.value === v || item.value + "" === v) {
+ if (item.value === v || `${item.value}` === v) {
text = item.text;
+
return true;
}
});
}
+
return text;
- },
+ }
- _getItemsByTimes: function (items, times) {
- var res = [];
- for (var i = (times - 1) * this._const.perPage; items[i] && i < times * this._const.perPage; i++) {
+ _getItemsByTimes(items, times) {
+ const res = [];
+ for (let i = (times - 1) * this._const.perPage; items[i] && i < times * this._const.perPage; i++) {
res.push(items[i]);
}
+
return res;
- },
+ }
- _hasNextByTimes: function (items, times) {
+ _hasNextByTimes(items, times) {
return times * this._const.perPage < items.length;
- },
+ }
- _itemsCreator: function (options, callback) {
- var self = this, o = this.options;
+ _itemsCreator(options, callback) {
+ const self = this,
+ o = this.options;
if (!o.cache || !this.items) {
- o.itemsCreator({}, function (items) {
+ o.itemsCreator({}, items => {
self.items = items;
call(items);
});
@@ -64,54 +77,56 @@ BI.AbstractAllValueChooser = BI.inherit(BI.Widget, {
}
function call(items) {
- var keywords = (options.keywords || []).slice();
+ const keywords = (options.keywords || []).slice();
if (options.keyword) {
keywords.push(options.keyword);
}
- var resultItems = items;
- if (BI.isNotEmptyArray(keywords)) {
+ let resultItems = items;
+ if (isNotEmptyArray(keywords)) {
resultItems = [];
- BI.each(keywords, function (i, kw) {
- var search = BI.Func.getSearchResult(items, kw);
+ each(keywords, (i, kw) => {
+ const search = Func.getSearchResult(items, kw);
resultItems = resultItems.concat(search.match).concat(search.find);
});
- resultItems = BI.uniq(resultItems);
+ resultItems = uniq(resultItems);
}
- if (options.selectedValues) {// 过滤
- var filter = BI.makeObject(options.selectedValues, true);
- resultItems = BI.filter(resultItems, function (i, ob) {
- return !filter[ob.value];
- });
+ if (options.selectedValues) {
+ // 过滤
+ const values = makeObject(options.selectedValues, true);
+ resultItems = filter(resultItems, (i, ob) => !values[ob.value]);
}
- if (options.type === BI.MultiSelectCombo.REQ_GET_ALL_DATA) {
+ if (options.type === MultiSelectCombo.REQ_GET_ALL_DATA) {
callback({
- items: resultItems
+ items: resultItems,
});
+
return;
}
- if (options.type === BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) {
+ if (options.type === MultiSelectCombo.REQ_GET_DATA_LENGTH) {
callback({ count: resultItems.length });
+
return;
}
callback({
items: self._getItemsByTimes(resultItems, options.times),
- hasNext: self._hasNextByTimes(resultItems, options.times)
+ hasNext: self._hasNextByTimes(resultItems, options.times),
});
}
- },
+ }
- _assertValue: function (v) {
+ _assertValue(v) {
v = v || {};
- var value = v;
- if (BI.isNotNull(this.items)) {
- var isAllSelect = BI.difference(BI.map(this.items, "value"), v.value).length === 0;
+ let value = v;
+ if (isNotNull(this.items)) {
+ const isAllSelect = difference(map(this.items, "value"), v.value).length === 0;
if (isAllSelect) {
value = {
- type: BI.Selection.All,
+ type: Selection.All,
value: [],
};
}
}
+
return value;
- },
-});
+ }
+}
diff --git a/src/component/allvaluechooser/combo.allvaluechooser.js b/src/component/allvaluechooser/combo.allvaluechooser.js
index 11494b584..ed746ec3c 100644
--- a/src/component/allvaluechooser/combo.allvaluechooser.js
+++ b/src/component/allvaluechooser/combo.allvaluechooser.js
@@ -1,77 +1,77 @@
-/**
- * 简单的复选下拉框控件, 适用于数据量少的情况, 与valuechooser的区别是allvaluechooser setValue和getValue返回的是所有值
- * 封装了字段处理逻辑
- *
- * Created by GUY on 2015/10/29.
- * @class BI.AllValueChooserCombo
- * @extends BI.AbstractAllValueChooser
- */
-BI.AllValueChooserCombo = BI.inherit(BI.AbstractAllValueChooser, {
+import { shortcut, extend, emptyFn, isNotNull, createWidget, bind, Selection, difference, map } from "@/core";
+import { AbstractAllValueChooser } from "./abstract.allvaluechooser";
+import { MultiSelectCombo } from "@/widget";
- _defaultConfig: function () {
- return BI.extend(BI.AllValueChooserCombo.superclass._defaultConfig.apply(this, arguments), {
+@shortcut()
+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",
width: 200,
height: 24,
items: null,
- itemsCreator: BI.emptyFn,
- cache: true
+ itemsCreator: emptyFn,
+ cache: true,
});
- },
+ }
- _init: function () {
- BI.AllValueChooserCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- if (BI.isNotNull(o.items)) {
+ _init() {
+ super._init(...arguments);
+ const o = this.options;
+ if (isNotNull(o.items)) {
this.items = o.items;
}
- this.combo = BI.createWidget({
- type: "bi.multi_select_combo",
+ this.combo = createWidget({
+ type: MultiSelectCombo.xtype,
simple: o.simple,
text: o.text,
element: this,
- itemsCreator: BI.bind(this._itemsCreator, this),
- valueFormatter: BI.bind(this._valueFormatter, this),
+ itemsCreator: bind(this._itemsCreator, this),
+ valueFormatter: bind(this._valueFormatter, this),
width: o.width,
height: o.height,
value: this._assertValue({
- type: BI.Selection.Multi,
- value: o.value || []
- })
+ type: Selection.Multi,
+ value: o.value || [],
+ }),
});
- this.combo.on(BI.MultiSelectCombo.EVENT_CONFIRM, function () {
- self.fireEvent(BI.AllValueChooserCombo.EVENT_CONFIRM);
+ this.combo.on(MultiSelectCombo.EVENT_CONFIRM, () => {
+ this.fireEvent(AllValueChooserCombo.EVENT_CONFIRM);
});
- },
+ }
- setValue: function (v) {
- this.combo.setValue(this._assertValue({
- type: BI.Selection.Multi,
- value: v || []
- }));
- },
+ setValue(v) {
+ this.combo.setValue(
+ this._assertValue({
+ type: Selection.Multi,
+ value: v || [],
+ })
+ );
+ }
- getValue: function () {
+ getValue() {
return this.getAllValue();
- },
+ }
- getAllValue: function () {
- var val = this.combo.getValue() || {};
- if (val.type === BI.Selection.Multi) {
+ getAllValue() {
+ const val = this.combo.getValue() || {};
+ if (val.type === Selection.Multi) {
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上
- if (BI.isNotNull(items)) {
+ if (isNotNull(items)) {
this.items = items;
}
this.combo.populate();
}
-});
-BI.AllValueChooserCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
-BI.shortcut("bi.all_value_chooser_combo", BI.AllValueChooserCombo);
+}
diff --git a/src/component/allvaluechooser/index.js b/src/component/allvaluechooser/index.js
new file mode 100644
index 000000000..d69b5f254
--- /dev/null
+++ b/src/component/allvaluechooser/index.js
@@ -0,0 +1,3 @@
+export { AbstractAllValueChooser } from "./abstract.allvaluechooser";
+export { AllValueChooserCombo } from "./combo.allvaluechooser";
+export { AllValueChooserPane } from "./pane.allvaluechooser";
diff --git a/src/component/allvaluechooser/pane.allvaluechooser.js b/src/component/allvaluechooser/pane.allvaluechooser.js
index 6188f14ee..6ea534af7 100644
--- a/src/component/allvaluechooser/pane.allvaluechooser.js
+++ b/src/component/allvaluechooser/pane.allvaluechooser.js
@@ -1,69 +1,67 @@
-/**
- * 简单的复选面板, 适用于数据量少的情况, 与valuechooser的区别是allvaluechooser setValue和getValue返回的是所有值
- * 封装了字段处理逻辑
- *
- * Created by GUY on 2015/10/29.
- * @class BI.AllValueChooserPane
- * @extends BI.AbstractAllValueChooser
- */
-BI.AllValueChooserPane = BI.inherit(BI.AbstractAllValueChooser, {
+import { shortcut, extend, emptyFn, createWidget, bind, isNotNull, Selection, difference, map } from "@/core";
+import { AbstractAllValueChooser } from "./abstract.allvaluechooser";
+import { MultiSelectList } from "@/widget";
- _defaultConfig: function () {
- return BI.extend(BI.AllValueChooserPane.superclass._defaultConfig.apply(this, arguments), {
+@shortcut()
+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",
width: 200,
height: 30,
items: null,
- itemsCreator: BI.emptyFn,
- cache: true
+ itemsCreator: emptyFn,
+ cache: true,
});
- },
+ }
- _init: function () {
- BI.AllValueChooserPane.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.list = BI.createWidget({
- type: "bi.multi_select_list",
+ _init() {
+ super._init(...arguments);
+ const o = this.options;
+ this.list = createWidget({
+ type: MultiSelectList.xtype,
element: this,
- itemsCreator: BI.bind(this._itemsCreator, this),
- valueFormatter: BI.bind(this._valueFormatter, this),
+ itemsCreator: bind(this._itemsCreator, this),
+ valueFormatter: bind(this._valueFormatter, this),
width: o.width,
- height: o.height
+ height: o.height,
});
- this.list.on(BI.MultiSelectList.EVENT_CHANGE, function () {
- self.fireEvent(BI.AllValueChooserPane.EVENT_CHANGE);
+ this.list.on(MultiSelectList.EVENT_CHANGE, () => {
+ this.fireEvent(AllValueChooserPane.EVENT_CHANGE);
});
- if (BI.isNotNull(o.items)) {
+ if (isNotNull(o.items)) {
this.items = o.items;
this.list.populate();
}
- },
+ }
- setValue: function (v) {
+ setValue(v) {
this.list.setValue({
- type: BI.Selection.Multi,
- value: v || []
+ type: Selection.Multi,
+ value: v || [],
});
- },
+ }
- getValue: function () {
- var val = this.list.getValue() || {};
- if (val.type === BI.Selection.Multi) {
+ getValue() {
+ const val = this.list.getValue() || {};
+ if (val.type === Selection.Multi) {
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上
- if (BI.isNotNull(items)) {
+ if (isNotNull(items)) {
this.items = items;
}
this.list.populate();
}
-});
-BI.AllValueChooserPane.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.all_value_chooser_pane", BI.AllValueChooserPane);
+}
diff --git a/src/component/allvaluemultitextvaluecombo/allvalue.multitextvalue.combo.js b/src/component/allvaluemultitextvaluecombo/allvalue.multitextvalue.combo.js
index 2ac30295b..0bbb70397 100644
--- a/src/component/allvaluemultitextvaluecombo/allvalue.multitextvalue.combo.js
+++ b/src/component/allvaluemultitextvaluecombo/allvalue.multitextvalue.combo.js
@@ -1,66 +1,72 @@
-BI.AllValueMultiTextValueCombo = BI.inherit(BI.Widget, {
+import { SearchMultiTextValueCombo } from "@/widget";
+import { shortcut, Widget, Selection, each, contains } from "@/core";
- props: {
- baseCls: "bi-all-value-multi-text-value-combo",
- width: 200,
- height: 24,
- items: []
- },
+@shortcut()
+export class AllValueMultiTextValueCombo extends Widget {
+ static xtype = "bi.all_value_multi_text_value_combo";
+
+ props = { baseCls: "bi-all-value-multi-text-value-combo", width: 200, height: 24, items: [] };
+
+ static EVENT_CONFIRM = "EVENT_CONFIRM";
+
+ render() {
+ const self = this,
+ o = this.options;
+ const value = this._digestValue(o.value);
- render: function () {
- var self = this, o = this.options;
- var value = this._digestValue(o.value);
return {
- type: "bi.search_multi_text_value_combo",
+ type: SearchMultiTextValueCombo.xtype,
simple: o.simple,
text: o.text,
height: o.height,
items: o.items,
- value: value,
+ value,
numOfPage: 100,
valueFormatter: o.valueFormatter,
warningTitle: o.warningTitle,
- listeners: [{
- eventName: BI.SearchMultiTextValueCombo.EVENT_CONFIRM,
- action: function () {
- self.fireEvent(BI.AllValueMultiTextValueCombo.EVENT_CONFIRM);
+ listeners: [
+ {
+ eventName: SearchMultiTextValueCombo.EVENT_CONFIRM,
+ action() {
+ self.fireEvent(AllValueMultiTextValueCombo.EVENT_CONFIRM);
+ },
}
- }],
- ref: function () {
+ ],
+ ref() {
self.combo = this;
- }
+ },
};
- },
+ }
- setValue: function (v) {
- var value = this._digestValue(v);
+ setValue(v) {
+ const value = this._digestValue(v);
this.combo.setValue(value);
- },
+ }
- getValue: function () {
- var obj = this.combo.getValue() || {};
+ getValue() {
+ const obj = this.combo.getValue() || {};
obj.value = obj.value || [];
- if(obj.type === BI.Selection.All) {
- var values = [];
- BI.each(this.options.items, function (idx, item) {
- !BI.contains(obj.value, item.value) && values.push(item.value);
+ if (obj.type === Selection.All) {
+ const values = [];
+ each(this.options.items, (idx, item) => {
+ !contains(obj.value, item.value) && values.push(item.value);
});
+
return values;
}
+
return obj.value || [];
- },
+ }
- populate: function (items) {
+ populate(items) {
this.options.items = items;
- this.combo.populate.apply(this.combo, arguments);
- },
+ this.combo.populate(...arguments);
+ }
- _digestValue: function (v) {
+ _digestValue(v) {
return {
- type: BI.Selection.Multi,
- value: v || []
+ type: Selection.Multi,
+ value: v || [],
};
}
-});
-BI.AllValueMultiTextValueCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
-BI.shortcut("bi.all_value_multi_text_value_combo", BI.AllValueMultiTextValueCombo);
+}
diff --git a/src/component/form/form.field.js b/src/component/form/form.field.js
index 0b67041b8..8cc80eae6 100644
--- a/src/component/form/form.field.js
+++ b/src/component/form/form.field.js
@@ -1,98 +1,108 @@
-/**
- * @author windy
- * @version 2.0
- * Created by windy on 2022/1/11
- */
- BI.FormField = BI.inherit(BI.Widget, {
+import { AbsoluteLayout, VerticalAdaptLayout, shortcut, Widget, extend, concat, isKey, VerticalAlign } from "@/core";
+import { Label } from "@/base";
- props: {
+@shortcut()
+export class FormField extends Widget {
+ static xtype = "bi.form_field";
+
+ props = {
baseCls: "bi-form-field",
label: "",
el: {},
headerCls: "",
labelAlign: "right", // 文字默认右对齐
- validate: function () {
+ validate() {
return true;
- } // 默认返回true
- },
+ }, // 默认返回true
+ };
- render: function () {
- var self = this, o = this.options;
+ render() {
+ const self = this,
+ o = this.options;
- var field = {
- type: "bi.absolute",
- items: [{
- el: BI.extend({}, o.el, {
- ref: function (_ref) {
- self.field = _ref;
- o.el.ref && o.el.ref.call(this, _ref);
- },
- height: o.el.height || 28,
- listeners: BI.concat(o.el.listeners, [{
- eventName: "EVENT_CHANGE",
- action: function () {
- self.fireEvent("EVENT_CHANGE");
- }
- }, {
- eventName: "EVENT_CONFIRM",
- action: function () {
- self.fireEvent("EVENT_CONFIRM");
- }
- }])
- }),
- left: 0,
- bottom: 0,
- right: 0,
- top: 0
- }, {
- el: {
- type: "bi.label",
- cls: "error-tip bi-error",
- ref: function (_ref) {
- self.error = _ref;
- },
- invisible: true
+ const field = {
+ type: AbsoluteLayout.xtype,
+ items: [
+ {
+ el: extend({}, o.el, {
+ ref(_ref) {
+ self.field = _ref;
+ o.el.ref && o.el.ref.call(this, _ref);
+ },
+ height: o.el.height || 28,
+ listeners: concat(o.el.listeners, [
+ {
+ eventName: "EVENT_CHANGE",
+ action() {
+ self.fireEvent("EVENT_CHANGE");
+ },
+ },
+ {
+ eventName: "EVENT_CONFIRM",
+ action() {
+ self.fireEvent("EVENT_CONFIRM");
+ },
+ }
+ ]),
+ }),
+ left: 0,
+ bottom: 0,
+ right: 0,
+ top: 0,
},
- bottom: -20,
- left: 0,
- right: 0,
- height: 20
- }]
+ {
+ el: {
+ type: Label.xtype,
+ cls: "error-tip bi-error",
+ ref(_ref) {
+ self.error = _ref;
+ },
+ invisible: true,
+ },
+ bottom: -20,
+ left: 0,
+ right: 0,
+ height: 20,
+ }
+ ],
};
return {
- type: "bi.vertical_adapt",
+ type: VerticalAdaptLayout.xtype,
columnSize: ["auto", "fill"],
- verticalAlign: BI.VerticalAlign.Stretch,
- items: BI.isKey(o.label) ? [{
- el: {
- type: "bi.label",
- textAlign: o.labelAlign,
- text: o.label,
- width: o.labelWidth,
- cls: o.headerCls,
- rgap: 20 // 表单文字与右侧输入间距均为20px
- }
- }, field] : [field]
+ verticalAlign: VerticalAlign.Stretch,
+ items: isKey(o.label)
+ ? [
+ {
+ el: {
+ type: Label.xtype,
+ textAlign: o.labelAlign,
+ text: o.label,
+ width: o.labelWidth,
+ cls: o.headerCls,
+ rgap: 20, // 表单文字与右侧输入间距均为20px
+ },
+ },
+ field
+ ]
+ : [field],
};
- },
+ }
- getValue: function () {
+ getValue() {
return this.field.getValue();
- },
+ }
- validate: function () {
- var isValid = this.validateWithNoTip();
+ validate() {
+ const isValid = this.validateWithNoTip();
!isValid && this.error.setText(this.options.tip(this.field.getValue(), this.field));
this.error.setVisible(!isValid);
this.field.element[isValid ? "removeClass" : "addClass"]("bi-error");
return isValid;
- },
+ }
- validateWithNoTip: function () {
+ validateWithNoTip() {
return this.options.validate(this.field.getValue(), this.field);
}
-});
-
-BI.shortcut("bi.form_field", BI.FormField);
+}
diff --git a/src/component/form/form.js b/src/component/form/form.js
index de8caeaea..514280808 100644
--- a/src/component/form/form.js
+++ b/src/component/form/form.js
@@ -1,47 +1,42 @@
-/**
- * @author windy
- * @version 2.0
- * Created by windy on 2022/1/11
- */
- BI.Form = BI.inherit(BI.Widget, {
+import { VerticalLayout, shortcut, Widget, map, some, each } from "@/core";
+import { FormField } from "./form.field";
+import { ButtonGroup } from "@/base";
- props: {
+@shortcut()
+export class Form extends Widget {
+ static xtype = "bi.custom_form";
+
+ props = {
baseCls: "bi-form",
labelAlign: "right",
- layout: {
- type: "bi.vertical",
- vgap: 20
- },
- items: [{
- validate: BI.emptyFn,
- tip: BI.emptyFn,
- label: "",
- el: {}
- }],
+ layout: { type: VerticalLayout.xtype, vgap: 20 },
+ items: [{ label: "", el: {} }],
labelWidth: "",
- headerCls: "", // 左侧文字样式
- },
+ headerCls: "",
+ };
+
+ static EVENT_CHANGE = "EVENT_CHANGE";
- render: function () {
- var self = this, o = this.options;
+ render() {
+ const o = this.options;
return {
- type: "bi.button_group",
+ type: ButtonGroup.xtype,
items: this._createItems(),
layouts: [o.layout],
- ref: function (ref) {
- self.group = ref;
- }
+ ref: _ref => {
+ this.group = _ref;
+ },
};
- },
+ }
- _createItems: function () {
- var self = this;
- var o = this.options;
+ _createItems() {
+ const self = this;
+ const o = this.options;
- return BI.map(o.items, function (idx, item) {
+ return map(o.items, (idx, item) => {
return {
- type: "bi.form_field",
+ type: FormField.xtype,
height: item.el.height || 28,
labelAlign: o.labelAlign,
labelWidth: o.labelWidth,
@@ -50,46 +45,41 @@
label: item.label,
tip: item.tip,
validate: item.validate,
- listeners: [{
- eventName: "EVENT_CHANGE",
- action: function () {
- self.fireEvent(BI.Form.EVENT_CHANGE, this.validate());
+ listeners: [
+ {
+ eventName: "EVENT_CHANGE",
+ action() {
+ self.fireEvent(Form.EVENT_CHANGE, this.validate());
+ },
}
- }]
+ ],
};
});
- },
+ }
- isAllValid: function () {
- return !BI.some(this.validateWithNoTip(), function (idx, v) {
- return !v;
- });
- },
+ isAllValid() {
+ return !some(this.validateWithNoTip(), (idx, v) => !v);
+ }
- validateWithNoTip: function () {
- var validInfo = [];
- BI.each(this.group.getAllButtons(), function (idx, button) {
+ validateWithNoTip() {
+ const validInfo = [];
+ each(this.group.getAllButtons(), (idx, button) => {
validInfo.push(button.validateWithNoTip());
});
return validInfo;
- },
+ }
- validate: function () {
- var validInfo = [];
- BI.each(this.group.getAllButtons(), function (idx, button) {
+ validate() {
+ const validInfo = [];
+ each(this.group.getAllButtons(), (idx, button) => {
validInfo.push(button.validate());
});
return validInfo;
- },
-
- getValue: function () {
- return !this.isAllValid() ? null : BI.map(this.group.getAllButtons(), function (idx, button) {
- return button.getValue();
- });
}
-});
-BI.Form.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.custom_form", BI.Form);
+ getValue() {
+ return !this.isAllValid() ? null : map(this.group.getAllButtons(), (idx, button) => button.getValue());
+ }
+}
diff --git a/src/component/form/index.js b/src/component/form/index.js
new file mode 100644
index 000000000..c2ffb7651
--- /dev/null
+++ b/src/component/form/index.js
@@ -0,0 +1,2 @@
+export { Form } from "./form";
+export { FormField } from "./form.field";
diff --git a/src/component/index.js b/src/component/index.js
new file mode 100644
index 000000000..97b0ba2c6
--- /dev/null
+++ b/src/component/index.js
@@ -0,0 +1,21 @@
+export * as allvaluechooser from "./allvaluechooser";
+export * as form from "./form";
+export * as valueChooser from "./valuechooser";
+export * as treeValueChooser from "./treevaluechooser";
+export { AllValueMultiTextValueCombo } from "./allvaluemultitextvaluecombo/allvalue.multitextvalue.combo";
+
+// Object.assign(BI, {
+// ...allvaluechooser,
+// ...form,
+// ...valueChooser,
+// ......treeValueChooser,
+// AllValueMultiTextValueCombo,
+// });
+
+// export * from "./allvaluechooser";
+// export * from "./form";
+// export * from "./valuechooser";
+// export * from "./treevaluechooser";
+// export {
+// AllValueMultiTextValueCombo
+// };
diff --git a/src/component/treevaluechooser/abstract.treevaluechooser.js b/src/component/treevaluechooser/abstract.treevaluechooser.js
index f1a7665d5..73f5b4616 100644
--- a/src/component/treevaluechooser/abstract.treevaluechooser.js
+++ b/src/component/treevaluechooser/abstract.treevaluechooser.js
@@ -1,158 +1,195 @@
-BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
-
- _const: {
- perPage: 100
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.AbstractTreeValueChooser.superclass._defaultConfig.apply(this, arguments), {
+import {
+ Widget,
+ extend,
+ emptyFn,
+ isNotNull,
+ some,
+ Tree,
+ isEmpty,
+ each,
+ clone,
+ isNull,
+ UUID,
+ size,
+ i18nText,
+ deepClone,
+ isNotEmptyArray,
+ last,
+ has,
+ nextTick,
+ concat,
+ filter,
+ Func,
+ any,
+ every,
+ map,
+ difference,
+ keys,
+ isPlainObject,
+ get,
+ set
+} from "@/core";
+import { TreeView } from "@/case";
+
+export class AbstractTreeValueChooser extends Widget {
+ _const = { perPage: 100 };
+
+ _defaultConfig() {
+ return extend(super._defaultConfig(...arguments), {
items: null,
- itemsCreator: BI.emptyFn,
- open: false
+ itemsCreator: emptyFn,
+ open: false,
});
- },
+ }
- _valueFormatter: function (v) {
- var text = v;
+ _valueFormatter(v) {
+ let text = v;
if (this.options.valueFormatter) {
return this.options.valueFormatter(v);
}
- if (BI.isNotNull(this.items)) {
- BI.some(this.items, function (i, item) {
- if (item.value === v || item.value + "" === v) {
+ if (isNotNull(this.items)) {
+ some(this.items, (i, item) => {
+ if (item.value === v || `${item.value}` === v) {
text = item.text;
+
return true;
}
});
}
+
return text;
- },
+ }
- _initData: function (items) {
+ _initData(items) {
this.items = items;
- var nodes = BI.Tree.treeFormat(items);
- this.tree = new BI.Tree();
+ const nodes = Tree.treeFormat(items);
+ this.tree = new Tree();
this.tree.initTree(nodes);
- },
+ }
- _itemsCreator: function (options, callback) {
- var self = this, o = this.options;
+ _itemsCreator(options, callback) {
+ const call = () => {
+ switch (options.type) {
+ case TreeView.REQ_TYPE_INIT_DATA:
+ this._reqInitTreeNode(options, callback);
+ break;
+ case TreeView.REQ_TYPE_ADJUST_DATA:
+ this._reqAdjustTreeNode(options, callback);
+ break;
+ case TreeView.REQ_TYPE_SELECT_DATA:
+ this._reqSelectedTreeNode(options, callback);
+ break;
+ case TreeView.REQ_TYPE_GET_SELECTED_DATA:
+ this._reqDisplayTreeNode(options, callback);
+ break;
+ default:
+ this._reqTreeNode(options, callback);
+ break;
+ }
+ };
+ const o = this.options;
if (!this.items) {
- o.itemsCreator({}, function (items) {
- self._initData(items);
+ o.itemsCreator({}, items => {
+ this._initData(items);
call();
});
} else {
call();
}
+ }
- function call() {
- switch (options.type) {
- case BI.TreeView.REQ_TYPE_INIT_DATA:
- self._reqInitTreeNode(options, callback);
- break;
- case BI.TreeView.REQ_TYPE_ADJUST_DATA:
- self._reqAdjustTreeNode(options, callback);
- break;
- case BI.TreeView.REQ_TYPE_SELECT_DATA:
- self._reqSelectedTreeNode(options, callback);
- break;
- case BI.TreeView.REQ_TYPE_GET_SELECTED_DATA:
- self._reqDisplayTreeNode(options, callback);
- break;
- default :
- self._reqTreeNode(options, callback);
- break;
- }
- }
- },
-
- _reqDisplayTreeNode: function (op, callback) {
- var self = this;
- var result = [];
- var selectedValues = op.selectedValues;
+ _reqDisplayTreeNode(op, callback) {
+ const result = [];
+ const selectedValues = op.selectedValues;
- if (selectedValues == null || BI.isEmpty(selectedValues)) {
+ if (selectedValues == null || isEmpty(selectedValues)) {
callback({});
+
return;
}
- doCheck([], this.tree.getRoot(), selectedValues);
+ const getCount = (jo, parentValues) => {
+ if (jo == null) {
+ return 0;
+ }
+ if (isEmpty(jo)) {
+ return this._getChildCount(parentValues);
+ }
- callback({
- items: result
- });
+ return size(jo);
+ };
- function doCheck(parentValues, node, selected) {
- if (selected == null || BI.isEmpty(selected)) {
- BI.each(node.getChildren(), function (i, child) {
- var newParents = BI.clone(parentValues);
+ const doCheck = (parentValues, node, selected) => {
+ if (selected == null || isEmpty(selected)) {
+ each(node.getChildren(), (i, child) => {
+ const newParents = clone(parentValues);
newParents.push(child.value);
- var llen = self._getChildCount(newParents);
+ const llen = this._getChildCount(newParents);
createOneJson(child, node.id, llen);
doCheck(newParents, child, {});
});
+
return;
}
- BI.each(selected, function (k) {
- var node = self._getTreeNode(parentValues, k);
+ each(selected, k => {
+ const node = this._getTreeNode(parentValues, k);
// 找不到就是新增值
- if(BI.isNull(node)) {
- createOneJson({
- id: BI.UUID(),
- text: k,
- value: k
- }, BI.UUID(), 0);
+ if (isNull(node)) {
+ createOneJson(
+ {
+ id: UUID(),
+ text: k,
+ value: k,
+ },
+ UUID(),
+ 0
+ );
} else {
- var newParents = BI.clone(parentValues);
+ const newParents = clone(parentValues);
newParents.push(node.value);
createOneJson(node, node.parent && node.parent.id, getCount(selected[k], newParents));
doCheck(newParents, node, selected[k]);
}
});
- }
+ };
- function getCount(jo, parentValues) {
- if (jo == null) {
- return 0;
- }
- if (BI.isEmpty(jo)) {
- return self._getChildCount(parentValues);
- }
+ doCheck([], this.tree.getRoot(), selectedValues);
- return BI.size(jo);
- }
+ callback({
+ items: result,
+ });
function createOneJson(node, pId, llen) {
result.push({
id: node.id,
- pId: pId,
- text: node.text + (llen > 0 ? ("(" + BI.i18nText("BI-Basic_Altogether") + llen + BI.i18nText("BI-Basic_Count") + ")") : ""),
+ pId,
+ text:
+ node.text +
+ (llen > 0 ? `(${i18nText("BI-Basic_Altogether")}${llen}${i18nText("BI-Basic_Count")})` : ""),
value: node.value,
open: true,
- disabled: node.disabled
+ disabled: node.disabled,
});
}
- },
+ }
- _reqSelectedTreeNode: function (op, callback) {
- var self = this;
- var selectedValues = BI.deepClone(op.selectedValues);
- var notSelectedValue = op.notSelectedValue || {};
- var keyword = op.keyword || "";
- var parentValues = op.parentValues || [];
+ _reqSelectedTreeNode(op, callback) {
+ const selectedValues = deepClone(op.selectedValues);
+ const notSelectedValue = op.notSelectedValue || {};
+ const keyword = op.keyword || "";
+ const parentValues = op.parentValues || [];
- if (selectedValues == null || BI.isEmpty(selectedValues)) {
+ if (selectedValues == null || isEmpty(selectedValues)) {
callback({});
+
return;
}
dealWithSelectedValues(selectedValues);
callback(selectedValues);
-
- function dealWithSelectedValues(selectedValues) {
- var p = parentValues.concat(notSelectedValue);
+ const dealWithSelectedValues = selectedValues => {
+ let p = parentValues.concat(notSelectedValue);
// 存储的值中存在这个值就把它删掉
// 例如选中了中国-江苏-南京, 取消中国或江苏或南京
// p长度不大于selectedValues的情况才可能找到,这样可以直接删除selectedValues的节点
@@ -160,21 +197,21 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
// 如果搜索的值在父亲链中
if (isSearchValueInParent(p)) {
// 例如选中了 中国-江苏, 搜索江苏, 取消江苏(干掉了江苏)
- self._deleteNode(selectedValues, p);
+ this._deleteNode(selectedValues, p);
} else {
- var searched = [];
+ const searched = [];
// 要找到所有以notSelectedValue为叶子节点的链路
- var find = search(parentValues, notSelectedValue, [], searched);
- if (find && BI.isNotEmptyArray(searched)) {
- BI.each(searched, function (i, arr) {
- var node = self._getNode(selectedValues, arr);
+ const find = search(parentValues, notSelectedValue, [], searched);
+ if (find && isNotEmptyArray(searched)) {
+ each(searched, (i, arr) => {
+ const node = this._getNode(selectedValues, arr);
if (node) {
// 例如选中了 中国-江苏, 搜索江苏, 取消中国(实际上只想删除中国-江苏,因为搜的是江苏)
// 例如选中了 中国-江苏-南京,搜索南京,取消中国(实际上只想删除中国-江苏-南京,因为搜的是南京)
- self._deleteNode(selectedValues, arr);
+ this._deleteNode(selectedValues, arr);
} else {
// 例如选中了 中国-江苏,搜索南京,取消中国(实际上只想删除中国-江苏-南京,因为搜的是南京)
- expandSelectedValue(selectedValues, arr, BI.last(arr));
+ expandSelectedValue(selectedValues, arr, last(arr));
}
});
}
@@ -185,7 +222,8 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
// 例如选中了中国-江苏,取消南京
// important 选中了中国-江苏,取消了江苏,但是搜索的是南京
if (isChild(selectedValues, p)) {
- var result = [], find = false;
+ const result = [];
+ let find = false;
// 如果parentValues中有匹配的值,说明搜索结果不在当前值下
if (isSearchValueInParent(p)) {
find = true;
@@ -200,42 +238,45 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
expandSelectedValue(selectedValues, p, notSelectedValue);
// 添加去掉搜索的结果集
if (result.length > 0) {
- BI.each(result, function (i, strs) {
- self._buildTree(selectedValues, strs);
+ each(result, (i, strs) => {
+ this._buildTree(selectedValues, strs);
});
}
}
}
+ };
- }
-
- function expandSelectedValue(selectedValues, parents, notSelectedValue) {
- var next = selectedValues;
- var childrenCount = [];
- var path = [];
+ const expandSelectedValue = (selectedValues, parents, notSelectedValue) => {
+ let next = selectedValues;
+ const childrenCount = [];
+ const path = [];
// 去掉点击的节点之后的结果集
- BI.some(parents, function (i, v) {
- var t = next[v];
+ some(parents, (i, v) => {
+ const t = next[v];
if (t == null) {
if (i === 0) {
return true;
}
- if (BI.isEmpty(next)) {
- var split = parents.slice(0, i);
- var expanded = self._getChildren(split);
+ if (isEmpty(next)) {
+ const split = parents.slice(0, i);
+ const expanded = this._getChildren(split);
path.push(split);
childrenCount.push(expanded.length);
// 如果只有一个值且取消的就是这个值
- if (i === parents.length - 1 && expanded.length === 1 && expanded[0].value === notSelectedValue) {
- for (var j = childrenCount.length - 1; j >= 0; j--) {
+ if (
+ i === parents.length - 1 &&
+ expanded.length === 1 &&
+ expanded[0].value === notSelectedValue
+ ) {
+ for (let j = childrenCount.length - 1; j >= 0; j--) {
if (childrenCount[j] === 1) {
- self._deleteNode(selectedValues, path[j]);
+ this._deleteNode(selectedValues, path[j]);
} else {
break;
}
}
} else {
- BI.each(expanded, function (m, child) {
+ each(expanded, (m, child) => {
if (i === parents.length - 1 && child.value === notSelectedValue) {
return true;
}
@@ -252,22 +293,23 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
next = t;
}
});
- }
+ };
- function search(parents, current, result, searched) {
- var newParents = BI.clone(parents);
+ const search = (parents, current, result, searched) => {
+ const newParents = clone(parents);
newParents.push(current);
- if (self._isMatch(parents, current, keyword)) {
+ if (this._isMatch(parents, current, keyword)) {
searched && searched.push(newParents);
+
return true;
}
- var children = self._getChildren(newParents);
+ const children = this._getChildren(newParents);
- var notSearch = [];
- var can = false;
+ const notSearch = [];
+ let can = false;
- BI.each(children, function (i, child) {
+ each(children, (i, child) => {
if (search(newParents, child.value, result, searched)) {
can = true;
} else {
@@ -275,117 +317,119 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
}
});
if (can === true) {
- BI.each(notSearch, function (i, v) {
- var next = BI.clone(newParents);
+ each(notSearch, (i, v) => {
+ const next = clone(newParents);
next.push(v);
result.push(next);
});
}
+
return can;
- }
+ };
- function isSearchValueInParent(parentValues) {
- for (var i = 0, len = parentValues.length; i < len; i++) {
- if (self._isMatch(parentValues.slice(0, i), parentValues[i], keyword)) {
+ const isSearchValueInParent = parentValues => {
+ for (let i = 0, len = parentValues.length; i < len; i++) {
+ if (this._isMatch(parentValues.slice(0, i), parentValues[i], keyword)) {
return true;
}
}
+
return false;
- }
+ };
function canFindKey(selectedValues, parents) {
- var t = selectedValues;
- for (var i = 0; i < parents.length; i++) {
- var v = parents[i];
+ let t = selectedValues;
+ for (let i = 0; i < parents.length; i++) {
+ const v = parents[i];
t = t[v];
if (t == null) {
return false;
}
}
+
return true;
}
function isChild(selectedValues, parents) {
- var t = selectedValues;
- for (var i = 0; i < parents.length; i++) {
- var v = parents[i];
- if (!BI.has(t, v)) {
+ let t = selectedValues;
+ for (let i = 0; i < parents.length; i++) {
+ const v = parents[i];
+ if (!has(t, v)) {
return false;
}
t = t[v];
- if (BI.isEmpty(t)) {
+ if (isEmpty(t)) {
return true;
}
}
+
return false;
}
- },
+ }
- _reqAdjustTreeNode: function (op, callback) {
- var self = this;
- var result = [];
- var selectedValues = op.selectedValues;
- if (selectedValues == null || BI.isEmpty(selectedValues)) {
+ _reqAdjustTreeNode(op, callback) {
+ const result = [];
+ const selectedValues = op.selectedValues;
+ if (selectedValues == null || isEmpty(selectedValues)) {
callback({});
+
return;
}
- BI.each(selectedValues, function (k, v) {
+ each(selectedValues, (k, v) => {
result.push([k]);
});
dealWithSelectedValues(selectedValues, []);
- var jo = {};
- BI.each(result, function (i, strs) {
- self._buildTree(jo, strs);
+ const jo = {};
+ each(result, (i, strs) => {
+ this._buildTree(jo, strs);
});
callback(jo);
function dealWithSelectedValues(selected, parents) {
- if (selected == null || BI.isEmpty(selected)) {
+ if (selected == null || isEmpty(selected)) {
return true;
}
- var can = true;
- BI.each(selected, function (k, v) {
- var p = BI.clone(parents);
+ let can = true;
+ each(selected, (k, v) => {
+ const p = clone(parents);
p.push(k);
if (!dealWithSelectedValues(selected[k], p)) {
- BI.each(selected[k], function (nk, nv) {
- var t = BI.clone(p);
+ each(selected[k], (nk, nv) => {
+ const t = clone(p);
t.push(nk);
result.push(t);
});
can = false;
}
});
+
return can && isAllSelected(selected, parents);
}
- function isAllSelected(selected, parents) {
- return BI.isEmpty(selected) || self._getChildCount(parents) === BI.size(selected);
- }
- },
-
- _reqInitTreeNode: function (op, callback) {
- var self = this;
- var result = [];
- var keyword = op.keyword || "";
- var selectedValues = op.selectedValues;
- var lastSearchValue = op.lastSearchValue || ""; // 一次请求100个,但是搜索是拿全部的,lastSearchValue是上一次遍历到的节点索引
- var output = search();
- BI.nextTick(function () {
+ const isAllSelected = (selected, parents) => isEmpty(selected) || this._getChildCount(parents) === size(selected);
+ }
+
+ _reqInitTreeNode(op, callback) {
+ let result = [];
+ const keyword = op.keyword || "";
+ const selectedValues = op.selectedValues;
+ const lastSearchValue = op.lastSearchValue || ""; // 一次请求100个,但是搜索是拿全部的,lastSearchValue是上一次遍历到的节点索引
+ const output = search();
+ nextTick(() => {
callback({
- hasNext: output.length > self._const.perPage,
+ hasNext: output.length > this._const.perPage,
items: result,
- lastSearchValue: BI.last(output)
+ lastSearchValue: last(output),
});
});
- function search() {
- var children = self._getChildren([]);
- var start = children.length;
+ const search = () => {
+ const children = this._getChildren([]);
+ let start = children.length;
if (lastSearchValue !== "") {
- for (var j = 0, len = start; j < len; j++) {
+ for (let j = 0, len = start; j < len; j++) {
if (children[j].value === lastSearchValue) {
start = j + 1;
break;
@@ -394,47 +438,63 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
} else {
start = 0;
}
- var output = [];
- for (var i = start, len = children.length; i < len; i++) {
- if (output.length < self._const.perPage) {
- var find = nodeSearch(1, [], children[i].value, false, result);
- } else if (output.length === self._const.perPage) {
- var find = nodeSearch(1, [], children[i].value, false, []);
+ const output = [];
+ for (let i = start, len = children.length; i < len; i++) {
+ let find;
+ if (output.length < this._const.perPage) {
+ find = nodeSearch(1, [], children[i].value, false, result);
+ } else if (output.length === this._const.perPage) {
+ find = nodeSearch(1, [], children[i].value, false, []);
}
if (find[0] === true) {
output.push(children[i].value);
}
- if (output.length > self._const.perPage) {
+ if (output.length > this._const.perPage) {
break;
}
}
// 深层嵌套的比较麻烦,这边先实现的是在根节点添加
if (op.times === 1) {
- var nodes = self._getAddedValueNode([], selectedValues);
- result = BI.concat(BI.filter(nodes, function (idx, node) {
- var find = BI.Func.getSearchResult([node.text || node.value], keyword);
- return find.find.length > 0 || find.match.length > 0;
- }), result);
- }
+ const nodes = this._getAddedValueNode([], selectedValues);
+ result = concat(
+ filter(nodes, (idx, node) => {
+ const find = Func.getSearchResult([node.text || node.value], keyword);
+
+ return find.find.length > 0 || find.match.length > 0;
+ }),
+ result
+ );
+ }
+
return output;
- }
-
- function nodeSearch(deep, parentValues, current, isAllSelect, result) {
- if (self._isMatch(parentValues, current, keyword)) {
- var checked = isAllSelect || isSelected(parentValues, current);
- createOneJson(parentValues, current, false, checked, !isAllSelect && isHalf(parentValues, current), true, result);
+ };
+
+ const nodeSearch = (deep, parentValues, current, isAllSelect, result) => {
+ if (this._isMatch(parentValues, current, keyword)) {
+ const checked = isAllSelect || isSelected(parentValues, current);
+ createOneJson(
+ parentValues,
+ current,
+ false,
+ checked,
+ !isAllSelect && isHalf(parentValues, current),
+ true,
+ result
+ );
+
return [true, checked];
}
- var newParents = BI.clone(parentValues);
+ const newParents = clone(parentValues);
newParents.push(current);
- var children = self._getChildren(newParents);
+ const children = this._getChildren(newParents);
- var can = false, checked = false;
+ let can = false,
+ checked = false;
- var isCurAllSelected = isAllSelect || isAllSelected(parentValues, current);
- BI.each(children, function (i, child) {
- var state = nodeSearch(deep + 1, newParents, child.value, isCurAllSelected, result);
+ const isCurAllSelected = isAllSelect || isAllSelected(parentValues, current);
+ each(children, (i, child) => {
+ const state = nodeSearch(deep + 1, newParents, child.value, isCurAllSelected, result);
// 当前节点的子节点是否选中,并不确定全选还是半选
if (state[1] === true) {
checked = true;
@@ -449,11 +509,12 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
checked = isCurAllSelected || (isSelected(parentValues, current) && checked);
createOneJson(parentValues, current, true, checked, false, false, result);
}
+
return [can, checked];
- }
+ };
- function createOneJson(parentValues, value, isOpen, checked, half, flag, result) {
- var node = self._getTreeNode(parentValues, value);
+ const createOneJson = (parentValues, value, isOpen, checked, half, flag, result) => {
+ const node = this._getTreeNode(parentValues, value);
result.push({
id: node.id,
pId: node.pId,
@@ -462,21 +523,22 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
title: node.title,
isParent: node.getChildrenLength() > 0,
open: isOpen,
- checked: checked,
+ checked,
halfCheck: half,
- flag: flag,
- disabled: node.disabled
+ flag,
+ disabled: node.disabled,
});
- }
+ };
function isHalf(parentValues, value) {
- var find = findSelectedObj(parentValues);
+ const find = findSelectedObj(parentValues);
if (find == null) {
return null;
}
- return BI.any(find, function (v, ob) {
+
+ return any(find, (v, ob) => {
if (v === value) {
- if (ob != null && !BI.isEmpty(ob)) {
+ if (ob != null && !isEmpty(ob)) {
return true;
}
}
@@ -484,13 +546,14 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
}
function isAllSelected(parentValues, value) {
- var find = findSelectedObj(parentValues);
+ const find = findSelectedObj(parentValues);
if (find == null) {
return null;
}
- return BI.any(find, function (v, ob) {
+
+ return any(find, (v, ob) => {
if (v === value) {
- if (ob != null && BI.isEmpty(ob)) {
+ if (ob != null && isEmpty(ob)) {
return true;
}
}
@@ -498,11 +561,12 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
}
function isSelected(parentValues, value) {
- var find = findSelectedObj(parentValues);
+ const find = findSelectedObj(parentValues);
if (find == null) {
return false;
}
- return BI.any(find, function (v) {
+
+ return any(find, v => {
if (v === value) {
return true;
}
@@ -510,37 +574,116 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
}
function findSelectedObj(parentValues) {
- var find = selectedValues;
+ let find = selectedValues;
if (find == null) {
return null;
}
- BI.every(parentValues, function (i, v) {
+ every(parentValues, (i, v) => {
find = find[v];
if (find == null) {
return false;
}
+
return true;
});
+
return find;
}
- },
-
- _reqTreeNode: function (op, callback) {
- var self = this, o = this.options;
- var result = [];
- var times = op.times;
- var checkState = op.checkState || {};
- var parentValues = op.parentValues || [];
- var selectedValues = op.selectedValues || {};
- function getResult(parentValues, checkState) {
- var valueMap = {};
+ }
+
+ _reqTreeNode(op, callback) {
+ const o = this.options;
+ let result = [];
+ const times = op.times;
+ const checkState = op.checkState || {};
+ const parentValues = op.parentValues || [];
+ const selectedValues = op.selectedValues || {};
+ const getCheckState = (current, parentValues, valueMap, checkState) => {
+ // 节点本身的checked和half优先级最高
+ const checked = checkState.checked,
+ half = checkState.half;
+ let tempCheck = false,
+ halfCheck = false;
+ if (has(valueMap, current)) {
+ // 可能是半选
+ if (valueMap[current][0] === 1) {
+ const values = clone(parentValues);
+ values.push(current);
+ const childCount = this._getChildCount(values);
+ if (childCount > 0 && childCount !== valueMap[current][1]) {
+ halfCheck = true;
+ }
+ } else if (valueMap[current][0] === 2) {
+ tempCheck = true;
+ }
+ }
+ let check;
+ // 展开的节点checked为false 且没有明确得出当前子节点是半选或者全选, 则check状态取决于valueMap
+ if (!checked && !halfCheck && !tempCheck) {
+ check = has(valueMap, current);
+ } else {
+ // 不是上面那种情况就先看在节点没有带有明确半选的时候,通过节点自身的checked和valueMap的状态能都得到选中信息
+ check = ((tempCheck || checked) && !half) || has(valueMap, current);
+ }
+
+ return [check, halfCheck];
+ };
+ const getResult = (parentValues, checkState) => {
+ let valueMap = {};
// if (judgeState(parentValues, selectedValues, checkState)) {
+ const isAllSelected = (selected, parents) => {
+ if (isEmpty(selected)) {
+ return true;
+ }
+
+ if (this._getChildCount(parents) !== size(selected)) {
+ return false;
+ }
+
+ return every(selected, value => isAllSelected(selected[value], concat(parents, value)));
+ };
+
+ function dealWithSelectedValue(parentValues, selectedValues) {
+ const valueMap = {},
+ parents = (parentValues || []).slice(0);
+ each(parentValues, (i, v) => {
+ parents.push(v);
+
+ selectedValues = selectedValues[v] || {};
+ });
+ each(selectedValues, (value, obj) => {
+ const currentParents = concat(parents, value);
+
+ if (isNull(obj)) {
+ valueMap[value] = [0, 0];
+
+ return;
+ }
+ if (isEmpty(obj)) {
+ valueMap[value] = [2, 0];
+
+ return;
+ }
+ const nextNames = {};
+ each(obj, (t, o) => {
+ if (isNull(o) || isEmpty(o)) {
+ nextNames[t] = true;
+ } else {
+ isAllSelected(o, concat(currentParents, [t])) && (nextNames[t] = true);
+ }
+ });
+ // valueMap的数组第一个参数为不选: 0, 半选: 1, 全选:2, 第二个参数为改节点下选中的子节点个数(子节点全选或者不存在)
+ valueMap[value] = [1, size(nextNames)];
+ });
+
+ return valueMap;
+ }
valueMap = dealWithSelectedValue(parentValues, selectedValues);
// }
- var nodes = self._getChildren(parentValues);
- for (var i = (times - 1) * self._const.perPage; nodes[i] && i < times * self._const.perPage; i++) {
- var state = getCheckState(nodes[i].value, parentValues, valueMap, checkState);
- var openState = o.open || nodes[i].open;
+ const nodes = this._getChildren(parentValues);
+ for (let i = (times - 1) * this._const.perPage; nodes[i] && i < times * this._const.perPage; i++) {
+ const state = getCheckState(nodes[i].value, parentValues, valueMap, checkState);
+ const openState = o.open || nodes[i].open;
result.push({
id: nodes[i].id,
pId: nodes[i].pId,
@@ -557,10 +700,10 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
warningTitle: nodes[i].warningTitle,
});
if (openState) {
- getResult(parentValues.concat([nodes[i].value]), {checked: state[0], half: state[1]});
+ getResult(parentValues.concat([nodes[i].value]), { checked: state[0], half: state[1] });
}
}
- }
+ };
getResult(parentValues, checkState);
@@ -568,22 +711,22 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
// if (o.open) {
// var allNodes = [];
// // 获取所有节点
- // BI.each(nodes, function (idx, node) {
- // allNodes = BI.concat(allNodes, self._getAllChildren(parentValues.concat([node.value])));
+ // each(nodes, function (idx, node) {
+ // allNodes = concat(allNodes, self._getAllChildren(parentValues.concat([node.value])));
// });
// var lastFind;
- // BI.each(allNodes, function (idx, node) {
+ // each(allNodes, function (idx, node) {
// var valueMap = dealWithSelectedValue(node.parentValues, selectedValues);
// // REPORT-24409 fix: 设置节点全部展开,添加的节点没有给状态
// var parentCheckState = {};
- // var find = BI.find(result, function (idx, pNode) {
+ // var find = find(result, function (idx, pNode) {
// return pNode.id === node.pId;
// });
// if (find) {
// parentCheckState.checked = find.halfCheck ? false : find.checked;
// parentCheckState.half = find.halfCheck;
// // 默认展开也需要重置父节点的halfCheck
- // if (BI.isNotNull(lastFind) && (lastFind !== find || allNodes.length - 1 === idx)) {
+ // if (isNotNull(lastFind) && (lastFind !== find || allNodes.length - 1 === idx)) {
// lastFind.half = lastFind.halfCheck;
// lastFind.halfCheck = false;
// }
@@ -609,12 +752,12 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
// 深层嵌套的比较麻烦,这边先实现的是在根节点添加
if (parentValues.length === 0 && times === 1) {
- result = BI.concat(self._getAddedValueNode(parentValues, selectedValues), result);
+ result = concat(this._getAddedValueNode(parentValues, selectedValues), result);
}
- BI.nextTick(function () {
+ nextTick(() => {
callback({
items: result,
- hasNext: self._getChildren(parentValues).length > times * self._const.perPage
+ hasNext: this._getChildren(parentValues).length > times * this._const.perPage,
});
});
@@ -623,90 +766,17 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
// if (parentValues.length > 0 && !checked) {
// return false;
// }
- // return (parentValues.length === 0 || (checked && half) && !BI.isEmpty(selected_value));
+ // return (parentValues.length === 0 || (checked && half) && !isEmpty(selected_value));
// }
+ }
- function dealWithSelectedValue(parentValues, selectedValues) {
- var valueMap = {}, parents = (parentValues || []).slice(0);
- BI.each(parentValues, function (i, v) {
- parents.push(v);
-
- selectedValues = selectedValues[v] || {};
- });
- BI.each(selectedValues, function (value, obj) {
- var currentParents = BI.concat(parents, value);
-
- if (BI.isNull(obj)) {
- valueMap[value] = [0, 0];
- return;
- }
- if (BI.isEmpty(obj)) {
- valueMap[value] = [2, 0];
- return;
- }
- var nextNames = {};
- BI.each(obj, function (t, o) {
- if (BI.isNull(o) || BI.isEmpty(o)) {
- nextNames[t] = true;
- } else {
- isAllSelected(o, BI.concat(currentParents, [t])) && (nextNames[t] = true);
- }
- });
- // valueMap的数组第一个参数为不选: 0, 半选: 1, 全选:2, 第二个参数为改节点下选中的子节点个数(子节点全选或者不存在)
- valueMap[value] = [1, BI.size(nextNames)];
- });
- return valueMap;
- }
-
- function isAllSelected(selected, parents) {
- if (BI.isEmpty(selected)) {
- return true;
- }
-
- if (self._getChildCount(parents) !== BI.size(selected)) {
- return false;
- }
-
- return BI.every(selected, function (value) {
- return isAllSelected(selected[value], BI.concat(parents, value));
- });
- }
-
- function getCheckState(current, parentValues, valueMap, checkState) {
- // 节点本身的checked和half优先级最高
- var checked = checkState.checked, half = checkState.half;
- var tempCheck = false, halfCheck = false;
- if (BI.has(valueMap, current)) {
- // 可能是半选
- if (valueMap[current][0] === 1) {
- var values = BI.clone(parentValues);
- values.push(current);
- var childCount = self._getChildCount(values);
- if (childCount > 0 && childCount !== valueMap[current][1]) {
- halfCheck = true;
- }
- } else if (valueMap[current][0] === 2) {
- tempCheck = true;
- }
- }
- var check;
- // 展开的节点checked为false 且没有明确得出当前子节点是半选或者全选, 则check状态取决于valueMap
- if (!checked && !halfCheck && !tempCheck) {
- check = BI.has(valueMap, current);
- } else {
- // 不是上面那种情况就先看在节点没有带有明确半选的时候,通过节点自身的checked和valueMap的状态能都得到选中信息
- check = ((tempCheck || checked) && !half) || BI.has(valueMap, current);
- }
- return [check, halfCheck];
- }
- },
-
- _getAddedValueNode: function (parentValues, selectedValues) {
- var nodes = this._getChildren(parentValues);
- return BI.map(BI.difference(BI.keys(selectedValues), BI.map(nodes, "value")), function (idx, v) {
+ _getAddedValueNode(parentValues, selectedValues) {
+ const nodes = this._getChildren(parentValues);
+
+ return map(difference(keys(selectedValues), map(nodes, "value")), (idx, v) => {
return {
- id: BI.UUID(),
- pId: nodes.length > 0 ? nodes[0].pId : BI.UUID(),
+ id: UUID(),
+ pId: nodes.length > 0 ? nodes[0].pId : UUID(),
value: v,
text: v,
times: 1,
@@ -715,27 +785,28 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
halfCheck: false,
};
});
- },
+ }
- _getNode: function (selectedValues, parentValues) {
- var pNode = selectedValues;
- for (var i = 0, len = parentValues.length; i < len; i++) {
+ _getNode(selectedValues, parentValues) {
+ let pNode = selectedValues;
+ for (let i = 0, len = parentValues.length; i < len; i++) {
if (pNode == null) {
return null;
}
pNode = pNode[parentValues[i]];
}
+
return pNode;
- },
+ }
- _deleteNode: function (selectedValues, values) {
- var name = values[values.length - 1];
- var p = values.slice(0, values.length - 1);
- var pNode = this._getNode(selectedValues, p);
+ _deleteNode(selectedValues, values) {
+ let name = values[values.length - 1];
+ let p = values.slice(0, values.length - 1);
+ let pNode = this._getNode(selectedValues, p);
if (pNode != null && pNode[name]) {
delete pNode[name];
// 递归删掉空父节点
- while (p.length > 0 && BI.isEmpty(pNode)) {
+ while (p.length > 0 && isEmpty(pNode)) {
name = p[p.length - 1];
p = p.slice(0, p.length - 1);
pNode = this._getNode(selectedValues, p);
@@ -744,40 +815,42 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
}
}
}
- },
+ }
- _buildTree: function (jo, values) {
- var t = jo;
- BI.each(values, function (i, v) {
- if (!BI.has(t, v)) {
+ _buildTree(jo, values) {
+ let t = jo;
+ each(values, (i, v) => {
+ if (!has(t, v)) {
t[v] = {};
}
t = t[v];
});
- },
+ }
- _isMatch: function (parentValues, value, keyword) {
- var o = this.options;
- var node = this._getTreeNode(parentValues, value);
+ _isMatch(parentValues, value, keyword) {
+ const o = this.options;
+ const node = this._getTreeNode(parentValues, value);
if (!node) {
return false;
}
- var find = BI.Func.getSearchResult([node.text || node.value], keyword);
- if(o.allowSearchValue && node.value) {
- var valueFind = BI.Func.getSearchResult([node.value], keyword);
- return valueFind.find.length > 0 || valueFind.match.length > 0 ||
- find.find.length > 0 || find.match.length > 0;
+ const find = Func.getSearchResult([node.text || node.value], keyword);
+ if (o.allowSearchValue && node.value) {
+ const valueFind = Func.getSearchResult([node.value], keyword);
+
+ return (
+ valueFind.find.length > 0 || valueFind.match.length > 0 || find.find.length > 0 || find.match.length > 0
+ );
}
+
return find.find.length > 0 || find.match.length > 0;
- },
-
- _getTreeNode: function (parentValues, v) {
- var self = this;
- var findParentNode;
- var index = 0;
- var currentParent = this.tree.getRoot();
- this.tree.traverse(function (node) {
- if (self.tree.isRoot(node)) {
+ }
+
+ _getTreeNode(parentValues, v) {
+ let findParentNode;
+ let index = 0;
+ let currentParent = this.tree.getRoot();
+ this.tree.traverse(node => {
+ if (this.tree.isRoot(node)) {
return;
}
if (index > parentValues.length) {
@@ -809,109 +882,111 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
});
return findParentNode;
- },
+ }
- _getChildren: function (parentValues) {
+ _getChildren(parentValues) {
+ let parent;
if (parentValues.length > 0) {
- var value = BI.last(parentValues);
- var parent = this._getTreeNode(parentValues.slice(0, parentValues.length - 1), value);
+ const value = last(parentValues);
+ parent = this._getTreeNode(parentValues.slice(0, parentValues.length - 1), value);
} else {
- var parent = this.tree.getRoot();
+ parent = this.tree.getRoot();
}
return parent ? parent.getChildren() : [];
- },
+ }
- _getAllChildren: function(parentValues) {
- var children = this._getChildren(parentValues);
- var nodes = [].concat(children);
- BI.each(nodes, function (idx, node) {
+ _getAllChildren(parentValues) {
+ const children = this._getChildren(parentValues);
+ let nodes = [].concat(children);
+ each(nodes, (idx, node) => {
node.parentValues = parentValues;
});
- var queue = BI.map(children, function (idx, node) {
+ let queue = map(children, (idx, node) => {
return {
- parentValues: parentValues,
- value: node.value
+ parentValues,
+ value: node.value,
};
});
- while (BI.isNotEmptyArray(queue)) {
- var node = queue.shift();
- var pValues = (node.parentValues).concat(node.value);
- var childNodes = this._getChildren(pValues);
- BI.each(childNodes, function (idx, node) {
+ while (isNotEmptyArray(queue)) {
+ const node = queue.shift();
+ const pValues = node.parentValues.concat(node.value);
+ const childNodes = this._getChildren(pValues);
+ each(childNodes, (idx, node) => {
node.parentValues = pValues;
});
queue = queue.concat(childNodes);
nodes = nodes.concat(childNodes);
}
+
return nodes;
- },
+ }
- _getChildCount: function (parentValues) {
+ _getChildCount(parentValues) {
return this._getChildren(parentValues).length;
- },
+ }
- assertSelectedValue: function (selectedValues, items = []) {
- if (BI.isPlainObject(selectedValues)) {
+ assertSelectedValue(selectedValues, items = []) {
+ if (isPlainObject(selectedValues)) {
return selectedValues;
}
- var tree = BI.Tree.transformToTreeFormat(items);
- var value2ParentMap = {};
- BI.Tree.traversal(tree, function (index, node, pNode) {
+ const tree = Tree.transformToTreeFormat(items);
+ const value2ParentMap = {};
+ Tree.traversal(tree, (index, node, pNode) => {
value2ParentMap[node.value] = pNode;
});
- var result = {};
- BI.each(selectedValues, function (index, value) {
- var curr = value;
- var parentPath = [];
+ const result = {};
+ each(selectedValues, (index, value) => {
+ let curr = value;
+ const parentPath = [];
while (curr) {
parentPath.unshift(curr);
curr = value2ParentMap[curr]?.value;
}
- BI.each(parentPath, function (index) {
- if (BI.isNull(BI.get(result, parentPath.slice(0, index + 1)))) {
- BI.set(result, parentPath.slice(0, index + 1), {});
+ each(parentPath, index => {
+ if (isNull(get(result, parentPath.slice(0, index + 1)))) {
+ set(result, parentPath.slice(0, index + 1), {});
}
});
// 执行完一条路径,check一下
- var lengths = BI.size(BI.get(result, parentPath.slice(0, -1)));
+ const lengths = size(get(result, parentPath.slice(0, -1)));
if (lengths === value2ParentMap[value]?.children?.length) {
- BI.set(result, parentPath.slice(0, -1), {});
+ set(result, parentPath.slice(0, -1), {});
}
});
return result;
- },
+ }
- buildCompleteTree: function (selectedValues) {
- var self = this;
- var result = {};
+ buildCompleteTree(selectedValues) {
+ const result = {};
- if (selectedValues !== null && !BI.isEmpty(selectedValues)) {
+ if (selectedValues !== null && !isEmpty(selectedValues)) {
fill([], this.tree.getRoot(), selectedValues, result);
}
return result;
function fill(parentValues, node, selected, r) {
- if (selected === null || BI.isEmpty(selected)) {
- BI.each(node.getChildren(), function (i, child) {
- var newParents = BI.clone(parentValues);
+ if (selected === null || isEmpty(selected)) {
+ each(node.getChildren(), (i, child) => {
+ const newParents = clone(parentValues);
newParents.push(child.value);
r[child.value] = {};
fill(newParents, child, null, r[child.value]);
});
+
return;
}
- BI.each(selected, function (k) {
- var node = self._getTreeNode(parentValues, k);
- var newParents = BI.clone(parentValues);
+ each(selected, k => {
+ const node = this._getTreeNode(parentValues, k);
+ const newParents = clone(parentValues);
newParents.push(node.value);
r[k] = {};
fill(newParents, node, selected[k], r[k]);
});
}
- },
-});
+ }
+}
diff --git a/src/component/treevaluechooser/abstract.treevaluechooser.list.js b/src/component/treevaluechooser/abstract.treevaluechooser.list.js
index 0a44af0f1..9c84e13ba 100644
--- a/src/component/treevaluechooser/abstract.treevaluechooser.list.js
+++ b/src/component/treevaluechooser/abstract.treevaluechooser.list.js
@@ -1,36 +1,60 @@
-BI.AbstractListTreeValueChooser = BI.inherit(BI.AbstractTreeValueChooser, {
+import {
+ isEmpty,
+ values,
+ each,
+ isNull,
+ UUID,
+ has,
+ nextTick,
+ last,
+ concat,
+ filter,
+ Func,
+ clone,
+ any,
+ isEqual,
+ every,
+ flatten,
+ map,
+ difference
+} from "@/core";
+import { AbstractTreeValueChooser } from "./abstract.treevaluechooser";
- _reqDisplayTreeNode: function (op, callback) {
- var self = this;
- var result = {};
- var selectedValues = op.selectedValues;
+export class AbstractListTreeValueChooser extends AbstractTreeValueChooser {
+ _reqDisplayTreeNode(op, callback) {
+ const result = {};
+ const selectedValues = op.selectedValues;
- if (selectedValues == null || BI.isEmpty(selectedValues)) {
+ if (selectedValues == null || isEmpty(selectedValues)) {
callback({});
+
return;
}
doCheck([], this.tree.getRoot(), selectedValues);
callback({
- items: BI.values(result)
+ items: values(result),
});
function doCheck(parentValues, node, selected) {
- BI.each(selected, function (idx, path) {
- BI.each(path, function (id, value) {
- var nodeValue = value;
- var node = self._getTreeNode(path.slice(0, id), nodeValue);
+ each(selected, (idx, path) => {
+ each(path, (id, value) => {
+ const nodeValue = value;
+ const node = this._getTreeNode(path.slice(0, id), nodeValue);
// 找不到就是新增值
- if (BI.isNull(node)) {
- createOneJson({
- id: BI.UUID(),
- text: nodeValue,
- value: nodeValue,
- isLeaf: true
- }, BI.UUID());
+ if (isNull(node)) {
+ createOneJson(
+ {
+ id: UUID(),
+ text: nodeValue,
+ value: nodeValue,
+ isLeaf: true,
+ },
+ UUID()
+ );
} else {
- if(!BI.has(result, node.id)) {
+ if (!has(result, node.id)) {
createOneJson(node, node.parent && node.parent.id);
}
result[node.id].isLeaf !== true && (result[node.id].isLeaf = id === path.length - 1);
@@ -42,35 +66,34 @@ BI.AbstractListTreeValueChooser = BI.inherit(BI.AbstractTreeValueChooser, {
function createOneJson(node, pId) {
result[node.id] = {
id: node.id,
- pId: pId,
+ pId,
text: node.text,
value: node.value,
open: true,
- isLeaf: node.isLeaf
+ isLeaf: node.isLeaf,
};
}
- },
+ }
- _reqInitTreeNode: function (op, callback) {
- var self = this;
- var result = [];
- var keyword = op.keyword || "";
- var selectedValues = op.selectedValues;
- var lastSearchValue = op.lastSearchValue || ""; // 一次请求100个,但是搜索是拿全部的,lastSearchValue是上一次遍历到的节点索引
- var output = search();
- BI.nextTick(function () {
+ _reqInitTreeNode(op, callback) {
+ let result = [];
+ const keyword = op.keyword || "";
+ const selectedValues = op.selectedValues;
+ const lastSearchValue = op.lastSearchValue || ""; // 一次请求100个,但是搜索是拿全部的,lastSearchValue是上一次遍历到的节点索引
+ const output = search();
+ nextTick(() => {
callback({
- hasNext: output.length > self._const.perPage,
+ hasNext: output.length > this._const.perPage,
items: result,
- lastSearchValue: BI.last(output)
+ lastSearchValue: last(output),
});
});
- function search() {
- var children = self._getChildren([]);
- var start = children.length;
+ const search = () => {
+ const children = this._getChildren([]);
+ let start = children.length;
if (lastSearchValue !== "") {
- for (var j = 0, len = start; j < len; j++) {
+ for (let j = 0, len = start; j < len; j++) {
if (children[j].value === lastSearchValue) {
start = j + 1;
break;
@@ -79,46 +102,72 @@ BI.AbstractListTreeValueChooser = BI.inherit(BI.AbstractTreeValueChooser, {
} else {
start = 0;
}
- var output = [];
- for (var i = start, len = children.length; i < len; i++) {
- if (output.length < self._const.perPage) {
- var find = nodeSearch(1, [], children[i].value, result);
- } else if (output.length === self._const.perPage) {
- var find = nodeSearch(1, [], children[i].value, []);
+ const output = [];
+ let find;
+ for (let i = start, len = children.length; i < len; i++) {
+ if (output.length < this._const.perPage) {
+ find = nodeSearch(1, [], children[i].value, result);
+ } else if (output.length === this._const.perPage) {
+ find = nodeSearch(1, [], children[i].value, []);
}
if (find[0] === true) {
output.push(children[i].value);
}
- if (output.length > self._const.perPage) {
+ if (output.length > this._const.perPage) {
break;
}
}
// 深层嵌套的比较麻烦,这边先实现的是在根节点添加
if (op.times === 1) {
- var nodes = self._getAddedValueNode([], selectedValues);
- result = BI.concat(BI.filter(nodes, function (idx, node) {
- var find = BI.Func.getSearchResult([node.text || node.value], keyword);
- return find.find.length > 0 || find.match.length > 0;
- }), result);
+ const nodes = this._getAddedValueNode([], selectedValues);
+ result = concat(
+ filter(nodes, (idx, node) => {
+ const find = Func.getSearchResult([node.text || node.value], keyword);
+
+ return find.find.length > 0 || find.match.length > 0;
+ }),
+ result
+ );
}
+
return output;
- }
+ };
+
+ const createOneJson = (parentValues, value, isOpen, checked, flag, result) => {
+ const node = this._getTreeNode(parentValues, value);
+ result.push({
+ id: node.id,
+ pId: node.pId,
+ text: node.text,
+ value: node.value,
+ title: node.title,
+ isParent: node.getChildrenLength() > 0,
+ open: isOpen,
+ checked,
+ halfCheck: false,
+ flag,
+ disabled: node.disabled,
+ });
+ };
- function nodeSearch(deep, parentValues, current, result) {
- if (self._isMatch(parentValues, current, keyword)) {
- var checked = isSelected(parentValues, current);
+ const nodeSearch = (deep, parentValues, current, result) => {
+ let checked;
+ if (this._isMatch(parentValues, current, keyword)) {
+ checked = isSelected(parentValues, current);
createOneJson(parentValues, current, false, checked, true, result);
+
return [true, checked];
}
- var newParents = BI.clone(parentValues);
+ const newParents = clone(parentValues);
newParents.push(current);
- var children = self._getChildren(newParents);
+ const children = this._getChildren(newParents);
- var can = false, checked = false;
+ let can = false;
+ checked = false;
- BI.each(children, function (i, child) {
- var state = nodeSearch(deep + 1, newParents, child.value, result);
+ each(children, (i, child) => {
+ const state = nodeSearch(deep + 1, newParents, child.value, result);
if (state[1] === true) {
checked = true;
}
@@ -130,48 +179,36 @@ BI.AbstractListTreeValueChooser = BI.inherit(BI.AbstractTreeValueChooser, {
checked = isSelected(parentValues, current);
createOneJson(parentValues, current, true, checked, false, result);
}
+
return [can, checked];
- }
-
- function createOneJson(parentValues, value, isOpen, checked, flag, result) {
- var node = self._getTreeNode(parentValues, value);
- result.push({
- id: node.id,
- pId: node.pId,
- text: node.text,
- value: node.value,
- title: node.title,
- isParent: node.getChildrenLength() > 0,
- open: isOpen,
- checked: checked,
- halfCheck: false,
- flag: flag,
- disabled: node.disabled
- });
- }
+ };
+ // eslint-disable-next-line no-unused-vars
function isHalf(parentValues, value) {
- var find = findSelectedObj(parentValues);
+ const find = findSelectedObj(parentValues);
if (find == null) {
return null;
}
- return BI.any(find, function (v, ob) {
+
+ return any(find, (v, ob) => {
if (v === value) {
- if (ob != null && !BI.isEmpty(ob)) {
+ if (ob != null && !isEmpty(ob)) {
return true;
}
}
});
}
+ // eslint-disable-next-line no-unused-vars
function isAllSelected(parentValues, value) {
- var find = findSelectedObj(parentValues);
+ const find = findSelectedObj(parentValues);
if (find == null) {
return null;
}
- return BI.any(find, function (v, ob) {
+
+ return any(find, (v, ob) => {
if (v === value) {
- if (ob != null && BI.isEmpty(ob)) {
+ if (ob != null && isEmpty(ob)) {
return true;
}
}
@@ -179,37 +216,37 @@ BI.AbstractListTreeValueChooser = BI.inherit(BI.AbstractTreeValueChooser, {
}
function isSelected(parentValues, value) {
- return BI.any(selectedValues, function (idx, array) {
- return BI.isEqual(parentValues, array.slice(0, parentValues.length)) && BI.last(array) === value;
- });
+ return any(selectedValues, (idx, array) => isEqual(parentValues, array.slice(0, parentValues.length)) && last(array) === value);
}
function findSelectedObj(parentValues) {
- var find = selectedValues;
+ let find = selectedValues;
if (find == null) {
return null;
}
- BI.every(parentValues, function (i, v) {
+ every(parentValues, (i, v) => {
find = find[v];
if (find == null) {
return false;
}
+
return true;
});
+
return find;
}
- },
+ }
- _reqTreeNode: function (op, callback) {
- var self = this, o = this.options;
- var result = [];
- var times = op.times;
- var parentValues = op.parentValues || [];
- var selectedValues = op.selectedValues || [];
- var valueMap = dealWithSelectedValue(parentValues, selectedValues);
- var nodes = this._getChildren(parentValues);
- for (var i = (times - 1) * this._const.perPage; nodes[i] && i < times * this._const.perPage; i++) {
- var checked = BI.has(valueMap, nodes[i].value);
+ _reqTreeNode(op, callback) {
+ const o = this.options;
+ let result = [];
+ const times = op.times;
+ const parentValues = op.parentValues || [];
+ const selectedValues = op.selectedValues || [];
+ const valueMap = dealWithSelectedValue(parentValues, selectedValues);
+ const nodes = this._getChildren(parentValues);
+ for (let i = (times - 1) * this._const.perPage; nodes[i] && i < times * this._const.perPage; i++) {
+ const checked = has(valueMap, nodes[i].value);
result.push({
id: nodes[i].id,
pId: nodes[i].pId,
@@ -217,22 +254,22 @@ BI.AbstractListTreeValueChooser = BI.inherit(BI.AbstractTreeValueChooser, {
text: nodes[i].text,
times: 1,
isParent: nodes[i].getChildrenLength() > 0,
- checked: checked,
+ checked,
halfCheck: false,
open: o.open,
- disabled: nodes[i].disabled
+ disabled: nodes[i].disabled,
});
}
// 如果指定节点全部打开
if (o.open) {
- var allNodes = [];
+ let allNodes = [];
// 获取所有节点
- BI.each(nodes, function (idx, node) {
- allNodes = BI.concat(allNodes, self._getAllChildren(parentValues.concat([node.value])));
+ each(nodes, (idx, node) => {
+ allNodes = concat(allNodes, this._getAllChildren(parentValues.concat([node.value])));
});
- BI.each(allNodes, function (idx, node) {
- var valueMap = dealWithSelectedValue(node.parentValues, selectedValues);
- var checked = BI.has(valueMap, node.value);
+ each(allNodes, (idx, node) => {
+ const valueMap = dealWithSelectedValue(node.parentValues, selectedValues);
+ const checked = has(valueMap, node.value);
result.push({
id: node.id,
pId: node.pId,
@@ -240,51 +277,53 @@ BI.AbstractListTreeValueChooser = BI.inherit(BI.AbstractTreeValueChooser, {
text: node.text,
times: 1,
isParent: node.getChildrenLength() > 0,
- checked: checked,
+ checked,
halfCheck: false,
open: o.open,
- disabled: node.disabled
+ disabled: node.disabled,
});
});
}
// 深层嵌套的比较麻烦,这边先实现的是在根节点添加
if (parentValues.length === 0 && times === 1) {
- result = BI.concat(self._getAddedValueNode(parentValues, selectedValues), result);
+ result = concat(this._getAddedValueNode(parentValues, selectedValues), result);
}
- BI.nextTick(function () {
+ nextTick(() => {
callback({
items: result,
- hasNext: nodes.length > times * self._const.perPage
+ hasNext: nodes.length > times * this._const.perPage,
});
});
function dealWithSelectedValue(parentValues, selectedValues) {
- var valueMap = {};
- BI.each(selectedValues, function (idx, v) {
- if (BI.isEqual(parentValues, v.slice(0, parentValues.length))) {
- valueMap[BI.last(v)] = [2, 0];
+ const valueMap = {};
+ each(selectedValues, (idx, v) => {
+ if (isEqual(parentValues, v.slice(0, parentValues.length))) {
+ valueMap[last(v)] = [2, 0];
}
});
+
return valueMap;
}
- },
+ }
- _getAddedValueNode: function (parentValues, selectedValues) {
- var nodes = this._getChildren(parentValues);
- var values = BI.flatten(BI.filter(selectedValues, function (idx, array) {
- return array.length === 1;
- }));
- return BI.map(BI.difference(values, BI.map(nodes, "value")), function (idx, v) {
+ _getAddedValueNode(parentValues, selectedValues) {
+ const nodes = this._getChildren(parentValues);
+ const values = flatten(
+ filter(selectedValues, (idx, array) => array.length === 1)
+ );
+
+ return map(difference(values, map(nodes, "value")), (idx, v) => {
return {
- id: BI.UUID(),
- pId: nodes.length > 0 ? nodes[0].pId : BI.UUID(),
+ id: UUID(),
+ pId: nodes.length > 0 ? nodes[0].pId : UUID(),
value: v,
text: v,
times: 1,
isParent: false,
checked: true,
- halfCheck: false
+ halfCheck: false,
};
});
}
-});
\ No newline at end of file
+}
diff --git a/src/component/treevaluechooser/combo.listtreevaluechooser.js b/src/component/treevaluechooser/combo.listtreevaluechooser.js
index 0366a4bbc..847280947 100644
--- a/src/component/treevaluechooser/combo.listtreevaluechooser.js
+++ b/src/component/treevaluechooser/combo.listtreevaluechooser.js
@@ -1,31 +1,39 @@
-/**
- * 简单的复选下拉树控件, 适用于数据量少的情况, 可以自增值
- *
- * Created by GUY on 2015/10/29.
- * @class BI.ListTreeValueChooserInsertCombo
- * @extends BI.Widget
- */
-BI.ListTreeValueChooserInsertCombo = BI.inherit(BI.AbstractListTreeValueChooser, {
+import { shortcut, extend, emptyFn, isNotNull, createWidget, bind } from "@/core";
+import { AbstractListTreeValueChooser } from "./abstract.treevaluechooser.list";
+import { MultiTreeListCombo, MultiTreeCombo } from "@/widget";
+import { TreeValueChooserInsertCombo } from "./combo.treevaluechooser.insert";
- _defaultConfig: function () {
- return BI.extend(BI.ListTreeValueChooserInsertCombo.superclass._defaultConfig.apply(this, arguments), {
+@shortcut()
+export class ListTreeValueChooserInsertCombo extends AbstractListTreeValueChooser {
+ static xtype = "bi.list_tree_value_chooser_insert_combo";
+
+ static EVENT_FOCUS = "EVENT_FOCUS";
+ static EVENT_BLUR = "EVENT_BLUR";
+ static EVENT_STOP = "EVENT_STOP";
+ static EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM";
+ static EVENT_SEARCHING = "EVENT_SEARCHING";
+ static EVENT_CONFIRM = "EVENT_CONFIRM";
+ static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+
+ _defaultConfig() {
+ return extend(super._defaultConfig(...arguments), {
baseCls: "bi-list-tree-value-chooser-insert-combo",
width: 200,
height: 24,
items: null,
- itemsCreator: BI.emptyFn,
+ itemsCreator: emptyFn,
isNeedAdjustWidth: true,
});
- },
+ }
- _init: function () {
- BI.ListTreeValueChooserInsertCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- if (BI.isNotNull(o.items)) {
+ _init() {
+ super._init(...arguments);
+ const o = this.options;
+ if (isNotNull(o.items)) {
this._initData(o.items);
}
- this.combo = BI.createWidget({
- type: "bi.multi_tree_list_combo",
+ this.combo = createWidget({
+ type: MultiTreeListCombo.xtype,
simple: o.simple,
isNeedAdjustWidth: o.isNeedAdjustWidth,
element: this,
@@ -35,94 +43,93 @@ BI.ListTreeValueChooserInsertCombo = BI.inherit(BI.AbstractListTreeValueChooser,
watermark: o.watermark,
allowInsertValue: o.allowInsertValue,
allowEdit: o.allowEdit,
- itemsCreator: BI.bind(this._itemsCreator, this),
- valueFormatter: BI.bind(this._valueFormatter, this),
+ itemsCreator: bind(this._itemsCreator, this),
+ valueFormatter: bind(this._valueFormatter, this),
width: o.width,
height: o.height,
- listeners: [{
- eventName: BI.MultiTreeListCombo.EVENT_FOCUS,
- action: function () {
- self.fireEvent(BI.ListTreeValueChooserInsertCombo.EVENT_FOCUS);
- }
- }, {
- eventName: BI.MultiTreeListCombo.EVENT_BLUR,
- action: function () {
- self.fireEvent(BI.ListTreeValueChooserInsertCombo.EVENT_BLUR);
- }
- }, {
- eventName: BI.MultiTreeListCombo.EVENT_STOP,
- action: function () {
- self.fireEvent(BI.ListTreeValueChooserInsertCombo.EVENT_STOP);
+ listeners: [
+ {
+ eventName: MultiTreeListCombo.EVENT_FOCUS,
+ action: () => {
+ this.fireEvent(ListTreeValueChooserInsertCombo.EVENT_FOCUS);
+ },
+ },
+ {
+ eventName: MultiTreeListCombo.EVENT_BLUR,
+ action: () => {
+ this.fireEvent(ListTreeValueChooserInsertCombo.EVENT_BLUR);
+ },
+ },
+ {
+ eventName: MultiTreeListCombo.EVENT_STOP,
+ action: () => {
+ this.fireEvent(ListTreeValueChooserInsertCombo.EVENT_STOP);
+ },
+ },
+ {
+ eventName: MultiTreeListCombo.EVENT_CLICK_ITEM,
+ action: v => {
+ this.fireEvent(ListTreeValueChooserInsertCombo.EVENT_CLICK_ITEM, v);
+ },
+ },
+ {
+ eventName: MultiTreeListCombo.EVENT_SEARCHING,
+ action: () => {
+ this.fireEvent(ListTreeValueChooserInsertCombo.EVENT_SEARCHING);
+ },
+ },
+ {
+ eventName: MultiTreeListCombo.EVENT_CONFIRM,
+ action: () => {
+ this.fireEvent(ListTreeValueChooserInsertCombo.EVENT_CONFIRM);
+ },
+ },
+ {
+ eventName: MultiTreeCombo.EVENT_BEFORE_POPUPVIEW,
+ action: () => {
+ this.fireEvent(TreeValueChooserInsertCombo.EVENT_BEFORE_POPUPVIEW);
+ },
}
- }, {
- eventName: BI.MultiTreeListCombo.EVENT_CLICK_ITEM,
- action: function (v) {
- self.fireEvent(BI.ListTreeValueChooserInsertCombo.EVENT_CLICK_ITEM, v);
- }
- }, {
- eventName: BI.MultiTreeListCombo.EVENT_SEARCHING,
- action: function () {
- self.fireEvent(BI.ListTreeValueChooserInsertCombo.EVENT_SEARCHING);
- }
- }, {
- eventName: BI.MultiTreeListCombo.EVENT_CONFIRM,
- action: function () {
- self.fireEvent(BI.ListTreeValueChooserInsertCombo.EVENT_CONFIRM);
- }
- }, {
- eventName: BI.MultiTreeCombo.EVENT_BEFORE_POPUPVIEW,
- action: function () {
- self.fireEvent(BI.TreeValueChooserInsertCombo.EVENT_BEFORE_POPUPVIEW);
- }
- }]
+ ],
});
- },
+ }
- showView: function () {
+ showView() {
this.combo.showView();
- },
+ }
- hideView: function () {
+ hideView() {
this.combo.hideView();
- },
+ }
- getSearcher: function () {
+ getSearcher() {
return this.combo.getSearcher();
- },
+ }
- setValue: function (v) {
+ setValue(v) {
this.combo.setValue(v);
- },
+ }
- getValue: function () {
+ getValue() {
return this.combo.getValue();
- },
+ }
- populate: function (items) {
- if (BI.isNotNull(items)) {
+ populate(items) {
+ if (isNotNull(items)) {
this._initData(items);
}
this.combo.populate();
- },
+ }
- focus: function () {
+ focus() {
this.combo.focus();
- },
+ }
- blur: function () {
+ blur() {
this.combo.blur();
- },
+ }
- setWaterMark: function (v) {
+ setWaterMark(v) {
this.combo.setWaterMark(v);
}
-});
-
-BI.ListTreeValueChooserInsertCombo.EVENT_FOCUS = "EVENT_FOCUS";
-BI.ListTreeValueChooserInsertCombo.EVENT_BLUR = "EVENT_BLUR";
-BI.ListTreeValueChooserInsertCombo.EVENT_STOP = "EVENT_STOP";
-BI.ListTreeValueChooserInsertCombo.EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM";
-BI.ListTreeValueChooserInsertCombo.EVENT_SEARCHING = "EVENT_SEARCHING";
-BI.ListTreeValueChooserInsertCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
-BI.ListTreeValueChooserInsertCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
-BI.shortcut("bi.list_tree_value_chooser_insert_combo", BI.ListTreeValueChooserInsertCombo);
+}
diff --git a/src/component/treevaluechooser/combo.treevaluechooser.insert.js b/src/component/treevaluechooser/combo.treevaluechooser.insert.js
index f9c6ebf4b..1eba57884 100644
--- a/src/component/treevaluechooser/combo.treevaluechooser.insert.js
+++ b/src/component/treevaluechooser/combo.treevaluechooser.insert.js
@@ -1,31 +1,39 @@
-/**
- * 简单的复选下拉树控件, 适用于数据量少的情况, 可以自增值
- *
- * Created by GUY on 2015/10/29.
- * @class BI.TreeValueChooserInsertCombo
- * @extends BI.Widget
- */
-BI.TreeValueChooserInsertCombo = BI.inherit(BI.AbstractTreeValueChooser, {
+import { shortcut, extend, emptyFn, isNotNull, createWidget, bind } from "@/core";
+import { AbstractTreeValueChooser } from "./abstract.treevaluechooser";
+import { MultiTreeInsertCombo, MultiTreeCombo } from "@/widget";
+import { TreeValueChooserCombo } from "./combo.treevaluechooser";
- _defaultConfig: function () {
- return BI.extend(BI.TreeValueChooserInsertCombo.superclass._defaultConfig.apply(this, arguments), {
+@shortcut()
+export class TreeValueChooserInsertCombo extends AbstractTreeValueChooser {
+ static xtype = "bi.tree_value_chooser_insert_combo";
+
+ static EVENT_FOCUS = "EVENT_FOCUS";
+ static EVENT_BLUR = "EVENT_BLUR";
+ static EVENT_STOP = "EVENT_STOP";
+ static EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM";
+ static EVENT_SEARCHING = "EVENT_SEARCHING";
+ static EVENT_CONFIRM = "EVENT_CONFIRM";
+ static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+
+ _defaultConfig() {
+ return extend(super._defaultConfig(...arguments), {
baseCls: "bi-tree-value-chooser-insert-combo",
width: 200,
height: 24,
items: null,
- itemsCreator: BI.emptyFn,
- isNeedAdjustWidth: true
+ itemsCreator: emptyFn,
+ isNeedAdjustWidth: true,
});
- },
+ }
- _init: function () {
- BI.TreeValueChooserInsertCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- if (BI.isNotNull(o.items)) {
+ _init() {
+ super._init(...arguments);
+ const o = this.options;
+ if (isNotNull(o.items)) {
this._initData(o.items);
}
- this.combo = BI.createWidget({
- type: "bi.multi_tree_insert_combo",
+ this.combo = createWidget({
+ type: MultiTreeInsertCombo.xtype,
simple: o.simple,
isNeedAdjustWidth: o.isNeedAdjustWidth,
allowEdit: o.allowEdit,
@@ -34,94 +42,93 @@ BI.TreeValueChooserInsertCombo = BI.inherit(BI.AbstractTreeValueChooser, {
value: o.value,
watermark: o.watermark,
element: this,
- itemsCreator: BI.bind(this._itemsCreator, this),
- valueFormatter: BI.bind(this._valueFormatter, this),
+ itemsCreator: bind(this._itemsCreator, this),
+ valueFormatter: bind(this._valueFormatter, this),
width: o.width,
height: o.height,
- listeners: [{
- eventName: BI.MultiTreeInsertCombo.EVENT_FOCUS,
- action: function () {
- self.fireEvent(BI.TreeValueChooserCombo.EVENT_FOCUS);
- }
- }, {
- eventName: BI.MultiTreeInsertCombo.EVENT_BLUR,
- action: function () {
- self.fireEvent(BI.TreeValueChooserCombo.EVENT_BLUR);
- }
- }, {
- eventName: BI.MultiTreeInsertCombo.EVENT_STOP,
- action: function () {
- self.fireEvent(BI.TreeValueChooserInsertCombo.EVENT_STOP);
+ listeners: [
+ {
+ eventName: MultiTreeInsertCombo.EVENT_FOCUS,
+ action: () => {
+ this.fireEvent(TreeValueChooserCombo.EVENT_FOCUS);
+ },
+ },
+ {
+ eventName: MultiTreeInsertCombo.EVENT_BLUR,
+ action: () => {
+ this.fireEvent(TreeValueChooserCombo.EVENT_BLUR);
+ },
+ },
+ {
+ eventName: MultiTreeInsertCombo.EVENT_STOP,
+ action: () => {
+ this.fireEvent(TreeValueChooserInsertCombo.EVENT_STOP);
+ },
+ },
+ {
+ eventName: MultiTreeInsertCombo.EVENT_CLICK_ITEM,
+ action: v => {
+ this.fireEvent(TreeValueChooserInsertCombo.EVENT_CLICK_ITEM, v);
+ },
+ },
+ {
+ eventName: MultiTreeInsertCombo.EVENT_SEARCHING,
+ action: () => {
+ this.fireEvent(TreeValueChooserInsertCombo.EVENT_SEARCHING);
+ },
+ },
+ {
+ eventName: MultiTreeInsertCombo.EVENT_CONFIRM,
+ action: () => {
+ this.fireEvent(TreeValueChooserInsertCombo.EVENT_CONFIRM);
+ },
+ },
+ {
+ eventName: MultiTreeCombo.EVENT_BEFORE_POPUPVIEW,
+ action: () => {
+ this.fireEvent(TreeValueChooserInsertCombo.EVENT_BEFORE_POPUPVIEW);
+ },
}
- }, {
- eventName: BI.MultiTreeInsertCombo.EVENT_CLICK_ITEM,
- action: function (v) {
- self.fireEvent(BI.TreeValueChooserInsertCombo.EVENT_CLICK_ITEM, v);
- }
- }, {
- eventName: BI.MultiTreeInsertCombo.EVENT_SEARCHING,
- action: function () {
- self.fireEvent(BI.TreeValueChooserInsertCombo.EVENT_SEARCHING);
- }
- }, {
- eventName: BI.MultiTreeInsertCombo.EVENT_CONFIRM,
- action: function () {
- self.fireEvent(BI.TreeValueChooserInsertCombo.EVENT_CONFIRM);
- }
- }, {
- eventName: BI.MultiTreeCombo.EVENT_BEFORE_POPUPVIEW,
- action: function () {
- self.fireEvent(BI.TreeValueChooserInsertCombo.EVENT_BEFORE_POPUPVIEW);
- }
- }]
+ ],
});
- },
+ }
- showView: function () {
+ showView() {
this.combo.showView();
- },
+ }
- hideView: function () {
+ hideView() {
this.combo.hideView();
- },
+ }
- getSearcher: function () {
+ getSearcher() {
return this.combo.getSearcher();
- },
+ }
- setValue: function (v) {
+ setValue(v) {
this.combo.setValue(v);
- },
+ }
- getValue: function () {
+ getValue() {
return this.combo.getValue();
- },
+ }
- populate: function (items) {
- if (BI.isNotNull(items)) {
+ populate(items) {
+ if (isNotNull(items)) {
this._initData(items);
}
this.combo.populate();
- },
+ }
- focus: function () {
+ focus() {
this.combo.focus();
- },
+ }
- blur: function () {
+ blur() {
this.combo.blur();
- },
+ }
- setWaterMark: function (v) {
+ setWaterMark(v) {
this.combo.setWaterMark(v);
}
-});
-
-BI.TreeValueChooserInsertCombo.EVENT_FOCUS = "EVENT_FOCUS";
-BI.TreeValueChooserInsertCombo.EVENT_BLUR = "EVENT_BLUR";
-BI.TreeValueChooserInsertCombo.EVENT_STOP = "EVENT_STOP";
-BI.TreeValueChooserInsertCombo.EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM";
-BI.TreeValueChooserInsertCombo.EVENT_SEARCHING = "EVENT_SEARCHING";
-BI.TreeValueChooserInsertCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
-BI.TreeValueChooserInsertCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
-BI.shortcut("bi.tree_value_chooser_insert_combo", BI.TreeValueChooserInsertCombo);
+}
diff --git a/src/component/treevaluechooser/combo.treevaluechooser.js b/src/component/treevaluechooser/combo.treevaluechooser.js
index 2c0709d67..51ee25614 100644
--- a/src/component/treevaluechooser/combo.treevaluechooser.js
+++ b/src/component/treevaluechooser/combo.treevaluechooser.js
@@ -1,31 +1,40 @@
-/**
- * 简单的复选下拉树控件, 适用于数据量少的情况
- *
- * Created by GUY on 2015/10/29.
- * @class BI.TreeValueChooserCombo
- * @extends BI.Widget
- */
-BI.TreeValueChooserCombo = BI.inherit(BI.AbstractTreeValueChooser, {
+import { shortcut, extend, emptyFn, isNotNull, createWidget, bind } from "@/core";
+import { AbstractTreeValueChooser } from "./abstract.treevaluechooser";
+import { MultiTreeCombo } from "@/widget";
- _defaultConfig: function () {
- return BI.extend(BI.TreeValueChooserCombo.superclass._defaultConfig.apply(this, arguments), {
+@shortcut()
+export class TreeValueChooserCombo extends AbstractTreeValueChooser {
+ // TODO:该组件有问题,未报错,但不显示pane,该问题看起来是其他组件es6化导致
+ static xtype = "bi.tree_value_chooser_combo";
+
+ static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+ static EVENT_CONFIRM = "EVENT_CONFIRM";
+ static EVENT_FOCUS = "EVENT_FOCUS";
+ static EVENT_BLUR = "EVENT_BLUR";
+ static EVENT_STOP = "EVENT_STOP";
+ static EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM";
+ static EVENT_SEARCHING = "EVENT_SEARCHING";
+ static EVENT_AFTER_HIDEVIEW = "EVENT_AFTER_HIDEVIEW";
+
+ _defaultConfig() {
+ return extend(super._defaultConfig(...arguments), {
baseCls: "bi-tree-value-chooser-combo",
width: 200,
height: 24,
items: null,
- itemsCreator: BI.emptyFn,
- isNeedAdjustWidth: true
+ itemsCreator: emptyFn,
+ isNeedAdjustWidth: true,
});
- },
+ }
- _init: function () {
- BI.TreeValueChooserCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- if (BI.isNotNull(o.items)) {
+ _init() {
+ super._init(...arguments);
+ const o = this.options;
+ if (isNotNull(o.items)) {
this._initData(o.items);
}
- this.combo = BI.createWidget({
- type: "bi.multi_tree_combo",
+ this.combo = createWidget({
+ type: MultiTreeCombo.xtype,
simple: o.simple,
text: o.text,
defaultText: o.defaultText,
@@ -33,105 +42,104 @@ BI.TreeValueChooserCombo = BI.inherit(BI.AbstractTreeValueChooser, {
value: this.assertSelectedValue(o.value, o.items),
watermark: o.watermark,
element: this,
- itemsCreator: BI.bind(this._itemsCreator, this),
- valueFormatter: BI.bind(this._valueFormatter, this),
+ itemsCreator: bind(this._itemsCreator, this),
+ valueFormatter: bind(this._valueFormatter, this),
width: o.width,
height: o.height,
isNeedAdjustWidth: o.isNeedAdjustWidth,
- listeners: [{
- eventName: BI.MultiTreeCombo.EVENT_FOCUS,
- action: function () {
- self.fireEvent(BI.TreeValueChooserCombo.EVENT_FOCUS);
- }
- }, {
- eventName: BI.MultiTreeCombo.EVENT_BLUR,
- action: function () {
- self.fireEvent(BI.TreeValueChooserCombo.EVENT_BLUR);
- }
- }, {
- eventName: BI.MultiTreeCombo.EVENT_STOP,
- action: function () {
- self.fireEvent(BI.TreeValueChooserCombo.EVENT_STOP);
- }
- }, {
- eventName: BI.MultiTreeCombo.EVENT_CLICK_ITEM,
- action: function (v) {
- self.fireEvent(BI.TreeValueChooserCombo.EVENT_CLICK_ITEM, v);
+ listeners: [
+ {
+ eventName: MultiTreeCombo.EVENT_FOCUS,
+ action: () => {
+ this.fireEvent(TreeValueChooserCombo.EVENT_FOCUS);
+ },
+ },
+ {
+ eventName: MultiTreeCombo.EVENT_BLUR,
+ action: () => {
+ this.fireEvent(TreeValueChooserCombo.EVENT_BLUR);
+ },
+ },
+ {
+ eventName: MultiTreeCombo.EVENT_STOP,
+ action: () => {
+ this.fireEvent(TreeValueChooserCombo.EVENT_STOP);
+ },
+ },
+ {
+ eventName: MultiTreeCombo.EVENT_CLICK_ITEM,
+ action: v => {
+ this.fireEvent(TreeValueChooserCombo.EVENT_CLICK_ITEM, v);
+ },
+ },
+ {
+ eventName: MultiTreeCombo.EVENT_SEARCHING,
+ action: () => {
+ this.fireEvent(TreeValueChooserCombo.EVENT_SEARCHING);
+ },
+ },
+ {
+ eventName: MultiTreeCombo.EVENT_CONFIRM,
+ action: () => {
+ this.fireEvent(TreeValueChooserCombo.EVENT_CONFIRM);
+ },
+ },
+ {
+ eventName: MultiTreeCombo.EVENT_BEFORE_POPUPVIEW,
+ action: () => {
+ this.fireEvent(TreeValueChooserCombo.EVENT_BEFORE_POPUPVIEW);
+ },
+ },
+ {
+ eventName: MultiTreeCombo.EVENT_AFTER_HIDEVIEW,
+ action: () => {
+ this.fireEvent(TreeValueChooserCombo.EVENT_AFTER_HIDEVIEW);
+ },
}
- }, {
- eventName: BI.MultiTreeCombo.EVENT_SEARCHING,
- action: function () {
- self.fireEvent(BI.TreeValueChooserCombo.EVENT_SEARCHING);
- }
- }, {
- eventName: BI.MultiTreeCombo.EVENT_CONFIRM,
- action: function () {
- self.fireEvent(BI.TreeValueChooserCombo.EVENT_CONFIRM);
- }
- }, {
- eventName: BI.MultiTreeCombo.EVENT_BEFORE_POPUPVIEW,
- action: function () {
- self.fireEvent(BI.TreeValueChooserCombo.EVENT_BEFORE_POPUPVIEW);
- }
- }, {
- eventName: BI.MultiTreeCombo.EVENT_AFTER_HIDEVIEW,
- action: function () {
- self.fireEvent(BI.TreeValueChooserCombo.EVENT_AFTER_HIDEVIEW);
- }
- }]
+ ],
});
- },
+ }
- showView: function () {
+ showView() {
this.combo.showView();
- },
+ }
- hideView: function () {
+ hideView() {
this.combo.hideView();
- },
+ }
- getSearcher: function () {
+ getSearcher() {
return this.combo.getSearcher();
- },
+ }
- setValue: function (v) {
+ setValue(v) {
this.combo.setValue(v);
- },
+ }
- getValue: function () {
+ getValue() {
return this.combo.getValue();
- },
+ }
- getAllValue: function () {
+ getAllValue() {
return this.buildCompleteTree(this.combo.getValue());
- },
+ }
- populate: function (items) {
- if (BI.isNotNull(items)) {
+ populate(items) {
+ if (isNotNull(items)) {
this._initData(items);
}
this.combo.populate();
- },
+ }
- focus: function () {
+ focus() {
this.combo.focus();
- },
+ }
- blur: function () {
+ blur() {
this.combo.blur();
- },
+ }
- setWaterMark: function (v) {
+ setWaterMark(v) {
this.combo.setWaterMark(v);
}
-});
-
-BI.TreeValueChooserCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
-BI.TreeValueChooserCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
-BI.TreeValueChooserCombo.EVENT_FOCUS = "EVENT_FOCUS";
-BI.TreeValueChooserCombo.EVENT_BLUR = "EVENT_BLUR";
-BI.TreeValueChooserCombo.EVENT_STOP = "EVENT_STOP";
-BI.TreeValueChooserCombo.EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM";
-BI.TreeValueChooserCombo.EVENT_SEARCHING = "EVENT_SEARCHING";
-BI.TreeValueChooserCombo.EVENT_AFTER_HIDEVIEW = "EVENT_AFTER_HIDEVIEW";
-BI.shortcut("bi.tree_value_chooser_combo", BI.TreeValueChooserCombo);
+}
diff --git a/src/component/treevaluechooser/index.js b/src/component/treevaluechooser/index.js
new file mode 100644
index 000000000..6b439bb08
--- /dev/null
+++ b/src/component/treevaluechooser/index.js
@@ -0,0 +1,6 @@
+export { AbstractTreeValueChooser } from "./abstract.treevaluechooser";
+export { AbstractListTreeValueChooser } from "./abstract.treevaluechooser.list";
+export { ListTreeValueChooserInsertCombo } from "./combo.listtreevaluechooser";
+export { TreeValueChooserInsertCombo } from "./combo.treevaluechooser.insert";
+export { TreeValueChooserCombo } from "./combo.treevaluechooser";
+export { TreeValueChooserPane } from "./pane.treevaluechooser";
diff --git a/src/component/treevaluechooser/pane.treevaluechooser.js b/src/component/treevaluechooser/pane.treevaluechooser.js
index 8171c04d8..aad0bf08d 100644
--- a/src/component/treevaluechooser/pane.treevaluechooser.js
+++ b/src/component/treevaluechooser/pane.treevaluechooser.js
@@ -1,66 +1,66 @@
-/**
- * 简单的树面板, 适用于数据量少的情况
- *
- * Created by GUY on 2015/10/29.
- * @class BI.TreeValueChooserPane
- * @extends BI.AbstractTreeValueChooser
- */
-BI.TreeValueChooserPane = BI.inherit(BI.AbstractTreeValueChooser, {
+import { shortcut, extend, emptyFn, createWidget, bind, isNotNull } from "@/core";
+import { AbstractTreeValueChooser } from "./abstract.treevaluechooser";
+import { MultiSelectTree } from "@/widget/multiselecttree/multiselecttree";
+import { MultiSelectTreePopup } from "@/widget/multiselecttree/multiselecttree.popup";
- _defaultConfig: function () {
- return BI.extend(BI.TreeValueChooserPane.superclass._defaultConfig.apply(this, arguments), {
+@shortcut()
+export class TreeValueChooserPane extends AbstractTreeValueChooser {
+ static xtype = "bi.tree_value_chooser_pane";
+
+ static EVENT_CHANGE = "EVENT_CHANGE";
+
+ _defaultConfig() {
+ return extend(super._defaultConfig(...arguments), {
baseCls: "bi-tree-value-chooser-pane",
items: null,
- itemsCreator: BI.emptyFn,
- showLine: true
+ itemsCreator: emptyFn,
+ showLine: true,
});
- },
+ }
- _init: function () {
- BI.TreeValueChooserPane.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.pane = BI.createWidget({
- type: o.hideSearch ? "bi.multi_select_tree_popup" : "bi.multi_select_tree",
+ _init() {
+ super._init(...arguments);
+ const o = this.options;
+ this.pane = createWidget({
+ type: o.hideSearch ? MultiSelectTreePopup.xtype : MultiSelectTree.xtype,
element: this,
showLine: o.showLine,
- itemsCreator: BI.bind(this._itemsCreator, this)
+ itemsCreator: bind(this._itemsCreator, this),
});
- this.pane.on(BI.MultiSelectTree.EVENT_CHANGE, function () {
- self.fireEvent(BI.TreeValueChooserPane.EVENT_CHANGE);
+ this.pane.on(MultiSelectTree.EVENT_CHANGE, () => {
+ this.fireEvent(TreeValueChooserPane.EVENT_CHANGE);
});
- if (BI.isNotNull(o.value)) {
- var selectedValues = this.assertSelectedValue(o.value, o.items);
+ if (isNotNull(o.value)) {
+ const selectedValues = this.assertSelectedValue(o.value, o.items);
this.pane.setSelectedValue(selectedValues);
}
- if (BI.isNotNull(o.items)) {
+ if (isNotNull(o.items)) {
this._initData(o.items);
this.pane.populate();
}
- },
+ }
- setSelectedValue: function (v) {
+ setSelectedValue(v) {
this.pane.setSelectedValue(v);
- },
+ }
- setValue: function (v) {
+ setValue(v) {
this.pane.setValue(v);
- },
+ }
- getValue: function () {
+ getValue() {
return this.pane.getValue();
- },
+ }
- getAllValue: function() {
+ getAllValue() {
return this.buildCompleteTree(this.pane.getValue());
- },
+ }
- populate: function (items) {
- if (BI.isNotNull(items)) {
+ populate(items) {
+ if (isNotNull(items)) {
this._initData(items);
}
this.pane.populate();
}
-});
-BI.TreeValueChooserPane.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.tree_value_chooser_pane", BI.TreeValueChooserPane);
+}
diff --git a/src/component/valuechooser/abstract.valuechooser.js b/src/component/valuechooser/abstract.valuechooser.js
index a97434a84..8cf66acc0 100644
--- a/src/component/valuechooser/abstract.valuechooser.js
+++ b/src/component/valuechooser/abstract.valuechooser.js
@@ -1,110 +1,122 @@
-/**
- * 简单的复选下拉框控件, 适用于数据量少的情况
- * 封装了字段处理逻辑
- *
- * Created by GUY on 2015/10/29.
- * @class BI.AbstractValueChooser
- * @extends BI.Widget
- */
-BI.AbstractValueChooser = BI.inherit(BI.Widget, {
+import {
+ Widget,
+ extend,
+ emptyFn,
+ isNotNull,
+ some,
+ isNotEmptyArray,
+ each,
+ Func,
+ uniq,
+ makeObject,
+ filter,
+ Selection,
+ difference,
+ map
+} from "@/core";
+import { MultiSelectCombo } from "@/widget";
- _const: {
- perPage: 100
- },
+export class AbstractValueChooser extends Widget {
+ _const = { perPage: 100 };
- _defaultConfig: function () {
- return BI.extend(BI.AbstractValueChooser.superclass._defaultConfig.apply(this, arguments), {
+ _defaultConfig() {
+ return extend(super._defaultConfig(...arguments), {
items: null,
- itemsCreator: BI.emptyFn,
- cache: true
+ itemsCreator: emptyFn,
+ cache: true,
});
- },
+ }
- _valueFormatter: function (v) {
- var text = v;
+ _valueFormatter(v) {
+ let text = v;
if (this.options.valueFormatter) {
return this.options.valueFormatter(v);
}
- if (BI.isNotNull(this.items)) {
- BI.some(this.items, function (i, item) {
+ if (isNotNull(this.items)) {
+ some(this.items, (i, item) => {
// 把value都换成字符串
- if (item.value === v || item.value + "" === v) {
+ if (item.value === v || `${item.value}` === v) {
text = item.text;
+
return true;
}
});
}
+
return text;
- },
+ }
- _getItemsByTimes: function (items, times) {
- var res = [];
- for (var i = (times - 1) * this._const.perPage; items[i] && i < times * this._const.perPage; i++) {
+ _getItemsByTimes(items, times) {
+ const res = [];
+ for (let i = (times - 1) * this._const.perPage; items[i] && i < times * this._const.perPage; i++) {
res.push(items[i]);
}
+
return res;
- },
+ }
- _hasNextByTimes: function (items, times) {
+ _hasNextByTimes(items, times) {
return times * this._const.perPage < items.length;
- },
+ }
- _itemsCreator: function (options, callback) {
- var self = this, o = this.options;
- if (!o.cache || !this.items) {
- o.itemsCreator({}, function (items) {
- self.items = items;
- call(items);
- });
- } else {
- call(this.items);
- }
- function call (items) {
- var keywords = (options.keywords || []).slice();
- var resultItems = items;
- if(BI.isNotEmptyArray(keywords)) {
+ _itemsCreator(options, callback) {
+ const call = items => {
+ const keywords = (options.keywords || []).slice();
+ let resultItems = items;
+ if (isNotEmptyArray(keywords)) {
resultItems = [];
- BI.each(keywords, function (i, kw) {
- var search = BI.Func.getSearchResult(items, kw);
+ each(keywords, (i, kw) => {
+ const search = Func.getSearchResult(items, kw);
resultItems = resultItems.concat(search.match).concat(search.find);
});
- resultItems = BI.uniq(resultItems);
+ resultItems = uniq(resultItems);
}
- if (options.selectedValues) {// 过滤
- var filter = BI.makeObject(options.selectedValues, true);
- resultItems = BI.filter(resultItems, function (i, ob) {
- return !filter[ob.value];
- });
+ if (options.selectedValues) {
+ // 过滤
+ const filterFunc = makeObject(options.selectedValues, true);
+ resultItems = filter(resultItems, (i, ob) => !filterFunc[ob.value]);
}
- if (options.type === BI.MultiSelectCombo.REQ_GET_ALL_DATA) {
+ if (options.type === MultiSelectCombo.REQ_GET_ALL_DATA) {
callback({
- items: resultItems
+ items: resultItems,
});
+
return;
}
- if (options.type === BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) {
- callback({count: resultItems.length});
+ if (options.type === MultiSelectCombo.REQ_GET_DATA_LENGTH) {
+ callback({ count: resultItems.length });
+
return;
}
callback({
- items: self._getItemsByTimes(resultItems, options.times),
- hasNext: self._hasNextByTimes(resultItems, options.times)
+ items: this._getItemsByTimes(resultItems, options.times),
+ hasNext: this._hasNextByTimes(resultItems, options.times),
+ });
+ };
+ const o = this.options;
+ if (!o.cache || !this.items) {
+ o.itemsCreator({}, items => {
+ this.items = items;
+ call(items);
});
+ } else {
+ call(this.items);
}
- },
+ }
- _assertValue: function (v) {
+ _assertValue(v) {
v = v || {};
- var value = v;
- if (v.type === BI.Selection.Multi && BI.isNotNull(this.items)) {
- var isAllSelect = BI.difference(BI.map(this.items, "value"), v.value).length === 0;
+ let value = v;
+ if (v.type === Selection.Multi && isNotNull(this.items)) {
+ const isAllSelect = difference(map(this.items, "value"), v.value).length === 0;
if (isAllSelect) {
value = {
- type: BI.Selection.All,
+ type: Selection.All,
value: [],
};
}
}
+
return value;
- },
-});
\ No newline at end of file
+ }
+}
diff --git a/src/component/valuechooser/combo.valuechooser.insert.js b/src/component/valuechooser/combo.valuechooser.insert.js
index a2cdce0d9..096aa5ac1 100644
--- a/src/component/valuechooser/combo.valuechooser.insert.js
+++ b/src/component/valuechooser/combo.valuechooser.insert.js
@@ -1,105 +1,114 @@
-/**
- * 简单的复选下拉框控件, 适用于数据量少的情况
- * 封装了字段处理逻辑
- */
-BI.ValueChooserInsertCombo = BI.inherit(BI.AbstractValueChooser, {
+import { shortcut, extend, emptyFn, isNotNull, createWidget, bind, Selection, difference, map } from "@/core";
+import { AbstractValueChooser } from "./abstract.valuechooser";
+import { MultiSelectCombo, MultiSelectInsertCombo } from "@/widget";
- _defaultConfig: function () {
- return BI.extend(BI.ValueChooserInsertCombo.superclass._defaultConfig.apply(this, arguments), {
+@shortcut()
+export class ValueChooserInsertCombo extends AbstractValueChooser {
+ static xtype = "bi.value_chooser_insert_combo";
+
+ static EVENT_BLUR = "EVENT_BLUR";
+ static EVENT_FOCUS = "EVENT_FOCUS";
+ static EVENT_STOP = "EVENT_STOP";
+ static EVENT_SEARCHING = "EVENT_SEARCHING";
+ static EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM";
+ static EVENT_CONFIRM = "EVENT_CONFIRM";
+
+ _defaultConfig() {
+ return extend(super._defaultConfig(...arguments), {
baseCls: "bi-value-chooser-insert-combo",
width: 200,
height: 24,
items: null,
- itemsCreator: BI.emptyFn,
- cache: true
+ itemsCreator: emptyFn,
+ cache: true,
});
- },
+ }
- _init: function () {
- BI.ValueChooserInsertCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- if (BI.isNotNull(o.items)) {
+ _init() {
+ super._init(...arguments);
+ const o = this.options;
+ if (isNotNull(o.items)) {
this.items = o.items;
}
- this.combo = BI.createWidget({
- type: "bi.multi_select_insert_combo",
+ this.combo = createWidget({
+ type: MultiSelectInsertCombo.xtype,
simple: o.simple,
element: this,
allowEdit: o.allowEdit,
text: o.text,
value: this._assertValue(o.value),
- itemsCreator: BI.bind(this._itemsCreator, this),
- valueFormatter: BI.bind(this._valueFormatter, this),
+ itemsCreator: bind(this._itemsCreator, this),
+ valueFormatter: bind(this._valueFormatter, this),
width: o.width,
height: o.height,
- listeners: [{
- eventName: BI.MultiSelectCombo.EVENT_FOCUS,
- action: function () {
- self.fireEvent(BI.ValueChooserInsertCombo.EVENT_FOCUS);
- }
- }, {
- eventName: BI.MultiSelectCombo.EVENT_BLUR,
- action: function () {
- self.fireEvent(BI.ValueChooserInsertCombo.EVENT_BLUR);
- }
- }, {
- eventName: BI.MultiSelectCombo.EVENT_STOP,
- action: function () {
- self.fireEvent(BI.ValueChooserInsertCombo.EVENT_STOP);
- }
- }, {
- eventName: BI.MultiSelectCombo.EVENT_CLICK_ITEM,
- action: function () {
- self.fireEvent(BI.ValueChooserInsertCombo.EVENT_CLICK_ITEM);
- }
- }, {
- eventName: BI.MultiSelectCombo.EVENT_SEARCHING,
- action: function () {
- self.fireEvent(BI.ValueChooserInsertCombo.EVENT_SEARCHING);
+ listeners: [
+ {
+ eventName: MultiSelectCombo.EVENT_FOCUS,
+ action: () => {
+ this.fireEvent(ValueChooserInsertCombo.EVENT_FOCUS);
+ },
+ },
+ {
+ eventName: MultiSelectCombo.EVENT_BLUR,
+ action: () => {
+ this.fireEvent(ValueChooserInsertCombo.EVENT_BLUR);
+ },
+ },
+ {
+ eventName: MultiSelectCombo.EVENT_STOP,
+ action: () => {
+ this.fireEvent(ValueChooserInsertCombo.EVENT_STOP);
+ },
+ },
+ {
+ eventName: MultiSelectCombo.EVENT_CLICK_ITEM,
+ action: () => {
+ this.fireEvent(ValueChooserInsertCombo.EVENT_CLICK_ITEM);
+ },
+ },
+ {
+ eventName: MultiSelectCombo.EVENT_SEARCHING,
+ action: () => {
+ this.fireEvent(ValueChooserInsertCombo.EVENT_SEARCHING);
+ },
+ },
+ {
+ eventName: MultiSelectCombo.EVENT_CONFIRM,
+ action: () => {
+ this.fireEvent(ValueChooserInsertCombo.EVENT_CONFIRM);
+ },
}
- }, {
- eventName: BI.MultiSelectCombo.EVENT_CONFIRM,
- action: function () {
- self.fireEvent(BI.ValueChooserInsertCombo.EVENT_CONFIRM);
- }
- }]
+ ],
});
- },
+ }
- setValue: function (v) {
+ setValue(v) {
this.combo.setValue(this._assertValue(v));
- },
+ }
- getValue: function () {
- var val = this.combo.getValue() || {};
+ getValue() {
+ const val = this.combo.getValue() || {};
+
return {
type: val.type,
- value: val.value
+ value: val.value,
};
- },
+ }
- getAllValue: function() {
- var val = this.combo.getValue() || {};
- if (val.type === BI.Selection.Multi) {
+ getAllValue() {
+ const val = this.combo.getValue() || {};
+ if (val.type === Selection.Multi) {
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上
- if (BI.isNotNull(items)) {
+ if (isNotNull(items)) {
this.items = items;
}
this.combo.populate();
}
-});
-
-BI.ValueChooserInsertCombo.EVENT_BLUR = "EVENT_BLUR";
-BI.ValueChooserInsertCombo.EVENT_FOCUS = "EVENT_FOCUS";
-BI.ValueChooserInsertCombo.EVENT_STOP = "EVENT_STOP";
-BI.ValueChooserInsertCombo.EVENT_SEARCHING = "EVENT_SEARCHING";
-BI.ValueChooserInsertCombo.EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM";
-BI.ValueChooserInsertCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
-BI.shortcut("bi.value_chooser_insert_combo", BI.ValueChooserInsertCombo);
+}
diff --git a/src/component/valuechooser/combo.valuechooser.js b/src/component/valuechooser/combo.valuechooser.js
index 786dc1abd..b913f9a55 100644
--- a/src/component/valuechooser/combo.valuechooser.js
+++ b/src/component/valuechooser/combo.valuechooser.js
@@ -1,110 +1,115 @@
-/**
- * 简单的复选下拉框控件, 适用于数据量少的情况
- * 封装了字段处理逻辑
- *
- * Created by GUY on 2015/10/29.
- * @class BI.ValueChooserCombo
- * @extends BI.Widget
- */
-BI.ValueChooserCombo = BI.inherit(BI.AbstractValueChooser, {
+import { shortcut, extend, emptyFn, isNotNull, createWidget, bind, Selection, difference, map } from "@/core";
+import { AbstractValueChooser } from "./abstract.valuechooser";
+import { MultiSelectCombo } from "@/widget";
- _defaultConfig: function () {
- return BI.extend(BI.ValueChooserCombo.superclass._defaultConfig.apply(this, arguments), {
+@shortcut()
+export class ValueChooserCombo extends AbstractValueChooser {
+ static xtype = "bi.value_chooser_combo";
+
+ static EVENT_BLUR = "EVENT_BLUR";
+ static EVENT_FOCUS = "EVENT_FOCUS";
+ static EVENT_STOP = "EVENT_STOP";
+ static EVENT_SEARCHING = "EVENT_SEARCHING";
+ static EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM";
+ static EVENT_CONFIRM = "EVENT_CONFIRM";
+
+ _defaultConfig() {
+ return extend(super._defaultConfig(...arguments), {
baseCls: "bi-value-chooser-combo",
width: 200,
height: 24,
items: null,
- itemsCreator: BI.emptyFn,
- cache: true
+ itemsCreator: emptyFn,
+ cache: true,
});
- },
+ }
- _init: function () {
- BI.ValueChooserCombo.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- if (BI.isNotNull(o.items)) {
+ _init() {
+ super._init(...arguments);
+ const o = this.options;
+ if (isNotNull(o.items)) {
this.items = o.items;
}
- this.combo = BI.createWidget({
- type: "bi.multi_select_combo",
+ this.combo = createWidget({
+ type: MultiSelectCombo.xtype,
simple: o.simple,
element: this,
allowEdit: o.allowEdit,
text: o.text,
defaultText: o.defaultText,
value: this._assertValue(o.value),
- itemsCreator: BI.bind(this._itemsCreator, this),
- valueFormatter: BI.bind(this._valueFormatter, this),
+ itemsCreator: bind(this._itemsCreator, this),
+ valueFormatter: bind(this._valueFormatter, this),
width: o.width,
height: o.height,
- listeners: [{
- eventName: BI.MultiSelectCombo.EVENT_FOCUS,
- action: function () {
- self.fireEvent(BI.ValueChooserCombo.EVENT_FOCUS);
- }
- }, {
- eventName: BI.MultiSelectCombo.EVENT_BLUR,
- action: function () {
- self.fireEvent(BI.ValueChooserCombo.EVENT_BLUR);
- }
- }, {
- eventName: BI.MultiSelectCombo.EVENT_STOP,
- action: function () {
- self.fireEvent(BI.ValueChooserCombo.EVENT_STOP);
- }
- }, {
- eventName: BI.MultiSelectCombo.EVENT_CLICK_ITEM,
- action: function () {
- self.fireEvent(BI.ValueChooserCombo.EVENT_CLICK_ITEM);
- }
- }, {
- eventName: BI.MultiSelectCombo.EVENT_SEARCHING,
- action: function () {
- self.fireEvent(BI.ValueChooserCombo.EVENT_SEARCHING);
+ listeners: [
+ {
+ eventName: MultiSelectCombo.EVENT_FOCUS,
+ action: () => {
+ this.fireEvent(ValueChooserCombo.EVENT_FOCUS);
+ },
+ },
+ {
+ eventName: MultiSelectCombo.EVENT_BLUR,
+ action: () => {
+ this.fireEvent(ValueChooserCombo.EVENT_BLUR);
+ },
+ },
+ {
+ eventName: MultiSelectCombo.EVENT_STOP,
+ action: () => {
+ this.fireEvent(ValueChooserCombo.EVENT_STOP);
+ },
+ },
+ {
+ eventName: MultiSelectCombo.EVENT_CLICK_ITEM,
+ action: () => {
+ this.fireEvent(ValueChooserCombo.EVENT_CLICK_ITEM);
+ },
+ },
+ {
+ eventName: MultiSelectCombo.EVENT_SEARCHING,
+ action: () => {
+ this.fireEvent(ValueChooserCombo.EVENT_SEARCHING);
+ },
+ },
+ {
+ eventName: MultiSelectCombo.EVENT_CONFIRM,
+ action: () => {
+ this.fireEvent(ValueChooserCombo.EVENT_CONFIRM);
+ },
}
- }, {
- eventName: BI.MultiSelectCombo.EVENT_CONFIRM,
- action: function () {
- self.fireEvent(BI.ValueChooserCombo.EVENT_CONFIRM);
- }
- }]
+ ],
});
- },
+ }
- setValue: function (v) {
+ setValue(v) {
this.combo.setValue(this._assertValue(v));
- },
+ }
- getValue: function () {
- var val = this.combo.getValue() || {};
+ getValue() {
+ const val = this.combo.getValue() || {};
+
return {
type: val.type,
- value: val.value
+ value: val.value,
};
- },
+ }
- getAllValue: function () {
- var val = this.combo.getValue() || {};
- if (val.type === BI.Selection.Multi) {
+ getAllValue() {
+ const val = this.combo.getValue() || {};
+ if (val.type === Selection.Multi) {
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上
- if (BI.isNotNull(items)) {
+ if (isNotNull(items)) {
this.items = items;
}
this.combo.populate();
}
-});
-
-BI.ValueChooserCombo.EVENT_BLUR = "EVENT_BLUR";
-BI.ValueChooserCombo.EVENT_FOCUS = "EVENT_FOCUS";
-BI.ValueChooserCombo.EVENT_STOP = "EVENT_STOP";
-BI.ValueChooserCombo.EVENT_SEARCHING = "EVENT_SEARCHING";
-BI.ValueChooserCombo.EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM";
-BI.ValueChooserCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
-BI.shortcut("bi.value_chooser_combo", BI.ValueChooserCombo);
+}
diff --git a/src/component/valuechooser/combo.valuechooser.nobar.js b/src/component/valuechooser/combo.valuechooser.nobar.js
index 2910ea4fa..502c61aaf 100644
--- a/src/component/valuechooser/combo.valuechooser.nobar.js
+++ b/src/component/valuechooser/combo.valuechooser.nobar.js
@@ -1,98 +1,98 @@
-/**
- * @author windy
- * @version 2.0
- * Created by windy on 2020/12/31
- */
-BI.ValueChooserNoBarCombo = BI.inherit(BI.AbstractValueChooser, {
+import { shortcut, isNotNull, bind } from "@/core";
+import { AbstractValueChooser } from "./abstract.valuechooser";
+import { MultiSelectCombo, MultiSelectNoBarCombo } from "@/widget";
- props: {
- baseCls: "bi-value-chooser-combo",
- width: 200,
- height: 24,
- items: null,
- itemsCreator: BI.emptyFn,
- cache: true
- },
+@shortcut()
+export class ValueChooserNoBarCombo extends AbstractValueChooser {
+ static xtype = "bi.value_chooser_no_bar_combo";
- render: function () {
- var self = this, o = this.options;
- if (BI.isNotNull(o.items)) {
+ props = { baseCls: "bi-value-chooser-combo", width: 200, height: 24, items: null, cache: true };
+
+ static EVENT_BLUR = "EVENT_BLUR";
+ static EVENT_FOCUS = "EVENT_FOCUS";
+ static EVENT_STOP = "EVENT_STOP";
+ static EVENT_SEARCHING = "EVENT_SEARCHING";
+ static EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM";
+ static EVENT_CONFIRM = "EVENT_CONFIRM";
+
+ render() {
+ const o = this.options;
+ if (isNotNull(o.items)) {
this.items = o.items;
}
return {
- type: "bi.multi_select_no_bar_combo",
+ type: MultiSelectNoBarCombo.xtype,
simple: o.simple,
allowEdit: o.allowEdit,
text: o.text,
defaultText: o.defaultText,
value: this._assertValue(o.value),
- itemsCreator: BI.bind(this._itemsCreator, this),
- valueFormatter: BI.bind(this._valueFormatter, this),
+ itemsCreator: bind(this._itemsCreator, this),
+ valueFormatter: bind(this._valueFormatter, this),
width: o.width,
height: o.height,
- ref: function (_ref) {
- self.combo = _ref;
+ ref: _ref => {
+ this.combo = _ref;
},
- listeners: [{
- eventName: BI.MultiSelectCombo.EVENT_FOCUS,
- action: function () {
- self.fireEvent(BI.ValueChooserNoBarCombo.EVENT_FOCUS);
- }
- }, {
- eventName: BI.MultiSelectCombo.EVENT_BLUR,
- action: function () {
- self.fireEvent(BI.ValueChooserNoBarCombo.EVENT_BLUR);
- }
- }, {
- eventName: BI.MultiSelectCombo.EVENT_STOP,
- action: function () {
- self.fireEvent(BI.ValueChooserNoBarCombo.EVENT_STOP);
- }
- }, {
- eventName: BI.MultiSelectCombo.EVENT_CLICK_ITEM,
- action: function () {
- self.fireEvent(BI.ValueChooserNoBarCombo.EVENT_CLICK_ITEM);
- }
- }, {
- eventName: BI.MultiSelectCombo.EVENT_SEARCHING,
- action: function () {
- self.fireEvent(BI.ValueChooserNoBarCombo.EVENT_SEARCHING);
+ listeners: [
+ {
+ eventName: MultiSelectCombo.EVENT_FOCUS,
+ action: () => {
+ this.fireEvent(ValueChooserNoBarCombo.EVENT_FOCUS);
+ },
+ },
+ {
+ eventName: MultiSelectCombo.EVENT_BLUR,
+ action: () => {
+ this.fireEvent(ValueChooserNoBarCombo.EVENT_BLUR);
+ },
+ },
+ {
+ eventName: MultiSelectCombo.EVENT_STOP,
+ action: () => {
+ this.fireEvent(ValueChooserNoBarCombo.EVENT_STOP);
+ },
+ },
+ {
+ eventName: MultiSelectCombo.EVENT_CLICK_ITEM,
+ action: () => {
+ this.fireEvent(ValueChooserNoBarCombo.EVENT_CLICK_ITEM);
+ },
+ },
+ {
+ eventName: MultiSelectCombo.EVENT_SEARCHING,
+ action: () => {
+ this.fireEvent(ValueChooserNoBarCombo.EVENT_SEARCHING);
+ },
+ },
+ {
+ eventName: MultiSelectCombo.EVENT_CONFIRM,
+ action: () => {
+ this.fireEvent(ValueChooserNoBarCombo.EVENT_CONFIRM);
+ },
}
- }, {
- eventName: BI.MultiSelectCombo.EVENT_CONFIRM,
- action: function () {
- self.fireEvent(BI.ValueChooserNoBarCombo.EVENT_CONFIRM);
- }
- }]
+ ],
};
- },
+ }
- setValue: function (v) {
+ setValue(v) {
this.combo.setValue(v);
- },
+ }
- getValue: function () {
+ getValue() {
return this.combo.getValue();
- },
+ }
- getAllValue: function () {
+ getAllValue() {
return this.getValue();
- },
+ }
- populate: function (items) {
+ populate(items) {
// 直接用combo的populate不会作用到AbstractValueChooser上
- if (BI.isNotNull(items)) {
+ if (isNotNull(items)) {
this.items = items;
}
this.combo.populate();
}
-});
-
-BI.ValueChooserNoBarCombo.EVENT_BLUR = "EVENT_BLUR";
-BI.ValueChooserNoBarCombo.EVENT_FOCUS = "EVENT_FOCUS";
-BI.ValueChooserNoBarCombo.EVENT_STOP = "EVENT_STOP";
-BI.ValueChooserNoBarCombo.EVENT_SEARCHING = "EVENT_SEARCHING";
-BI.ValueChooserNoBarCombo.EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM";
-BI.ValueChooserNoBarCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
-BI.shortcut("bi.value_chooser_no_bar_combo", BI.ValueChooserNoBarCombo);
+}
diff --git a/src/component/valuechooser/index.js b/src/component/valuechooser/index.js
new file mode 100644
index 000000000..1b920d806
--- /dev/null
+++ b/src/component/valuechooser/index.js
@@ -0,0 +1,5 @@
+export { ValueChooserInsertCombo } from "./combo.valuechooser.insert";
+export { ValueChooserCombo } from "./combo.valuechooser";
+export { ValueChooserNoBarCombo } from "./combo.valuechooser.nobar";
+export { AbstractValueChooser } from "./abstract.valuechooser";
+export { ValueChooserPane } from "./pane.valuechooser";
diff --git a/src/component/valuechooser/pane.valuechooser.js b/src/component/valuechooser/pane.valuechooser.js
index d483f26fb..9936aeebd 100644
--- a/src/component/valuechooser/pane.valuechooser.js
+++ b/src/component/valuechooser/pane.valuechooser.js
@@ -1,70 +1,69 @@
-/**
- * 简单的复选面板, 适用于数据量少的情况
- * 封装了字段处理逻辑
- *
- * Created by GUY on 2015/10/29.
- * @class BI.ValueChooserPane
- * @extends BI.Widget
- */
-BI.ValueChooserPane = BI.inherit(BI.AbstractValueChooser, {
+import { shortcut, extend, emptyFn, createWidget, bind, isNotNull, Selection, difference, map } from "@/core";
+import { AbstractValueChooser } from "./abstract.valuechooser";
+import { MultiSelectList } from "@/widget";
- _defaultConfig: function () {
- return BI.extend(BI.ValueChooserPane.superclass._defaultConfig.apply(this, arguments), {
+@shortcut()
+export class ValueChooserPane extends AbstractValueChooser {
+ static xtype = "bi.value_chooser_pane";
+
+ static EVENT_CHANGE = "EVENT_CHANGE";
+
+ _defaultConfig() {
+ return extend(super._defaultConfig(...arguments), {
baseCls: "bi-value-chooser-pane",
items: null,
- itemsCreator: BI.emptyFn,
- cache: true
+ itemsCreator: emptyFn,
+ cache: true,
});
- },
+ }
- _init: function () {
- BI.ValueChooserPane.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.list = BI.createWidget({
- type: "bi.multi_select_list",
+ _init() {
+ super._init(...arguments);
+ const o = this.options;
+ this.list = createWidget({
+ type: MultiSelectList.xtype,
element: this,
value: o.value,
- itemsCreator: BI.bind(this._itemsCreator, this),
- valueFormatter: BI.bind(this._valueFormatter, this)
+ itemsCreator: bind(this._itemsCreator, this),
+ valueFormatter: bind(this._valueFormatter, this),
});
- this.list.on(BI.MultiSelectList.EVENT_CHANGE, function () {
- self.fireEvent(BI.ValueChooserPane.EVENT_CHANGE);
+ this.list.on(MultiSelectList.EVENT_CHANGE, () => {
+ this.fireEvent(ValueChooserPane.EVENT_CHANGE);
});
- if (BI.isNotNull(o.items)) {
+ if (isNotNull(o.items)) {
this.items = o.items;
this.list.populate();
}
- },
+ }
- setValue: function (v) {
+ setValue(v) {
this.list.setValue(v);
- },
+ }
- getValue: function () {
- var val = this.list.getValue() || {};
+ getValue() {
+ const val = this.list.getValue() || {};
+
return {
type: val.type,
- value: val.value
+ value: val.value,
};
- },
+ }
- getAllValue: function() {
- var val = this.combo.getValue() || {};
- if (val.type === BI.Selection.Multi) {
+ getAllValue() {
+ const val = this.combo.getValue() || {};
+ if (val.type === Selection.Multi) {
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上
- if (BI.isNotNull(items)) {
+ if (isNotNull(items)) {
this.items = items;
}
this.list.populate();
}
-});
-BI.ValueChooserPane.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);
+}
diff --git a/src/core/5.inject.js b/src/core/5.inject.js
index 8a54bbeb7..2b04a435f 100644
--- a/src/core/5.inject.js
+++ b/src/core/5.inject.js
@@ -401,6 +401,8 @@ export function shortcut(xtype, cls) {
kv[xtype] = cls;
}
+export const component = shortcut;
+
// 根据配置属性生成widget
const createRealWidget = (config, context, lazy) => {
const Cls = isFunction(config.type) ? config.type : kv[config.type];
diff --git a/src/core/behavior/behavior.highlight.js b/src/core/behavior/behavior.highlight.js
index f66355c65..2b10c012f 100644
--- a/src/core/behavior/behavior.highlight.js
+++ b/src/core/behavior/behavior.highlight.js
@@ -3,7 +3,7 @@
*/
import { Behavior } from "./0.behavior";
import { isFunction, each } from "../2.base";
-import { Single } from "../../base";
+import { Single } from "@/base/single/0.single";
export class HighlightBehavior extends Behavior {
doBehavior(items) {
diff --git a/src/core/behavior/behavior.redmark.js b/src/core/behavior/behavior.redmark.js
index 7ca2b9df2..1158757a7 100644
--- a/src/core/behavior/behavior.redmark.js
+++ b/src/core/behavior/behavior.redmark.js
@@ -4,7 +4,7 @@
*/
import { Behavior } from "./0.behavior";
import { each } from "../2.base";
-import { Single } from "../../base";
+import { Single } from "@/base/single/0.single";
export class RedMarkBehavior extends Behavior {
doBehavior(items) {
diff --git a/src/core/index.js b/src/core/index.js
index d3a64ffc7..89b01230c 100644
--- a/src/core/index.js
+++ b/src/core/index.js
@@ -1,32 +1,29 @@
-import * as base from "./2.base";
-import * as ob from "./3.ob";
-import * as widget from "./4.widget";
-import * as inject from "./5.inject";
-import { Plugin } from "./6.plugin";
-import * as h from "./h";
-import * as action from "./action";
-import * as behavior from "./behavior";
-import * as controllers from "./controller";
-import * as func from "./func";
-import * as structure from "./structure";
-import { StyleLoaderManager } from "./loader/loader.style";
-import { ShowListener } from "./listener/listener.show";
-import { useInWorker } from "./worker";
-import * as constant from "./constant";
-import * as logic from "./logic";
-import { Element } from "./element";
-import * as utils from "./utils";
-import * as wrapper from "./wrapper";
-import * as platform from "./platform/web";
+export { Plugin } from "./6.plugin";
+export { StyleLoaderManager } from "./loader/loader.style";
+export { ShowListener } from "./listener/listener.show";
+export { useInWorker } from "./worker";
+export { Element } from "./element";
+
+export { Controller } from "./controller/0.controller";
+export { BroadcastController } from "./controller/controller.broadcast";
+export { BubblesController } from "./controller/controller.bubbles";
+export { DrawerController } from "./controller/controller.drawer";
+export { LayerController } from "./controller/controller.layer";
+export { MaskersController } from "./controller/controller.masker";
+export { PopoverController } from "./controller/controller.popover";
+export { ResizeController } from "./controller/controller.resizer";
+export { TooltipsController } from "./controller/controller.tooltips";
export * from "./decorator";
export * from "./2.base";
export * from "./3.ob";
export * from "./4.widget";
export * from "./5.inject";
+export * from "./6.plugin";
+export * from "./system";
export * from "./action";
export * from "./behavior";
-export * from "./controller";
+// export * from "./controller";
export * from "./func";
export * from "./structure";
export * from "./h";
@@ -35,35 +32,3 @@ export * from "./logic";
export * from "./wrapper";
export * from "./platform/web";
export * from "./utils";
-
-export {
- StyleLoaderManager,
- ShowListener,
- Plugin,
- useInWorker,
- Element
-};
-
-Object.assign(BI, {
- ...base,
- ...ob,
- ...widget,
- ...inject,
- Plugin,
- ...behavior,
- ...constant,
- component: inject.shortcut,
- ...action,
- ...controllers,
- Element,
- ...func,
- StyleLoaderManager,
- ShowListener,
- ...logic,
- ...structure,
- useInWorker,
- ...h,
- ...utils,
- ...wrapper,
- ...platform,
-});
diff --git a/src/core/wrapper/layout/responsive/responsive.flex.horizontal.js b/src/core/wrapper/layout/responsive/responsive.flex.horizontal.js
index 7cfceede4..d52acb6c5 100644
--- a/src/core/wrapper/layout/responsive/responsive.flex.horizontal.js
+++ b/src/core/wrapper/layout/responsive/responsive.flex.horizontal.js
@@ -1,7 +1,7 @@
import { shortcut } from "@/core/decorator";
import { each } from "@/core/2.base";
import { HorizontalAlign } from "@/core/constant";
-import { Resizers } from "@/base";
+// import { Resizers } from "@/base/0.base";
import { FlexHorizontalLayout } from "../flex";
/**
@@ -34,22 +34,22 @@ export class ResponsiveFlexHorizontalLayout extends FlexHorizontalLayout {
}
}
};
- const resize = () => {
- defaultResize();
- if (o.scrollable !== true && o.scrollx !== true) {
- const clientWidth = document.body.clientWidth;
- if (this.element.width() > 2 / 3 * clientWidth) {
- if (clientWidth > 768) {
- each(this._children, (i, child) => {
- this._clearGap(child);
- });
- this.resize();
- this.element.css("flex-direction", "row");
- }
- }
- }
- };
- this.unResize = Resizers.add(this.getName(), resize);
+ // const resize = () => {
+ // defaultResize();
+ // if (o.scrollable !== true && o.scrollx !== true) {
+ // const clientWidth = document.body.clientWidth;
+ // if (this.element.width() > 2 / 3 * clientWidth) {
+ // if (clientWidth > 768) {
+ // each(this._children, (i, child) => {
+ // this._clearGap(child);
+ // });
+ // this.resize();
+ // this.element.css("flex-direction", "row");
+ // }
+ // }
+ // }
+ // };
+ // this.unResize = Resizers.add(this.getName(), resize);
defaultResize();
}
diff --git a/src/core/wrapper/layout/responsive/responsive.flex.wrapper.horizontal.js b/src/core/wrapper/layout/responsive/responsive.flex.wrapper.horizontal.js
index 90677598a..52389036a 100644
--- a/src/core/wrapper/layout/responsive/responsive.flex.wrapper.horizontal.js
+++ b/src/core/wrapper/layout/responsive/responsive.flex.wrapper.horizontal.js
@@ -1,7 +1,7 @@
import { shortcut } from "@/core/decorator";
import { each } from "@/core/2.base";
import { HorizontalAlign } from "@/core/constant";
-import { Resizers } from "@/base";
+// import { Resizers } from "@/base/0.base";
import { FlexWrapperHorizontalLayout } from "../flex";
/**
@@ -35,23 +35,23 @@ export class ResponsiveFlexWrapperHorizontalLayout extends FlexWrapperHorizontal
}
}
};
- const resize = () => {
- defaultResize();
- if (o.scrollable !== true && o.scrollx !== true) {
- const clientWidth = document.body.clientWidth;
- if (this.element.width() > 2 / 3 * clientWidth) {
- if (clientWidth > 768) {
- each(this._children, (i, child) => {
- this._clearGap(child);
- });
- this.resize();
- this.element.css("flex-direction", "row");
- this.$wrapper.element.css("flex-direction", "row");
- }
- }
- }
- };
- this.unResize = Resizers.add(this.getName(), resize);
+ // const resize = () => {
+ // defaultResize();
+ // if (o.scrollable !== true && o.scrollx !== true) {
+ // const clientWidth = document.body.clientWidth;
+ // if (this.element.width() > 2 / 3 * clientWidth) {
+ // if (clientWidth > 768) {
+ // each(this._children, (i, child) => {
+ // this._clearGap(child);
+ // });
+ // this.resize();
+ // this.element.css("flex-direction", "row");
+ // this.$wrapper.element.css("flex-direction", "row");
+ // }
+ // }
+ // }
+ // };
+ // this.unResize = Resizers.add(this.getName(), resize);
defaultResize();
}
diff --git a/src/core/wrapper/layout/responsive/responsive.inline.js b/src/core/wrapper/layout/responsive/responsive.inline.js
index 747a9d9cf..b0d23c09a 100644
--- a/src/core/wrapper/layout/responsive/responsive.inline.js
+++ b/src/core/wrapper/layout/responsive/responsive.inline.js
@@ -1,7 +1,7 @@
import { shortcut } from "@/core/decorator";
import { each } from "@/core/2.base";
import { HorizontalAlign } from "@/core/constant";
-import { Resizers } from "@/base";
+// import { Resizers } from "@/base/0.base";
import { InlineLayout } from "../layout.inline";
/**
@@ -34,21 +34,21 @@ export class ResponsiveInlineLayout extends InlineLayout {
}
}
};
- const resize = () => {
- defaultResize();
- if (o.scrollable !== true && o.scrollx !== true) {
- const clientWidth = document.body.clientWidth;
- if (this.element.width() > 2 / 3 * clientWidth) {
- if (clientWidth > 768) {
- each(this._children, (i, child) => {
- this._clearGap(child);
- });
- this.resize();
- }
- }
- }
- };
- this.unResize = Resizers.add(this.getName(), resize);
+ // const resize = () => {
+ // defaultResize();
+ // if (o.scrollable !== true && o.scrollx !== true) {
+ // const clientWidth = document.body.clientWidth;
+ // if (this.element.width() > 2 / 3 * clientWidth) {
+ // if (clientWidth > 768) {
+ // each(this._children, (i, child) => {
+ // this._clearGap(child);
+ // });
+ // this.resize();
+ // }
+ // }
+ // }
+ // };
+ // this.unResize = Resizers.add(this.getName(), resize);
defaultResize();
}
diff --git a/src/index.js b/src/index.js
new file mode 100644
index 000000000..2f3f17564
--- /dev/null
+++ b/src/index.js
@@ -0,0 +1,5 @@
+export * from "./core";
+export * from "./base";
+export * from "./case";
+export * from "./widget";
+export * from "./component";
diff --git a/src/widget/collapse/collapse.js b/src/widget/collapse/collapse.js
index 4111a23ce..5c7b1c5ac 100644
--- a/src/widget/collapse/collapse.js
+++ b/src/widget/collapse/collapse.js
@@ -1,11 +1,23 @@
-import { shortcut, Widget, map, extend, isFunction, contains, each, isKey, isNotEmptyArray } from "@/core";
+import {
+ VerticalLayout,
+ shortcut,
+ Widget,
+ map,
+ extend,
+ isFunction,
+ contains,
+ each,
+ isKey,
+ isNotEmptyArray
+} from "@/core";
+import { ArrowNode } from "@/case";
import { Expander } from "@/base";
@shortcut()
export class Collapse extends Widget {
- static xtype = "bi.collapse"
+ static xtype = "bi.collapse";
- static EVENT_EXPAND = "EVENT_EXPAND"
+ static EVENT_EXPAND = "EVENT_EXPAND";
props = {
baseCls: "bi-collapse",
@@ -30,10 +42,9 @@ export class Collapse extends Widget {
this.expanders = {};
return {
- type: "bi.vertical",
+ type: VerticalLayout.xtype,
cls: collapseCls,
items: this._getItems(this.options.items),
-
};
}
@@ -44,46 +55,58 @@ export class Collapse extends Widget {
const isActive = contains(this._getCurrentValue(o.value), item.value);
const cls = o.ghost || index === 0 ? "" : "bi-border-top";
- const el = extend({
- type: "bi.arrow_group_node",
- height: 30,
- text: item.text,
- value: item.value,
- open: isActive,
- }, item.el);
-
- const popup = extend({
- animation: o.openMotion.animation,
- animationDuring: o.openMotion.animationDuring,
- }, item.popup);
-
- return extend({
- type: "bi.expander",
- cls,
- isDefaultInit: o.isDefaultInit,
- trigger: o.trigger,
- listeners: [{
- eventName: Expander.EVENT_EXPAND,
- action: () => {
- this._hideOtherExpander(item.value);
- this.fireEvent(Collapse.EVENT_EXPAND, item.value);
- },
- }],
- }, item, {
- el,
- popup,
- ref: _ref => {
- isFunction(item.ref) && item.ref(_ref);
- this.expanders[item.value] = _ref;
+ const el = extend(
+ {
+ type: ArrowNode.xtype,
+ height: 30,
+ text: item.text,
+ value: item.value,
+ open: isActive,
},
- });
+ item.el
+ );
+
+ const popup = extend(
+ {
+ animation: o.openMotion.animation,
+ animationDuring: o.openMotion.animationDuring,
+ },
+ item.popup
+ );
+
+ return extend(
+ {
+ type: Expander.xtype,
+ cls,
+ isDefaultInit: o.isDefaultInit,
+ trigger: o.trigger,
+ listeners: [
+ {
+ eventName: Expander.EVENT_EXPAND,
+ action: () => {
+ this._hideOtherExpander(item.value);
+ this.fireEvent(Collapse.EVENT_EXPAND, item.value);
+ },
+ }
+ ],
+ },
+ item,
+ {
+ el,
+ popup,
+ ref: _ref => {
+ isFunction(item.ref) && item.ref(_ref);
+ this.expanders[item.value] = _ref;
+ },
+ }
+ );
});
}
_hideOtherExpander(expandKey) {
if (this.options.accordion) {
each(this.expanders, (key, expander) => {
- key !== (`${expandKey}`) && expander.hideView();
+ key !== `${expandKey}` && expander.hideView();
});
}
}
diff --git a/src/widget/date/calendar/combo.month.date.js b/src/widget/date/calendar/combo.month.date.js
index 565745c4e..cb01f09d2 100644
--- a/src/widget/date/calendar/combo.month.date.js
+++ b/src/widget/date/calendar/combo.month.date.js
@@ -1,6 +1,7 @@
-import { shortcut, extend, createWidget } from "@/core";
-import { Trigger, Combo } from "@/base";
+import { DateTriangleTrigger } from "./trigger.triangle.date";
import { MonthPopup } from "./popup.month";
+import { Combo, Trigger } from "@/base";
+import { VerticalLayout, shortcut, extend, createWidget } from "@/core";
/**
* 日期控件中的月份下拉框
@@ -11,9 +12,9 @@ import { MonthPopup } from "./popup.month";
*/
@shortcut()
export class MonthDateCombo extends Trigger {
- static xtype = "bi.month_date_combo"
+ static xtype = "bi.month_date_combo";
- static EVENT_CHANGE = "EVENT_CHANGE"
+ static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
@@ -28,11 +29,11 @@ export class MonthDateCombo extends Trigger {
const o = this.options;
this.trigger = createWidget({
- type: "bi.date_triangle_trigger",
+ type: DateTriangleTrigger.xtype,
});
this.popup = createWidget({
- type: "bi.month_popup",
+ type: MonthPopup.xtype,
allowMonths: o.allowMonths,
behaviors: o.behaviors,
});
@@ -44,7 +45,7 @@ export class MonthDateCombo extends Trigger {
});
this.combo = createWidget({
- type: "bi.combo",
+ type: Combo.xtype,
offsetStyle: "center",
container: o.container,
element: this,
@@ -55,7 +56,7 @@ export class MonthDateCombo extends Trigger {
minWidth: 100,
stopPropagation: false,
el: {
- type: "bi.vertical",
+ type: VerticalLayout.xtype,
hgap: 6,
vgap: 5,
items: [this.popup],
diff --git a/src/widget/date/calendar/combo.year.date.js b/src/widget/date/calendar/combo.year.date.js
index b3f883b12..5cd38b3b8 100644
--- a/src/widget/date/calendar/combo.year.date.js
+++ b/src/widget/date/calendar/combo.year.date.js
@@ -1,6 +1,7 @@
-import { shortcut, extend, createWidget } from "@/core";
-import { Trigger, Combo } from "@/base";
+import { DateTriangleTrigger } from "./trigger.triangle.date";
import { YearPopup } from "./popup.year";
+import { Combo, Trigger } from "@/base";
+import { shortcut, extend, createWidget } from "@/core";
/**
* 年份下拉框
@@ -11,10 +12,10 @@ import { YearPopup } from "./popup.year";
*/
@shortcut()
export class YearDateCombo extends Trigger {
- static xtype = "bi.year_date_combo"
+ static xtype = "bi.year_date_combo";
- static EVENT_CHANGE = "EVENT_CHANGE"
- static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"
+ static EVENT_CHANGE = "EVENT_CHANGE";
+ static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
@@ -32,11 +33,11 @@ export class YearDateCombo extends Trigger {
const o = this.options;
this.trigger = createWidget({
- type: "bi.date_triangle_trigger",
+ type: DateTriangleTrigger.xtype,
});
this.popup = createWidget({
- type: "bi.year_popup",
+ type: YearPopup.xtype,
behaviors: o.behaviors,
min: o.min,
max: o.max,
@@ -50,7 +51,7 @@ export class YearDateCombo extends Trigger {
});
this.combo = createWidget({
- type: "bi.combo",
+ type: Combo.xtype,
offsetStyle: "center",
element: this,
container: o.container,
diff --git a/src/widget/date/calendar/picker.date.js b/src/widget/date/calendar/picker.date.js
index a5a23ae11..c0cdc54d4 100644
--- a/src/widget/date/calendar/picker.date.js
+++ b/src/widget/date/calendar/picker.date.js
@@ -1,7 +1,23 @@
-import { shortcut, Widget, extend, createWidget, contains, isNull, getDate, filter, range, checkDateVoid, parseDateTime, parseInt, print } from "@/core";
import { IconButton } from "@/base";
import { YearDateCombo } from "./combo.year.date";
import { MonthDateCombo } from "./combo.month.date";
+import {
+ HTapeLayout,
+ CenterAdaptLayout,
+ shortcut,
+ Widget,
+ extend,
+ createWidget,
+ contains,
+ isNull,
+ getDate,
+ filter,
+ range,
+ checkDateVoid,
+ parseDateTime,
+ parseInt,
+ print
+} from "@/core";
/**
* Created by GUY on 2015/9/7.
@@ -10,10 +26,10 @@ import { MonthDateCombo } from "./combo.month.date";
*/
@shortcut()
export class DatePicker extends Widget {
- static xtype = "bi.date_picker"
+ static xtype = "bi.date_picker";
- static EVENT_CHANGE = "EVENT_CHANGE"
- static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW"
+ static EVENT_CHANGE = "EVENT_CHANGE";
+ static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW";
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
@@ -32,7 +48,7 @@ export class DatePicker extends Widget {
this._year = getDate().getFullYear();
this._month = getDate().getMonth() + 1;
this.left = createWidget({
- type: "bi.icon_button",
+ type: IconButton.xtype,
cls: "pre-page-h-font",
width: 24,
height: 24,
@@ -40,13 +56,13 @@ export class DatePicker extends Widget {
this.left.on(IconButton.EVENT_CHANGE, () => {
if (this._month === 1) {
this.setValue({
- year: (this.year.getValue() - 1) || (getDate().getFullYear() - 1),
+ year: this.year.getValue() - 1 || getDate().getFullYear() - 1,
month: 12,
});
} else {
this.setValue({
year: this.year.getValue() || getDate().getFullYear(),
- month: (this.month.getValue() - 1) || getDate().getMonth(),
+ month: this.month.getValue() - 1 || getDate().getMonth(),
});
}
this.fireEvent(DatePicker.EVENT_CHANGE);
@@ -55,7 +71,7 @@ export class DatePicker extends Widget {
});
this.right = createWidget({
- type: "bi.icon_button",
+ type: IconButton.xtype,
cls: "next-page-h-font",
width: 24,
height: 24,
@@ -64,13 +80,13 @@ export class DatePicker extends Widget {
this.right.on(IconButton.EVENT_CHANGE, () => {
if (this._month === 12) {
this.setValue({
- year: (this.year.getValue() + 1) || (getDate().getFullYear() + 1),
+ year: this.year.getValue() + 1 || getDate().getFullYear() + 1,
month: 1,
});
} else {
this.setValue({
year: this.year.getValue() || getDate().getFullYear(),
- month: (this.month.getValue() + 1) || (getDate().getMonth() + 2),
+ month: this.month.getValue() + 1 || getDate().getMonth() + 2,
});
}
this.fireEvent(DatePicker.EVENT_CHANGE);
@@ -79,7 +95,7 @@ export class DatePicker extends Widget {
});
this.year = createWidget({
- type: "bi.year_date_combo",
+ type: YearDateCombo.xtype,
behaviors: o.behaviors,
min: o.min,
max: o.max,
@@ -95,7 +111,7 @@ export class DatePicker extends Widget {
this.fireEvent(DatePicker.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
});
this.month = createWidget({
- type: "bi.month_date_combo",
+ type: MonthDateCombo.xtype,
behaviors: o.behaviors,
allowMonths: this._getAllowMonths(),
});
@@ -111,27 +127,31 @@ export class DatePicker extends Widget {
});
createWidget({
- type: "bi.htape",
+ type: HTapeLayout.xtype,
element: this,
- items: [{
- el: {
- type: "bi.center_adapt",
- items: [this.left],
+ items: [
+ {
+ el: {
+ type: CenterAdaptLayout.xtype,
+ items: [this.left],
+ },
+ width: 24,
},
- width: 24,
- }, {
- el: {
- type: "bi.center_adapt",
- hgap: 10,
- items: [this.year, this.month],
+ {
+ el: {
+ type: CenterAdaptLayout.xtype,
+ hgap: 10,
+ items: [this.year, this.month],
+ },
},
- }, {
- el: {
- type: "bi.center_adapt",
- items: [this.right],
- },
- width: 24,
- }],
+ {
+ el: {
+ type: CenterAdaptLayout.xtype,
+ items: [this.right],
+ },
+ width: 24,
+ }
+ ],
});
this.setValue({
year: this._year,
@@ -147,7 +167,7 @@ export class DatePicker extends Widget {
month = defaultMonth || allowMonth[0];
}
this.month.setValue(month);
-
+
return month;
}
diff --git a/src/widget/date/calendar/picker.year.js b/src/widget/date/calendar/picker.year.js
index cced43639..06bb277d9 100644
--- a/src/widget/date/calendar/picker.year.js
+++ b/src/widget/date/calendar/picker.year.js
@@ -1,17 +1,17 @@
-import { shortcut, Widget, extend, createWidget, getDate, parseDateTime } from "@/core";
-import { IconButton } from "@/base";
import { YearDateCombo } from "./combo.year.date";
+import { HTapeLayout, CenterAdaptLayout, shortcut, Widget, extend, createWidget, getDate, parseDateTime } from "@/core";
+import { IconButton } from "@/base";
@shortcut()
export class YearPicker extends Widget {
- static xtype = "bi.year_picker"
+ static xtype = "bi.year_picker";
- static EVENT_CHANGE = "EVENT_CHANGE"
- static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"
+ static EVENT_CHANGE = "EVENT_CHANGE";
+ static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
-
+
return extend(conf, {
baseCls: "bi-year-picker",
behaviors: {},
@@ -53,7 +53,7 @@ export class YearPicker extends Widget {
});
this.year = createWidget({
- type: "bi.year_date_combo",
+ type: YearDateCombo.xtype,
min: o.min,
behaviors: o.behaviors,
max: o.max,
@@ -68,26 +68,32 @@ export class YearPicker extends Widget {
});
createWidget({
- type: "bi.htape",
+ type: HTapeLayout.xtype,
element: this,
- items: [{
- el: {
- type: "bi.center_adapt",
- items: [this.left],
+ items: [
+ {
+ el: {
+ type: CenterAdaptLayout.xtype,
+ items: [this.left],
+ },
+ width: 25,
},
- width: 25,
- }, {
- type: "bi.center_adapt",
- items: [{
- el: this.year,
- }],
- }, {
- el: {
- type: "bi.center_adapt",
- items: [this.right],
+ {
+ type: CenterAdaptLayout.xtype,
+ items: [
+ {
+ el: this.year,
+ }
+ ],
},
- width: 25,
- }],
+ {
+ el: {
+ type: CenterAdaptLayout.xtype,
+ items: [this.right],
+ },
+ width: 25,
+ }
+ ],
});
this.setValue(this._year);
}
@@ -96,7 +102,7 @@ export class YearPicker extends Widget {
const o = this.options;
const valid = this._year > parseDateTime(o.min, "%Y-%X-%d").getFullYear();
this.left.setEnable(valid);
-
+
return valid;
}
@@ -104,7 +110,7 @@ export class YearPicker extends Widget {
const o = this.options;
const valid = this._year < parseDateTime(o.max, "%Y-%X-%d").getFullYear();
this.right.setEnable(valid);
-
+
return valid;
}
diff --git a/src/widget/date/calendar/popup.calendar.date.js b/src/widget/date/calendar/popup.calendar.date.js
index a3180e334..df5d81a43 100644
--- a/src/widget/date/calendar/popup.calendar.date.js
+++ b/src/widget/date/calendar/popup.calendar.date.js
@@ -1,7 +1,18 @@
-import { shortcut, Widget, createWidget, bind, getDate, each, isNotEmptyString } from "@/core";
-import { Navigation } from "@/base";
import { Calendar } from "@/case";
import { DatePicker } from "./picker.date";
+import { Navigation } from "@/base";
+import {
+ VerticalLayout,
+ AbsoluteLayout,
+ Layout,
+ shortcut,
+ Widget,
+ createWidget,
+ bind,
+ getDate,
+ each,
+ isNotEmptyString
+} from "@/core";
/**
* Created by GUY on 2015/9/7.
@@ -10,7 +21,7 @@ import { DatePicker } from "./picker.date";
*/
@shortcut()
export class DateCalendarPopup extends Widget {
- static xtype = "bi.date_calendar_popup"
+ static xtype = "bi.date_calendar_popup";
props = {
baseCls: "bi-date-calendar-popup",
@@ -19,14 +30,13 @@ export class DateCalendarPopup extends Widget {
selectedTime: null,
};
- static EVENT_CHANGE = "EVENT_CHANGE"
- static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW"
-
+ static EVENT_CHANGE = "EVENT_CHANGE";
+ static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW";
_createNav(v) {
const date = Calendar.getDateJSONByPage(v);
const calendar = createWidget({
- type: "bi.calendar",
+ type: Calendar.xtype,
logic: {
dynamic: true,
},
@@ -37,7 +47,7 @@ export class DateCalendarPopup extends Widget {
// BI-45616 此处为确定当前应该展示哪个年月对应的Calendar, day不是关键数据, 给1号就可
day: 1,
});
-
+
return calendar;
}
@@ -54,7 +64,7 @@ export class DateCalendarPopup extends Widget {
day: this._day,
};
this.datePicker = createWidget({
- type: "bi.date_picker",
+ type: DatePicker.xtype,
behaviors: o.behaviors,
min: o.min,
max: o.max,
@@ -65,13 +75,11 @@ export class DateCalendarPopup extends Widget {
logic: {
dynamic: true,
},
- type: "bi.navigation",
+ type: Navigation.xtype,
tab: this.datePicker,
cardCreator: bind(this._createNav, this),
- afterCardCreated () {
-
- },
+ afterCardCreated() {},
afterCardShow: () => {
this.calendar.setValue(this.selectedTime);
@@ -94,26 +102,33 @@ export class DateCalendarPopup extends Widget {
this.fireEvent(DateCalendarPopup.EVENT_CHANGE);
});
- return [{
- type: "bi.vertical",
- items: [{
- el: this.calendar,
- hgap: 12,
- bgap: 7,
- }],
- }, {
- type: "bi.absolute",
- items: [{
- el: {
- type: "bi.layout",
- cls: "bi-split-top",
- },
- height: 1,
- top: 40,
- left: 0,
- right: 0,
- }],
- }];
+ return [
+ {
+ type: VerticalLayout.xtype,
+ items: [
+ {
+ el: this.calendar,
+ hgap: 12,
+ bgap: 7,
+ }
+ ],
+ },
+ {
+ type: AbsoluteLayout.xtype,
+ items: [
+ {
+ el: {
+ type: Layout.xtype,
+ cls: "bi-split-top",
+ },
+ height: 1,
+ top: 40,
+ left: 0,
+ right: 0,
+ }
+ ],
+ }
+ ];
}
_checkMin() {
diff --git a/src/widget/date/calendar/popup.month.js b/src/widget/date/calendar/popup.month.js
index 2c859c660..32c3b6f5a 100644
--- a/src/widget/date/calendar/popup.month.js
+++ b/src/widget/date/calendar/popup.month.js
@@ -1,4 +1,20 @@
-import { shortcut, Widget, extend, Controller, createWidget, Events, createItems, toPix, map, contains, getDate, LogicFactory, parseInt } from "@/core";
+import { ButtonGroup, TextItem } from "@/base";
+import {
+ CenterAdaptLayout,
+ shortcut,
+ Widget,
+ extend,
+ Controller,
+ createWidget,
+ Events,
+ createItems,
+ toPix,
+ map,
+ contains,
+ getDate,
+ LogicFactory,
+ parseInt
+} from "@/core";
/**
* 月份展示面板
@@ -9,9 +25,9 @@ import { shortcut, Widget, extend, Controller, createWidget, Events, createItems
*/
@shortcut()
export class MonthPopup extends Widget {
- static xtype = "bi.month_popup"
+ static xtype = "bi.month_popup";
- static EVENT_CHANGE = "EVENT_CHANGE"
+ static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
@@ -27,21 +43,30 @@ export class MonthPopup extends Widget {
this.selectedMonth = getDate().getMonth() + 1;
this.month = createWidget({
- type: "bi.button_group",
+ type: ButtonGroup.xtype,
element: this,
behaviors: o.behaviors,
items: createItems(this._getItems(o.allowMonths), {}),
- layouts: [LogicFactory.createLogic("table", extend({
- dynamic: true,
- }, {
- columns: 2,
- rows: 6,
- columnSize: [1 / 2, 1 / 2],
- rowSize: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT + 1,
- })), {
- type: "bi.center_adapt",
- vgap: 2,
- }],
+ layouts: [
+ LogicFactory.createLogic(
+ "table",
+ extend(
+ {
+ dynamic: true,
+ },
+ {
+ columns: 2,
+ rows: 6,
+ columnSize: [1 / 2, 1 / 2],
+ rowSize: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT + 1,
+ }
+ )
+ ),
+ {
+ type: CenterAdaptLayout.xtype,
+ vgap: 2,
+ }
+ ],
value: o.value,
});
@@ -66,21 +91,23 @@ export class MonthPopup extends Widget {
items.push(month.slice(6, 8));
items.push(month.slice(8, 10));
items.push(month.slice(10, 12));
- items = map(items, (i, item) => map(item, (j, td) => {
- return {
- type: "bi.text_item",
- cls: "bi-border-radius bi-list-item-select",
- textAlign: "center",
- whiteSpace: "nowrap",
- once: false,
- forceSelected: true,
- height: toPix(BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, 1),
- width: 30,
- value: td,
- text: td,
- disabled: !contains(m, td),
- };
- }));
+ items = map(items, (i, item) =>
+ map(item, (j, td) => {
+ return {
+ type: TextItem.xtype,
+ cls: "bi-border-radius bi-list-item-select",
+ textAlign: "center",
+ whiteSpace: "nowrap",
+ once: false,
+ forceSelected: true,
+ height: toPix(BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, 1),
+ width: 30,
+ value: td,
+ text: td,
+ disabled: !contains(m, td),
+ };
+ })
+ );
Widget.popContext();
return items;
diff --git a/src/widget/date/calendar/popup.year.js b/src/widget/date/calendar/popup.year.js
index 872f35a73..a835bfb7d 100644
--- a/src/widget/date/calendar/popup.year.js
+++ b/src/widget/date/calendar/popup.year.js
@@ -1,6 +1,18 @@
-import { shortcut, Widget, extend, createWidget, isKey, Controller, bind, isNotNull, isNotEmptyString, getDate, parseInt } from "@/core";
-import { Navigation } from "@/base";
import { YearCalendar } from "@/case";
+import { IconButton, Navigation } from "@/base";
+import {
+ shortcut,
+ Widget,
+ extend,
+ createWidget,
+ isKey,
+ Controller,
+ bind,
+ isNotNull,
+ isNotEmptyString,
+ getDate,
+ parseInt
+} from "@/core";
/**
* 年份展示面板
@@ -11,9 +23,9 @@ import { YearCalendar } from "@/case";
*/
@shortcut()
export class YearPopup extends Widget {
- static xtype = "bi.year_popup"
+ static xtype = "bi.year_popup";
- static EVENT_CHANGE = "EVENT_CHANGE"
+ static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
@@ -29,7 +41,7 @@ export class YearPopup extends Widget {
y = this._year;
const calendar = createWidget({
- type: "bi.year_calendar",
+ type: YearCalendar.xtype,
behaviors: o.behaviors,
min: o.min,
max: o.max,
@@ -39,7 +51,7 @@ export class YearPopup extends Widget {
year: y + v * 12,
});
calendar.setValue(this._year);
-
+
return calendar;
}
@@ -50,7 +62,7 @@ export class YearPopup extends Widget {
this.selectedYear = this._year = getDate().getFullYear();
this.backBtn = createWidget({
- type: "bi.icon_button",
+ type: IconButton.xtype,
cls: "pre-page-h-font",
width: 24,
height: 24,
@@ -58,7 +70,7 @@ export class YearPopup extends Widget {
});
this.preBtn = createWidget({
- type: "bi.icon_button",
+ type: IconButton.xtype,
cls: "next-page-h-font",
width: 24,
height: 24,
@@ -66,7 +78,7 @@ export class YearPopup extends Widget {
});
this.navigation = createWidget({
- type: "bi.navigation",
+ type: Navigation.xtype,
element: this,
single: true,
logic: {
diff --git a/src/widget/date/calendar/trigger.triangle.date.js b/src/widget/date/calendar/trigger.triangle.date.js
index d79b0e431..d1b013618 100644
--- a/src/widget/date/calendar/trigger.triangle.date.js
+++ b/src/widget/date/calendar/trigger.triangle.date.js
@@ -1,5 +1,5 @@
-import { shortcut, extend, createWidget } from "@/core";
-import { Trigger } from "@/base";
+import { Label, IconLabel, Trigger } from "@/base";
+import { VerticalAdaptLayout, shortcut, extend, createWidget } from "@/core";
/**
* 日期控件中的年份或月份trigger
@@ -10,7 +10,7 @@ import { Trigger } from "@/base";
*/
@shortcut()
export class DateTriangleTrigger extends Trigger {
- static xtype = "bi.date_triangle_trigger"
+ static xtype = "bi.date_triangle_trigger";
_const = {
height: 24,
@@ -30,7 +30,7 @@ export class DateTriangleTrigger extends Trigger {
const o = this.options,
c = this._const;
this.text = createWidget({
- type: "bi.label",
+ type: Label.xtype,
cls: "list-item-text",
textAlign: "right",
text: o.text,
@@ -39,15 +39,18 @@ export class DateTriangleTrigger extends Trigger {
});
createWidget({
- type: "bi.vertical_adapt",
+ type: VerticalAdaptLayout.xtype,
element: this,
- items: [{
- el: this.text,
- rgap: 5,
- }, {
- type: "bi.icon_label",
- width: 16,
- }],
+ items: [
+ {
+ el: this.text,
+ rgap: 5,
+ },
+ {
+ type: IconLabel.xtype,
+ width: 16,
+ }
+ ],
});
}
@@ -67,7 +70,5 @@ export class DateTriangleTrigger extends Trigger {
return this.item.getText();
}
- getKey() {
-
- }
+ getKey() {}
}
diff --git a/src/widget/datepane/card.static.datepane.js b/src/widget/datepane/card.static.datepane.js
index a6a469437..44c506080 100644
--- a/src/widget/datepane/card.static.datepane.js
+++ b/src/widget/datepane/card.static.datepane.js
@@ -1,18 +1,31 @@
-import { shortcut, Widget, extend, createWidget, bind, isNull, each, isNotEmptyString, getDate, getMonthDays } from "@/core";
import { DatePicker, DateCalendarPopup } from "../date/calendar";
-import { Calendar } from "@/case";
import { Navigation } from "@/base";
+import {
+ VTapeLayout,
+ AbsoluteLayout,
+ Layout,
+ shortcut,
+ Widget,
+ extend,
+ createWidget,
+ bind,
+ isNull,
+ each,
+ isNotEmptyString,
+ getDate,
+ getMonthDays
+} from "@/core";
+import { Calendar } from "@/case";
@shortcut()
export class StaticDatePaneCard extends Widget {
static xtype = "bi.static_date_pane_card";
- static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW =
- "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW";
+ static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW";
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
-
+
return extend(conf, {
baseCls: "bi-date-pane",
min: "1900-01-01", // 最小日期
@@ -35,16 +48,14 @@ export class StaticDatePaneCard extends Widget {
};
this.datePicker = createWidget({
- type: "bi.date_picker",
+ type: DatePicker.xtype,
behaviors: o.behaviors,
min: o.min,
max: o.max,
});
this.datePicker.on(DatePicker.EVENT_CHANGE, () => {
const value = this.datePicker.getValue();
- const monthDay = getMonthDays(
- getDate(value.year, value.month - 1, 1)
- );
+ const monthDay = getMonthDays(getDate(value.year, value.month - 1, 1));
let day = this.selectedTime.day || 0;
if (day > monthDay) {
day = monthDay;
@@ -54,27 +65,20 @@ export class StaticDatePaneCard extends Widget {
month: value.month,
};
day !== 0 && (this.selectedTime.day = day);
- this.calendar.setSelect(
- Calendar.getPageByDateJSON(this.selectedTime)
- );
+ this.calendar.setSelect(Calendar.getPageByDateJSON(this.selectedTime));
this.calendar.setValue(this.selectedTime);
day !== 0 && this.fireEvent(DateCalendarPopup.EVENT_CHANGE);
});
- this.datePicker.on(
- DatePicker.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW,
- () => {
- this.fireEvent(
- StaticDatePaneCard.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW
- );
- }
- );
+ this.datePicker.on(DatePicker.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW, () => {
+ this.fireEvent(StaticDatePaneCard.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
+ });
this.calendar = createWidget({
direction: "custom",
// logic: {
// dynamic: false
// },
- type: "bi.navigation",
+ type: Navigation.xtype,
tab: this.datePicker,
cardCreator: bind(this._createNav, this),
});
@@ -87,7 +91,7 @@ export class StaticDatePaneCard extends Widget {
this.setValue(o.selectedTime);
createWidget({
- type: "bi.vtape",
+ type: VTapeLayout.xtype,
element: this,
items: [
{
@@ -100,12 +104,12 @@ export class StaticDatePaneCard extends Widget {
});
createWidget({
- type: "bi.absolute",
+ type: AbsoluteLayout.xtype,
element: this,
items: [
{
el: {
- type: "bi.layout",
+ type: Layout.xtype,
cls: "bi-split-top",
},
height: 1,
@@ -120,7 +124,7 @@ export class StaticDatePaneCard extends Widget {
_createNav(v) {
const date = Calendar.getDateJSONByPage(v);
const calendar = createWidget({
- type: "bi.calendar",
+ type: Calendar.xtype,
logic: {
dynamic: false,
},
@@ -130,13 +134,13 @@ export class StaticDatePaneCard extends Widget {
month: date.month,
day: this.selectedTime.day,
});
-
+
return calendar;
}
_getNewCurrentDate() {
const today = getDate();
-
+
return {
year: today.getFullYear(),
month: today.getMonth() + 1,
diff --git a/src/widget/datepane/datepane.js b/src/widget/datepane/datepane.js
index e3bc64684..a98d87325 100644
--- a/src/widget/datepane/datepane.js
+++ b/src/widget/datepane/datepane.js
@@ -1,6 +1,20 @@
-import { shortcut, Widget, createItems, i18nText, isEmptyObject, isNull, isEmptyString, isNotEmptyObject, getDate } from "@/core";
-import { ButtonGroup, TextButton } from "@/base";
-import { DynamicDateHelper, DynamicDateCombo, DynamicDatePopup } from "../dynamicdate";
+import {
+ VTapeLayout,
+ CenterLayout,
+ shortcut,
+ Widget,
+ createItems,
+ i18nText,
+ isEmptyObject,
+ isNull,
+ isEmptyString,
+ isNotEmptyObject,
+ getDate
+} from "@/core";
+import { LinearSegment } from "@/case";
+import { Tab, TextButton, ButtonGroup } from "@/base";
+import { StaticDatePaneCard } from "./card.static.datepane";
+import { DynamicDateCard, DynamicDateHelper, DynamicDateCombo, DynamicDatePopup } from "../dynamicdate";
@shortcut()
export class DynamicDatePane extends Widget {
@@ -16,140 +30,167 @@ export class DynamicDatePane extends Widget {
minDate: "1900-01-01",
maxDate: "2099-12-31",
supportDynamic: true,
- }
+ };
render() {
const o = this.options;
-
+
return {
- type: "bi.vtape",
- items: [{
- el: {
- type: "bi.linear_segment",
- invisible: !o.supportDynamic,
- cls: "bi-split-bottom",
- height: 30,
- items: createItems([{
- text: i18nText("BI-Multi_Date_YMD"),
- value: DynamicDatePane.Static,
- }, {
- text: i18nText("BI-Basic_Dynamic_Title"),
- value: DynamicDatePane.Dynamic,
- }], {
- textAlign: "center",
- }),
- listeners: [{
- eventName: ButtonGroup.EVENT_CHANGE,
- action: () => {
- let date;
- const value = this.switcher.getValue()[0];
- this.dateTab.setSelect(value);
- switch (value) {
- case DynamicDatePane.Static:
- date = DynamicDateHelper.getCalculation(this.dynamicPane.getValue());
- this.ymd.setValue({
- year: date.getFullYear(),
- month: date.getMonth() + 1,
- day: date.getDate(),
- });
- break;
- case DynamicDatePane.Dynamic:
- this.dynamicPane.setValue({
- year: 0,
- });
- break;
- default:
- break;
+ type: VTapeLayout.xtype,
+ items: [
+ {
+ el: {
+ type: LinearSegment.xtype,
+ invisible: !o.supportDynamic,
+ cls: "bi-split-bottom",
+ height: 30,
+ items: createItems(
+ [
+ {
+ text: i18nText("BI-Multi_Date_YMD"),
+ value: DynamicDatePane.Static,
+ },
+ {
+ text: i18nText("BI-Basic_Dynamic_Title"),
+ value: DynamicDatePane.Dynamic,
+ }
+ ],
+ {
+ textAlign: "center",
}
- this.fireEvent(DynamicDatePane.EVENT_CHANGE);
- },
- }],
- ref: _ref => {
- this.switcher = _ref;
- },
- },
- height: o.supportDynamic ? 30 : 0,
- }, {
- type: "bi.tab",
- ref: _ref => {
- this.dateTab = _ref;
- },
- showIndex: DynamicDatePane.Static,
- cardCreator: v => {
- switch (v) {
- case DynamicDatePane.Static:
- return {
- type: "bi.static_date_pane_card",
- min: o.minDate,
- max: o.maxDate,
- behaviors: o.behaviors,
- listeners: [{
- eventName: "EVENT_CHANGE",
+ ),
+ listeners: [
+ {
+ eventName: ButtonGroup.EVENT_CHANGE,
action: () => {
+ let date;
+ const value = this.switcher.getValue()[0];
+ this.dateTab.setSelect(value);
+ switch (value) {
+ case DynamicDatePane.Static:
+ date = DynamicDateHelper.getCalculation(this.dynamicPane.getValue());
+ this.ymd.setValue({
+ year: date.getFullYear(),
+ month: date.getMonth() + 1,
+ day: date.getDate(),
+ });
+ break;
+ case DynamicDatePane.Dynamic:
+ this.dynamicPane.setValue({
+ year: 0,
+ });
+ break;
+ default:
+ break;
+ }
this.fireEvent(DynamicDatePane.EVENT_CHANGE);
},
- }, {
- eventName: "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW",
- action: () => {
- this.fireEvent(DynamicDatePane.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
- },
- }],
- ref: _ref => {
- this.ymd = _ref;
- },
- };
- case DynamicDatePane.Dynamic:
- default:
- return {
- type: "bi.vtape",
- items: [{
- type: "bi.dynamic_date_card",
+ }
+ ],
+ ref: _ref => {
+ this.switcher = _ref;
+ },
+ },
+ height: o.supportDynamic ? 30 : 0,
+ },
+ {
+ type: Tab.xtype,
+ ref: _ref => {
+ this.dateTab = _ref;
+ },
+ showIndex: DynamicDatePane.Static,
+ cardCreator: v => {
+ switch (v) {
+ case DynamicDatePane.Static:
+ return {
+ type: StaticDatePaneCard.xtype,
min: o.minDate,
max: o.maxDate,
+ behaviors: o.behaviors,
+ listeners: [
+ {
+ eventName: "EVENT_CHANGE",
+ action: () => {
+ this.fireEvent(DynamicDatePane.EVENT_CHANGE);
+ },
+ },
+ {
+ eventName: "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW",
+ action: () => {
+ this.fireEvent(DynamicDatePane.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
+ },
+ }
+ ],
ref: _ref => {
- this.dynamicPane = _ref;
+ this.ymd = _ref;
},
- }, {
- el: {
- type: "bi.center",
- items: [{
- type: "bi.text_button",
- cls: "bi-high-light bi-border-top",
- shadow: true,
- text: i18nText("BI-Basic_Clear"),
- textHeight: 23,
- listeners: [{
- eventName: TextButton.EVENT_CHANGE,
- action: () => {
- this.setValue();
- this.fireEvent(DynamicDatePane.EVENT_CHANGE);
- },
- }],
- }, {
- type: "bi.text_button",
- cls: "bi-border-left bi-high-light bi-border-top",
- textHeight: 23,
- shadow: true,
- 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.EVENT_CHANGE);
- } else {
- this.fireEvent(DynamicDatePane.EVENT_CHANGE);
+ };
+ case DynamicDatePane.Dynamic:
+ default:
+ return {
+ type: VTapeLayout.xtype,
+ items: [
+ {
+ type: DynamicDateCard.xtype,
+ min: o.minDate,
+ max: o.maxDate,
+ ref: _ref => {
+ this.dynamicPane = _ref;
+ },
+ },
+ {
+ el: {
+ type: CenterLayout.xtype,
+ items: [
+ {
+ type: TextButton.xtype,
+ cls: "bi-high-light bi-border-top",
+ shadow: true,
+ text: i18nText("BI-Basic_Clear"),
+ textHeight: 23,
+ listeners: [
+ {
+ eventName: TextButton.EVENT_CHANGE,
+ action: () => {
+ this.setValue();
+ this.fireEvent(DynamicDatePane.EVENT_CHANGE);
+ },
+ }
+ ],
+ },
+ {
+ type: TextButton.xtype,
+ cls: "bi-border-left bi-high-light bi-border-top",
+ textHeight: 23,
+ shadow: true,
+ 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.EVENT_CHANGE
+ );
+ } else {
+ this.fireEvent(DynamicDatePane.EVENT_CHANGE);
+ }
+ },
+ }
+ ],
}
- },
- }],
- }],
- },
- height: 24,
- }],
- };
- }
- },
- }],
+ ],
+ },
+ height: 24,
+ }
+ ],
+ };
+ }
+ },
+ }
+ ],
};
}
@@ -212,7 +253,7 @@ export class DynamicDatePane extends Widget {
getValue() {
const type = this.dateTab.getSelect();
-
+
return {
type,
value: type === DynamicDatePane.Static ? this.dateTab.getValue() : this.dynamicPane.getValue(),
diff --git a/src/widget/datetime/datetime.combo.js b/src/widget/datetime/datetime.combo.js
index 1d279cb39..f332a31ac 100644
--- a/src/widget/datetime/datetime.combo.js
+++ b/src/widget/datetime/datetime.combo.js
@@ -1,10 +1,11 @@
-import { shortcut, extend, getDate, isNotNull, createWidget } from "@/core";
-import { Single, Combo, IconButton } from "@/base";
+import { DateTimeTrigger } from "./datetime.trigger";
import { DateTimePopup } from "./datetime.popup";
+import { Combo, IconButton, Single } from "@/base";
+import { HTapeLayout, shortcut, extend, getDate, isNotNull, createWidget } from "@/core";
@shortcut()
export class DateTimeCombo extends Single {
- static xtype = "bi.date_time_combo"
+ static xtype = "bi.date_time_combo";
constants = {
popupHeight: 290,
@@ -14,14 +15,16 @@ export class DateTimeCombo extends Single {
iconWidth: 24,
};
- static EVENT_CANCEL = "EVENT_CANCEL"
- static EVENT_CONFIRM = "EVENT_CONFIRM"
- static EVENT_CHANGE = "EVENT_CHANGE"
- static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"
+ static EVENT_CANCEL = "EVENT_CANCEL";
+ static EVENT_CONFIRM = "EVENT_CONFIRM";
+ static EVENT_CHANGE = "EVENT_CHANGE";
+ static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
_defaultConfig(conf) {
return extend(super._defaultConfig(...arguments), {
- baseCls: `bi-date-time-combo bi-focus-shadow ${conf.simple ? "bi-border-bottom" : "bi-border bi-border-radius"}`,
+ baseCls: `bi-date-time-combo bi-focus-shadow ${
+ conf.simple ? "bi-border-bottom" : "bi-border bi-border-radius"
+ }`,
width: 200,
height: 24,
minDate: "1900-01-01",
@@ -33,16 +36,18 @@ export class DateTimeCombo extends Single {
super._init(...arguments);
const opts = this.options;
const date = getDate();
- this.storeValue = isNotNull(opts.value) ? opts.value : {
- year: date.getFullYear(),
- month: date.getMonth() + 1,
- day: date.getDate(),
- hour: date.getHours(),
- minute: date.getMinutes(),
- second: date.getSeconds(),
- };
+ this.storeValue = isNotNull(opts.value)
+ ? opts.value
+ : {
+ year: date.getFullYear(),
+ month: date.getMonth() + 1,
+ day: date.getDate(),
+ hour: date.getHours(),
+ minute: date.getMinutes(),
+ second: date.getSeconds(),
+ };
this.trigger = createWidget({
- type: "bi.date_time_trigger",
+ type: DateTimeTrigger.xtype,
height: opts.height,
min: opts.minDate,
max: opts.maxDate,
@@ -50,7 +55,7 @@ export class DateTimeCombo extends Single {
});
this.popup = createWidget({
- type: "bi.date_time_popup",
+ type: DateTimePopup.xtype,
behaviors: opts.behaviors,
min: opts.minDate,
max: opts.maxDate,
@@ -70,7 +75,7 @@ export class DateTimeCombo extends Single {
this.fireEvent(DateTimeCombo.EVENT_CONFIRM);
});
this.combo = createWidget({
- type: "bi.combo",
+ type: Combo.xtype,
container: opts.container,
toggle: false,
isNeedAdjustHeight: false,
@@ -83,7 +88,7 @@ export class DateTimeCombo extends Single {
stopPropagation: false,
},
// DEC-4250 和复选下拉一样,点击不收起
- hideChecker (e) {
+ hideChecker(e) {
return triggerBtn.element.find(e.target).length === 0;
},
});
@@ -93,7 +98,7 @@ export class DateTimeCombo extends Single {
});
const triggerBtn = createWidget({
- type: "bi.icon_button",
+ type: IconButton.xtype,
cls: "bi-trigger-icon-button date-font",
width: this.constants.iconWidth,
height: opts.height,
@@ -107,7 +112,7 @@ export class DateTimeCombo extends Single {
});
createWidget({
- type: "bi.htape",
+ type: HTapeLayout.xtype,
columnSize: ["", this.constants.iconWidth],
element: this,
items: [this.combo, triggerBtn],
diff --git a/src/widget/datetime/datetime.popup.js b/src/widget/datetime/datetime.popup.js
index bafe42b11..999e10779 100644
--- a/src/widget/datetime/datetime.popup.js
+++ b/src/widget/datetime/datetime.popup.js
@@ -1,14 +1,26 @@
-import { shortcut, Widget, extend, createWidget, i18nText, isNull, getDate } from "@/core";
import { TextButton } from "@/base";
import { DateCalendarPopup } from "../date/calendar";
+import {
+ GridLayout,
+ VTapeLayout,
+ CenterAdaptLayout,
+ shortcut,
+ Widget,
+ extend,
+ createWidget,
+ i18nText,
+ isNull,
+ getDate
+} from "@/core";
+import { DynamicDateTimeSelect } from "../dynamicdatetime";
@shortcut()
export class DateTimePopup extends Widget {
- static xtype = "bi.date_time_popup"
+ static xtype = "bi.date_time_popup";
- static BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE"
- static BUTTON_CANCEL_EVENT_CHANGE = "BUTTON_CANCEL_EVENT_CHANGE"
- static CALENDAR_EVENT_CHANGE = "CALENDAR_EVENT_CHANGE"
+ static BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE";
+ static BUTTON_CANCEL_EVENT_CHANGE = "BUTTON_CANCEL_EVENT_CHANGE";
+ static CALENDAR_EVENT_CHANGE = "CALENDAR_EVENT_CHANGE";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
@@ -22,7 +34,7 @@ export class DateTimePopup extends Widget {
super._init(...arguments);
const opts = this.options;
this.cancelButton = createWidget({
- type: "bi.text_button",
+ type: TextButton.xtype,
cls: "multidate-popup-button bi-border-top bi-border-right",
shadow: true,
text: i18nText("BI-Basic_Cancel"),
@@ -32,7 +44,7 @@ export class DateTimePopup extends Widget {
});
this.okButton = createWidget({
- type: "bi.text_button",
+ type: TextButton.xtype,
cls: "multidate-popup-button bi-border-top",
shadow: true,
text: i18nText("BI-Basic_OK"),
@@ -42,7 +54,7 @@ export class DateTimePopup extends Widget {
});
this.dateCombo = createWidget({
- type: "bi.date_calendar_popup",
+ type: DateCalendarPopup.xtype,
behaviors: opts.behaviors,
min: this.options.min,
max: this.options.max,
@@ -52,32 +64,36 @@ export class DateTimePopup extends Widget {
});
this.dateButton = createWidget({
- type: "bi.grid",
- items: [
- [this.cancelButton, this.okButton]
- ],
+ type: GridLayout.xtype,
+ items: [[this.cancelButton, this.okButton]],
});
createWidget({
element: this,
- type: "bi.vtape",
- items: [{
- el: this.dateCombo,
- }, {
- el: {
- type: "bi.center_adapt",
- cls: "bi-split-top",
- items: [{
- type: "bi.dynamic_date_time_select",
- ref: _ref => {
- this.timeSelect = _ref;
- },
- }],
+ type: VTapeLayout.xtype,
+ items: [
+ {
+ el: this.dateCombo,
},
- height: 50,
- }, {
- el: this.dateButton,
- height: 30,
- }],
+ {
+ el: {
+ type: CenterAdaptLayout.xtype,
+ cls: "bi-split-top",
+ items: [
+ {
+ type: DynamicDateTimeSelect.xtype,
+ ref: _ref => {
+ this.timeSelect = _ref;
+ },
+ }
+ ],
+ },
+ height: 50,
+ },
+ {
+ el: this.dateButton,
+ height: 30,
+ }
+ ],
});
this.setValue(opts.value);
}
@@ -112,10 +128,13 @@ export class DateTimePopup extends Widget {
}
getValue() {
- return extend({
- year: this.dateCombo.getValue().year,
- month: this.dateCombo.getValue().month,
- day: this.dateCombo.getValue().day,
- }, this.timeSelect.getValue());
+ return extend(
+ {
+ year: this.dateCombo.getValue().year,
+ month: this.dateCombo.getValue().month,
+ day: this.dateCombo.getValue().day,
+ },
+ this.timeSelect.getValue()
+ );
}
}
diff --git a/src/widget/datetime/datetime.trigger.js b/src/widget/datetime/datetime.trigger.js
index c8ea49714..cdbd7896c 100644
--- a/src/widget/datetime/datetime.trigger.js
+++ b/src/widget/datetime/datetime.trigger.js
@@ -1,19 +1,9 @@
-import {
- shortcut,
- extend,
- createWidget,
- isNull,
- getDate,
- print
-} from "@/core";
-import {
- Trigger
-} from "@/base";
-
+import { Label, Trigger } from "@/base";
+import { HTapeLayout, shortcut, extend, createWidget, isNull, getDate, print } from "@/core";
@shortcut()
export class DateTimeTrigger extends Trigger {
- static xtype = "bi.date_time_trigger"
+ static xtype = "bi.date_time_trigger";
_const = {
hgap: 4,
@@ -35,7 +25,7 @@ export class DateTimeTrigger extends Trigger {
const o = this.options,
c = this._const;
this.text = createWidget({
- type: "bi.label",
+ type: Label.xtype,
textAlign: "left",
height: o.height,
width: o.width,
@@ -43,14 +33,17 @@ export class DateTimeTrigger extends Trigger {
});
createWidget({
- type: "bi.htape",
+ type: HTapeLayout.xtype,
element: this,
- items: [{
- el: this.text,
- }, {
- el: createWidget(),
- width: this._const.iconWidth,
- }],
+ items: [
+ {
+ el: this.text,
+ },
+ {
+ el: createWidget(),
+ width: this._const.iconWidth,
+ }
+ ],
});
this.setValue(o.value);
}
diff --git a/src/widget/datetimepane/card.static.datetimepane.js b/src/widget/datetimepane/card.static.datetimepane.js
index 910ed91f8..24f706cc0 100644
--- a/src/widget/datetimepane/card.static.datetimepane.js
+++ b/src/widget/datetimepane/card.static.datetimepane.js
@@ -1,18 +1,32 @@
-import { shortcut, Widget, extend, getDate, createWidget, bind, isNull, each, isNotEmptyString, getMonthDays } from "@/core";
import { DatePicker, DateCalendarPopup } from "../date/calendar";
-import { Calendar } from "@/case";
import { Navigation } from "@/base";
+import {
+ VTapeLayout,
+ AbsoluteLayout,
+ Layout,
+ shortcut,
+ Widget,
+ extend,
+ getDate,
+ createWidget,
+ bind,
+ isNull,
+ each,
+ isNotEmptyString,
+ getMonthDays
+} from "@/core";
+import { Calendar } from "@/case";
import { DynamicDateTimeSelect } from "../dynamicdatetime/dynamicdatetime.timeselect";
@shortcut()
export class StaticDateTimePaneCard extends Widget {
- static xtype = "bi.static_date_time_pane_card"
+ static xtype = "bi.static_date_time_pane_card";
- static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW"
+ static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW";
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
-
+
return extend(conf, {
baseCls: "bi-date-time-pane",
min: "1900-01-01", // 最小日期
@@ -35,7 +49,7 @@ export class StaticDateTimePaneCard extends Widget {
};
this.datePicker = createWidget({
- type: "bi.date_picker",
+ type: DatePicker.xtype,
behaviors: o.behaviors,
min: o.min,
max: o.max,
@@ -66,7 +80,7 @@ export class StaticDateTimePaneCard extends Widget {
// logic: {
// dynamic: false
// },
- type: "bi.navigation",
+ type: Navigation.xtype,
tab: this.datePicker,
cardCreator: bind(this._createNav, this),
});
@@ -78,44 +92,52 @@ export class StaticDateTimePaneCard extends Widget {
});
createWidget({
- type: "bi.vtape",
+ type: VTapeLayout.xtype,
element: this,
hgap: 10,
- items: [{
- el: this.datePicker,
- height: 40,
- }, this.calendar, {
- el: {
- type: "bi.dynamic_date_time_select",
- cls: "bi-split-top",
- ref: _ref => {
- this.timeSelect = _ref;
- },
- listeners: [{
- eventName: DynamicDateTimeSelect.EVENT_CONFIRM,
- action: () => {
- this.selectedTime = extend(this.calendar.getValue(), this.timeSelect.getValue());
- this.fireEvent("EVENT_CHANGE");
- },
- }],
+ items: [
+ {
+ el: this.datePicker,
+ height: 40,
},
- height: 40,
- }],
+ this.calendar,
+ {
+ el: {
+ type: DynamicDateTimeSelect.xtype,
+ cls: "bi-split-top",
+ ref: _ref => {
+ this.timeSelect = _ref;
+ },
+ listeners: [
+ {
+ eventName: DynamicDateTimeSelect.EVENT_CONFIRM,
+ action: () => {
+ this.selectedTime = extend(this.calendar.getValue(), this.timeSelect.getValue());
+ this.fireEvent("EVENT_CHANGE");
+ },
+ }
+ ],
+ },
+ height: 40,
+ }
+ ],
});
createWidget({
- type: "bi.absolute",
+ type: AbsoluteLayout.xtype,
element: this,
- items: [{
- el: {
- type: "bi.layout",
- cls: "bi-split-top",
- },
- height: 1,
- top: 40,
- left: 0,
- right: 0,
- }],
+ items: [
+ {
+ el: {
+ type: Layout.xtype,
+ cls: "bi-split-top",
+ },
+ height: 1,
+ top: 40,
+ left: 0,
+ right: 0,
+ }
+ ],
});
this.setValue(o.selectedTime);
}
@@ -123,7 +145,7 @@ export class StaticDateTimePaneCard extends Widget {
_createNav(v) {
const date = Calendar.getDateJSONByPage(v);
const calendar = createWidget({
- type: "bi.calendar",
+ type: Calendar.xtype,
logic: {
dynamic: false,
},
@@ -133,13 +155,13 @@ export class StaticDateTimePaneCard extends Widget {
month: date.month,
day: this.selectedTime.day,
});
-
+
return calendar;
}
_getNewCurrentDate() {
const today = getDate();
-
+
return {
year: today.getFullYear(),
month: today.getMonth() + 1,
diff --git a/src/widget/datetimepane/datetimepane.js b/src/widget/datetimepane/datetimepane.js
index f806b0f4d..9bad2963e 100644
--- a/src/widget/datetimepane/datetimepane.js
+++ b/src/widget/datetimepane/datetimepane.js
@@ -1,17 +1,31 @@
-import { shortcut, Widget, createItems, i18nText, isNull, isEmptyObject, isEmptyString, isNotEmptyObject, getDate } from "@/core";
-import { ButtonGroup, TextButton } from "@/base";
+import {
+ VTapeLayout,
+ CenterLayout,
+ shortcut,
+ Widget,
+ createItems,
+ i18nText,
+ isNull,
+ isEmptyObject,
+ isEmptyString,
+ isNotEmptyObject,
+ getDate
+} from "@/core";
+import { LinearSegment } from "@/case";
+import { Tab, TextButton, ButtonGroup } from "@/base";
+import { StaticDateTimePaneCard } from "./card.static.datetimepane";
+import { DynamicDateCard, DynamicDateCombo, DynamicDateHelper } from "../dynamicdate";
import { DynamicDatePane } from "../datepane";
-import { DynamicDateCombo, DynamicDateHelper } from "../dynamicdate";
@shortcut()
export class DynamicDateTimePane extends Widget {
- static xtype = "bi.dynamic_date_time_pane"
+ static xtype = "bi.dynamic_date_time_pane";
- static EVENT_CHANGE = "EVENT_CHANGE"
- static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW"
+ static EVENT_CHANGE = "EVENT_CHANGE";
+ static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW";
- static Static = 1
- static Dynamic = 2
+ static Static = 1;
+ static Dynamic = 2;
props = {
baseCls: "bi-dynamic-date-pane",
@@ -22,136 +36,163 @@ export class DynamicDateTimePane extends Widget {
render() {
const o = this.options;
-
+
return {
- type: "bi.vtape",
- items: [{
- el: {
- type: "bi.linear_segment",
- invisible: !o.supportDynamic,
- cls: "bi-split-bottom",
- height: 30,
- items: createItems([{
- text: i18nText("BI-Multi_Date_YMD"),
- value: DynamicDateTimePane.Static,
- }, {
- text: i18nText("BI-Basic_Dynamic_Title"),
- value: DynamicDateTimePane.Dynamic,
- }], {
- textAlign: "center",
- }),
- listeners: [{
- eventName: ButtonGroup.EVENT_CHANGE,
- action: () => {
- const value = this.switcher.getValue()[0];
- let date;
- this.dateTab.setSelect(value);
- switch (value) {
- case DynamicDateTimePane.Static:
- date = DynamicDateHelper.getCalculation(this.dynamicPane.getValue());
- this.ymd.setValue({
- year: date.getFullYear(),
- month: date.getMonth() + 1,
- day: date.getDate(),
- });
- break;
- case DynamicDateTimePane.Dynamic:
- this.dynamicPane.setValue({
- year: 0,
- });
- break;
- default:
- break;
+ type: VTapeLayout.xtype,
+ items: [
+ {
+ el: {
+ type: LinearSegment.xtype,
+ invisible: !o.supportDynamic,
+ cls: "bi-split-bottom",
+ height: 30,
+ items: createItems(
+ [
+ {
+ text: i18nText("BI-Multi_Date_YMD"),
+ value: DynamicDateTimePane.Static,
+ },
+ {
+ text: i18nText("BI-Basic_Dynamic_Title"),
+ value: DynamicDateTimePane.Dynamic,
+ }
+ ],
+ {
+ textAlign: "center",
}
- this.fireEvent(DynamicDateTimePane.EVENT_CHANGE);
- },
- }],
- ref: _ref => {
- this.switcher = _ref;
- },
- },
- height: o.supportDynamic ? 30 : 0,
- }, {
- type: "bi.tab",
- ref: _ref => {
- this.dateTab = _ref;
- },
- showIndex: DynamicDateTimePane.Static,
- cardCreator: v => {
- switch (v) {
- case DynamicDateTimePane.Static:
- return {
- type: "bi.static_date_time_pane_card",
- min: o.minDate,
- max: o.maxDate,
- behaviors: o.behaviors,
- listeners: [{
- eventName: "EVENT_CHANGE",
+ ),
+ listeners: [
+ {
+ eventName: ButtonGroup.EVENT_CHANGE,
action: () => {
+ const value = this.switcher.getValue()[0];
+ let date;
+ this.dateTab.setSelect(value);
+ switch (value) {
+ case DynamicDateTimePane.Static:
+ date = DynamicDateHelper.getCalculation(this.dynamicPane.getValue());
+ this.ymd.setValue({
+ year: date.getFullYear(),
+ month: date.getMonth() + 1,
+ day: date.getDate(),
+ });
+ break;
+ case DynamicDateTimePane.Dynamic:
+ this.dynamicPane.setValue({
+ year: 0,
+ });
+ break;
+ default:
+ break;
+ }
this.fireEvent(DynamicDateTimePane.EVENT_CHANGE);
},
- }, {
- eventName: "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW",
- action: () => {
- this.fireEvent(DynamicDateTimePane.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
- },
- }],
- ref: _ref => {
- this.ymd = _ref;
- },
- };
- case DynamicDateTimePane.Dynamic:
- default:
- return {
- type: "bi.vtape",
- items: [{
- type: "bi.dynamic_date_card",
+ }
+ ],
+ ref: _ref => {
+ this.switcher = _ref;
+ },
+ },
+ height: o.supportDynamic ? 30 : 0,
+ },
+ {
+ type: Tab.xtype,
+ ref: _ref => {
+ this.dateTab = _ref;
+ },
+ showIndex: DynamicDateTimePane.Static,
+ cardCreator: v => {
+ switch (v) {
+ case DynamicDateTimePane.Static:
+ return {
+ type: StaticDateTimePaneCard.xtype,
min: o.minDate,
max: o.maxDate,
+ behaviors: o.behaviors,
+ listeners: [
+ {
+ eventName: "EVENT_CHANGE",
+ action: () => {
+ this.fireEvent(DynamicDateTimePane.EVENT_CHANGE);
+ },
+ },
+ {
+ eventName: "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW",
+ action: () => {
+ this.fireEvent(DynamicDateTimePane.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
+ },
+ }
+ ],
ref: _ref => {
- this.dynamicPane = _ref;
+ this.ymd = _ref;
},
- }, {
- el: {
- type: "bi.center",
- items: [{
- type: "bi.text_button",
- cls: "bi-high-light bi-border-top",
- shadow: true,
- text: i18nText("BI-Basic_Clear"),
- textHeight: 23,
- listeners: [{
- eventName: TextButton.EVENT_CHANGE,
- action: () => {
- this.setValue();
- this.fireEvent(DynamicDatePane.EVENT_CHANGE);
- },
- }],
- }, {
- type: "bi.text_button",
- cls: "bi-border-left bi-high-light bi-border-top",
- textHeight: 23,
- shadow: true,
- 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(DynamicDatePane.EVENT_CHANGE);
- } else {
- this.fireEvent(DynamicDatePane.EVENT_CHANGE);
+ };
+ case DynamicDateTimePane.Dynamic:
+ default:
+ return {
+ type: VTapeLayout.xtype,
+ items: [
+ {
+ type: DynamicDateCard.xtype,
+ min: o.minDate,
+ max: o.maxDate,
+ ref: _ref => {
+ this.dynamicPane = _ref;
+ },
+ },
+ {
+ el: {
+ type: CenterLayout.xtype,
+ items: [
+ {
+ type: TextButton.xtype,
+ cls: "bi-high-light bi-border-top",
+ shadow: true,
+ text: i18nText("BI-Basic_Clear"),
+ textHeight: 23,
+ listeners: [
+ {
+ eventName: TextButton.EVENT_CHANGE,
+ action: () => {
+ this.setValue();
+ this.fireEvent(DynamicDatePane.EVENT_CHANGE);
+ },
+ }
+ ],
+ },
+ {
+ type: TextButton.xtype,
+ cls: "bi-border-left bi-high-light bi-border-top",
+ textHeight: 23,
+ shadow: true,
+ 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(
+ DynamicDatePane.EVENT_CHANGE
+ );
+ } else {
+ this.fireEvent(DynamicDatePane.EVENT_CHANGE);
+ }
+ },
+ }
+ ],
}
- },
- }],
- }],
- },
- height: 24,
- }],
- };
- }
- },
- }],
+ ],
+ },
+ height: 24,
+ }
+ ],
+ };
+ }
+ },
+ }
+ ],
};
}
diff --git a/src/widget/downlist/combo.downlist.js b/src/widget/downlist/combo.downlist.js
index eb4c9e636..4b8a9294b 100644
--- a/src/widget/downlist/combo.downlist.js
+++ b/src/widget/downlist/combo.downlist.js
@@ -3,7 +3,6 @@ import { DownListPopup } from "./popup.downlist";
import { Combo } from "@/base";
import { IconTrigger } from "@/case";
-
function transformItems(items) {
if (!items) return items;
let result = cloneDeep(items);
@@ -26,7 +25,7 @@ function transformItems(items) {
}
});
});
-
+
return result;
}
@@ -93,21 +92,14 @@ export class DownListCombo extends Widget {
{
eventName: DownListPopup.EVENT_CHANGE,
action: value => {
- this.fireEvent(
- DownListCombo.EVENT_CHANGE,
- value
- );
+ this.fireEvent(DownListCombo.EVENT_CHANGE, value);
this.downlistcombo.hideView();
},
},
{
eventName: DownListPopup.EVENT_SON_VALUE_CHANGE,
action: (value, fatherValue) => {
- this.fireEvent(
- DownListCombo.EVENT_SON_VALUE_CHANGE,
- value,
- fatherValue
- );
+ this.fireEvent(DownListCombo.EVENT_SON_VALUE_CHANGE, value, fatherValue);
this.downlistcombo.hideView();
},
}
diff --git a/src/widget/downlist/group.downlist.js b/src/widget/downlist/group.downlist.js
index 2d06f83e0..ee1109938 100644
--- a/src/widget/downlist/group.downlist.js
+++ b/src/widget/downlist/group.downlist.js
@@ -1,62 +1,56 @@
-import {
- shortcut,
- Widget,
- extend,
- createWidget,
- Controller,
- Events
-} from "@/core";
+import { ButtonTree } from "@/base";
+import { VerticalLayout, shortcut, Widget, extend, createWidget, Controller, Events } from "@/core";
@shortcut()
export class DownListGroup extends Widget {
- static xtype = "bi.down_list_group";
-
- constants = { iconCls: "check-mark-ha-font" };
-
- static EVENT_CHANGE = "EVENT_CHANGE";
-
- _defaultConfig() {
- return extend(super._defaultConfig(...arguments), {
- baseCls: "bi-down-list-group",
- items: [
- {
- el: {},
- }
- ],
- });
- }
-
- _init() {
- super._init(...arguments);
- const o = this.options;
-
- this.downlistgroup = createWidget({
- element: this,
- type: "bi.button_tree",
- items: o.items,
- chooseType: 0, // 0单选,1多选
- layouts: [
- {
- type: "bi.vertical",
- hgap: 0,
- vgap: 0,
- }
- ],
- value: o.value,
- });
- this.downlistgroup.on(Controller.EVENT_CHANGE, (type, ...args) => {
- this.fireEvent(Controller.EVENT_CHANGE, type, ...args);
- if (type === Events.CLICK) {
- this.fireEvent(DownListGroup.EVENT_CHANGE, type, ...args);
- }
- });
- }
-
- getValue() {
- return this.downlistgroup.getValue();
- }
-
- setValue(v) {
- this.downlistgroup.setValue(v);
- }
+ static xtype = "bi.down_list_group";
+
+ constants = { iconCls: "check-mark-ha-font" };
+
+ static EVENT_CHANGE = "EVENT_CHANGE";
+
+ _defaultConfig() {
+ return extend(super._defaultConfig(...arguments), {
+ baseCls: "bi-down-list-group",
+ items: [
+ {
+ el: {},
+ }
+ ],
+ });
+ }
+
+ _init() {
+ super._init(...arguments);
+ const o = this.options;
+
+ this.downlistgroup = createWidget({
+ element: this,
+ type: ButtonTree.xtype,
+ items: o.items,
+ chooseType: 0, // 0单选,1多选
+ layouts: [
+ {
+ type: VerticalLayout.xtype,
+ hgap: 0,
+ vgap: 0,
+ }
+ ],
+ value: o.value,
+ });
+ this.downlistgroup.on(Controller.EVENT_CHANGE, (type, ...args) => {
+ this.fireEvent(Controller.EVENT_CHANGE, type, ...args);
+ if (type === Events.CLICK) {
+ this.fireEvent(DownListGroup.EVENT_CHANGE, type, ...args);
+ }
+ });
+ }
+
+ getValue() {
+ return this.downlistgroup.getValue();
+ }
+
+ setValue(v) {
+ this.downlistgroup.setValue(v);
+ }
}
diff --git a/src/widget/downlist/index.js b/src/widget/downlist/index.js
index 07a86df06..f27a18682 100644
--- a/src/widget/downlist/index.js
+++ b/src/widget/downlist/index.js
@@ -1,5 +1,5 @@
-export { DownListGroup } from "./group.downlist";
-export { DownListItem } from "./item.downlist";
-export { DownListGroupItem } from "./item.downlistgroup";
-export { DownListPopup } from "./popup.downlist";
-export { DownListCombo } from "./combo.downlist";
+export { DownListGroup } from "./group.downlist";
+export { DownListItem } from "./item.downlist";
+export { DownListGroupItem } from "./item.downlistgroup";
+export { DownListPopup } from "./popup.downlist";
+export { DownListCombo } from "./combo.downlist";
diff --git a/src/widget/downlist/item.downlist.js b/src/widget/downlist/item.downlist.js
index 1a1598490..2adf328c1 100644
--- a/src/widget/downlist/item.downlist.js
+++ b/src/widget/downlist/item.downlist.js
@@ -1,125 +1,121 @@
-import { shortcut, extend, createWidget, isPlainObject, LogicFactory, Direction } from "@/core";
-import { BasicButton } from "@/base";
+import { Label, Icon, BasicButton } from "@/base";
+import { CenterAdaptLayout, shortcut, extend, createWidget, isPlainObject, LogicFactory, Direction } from "@/core";
@shortcut()
export class DownListItem extends BasicButton {
- static xtype = "bi.down_list_item";
-
- static EVENT_CHANGE = "EVENT_CHANGE";
-
- _defaultConfig() {
- const conf = super._defaultConfig(...arguments);
-
- return extend(conf, {
- baseCls: "bi-down-list-item bi-list-item-active",
- cls: "",
- height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
- logic: {
- dynamic: true,
- },
- selected: false,
- iconHeight: null,
- iconWidth: null,
- textHgap: 0,
- textVgap: 0,
- textLgap: 0,
- textRgap: 0,
- });
- }
-
- _init() {
- super._init(...arguments);
- const o = this.options;
- this.text = createWidget({
- type: "bi.label",
- cls: "list-item-text",
- textAlign: "left",
- hgap: o.textHgap,
- vgap: o.textVgap,
- lgap: o.textLgap,
- rgap: o.textRgap,
- text: o.text,
- value: o.value,
- keyword: o.keyword,
- height: o.height,
- });
-
- const icon = isPlainObject(o.icon)
- ? o.icon
- : {
- type: "bi.icon",
- width: o.iconWidth,
- height: o.iconHeight,
- };
-
- this.icon = createWidget({
- type: "bi.center_adapt",
- width: 36,
- height: o.height,
- items: [
- {
- el: icon,
- }
- ],
- });
-
- createWidget(
- extend(
- {
- element: this,
- },
- LogicFactory.createLogic(
- LogicFactory.createLogicTypeByDirection(Direction.Left),
- extend(o.logic, {
- items: LogicFactory.createLogicItemsByDirection(
- Direction.Left,
- this.icon,
- this.text
- ),
- })
- )
- )
- );
- }
-
- setValue() {
- if (!this.isReadOnly()) {
- this.text.setValue(...arguments);
- }
- }
-
- getValue() {
- return this.text.getValue();
- }
-
- setText() {
- this.text.setText(...arguments);
- }
-
- getText() {
- return this.text.getText();
- }
-
- doClick() {
- super.doClick(...arguments);
- if (this.isValid()) {
- this.fireEvent(DownListItem.EVENT_CHANGE, this.getValue(), this);
- }
- }
-
- doRedMark() {
- this.text.doRedMark(...arguments);
- }
-
- unRedMark() {
- this.text.unRedMark(...arguments);
- }
-
- doHighLight() {
- this.text.doHighLight(...arguments);
- }
-
- unHighLight() {
- this.text.unHighLight(...arguments);
- }
+ static xtype = "bi.down_list_item";
+
+ static EVENT_CHANGE = "EVENT_CHANGE";
+
+ _defaultConfig() {
+ const conf = super._defaultConfig(...arguments);
+
+ return extend(conf, {
+ baseCls: "bi-down-list-item bi-list-item-active",
+ cls: "",
+ height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
+ logic: {
+ dynamic: true,
+ },
+ selected: false,
+ iconHeight: null,
+ iconWidth: null,
+ textHgap: 0,
+ textVgap: 0,
+ textLgap: 0,
+ textRgap: 0,
+ });
+ }
+
+ _init() {
+ super._init(...arguments);
+ const o = this.options;
+ this.text = createWidget({
+ type: Label.xtype,
+ cls: "list-item-text",
+ textAlign: "left",
+ hgap: o.textHgap,
+ vgap: o.textVgap,
+ lgap: o.textLgap,
+ rgap: o.textRgap,
+ text: o.text,
+ value: o.value,
+ keyword: o.keyword,
+ height: o.height,
+ });
+
+ const icon = isPlainObject(o.icon)
+ ? o.icon
+ : {
+ type: Icon.xtype,
+ width: o.iconWidth,
+ height: o.iconHeight,
+ };
+
+ this.icon = createWidget({
+ type: CenterAdaptLayout.xtype,
+ width: 36,
+ height: o.height,
+ items: [
+ {
+ el: icon,
+ }
+ ],
+ });
+
+ createWidget(
+ extend(
+ {
+ element: this,
+ },
+ LogicFactory.createLogic(
+ LogicFactory.createLogicTypeByDirection(Direction.Left),
+ extend(o.logic, {
+ items: LogicFactory.createLogicItemsByDirection(Direction.Left, this.icon, this.text),
+ })
+ )
+ )
+ );
+ }
+
+ setValue() {
+ if (!this.isReadOnly()) {
+ this.text.setValue(...arguments);
+ }
+ }
+
+ getValue() {
+ return this.text.getValue();
+ }
+
+ setText() {
+ this.text.setText(...arguments);
+ }
+
+ getText() {
+ return this.text.getText();
+ }
+
+ doClick() {
+ super.doClick(...arguments);
+ if (this.isValid()) {
+ this.fireEvent(DownListItem.EVENT_CHANGE, this.getValue(), this);
+ }
+ }
+
+ doRedMark() {
+ this.text.doRedMark(...arguments);
+ }
+
+ unRedMark() {
+ this.text.unRedMark(...arguments);
+ }
+
+ doHighLight() {
+ this.text.doHighLight(...arguments);
+ }
+
+ unHighLight() {
+ this.text.unHighLight(...arguments);
+ }
}
diff --git a/src/widget/downlist/item.downlistgroup.js b/src/widget/downlist/item.downlistgroup.js
index d2c9d14a7..8bc1d6094 100644
--- a/src/widget/downlist/item.downlistgroup.js
+++ b/src/widget/downlist/item.downlistgroup.js
@@ -1,4 +1,7 @@
+import { Label, IconButton, BasicButton } from "@/base";
import {
+ CenterAdaptLayout,
+ HorizontalFillLayout,
shortcut,
extend,
createWidget,
@@ -10,132 +13,130 @@ import {
first,
BlankSplitChar
} from "@/core";
-import { BasicButton } from "@/base";
@shortcut()
export class DownListGroupItem extends BasicButton {
- static xtype = "bi.down_list_group_item";
-
- static EVENT_CHANGE = "EVENT_CHANGE";
-
- _defaultConfig() {
- const conf = super._defaultConfig(...arguments);
-
- return extend(conf, {
- baseCls: `${conf.baseCls || ""} bi-down-list-group-item`,
- logic: {
- dynamic: false,
- },
- // invalid: true,
- iconCls1: "dot-e-font",
- icon: "",
- iconCls2: "pull-right-e-font",
- });
- }
-
- render() {
- const o = this.options;
- this.text = createWidget({
- type: "bi.label",
- cls: "list-group-item-text",
- textAlign: "left",
- text: o.text,
- value: o.value,
- height: o.height,
- });
-
- if (isPlainObject(o.icon)) {
- this.icon1 = createWidget({
- width: 36,
- height: o.height,
- type: "bi.center_adapt",
- items: [o.icon],
- });
- } else {
- this.icon1 = createWidget({
- type: "bi.icon_button",
- cls: o.iconCls1,
- width: 36,
- height: o.height,
- iconHeight: o.iconHeight,
- iconWidth: 36,
- disableSelected: true,
- selected: this._digest(o.value),
- });
- }
-
- this.icon2 = createWidget({
- type: "bi.icon_button",
- cls: o.iconCls2,
- width: 24,
- forceNotSelected: true,
- });
-
- this.element.hover(
- () => {
- if (this.isEnabled()) {
- this.hover();
- }
- },
- () => {
- if (this.isEnabled()) {
- this.dishover();
- }
- }
- );
-
- return {
- type: "bi.horizontal_fill",
- columnSize: [36, "fill", 24],
- items: [this.icon1, this.text, this.icon2],
- };
- }
-
- _getLevel() {
- const child = first(this.options.childValues);
-
- return isNotNull(child) ? (`${child}`).split(BlankSplitChar).length : 0;
- }
-
- _digest(v) {
- const o = this.options;
- v = isArray(v) ? v : [v];
- const level = this._getLevel();
-
- return any(v, (idx, value) => contains(
- o.childValues,
- (`${value}`).split(BlankSplitChar).slice(0, level).join(BlankSplitChar)
- ));
- }
-
- hover() {
- super.hover(...arguments);
- this.icon1.element.addClass("hover");
- this.icon2.element.addClass("hover");
- }
-
- dishover() {
- super.dishover(...arguments);
- this.icon1.element.removeClass("hover");
- this.icon2.element.removeClass("hover");
- }
-
- doClick() {
- super.doClick(...arguments);
- if (this.isValid()) {
- this.fireEvent(DownListGroupItem.EVENT_CHANGE, this.getValue());
- }
- }
-
- doRedMark() {
- this.text.doRedMark(...arguments);
- }
-
- unRedMark() {
- this.text.unRedMark(...arguments);
- }
-
- setValue(v) {
- this.icon1.setSelected && this.icon1.setSelected(this._digest(v));
- }
+ static xtype = "bi.down_list_group_item";
+
+ static EVENT_CHANGE = "EVENT_CHANGE";
+
+ _defaultConfig() {
+ const conf = super._defaultConfig(...arguments);
+
+ return extend(conf, {
+ baseCls: `${conf.baseCls || ""} bi-down-list-group-item`,
+ logic: {
+ dynamic: false,
+ },
+ // invalid: true,
+ iconCls1: "dot-e-font",
+ icon: "",
+ iconCls2: "pull-right-e-font",
+ });
+ }
+
+ render() {
+ const o = this.options;
+ this.text = createWidget({
+ type: Label.xtype,
+ cls: "list-group-item-text",
+ textAlign: "left",
+ text: o.text,
+ value: o.value,
+ height: o.height,
+ });
+
+ if (isPlainObject(o.icon)) {
+ this.icon1 = createWidget({
+ width: 36,
+ height: o.height,
+ type: CenterAdaptLayout.xtype,
+ items: [o.icon],
+ });
+ } else {
+ this.icon1 = createWidget({
+ type: IconButton.xtype,
+ cls: o.iconCls1,
+ width: 36,
+ height: o.height,
+ iconHeight: o.iconHeight,
+ iconWidth: 36,
+ disableSelected: true,
+ selected: this._digest(o.value),
+ });
+ }
+
+ this.icon2 = createWidget({
+ type: IconButton.xtype,
+ cls: o.iconCls2,
+ width: 24,
+ forceNotSelected: true,
+ });
+
+ this.element.hover(
+ () => {
+ if (this.isEnabled()) {
+ this.hover();
+ }
+ },
+ () => {
+ if (this.isEnabled()) {
+ this.dishover();
+ }
+ }
+ );
+
+ return {
+ type: HorizontalFillLayout.xtype,
+ columnSize: [36, "fill", 24],
+ items: [this.icon1, this.text, this.icon2],
+ };
+ }
+
+ _getLevel() {
+ const child = first(this.options.childValues);
+
+ return isNotNull(child) ? `${child}`.split(BlankSplitChar).length : 0;
+ }
+
+ _digest(v) {
+ const o = this.options;
+ v = isArray(v) ? v : [v];
+ const level = this._getLevel();
+
+ return any(v, (idx, value) =>
+ contains(o.childValues, `${value}`.split(BlankSplitChar).slice(0, level).join(BlankSplitChar))
+ );
+ }
+
+ hover() {
+ super.hover(...arguments);
+ this.icon1.element.addClass("hover");
+ this.icon2.element.addClass("hover");
+ }
+
+ dishover() {
+ super.dishover(...arguments);
+ this.icon1.element.removeClass("hover");
+ this.icon2.element.removeClass("hover");
+ }
+
+ doClick() {
+ super.doClick(...arguments);
+ if (this.isValid()) {
+ this.fireEvent(DownListGroupItem.EVENT_CHANGE, this.getValue());
+ }
+ }
+
+ doRedMark() {
+ this.text.doRedMark(...arguments);
+ }
+
+ unRedMark() {
+ this.text.unRedMark(...arguments);
+ }
+
+ setValue(v) {
+ this.icon1.setSelected && this.icon1.setSelected(this._digest(v));
+ }
}
diff --git a/src/widget/downlist/popup.downlist.js b/src/widget/downlist/popup.downlist.js
index 9ca7e0edd..984e78273 100644
--- a/src/widget/downlist/popup.downlist.js
+++ b/src/widget/downlist/popup.downlist.js
@@ -1,4 +1,7 @@
+import { ButtonTree, Pane } from "@/base";
import {
+ VerticalLayout,
+ Layout,
shortcut,
extend,
createWidget,
@@ -13,320 +16,315 @@ import {
some,
deepClone
} from "@/core";
-import { Pane, ButtonTree } from "@/base";
+import { DownListGroup } from "./group.downlist";
@shortcut()
export class DownListPopup extends Pane {
- static xtype = "bi.down_list_popup";
+ static xtype = "bi.down_list_popup";
- constants = {
- nextIcon: "pull-right-e-font",
- height: 24,
- iconHeight: 12,
- iconWidth: 12,
- hgap: 0,
- vgap: 0,
- border: 1,
- };
+ constants = {
+ nextIcon: "pull-right-e-font",
+ height: 24,
+ iconHeight: 12,
+ iconWidth: 12,
+ hgap: 0,
+ vgap: 0,
+ border: 1,
+ };
- static EVENT_CHANGE = "EVENT_CHANGE";
- static EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE";
+ static EVENT_CHANGE = "EVENT_CHANGE";
+ static EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE";
- _defaultConfig() {
- const conf = super._defaultConfig(...arguments);
-
- return extend(conf, {
- baseCls: "bi-down-list-popup",
- items: [],
- chooseType: Selection.Multi,
- });
- }
+ _defaultConfig() {
+ const conf = super._defaultConfig(...arguments);
- _init() {
- super._init(...arguments);
- this.singleValues = [];
- this.childValueMap = {};
- this.fatherValueMap = {};
- this.items = [];
- const o = this.options,
- children = this._createPopupItems(o.items);
- this.popup = createWidget({
- type: "bi.button_tree",
- items: createItems(
- children,
- {},
- {
- adjustLength: -2,
- }
- ),
- layouts: [
- {
- type: "bi.vertical",
- hgap: this.constants.hgap,
- vgap: this.constants.vgap,
- }
- ],
- value: this._digest(o.value),
- chooseType: o.chooseType,
- });
+ return extend(conf, {
+ baseCls: "bi-down-list-popup",
+ items: [],
+ chooseType: Selection.Multi,
+ });
+ }
- this.popup.on(ButtonTree.EVENT_CHANGE, (value, object) => {
- let changedValue = value;
- if (isNotNull(this.childValueMap[value])) {
- changedValue = this.childValueMap[value];
- this.fireEvent(
- DownListPopup.EVENT_SON_VALUE_CHANGE,
- changedValue,
- this.fatherValueMap[value]
- );
- } else {
- this.fireEvent(DownListPopup.EVENT_CHANGE, changedValue, object);
- }
+ _init() {
+ super._init(...arguments);
+ this.singleValues = [];
+ this.childValueMap = {};
+ this.fatherValueMap = {};
+ this.items = [];
+ const o = this.options,
+ children = this._createPopupItems(o.items);
+ this.popup = createWidget({
+ type: ButtonTree.xtype,
+ items: createItems(
+ children,
+ {},
+ {
+ adjustLength: -2,
+ }
+ ),
+ layouts: [
+ {
+ type: VerticalLayout.xtype,
+ hgap: this.constants.hgap,
+ vgap: this.constants.vgap,
+ }
+ ],
+ value: this._digest(o.value),
+ chooseType: o.chooseType,
+ });
- if (!contains(this.singleValues, changedValue)) {
- const item = this.getValue();
- const result = [];
- each(item, (i, valueObject) => {
- if (valueObject.value !== changedValue) {
- result.push(valueObject);
- }
- });
- this.setValue(result);
- }
- });
+ this.popup.on(ButtonTree.EVENT_CHANGE, (value, object) => {
+ let changedValue = value;
+ if (isNotNull(this.childValueMap[value])) {
+ changedValue = this.childValueMap[value];
+ this.fireEvent(DownListPopup.EVENT_SON_VALUE_CHANGE, changedValue, this.fatherValueMap[value]);
+ } else {
+ this.fireEvent(DownListPopup.EVENT_CHANGE, changedValue, object);
+ }
- createWidget({
- type: "bi.vertical",
- element: this,
- items: [this.popup],
- vgap: 5,
- });
- }
+ if (!contains(this.singleValues, changedValue)) {
+ const item = this.getValue();
+ const result = [];
+ each(item, (i, valueObject) => {
+ if (valueObject.value !== changedValue) {
+ result.push(valueObject);
+ }
+ });
+ this.setValue(result);
+ }
+ });
- _createPopupItems(items) {
- const result = [];
- // 不能修改populate进来的item的引用
- each(items, (i, it) => {
- const item_done = {
- type: "bi.down_list_group",
- items: [],
- };
+ createWidget({
+ type: VerticalLayout.xtype,
+ element: this,
+ items: [this.popup],
+ vgap: 5,
+ });
+ }
- const storeItem = [];
+ _createPopupItems(items) {
+ const result = [];
+ // 不能修改populate进来的item的引用
+ each(items, (i, it) => {
+ const item_done = {
+ type: DownListGroup.xtype,
+ items: [],
+ };
- each(it, (i, sourceItem) => {
- const item = extend({}, sourceItem);
- if (isNotEmptyArray(sourceItem.children) && !isEmpty(sourceItem.el)) {
- item.type = "bi.combo_group";
- // popup未初始化返回的是options中的value, 在经过buttontree的getValue concat之后,无法区分值来自options
- // 还是item自身, 这边控制defaultInit为true来避免这个问题
- item.isDefaultInit = true;
- item.cls = "down-list-group";
- item.trigger = "hover";
- item.isNeedAdjustWidth = false;
- item.el = sourceItem.el;
- item.el.title = sourceItem.el.title || sourceItem.el.text;
- item.el.type = "bi.down_list_group_item";
- item.el.logic = {
- dynamic: true,
- };
- item.el.height =
- sourceItem.el.height || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT;
- item.el.iconCls2 = this.constants.nextIcon;
- item.popup = {
- lgap: 1,
- el: {
- type: "bi.button_tree",
- chooseType: 0,
- layouts: [
- {
- type: "bi.vertical",
- }
- ],
- },
- innerVgap: 5,
- maxHeight: 378,
- };
- this._createChildren(item, sourceItem);
- } else {
- item.type = sourceItem.type || "bi.down_list_item";
- item.title = sourceItem.title || sourceItem.text;
- item.textRgap = 10;
- item.isNeedAdjustWidth = false;
- item.logic = {
- dynamic: true,
- };
- }
- const el_done = {};
- el_done.el = item;
- item_done.items.push(el_done);
- storeItem.push(item);
- });
- if (this._isGroup(item_done.items)) {
- each(item_done.items, (i, item) => {
- this.singleValues.push(item.el.value);
- });
- }
+ const storeItem = [];
- result.push(item_done);
- this.items.push(storeItem);
- if (this._needSpliter(i, items.length)) {
- const spliter_container = createWidget({
- type: "bi.vertical",
- items: [
- {
- el: {
- type: "bi.layout",
- cls: "bi-down-list-spliter bi-split-top cursor-pointer",
- height: 0,
- },
- }
- ],
- cls: "bi-down-list-spliter-container cursor-pointer",
- vgap: 5,
- hgap: 12,
- });
- result.push(spliter_container);
- }
- });
-
- return result;
- }
+ each(it, (i, sourceItem) => {
+ const item = extend({}, sourceItem);
+ if (isNotEmptyArray(sourceItem.children) && !isEmpty(sourceItem.el)) {
+ item.type = "bi.combo_group";
+ // popup未初始化返回的是options中的value, 在经过buttontree的getValue concat之后,无法区分值来自options
+ // 还是item自身, 这边控制defaultInit为true来避免这个问题
+ item.isDefaultInit = true;
+ item.cls = "down-list-group";
+ item.trigger = "hover";
+ item.isNeedAdjustWidth = false;
+ item.el = sourceItem.el;
+ item.el.title = sourceItem.el.title || sourceItem.el.text;
+ item.el.type = "bi.down_list_group_item";
+ item.el.logic = {
+ dynamic: true,
+ };
+ item.el.height = sourceItem.el.height || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT;
+ item.el.iconCls2 = this.constants.nextIcon;
+ item.popup = {
+ lgap: 1,
+ el: {
+ type: ButtonTree.xtype,
+ chooseType: 0,
+ layouts: [
+ {
+ type: VerticalLayout.xtype,
+ }
+ ],
+ },
+ innerVgap: 5,
+ maxHeight: 378,
+ };
+ this._createChildren(item, sourceItem);
+ } else {
+ item.type = sourceItem.type || "bi.down_list_item";
+ item.title = sourceItem.title || sourceItem.text;
+ item.textRgap = 10;
+ item.isNeedAdjustWidth = false;
+ item.logic = {
+ dynamic: true,
+ };
+ }
+ const el_done = {};
+ el_done.el = item;
+ item_done.items.push(el_done);
+ storeItem.push(item);
+ });
+ if (this._isGroup(item_done.items)) {
+ each(item_done.items, (i, item) => {
+ this.singleValues.push(item.el.value);
+ });
+ }
- _createChildren(targetItem, sourceItem) {
- targetItem.el.childValues = [];
- targetItem.items = targetItem.children = [];
- each(sourceItem.children, (i, child) => {
- const item = extend({}, child);
- const fatherValue = deepClone(targetItem.el.value);
- const childValue = deepClone(item.value);
- this.singleValues.push(item.value);
- item.type = item.type || "bi.down_list_item";
- item.extraCls = " child-down-list-item";
- item.title = item.title || item.text;
- item.textRgap = 10;
- item.isNeedAdjustWidth = false;
- item.logic = {
- dynamic: true,
- };
- item.father = fatherValue;
- item.childValue = item.value;
- this.fatherValueMap[this._createChildValue(fatherValue, childValue)] =
- fatherValue;
- this.childValueMap[this._createChildValue(fatherValue, childValue)] =
- childValue;
- item.value = this._createChildValue(fatherValue, childValue);
- targetItem.el.childValues.push(item.value);
- targetItem.items.push(item);
- });
- }
+ result.push(item_done);
+ this.items.push(storeItem);
+ if (this._needSpliter(i, items.length)) {
+ const spliter_container = createWidget({
+ type: VerticalLayout.xtype,
+ items: [
+ {
+ el: {
+ type: Layout.xtype,
+ cls: "bi-down-list-spliter bi-split-top cursor-pointer",
+ height: 0,
+ },
+ }
+ ],
+ cls: "bi-down-list-spliter-container cursor-pointer",
+ vgap: 5,
+ hgap: 12,
+ });
+ result.push(spliter_container);
+ }
+ });
- _isGroup(i) {
- return i.length > 1;
- }
+ return result;
+ }
- _needSpliter(i, itemLength) {
- return i < itemLength - 1;
- }
+ _createChildren(targetItem, sourceItem) {
+ targetItem.el.childValues = [];
+ targetItem.items = targetItem.children = [];
+ each(sourceItem.children, (i, child) => {
+ const item = extend({}, child);
+ const fatherValue = deepClone(targetItem.el.value);
+ const childValue = deepClone(item.value);
+ this.singleValues.push(item.value);
+ item.type = item.type || "bi.down_list_item";
+ item.extraCls = " child-down-list-item";
+ item.title = item.title || item.text;
+ item.textRgap = 10;
+ item.isNeedAdjustWidth = false;
+ item.logic = {
+ dynamic: true,
+ };
+ item.father = fatherValue;
+ item.childValue = item.value;
+ this.fatherValueMap[this._createChildValue(fatherValue, childValue)] = fatherValue;
+ this.childValueMap[this._createChildValue(fatherValue, childValue)] = childValue;
+ item.value = this._createChildValue(fatherValue, childValue);
+ targetItem.el.childValues.push(item.value);
+ targetItem.items.push(item);
+ });
+ }
- _createChildValue(fatherValue, childValue) {
- return fatherValue + BI.BlankSplitChar + childValue;
- }
+ _isGroup(i) {
+ return i.length > 1;
+ }
- _digest(valueItem) {
- const valueArray = [];
- each(valueItem, (i, item) => {
- let value;
- if (isNotNull(item.childValue)) {
- value = this._createChildValue(item.value, item.childValue);
- } else {
- value = item.value;
- }
- valueArray.push(value);
- });
-
- return valueArray;
- }
+ _needSpliter(i, itemLength) {
+ return i < itemLength - 1;
+ }
- _checkValues(values) {
- const value = [];
- each(this.items, (idx, itemGroup) => {
- each(itemGroup, (id, item) => {
- if (isNotNull(item.children)) {
- const childValues = map(item.children, "value");
- const v = joinValue(childValues, values[idx]);
- if (isNotEmptyString(v)) {
- value.push(v);
- }
- } else {
- if (item.value === values[idx][0]) {
- value.push(values[idx][0]);
- }
- }
- });
- });
-
- return value;
+ _createChildValue(fatherValue, childValue) {
+ return fatherValue + BI.BlankSplitChar + childValue;
+ }
- function joinValue(sources, targets) {
- let value = "";
- some(sources, (idx, s) => some(targets, (id, t) => {
- if (s === t) {
- value = s;
-
- return true;
- }
- }));
-
- return value;
- }
- }
+ _digest(valueItem) {
+ const valueArray = [];
+ each(valueItem, (i, item) => {
+ let value;
+ if (isNotNull(item.childValue)) {
+ value = this._createChildValue(item.value, item.childValue);
+ } else {
+ value = item.value;
+ }
+ valueArray.push(value);
+ });
- populate(items) {
- super.populate(...arguments);
- this.items = [];
- this.childValueMap = {};
- this.fatherValueMap = {};
- this.singleValues = [];
- const children = this._createPopupItems(items);
- const popupItem = createItems(
- children,
- {},
- {
- adjustLength: -2,
- }
- );
- this.popup.populate(popupItem);
- }
+ return valueArray;
+ }
- setValue(valueItem) {
- this.popup.setValue(this._digest(valueItem));
- }
+ _checkValues(values) {
+ const value = [];
+ each(this.items, (idx, itemGroup) => {
+ each(itemGroup, (id, item) => {
+ if (isNotNull(item.children)) {
+ const childValues = map(item.children, "value");
+ const v = joinValue(childValues, values[idx]);
+ if (isNotEmptyString(v)) {
+ value.push(v);
+ }
+ } else {
+ if (item.value === values[idx][0]) {
+ value.push(values[idx][0]);
+ }
+ }
+ });
+ });
- _getValue() {
- const v = [];
- each(this.popup.getAllButtons(), (i, item) => {
- i % 2 === 0 && v.push(item.getValue());
- });
-
- return v;
- }
+ return value;
- getValue() {
- const result = [];
- const values = this._checkValues(this._getValue());
- each(values, (i, value) => {
- const valueItem = {};
- if (isNotNull(this.childValueMap[value])) {
- const fartherValue = this.fatherValueMap[value];
- valueItem.childValue = this.childValueMap[value];
- valueItem.value = fartherValue;
- } else {
- valueItem.value = value;
- }
- result.push(valueItem);
- });
-
- return result;
- }
+ function joinValue(sources, targets) {
+ let value = "";
+ some(sources, (idx, s) =>
+ some(targets, (id, t) => {
+ if (s === t) {
+ value = s;
+
+ return true;
+ }
+ })
+ );
+
+ return value;
+ }
+ }
+
+ populate(items) {
+ super.populate(...arguments);
+ this.items = [];
+ this.childValueMap = {};
+ this.fatherValueMap = {};
+ this.singleValues = [];
+ const children = this._createPopupItems(items);
+ const popupItem = createItems(
+ children,
+ {},
+ {
+ adjustLength: -2,
+ }
+ );
+ this.popup.populate(popupItem);
+ }
+
+ setValue(valueItem) {
+ this.popup.setValue(this._digest(valueItem));
+ }
+
+ _getValue() {
+ const v = [];
+ each(this.popup.getAllButtons(), (i, item) => {
+ i % 2 === 0 && v.push(item.getValue());
+ });
+
+ return v;
+ }
+
+ getValue() {
+ const result = [];
+ const values = this._checkValues(this._getValue());
+ each(values, (i, value) => {
+ const valueItem = {};
+ if (isNotNull(this.childValueMap[value])) {
+ const fartherValue = this.fatherValueMap[value];
+ valueItem.childValue = this.childValueMap[value];
+ valueItem.value = fartherValue;
+ } else {
+ valueItem.value = value;
+ }
+ result.push(valueItem);
+ });
+
+ return result;
+ }
}
diff --git a/src/widget/dynamicdate/dynamicdate.caculate.js b/src/widget/dynamicdate/dynamicdate.caculate.js
index e94718d82..245471cfd 100644
--- a/src/widget/dynamicdate/dynamicdate.caculate.js
+++ b/src/widget/dynamicdate/dynamicdate.caculate.js
@@ -1,53 +1,86 @@
-import { isNotNull, parseInt, getDate, i18nText, size, getOffsetQuarter, getOffsetMonth, getOffsetDate, getLastDateOfMonth, getWeekStartDate, getWeekEndDate, getQuarterStartDate, getQuarterEndDate, print } from "@/core";
+import {
+ isNotNull,
+ parseInt,
+ getDate,
+ i18nText,
+ size,
+ getOffsetQuarter,
+ getOffsetMonth,
+ getOffsetDate,
+ getLastDateOfMonth,
+ getWeekStartDate,
+ getWeekEndDate,
+ getQuarterStartDate,
+ getQuarterEndDate,
+ print
+} from "@/core";
import { DynamicDateCard } from "./dynamicdate.card";
export const DynamicDateHelper = {
- getCalculation (obj) {
+ getCalculation(obj) {
const date = getDate();
return this.getCalculationByDate(date, obj);
},
- getDescription (obj) {
+ getDescription(obj) {
let value = "";
let endText = "";
if (isNotNull(obj.year)) {
if (parseInt(obj.year) !== 0) {
- value += Math.abs(obj.year) + i18nText("BI-Basic_Year") + (obj.year < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
+ value +=
+ Math.abs(obj.year) +
+ i18nText("BI-Basic_Year") +
+ (obj.year < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
}
endText = getPositionText(i18nText("BI-Basic_Year"), obj.position);
}
if (isNotNull(obj.quarter)) {
if (parseInt(obj.quarter) !== 0) {
- value += Math.abs(obj.quarter) + i18nText("BI-Basic_Single_Quarter") + (obj.quarter < 0 ? i18nText("BI-Basic_Front") : 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"));
}
endText = getPositionText(i18nText("BI-Basic_Single_Quarter"), obj.position);
}
if (isNotNull(obj.month)) {
if (parseInt(obj.month) !== 0) {
- value += Math.abs(obj.month) + i18nText("BI-Basic_Month") + (obj.month < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
+ value +=
+ Math.abs(obj.month) +
+ i18nText("BI-Basic_Month") +
+ (obj.month < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
}
endText = getPositionText(i18nText("BI-Basic_Month"), obj.position);
}
if (isNotNull(obj.week)) {
if (parseInt(obj.week) !== 0) {
- value += Math.abs(obj.week) + i18nText("BI-Basic_Week") + (obj.week < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
+ value +=
+ Math.abs(obj.week) +
+ i18nText("BI-Basic_Week") +
+ (obj.week < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
}
endText = getPositionText(i18nText("BI-Basic_Week"), obj.position);
}
if (isNotNull(obj.day)) {
if (parseInt(obj.day) !== 0) {
- value += Math.abs(obj.day) + i18nText("BI-Basic_Day") + (obj.day < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
+ value +=
+ Math.abs(obj.day) +
+ i18nText("BI-Basic_Day") +
+ (obj.day < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
}
endText = size(obj) === 1 ? getPositionText(i18nText("BI-Basic_Month"), obj.position) : "";
}
if (isNotNull(obj.workDay) && parseInt(obj.workDay) !== 0) {
- value += Math.abs(obj.workDay) + i18nText("BI-Basic_Work_Day") + (obj.workDay < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
+ value +=
+ Math.abs(obj.workDay) +
+ i18nText("BI-Basic_Work_Day") +
+ (obj.workDay < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
}
-
+
return value + endText;
- function getPositionText (baseText, position) {
+ function getPositionText(baseText, position) {
switch (position) {
case DynamicDateCard.OFFSET.BEGIN:
return baseText + i18nText("BI-Basic_Begin_Start");
@@ -60,9 +93,9 @@ export const DynamicDateHelper = {
}
},
- getCalculationByDate (date, obj) {
+ getCalculationByDate(date, obj) {
if (isNotNull(obj.year)) {
- date = getDate((date.getFullYear() + parseInt(obj.year)), date.getMonth(), date.getDate());
+ date = getDate(date.getFullYear() + parseInt(obj.year), date.getMonth(), date.getDate());
}
if (isNotNull(obj.quarter)) {
date = getOffsetQuarter(date, parseInt(obj.quarter));
@@ -97,23 +130,29 @@ export const DynamicDateHelper = {
return getDate(date.getFullYear(), date.getMonth(), date.getDate());
},
- getBeginDate (date, obj) {
+ getBeginDate(date, obj) {
if (isNotNull(obj.day)) {
- return obj.position === DynamicDateCard.OFFSET.BEGIN ? getDate(date.getFullYear(), date.getMonth(), 1) : getDate(date.getFullYear(), date.getMonth(), (getLastDateOfMonth(date)).getDate());
+ return obj.position === DynamicDateCard.OFFSET.BEGIN
+ ? getDate(date.getFullYear(), date.getMonth(), 1)
+ : getDate(date.getFullYear(), date.getMonth(), getLastDateOfMonth(date).getDate());
}
if (isNotNull(obj.week)) {
return obj.position === DynamicDateCard.OFFSET.BEGIN ? getWeekStartDate(date) : getWeekEndDate(date);
}
if (isNotNull(obj.month)) {
- return obj.position === DynamicDateCard.OFFSET.BEGIN ? getDate(date.getFullYear(), date.getMonth(), 1) : getDate(date.getFullYear(), date.getMonth(), (getLastDateOfMonth(date)).getDate());
+ return obj.position === DynamicDateCard.OFFSET.BEGIN
+ ? getDate(date.getFullYear(), date.getMonth(), 1)
+ : getDate(date.getFullYear(), date.getMonth(), getLastDateOfMonth(date).getDate());
}
if (isNotNull(obj.quarter)) {
return obj.position === DynamicDateCard.OFFSET.BEGIN ? getQuarterStartDate(date) : getQuarterEndDate(date);
}
if (isNotNull(obj.year)) {
- return obj.position === DynamicDateCard.OFFSET.BEGIN ? getDate(date.getFullYear(), 0, 1) : getDate(date.getFullYear(), 11, 31);
+ return obj.position === DynamicDateCard.OFFSET.BEGIN
+ ? getDate(date.getFullYear(), 0, 1)
+ : getDate(date.getFullYear(), 11, 31);
}
-
+
return date;
},
};
diff --git a/src/widget/dynamicdate/dynamicdate.card.js b/src/widget/dynamicdate/dynamicdate.card.js
index 4b0ce2649..e70d2bdd1 100644
--- a/src/widget/dynamicdate/dynamicdate.card.js
+++ b/src/widget/dynamicdate/dynamicdate.card.js
@@ -1,12 +1,33 @@
-import { shortcut, Widget, i18nText, createItems, each, isNotNull, map, has, bind, last, extend, checkDateVoid, isNull, isNotEmptyString, parseDateTime, any } from "@/core";
-import { ButtonGroup, Bubbles } from "@/base";
-import { MultiSelectItem } from "@/case";
+import {
+ VerticalLayout,
+ FloatLeftLayout,
+ VerticalAdaptLayout,
+ shortcut,
+ Widget,
+ i18nText,
+ createItems,
+ each,
+ isNotNull,
+ map,
+ has,
+ bind,
+ last,
+ extend,
+ checkDateVoid,
+ isNull,
+ isNotEmptyString,
+ parseDateTime,
+ any
+} from "@/core";
+import { Label, ButtonGroup, Bubbles } from "@/base";
+import { MultiSelectItem, TextValueCombo } from "@/case";
+import { DynamicDateParamItem } from "./dynamicdate.param.item";
import { DynamicDateHelper } from "./dynamicdate.caculate";
@shortcut()
export class DynamicDateCard extends Widget {
static xtype = "bi.dynamic_date_card";
-
+
static TYPE = {
YEAR: 1,
QUARTER: 2,
@@ -27,132 +48,168 @@ export class DynamicDateCard extends Widget {
render() {
this.position = DynamicDateCard.OFFSET.CURRENT;
-
+
return {
- type: "bi.vertical",
- items: [{
- el: {
- type: "bi.label",
- text: i18nText("BI-Multi_Date_Relative_Current_Time"),
- textAlign: "left",
- lgap: 10,
- },
- tgap: 10,
- bgap: 5,
- }, {
- type: "bi.button_group",
- ref: _ref => {
- this.checkgroup = _ref;
+ type: VerticalLayout.xtype,
+ items: [
+ {
+ el: {
+ type: Label.xtype,
+ text: i18nText("BI-Multi_Date_Relative_Current_Time"),
+ textAlign: "left",
+ lgap: 10,
+ },
+ tgap: 10,
+ bgap: 5,
},
- chooseType: ButtonGroup.CHOOSE_TYPE_MULTI,
- lgap: 4,
- value: [DynamicDateCard.TYPE.YEAR],
- items: createItems([{
- text: i18nText("BI-Basic_Year"),
- value: DynamicDateCard.TYPE.YEAR,
- }, {
- text: i18nText("BI-Basic_Single_Quarter"),
- value: DynamicDateCard.TYPE.QUARTER,
- }, {
- text: i18nText("BI-Basic_Month"),
- value: DynamicDateCard.TYPE.MONTH,
- }, {
- text: i18nText("BI-Basic_Week"),
- value: DynamicDateCard.TYPE.WEEK,
- }, {
- text: i18nText("BI-Basic_Day"),
- value: DynamicDateCard.TYPE.DAY,
- }], {
- type: "bi.multi_select_item",
- logic: {
- dynamic: true,
+ {
+ type: ButtonGroup.xtype,
+ ref: _ref => {
+ this.checkgroup = _ref;
},
- iconWrapperWidth: 26,
- }),
- layouts: [{
- type: "bi.left",
- rgap: 4,
- }],
- listeners: [{
- eventName: ButtonGroup.EVENT_CHANGE,
- action: () => {
- const value = this.checkgroup.getValue();
- if (value.length !== 0) {
- this.workDayBox.setSelected(false);
- }
-
- const plainValue = {};
- each(this.resultPane.getAllButtons(), (idx, button) => {
- const value = button.getValue();
- if (isNotNull(value.dateType)) {
- plainValue[value.dateType] = {
- value: value.value,
- offset: value.offset,
- };
- }
- });
- this.resultPane.populate(this._getParamJson(map(this.checkgroup.getValue(), (idx, v) => {
- const obj = {
- dateType: v,
- };
- if (has(plainValue, v)) {
- obj.value = plainValue[v].value;
- obj.offset = plainValue[v].offset;
+ chooseType: ButtonGroup.CHOOSE_TYPE_MULTI,
+ lgap: 4,
+ value: [DynamicDateCard.TYPE.YEAR],
+ items: createItems(
+ [
+ {
+ text: i18nText("BI-Basic_Year"),
+ value: DynamicDateCard.TYPE.YEAR,
+ },
+ {
+ text: i18nText("BI-Basic_Single_Quarter"),
+ value: DynamicDateCard.TYPE.QUARTER,
+ },
+ {
+ text: i18nText("BI-Basic_Month"),
+ value: DynamicDateCard.TYPE.MONTH,
+ },
+ {
+ text: i18nText("BI-Basic_Week"),
+ value: DynamicDateCard.TYPE.WEEK,
+ },
+ {
+ text: i18nText("BI-Basic_Day"),
+ value: DynamicDateCard.TYPE.DAY,
}
-
- return obj;
- })));
- this.position = DynamicDateCard.OFFSET.CURRENT;
- this.fireEvent("EVENT_CHANGE");
- },
- }],
- }, {
- type: "bi.vertical_adapt",
- lgap: 2,
- items: [{
- el: {
- type: "bi.multi_select_item",
- iconWrapperWidth: 26,
- ref: _ref => {
- this.workDayBox = _ref;
- },
- logic: {
- dynamic: true,
- },
- text: i18nText("BI-Basic_Work_Day"),
- value: DynamicDateCard.TYPE.WORK_DAY,
- listeners: [{
- eventName: MultiSelectItem.EVENT_CHANGE,
+ ],
+ {
+ type: MultiSelectItem.xtype,
+ logic: {
+ dynamic: true,
+ },
+ iconWrapperWidth: 26,
+ }
+ ),
+ layouts: [
+ {
+ type: FloatLeftLayout.xtype,
+ rgap: 4,
+ }
+ ],
+ listeners: [
+ {
+ eventName: ButtonGroup.EVENT_CHANGE,
action: () => {
- if (this.workDayBox.isSelected()) {
- this.checkgroup.setValue();
+ const value = this.checkgroup.getValue();
+ if (value.length !== 0) {
+ this.workDayBox.setSelected(false);
}
- this.resultPane.populate(this.workDayBox.isSelected() ? this._getParamJson([{
- dateType: DynamicDateCard.TYPE.WORK_DAY,
- }]) : []);
+
+ const plainValue = {};
+ each(this.resultPane.getAllButtons(), (idx, button) => {
+ const value = button.getValue();
+ if (isNotNull(value.dateType)) {
+ plainValue[value.dateType] = {
+ value: value.value,
+ offset: value.offset,
+ };
+ }
+ });
+ this.resultPane.populate(
+ this._getParamJson(
+ map(this.checkgroup.getValue(), (idx, v) => {
+ const obj = {
+ dateType: v,
+ };
+ if (has(plainValue, v)) {
+ obj.value = plainValue[v].value;
+ obj.offset = plainValue[v].offset;
+ }
+
+ return obj;
+ })
+ )
+ );
this.position = DynamicDateCard.OFFSET.CURRENT;
this.fireEvent("EVENT_CHANGE");
},
- }],
- },
- }],
- ref: _ref => {
- this.workDay = _ref;
+ }
+ ],
},
- }, {
- type: "bi.button_group",
- items: this._getParamJson([{
- dateType: DynamicDateCard.TYPE.YEAR,
- }]),
- ref: _ref => {
- this.resultPane = _ref;
+ {
+ type: VerticalAdaptLayout.xtype,
+ lgap: 2,
+ items: [
+ {
+ el: {
+ type: MultiSelectItem.xtype,
+ iconWrapperWidth: 26,
+ ref: _ref => {
+ this.workDayBox = _ref;
+ },
+ logic: {
+ dynamic: true,
+ },
+ text: i18nText("BI-Basic_Work_Day"),
+ value: DynamicDateCard.TYPE.WORK_DAY,
+ listeners: [
+ {
+ eventName: MultiSelectItem.EVENT_CHANGE,
+ action: () => {
+ if (this.workDayBox.isSelected()) {
+ this.checkgroup.setValue();
+ }
+ this.resultPane.populate(
+ this.workDayBox.isSelected()
+ ? this._getParamJson([
+ {
+ dateType: DynamicDateCard.TYPE.WORK_DAY,
+ }
+ ])
+ : []
+ );
+ this.position = DynamicDateCard.OFFSET.CURRENT;
+ this.fireEvent("EVENT_CHANGE");
+ },
+ }
+ ],
+ },
+ }
+ ],
+ ref: _ref => {
+ this.workDay = _ref;
+ },
},
- layouts: [{
- type: "bi.vertical",
- bgap: 10,
- hgap: 10,
- }],
- }],
+ {
+ type: ButtonGroup.xtype,
+ items: this._getParamJson([
+ {
+ dateType: DynamicDateCard.TYPE.YEAR,
+ }
+ ]),
+ ref: _ref => {
+ this.resultPane = _ref;
+ },
+ layouts: [
+ {
+ type: VerticalLayout.xtype,
+ bgap: 10,
+ hgap: 10,
+ }
+ ],
+ }
+ ],
};
}
@@ -160,22 +217,25 @@ export class DynamicDateCard extends Widget {
const items = map(values, (idx, value) => {
return {
el: {
- type: "bi.dynamic_date_param_item",
+ type: DynamicDateParamItem.xtype,
validationChecker: bind(this._checkDate, this),
dateType: value.dateType,
value: value.value,
offset: value.offset,
- listeners: [{
- eventName: "EVENT_CHANGE",
- action: () => {
- this.fireEvent("EVENT_CHANGE");
- },
- }, {
- eventName: "EVENT_INPUT_CHANGE",
- action () {
- Bubbles.hide("dynamic-date-error");
+ listeners: [
+ {
+ eventName: "EVENT_CHANGE",
+ action: () => {
+ this.fireEvent("EVENT_CHANGE");
+ },
},
- }],
+ {
+ eventName: "EVENT_INPUT_CHANGE",
+ action() {
+ Bubbles.hide("dynamic-date-error");
+ },
+ }
+ ],
},
tgap: idx === 0 ? 5 : 0,
};
@@ -185,7 +245,7 @@ export class DynamicDateCard extends Widget {
const comboItems = this._getText(DynamicDateCard.TYPE.MONTH);
comboItems[0].text = i18nText("BI-Basic_Empty");
items.push({
- type: "bi.text_value_combo",
+ type: TextValueCombo.xtype,
height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
items: comboItems,
container: null,
@@ -193,19 +253,25 @@ export class DynamicDateCard extends Widget {
ref: _ref => {
this.textValueCombo = _ref;
},
- listeners: [{
- eventName: "EVENT_CHANGE",
- action: () => {
- this.position = this.textValueCombo.getValue()[0];
- this.textValueCombo.setValue(this.position);
- this.fireEvent("EVENT_CHANGE");
- },
- }],
+ listeners: [
+ {
+ eventName: "EVENT_CHANGE",
+ action: () => {
+ this.position = this.textValueCombo.getValue()[0];
+ this.textValueCombo.setValue(this.position);
+ this.fireEvent("EVENT_CHANGE");
+ },
+ }
+ ],
});
} else {
- if (values.length !== 0 && last(values).dateType !== DynamicDateCard.TYPE.DAY && last(values).dateType !== DynamicDateCard.TYPE.WORK_DAY) {
+ if (
+ values.length !== 0 &&
+ last(values).dateType !== DynamicDateCard.TYPE.DAY &&
+ last(values).dateType !== DynamicDateCard.TYPE.WORK_DAY
+ ) {
items.push({
- type: "bi.text_value_combo",
+ type: TextValueCombo.xtype,
height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
container: null,
items: this._getText(last(values).dateType),
@@ -213,14 +279,16 @@ export class DynamicDateCard extends Widget {
ref: _ref => {
this.textValueCombo = _ref;
},
- listeners: [{
- eventName: "EVENT_CHANGE",
- action: () => {
- this.position = this.textValueCombo.getValue()[0];
- this.textValueCombo.setValue(this.position);
- this.fireEvent("EVENT_CHANGE");
- },
- }],
+ listeners: [
+ {
+ eventName: "EVENT_CHANGE",
+ action: () => {
+ this.position = this.textValueCombo.getValue()[0];
+ this.textValueCombo.setValue(this.position);
+ this.fireEvent("EVENT_CHANGE");
+ },
+ }
+ ],
});
}
}
@@ -238,50 +306,66 @@ export class DynamicDateCard extends Widget {
_getText(lastValue) {
switch (lastValue) {
case DynamicDateCard.TYPE.YEAR:
- return [{
- text: i18nText("BI-Basic_Current_Day"),
- value: DynamicDateCard.OFFSET.CURRENT,
- }, {
- text: i18nText("BI-Basic_Year_Begin"),
- value: DynamicDateCard.OFFSET.BEGIN,
- }, {
- text: i18nText("BI-Basic_Year_End"),
- value: DynamicDateCard.OFFSET.END,
- }];
+ return [
+ {
+ text: i18nText("BI-Basic_Current_Day"),
+ value: DynamicDateCard.OFFSET.CURRENT,
+ },
+ {
+ text: i18nText("BI-Basic_Year_Begin"),
+ value: DynamicDateCard.OFFSET.BEGIN,
+ },
+ {
+ text: i18nText("BI-Basic_Year_End"),
+ value: DynamicDateCard.OFFSET.END,
+ }
+ ];
case DynamicDateCard.TYPE.QUARTER:
- return [{
- text: i18nText("BI-Basic_Current_Day"),
- value: DynamicDateCard.OFFSET.CURRENT,
- }, {
- text: i18nText("BI-Basic_Quarter_Begin"),
- value: DynamicDateCard.OFFSET.BEGIN,
- }, {
- text: i18nText("BI-Basic_Quarter_End"),
- value: DynamicDateCard.OFFSET.END,
- }];
+ return [
+ {
+ text: i18nText("BI-Basic_Current_Day"),
+ value: DynamicDateCard.OFFSET.CURRENT,
+ },
+ {
+ text: i18nText("BI-Basic_Quarter_Begin"),
+ value: DynamicDateCard.OFFSET.BEGIN,
+ },
+ {
+ text: i18nText("BI-Basic_Quarter_End"),
+ value: DynamicDateCard.OFFSET.END,
+ }
+ ];
case DynamicDateCard.TYPE.MONTH:
- return [{
- text: i18nText("BI-Basic_Current_Day"),
- value: DynamicDateCard.OFFSET.CURRENT,
- }, {
- text: i18nText("BI-Basic_Month_Begin"),
- value: DynamicDateCard.OFFSET.BEGIN,
- }, {
- text: i18nText("BI-Basic_Month_End"),
- value: DynamicDateCard.OFFSET.END,
- }];
+ return [
+ {
+ text: i18nText("BI-Basic_Current_Day"),
+ value: DynamicDateCard.OFFSET.CURRENT,
+ },
+ {
+ text: i18nText("BI-Basic_Month_Begin"),
+ value: DynamicDateCard.OFFSET.BEGIN,
+ },
+ {
+ text: i18nText("BI-Basic_Month_End"),
+ value: DynamicDateCard.OFFSET.END,
+ }
+ ];
case DynamicDateCard.TYPE.WEEK:
default:
- return [{
- text: i18nText("BI-Basic_Current_Day"),
- value: DynamicDateCard.OFFSET.CURRENT,
- }, {
- text: i18nText("BI-Basic_Week_Begin"),
- value: DynamicDateCard.OFFSET.BEGIN,
- }, {
- text: i18nText("BI-Basic_Week_End"),
- value: DynamicDateCard.OFFSET.END,
- }];
+ return [
+ {
+ text: i18nText("BI-Basic_Current_Day"),
+ value: DynamicDateCard.OFFSET.CURRENT,
+ },
+ {
+ text: i18nText("BI-Basic_Week_Begin"),
+ value: DynamicDateCard.OFFSET.BEGIN,
+ },
+ {
+ text: i18nText("BI-Basic_Week_End"),
+ value: DynamicDateCard.OFFSET.END,
+ }
+ ];
}
}
@@ -297,22 +381,22 @@ export class DynamicDateCard extends Widget {
const valueMap = {};
switch (value.dateType) {
case DynamicDateCard.TYPE.YEAR:
- valueMap.year = (value.offset === 0 ? -value.value : +value.value);
+ valueMap.year = value.offset === 0 ? -value.value : +value.value;
break;
case DynamicDateCard.TYPE.QUARTER:
- valueMap.quarter = (value.offset === 0 ? -value.value : +value.value);
+ valueMap.quarter = value.offset === 0 ? -value.value : +value.value;
break;
case DynamicDateCard.TYPE.MONTH:
- valueMap.month = (value.offset === 0 ? -value.value : +value.value);
+ valueMap.month = value.offset === 0 ? -value.value : +value.value;
break;
case DynamicDateCard.TYPE.WEEK:
- valueMap.week = (value.offset === 0 ? -value.value : +value.value);
+ valueMap.week = value.offset === 0 ? -value.value : +value.value;
break;
case DynamicDateCard.TYPE.DAY:
- valueMap.day = (value.offset === 0 ? -value.value : +value.value);
+ valueMap.day = value.offset === 0 ? -value.value : +value.value;
break;
case DynamicDateCard.TYPE.WORK_DAY:
- valueMap.workDay = (value.offset === 0 ? -value.value : +value.value);
+ valueMap.workDay = value.offset === 0 ? -value.value : +value.value;
break;
default:
break;
@@ -320,7 +404,7 @@ export class DynamicDateCard extends Widget {
if (isNull(value.dateType)) {
valueMap.position = this.position || DynamicDateCard.OFFSET.CURRENT;
}
-
+
return valueMap;
}
@@ -382,7 +466,7 @@ export class DynamicDateCard extends Widget {
}
if (this.workDayBox.isSelected()) {
const value = buttons[0].getValue();
- valueMap.workDay = (value.offset === 0 ? -value.value : +value.value);
+ valueMap.workDay = value.offset === 0 ? -value.value : +value.value;
}
return valueMap;
@@ -393,7 +477,8 @@ export class DynamicDateCard extends Widget {
const start = parseDateTime(o.min, "%Y-%X-%d");
const end = parseDateTime(o.max, "%Y-%X-%d");
- return i18nText("BI-Basic_Date_Range_Error",
+ return i18nText(
+ "BI-Basic_Date_Range_Error",
start.getFullYear(),
start.getMonth() + 1,
start.getDate(),
diff --git a/src/widget/dynamicdate/dynamicdate.combo.js b/src/widget/dynamicdate/dynamicdate.combo.js
index 173327f56..96266a023 100644
--- a/src/widget/dynamicdate/dynamicdate.combo.js
+++ b/src/widget/dynamicdate/dynamicdate.combo.js
@@ -1,11 +1,37 @@
-import { shortcut, getDate, toPix, isEqual, isNotEmptyString, isEmptyString, isNotNull, isNotEmptyObject, checkDateVoid } from "@/core";
-import { Single, Combo } from "@/base";
+import {
+ AbsoluteLayout,
+ HorizontalFillLayout,
+ shortcut,
+ getDate,
+ toPix,
+ isEqual,
+ isNotEmptyString,
+ isEmptyString,
+ isNotNull,
+ isNotEmptyObject,
+ checkDateVoid
+} from "@/core";
+import { Combo, IconButton, Single } from "@/base";
import { DynamicDateTrigger } from "./dynamicdate.trigger";
import { DynamicDatePopup } from "./dynamicdate.popup";
@shortcut()
export class DynamicDateCombo extends Single {
- static xtype = "bi.dynamic_date_combo"
+ static xtype = "bi.dynamic_date_combo";
+
+ static EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
+ static EVENT_CONFIRM = "EVENT_CONFIRM";
+ static EVENT_FOCUS = "EVENT_FOCUS";
+ static EVENT_BLUR = "EVENT_BLUR";
+ static EVENT_CHANGE = "EVENT_CHANGE";
+ static EVENT_VALID = "EVENT_VALID";
+ static EVENT_ERROR = "EVENT_ERROR";
+ static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+ static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW";
+ static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW";
+
+ static Static = 1;
+ static Dynamic = 2;
constants = {
popupHeight: 259,
@@ -13,7 +39,7 @@ export class DynamicDateCombo extends Single {
comboAdjustHeight: 1,
border: 1,
iconWidth: 24,
- }
+ };
props = {
baseCls: "bi-dynamic-date-combo",
@@ -30,20 +56,6 @@ export class DynamicDateCombo extends Single {
isNeedAdjustWidth: false,
};
- static EVENT_KEY_DOWN = "EVENT_KEY_DOWN"
- static EVENT_CONFIRM = "EVENT_CONFIRM"
- static EVENT_FOCUS = "EVENT_FOCUS"
- static EVENT_BLUR = "EVENT_BLUR"
- static EVENT_CHANGE = "EVENT_CHANGE"
- static EVENT_VALID = "EVENT_VALID"
- static EVENT_ERROR = "EVENT_ERROR"
- static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"
- static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW"
- static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW"
-
- static Static = 1;
- static Dynamic = 2;
-
_init() {
super._init(...arguments);
}
@@ -56,200 +68,222 @@ export class DynamicDateCombo extends Single {
const border = opts.simple ? 1 : 2;
return {
- type: "bi.absolute",
- items: [{
- el: {
- type: "bi.combo",
- cls: `${opts.simple ? "bi-border-bottom" : "bi-border bi-border-radius"} bi-focus-shadow`,
- container: opts.container,
- ref: _ref => {
- this.combo = _ref;
- },
- toggle: false,
- isNeedAdjustHeight: opts.isNeedAdjustHeight,
- isNeedAdjustWidth: opts.isNeedAdjustWidth,
- destroyWhenHide: true,
+ type: AbsoluteLayout.xtype,
+ items: [
+ {
el: {
- type: "bi.horizontal_fill",
- columnSize: [this.constants.iconWidth, "fill"],
- height: toPix(opts.height, border),
- items: [{
- el: {
- type: "bi.icon_button",
- cls: "bi-trigger-icon-button date-change-h-font",
- width: toPix(opts.height, border),
- height: toPix(opts.height, border),
- ref: _ref => {
- this.changeIcon = _ref;
- },
- },
- }, {
- type: "bi.dynamic_date_trigger",
- simple: opts.simple,
- min: opts.minDate,
- max: opts.maxDate,
- format: opts.format,
- allowEdit: opts.allowEdit,
- watermark: opts.watermark,
- iconWidth: toPix(opts.height, border),
+ type: Combo.xtype,
+ cls: `${opts.simple ? "bi-border-bottom" : "bi-border bi-border-radius"} bi-focus-shadow`,
+ container: opts.container,
+ ref: _ref => {
+ this.combo = _ref;
+ },
+ toggle: false,
+ isNeedAdjustHeight: opts.isNeedAdjustHeight,
+ isNeedAdjustWidth: opts.isNeedAdjustWidth,
+ destroyWhenHide: true,
+ el: {
+ type: HorizontalFillLayout.xtype,
+ columnSize: [this.constants.iconWidth, "fill"],
height: toPix(opts.height, border),
- value: opts.value,
- ref: _ref => {
- this.trigger = _ref;
- },
- listeners: [{
- eventName: DynamicDateTrigger.EVENT_KEY_DOWN,
- action: (...args) => {
- if (this.combo.isViewVisible()) {
- this.combo.hideView();
- }
- this.fireEvent(DynamicDateCombo.EVENT_KEY_DOWN, ...args);
- },
- }, {
- eventName: DynamicDateTrigger.EVENT_STOP,
- action: () => {
- if (!this.combo.isViewVisible()) {
- this.combo.showView();
- }
- },
- }, {
- eventName: DynamicDateTrigger.EVENT_FOCUS,
- action: () => {
- this.storeTriggerValue = this.trigger.getKey();
- if (!this.combo.isViewVisible()) {
- this.combo.showView();
- }
- this.fireEvent(DynamicDateCombo.EVENT_FOCUS);
- },
- }, {
- eventName: DynamicDateTrigger.EVENT_BLUR,
- action: () => {
- this.fireEvent(DynamicDateCombo.EVENT_BLUR);
- },
- }, {
- eventName: DynamicDateTrigger.EVENT_ERROR,
- action: () => {
- this.storeValue = {
- type: DynamicDateCombo.Static,
- value: {
- year: date.getFullYear(),
- month: date.getMonth() + 1,
+ items: [
+ {
+ el: {
+ type: IconButton.xtype,
+ cls: "bi-trigger-icon-button date-change-h-font",
+ width: toPix(opts.height, border),
+ height: toPix(opts.height, border),
+ ref: _ref => {
+ this.changeIcon = _ref;
},
- };
- this.combo.element.addClass("error");
- this.fireEvent(DynamicDateCombo.EVENT_ERROR);
- },
- }, {
- eventName: DynamicDateTrigger.EVENT_VALID,
- action: () => {
- this.storeValue = this.trigger.getValue();
- this.combo.element.removeClass("error");
- this.fireEvent(DynamicDateCombo.EVENT_VALID);
- },
- }, {
- eventName: DynamicDateTrigger.EVENT_CHANGE,
- action: () => {
- this.fireEvent(DynamicDateCombo.EVENT_CHANGE);
+ },
},
- }, {
- eventName: DynamicDateTrigger.EVENT_CONFIRM,
- action: () => {
- const dateStore = this.storeTriggerValue;
- const dateObj = this.trigger.getKey();
- if (this.combo.isViewVisible() || isEqual(dateObj, dateStore)) {
- return;
- }
- if (isNotEmptyString(dateObj) && !isEqual(dateObj, dateStore)) {
- this.storeValue = this.trigger.getValue();
- this.setValue(this.trigger.getValue());
- } else if (isEmptyString(dateObj)) {
- this.storeValue = null;
- this.trigger.setValue();
- }
- this._checkDynamicValue(this.storeValue);
- this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
- },
- }],
- }],
- },
- adjustLength: this.constants.comboAdjustHeight,
- popup: {
- el: {
- type: "bi.dynamic_date_popup",
- width: opts.isNeedAdjustWidth ? opts.width : undefined,
- supportDynamic: opts.supportDynamic,
- behaviors: opts.behaviors,
- min: opts.minDate,
- max: opts.maxDate,
- ref: _ref => {
- this.popup = _ref;
- },
- listeners: [{
- eventName: DynamicDatePopup.BUTTON_CLEAR_EVENT_CHANGE,
- action: () => {
- this.setValue();
- this.combo.hideView();
- this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
- },
- }, {
- eventName: DynamicDatePopup.BUTTON_lABEL_EVENT_CHANGE,
- action: () => {
- const date = getDate();
- this.setValue({
- type: DynamicDateCombo.Static,
- value: {
- year: date.getFullYear(),
- month: date.getMonth() + 1,
- day: date.getDate(),
+ {
+ type: DynamicDateTrigger.xtype,
+ simple: opts.simple,
+ min: opts.minDate,
+ max: opts.maxDate,
+ format: opts.format,
+ allowEdit: opts.allowEdit,
+ watermark: opts.watermark,
+ iconWidth: toPix(opts.height, border),
+ height: toPix(opts.height, border),
+ value: opts.value,
+ ref: _ref => {
+ this.trigger = _ref;
+ },
+ listeners: [
+ {
+ eventName: DynamicDateTrigger.EVENT_KEY_DOWN,
+ action: (...args) => {
+ if (this.combo.isViewVisible()) {
+ this.combo.hideView();
+ }
+ this.fireEvent(DynamicDateCombo.EVENT_KEY_DOWN, ...args);
+ },
},
- });
- this.combo.hideView();
- this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
+ {
+ eventName: DynamicDateTrigger.EVENT_STOP,
+ action: () => {
+ if (!this.combo.isViewVisible()) {
+ this.combo.showView();
+ }
+ },
+ },
+ {
+ eventName: DynamicDateTrigger.EVENT_FOCUS,
+ action: () => {
+ this.storeTriggerValue = this.trigger.getKey();
+ if (!this.combo.isViewVisible()) {
+ this.combo.showView();
+ }
+ this.fireEvent(DynamicDateCombo.EVENT_FOCUS);
+ },
+ },
+ {
+ eventName: DynamicDateTrigger.EVENT_BLUR,
+ action: () => {
+ this.fireEvent(DynamicDateCombo.EVENT_BLUR);
+ },
+ },
+ {
+ eventName: DynamicDateTrigger.EVENT_ERROR,
+ action: () => {
+ this.storeValue = {
+ type: DynamicDateCombo.Static,
+ value: {
+ year: date.getFullYear(),
+ month: date.getMonth() + 1,
+ },
+ };
+ this.combo.element.addClass("error");
+ this.fireEvent(DynamicDateCombo.EVENT_ERROR);
+ },
+ },
+ {
+ eventName: DynamicDateTrigger.EVENT_VALID,
+ action: () => {
+ this.storeValue = this.trigger.getValue();
+ this.combo.element.removeClass("error");
+ this.fireEvent(DynamicDateCombo.EVENT_VALID);
+ },
+ },
+ {
+ eventName: DynamicDateTrigger.EVENT_CHANGE,
+ action: () => {
+ this.fireEvent(DynamicDateCombo.EVENT_CHANGE);
+ },
+ },
+ {
+ eventName: DynamicDateTrigger.EVENT_CONFIRM,
+ action: () => {
+ const dateStore = this.storeTriggerValue;
+ const dateObj = this.trigger.getKey();
+ if (this.combo.isViewVisible() || isEqual(dateObj, dateStore)) {
+ return;
+ }
+ if (isNotEmptyString(dateObj) && !isEqual(dateObj, dateStore)) {
+ this.storeValue = this.trigger.getValue();
+ this.setValue(this.trigger.getValue());
+ } else if (isEmptyString(dateObj)) {
+ this.storeValue = null;
+ this.trigger.setValue();
+ }
+ this._checkDynamicValue(this.storeValue);
+ this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
+ },
+ }
+ ],
+ }
+ ],
+ },
+ adjustLength: this.constants.comboAdjustHeight,
+ popup: {
+ el: {
+ type: DynamicDatePopup.xtype,
+ width: opts.isNeedAdjustWidth ? opts.width : undefined,
+ supportDynamic: opts.supportDynamic,
+ behaviors: opts.behaviors,
+ min: opts.minDate,
+ max: opts.maxDate,
+ ref: _ref => {
+ this.popup = _ref;
},
- }, {
- eventName: DynamicDatePopup.BUTTON_OK_EVENT_CHANGE,
- action: () => {
- const value = this.popup.getValue();
- if (this._checkValue(value)) {
- this.setValue(value);
+ listeners: [
+ {
+ eventName: DynamicDatePopup.BUTTON_CLEAR_EVENT_CHANGE,
+ action: () => {
+ this.setValue();
+ this.combo.hideView();
+ this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
+ },
+ },
+ {
+ eventName: DynamicDatePopup.BUTTON_lABEL_EVENT_CHANGE,
+ action: () => {
+ const date = getDate();
+ this.setValue({
+ type: DynamicDateCombo.Static,
+ value: {
+ year: date.getFullYear(),
+ month: date.getMonth() + 1,
+ day: date.getDate(),
+ },
+ });
+ this.combo.hideView();
+ this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
+ },
+ },
+ {
+ eventName: DynamicDatePopup.BUTTON_OK_EVENT_CHANGE,
+ action: () => {
+ const value = this.popup.getValue();
+ if (this._checkValue(value)) {
+ this.setValue(value);
+ }
+ this.combo.hideView();
+ this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
+ },
+ },
+ {
+ eventName: DynamicDatePopup.EVENT_CHANGE,
+ action: () => {
+ this.setValue(this.popup.getValue());
+ this.combo.hideView();
+ this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
+ },
+ },
+ {
+ eventName: DynamicDatePopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW,
+ action: () => {
+ this.fireEvent(DynamicDateCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
+ },
}
- this.combo.hideView();
- this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
- },
- }, {
- eventName: DynamicDatePopup.EVENT_CHANGE,
- action: () => {
- this.setValue(this.popup.getValue());
- this.combo.hideView();
- this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
- },
- }, {
- eventName: DynamicDatePopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW,
+ ],
+ },
+ },
+ // // DEC-4250 和复选下拉一样,点击triggerBtn不默认收起
+ // hideChecker: function (e) {
+ // return self.triggerBtn.element.find(e.target).length === 0;
+ // },
+ listeners: [
+ {
+ eventName: Combo.EVENT_BEFORE_POPUPVIEW,
action: () => {
- this.fireEvent(DynamicDateCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
+ this.popup.setMinDate(opts.minDate);
+ this.popup.setMaxDate(opts.maxDate);
+ this.popup.setValue(this.storeValue);
+ this.fireEvent(DynamicDateCombo.EVENT_BEFORE_POPUPVIEW);
},
- }],
- },
+ }
+ ],
},
- // // DEC-4250 和复选下拉一样,点击triggerBtn不默认收起
- // hideChecker: function (e) {
- // return self.triggerBtn.element.find(e.target).length === 0;
- // },
- listeners: [{
- eventName: Combo.EVENT_BEFORE_POPUPVIEW,
- action: () => {
- this.popup.setMinDate(opts.minDate);
- this.popup.setMaxDate(opts.maxDate);
- this.popup.setValue(this.storeValue);
- this.fireEvent(DynamicDateCombo.EVENT_BEFORE_POPUPVIEW);
- },
- }],
- },
- top: 0,
- left: 0,
- right: 0,
- bottom: 0,
- }],
+ top: 0,
+ left: 0,
+ right: 0,
+ bottom: 0,
+ }
+ ],
};
}
@@ -291,9 +325,7 @@ export class DynamicDateCombo extends Single {
}
}
- _defaultState() {
-
- }
+ _defaultState() {}
setMinDate(minDate) {
const o = this.options;
diff --git a/src/widget/dynamicdate/dynamicdate.param.item.js b/src/widget/dynamicdate/dynamicdate.param.item.js
index a0fe36814..3ab6561dd 100644
--- a/src/widget/dynamicdate/dynamicdate.param.item.js
+++ b/src/widget/dynamicdate/dynamicdate.param.item.js
@@ -1,19 +1,20 @@
-import { shortcut, Widget, toPix, isNaturalNumber, i18nText } from "@/core";
-import { DynamicDateCard } from "./dynamicdate.card";
+import { HTapeLayout, shortcut, Widget, toPix, isNaturalNumber, i18nText } from "@/core";
import { SignEditor, TextValueCombo } from "@/case";
+import { Label } from "@/base";
+import { DynamicDateCard } from "./dynamicdate.card";
@shortcut()
export class DynamicDateParamItem extends Widget {
- static xtype = "bi.dynamic_date_param_item"
+ static xtype = "bi.dynamic_date_param_item";
- static EVENT_CHANGE = "EVENT_CHANGE"
- static EVENT_INPUT_CHANGE = "EVENT_INPUT_CHANGE"
+ static EVENT_CHANGE = "EVENT_CHANGE";
+ static EVENT_INPUT_CHANGE = "EVENT_INPUT_CHANGE";
props() {
return {
baseCls: "bi-dynamic-date-param-item",
dateType: DynamicDateCard.TYPE.YEAR,
- validationChecker () {
+ validationChecker() {
return true;
},
value: 0,
@@ -24,67 +25,79 @@ export class DynamicDateParamItem extends Widget {
render() {
const o = this.options;
-
+
return {
- type: "bi.htape",
- items: [{
- el: {
- type: "bi.sign_editor",
- cls: "bi-border bi-focus-shadow bi-border-radius",
- height: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 2),
- validationChecker (v) {
- return isNaturalNumber(v);
- },
- value: o.value,
- ref: _ref => {
- this.editor = _ref;
- },
- errorText () {
- return i18nText("BI-Please_Input_Natural_Number");
- },
- allowBlank: false,
- listeners: [{
- eventName: SignEditor.EVENT_CONFIRM,
- action: () => {
- this.fireEvent(DynamicDateParamItem.EVENT_CHANGE);
+ type: HTapeLayout.xtype,
+ items: [
+ {
+ el: {
+ type: SignEditor.xtype,
+ cls: "bi-border bi-focus-shadow bi-border-radius",
+ height: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 2),
+ validationChecker(v) {
+ return isNaturalNumber(v);
},
- }, {
- eventName: SignEditor.EVENT_CHANGE,
- action: () => {
- this.fireEvent(DynamicDateParamItem.EVENT_INPUT_CHANGE);
+ value: o.value,
+ ref: _ref => {
+ this.editor = _ref;
},
- }],
- },
- width: 60,
- }, {
- el: {
- type: "bi.label",
- height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
- text: this._getText(),
+ errorText() {
+ return i18nText("BI-Please_Input_Natural_Number");
+ },
+ allowBlank: false,
+ listeners: [
+ {
+ eventName: SignEditor.EVENT_CONFIRM,
+ action: () => {
+ this.fireEvent(DynamicDateParamItem.EVENT_CHANGE);
+ },
+ },
+ {
+ eventName: SignEditor.EVENT_CHANGE,
+ action: () => {
+ this.fireEvent(DynamicDateParamItem.EVENT_INPUT_CHANGE);
+ },
+ }
+ ],
+ },
+ width: 60,
},
- width: o.dateType === DynamicDateCard.TYPE.WORK_DAY ? 60 : 20,
- }, {
- type: "bi.text_value_combo",
- height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
- items: [{
- text: i18nText("BI-Basic_Front"),
- value: 0,
- }, {
- text: i18nText("BI-Basic_Behind"),
- value: 1,
- }],
- ref: _ref => {
- this.offsetCombo = _ref;
+ {
+ el: {
+ type: Label.xtype,
+ height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
+ text: this._getText(),
+ },
+ width: o.dateType === DynamicDateCard.TYPE.WORK_DAY ? 60 : 20,
},
- container: null,
- value: o.offset,
- listeners: [{
- eventName: TextValueCombo.EVENT_CHANGE,
- action: () => {
- this.fireEvent(DynamicDateParamItem.EVENT_CHANGE);
+ {
+ type: TextValueCombo.xtype,
+ height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
+ items: [
+ {
+ text: i18nText("BI-Basic_Front"),
+ value: 0,
+ },
+ {
+ text: i18nText("BI-Basic_Behind"),
+ value: 1,
+ }
+ ],
+ ref: _ref => {
+ this.offsetCombo = _ref;
},
- }],
- }],
+ container: null,
+ value: o.offset,
+ listeners: [
+ {
+ eventName: TextValueCombo.EVENT_CHANGE,
+ action: () => {
+ this.fireEvent(DynamicDateParamItem.EVENT_CHANGE);
+ },
+ }
+ ],
+ }
+ ],
};
}
@@ -111,7 +124,7 @@ export class DynamicDateParamItem extends Widget {
text = i18nText("BI-Basic_Work_Day");
break;
}
-
+
return text;
}
diff --git a/src/widget/dynamicdate/dynamicdate.popup.js b/src/widget/dynamicdate/dynamicdate.popup.js
index 4e8a8d157..253c4a210 100644
--- a/src/widget/dynamicdate/dynamicdate.popup.js
+++ b/src/widget/dynamicdate/dynamicdate.popup.js
@@ -1,16 +1,33 @@
-import { shortcut, Widget, createWidget, i18nText, toPix, createItems, isNull, isEmptyObject, isEmptyString, getDate, checkDateVoid, print } from "@/core";
-import { DynamicDateCombo } from "./dynamicdate.combo";
+import {
+ VerticalLayout,
+ GridLayout,
+ shortcut,
+ Widget,
+ createWidget,
+ i18nText,
+ toPix,
+ createItems,
+ isNull,
+ isEmptyObject,
+ isEmptyString,
+ getDate,
+ checkDateVoid,
+ print
+} from "@/core";
import { TextButton, Tab } from "@/base";
+import { LinearSegment } from "@/case";
+import { DynamicDateCard } from "./dynamicdate.card";
import { DateCalendarPopup } from "../date/calendar";
+import { DynamicDateCombo } from "./dynamicdate.combo";
import { DynamicDateHelper } from "./dynamicdate.caculate";
@shortcut()
export class DynamicDatePopup extends Widget {
- static xtype = "bi.dynamic_date_popup"
+ static xtype = "bi.dynamic_date_popup";
constants = {
tabHeight: 40,
- }
+ };
props = {
baseCls: "bi-dynamic-date-popup",
@@ -18,11 +35,11 @@ export class DynamicDatePopup extends Widget {
supportDynamic: true,
};
- static EVENT_CHANGE = "EVENT_CHANGE"
- static BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE"
- static BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE"
- static BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE"
- static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW"
+ static EVENT_CHANGE = "EVENT_CHANGE";
+ static BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE";
+ static BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE";
+ static BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE";
+ static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW";
_init() {
super._init(...arguments);
@@ -32,72 +49,86 @@ export class DynamicDatePopup extends Widget {
};
createWidget({
element: this,
- type: "bi.vertical",
- items: [{
- el: this._getTabJson(),
- }, {
- el: {
- type: "bi.grid",
- items: [
- [{
- type: "bi.text_button",
- cls: "bi-high-light bi-split-top",
- shadow: true,
- text: i18nText("BI-Basic_Clear"),
- textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
- listeners: [{
- eventName: TextButton.EVENT_CHANGE,
- action: () => {
- this.fireEvent(DynamicDatePopup.BUTTON_CLEAR_EVENT_CHANGE);
- },
- }],
- }, {
- type: "bi.text_button",
- cls: "bi-split-left bi-split-right bi-high-light bi-split-top",
- shadow: true,
- textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
- text: i18nText("BI-Multi_Date_Today"),
- disabled: this._checkTodayValid(),
- ref: _ref => {
- this.todayButton = _ref;
- },
- listeners: [{
- eventName: TextButton.EVENT_CHANGE,
- action: () => {
- this.fireEvent(DynamicDatePopup.BUTTON_lABEL_EVENT_CHANGE);
+ type: VerticalLayout.xtype,
+ items: [
+ {
+ el: this._getTabJson(),
+ },
+ {
+ el: {
+ type: GridLayout.xtype,
+ items: [
+ [
+ {
+ type: TextButton.xtype,
+ cls: "bi-high-light bi-split-top",
+ shadow: true,
+ text: i18nText("BI-Basic_Clear"),
+ textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
+ listeners: [
+ {
+ eventName: TextButton.EVENT_CHANGE,
+ action: () => {
+ this.fireEvent(DynamicDatePopup.BUTTON_CLEAR_EVENT_CHANGE);
+ },
+ }
+ ],
},
- }],
- }, {
- type: "bi.text_button",
- cls: "bi-high-light bi-split-top",
- textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
- shadow: true,
- 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(DynamicDatePopup.BUTTON_OK_EVENT_CHANGE);
- }
+ {
+ type: TextButton.xtype,
+ cls: "bi-split-left bi-split-right bi-high-light bi-split-top",
+ shadow: true,
+ textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
+ text: i18nText("BI-Multi_Date_Today"),
+ disabled: this._checkTodayValid(),
+ ref: _ref => {
+ this.todayButton = _ref;
+ },
+ listeners: [
+ {
+ eventName: TextButton.EVENT_CHANGE,
+ action: () => {
+ this.fireEvent(DynamicDatePopup.BUTTON_lABEL_EVENT_CHANGE);
+ },
+ }
+ ],
},
- }],
- }]
- ],
- height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
- },
- }],
+ {
+ type: TextButton.xtype,
+ cls: "bi-high-light bi-split-top",
+ textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
+ shadow: true,
+ 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(DynamicDatePopup.BUTTON_OK_EVENT_CHANGE);
+ }
+ },
+ }
+ ],
+ }
+ ]
+ ],
+ height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
+ },
+ }
+ ],
});
this.setValue(opts.value);
}
_getTabJson() {
const o = this.options;
-
+
return {
- type: "bi.tab",
+ type: Tab.xtype,
logic: {
dynamic: true,
},
@@ -105,32 +136,40 @@ export class DynamicDatePopup extends Widget {
this.dateTab = _ref;
},
tab: {
- type: "bi.linear_segment",
+ type: LinearSegment.xtype,
invisible: !o.supportDynamic,
cls: "bi-split-bottom",
height: this.constants.tabHeight,
- items: createItems([{
- text: i18nText("BI-Multi_Date_YMD"),
- value: DynamicDateCombo.Static,
- }, {
- text: i18nText("BI-Basic_Dynamic_Title"),
- value: DynamicDateCombo.Dynamic,
- }], {
- textAlign: "center",
- }),
+ items: createItems(
+ [
+ {
+ text: i18nText("BI-Multi_Date_YMD"),
+ value: DynamicDateCombo.Static,
+ },
+ {
+ text: i18nText("BI-Basic_Dynamic_Title"),
+ value: DynamicDateCombo.Dynamic,
+ }
+ ],
+ {
+ textAlign: "center",
+ }
+ ),
},
cardCreator: v => {
switch (v) {
case DynamicDateCombo.Dynamic:
return {
- type: "bi.dynamic_date_card",
+ type: DynamicDateCard.xtype,
cls: "dynamic-date-pane",
- listeners: [{
- eventName: "EVENT_CHANGE",
- action: () => {
- this._setInnerValue(this.year, v);
- },
- }],
+ listeners: [
+ {
+ eventName: "EVENT_CHANGE",
+ action: () => {
+ this._setInnerValue(this.year, v);
+ },
+ }
+ ],
min: this.options.min,
max: this.options.max,
ref: _ref => {
@@ -140,56 +179,61 @@ export class DynamicDatePopup extends Widget {
case DynamicDateCombo.Static:
default:
return {
- type: "bi.date_calendar_popup",
+ type: DateCalendarPopup.xtype,
behaviors: o.behaviors,
min: this.options.min,
max: this.options.max,
- listeners: [{
- eventName: DateCalendarPopup.EVENT_CHANGE,
- action: () => {
- this.fireEvent(DynamicDatePopup.EVENT_CHANGE);
- },
- }, {
- eventName: DateCalendarPopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW,
- action: () => {
- this.fireEvent(DynamicDatePopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
+ listeners: [
+ {
+ eventName: DateCalendarPopup.EVENT_CHANGE,
+ action: () => {
+ this.fireEvent(DynamicDatePopup.EVENT_CHANGE);
+ },
},
- }],
+ {
+ eventName: DateCalendarPopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW,
+ action: () => {
+ this.fireEvent(DynamicDatePopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
+ },
+ }
+ ],
ref: _ref => {
this.ymd = _ref;
},
};
}
},
- listeners: [{
- eventName: Tab.EVENT_CHANGE,
- action: () => {
- const v = this.dateTab.getSelect();
- let date;
- switch (v) {
- case DynamicDateCombo.Static:
- date = DynamicDateHelper.getCalculation(this.dynamicPane.getValue());
- this.ymd.setValue({
- year: date.getFullYear(),
- month: date.getMonth() + 1,
- day: date.getDate(),
- });
- this._setInnerValue();
- break;
- case DynamicDateCombo.Dynamic:
- default:
- if (this.storeValue && this.storeValue.type === DynamicDateCombo.Dynamic) {
- this.dynamicPane.setValue(this.storeValue.value);
- } else {
- this.dynamicPane.setValue({
- year: 0,
+ listeners: [
+ {
+ eventName: Tab.EVENT_CHANGE,
+ action: () => {
+ const v = this.dateTab.getSelect();
+ let date;
+ switch (v) {
+ case DynamicDateCombo.Static:
+ date = DynamicDateHelper.getCalculation(this.dynamicPane.getValue());
+ this.ymd.setValue({
+ year: date.getFullYear(),
+ month: date.getMonth() + 1,
+ day: date.getDate(),
});
+ this._setInnerValue();
+ break;
+ case DynamicDateCombo.Dynamic:
+ default:
+ if (this.storeValue && this.storeValue.type === DynamicDateCombo.Dynamic) {
+ this.dynamicPane.setValue(this.storeValue.value);
+ } else {
+ this.dynamicPane.setValue({
+ year: 0,
+ });
+ }
+ this._setInnerValue();
+ break;
}
- this._setInnerValue();
- break;
- }
- },
- }],
+ },
+ }
+ ],
};
}
@@ -212,7 +256,7 @@ export class DynamicDatePopup extends Widget {
_checkTodayValid() {
const o = this.options;
const today = getDate();
-
+
return !!checkDateVoid(today.getFullYear(), today.getMonth() + 1, today.getDate(), o.min, o.max)[0];
}
diff --git a/src/widget/dynamicdate/dynamicdate.trigger.js b/src/widget/dynamicdate/dynamicdate.trigger.js
index adad56bf7..7cef929b4 100644
--- a/src/widget/dynamicdate/dynamicdate.trigger.js
+++ b/src/widget/dynamicdate/dynamicdate.trigger.js
@@ -1,13 +1,32 @@
-import { shortcut, i18nText, createWidget, isKey, checkDateLegal, parseDateTime, bind, isNotNull, isNotEmptyString, isEqual, isEmptyObject, getDate, isEmptyString, isNull, each, checkDateVoid, print } from "@/core";
-import { Trigger } from "@/base";
import { SignEditor } from "@/case";
+import {
+ HTapeLayout,
+ AbsoluteLayout,
+ shortcut,
+ i18nText,
+ createWidget,
+ isKey,
+ checkDateLegal,
+ parseDateTime,
+ bind,
+ isNotNull,
+ isNotEmptyString,
+ isEqual,
+ isEmptyObject,
+ getDate,
+ isEmptyString,
+ isNull,
+ each,
+ checkDateVoid,
+ print
+} from "@/core";
+import { IconButton, Text, Trigger } from "@/base";
import { DynamicDateCombo } from "./dynamicdate.combo";
import { DynamicDateHelper } from "./dynamicdate.caculate";
-
@shortcut()
export class DynamicDateTrigger extends Trigger {
- static xtype = "bi.dynamic_date_trigger"
+ static xtype = "bi.dynamic_date_trigger";
_const = {
hgap: 4,
@@ -19,16 +38,16 @@ export class DynamicDateTrigger extends Trigger {
iconWidth: 24,
};
- static EVENT_BLUR = "EVENT_BLUR"
- static EVENT_FOCUS = "EVENT_FOCUS"
- static EVENT_START = "EVENT_START"
- static EVENT_STOP = "EVENT_STOP"
- static EVENT_CONFIRM = "EVENT_CONFIRM"
- static EVENT_CHANGE = "EVENT_CHANGE"
- static EVENT_VALID = "EVENT_VALID"
- static EVENT_ERROR = "EVENT_ERROR"
- static EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK"
- static EVENT_KEY_DOWN = "EVENT_KEY_DOWN"
+ static EVENT_BLUR = "EVENT_BLUR";
+ static EVENT_FOCUS = "EVENT_FOCUS";
+ static EVENT_START = "EVENT_START";
+ static EVENT_STOP = "EVENT_STOP";
+ static EVENT_CONFIRM = "EVENT_CONFIRM";
+ static EVENT_CHANGE = "EVENT_CHANGE";
+ static EVENT_VALID = "EVENT_VALID";
+ static EVENT_ERROR = "EVENT_ERROR";
+ static EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK";
+ static EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
props() {
return {
@@ -49,21 +68,25 @@ export class DynamicDateTrigger extends Trigger {
c = this._const;
this.storeTriggerValue = "";
this.editor = createWidget({
- type: "bi.sign_editor",
+ type: SignEditor.xtype,
simple: o.simple,
height: o.height,
validationChecker: v => {
const formatStr = this._getStandardDateStr(v);
const date = formatStr.match(/\d+/g);
!isKey(o.format) && this._autoAppend(v, date);
-
- return this._dateCheck(formatStr) && checkDateLegal(formatStr) && this._checkVoid({
- year: date[0] | 0,
- month: date[1] | 0,
- day: date[2] | 0,
- });
+
+ return (
+ this._dateCheck(formatStr) &&
+ checkDateLegal(formatStr) &&
+ this._checkVoid({
+ year: date[0] | 0,
+ month: date[1] | 0,
+ day: date[2] | 0,
+ })
+ );
},
- quitChecker () {
+ quitChecker() {
return false;
},
hgap: c.hgap,
@@ -74,11 +97,14 @@ export class DynamicDateTrigger extends Trigger {
let str = "";
if (!isKey(o.format)) {
if (!this._dateCheck(v)) {
- str = this.editor.isEditing() ? i18nText("BI-Date_Trigger_Error_Text") : i18nText("BI-Year_Trigger_Invalid_Text");
+ str = this.editor.isEditing()
+ ? i18nText("BI-Date_Trigger_Error_Text")
+ : i18nText("BI-Year_Trigger_Invalid_Text");
} else {
const start = parseDateTime(o.min, "%Y-%X-%d");
const end = parseDateTime(o.max, "%Y-%X-%d");
- str = i18nText("BI-Basic_Date_Range_Error",
+ str = i18nText(
+ "BI-Basic_Date_Range_Error",
start.getFullYear(),
start.getMonth() + 1,
start.getDate(),
@@ -144,34 +170,40 @@ export class DynamicDateTrigger extends Trigger {
this.fireEvent(DynamicDateTrigger.EVENT_CHANGE);
});
createWidget({
- type: "bi.htape",
+ type: HTapeLayout.xtype,
element: this,
columnSize: ["", this._const.iconWidth],
- items: [{
- el: this.editor,
- }, {
- el: {
- type: "bi.icon_button",
- cls: "bi-trigger-icon-button date-font",
- width: this._const.iconWidth,
- },
- width: this._const.iconWidth,
- }],
- });
- !o.allowEdit && createWidget({
- type: "bi.absolute",
- element: this,
- items: [{
- el: {
- type: "bi.text",
- title: bind(this._getTitle, this),
+ items: [
+ {
+ el: this.editor,
},
- left: 0,
- right: o.iconWidth,
- top: 0,
- bottom: 0,
- }],
+ {
+ el: {
+ type: IconButton.xtype,
+ cls: "bi-trigger-icon-button date-font",
+ width: this._const.iconWidth,
+ },
+ width: this._const.iconWidth,
+ }
+ ],
});
+ !o.allowEdit &&
+ createWidget({
+ type: AbsoluteLayout.xtype,
+ element: this,
+ items: [
+ {
+ el: {
+ type: Text.xtype,
+ title: bind(this._getTitle, this),
+ },
+ left: 0,
+ right: o.iconWidth,
+ top: 0,
+ bottom: 0,
+ }
+ ],
+ });
this.setValue(o.value);
}
@@ -189,15 +221,15 @@ export class DynamicDateTrigger extends Trigger {
date = getDate();
date = DynamicDateHelper.getCalculation(value);
dateStr = print(date, this._getFormatString());
-
- return isEmptyString(text) ? dateStr : (`${text}:${dateStr}`);
+
+ return isEmptyString(text) ? dateStr : `${text}:${dateStr}`;
case DynamicDateCombo.Static:
default:
if (isNull(value) || isNull(value.day)) {
return "";
}
-
- return print(getDate(value.year, (value.month - 1), value.day), this._getFormatString());
+
+ return print(getDate(value.year, value.month - 1, value.day), this._getFormatString());
}
}
@@ -248,10 +280,12 @@ export class DynamicDateTrigger extends Trigger {
}
_dateCheck(date) {
- return print(parseDateTime(date, "%Y-%x-%d"), "%Y-%x-%d") === date ||
+ return (
+ print(parseDateTime(date, "%Y-%x-%d"), "%Y-%x-%d") === date ||
print(parseDateTime(date, "%Y-%X-%d"), "%Y-%X-%d") === date ||
print(parseDateTime(date, "%Y-%x-%e"), "%Y-%x-%e") === date ||
- print(parseDateTime(date, "%Y-%X-%e"), "%Y-%X-%e") === date;
+ print(parseDateTime(date, "%Y-%X-%e"), "%Y-%X-%e") === date
+ );
}
_checkVoid(obj) {
@@ -280,16 +314,20 @@ export class DynamicDateTrigger extends Trigger {
_yearCheck(v) {
const date = print(parseDateTime(v, this._getFormatString()), this._const.compareFormat);
-
+
return print(parseDateTime(v, "%Y"), "%Y") === v && date >= this.options.min && date <= this.options.max;
}
_monthCheck(v) {
const date = parseDateTime(v, this._getFormatString());
const dateStr = print(date, this._const.compareFormat);
-
- return (date.getMonth() >= 0 && (print(parseDateTime(v, "%Y-%X"), "%Y-%X") === v ||
- print(parseDateTime(v, "%Y-%x"), "%Y-%x") === v)) && dateStr >= this.options.min && dateStr <= this.options.max;
+
+ return (
+ date.getMonth() >= 0 &&
+ (print(parseDateTime(v, "%Y-%X"), "%Y-%X") === v || print(parseDateTime(v, "%Y-%x"), "%Y-%x") === v) &&
+ dateStr >= this.options.min &&
+ dateStr <= this.options.max
+ );
}
_setInnerValue(date) {
@@ -322,7 +360,7 @@ export class DynamicDateTrigger extends Trigger {
this.editor.setState("");
this.editor.setValue("");
} else {
- const dateStr = print(getDate(value.year, (value.month - 1), value.day), this._getFormatString());
+ const dateStr = print(getDate(value.year, value.month - 1, value.day), this._getFormatString());
this.editor.setState(dateStr);
this.editor.setValue(dateStr);
}
diff --git a/src/widget/dynamicdatetime/dynamicdatetime.combo.js b/src/widget/dynamicdatetime/dynamicdatetime.combo.js
index 0d88cf567..ee1a1ec9a 100644
--- a/src/widget/dynamicdatetime/dynamicdatetime.combo.js
+++ b/src/widget/dynamicdatetime/dynamicdatetime.combo.js
@@ -1,15 +1,27 @@
-import { shortcut, getDate, toPix, isEqual, isNotEmptyString, isEmptyString, isNotNull, isNotEmptyObject, checkDateVoid } from "@/core";
-import { Single, Combo } from "@/base";
+import {
+ AbsoluteLayout,
+ HorizontalFillLayout,
+ shortcut,
+ getDate,
+ toPix,
+ isEqual,
+ isNotEmptyString,
+ isEmptyString,
+ isNotNull,
+ isNotEmptyObject,
+ checkDateVoid
+} from "@/core";
+import { Combo, IconButton, Single } from "@/base";
import { DynamicDateTimeTrigger } from "./dynamicdatetime.trigger";
import { DynamicDateTimePopup } from "./dynamicdatetime.popup";
import { DynamicDateCombo } from "../dynamicdate";
@shortcut()
export class DynamicDateTimeCombo extends Single {
- static xtype = "bi.dynamic_date_time_combo"
+ static xtype = "bi.dynamic_date_time_combo";
- static Static = 1
- static Dynamic = 2
+ static Static = 1;
+ static Dynamic = 2;
constants = {
popupHeight: 259,
@@ -17,7 +29,7 @@ export class DynamicDateTimeCombo extends Single {
comboAdjustHeight: 1,
border: 1,
iconWidth: 24,
- }
+ };
props = {
baseCls: "bi-dynamic-date--time-combo",
@@ -34,16 +46,15 @@ export class DynamicDateTimeCombo extends Single {
isNeedAdjustWidth: false,
};
- static EVENT_KEY_DOWN = "EVENT_KEY_DOWN"
- static EVENT_CONFIRM = "EVENT_CONFIRM"
- static EVENT_FOCUS = "EVENT_FOCUS"
- static EVENT_BLUR = "EVENT_BLUR"
- static EVENT_CHANGE = "EVENT_CHANGE"
- static EVENT_VALID = "EVENT_VALID"
- static EVENT_ERROR = "EVENT_ERROR"
- static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"
- static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW"
-
+ static EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
+ static EVENT_CONFIRM = "EVENT_CONFIRM";
+ static EVENT_FOCUS = "EVENT_FOCUS";
+ static EVENT_BLUR = "EVENT_BLUR";
+ static EVENT_CHANGE = "EVENT_CHANGE";
+ static EVENT_VALID = "EVENT_VALID";
+ static EVENT_ERROR = "EVENT_ERROR";
+ static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+ static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW";
_init() {
super._init(...arguments);
@@ -57,208 +68,231 @@ export class DynamicDateTimeCombo extends Single {
const border = opts.simple ? 1 : 2;
return {
- type: "bi.absolute",
- items: [{
- el: {
- type: "bi.combo",
- cls: `${opts.simple ? "bi-border-bottom" : "bi-border bi-border-radius"} bi-focus-shadow`,
- destroyWhenHide: true,
- container: opts.container,
- ref: _ref => {
- this.combo = _ref;
- },
- toggle: false,
- isNeedAdjustHeight: opts.isNeedAdjustHeight,
- isNeedAdjustWidth: opts.isNeedAdjustWidth,
+ type: AbsoluteLayout.xtype,
+ items: [
+ {
el: {
- type: "bi.horizontal_fill",
- columnSize: [this.constants.iconWidth, "fill"],
- height: toPix(opts.height, border),
- items: [{
- el: {
- type: "bi.icon_button",
- cls: "bi-trigger-icon-button date-change-h-font",
- width: this.constants.iconWidth,
- height: toPix(opts.height, border),
- ref: _ref => {
- this.changeIcon = _ref;
- },
- },
- }, {
- type: "bi.dynamic_date_time_trigger",
- simple: opts.simple,
- min: opts.minDate,
- max: opts.maxDate,
- allowEdit: opts.allowEdit,
- watermark: opts.watermark,
- format: opts.format,
- iconWidth: this.constants.iconWidth,
+ type: Combo.xtype,
+ cls: `${opts.simple ? "bi-border-bottom" : "bi-border bi-border-radius"} bi-focus-shadow`,
+ destroyWhenHide: true,
+ container: opts.container,
+ ref: _ref => {
+ this.combo = _ref;
+ },
+ toggle: false,
+ isNeedAdjustHeight: opts.isNeedAdjustHeight,
+ isNeedAdjustWidth: opts.isNeedAdjustWidth,
+ el: {
+ type: HorizontalFillLayout.xtype,
+ columnSize: [this.constants.iconWidth, "fill"],
height: toPix(opts.height, border),
- value: opts.value,
- ref: _ref => {
- this.trigger = _ref;
- },
- listeners: [{
- eventName: DynamicDateTimeTrigger.EVENT_KEY_DOWN,
- action: (...args) => {
- if (this.combo.isViewVisible()) {
- this.combo.hideView();
- }
- this.fireEvent(DynamicDateTimeCombo.EVENT_KEY_DOWN, ...args);
- },
- }, {
- eventName: DynamicDateTimeTrigger.EVENT_STOP,
- action: () => {
- if (!this.combo.isViewVisible()) {
- this.combo.showView();
- }
- },
- }, {
- eventName: DynamicDateTimeTrigger.EVENT_TRIGGER_CLICK,
- action: () => {
- this.combo.toggle();
- },
- }, {
- eventName: DynamicDateTimeTrigger.EVENT_FOCUS,
- action: () => {
- this.storeTriggerValue = this.trigger.getKey();
- if (!this.combo.isViewVisible()) {
- this.combo.showView();
- }
- this.fireEvent(DynamicDateTimeCombo.EVENT_FOCUS);
- },
- }, {
- eventName: DynamicDateTimeTrigger.EVENT_BLUR,
- action: () => {
- this.fireEvent(DynamicDateTimeCombo.EVENT_BLUR);
- },
- }, {
- eventName: DynamicDateTimeTrigger.EVENT_ERROR,
- action: () => {
- this.storeValue = {
- type: DynamicDateTimeCombo.Static,
- value: {
- year: date.getFullYear(),
- month: date.getMonth() + 1,
+ items: [
+ {
+ el: {
+ type: IconButton.xtype,
+ cls: "bi-trigger-icon-button date-change-h-font",
+ width: this.constants.iconWidth,
+ height: toPix(opts.height, border),
+ ref: _ref => {
+ this.changeIcon = _ref;
},
- };
- this.combo.element.addClass("error");
- this.fireEvent(DynamicDateTimeCombo.EVENT_ERROR);
+ },
},
- }, {
- eventName: DynamicDateTimeTrigger.EVENT_VALID,
- action: () => {
- this.storeValue = this.trigger.getValue();
- this.combo.element.removeClass("error");
- this.fireEvent(DynamicDateTimeCombo.EVENT_VALID);
- },
- }, {
- eventName: DynamicDateTimeTrigger.EVENT_CHANGE,
- action: () => {
- this.fireEvent(DynamicDateTimeCombo.EVENT_CHANGE);
- },
- }, {
- eventName: DynamicDateTimeTrigger.EVENT_CONFIRM,
- action: () => {
- const dateStore = this.storeTriggerValue;
- const dateObj = this.trigger.getKey();
- if (this.combo.isViewVisible() || isEqual(dateObj, dateStore)) {
- return;
- }
- if (isNotEmptyString(dateObj) && !isEqual(dateObj, dateStore)) {
- this.storeValue = this.trigger.getValue();
- this.setValue(this.trigger.getValue());
- } else if (isEmptyString(dateObj)) {
- this.storeValue = null;
- this.trigger.setValue();
- }
- this._checkDynamicValue(this.storeValue);
- this.fireEvent(DynamicDateTimeCombo.EVENT_CONFIRM);
- },
- }],
- }],
- },
- adjustLength: this.constants.comboAdjustHeight,
- popup: {
- el: {
- type: "bi.dynamic_date_time_popup",
- width: opts.isNeedAdjustWidth ? opts.width : undefined,
- supportDynamic: opts.supportDynamic,
- behaviors: opts.behaviors,
- min: opts.minDate,
- max: opts.maxDate,
- ref: _ref => {
- this.popup = _ref;
- },
- listeners: [{
- eventName: DynamicDateTimePopup.BUTTON_CLEAR_EVENT_CHANGE,
- action: () => {
- this.setValue();
- this.combo.hideView();
- this.fireEvent(DynamicDateTimeCombo.EVENT_CONFIRM);
- },
- }, {
- eventName: DynamicDateTimePopup.BUTTON_lABEL_EVENT_CHANGE,
- action: () => {
- const date = getDate();
- this.setValue({
- type: DynamicDateTimeCombo.Static,
- value: {
- year: date.getFullYear(),
- month: date.getMonth() + 1,
- day: date.getDate(),
- hour: 0,
- minute: 0,
- second: 0,
+ {
+ type: DynamicDateTimeTrigger.xtype,
+ simple: opts.simple,
+ min: opts.minDate,
+ max: opts.maxDate,
+ allowEdit: opts.allowEdit,
+ watermark: opts.watermark,
+ format: opts.format,
+ iconWidth: this.constants.iconWidth,
+ height: toPix(opts.height, border),
+ value: opts.value,
+ ref: _ref => {
+ this.trigger = _ref;
+ },
+ listeners: [
+ {
+ eventName: DynamicDateTimeTrigger.EVENT_KEY_DOWN,
+ action: (...args) => {
+ if (this.combo.isViewVisible()) {
+ this.combo.hideView();
+ }
+ this.fireEvent(DynamicDateTimeCombo.EVENT_KEY_DOWN, ...args);
+ },
+ },
+ {
+ eventName: DynamicDateTimeTrigger.EVENT_STOP,
+ action: () => {
+ if (!this.combo.isViewVisible()) {
+ this.combo.showView();
+ }
+ },
},
- });
- this.combo.hideView();
- this.fireEvent(DynamicDateTimeCombo.EVENT_CONFIRM);
+ {
+ eventName: DynamicDateTimeTrigger.EVENT_TRIGGER_CLICK,
+ action: () => {
+ this.combo.toggle();
+ },
+ },
+ {
+ eventName: DynamicDateTimeTrigger.EVENT_FOCUS,
+ action: () => {
+ this.storeTriggerValue = this.trigger.getKey();
+ if (!this.combo.isViewVisible()) {
+ this.combo.showView();
+ }
+ this.fireEvent(DynamicDateTimeCombo.EVENT_FOCUS);
+ },
+ },
+ {
+ eventName: DynamicDateTimeTrigger.EVENT_BLUR,
+ action: () => {
+ this.fireEvent(DynamicDateTimeCombo.EVENT_BLUR);
+ },
+ },
+ {
+ eventName: DynamicDateTimeTrigger.EVENT_ERROR,
+ action: () => {
+ this.storeValue = {
+ type: DynamicDateTimeCombo.Static,
+ value: {
+ year: date.getFullYear(),
+ month: date.getMonth() + 1,
+ },
+ };
+ this.combo.element.addClass("error");
+ this.fireEvent(DynamicDateTimeCombo.EVENT_ERROR);
+ },
+ },
+ {
+ eventName: DynamicDateTimeTrigger.EVENT_VALID,
+ action: () => {
+ this.storeValue = this.trigger.getValue();
+ this.combo.element.removeClass("error");
+ this.fireEvent(DynamicDateTimeCombo.EVENT_VALID);
+ },
+ },
+ {
+ eventName: DynamicDateTimeTrigger.EVENT_CHANGE,
+ action: () => {
+ this.fireEvent(DynamicDateTimeCombo.EVENT_CHANGE);
+ },
+ },
+ {
+ eventName: DynamicDateTimeTrigger.EVENT_CONFIRM,
+ action: () => {
+ const dateStore = this.storeTriggerValue;
+ const dateObj = this.trigger.getKey();
+ if (this.combo.isViewVisible() || isEqual(dateObj, dateStore)) {
+ return;
+ }
+ if (isNotEmptyString(dateObj) && !isEqual(dateObj, dateStore)) {
+ this.storeValue = this.trigger.getValue();
+ this.setValue(this.trigger.getValue());
+ } else if (isEmptyString(dateObj)) {
+ this.storeValue = null;
+ this.trigger.setValue();
+ }
+ this._checkDynamicValue(this.storeValue);
+ this.fireEvent(DynamicDateTimeCombo.EVENT_CONFIRM);
+ },
+ }
+ ],
+ }
+ ],
+ },
+ adjustLength: this.constants.comboAdjustHeight,
+ popup: {
+ el: {
+ type: DynamicDateTimePopup.xtype,
+ width: opts.isNeedAdjustWidth ? opts.width : undefined,
+ supportDynamic: opts.supportDynamic,
+ behaviors: opts.behaviors,
+ min: opts.minDate,
+ max: opts.maxDate,
+ ref: _ref => {
+ this.popup = _ref;
},
- }, {
- eventName: DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE,
- action: () => {
- const value = this.popup.getValue();
- if (this._checkValue(value)) {
- this.setValue(value);
+ listeners: [
+ {
+ eventName: DynamicDateTimePopup.BUTTON_CLEAR_EVENT_CHANGE,
+ action: () => {
+ this.setValue();
+ this.combo.hideView();
+ this.fireEvent(DynamicDateTimeCombo.EVENT_CONFIRM);
+ },
+ },
+ {
+ eventName: DynamicDateTimePopup.BUTTON_lABEL_EVENT_CHANGE,
+ action: () => {
+ const date = getDate();
+ this.setValue({
+ type: DynamicDateTimeCombo.Static,
+ value: {
+ year: date.getFullYear(),
+ month: date.getMonth() + 1,
+ day: date.getDate(),
+ hour: 0,
+ minute: 0,
+ second: 0,
+ },
+ });
+ this.combo.hideView();
+ this.fireEvent(DynamicDateTimeCombo.EVENT_CONFIRM);
+ },
+ },
+ {
+ eventName: DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE,
+ action: () => {
+ const value = this.popup.getValue();
+ if (this._checkValue(value)) {
+ this.setValue(value);
+ }
+ this.combo.hideView();
+ this.fireEvent(DynamicDateTimeCombo.EVENT_CONFIRM);
+ },
+ },
+ {
+ eventName: DynamicDateTimePopup.EVENT_CHANGE,
+ action: () => {
+ this.setValue(this.popup.getValue());
+ this.combo.hideView();
+ this.fireEvent(DynamicDateTimeCombo.EVENT_CONFIRM);
+ },
+ },
+ {
+ eventName: DynamicDateTimePopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW,
+ action: () => {
+ this.fireEvent(DynamicDateTimeCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
+ },
}
- this.combo.hideView();
- this.fireEvent(DynamicDateTimeCombo.EVENT_CONFIRM);
- },
- }, {
- eventName: DynamicDateTimePopup.EVENT_CHANGE,
- action: () => {
- this.setValue(this.popup.getValue());
- this.combo.hideView();
- this.fireEvent(DynamicDateTimeCombo.EVENT_CONFIRM);
- },
- }, {
- eventName: DynamicDateTimePopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW,
+ ],
+ },
+ },
+ listeners: [
+ {
+ eventName: Combo.EVENT_BEFORE_POPUPVIEW,
action: () => {
- this.fireEvent(DynamicDateTimeCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
+ this.popup.setMinDate(opts.minDate);
+ this.popup.setMaxDate(opts.maxDate);
+ this.popup.setValue(this.storeValue);
+ this.fireEvent(DynamicDateTimeCombo.EVENT_BEFORE_POPUPVIEW);
},
- }],
- },
+ }
+ ],
+ // // DEC-4250 和复选下拉一样,点击不收起
+ // hideChecker: function (e) {
+ // return self.triggerBtn.element.find(e.target).length === 0;
+ // }
},
- listeners: [{
- eventName: Combo.EVENT_BEFORE_POPUPVIEW,
- action: () => {
- this.popup.setMinDate(opts.minDate);
- this.popup.setMaxDate(opts.maxDate);
- this.popup.setValue(this.storeValue);
- this.fireEvent(DynamicDateTimeCombo.EVENT_BEFORE_POPUPVIEW);
- },
- }],
- // // DEC-4250 和复选下拉一样,点击不收起
- // hideChecker: function (e) {
- // return self.triggerBtn.element.find(e.target).length === 0;
- // }
- },
- top: 0,
- left: 0,
- right: 0,
- bottom: 0,
- }],
+ top: 0,
+ left: 0,
+ right: 0,
+ bottom: 0,
+ }
+ ],
};
}
diff --git a/src/widget/dynamicdatetime/dynamicdatetime.popup.js b/src/widget/dynamicdatetime/dynamicdatetime.popup.js
index a69aaabb1..a5f184e0c 100644
--- a/src/widget/dynamicdatetime/dynamicdatetime.popup.js
+++ b/src/widget/dynamicdatetime/dynamicdatetime.popup.js
@@ -1,17 +1,35 @@
-import { shortcut, Widget, createWidget, toPix, i18nText, createItems, print, isNull, isEmptyObject, isEmptyString, getDate, checkDateVoid, extend } from "@/core";
-import { DynamicDateCombo, DynamicDateHelper } from "../dynamicdate";
+import {
+ VerticalLayout,
+ GridLayout,
+ shortcut,
+ Widget,
+ createWidget,
+ toPix,
+ i18nText,
+ createItems,
+ print,
+ isNull,
+ isEmptyObject,
+ isEmptyString,
+ getDate,
+ checkDateVoid,
+ extend
+} from "@/core";
import { TextButton, Tab } from "@/base";
+import { LinearSegment } from "@/case";
+import { DynamicDateCard, DynamicDateCombo, DynamicDateHelper } from "../dynamicdate";
import { DateCalendarPopup } from "../date/calendar";
+import { DynamicDateTimeSelect } from "./dynamicdatetime.timeselect";
import { DynamicDateTimeCombo } from "./dynamicdatetime.combo";
@shortcut()
export class DynamicDateTimePopup extends Widget {
- static xtype = "bi.dynamic_date_time_popup"
+ static xtype = "bi.dynamic_date_time_popup";
constants = {
tabHeight: 40,
buttonHeight: 24,
- }
+ };
props = {
baseCls: "bi-dynamic-date-time-popup",
@@ -19,11 +37,11 @@ export class DynamicDateTimePopup extends Widget {
supportDynamic: true,
};
- static EVENT_CHANGE = "EVENT_CHANGE"
- static BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE"
- static BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE"
- static BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE"
- static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW"
+ static EVENT_CHANGE = "EVENT_CHANGE";
+ static BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE";
+ static BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE";
+ static BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE";
+ static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW";
_init() {
super._init(...arguments);
@@ -33,72 +51,86 @@ export class DynamicDateTimePopup extends Widget {
};
createWidget({
element: this,
- type: "bi.vertical",
- items: [{
- el: this._getTabJson(),
- }, {
- el: {
- type: "bi.grid",
- items: [
- [{
- type: "bi.text_button",
- cls: "bi-high-light bi-split-top",
- textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
- shadow: true,
- text: i18nText("BI-Basic_Clear"),
- listeners: [{
- eventName: TextButton.EVENT_CHANGE,
- action: () => {
- this.fireEvent(DynamicDateTimePopup.BUTTON_CLEAR_EVENT_CHANGE);
+ type: VerticalLayout.xtype,
+ items: [
+ {
+ el: this._getTabJson(),
+ },
+ {
+ el: {
+ type: GridLayout.xtype,
+ items: [
+ [
+ {
+ type: TextButton.xtype,
+ cls: "bi-high-light bi-split-top",
+ textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
+ shadow: true,
+ text: i18nText("BI-Basic_Clear"),
+ listeners: [
+ {
+ eventName: TextButton.EVENT_CHANGE,
+ action: () => {
+ this.fireEvent(DynamicDateTimePopup.BUTTON_CLEAR_EVENT_CHANGE);
+ },
+ }
+ ],
},
- }],
- }, {
- type: "bi.text_button",
- 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-Multi_Date_Today"),
- disabled: this._checkTodayValid(),
- ref: _ref => {
- this.todayButton = _ref;
- },
- listeners: [{
- eventName: TextButton.EVENT_CHANGE,
- action: () => {
- this.fireEvent(DynamicDateTimePopup.BUTTON_lABEL_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-Multi_Date_Today"),
+ disabled: this._checkTodayValid(),
+ ref: _ref => {
+ this.todayButton = _ref;
+ },
+ listeners: [
+ {
+ eventName: TextButton.EVENT_CHANGE,
+ action: () => {
+ this.fireEvent(DynamicDateTimePopup.BUTTON_lABEL_EVENT_CHANGE);
+ },
+ }
+ ],
},
- }],
- }, {
- type: "bi.text_button",
- cls: "bi-high-light bi-split-top",
- textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
- shadow: true,
- 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(DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE);
- } else {
- this.fireEvent(DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE);
- }
- },
- }],
- }]
- ],
- height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
- },
- }],
+ {
+ type: TextButton.xtype,
+ cls: "bi-high-light bi-split-top",
+ textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
+ shadow: true,
+ 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(DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE);
+ } else {
+ this.fireEvent(DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE);
+ }
+ },
+ }
+ ],
+ }
+ ]
+ ],
+ height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
+ },
+ }
+ ],
});
this.setValue(opts.value);
}
_getTabJson() {
const o = this.options;
-
+
return {
- type: "bi.tab",
+ type: Tab.xtype,
logic: {
dynamic: true,
},
@@ -106,32 +138,40 @@ export class DynamicDateTimePopup extends Widget {
this.dateTab = _ref;
},
tab: {
- type: "bi.linear_segment",
+ type: LinearSegment.xtype,
invisible: !o.supportDynamic,
cls: "bi-split-bottom",
height: this.constants.tabHeight,
- items: createItems([{
- text: i18nText("BI-Multi_Date_YMD"),
- value: DynamicDateCombo.Static,
- }, {
- text: i18nText("BI-Basic_Dynamic_Title"),
- value: DynamicDateCombo.Dynamic,
- }], {
- textAlign: "center",
- }),
+ items: createItems(
+ [
+ {
+ text: i18nText("BI-Multi_Date_YMD"),
+ value: DynamicDateCombo.Static,
+ },
+ {
+ text: i18nText("BI-Basic_Dynamic_Title"),
+ value: DynamicDateCombo.Dynamic,
+ }
+ ],
+ {
+ textAlign: "center",
+ }
+ ),
},
cardCreator: v => {
switch (v) {
case DynamicDateCombo.Dynamic:
return {
- type: "bi.dynamic_date_card",
+ type: DynamicDateCard.xtype,
cls: "dynamic-date-pane",
- listeners: [{
- eventName: "EVENT_CHANGE",
- action: () => {
- this._setInnerValue(this.year, v);
- },
- }],
+ listeners: [
+ {
+ eventName: "EVENT_CHANGE",
+ action: () => {
+ this._setInnerValue(this.year, v);
+ },
+ }
+ ],
ref: _ref => {
this.dynamicPane = _ref;
},
@@ -141,63 +181,70 @@ export class DynamicDateTimePopup extends Widget {
case DynamicDateCombo.Static:
default:
return {
- type: "bi.vertical",
- items: [{
- type: "bi.date_calendar_popup",
- behaviors: o.behaviors,
- min: this.options.min,
- max: this.options.max,
- ref: _ref => {
- this.ymd = _ref;
- },
- listeners: [{
- eventName: DateCalendarPopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW,
- action: () => {
- this.fireEvent(DynamicDateTimePopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
- },
- }],
- }, {
- el: {
- type: "bi.dynamic_date_time_select",
- cls: "bi-split-top",
+ type: VerticalLayout.xtype,
+ items: [
+ {
+ type: DateCalendarPopup.xtype,
+ behaviors: o.behaviors,
+ min: this.options.min,
+ max: this.options.max,
ref: _ref => {
- this.timeSelect = _ref;
+ this.ymd = _ref;
},
- height: 40,
+ listeners: [
+ {
+ eventName: DateCalendarPopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW,
+ action: () => {
+ this.fireEvent(DynamicDateTimePopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
+ },
+ }
+ ],
},
- }],
+ {
+ el: {
+ type: DynamicDateTimeSelect.xtype,
+ cls: "bi-split-top",
+ ref: _ref => {
+ this.timeSelect = _ref;
+ },
+ height: 40,
+ },
+ }
+ ],
};
}
},
- listeners: [{
- eventName: Tab.EVENT_CHANGE,
- action: () => {
- const v = this.dateTab.getSelect();
- const date = DynamicDateHelper.getCalculation(this.dynamicPane.getValue());
- switch (v) {
- case DynamicDateCombo.Static:
- this.ymd.setValue({
- year: date.getFullYear(),
- month: date.getMonth() + 1,
- day: date.getDate(),
- });
- this.timeSelect.setValue();
- this._setInnerValue();
- break;
- case DynamicDateCombo.Dynamic:
- default:
- if (this.storeValue && this.storeValue.type === DynamicDateCombo.Dynamic) {
- this.dynamicPane.setValue(this.storeValue.value);
- } else {
- this.dynamicPane.setValue({
- year: 0,
+ listeners: [
+ {
+ eventName: Tab.EVENT_CHANGE,
+ action: () => {
+ const v = this.dateTab.getSelect();
+ const date = DynamicDateHelper.getCalculation(this.dynamicPane.getValue());
+ switch (v) {
+ case DynamicDateCombo.Static:
+ this.ymd.setValue({
+ year: date.getFullYear(),
+ month: date.getMonth() + 1,
+ day: date.getDate(),
});
+ this.timeSelect.setValue();
+ this._setInnerValue();
+ break;
+ case DynamicDateCombo.Dynamic:
+ default:
+ if (this.storeValue && this.storeValue.type === DynamicDateCombo.Dynamic) {
+ this.dynamicPane.setValue(this.storeValue.value);
+ } else {
+ this.dynamicPane.setValue({
+ year: 0,
+ });
+ }
+ this._setInnerValue();
+ break;
}
- this._setInnerValue();
- break;
- }
- },
- }],
+ },
+ }
+ ],
};
}
@@ -220,7 +267,7 @@ export class DynamicDateTimePopup extends Widget {
_checkTodayValid() {
const o = this.options;
const today = getDate();
-
+
return !!checkDateVoid(today.getFullYear(), today.getMonth() + 1, today.getDate(), o.min, o.max)[0];
}
@@ -276,10 +323,13 @@ export class DynamicDateTimePopup extends Widget {
getValue() {
const type = this.dateTab.getSelect();
-
+
return {
type,
- value: type === DynamicDateTimeCombo.Static ? extend(this.ymd.getValue(), this.timeSelect.getValue()) : this.dynamicPane.getValue(),
+ value:
+ type === DynamicDateTimeCombo.Static
+ ? extend(this.ymd.getValue(), this.timeSelect.getValue())
+ : this.dynamicPane.getValue(),
};
}
}
diff --git a/src/widget/dynamicdatetime/dynamicdatetime.timeselect.js b/src/widget/dynamicdatetime/dynamicdatetime.timeselect.js
index 00f21b78c..475092cb5 100644
--- a/src/widget/dynamicdatetime/dynamicdatetime.timeselect.js
+++ b/src/widget/dynamicdatetime/dynamicdatetime.timeselect.js
@@ -1,15 +1,28 @@
-import { shortcut, Widget, isNaturalNumber, parseInt, isNumeric, i18nText, isNull, isEmptyString } from "@/core";
+import {
+ CenterAdaptLayout,
+ VerticalAdaptLayout,
+ shortcut,
+ Widget,
+ isNaturalNumber,
+ parseInt,
+ isNumeric,
+ i18nText,
+ isNull,
+ isEmptyString
+} from "@/core";
+import { NumberEditor } from "../numbereditor/number.editor";
+import { Label } from "@/base";
import { SignEditor } from "@/case";
@shortcut()
export class DynamicDateTimeSelect extends Widget {
- static xtype = "bi.dynamic_date_time_select"
+ static xtype = "bi.dynamic_date_time_select";
- static HOUR = 1
- static MINUTE = 2
- static SECOND = 3
+ static HOUR = 1;
+ static MINUTE = 2;
+ static SECOND = 3;
- static EVENT_CONFIRM = "EVENT_CONFIRM"
+ static EVENT_CONFIRM = "EVENT_CONFIRM";
props = {
baseCls: "bi-date-time-select",
@@ -17,111 +30,133 @@ export class DynamicDateTimeSelect extends Widget {
render() {
return {
- type: "bi.center_adapt",
- items: [{
- type: "bi.vertical_adapt",
- items: [{
- el: {
- type: "bi.number_editor",
- ref: _ref => {
- this.hour = _ref;
- },
- validationChecker (v) {
- return isNaturalNumber(v) && parseInt(v) < 24;
+ type: CenterAdaptLayout.xtype,
+ items: [
+ {
+ type: VerticalAdaptLayout.xtype,
+ items: [
+ {
+ el: {
+ type: NumberEditor.xtype,
+ ref: _ref => {
+ this.hour = _ref;
+ },
+ validationChecker(v) {
+ return isNaturalNumber(v) && parseInt(v) < 24;
+ },
+ errorText(v) {
+ if (isNumeric(v)) {
+ return i18nText("BI-Basic_Input_From_To_Number", "\"00-23\"");
+ }
+
+ return i18nText("BI-Numerical_Interval_Input_Data");
+ },
+ listeners: [
+ {
+ eventName: SignEditor.EVENT_CONFIRM,
+ action: () => {
+ const value = this.hour.getValue();
+ this._checkHour(value);
+ this.hour.setValue(this._formatValueToDoubleDigit(value));
+ this.fireEvent(DynamicDateTimeSelect.EVENT_CONFIRM);
+ },
+ },
+ {
+ eventName: SignEditor.EVENT_CHANGE,
+ action: () => {
+ const value = this._autoSwitch(
+ this.hour.getValue(),
+ DynamicDateTimeSelect.HOUR
+ );
+ this.hour.setValue(value);
+ },
+ }
+ ],
+ width: 60,
+ height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
+ },
},
- errorText (v) {
- if (isNumeric(v)) {
- return i18nText("BI-Basic_Input_From_To_Number", "\"00-23\"");
- }
-
- return i18nText("BI-Numerical_Interval_Input_Data");
+ {
+ type: Label.xtype,
+ text: ":",
+ width: 20,
},
- listeners: [{
- eventName: SignEditor.EVENT_CONFIRM,
- action: () => {
- const value = this.hour.getValue();
- this._checkHour(value);
- this.hour.setValue(this._formatValueToDoubleDigit(value));
- this.fireEvent(DynamicDateTimeSelect.EVENT_CONFIRM);
+ {
+ type: NumberEditor.xtype,
+ ref: _ref => {
+ this.minute = _ref;
},
- }, {
- eventName: SignEditor.EVENT_CHANGE,
- action: () => {
- const value = this._autoSwitch(this.hour.getValue(), DynamicDateTimeSelect.HOUR);
- this.hour.setValue(value);
+ validationChecker(v) {
+ return isNaturalNumber(v) && parseInt(v) < 60;
},
- }],
- width: 60,
- height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
- },
- }, {
- type: "bi.label",
- text: ":",
- width: 20,
- }, {
- type: "bi.number_editor",
- ref: _ref => {
- this.minute = _ref;
- },
- validationChecker (v) {
- return isNaturalNumber(v) && parseInt(v) < 60;
- },
- errorText (v) {
- if (isNumeric(v)) {
- return i18nText("BI-Basic_Input_From_To_Number", "\"00-59\"");
- }
-
- return i18nText("BI-Numerical_Interval_Input_Data");
- },
- listeners: [{
- eventName: SignEditor.EVENT_CONFIRM,
- action: () => {
- const value = this.minute.getValue();
- this._checkMinute(value);
- this.minute.setValue(this._formatValueToDoubleDigit(value), DynamicDateTimeSelect.MINUTE);
- this.fireEvent(DynamicDateTimeSelect.EVENT_CONFIRM);
+ errorText(v) {
+ if (isNumeric(v)) {
+ return i18nText("BI-Basic_Input_From_To_Number", "\"00-59\"");
+ }
+
+ return i18nText("BI-Numerical_Interval_Input_Data");
+ },
+ listeners: [
+ {
+ eventName: SignEditor.EVENT_CONFIRM,
+ action: () => {
+ const value = this.minute.getValue();
+ this._checkMinute(value);
+ this.minute.setValue(
+ this._formatValueToDoubleDigit(value),
+ DynamicDateTimeSelect.MINUTE
+ );
+ this.fireEvent(DynamicDateTimeSelect.EVENT_CONFIRM);
+ },
+ },
+ {
+ eventName: SignEditor.EVENT_CHANGE,
+ action: () => {
+ const value = this._autoSwitch(this.getValue(), DynamicDateTimeSelect.MINUTE);
+ this.minute.setValue(value);
+ },
+ }
+ ],
+ width: 60,
+ height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
},
- }, {
- eventName: SignEditor.EVENT_CHANGE,
- action: () => {
- const value = this._autoSwitch(this.getValue(), DynamicDateTimeSelect.MINUTE);
- this.minute.setValue(value);
+ {
+ type: Label.xtype,
+ text: ":",
+ width: 20,
},
- }],
- width: 60,
- height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
- }, {
- type: "bi.label",
- text: ":",
- width: 20,
- }, {
- type: "bi.number_editor",
- ref: _ref => {
- this.second = _ref;
- },
- validationChecker (v) {
- return isNaturalNumber(v) && parseInt(v) < 60;
- },
- errorText (v) {
- if (isNumeric(v)) {
- return i18nText("BI-Basic_Input_From_To_Number", "\"00-59\"");
+ {
+ type: NumberEditor.xtype,
+ ref: _ref => {
+ this.second = _ref;
+ },
+ validationChecker(v) {
+ return isNaturalNumber(v) && parseInt(v) < 60;
+ },
+ errorText(v) {
+ if (isNumeric(v)) {
+ return i18nText("BI-Basic_Input_From_To_Number", "\"00-59\"");
+ }
+
+ return i18nText("BI-Numerical_Interval_Input_Data");
+ },
+ listeners: [
+ {
+ eventName: SignEditor.EVENT_CONFIRM,
+ action: () => {
+ const value = this.second.getValue();
+ this._checkSecond(value);
+ this.second.setValue(this._formatValueToDoubleDigit(value));
+ this.fireEvent(DynamicDateTimeSelect.EVENT_CONFIRM);
+ },
+ }
+ ],
+ width: 60,
+ height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
}
-
- return i18nText("BI-Numerical_Interval_Input_Data");
- },
- listeners: [{
- eventName: SignEditor.EVENT_CONFIRM,
- action: () => {
- const value = this.second.getValue();
- this._checkSecond(value);
- this.second.setValue(this._formatValueToDoubleDigit(value));
- this.fireEvent(DynamicDateTimeSelect.EVENT_CONFIRM);
- },
- }],
- width: 60,
- height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
- }],
- }],
+ ],
+ }
+ ],
};
}
@@ -176,7 +211,7 @@ export class DynamicDateTimeSelect extends Widget {
break;
}
}
-
+
return value;
}
@@ -188,7 +223,7 @@ export class DynamicDateTimeSelect extends Widget {
if (value < 10) {
value = `0${value}`;
}
-
+
return value;
}
@@ -197,7 +232,7 @@ export class DynamicDateTimeSelect extends Widget {
v.hour = this._formatValueToDoubleDigit(v.hour) || "00";
v.minute = this._formatValueToDoubleDigit(v.minute) || "00";
v.second = this._formatValueToDoubleDigit(v.second) || "00";
-
+
return v;
}
diff --git a/src/widget/dynamicdatetime/dynamicdatetime.trigger.js b/src/widget/dynamicdatetime/dynamicdatetime.trigger.js
index 82e6a1a83..c28ae707c 100644
--- a/src/widget/dynamicdatetime/dynamicdatetime.trigger.js
+++ b/src/widget/dynamicdatetime/dynamicdatetime.trigger.js
@@ -1,11 +1,34 @@
-import { shortcut, i18nText, createWidget, isKey, checkDateLegal, parseDateTime, bind, isNotNull, isNotEmptyString, isEqual, isEmptyObject, isEmptyString, isNull, getDate, each, isNumeric, checkDateVoid, parseInt, size, print } from "@/core";
-import { Trigger } from "@/base";
import { SignEditor } from "@/case";
+import {
+ HTapeLayout,
+ AbsoluteLayout,
+ shortcut,
+ i18nText,
+ createWidget,
+ isKey,
+ checkDateLegal,
+ parseDateTime,
+ bind,
+ isNotNull,
+ isNotEmptyString,
+ isEqual,
+ isEmptyObject,
+ isEmptyString,
+ isNull,
+ getDate,
+ each,
+ isNumeric,
+ checkDateVoid,
+ parseInt,
+ size,
+ print
+} from "@/core";
+import { IconButton, Text, Trigger } from "@/base";
import { DynamicDateCombo, DynamicDateCard, DynamicDateHelper } from "../dynamicdate";
@shortcut()
export class DynamicDateTimeTrigger extends Trigger {
- static xtype = "bi.dynamic_date_time_trigger"
+ static xtype = "bi.dynamic_date_time_trigger";
_const = {
hgap: 4,
@@ -17,16 +40,16 @@ export class DynamicDateTimeTrigger extends Trigger {
iconWidth: 24,
};
- static EVENT_BLUR = "EVENT_BLUR"
- static EVENT_FOCUS = "EVENT_FOCUS"
- static EVENT_START = "EVENT_START"
- static EVENT_STOP = "EVENT_STOP"
- static EVENT_CONFIRM = "EVENT_CONFIRM"
- static EVENT_CHANGE = "EVENT_CHANGE"
- static EVENT_VALID = "EVENT_VALID"
- static EVENT_ERROR = "EVENT_ERROR"
- static EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK"
- static EVENT_KEY_DOWN = "EVENT_KEY_DOWN"
+ static EVENT_BLUR = "EVENT_BLUR";
+ static EVENT_FOCUS = "EVENT_FOCUS";
+ static EVENT_START = "EVENT_START";
+ static EVENT_STOP = "EVENT_STOP";
+ static EVENT_CONFIRM = "EVENT_CONFIRM";
+ static EVENT_CHANGE = "EVENT_CHANGE";
+ static EVENT_VALID = "EVENT_VALID";
+ static EVENT_ERROR = "EVENT_ERROR";
+ static EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK";
+ static EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
props() {
return {
@@ -47,21 +70,25 @@ export class DynamicDateTimeTrigger extends Trigger {
c = this._const;
this.storeTriggerValue = "";
this.editor = createWidget({
- type: "bi.sign_editor",
+ type: SignEditor.xtype,
simple: o.simple,
height: o.height,
validationChecker: v => {
const formatStr = this._getStandardDateStr(v);
const date = formatStr.match(/\d+/g);
!isKey(o.format) && this._autoAppend(v, date);
-
- return this._dateCheck(formatStr) && checkDateLegal(formatStr) && this._checkVoid({
- year: date[0] | 0,
- month: date[1] | 0,
- day: date[2] | 0,
- });
+
+ return (
+ this._dateCheck(formatStr) &&
+ checkDateLegal(formatStr) &&
+ this._checkVoid({
+ year: date[0] | 0,
+ month: date[1] | 0,
+ day: date[2] | 0,
+ })
+ );
},
- quitChecker () {
+ quitChecker() {
return false;
},
hgap: c.hgap,
@@ -72,11 +99,14 @@ export class DynamicDateTimeTrigger extends Trigger {
let str = "";
if (!isKey(o.format)) {
if (!this._dateCheck(v)) {
- str = this.editor.isEditing() ? i18nText("BI-Date_Trigger_Error_Text") : i18nText("BI-Year_Trigger_Invalid_Text");
+ str = this.editor.isEditing()
+ ? i18nText("BI-Date_Trigger_Error_Text")
+ : i18nText("BI-Year_Trigger_Invalid_Text");
} else {
const start = parseDateTime(o.min, "%Y-%X-%d");
const end = parseDateTime(o.max, "%Y-%X-%d");
- str = i18nText("BI-Basic_Date_Range_Error",
+ str = i18nText(
+ "BI-Basic_Date_Range_Error",
start.getFullYear(),
start.getMonth() + 1,
start.getDate(),
@@ -140,34 +170,40 @@ export class DynamicDateTimeTrigger extends Trigger {
this.fireEvent(DynamicDateTimeTrigger.EVENT_CHANGE);
});
createWidget({
- type: "bi.htape",
+ type: HTapeLayout.xtype,
element: this,
columnSize: ["", this._const.iconWidth],
- items: [{
- el: this.editor,
- }, {
- el: {
- type: "bi.icon_button",
- cls: "bi-trigger-icon-button date-font",
+ items: [
+ {
+ el: this.editor,
},
- width: o.iconWidth,
- }],
+ {
+ el: {
+ type: IconButton.xtype,
+ cls: "bi-trigger-icon-button date-font",
+ },
+ width: o.iconWidth,
+ }
+ ],
});
- !o.allowEdit && createWidget({
- type: "bi.absolute",
- element: this,
- items: [{
- el: {
- type: "bi.text",
- title: bind(this._getTitle, this),
- },
- left: 0,
- right: o.iconWidth,
- top: 0,
- bottom: 0,
- }],
- });
+ !o.allowEdit &&
+ createWidget({
+ type: AbsoluteLayout.xtype,
+ element: this,
+ items: [
+ {
+ el: {
+ type: Text.xtype,
+ title: bind(this._getTitle, this),
+ },
+ left: 0,
+ right: o.iconWidth,
+ top: 0,
+ bottom: 0,
+ }
+ ],
+ });
this.setValue(o.value);
}
@@ -185,15 +221,24 @@ export class DynamicDateTimeTrigger extends Trigger {
switch (type) {
case DynamicDateCombo.Dynamic:
- return isEmptyString(text) ? dateStr : (`${text}:${dateStr}`);
+ return isEmptyString(text) ? dateStr : `${text}:${dateStr}`;
case DynamicDateCombo.Static:
default:
if (isNull(value) || isNull(value.day)) {
return "";
}
-
- return print(getDate(value.year, (value.month - 1), value.day, value.hour || 0, value.minute || 0,
- value.second || 0), this._getFormatString());
+
+ return print(
+ getDate(
+ value.year,
+ value.month - 1,
+ value.day,
+ value.hour || 0,
+ value.minute || 0,
+ value.second || 0
+ ),
+ this._getFormatString()
+ );
}
}
@@ -251,7 +296,7 @@ export class DynamicDateTimeTrigger extends Trigger {
if (isNotEmptyString(suffixString)) {
dateString += ` ${suffixString}`;
}
-
+
return dateString;
}
@@ -260,15 +305,16 @@ export class DynamicDateTimeTrigger extends Trigger {
}
_dateCheck(date) {
- return print(parseDateTime(date, "%Y-%x-%d %H:%M:%S"), "%Y-%x-%d %H:%M:%S") === date ||
+ return (
+ print(parseDateTime(date, "%Y-%x-%d %H:%M:%S"), "%Y-%x-%d %H:%M:%S") === date ||
print(parseDateTime(date, "%Y-%X-%d %H:%M:%S"), "%Y-%X-%d %H:%M:%S") === date ||
print(parseDateTime(date, "%Y-%x-%e %H:%M:%S"), "%Y-%x-%e %H:%M:%S") === date ||
print(parseDateTime(date, "%Y-%X-%e %H:%M:%S"), "%Y-%X-%e %H:%M:%S") === date ||
-
print(parseDateTime(date, "%Y-%x-%d"), "%Y-%x-%d") === date ||
print(parseDateTime(date, "%Y-%X-%d"), "%Y-%X-%d") === date ||
print(parseDateTime(date, "%Y-%x-%e"), "%Y-%x-%e") === date ||
- print(parseDateTime(date, "%Y-%X-%e"), "%Y-%X-%e") === date;
+ print(parseDateTime(date, "%Y-%X-%e"), "%Y-%X-%e") === date
+ );
}
_checkVoid(obj) {
@@ -297,16 +343,20 @@ export class DynamicDateTimeTrigger extends Trigger {
_yearCheck(v) {
const date = print(parseDateTime(v, "%Y-%X-%d"), "%Y-%X-%d");
-
+
return print(parseDateTime(v, "%Y"), "%Y") === v && date >= this.options.min && date <= this.options.max;
}
_monthCheck(v) {
const date = parseDateTime(v, "%Y-%X-%d");
const dateStr = print(date, "%Y-%X-%d");
-
- return (date.getMonth() > 0 && (print(parseDateTime(v, "%Y-%X"), "%Y-%X") === v ||
- print(parseDateTime(v, "%Y-%x"), "%Y-%x") === v)) && dateStr >= this.options.min && dateStr <= this.options.max;
+
+ return (
+ date.getMonth() > 0 &&
+ (print(parseDateTime(v, "%Y-%X"), "%Y-%X") === v || print(parseDateTime(v, "%Y-%x"), "%Y-%x") === v) &&
+ dateStr >= this.options.min &&
+ dateStr <= this.options.max
+ );
}
_setInnerValue(date) {
@@ -320,38 +370,56 @@ export class DynamicDateTimeTrigger extends Trigger {
let endText = "";
if (isNotNull(obj.year)) {
if (parseInt(obj.year) !== 0) {
- value += Math.abs(obj.year) + i18nText("BI-Basic_Year") + (obj.year < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
+ value +=
+ Math.abs(obj.year) +
+ i18nText("BI-Basic_Year") +
+ (obj.year < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
}
endText = getPositionText(i18nText("BI-Basic_Year"), obj.position);
}
if (isNotNull(obj.quarter)) {
if (parseInt(obj.quarter) !== 0) {
- value += Math.abs(obj.quarter) + i18nText("BI-Basic_Single_Quarter") + (obj.quarter < 0 ? i18nText("BI-Basic_Front") : 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"));
}
endText = getPositionText(i18nText("BI-Basic_Single_Quarter"), obj.position);
}
if (isNotNull(obj.month)) {
if (parseInt(obj.month) !== 0) {
- value += Math.abs(obj.month) + i18nText("BI-Basic_Month") + (obj.month < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
+ value +=
+ Math.abs(obj.month) +
+ i18nText("BI-Basic_Month") +
+ (obj.month < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
}
endText = getPositionText(i18nText("BI-Basic_Month"), obj.position);
}
if (isNotNull(obj.week)) {
if (parseInt(obj.week) !== 0) {
- value += Math.abs(obj.week) + i18nText("BI-Basic_Week") + (obj.week < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
+ value +=
+ Math.abs(obj.week) +
+ i18nText("BI-Basic_Week") +
+ (obj.week < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
}
endText = getPositionText(i18nText("BI-Basic_Week"), obj.position);
}
if (isNotNull(obj.day)) {
if (parseInt(obj.day) !== 0) {
- value += Math.abs(obj.day) + i18nText("BI-Basic_Day") + (obj.day < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
+ value +=
+ Math.abs(obj.day) +
+ i18nText("BI-Basic_Day") +
+ (obj.day < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
}
endText = size(obj) === 1 ? getPositionText(i18nText("BI-Basic_Month"), obj.position) : "";
}
if (isNotNull(obj.workDay) && parseInt(obj.workDay) !== 0) {
- value += Math.abs(obj.workDay) + i18nText("BI-Basic_Work_Day") + (obj.workDay < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
+ value +=
+ Math.abs(obj.workDay) +
+ i18nText("BI-Basic_Work_Day") +
+ (obj.workDay < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
}
-
+
return value + endText;
function getPositionText(baseText, position) {
@@ -400,8 +468,17 @@ export class DynamicDateTimeTrigger extends Trigger {
this.editor.setState("");
this.editor.setValue("");
} else {
- const dateStr = print(getDate(value.year, (value.month - 1), value.day, value.hour || 0, value.minute || 0,
- value.second || 0), this._getFormatString());
+ const dateStr = print(
+ getDate(
+ value.year,
+ value.month - 1,
+ value.day,
+ value.hour || 0,
+ value.minute || 0,
+ value.second || 0
+ ),
+ this._getFormatString()
+ );
this.editor.setState(dateStr);
this.editor.setValue(dateStr);
}
diff --git a/src/widget/editor/editor.search.js b/src/widget/editor/editor.search.js
index aef7cff33..00909258f 100644
--- a/src/widget/editor/editor.search.js
+++ b/src/widget/editor/editor.search.js
@@ -1,35 +1,50 @@
-import { shortcut, Widget, extend, i18nText, emptyFn, createWidget, toPix, isKey, Controller, Events, HTapeLayout, isEndWithBlank } from "@/core";
+import {
+ shortcut,
+ Widget,
+ extend,
+ i18nText,
+ emptyFn,
+ createWidget,
+ toPix,
+ isKey,
+ Controller,
+ Events,
+ HTapeLayout,
+ isEndWithBlank
+} from "@/core";
import { IconButton, Editor, IconLabel } from "@/base";
@shortcut()
export class SearchEditor extends Widget {
- static xtype = "bi.search_editor"
-
- static EVENT_CHANGE = "EVENT_CHANGE"
- static EVENT_FOCUS = "EVENT_FOCUS"
- static EVENT_BLUR = "EVENT_BLUR"
- static EVENT_CLICK = "EVENT_CLICK"
- static EVENT_KEY_DOWN = "EVENT_KEY_DOWN"
- static EVENT_SPACE = "EVENT_SPACE"
- static EVENT_BACKSPACE = "EVENT_BACKSPACE"
- static EVENT_CLEAR = "EVENT_CLEAR"
- static EVENT_START = "EVENT_START"
- static EVENT_PAUSE = "EVENT_PAUSE"
- static EVENT_STOP = "EVENT_STOP"
- static EVENT_CONFIRM = "EVENT_CONFIRM"
- static EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM"
- static EVENT_VALID = "EVENT_VALID"
- static EVENT_ERROR = "EVENT_ERROR"
- static EVENT_ENTER = "EVENT_ENTER"
- static EVENT_RESTRICT = "EVENT_RESTRICT"
- static EVENT_REMOVE = "EVENT_REMOVE"
- static EVENT_EMPTY = "EVENT_EMPTY"
+ static xtype = "bi.search_editor";
+
+ static EVENT_CHANGE = "EVENT_CHANGE";
+ static EVENT_FOCUS = "EVENT_FOCUS";
+ static EVENT_BLUR = "EVENT_BLUR";
+ static EVENT_CLICK = "EVENT_CLICK";
+ static EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
+ static EVENT_SPACE = "EVENT_SPACE";
+ static EVENT_BACKSPACE = "EVENT_BACKSPACE";
+ static EVENT_CLEAR = "EVENT_CLEAR";
+ static EVENT_START = "EVENT_START";
+ static EVENT_PAUSE = "EVENT_PAUSE";
+ static EVENT_STOP = "EVENT_STOP";
+ static EVENT_CONFIRM = "EVENT_CONFIRM";
+ static EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM";
+ static EVENT_VALID = "EVENT_VALID";
+ static EVENT_ERROR = "EVENT_ERROR";
+ static EVENT_ENTER = "EVENT_ENTER";
+ static EVENT_RESTRICT = "EVENT_RESTRICT";
+ static EVENT_REMOVE = "EVENT_REMOVE";
+ static EVENT_EMPTY = "EVENT_EMPTY";
_defaultConfig(config) {
const conf = super._defaultConfig(...arguments);
-
+
return extend(conf, {
- baseCls: `bi-search-editor bi-focus-shadow ${config.simple ? "bi-border-bottom" : "bi-border bi-border-radius"}`,
+ baseCls: `bi-search-editor bi-focus-shadow ${
+ config.simple ? "bi-border-bottom" : "bi-border bi-border-radius"
+ }`,
height: 24,
errorText: "",
watermark: i18nText("BI-Basic_Search"),
@@ -72,20 +87,21 @@ export class SearchEditor extends Widget {
element: this,
height: toPix(o.height, o.simple ? 1 : 2),
type: HTapeLayout.xtype,
- items: [{
- el: {
- type: IconLabel.xtype,
- cls: "search-font",
+ items: [
+ {
+ el: {
+ type: IconLabel.xtype,
+ cls: "search-font",
+ },
+ width: 24,
+ },
+ {
+ el: this.editor,
},
- width: 24,
- },
- {
- el: this.editor,
- },
- {
- el: this.clear,
- width: 24,
- }
+ {
+ el: this.clear,
+ width: 24,
+ }
],
});
this.editor.on(Controller.EVENT_CHANGE, (...args) => {
@@ -115,7 +131,6 @@ export class SearchEditor extends Widget {
this.fireEvent(SearchEditor.EVENT_BACKSPACE);
});
-
this.editor.on(Editor.EVENT_VALID, () => {
this.fireEvent(SearchEditor.EVENT_VALID);
});
@@ -185,7 +200,7 @@ export class SearchEditor extends Widget {
if (isEndWithBlank(val)) {
return keywords.concat([" "]);
}
-
+
return keywords;
}
diff --git a/src/widget/editor/editor.search.small.js b/src/widget/editor/editor.search.small.js
index 890a1499f..90e44de8d 100644
--- a/src/widget/editor/editor.search.small.js
+++ b/src/widget/editor/editor.search.small.js
@@ -3,11 +3,11 @@ import { SearchEditor } from "./editor.search";
@shortcut()
export class SmallSearchEditor extends SearchEditor {
- static xtype = "bi.small_search_editor"
+ static xtype = "bi.small_search_editor";
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
-
+
return extend(conf, {
baseCls: `${conf.baseCls || ""} bi-small-search-editor`,
height: 20,
diff --git a/src/widget/editor/editor.text.js b/src/widget/editor/editor.text.js
index 8841eb339..ba87a3a5a 100644
--- a/src/widget/editor/editor.text.js
+++ b/src/widget/editor/editor.text.js
@@ -3,30 +3,30 @@ import { Editor } from "@/base";
@shortcut()
export class TextEditor extends Widget {
- static xtype = "bi.text_editor"
+ static xtype = "bi.text_editor";
- static EVENT_CHANGE = "EVENT_CHANGE"
- static EVENT_FOCUS = "EVENT_FOCUS"
- static EVENT_BLUR = "EVENT_BLUR"
- static EVENT_CLICK = "EVENT_CLICK"
- static EVENT_KEY_DOWN = "EVENT_KEY_DOWN"
- static EVENT_SPACE = "EVENT_SPACE"
- static EVENT_BACKSPACE = "EVENT_BACKSPACE"
- static EVENT_START = "EVENT_START"
- static EVENT_PAUSE = "EVENT_PAUSE"
- static EVENT_STOP = "EVENT_STOP"
- static EVENT_CONFIRM = "EVENT_CONFIRM"
- static EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM"
- static EVENT_VALID = "EVENT_VALID"
- static EVENT_ERROR = "EVENT_ERROR"
- static EVENT_ENTER = "EVENT_ENTER"
- static EVENT_RESTRICT = "EVENT_RESTRICT"
- static EVENT_REMOVE = "EVENT_REMOVE"
- static EVENT_EMPTY = "EVENT_EMPTY"
+ static EVENT_CHANGE = "EVENT_CHANGE";
+ static EVENT_FOCUS = "EVENT_FOCUS";
+ static EVENT_BLUR = "EVENT_BLUR";
+ static EVENT_CLICK = "EVENT_CLICK";
+ static EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
+ static EVENT_SPACE = "EVENT_SPACE";
+ static EVENT_BACKSPACE = "EVENT_BACKSPACE";
+ static EVENT_START = "EVENT_START";
+ static EVENT_PAUSE = "EVENT_PAUSE";
+ static EVENT_STOP = "EVENT_STOP";
+ static EVENT_CONFIRM = "EVENT_CONFIRM";
+ static EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM";
+ static EVENT_VALID = "EVENT_VALID";
+ static EVENT_ERROR = "EVENT_ERROR";
+ static EVENT_ENTER = "EVENT_ENTER";
+ static EVENT_RESTRICT = "EVENT_RESTRICT";
+ static EVENT_REMOVE = "EVENT_REMOVE";
+ static EVENT_EMPTY = "EVENT_EMPTY";
_defaultConfig(config) {
const conf = super._defaultConfig(...arguments);
-
+
return extend(conf, {
extraCls: `bi-text-editor bi-focus-shadow ${config.simple ? "bi-border-bottom" : "bi-border"}`,
hgap: 4,
@@ -97,7 +97,6 @@ export class TextEditor extends Widget {
this.fireEvent(TextEditor.EVENT_BACKSPACE);
});
-
this.editor.on(Editor.EVENT_VALID, () => {
this.element.removeClass("error");
this.fireEvent(TextEditor.EVENT_VALID);
diff --git a/src/widget/editor/editor.text.small.js b/src/widget/editor/editor.text.small.js
index 0d79c8c22..5f574fe0f 100644
--- a/src/widget/editor/editor.text.small.js
+++ b/src/widget/editor/editor.text.small.js
@@ -3,11 +3,11 @@ import { TextEditor } from "./editor.text";
@shortcut()
export class SmallTextEditor extends TextEditor {
- static xtype = "bi.small_text_editor"
+ static xtype = "bi.small_text_editor";
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
-
+
return extend(conf, {
baseCls: `${conf.baseCls || ""} bi-small-text-editor`,
height: 20,
diff --git a/src/widget/index.js b/src/widget/index.js
index acd1aaf9d..cc74ecb27 100644
--- a/src/widget/index.js
+++ b/src/widget/index.js
@@ -1,61 +1,14 @@
-import { Collapse } from "./collapse/collapse";
-import * as calendar from "./date/calendar";
-import * as dynamicdate from "./dynamicdate";
-import * as datepane from "./datepane";
-import * as datetime from "./datetime";
-import * as datetimepane from "./datetimepane";
-import * as dynamicdatetime from "./dynamicdatetime";
-import * as time from "./time";
-import * as editor from "./editor";
-import * as downList from "./downlist";
-import * as singleSliderItem from "./singleslider";
-import * as intervalSliderItem from "./intervalslider";
-import { SelectTreeCombo } from "./selecttree/selecttree.combo";
-import { SingleTreeCombo } from "./singletree/singletree.combo";
-import { MultiTreeCombo } from "./multitree/multi.tree.combo";
-import { MultiTreeInsertCombo } from "./multitree/multi.tree.insert.combo";
-import { MultiTreeListCombo } from "./multitree/multi.tree.list.combo";
-import { NumberEditor } from "./numbereditor/number.editor";
-import { NumberInterval } from "./numberinterval/numberinterval";
-import * as multiselect from "./multiselect";
-import * as multiselectlist from "./multiselectlist";
-import * as multilayerselectree from "./multilayerselecttree";
-import * as year from "./year";
-import { YearInterval } from "./yearinterval/yearinterval";
-import * as singleselect from "./singleselect";
-import * as multilayerdownlist from "./multilayerdownlist";
-import * as multilayersingletree from "./multilayersingletree";
-
-
-Object.assign(BI, {
- Collapse,
- ...calendar,
- ...dynamicdate,
- ...datepane,
- ...datetime,
- ...datetimepane,
- ...dynamicdatetime,
- ...time,
- ...year,
- ...editor,
- ...downList,
- ...singleSliderItem,
- ...intervalSliderItem,
- SelectTreeCombo,
- SingleTreeCombo,
- MultiTreeCombo,
- MultiTreeInsertCombo,
- MultiTreeListCombo,
- NumberEditor,
- NumberInterval,
- YearInterval,
- ...multiselect,
- ...multiselectlist,
- ...multilayerselectree,
- ...singleselect,
- ...multilayerdownlist,
- ...multilayersingletree,
-});
+export { Collapse } from "./collapse/collapse";
+export { SelectTreeCombo } from "./selecttree/selecttree.combo";
+export { SingleTreeCombo } from "./singletree/singletree.combo";
+export { MultiTreeCombo } from "./multitree/multi.tree.combo";
+export { MultiTreeInsertCombo } from "./multitree/multi.tree.insert.combo";
+export { MultiTreeListCombo } from "./multitree/multi.tree.list.combo";
+export { NumberEditor } from "./numbereditor/number.editor";
+export { NumberInterval } from "./numberinterval/numberinterval";
+export { YearMonthInterval } from "./yearmonthinterval/yearmonthinterval";
+export { YearQuarterInterval } from "./yearquarterinterval/yearquarterinterval";
+export { YearInterval } from "./yearinterval/yearinterval";
export * from "./date/calendar";
export * from "./dynamicdate";
@@ -65,6 +18,7 @@ export * from "./datetimepane";
export * from "./dynamicdatetime";
export * from "./time";
export * from "./editor";
+export * from "./yearmonth";
export * from "./multiselect";
export * from "./multiselectlist";
export * from "./downlist";
@@ -73,18 +27,9 @@ export * from "./intervalslider";
export * from "./year";
export * from "./multilayersingletree";
export * from "./multilayerselecttree";
+export * from "./searchmultitextvaluecombo";
export * from "./singleselect";
export * from "./multilayerdownlist";
-export * from "./multilayersingletree";
-
-export {
- Collapse,
- NumberEditor,
- NumberInterval,
- SelectTreeCombo,
- SingleTreeCombo,
- MultiTreeCombo,
- MultiTreeInsertCombo,
- MultiTreeListCombo,
- YearInterval
-};
+export * from "./yearquarter";
+export * from "./textvaluedownlistcombo";
+export * from "./searchmultitextvaluecombo";
diff --git a/src/widget/intervalslider/index.js b/src/widget/intervalslider/index.js
index 2a99c23bd..cee9fd741 100644
--- a/src/widget/intervalslider/index.js
+++ b/src/widget/intervalslider/index.js
@@ -1,2 +1,2 @@
-export { AccurateCalculationModel } from "./model.accuratecalculation";
-export { IntervalSlider } from "./intervalslider";
+export { AccurateCalculationModel } from "./model.accuratecalculation";
+export { IntervalSlider } from "./intervalslider";
diff --git a/src/widget/intervalslider/intervalslider.js b/src/widget/intervalslider/intervalslider.js
index bd0121523..ab8732ee2 100644
--- a/src/widget/intervalslider/intervalslider.js
+++ b/src/widget/intervalslider/intervalslider.js
@@ -1,4 +1,6 @@
import {
+ VerticalFillLayout,
+ HorizontalLayout,
shortcut,
createWidget,
toPix,
@@ -32,7 +34,7 @@ export class IntervalSlider extends Single {
SLIDER_WIDTH: 30,
SLIDER_HEIGHT: 30,
TRACK_HEIGHT: 24,
- }
+ };
props = {
baseCls: "bi-interval-slider bi-slider-track",
digit: false,
@@ -84,9 +86,7 @@ export class IntervalSlider extends Single {
});
this.labelOne.element.hover(
() => {
- this.labelOne.element
- .removeClass("bi-border")
- .addClass("bi-border");
+ this.labelOne.element.removeClass("bi-border").addClass("bi-border");
},
() => {
this.labelOne.element.removeClass("bi-border");
@@ -100,12 +100,7 @@ export class IntervalSlider extends Single {
const significantPercent = parseFloat(percent.toFixed(1)); // 分成1000份
this._setSliderOnePosition(significantPercent);
this._setBlueTrack();
- this._checkLabelPosition(
- oldValueOne,
- this.valueTwo,
- this.valueOne,
- this.valueTwo
- );
+ this._checkLabelPosition(oldValueOne, this.valueTwo, this.valueOne, this.valueTwo);
this.fireEvent(IntervalSlider.EVENT_CHANGE);
});
@@ -120,9 +115,7 @@ export class IntervalSlider extends Single {
});
this.labelTwo.element.hover(
() => {
- this.labelTwo.element
- .removeClass("bi-border")
- .addClass("bi-border");
+ this.labelTwo.element.removeClass("bi-border").addClass("bi-border");
},
() => {
this.labelTwo.element.removeClass("bi-border");
@@ -136,12 +129,7 @@ export class IntervalSlider extends Single {
const significantPercent = parseFloat(percent.toFixed(1));
this._setSliderTwoPosition(significantPercent);
this._setBlueTrack();
- this._checkLabelPosition(
- this.valueOne,
- oldValueTwo,
- this.valueOne,
- this.valueTwo
- );
+ this._checkLabelPosition(this.valueOne, oldValueTwo, this.valueOne, this.valueTwo);
this.fireEvent(IntervalSlider.EVENT_CHANGE);
});
@@ -156,7 +144,7 @@ export class IntervalSlider extends Single {
this._setVisible(false);
return {
- type: "bi.vertical_fill",
+ type: VerticalFillLayout.xtype,
rowSize: [30, 30],
items: [
this._createLabelWrapper(),
@@ -165,7 +153,7 @@ export class IntervalSlider extends Single {
items: [
{
el: {
- type: "bi.horizontal",
+ type: HorizontalLayout.xtype,
horizontalAlign: "stretch",
verticalAlign: "middle",
columnSize: ["fill"],
@@ -198,22 +186,12 @@ export class IntervalSlider extends Single {
this._setSliderOnePosition(significantPercent);
this.labelOne.setValue(v);
this.valueOne = v;
- this._checkLabelPosition(
- oldValueOne,
- oldValueTwo,
- v,
- this.valueTwo
- );
+ this._checkLabelPosition(oldValueOne, oldValueTwo, v, this.valueTwo);
} else {
this._setSliderTwoPosition(significantPercent);
this.labelTwo.setValue(v);
this.valueTwo = v;
- this._checkLabelPosition(
- oldValueOne,
- oldValueTwo,
- this.valueOne,
- v
- );
+ this._checkLabelPosition(oldValueOne, oldValueTwo, this.valueOne, v);
}
this._setBlueTrack();
}
@@ -221,9 +199,7 @@ export class IntervalSlider extends Single {
_rePosBySizeAfterStop(size, isLeft) {
const percent = (size * 100) / this._getGrayTrackLength();
const significantPercent = parseFloat(percent.toFixed(1));
- isLeft
- ? this._setSliderOnePosition(significantPercent)
- : this._setSliderTwoPosition(significantPercent);
+ isLeft ? this._setSliderOnePosition(significantPercent) : this._setSliderTwoPosition(significantPercent);
}
_draggable(widget, isLeft) {
@@ -232,7 +208,7 @@ export class IntervalSlider extends Single {
offset = 0,
defaultSize = 0;
const mouseMoveTracker = new MouseMoveTracker(
- (deltaX => {
+ deltaX => {
if (mouseMoveTracker.isDragging()) {
startDrag = true;
offset += deltaX;
@@ -240,8 +216,8 @@ export class IntervalSlider extends Single {
widget.element.addClass("dragging");
this._rePosBySizeAfterMove(size, isLeft);
}
- }),
- (() => {
+ },
+ () => {
if (startDrag === true) {
size = optimizeSize(size);
this._rePosBySizeAfterStop(size, isLeft);
@@ -253,7 +229,7 @@ export class IntervalSlider extends Single {
widget.element.removeClass("dragging");
mouseMoveTracker.releaseMouseMoves();
this.fireEvent(IntervalSlider.EVENT_CHANGE);
- }),
+ },
window
);
widget.element.on("mousedown", function (event) {
@@ -270,7 +246,7 @@ export class IntervalSlider extends Single {
_createLabelWrapper() {
const c = this._constant;
-
+
return {
el: {
type: VerticalLayout.xtype,
@@ -308,7 +284,7 @@ export class IntervalSlider extends Single {
_createSliderWrapper() {
return {
el: {
- type: "bi.horizontal",
+ type: HorizontalLayout.xtype,
horizontalAlign: "stretch",
verticalAlign: "middle",
items: [
@@ -340,7 +316,7 @@ export class IntervalSlider extends Single {
_createTrackWrapper() {
return createWidget({
- type: "bi.horizontal",
+ type: HorizontalLayout.xtype,
cls: "track-wrapper",
horizontalAlign: "stretch",
verticalAlign: "middle",
@@ -375,7 +351,7 @@ export class IntervalSlider extends Single {
const o = this.options;
let valid = false;
// 像90.这样的既不属于整数又不属于小数,是不合法的值
- let dotText = (`${v}`).split(".")[1];
+ let dotText = `${v}`.split(".")[1];
// eslint-disable-next-line no-empty
if (isEmptyString(dotText)) {
} else {
@@ -390,7 +366,7 @@ export class IntervalSlider extends Single {
}
}
}
-
+
return valid;
}
@@ -421,9 +397,7 @@ export class IntervalSlider extends Single {
(oldValueOne <= oldValueTwo && valueOne > valueTwo) ||
(oldValueOne >= oldValueTwo && valueOne < valueTwo)
) {
- const isSliderOneLeft =
- parseFloat(this.labelOne.getValue()) <
- parseFloat(this.labelTwo.getValue());
+ const isSliderOneLeft = parseFloat(this.labelOne.getValue()) < parseFloat(this.labelTwo.getValue());
this._resetLabelPosition(!isSliderOneLeft);
}
}
@@ -475,11 +449,7 @@ export class IntervalSlider extends Single {
}
_setErrorText() {
- const errorText = i18nText(
- "BI-Basic_Please_Enter_Number_Between",
- this.min,
- this.max
- );
+ const errorText = i18nText("BI-Basic_Please_Enter_Number_Between", this.min, this.max);
this.labelOne.setErrorText(errorText);
this.labelTwo.setErrorText(errorText);
}
@@ -500,27 +470,13 @@ export class IntervalSlider extends Single {
const mul = this.calculation.accurateMultiplication(sub, percent);
const div = this.calculation.accurateDivisionTenExponent(mul, 2);
if (this.precision < 0) {
- const value = parseFloat(
- this.calculation.accurateAddition(div, this.min)
- );
- const reduceValue = Math.round(
- this.calculation.accurateDivisionTenExponent(
- value,
- -this.precision
- )
- );
-
- return this.calculation.accurateMultiplication(
- reduceValue,
- Math.pow(10, -this.precision)
- );
+ const value = parseFloat(this.calculation.accurateAddition(div, this.min));
+ const reduceValue = Math.round(this.calculation.accurateDivisionTenExponent(value, -this.precision));
+
+ return this.calculation.accurateMultiplication(reduceValue, Math.pow(10, -this.precision));
}
-
- return parseFloat(
- this.calculation
- .accurateAddition(div, this.min)
- .toFixed(this.precision)
- );
+
+ return parseFloat(this.calculation.accurateAddition(div, this.min).toFixed(this.precision));
}
_getPercentByValue(v) {
@@ -541,11 +497,11 @@ export class IntervalSlider extends Single {
arr = pre.split("e");
const decimalPartLength = size(arr[0].split(".")[1]);
const sciencePartLength = parseInt(arr[1].substring(1));
-
+
return decimalPartLength - sciencePartLength;
}
arr = pre.split(".");
-
+
return arr.length > 1 ? arr[1].length : 0;
}
@@ -556,20 +512,16 @@ export class IntervalSlider extends Single {
if (value >= this.max) {
return this.max;
}
-
+
return value;
}
_setEnable(b) {
super._setEnable.apply(this, [b]);
if (b) {
- this.blueTrack.element
- .removeClass("disabled-blue-track")
- .addClass("blue-track");
+ this.blueTrack.element.removeClass("disabled-blue-track").addClass("blue-track");
} else {
- this.blueTrack.element
- .removeClass("blue-track")
- .addClass("disabled-blue-track");
+ this.blueTrack.element.removeClass("blue-track").addClass("disabled-blue-track");
}
}
@@ -577,7 +529,7 @@ export class IntervalSlider extends Single {
if (this.valueOne <= this.valueTwo) {
return { min: this.valueOne, max: this.valueTwo };
}
-
+
return { min: this.valueTwo, max: this.valueOne };
}
@@ -602,22 +554,14 @@ export class IntervalSlider extends Single {
const o = this.options;
let valueOne = parseFloat(v.min);
let valueTwo = parseFloat(v.max);
- valueOne =
- o.digit === false
- ? valueOne
- : parseFloat(valueOne.toFixed(o.digit));
- valueTwo =
- o.digit === false
- ? valueTwo
- : parseFloat(valueTwo.toFixed(o.digit));
+ valueOne = o.digit === false ? valueOne : parseFloat(valueOne.toFixed(o.digit));
+ valueTwo = o.digit === false ? valueTwo : parseFloat(valueTwo.toFixed(o.digit));
if (!isNaN(valueOne) && !isNaN(valueTwo)) {
if (this._checkValidation(valueOne)) {
- this.valueOne =
- this.valueOne <= this.valueTwo ? valueOne : valueTwo;
+ this.valueOne = this.valueOne <= this.valueTwo ? valueOne : valueTwo;
}
if (this._checkValidation(valueTwo)) {
- this.valueTwo =
- this.valueOne <= this.valueTwo ? valueTwo : valueOne;
+ this.valueTwo = this.valueOne <= this.valueTwo ? valueTwo : valueOne;
}
if (valueOne < this.min) {
this.valueOne = this.min;
@@ -648,20 +592,9 @@ export class IntervalSlider extends Single {
(isNumeric(this.valueOne) || isNotEmptyString(this.valueOne)) &&
(isNumeric(this.valueTwo) || isNotEmptyString(this.valueTwo))
) {
- this.labelOne.setValue(
- o.digit === false
- ? this.valueOne
- : parseFloat(this.valueOne).toFixed(o.digit)
- );
- this.labelTwo.setValue(
- o.digit === false
- ? this.valueTwo
- : parseFloat(this.valueTwo).toFixed(o.digit)
- );
- this._setAllPosition(
- this._getPercentByValue(this.valueOne),
- this._getPercentByValue(this.valueTwo)
- );
+ this.labelOne.setValue(o.digit === false ? this.valueOne : parseFloat(this.valueOne).toFixed(o.digit));
+ this.labelTwo.setValue(o.digit === false ? this.valueTwo : parseFloat(this.valueTwo).toFixed(o.digit));
+ this._setAllPosition(this._getPercentByValue(this.valueOne), this._getPercentByValue(this.valueTwo));
} else {
this.labelOne.setValue(this.min);
this.labelTwo.setValue(this.max);
diff --git a/src/widget/intervalslider/model.accuratecalculation.js b/src/widget/intervalslider/model.accuratecalculation.js
index fcc944e78..3d423faa5 100644
--- a/src/widget/intervalslider/model.accuratecalculation.js
+++ b/src/widget/intervalslider/model.accuratecalculation.js
@@ -16,7 +16,7 @@ export class AccurateCalculationModel extends Widget {
for (let i = 0; i < n; i++) {
magnitude += "0";
}
-
+
return parseInt(magnitude);
}
@@ -24,8 +24,7 @@ export class AccurateCalculationModel extends Widget {
if (stringNumber1.numDecimalLength === stringNumber2.numDecimalLength) {
return;
}
- let magnitudeDiff =
- stringNumber1.numDecimalLength - stringNumber2.numDecimalLength;
+ let magnitudeDiff = stringNumber1.numDecimalLength - stringNumber2.numDecimalLength;
let needAddZero;
if (magnitudeDiff > 0) {
needAddZero = stringNumber2;
@@ -54,7 +53,7 @@ export class AccurateCalculationModel extends Widget {
numDecimal = numStrArray[1];
numDecimalLength = numStrArray[1].length;
}
-
+
return {
numInteger,
numDecimal,
@@ -67,27 +66,16 @@ export class AccurateCalculationModel extends Widget {
const stringNumber1 = this._stringNumberFactory(num1);
const stringNumber2 = this._stringNumberFactory(num2);
// 整数部分计算
- let integerResult =
- parseInt(stringNumber1.numInteger) -
- parseInt(stringNumber2.numInteger);
+ let integerResult = parseInt(stringNumber1.numInteger) - parseInt(stringNumber2.numInteger);
// 小数部分
this._formatDecimal(stringNumber1, stringNumber2);
- const decimalMaxLength = getDecimalMaxLength(
- stringNumber1,
- stringNumber2
- );
+ const decimalMaxLength = getDecimalMaxLength(stringNumber1, stringNumber2);
let decimalResultTemp;
let decimalResult;
- if (
- parseInt(stringNumber1.numDecimal) >=
- parseInt(stringNumber2.numDecimal)
- ) {
- decimalResultTemp = (
- parseInt(stringNumber1.numDecimal) -
- parseInt(stringNumber2.numDecimal)
- ).toString();
+ if (parseInt(stringNumber1.numDecimal) >= parseInt(stringNumber2.numDecimal)) {
+ decimalResultTemp = (parseInt(stringNumber1.numDecimal) - parseInt(stringNumber2.numDecimal)).toString();
decimalResult = addZero(decimalResultTemp, decimalMaxLength);
} else {
// 否则借位
@@ -101,14 +89,14 @@ export class AccurateCalculationModel extends Widget {
decimalResult = addZero(decimalResultTemp, decimalMaxLength);
}
const result = `${integerResult}.${decimalResult}`;
-
+
return parseFloat(result);
function getDecimalMaxLength(num1, num2) {
if (num1.numDecimal.length >= num2.numDecimal.length) {
return num1.numDecimal.length;
}
-
+
return num2.numDecimal.length;
}
@@ -117,7 +105,7 @@ export class AccurateCalculationModel extends Widget {
for (let i = 0; i < diff; i++) {
resultTemp = `0${resultTemp}`;
}
-
+
return resultTemp;
}
}
@@ -127,30 +115,22 @@ export class AccurateCalculationModel extends Widget {
const stringNumber1 = this._stringNumberFactory(num1);
const stringNumber2 = this._stringNumberFactory(num2);
// 整数部分计算
- let integerResult =
- parseInt(stringNumber1.numInteger) +
- parseInt(stringNumber2.numInteger);
+ let integerResult = parseInt(stringNumber1.numInteger) + parseInt(stringNumber2.numInteger);
// 小数部分
this._formatDecimal(stringNumber1, stringNumber2);
- let decimalResult = (
- parseInt(stringNumber1.numDecimal) +
- parseInt(stringNumber2.numDecimal)
- ).toString();
+ let decimalResult = (parseInt(stringNumber1.numDecimal) + parseInt(stringNumber2.numDecimal)).toString();
if (decimalResult !== "0") {
if (decimalResult.length <= stringNumber1.numDecimal.length) {
- decimalResult = addZero(
- decimalResult,
- stringNumber1.numDecimal.length
- );
+ decimalResult = addZero(decimalResult, stringNumber1.numDecimal.length);
} else {
integerResult++; // 进一
decimalResult = decimalResult.slice(1);
}
}
const result = `${integerResult}.${decimalResult}`;
-
+
return parseFloat(result);
function addZero(resultTemp, length) {
@@ -158,7 +138,7 @@ export class AccurateCalculationModel extends Widget {
for (let i = 0; i < diff; i++) {
resultTemp = `0${resultTemp}`;
}
-
+
return resultTemp;
}
}
@@ -168,33 +148,25 @@ export class AccurateCalculationModel extends Widget {
const stringNumber1 = this._stringNumberFactory(num1);
const stringNumber2 = this._stringNumberFactory(num2);
// 整数部分计算
- const integerResult =
- parseInt(stringNumber1.numInteger) *
- parseInt(stringNumber2.numInteger);
+ const integerResult = parseInt(stringNumber1.numInteger) * parseInt(stringNumber2.numInteger);
// num1的小数和num2的整数
const dec1Int2 = this._accurateDivisionTenExponent(
- parseInt(stringNumber1.numDecimal) *
- parseInt(stringNumber2.numInteger),
+ parseInt(stringNumber1.numDecimal) * parseInt(stringNumber2.numInteger),
stringNumber1.numDecimalLength
);
// num1的整数和num2的小数
const int1dec2 = this._accurateDivisionTenExponent(
- parseInt(stringNumber1.numInteger) *
- parseInt(stringNumber2.numDecimal),
+ parseInt(stringNumber1.numInteger) * parseInt(stringNumber2.numDecimal),
stringNumber2.numDecimalLength
);
// 小数*小数
const dec1dec2 = this._accurateDivisionTenExponent(
- parseInt(stringNumber1.numDecimal) *
- parseInt(stringNumber2.numDecimal),
+ parseInt(stringNumber1.numDecimal) * parseInt(stringNumber2.numDecimal),
stringNumber1.numDecimalLength + stringNumber2.numDecimalLength
);
return this._accurateAddition(
- this._accurateAddition(
- this._accurateAddition(integerResult, dec1Int2),
- int1dec2
- ),
+ this._accurateAddition(this._accurateAddition(integerResult, dec1Int2), int1dec2),
dec1dec2
);
}
@@ -204,18 +176,14 @@ export class AccurateCalculationModel extends Widget {
const stringNumber = this._stringNumberFactory(num);
let integerResult, partDecimalResult;
if (stringNumber.numInteger.length > n) {
- integerResult = stringNumber.numInteger.slice(
- 0,
- stringNumber.numInteger.length - n
- );
+ integerResult = stringNumber.numInteger.slice(0, stringNumber.numInteger.length - n);
partDecimalResult = stringNumber.numInteger.slice(-n);
} else {
integerResult = "0";
partDecimalResult = addZero(stringNumber.numInteger, n);
}
- const result =
- `${integerResult}.${partDecimalResult}${stringNumber.numDecimal}`;
-
+ const result = `${integerResult}.${partDecimalResult}${stringNumber.numDecimal}`;
+
return parseFloat(result);
function addZero(resultTemp, length) {
@@ -223,7 +191,7 @@ export class AccurateCalculationModel extends Widget {
for (let i = 0; i < diff; i++) {
resultTemp = `0${resultTemp}`;
}
-
+
return resultTemp;
}
}
@@ -233,7 +201,7 @@ export class AccurateCalculationModel extends Widget {
if (num1 >= num2) {
return this._accurateSubtraction(num1, num2);
}
-
+
return -this._accurateSubtraction(num2, num1);
}
if (num1 >= 0 && num2 < 0) {
@@ -246,7 +214,7 @@ export class AccurateCalculationModel extends Widget {
if (num1 >= num2) {
return this._accurateSubtraction(-num2, -num1);
}
-
+
return this._accurateSubtraction(-num1, -num2);
}
}
@@ -285,7 +253,7 @@ export class AccurateCalculationModel extends Widget {
if (num1 >= 0) {
return this._accurateDivisionTenExponent(num1, n);
}
-
+
return -this._accurateDivisionTenExponent(-num1, n);
}
}
diff --git a/src/widget/multilayerdownlist/combo.downlist.js b/src/widget/multilayerdownlist/combo.downlist.js
index 281e2fc0f..c8824e46c 100644
--- a/src/widget/multilayerdownlist/combo.downlist.js
+++ b/src/widget/multilayerdownlist/combo.downlist.js
@@ -1,5 +1,5 @@
-import { shortcut, Widget, extend, createWidget } from "@/core";
import { MultiLayerDownListPopup } from "./popup.downlist";
+import { shortcut, Widget, extend, createWidget } from "@/core";
import { Combo } from "@/base";
import { IconTrigger } from "@/case";
@@ -29,7 +29,7 @@ export class MultiLayerDownListCombo extends Widget {
super._init(...arguments);
const o = this.options;
this.popupview = createWidget({
- type: "bi.multi_layer_down_list_popup",
+ type: MultiLayerDownListPopup.xtype,
items: o.items,
chooseType: o.chooseType,
value: o.value,
diff --git a/src/widget/multilayerdownlist/popup.downlist.js b/src/widget/multilayerdownlist/popup.downlist.js
index b8abc5cf9..edbd95dff 100644
--- a/src/widget/multilayerdownlist/popup.downlist.js
+++ b/src/widget/multilayerdownlist/popup.downlist.js
@@ -40,7 +40,7 @@ export class MultiLayerDownListPopup extends Pane {
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
-
+
return extend(conf, {
baseCls: "bi-down-list-popup",
items: [],
@@ -82,7 +82,7 @@ export class MultiLayerDownListPopup extends Pane {
if (isNotNull(self.childValueMap[value])) {
changedValue = self.childValueMap[value];
const fatherValue = self.fatherValueMap[value];
- const fatherArrayValue = (`${fatherValue}`).split(BlankSplitChar);
+ const fatherArrayValue = `${fatherValue}`.split(BlankSplitChar);
self.fireEvent(
MultiLayerDownListPopup.EVENT_SON_VALUE_CHANGE,
changedValue,
@@ -193,7 +193,7 @@ export class MultiLayerDownListPopup extends Pane {
result.push(spliter_container);
}
});
-
+
return result;
}
@@ -252,7 +252,7 @@ export class MultiLayerDownListPopup extends Pane {
if (isArray(fatherValue)) {
fValue = fatherValue.join(BlankSplitChar);
}
-
+
return fValue + BlankSplitChar + childValue;
}
@@ -268,7 +268,7 @@ export class MultiLayerDownListPopup extends Pane {
}
valueArray.push(value);
});
-
+
return valueArray;
}
@@ -289,19 +289,21 @@ export class MultiLayerDownListPopup extends Pane {
}
});
});
-
+
return value;
function joinValue(sources, targets) {
let value = "";
- some(sources, (idx, s) => some(targets, (id, t) => {
- if (s === t) {
- value = s;
-
- return true;
- }
- }));
-
+ some(sources, (idx, s) =>
+ some(targets, (id, t) => {
+ if (s === t) {
+ value = s;
+
+ return true;
+ }
+ })
+ );
+
return value;
}
@@ -314,7 +316,7 @@ export class MultiLayerDownListPopup extends Pane {
} else {
children.push(item.value);
}
-
+
return children;
}
}
@@ -346,7 +348,7 @@ export class MultiLayerDownListPopup extends Pane {
each(this.popup.getAllButtons(), (i, item) => {
i % 2 === 0 && v.push(item.getValue());
});
-
+
return v;
}
@@ -359,14 +361,14 @@ export class MultiLayerDownListPopup extends Pane {
if (isNotNull(self.childValueMap[value])) {
const fartherValue = self.fatherValueMap[value];
valueItem.childValue = self.childValueMap[value];
- const fatherArrayValue = (`${fartherValue}`).split(BlankSplitChar);
+ const fatherArrayValue = `${fartherValue}`.split(BlankSplitChar);
valueItem.value = fatherArrayValue.length > 1 ? fatherArrayValue : fartherValue;
} else {
valueItem.value = value;
}
result.push(valueItem);
});
-
+
return result;
}
}
diff --git a/src/widget/multilayerselecttree/multilayerselecttree.combo.js b/src/widget/multilayerselecttree/multilayerselecttree.combo.js
index 834a4fb40..f12c54d55 100644
--- a/src/widget/multilayerselecttree/multilayerselecttree.combo.js
+++ b/src/widget/multilayerselecttree/multilayerselecttree.combo.js
@@ -1,14 +1,4 @@
-import {
- shortcut,
- Widget,
- extend,
- emptyFn,
- isKey,
- toPix,
- AbsoluteLayout,
- nextTick,
- isArray
-} from "@/core";
+import { shortcut, Widget, extend, emptyFn, isKey, toPix, AbsoluteLayout, nextTick, isArray } from "@/core";
import { SingleTreeTrigger } from "../singletree/singletree.trigger";
import { MultiLayerSelectTreePopup } from "./multilayerselecttree.popup";
import { Combo } from "@/base";
@@ -121,8 +111,7 @@ export class MultiLayerSelectTreeCombo extends Widget {
itemsCreator: o.itemsCreator,
items: o.items,
ref(_ref) {
- self.trigger &&
- self.trigger.getSearcher().setAdapter(_ref);
+ self.trigger && self.trigger.getSearcher().setAdapter(_ref);
},
listeners: [
{
@@ -130,13 +119,8 @@ export class MultiLayerSelectTreeCombo extends Widget {
action() {
self.setValue(this.getValue());
self.combo.hideView();
- self.fireEvent(
- MultiLayerSelectTreeCombo.EVENT_CHANGE
- );
- self.fireEvent(
- MultiLayerSelectTreeCombo.EVENT_CLICK_ITEM,
- self.combo.getValue()
- );
+ self.fireEvent(MultiLayerSelectTreeCombo.EVENT_CHANGE);
+ self.fireEvent(MultiLayerSelectTreeCombo.EVENT_CLICK_ITEM, self.combo.getValue());
},
}
],
@@ -157,9 +141,7 @@ export class MultiLayerSelectTreeCombo extends Widget {
{
eventName: Combo.EVENT_BEFORE_POPUPVIEW,
action() {
- self.fireEvent(
- MultiLayerSelectTreeCombo.EVENT_BEFORE_POPUPVIEW
- );
+ self.fireEvent(MultiLayerSelectTreeCombo.EVENT_BEFORE_POPUPVIEW);
},
}
],
@@ -198,45 +180,32 @@ export class MultiLayerSelectTreeCombo extends Widget {
action() {
self.setValue(this.getValue());
self.combo.hideView();
- self.fireEvent(
- MultiLayerSelectTreeCombo.EVENT_CHANGE
- );
- self.fireEvent(
- MultiLayerSelectTreeCombo.EVENT_CLICK_ITEM,
- self.combo.getValue()
- );
+ self.fireEvent(MultiLayerSelectTreeCombo.EVENT_CHANGE);
+ self.fireEvent(MultiLayerSelectTreeCombo.EVENT_CLICK_ITEM, self.combo.getValue());
},
},
{
eventName: MultiLayerSelectTreeTrigger.EVENT_FOCUS,
action() {
- self.fireEvent(
- MultiLayerSelectTreeCombo.EVENT_FOCUS
- );
+ self.fireEvent(MultiLayerSelectTreeCombo.EVENT_FOCUS);
},
},
{
eventName: MultiLayerSelectTreeTrigger.EVENT_BLUR,
action() {
- self.fireEvent(
- MultiLayerSelectTreeCombo.EVENT_BLUR
- );
+ self.fireEvent(MultiLayerSelectTreeCombo.EVENT_BLUR);
},
},
{
eventName: MultiLayerSelectTreeTrigger.EVENT_SEARCHING,
action() {
- self.fireEvent(
- MultiLayerSelectTreeCombo.EVENT_SEARCHING
- );
+ self.fireEvent(MultiLayerSelectTreeCombo.EVENT_SEARCHING);
},
},
{
eventName: MultiLayerSelectTreeTrigger.EVENT_STOP,
action() {
- self.fireEvent(
- MultiLayerSelectTreeCombo.EVENT_STOP
- );
+ self.fireEvent(MultiLayerSelectTreeCombo.EVENT_STOP);
},
},
{
@@ -245,9 +214,7 @@ export class MultiLayerSelectTreeCombo extends Widget {
const value = self.trigger.getSearcher().getKeyword();
self.combo.setValue([value]);
self.combo.hideView();
- self.fireEvent(
- MultiLayerSelectTreeCombo.EVENT_CHANGE
- );
+ self.fireEvent(MultiLayerSelectTreeCombo.EVENT_CHANGE);
},
}
],
@@ -259,9 +226,8 @@ export class MultiLayerSelectTreeCombo extends Widget {
// 通过container参数将popup放置于popover之外解决此问题, 其他下拉控件由于元素少或者有分页,所以
// 卡顿不明显, 先在此做尝试, 并在FineUI特殊处理待解决文档中标记跟踪
return o.container &&
- self.trigger.getSearcher().isSearching() &&
- self.trigger.getSearcher().getView().element.find(e.target)
- .length > 0
+ self.trigger.getSearcher().isSearching() &&
+ self.trigger.getSearcher().getView().element.find(e.target).length > 0
? false
: self.triggerBtn?.element.find(e.target).length === 0;
},
@@ -275,9 +241,7 @@ export class MultiLayerSelectTreeCombo extends Widget {
{
eventName: Combo.EVENT_BEFORE_POPUPVIEW,
action() {
- self.fireEvent(
- MultiLayerSelectTreeCombo.EVENT_BEFORE_POPUPVIEW
- );
+ self.fireEvent(MultiLayerSelectTreeCombo.EVENT_BEFORE_POPUPVIEW);
},
}
],
@@ -321,9 +285,7 @@ export class MultiLayerSelectTreeCombo extends Widget {
}
getSearcher() {
- return this.trigger
- ? this.trigger.getSearcher()
- : this.textTrigger.getTextor();
+ return this.trigger ? this.trigger.getSearcher() : this.textTrigger.getTextor();
}
clear() {
@@ -339,9 +301,7 @@ export class MultiLayerSelectTreeCombo extends Widget {
}
setTipType(v) {
- this.trigger
- ? this.trigger.setTipType(v)
- : this.textTrigger.setTipType(v);
+ this.trigger ? this.trigger.setTipType(v) : this.textTrigger.setTipType(v);
}
populate(items) {
@@ -361,8 +321,6 @@ export class MultiLayerSelectTreeCombo extends Widget {
}
setWaterMark(v) {
- this.trigger
- ? this.trigger.setWaterMark(v)
- : this.textTrigger.setWaterMark(v);
+ this.trigger ? this.trigger.setWaterMark(v) : this.textTrigger.setWaterMark(v);
}
}
diff --git a/src/widget/multilayerselecttree/multilayerselecttree.insert.search.pane.js b/src/widget/multilayerselecttree/multilayerselecttree.insert.search.pane.js
index 058493c12..f21c07112 100644
--- a/src/widget/multilayerselecttree/multilayerselecttree.insert.search.pane.js
+++ b/src/widget/multilayerselecttree/multilayerselecttree.insert.search.pane.js
@@ -59,9 +59,7 @@ export class MultiLayerSelectTreeInsertSearchPane extends Widget {
{
eventName: MultiLayerSelectLevelTree.EVENT_CHANGE,
action() {
- self.fireEvent(
- MultiLayerSelectTreeInsertSearchPane.EVENT_CHANGE
- );
+ self.fireEvent(MultiLayerSelectTreeInsertSearchPane.EVENT_CHANGE);
},
}
],
@@ -84,10 +82,7 @@ export class MultiLayerSelectTreeInsertSearchPane extends Widget {
self.addNotMatchTip = _ref;
},
handler() {
- self.fireEvent(
- MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM,
- o.keywordGetter()
- );
+ self.fireEvent(MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM, o.keywordGetter());
},
},
this.tree
@@ -98,10 +93,7 @@ export class MultiLayerSelectTreeInsertSearchPane extends Widget {
setKeyword(keyword) {
const showTip = isEmptyArray(this.tree.getAllLeaves());
this.addNotMatchTip.setVisible(showTip);
- showTip &&
- this.addNotMatchTip.setText(
- i18nText("BI-Basic_Click_To_Add_Text", keyword)
- );
+ showTip && this.addNotMatchTip.setText(i18nText("BI-Basic_Click_To_Add_Text", keyword));
}
getValue() {
diff --git a/src/widget/multilayerselecttree/multilayerselecttree.leveltree.js b/src/widget/multilayerselecttree/multilayerselecttree.leveltree.js
index a307ffb2c..dc621d9e6 100644
--- a/src/widget/multilayerselecttree/multilayerselecttree.leveltree.js
+++ b/src/widget/multilayerselecttree/multilayerselecttree.leveltree.js
@@ -66,11 +66,7 @@ export class MultiLayerSelectLevelTree extends Pane {
}
node.keyword = node.keyword || keyword;
extend.pNode = pNode;
- if (
- node.isParent === true ||
- node.parent === true ||
- isNotEmptyArray(node.children)
- ) {
+ if (node.isParent === true || node.parent === true || isNotEmptyArray(node.children)) {
extend.type = BasicTreeNode.xtype;
extend.selectable = true;
defaults(node, extend);
@@ -112,10 +108,10 @@ export class MultiLayerSelectLevelTree extends Pane {
items: this._formatItems(Tree.transformToTreeFormat(nodes), 0),
itemsCreator(op, callback) {
op.times === 1 &&
- !op.node &&
- nextTick(() => {
- self.loading();
- });
+ !op.node &&
+ nextTick(() => {
+ self.loading();
+ });
o.itemsCreator(op, ob => {
hasNext = ob.hasNext;
op.times === 1 && !op.node && self._populate(ob.items);
@@ -128,10 +124,10 @@ export class MultiLayerSelectLevelTree extends Pane {
);
self.setValue(self.storeValue);
op.times === 1 &&
- !op.node &&
- nextTick(() => {
- self.loaded();
- });
+ !op.node &&
+ nextTick(() => {
+ self.loaded();
+ });
});
},
value: o.value,
@@ -141,10 +137,7 @@ export class MultiLayerSelectLevelTree extends Pane {
isDefaultInit: o.itemsCreator !== emptyFn,
el: {
type: ButtonTree.xtype,
- chooseType:
- o.chooseType === Selection.None
- ? Selection.None
- : Selection.Default, // 不使用buttontree内部getValue逻辑
+ chooseType: o.chooseType === Selection.None ? Selection.None : Selection.Default, // 不使用buttontree内部getValue逻辑
behaviors: o.behaviors,
layouts: [
{
@@ -161,10 +154,7 @@ export class MultiLayerSelectLevelTree extends Pane {
self.fireEvent(Controller.EVENT_CHANGE, arguments);
if (type === Events.CLICK) {
self.setValue(value);
- self.fireEvent(
- MultiLayerSelectLevelTree.EVENT_CHANGE,
- arguments
- );
+ self.fireEvent(MultiLayerSelectLevelTree.EVENT_CHANGE, arguments);
}
});
@@ -184,9 +174,7 @@ export class MultiLayerSelectLevelTree extends Pane {
this._populate(nodes);
isNull(nodes)
? this.tree.populate()
- : this.tree.populate(
- this._formatItems(Tree.transformToTreeFormat(nodes), 0)
- );
+ : this.tree.populate(this._formatItems(Tree.transformToTreeFormat(nodes), 0));
}
setValue(v) {
@@ -199,11 +187,7 @@ export class MultiLayerSelectLevelTree extends Pane {
}
getValue() {
- return isArray(this.storeValue)
- ? this.storeValue
- : isNull(this.storeValue)
- ? []
- : [this.storeValue];
+ return isArray(this.storeValue) ? this.storeValue : isNull(this.storeValue) ? [] : [this.storeValue];
}
getAllLeaves() {
diff --git a/src/widget/multilayerselecttree/multilayerselecttree.popup.js b/src/widget/multilayerselecttree/multilayerselecttree.popup.js
index d5a781d4a..e16b341ff 100644
--- a/src/widget/multilayerselecttree/multilayerselecttree.popup.js
+++ b/src/widget/multilayerselecttree/multilayerselecttree.popup.js
@@ -1,14 +1,4 @@
-import {
- shortcut,
- Widget,
- extend,
- i18nText,
- emptyFn,
- createWidget,
- Controller,
- VerticalLayout,
- isArray
-} from "@/core";
+import { shortcut, Widget, extend, i18nText, emptyFn, createWidget, Controller, VerticalLayout, isArray } from "@/core";
import { MultiLayerSelectLevelTree } from "./multilayerselecttree.leveltree";
@shortcut()
diff --git a/src/widget/multilayerselecttree/multilayerselecttree.trigger.js b/src/widget/multilayerselecttree/multilayerselecttree.trigger.js
index 36ce295a2..3dc982964 100644
--- a/src/widget/multilayerselecttree/multilayerselecttree.trigger.js
+++ b/src/widget/multilayerselecttree/multilayerselecttree.trigger.js
@@ -75,9 +75,7 @@ export class MultiLayerSelectTreeTrigger extends Trigger {
self.editor = this;
},
defaultText: o.defaultText,
- text: isKey(o.value)
- ? this._digest(o.value)
- : o.text,
+ text: isKey(o.value) ? this._digest(o.value) : o.text,
value: o.value,
height: o.height,
tipText: "",
@@ -86,25 +84,19 @@ export class MultiLayerSelectTreeTrigger extends Trigger {
{
eventName: StateEditor.EVENT_FOCUS,
action() {
- self.fireEvent(
- MultiLayerSelectTreeTrigger.EVENT_FOCUS
- );
+ self.fireEvent(MultiLayerSelectTreeTrigger.EVENT_FOCUS);
},
},
{
eventName: StateEditor.EVENT_BLUR,
action() {
- self.fireEvent(
- MultiLayerSelectTreeTrigger.EVENT_BLUR
- );
+ self.fireEvent(MultiLayerSelectTreeTrigger.EVENT_BLUR);
},
},
{
eventName: StateEditor.EVENT_CHANGE,
action() {
- self.fireEvent(
- MultiLayerSelectTreeTrigger.EVENT_SEARCHING
- );
+ self.fireEvent(MultiLayerSelectTreeTrigger.EVENT_SEARCHING);
},
}
],
@@ -126,15 +118,10 @@ export class MultiLayerSelectTreeTrigger extends Trigger {
cls: "bi-card",
listeners: [
{
- eventName:
- MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM,
+ eventName: MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM,
action() {
- self.options.text = self
- .getSearcher()
- .getKeyword();
- self.fireEvent(
- MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM
- );
+ self.options.text = self.getSearcher().getKeyword();
+ self.fireEvent(MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM);
},
}
],
@@ -146,8 +133,7 @@ export class MultiLayerSelectTreeTrigger extends Trigger {
const keyword = obj.keyword;
if (o.itemsCreator === BI.emptyFn) {
callback(self._getSearchItems(keyword));
- o.allowInsertValue &&
- self.popup.setKeyword(keyword);
+ o.allowInsertValue && self.popup.setKeyword(keyword);
} else {
callback();
}
@@ -156,9 +142,7 @@ export class MultiLayerSelectTreeTrigger extends Trigger {
{
eventName: Searcher.EVENT_CHANGE,
action() {
- self.fireEvent(
- MultiLayerSelectTreeTrigger.EVENT_CHANGE
- );
+ self.fireEvent(MultiLayerSelectTreeTrigger.EVENT_CHANGE);
},
}
],
@@ -184,12 +168,7 @@ export class MultiLayerSelectTreeTrigger extends Trigger {
const items = [];
this.tree.traverse(node => {
const find = Func.getSearchResult(
- self.tree.isRoot(node)
- ? []
- : concat(
- [node.text],
- o.allowSearchValue ? [node.value] : []
- ),
+ self.tree.isRoot(node) ? [] : concat([node.text], o.allowSearchValue ? [node.value] : []),
keyword
);
if (find.find.length > 0 || find.match.length > 0) {
diff --git a/src/widget/multilayersingletree/multilayersingletree.combo.js b/src/widget/multilayersingletree/multilayersingletree.combo.js
index 058939d7d..ea0695257 100644
--- a/src/widget/multilayersingletree/multilayersingletree.combo.js
+++ b/src/widget/multilayersingletree/multilayersingletree.combo.js
@@ -1,14 +1,4 @@
-import {
- shortcut,
- Widget,
- extend,
- emptyFn,
- isKey,
- toPix,
- AbsoluteLayout,
- nextTick,
- isArray
-} from "@/core";
+import { shortcut, Widget, extend, emptyFn, isKey, toPix, AbsoluteLayout, nextTick, isArray } from "@/core";
import { SingleTreeTrigger } from "../singletree/singletree.trigger";
import { MultiLayerSingleTreePopup } from "./multilayersingletree.popup";
import { Combo } from "@/base";
@@ -47,9 +37,7 @@ export class MultiLayerSingleTreeCombo extends Widget {
o = this.options;
const cls =
- (o.simple
- ? "bi-border-bottom bi-focus-shadow "
- : "bi-border bi-border-radius bi-focus-shadow ") +
+ (o.simple ? "bi-border-bottom bi-focus-shadow " : "bi-border bi-border-radius bi-focus-shadow ") +
(isKey(o.status) ? `status-${o.status}` : "");
const baseConfig = this._getBaseConfig();
@@ -121,8 +109,7 @@ export class MultiLayerSingleTreeCombo extends Widget {
itemsCreator: o.itemsCreator,
items: o.items,
ref(_ref) {
- self.trigger &&
- self.trigger.getSearcher().setAdapter(_ref);
+ self.trigger && self.trigger.getSearcher().setAdapter(_ref);
},
listeners: [
{
@@ -130,9 +117,7 @@ export class MultiLayerSingleTreeCombo extends Widget {
action() {
self.setValue(this.getValue());
self.combo.hideView();
- self.fireEvent(
- MultiLayerSingleTreeCombo.EVENT_CHANGE
- );
+ self.fireEvent(MultiLayerSingleTreeCombo.EVENT_CHANGE);
},
}
],
@@ -153,9 +138,7 @@ export class MultiLayerSingleTreeCombo extends Widget {
{
eventName: Combo.EVENT_BEFORE_POPUPVIEW,
action() {
- self.fireEvent(
- MultiLayerSingleTreeCombo.EVENT_BEFORE_POPUPVIEW
- );
+ self.fireEvent(MultiLayerSingleTreeCombo.EVENT_BEFORE_POPUPVIEW);
},
}
],
@@ -193,41 +176,31 @@ export class MultiLayerSingleTreeCombo extends Widget {
action() {
self.setValue(this.getValue());
self.combo.hideView();
- self.fireEvent(
- MultiLayerSingleTreeCombo.EVENT_CHANGE
- );
+ self.fireEvent(MultiLayerSingleTreeCombo.EVENT_CHANGE);
},
},
{
eventName: MultiLayerSingleTreeTrigger.EVENT_FOCUS,
action() {
- self.fireEvent(
- MultiLayerSingleTreeCombo.EVENT_FOCUS
- );
+ self.fireEvent(MultiLayerSingleTreeCombo.EVENT_FOCUS);
},
},
{
eventName: MultiLayerSingleTreeTrigger.EVENT_BLUR,
action() {
- self.fireEvent(
- MultiLayerSingleTreeCombo.EVENT_BLUR
- );
+ self.fireEvent(MultiLayerSingleTreeCombo.EVENT_BLUR);
},
},
{
eventName: MultiLayerSingleTreeTrigger.EVENT_SEARCHING,
action() {
- self.fireEvent(
- MultiLayerSingleTreeCombo.EVENT_SEARCHING
- );
+ self.fireEvent(MultiLayerSingleTreeCombo.EVENT_SEARCHING);
},
},
{
eventName: MultiLayerSingleTreeTrigger.EVENT_STOP,
action() {
- self.fireEvent(
- MultiLayerSingleTreeCombo.EVENT_STOP
- );
+ self.fireEvent(MultiLayerSingleTreeCombo.EVENT_STOP);
},
},
{
@@ -236,9 +209,7 @@ export class MultiLayerSingleTreeCombo extends Widget {
const value = self.trigger.getSearcher().getKeyword();
self.combo.setValue([value]);
self.combo.hideView();
- self.fireEvent(
- MultiLayerSingleTreeCombo.EVENT_CHANGE
- );
+ self.fireEvent(MultiLayerSingleTreeCombo.EVENT_CHANGE);
},
}
],
@@ -250,9 +221,8 @@ export class MultiLayerSingleTreeCombo extends Widget {
// 通过container参数将popup放置于popover之外解决此问题, 其他下拉控件由于元素少或者有分页,所以
// 卡顿不明显, 先在此做尝试, 并在FineUI特殊处理待解决文档中标记跟踪
return o.container &&
- self.trigger.getSearcher().isSearching() &&
- self.trigger.getSearcher().getView().element.find(e.target)
- .length > 0
+ self.trigger.getSearcher().isSearching() &&
+ self.trigger.getSearcher().getView().element.find(e.target).length > 0
? false
: self.triggerBtn?.element.find(e.target).length === 0;
},
@@ -266,9 +236,7 @@ export class MultiLayerSingleTreeCombo extends Widget {
{
eventName: Combo.EVENT_BEFORE_POPUPVIEW,
action() {
- self.fireEvent(
- MultiLayerSingleTreeCombo.EVENT_BEFORE_POPUPVIEW
- );
+ self.fireEvent(MultiLayerSingleTreeCombo.EVENT_BEFORE_POPUPVIEW);
},
}
],
@@ -303,9 +271,7 @@ export class MultiLayerSingleTreeCombo extends Widget {
}
getSearcher() {
- return this.trigger
- ? this.trigger.getSearcher()
- : this.textTrigger.getTextor();
+ return this.trigger ? this.trigger.getSearcher() : this.textTrigger.getTextor();
}
setValue(v) {
@@ -326,9 +292,7 @@ export class MultiLayerSingleTreeCombo extends Widget {
}
setTipType(v) {
- this.trigger
- ? this.trigger.setTipType(v)
- : this.textTrigger.setTipType(v);
+ this.trigger ? this.trigger.setTipType(v) : this.textTrigger.setTipType(v);
}
populate(items) {
diff --git a/src/widget/multilayersingletree/multilayersingletree.insert.search.pane.js b/src/widget/multilayersingletree/multilayersingletree.insert.search.pane.js
index eb7a6d2a3..e00b66ea7 100644
--- a/src/widget/multilayersingletree/multilayersingletree.insert.search.pane.js
+++ b/src/widget/multilayersingletree/multilayersingletree.insert.search.pane.js
@@ -59,9 +59,7 @@ export class MultiLayerSingleTreeInsertSearchPane extends Widget {
{
eventName: MultiLayerSingleLevelTree.EVENT_CHANGE,
action() {
- self.fireEvent(
- MultiLayerSingleTreeInsertSearchPane.EVENT_CHANGE
- );
+ self.fireEvent(MultiLayerSingleTreeInsertSearchPane.EVENT_CHANGE);
},
}
],
@@ -84,10 +82,7 @@ export class MultiLayerSingleTreeInsertSearchPane extends Widget {
self.addNotMatchTip = _ref;
},
handler() {
- self.fireEvent(
- MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM,
- o.keywordGetter()
- );
+ self.fireEvent(MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM, o.keywordGetter());
},
},
this.tree
@@ -98,10 +93,7 @@ export class MultiLayerSingleTreeInsertSearchPane extends Widget {
setKeyword(keyword) {
const showTip = isEmptyArray(this.tree.getAllLeaves());
this.addNotMatchTip.setVisible(showTip);
- showTip &&
- this.addNotMatchTip.setText(
- i18nText("BI-Basic_Click_To_Add_Text", keyword)
- );
+ showTip && this.addNotMatchTip.setText(i18nText("BI-Basic_Click_To_Add_Text", keyword));
}
getValue() {
diff --git a/src/widget/multilayersingletree/multilayersingletree.leveltree.js b/src/widget/multilayersingletree/multilayersingletree.leveltree.js
index 06213988c..96076ca70 100644
--- a/src/widget/multilayersingletree/multilayersingletree.leveltree.js
+++ b/src/widget/multilayersingletree/multilayersingletree.leveltree.js
@@ -66,11 +66,7 @@ export class MultiLayerSingleLevelTree extends Pane {
}
node.keyword = node.keyword || keyword;
extend.pNode = pNode;
- if (
- node.isParent === true ||
- node.parent === true ||
- isNotEmptyArray(node.children)
- ) {
+ if (node.isParent === true || node.parent === true || isNotEmptyArray(node.children)) {
extend.type = BasicTreeNode.xtype;
extend.selectable = false;
defaults(node, extend);
@@ -112,10 +108,10 @@ export class MultiLayerSingleLevelTree extends Pane {
value: o.value,
itemsCreator(op, callback) {
op.times === 1 &&
- !op.node &&
- nextTick(() => {
- self.loading();
- });
+ !op.node &&
+ nextTick(() => {
+ self.loading();
+ });
o.itemsCreator(op, ob => {
hasNext = ob.hasNext;
op.times === 1 && !op.node && self._populate(ob.items);
@@ -128,10 +124,10 @@ export class MultiLayerSingleLevelTree extends Pane {
);
self.setValue(self.storeValue);
op.times === 1 &&
- !op.node &&
- nextTick(() => {
- self.loaded();
- });
+ !op.node &&
+ nextTick(() => {
+ self.loaded();
+ });
});
},
@@ -140,10 +136,7 @@ export class MultiLayerSingleLevelTree extends Pane {
isDefaultInit: o.itemsCreator !== emptyFn,
el: {
type: ButtonTree.xtype,
- chooseType:
- o.chooseType === Selection.None
- ? Selection.None
- : Selection.Default, // 不使用buttontree内部getValue逻辑
+ chooseType: o.chooseType === Selection.None ? Selection.None : Selection.Default, // 不使用buttontree内部getValue逻辑
behaviors: o.behaviors,
layouts: [
{
@@ -180,26 +173,19 @@ export class MultiLayerSingleLevelTree extends Pane {
this._populate(nodes);
isNull(nodes)
? this.tree.populate()
- : this.tree.populate(
- this._formatItems(Tree.transformToTreeFormat(nodes), 0)
- );
+ : this.tree.populate(this._formatItems(Tree.transformToTreeFormat(nodes), 0));
}
setValue(v) {
// getValue依赖于storeValue, 那么不选的时候就不要更新storeValue了
- if (this.options.chooseType === Selection.None) {
- } else {
+ if (this.options.chooseType !== Selection.None) {
this.storeValue = v;
this.tree.setValue(v);
}
}
getValue() {
- return isArray(this.storeValue)
- ? this.storeValue
- : isNull(this.storeValue)
- ? []
- : [this.storeValue];
+ return isArray(this.storeValue) ? this.storeValue : isNull(this.storeValue) ? [] : [this.storeValue];
}
getAllLeaves() {
diff --git a/src/widget/multilayersingletree/multilayersingletree.popup.js b/src/widget/multilayersingletree/multilayersingletree.popup.js
index 7e61cb184..760ad3743 100644
--- a/src/widget/multilayersingletree/multilayersingletree.popup.js
+++ b/src/widget/multilayersingletree/multilayersingletree.popup.js
@@ -1,14 +1,4 @@
-import {
- shortcut,
- Widget,
- extend,
- i18nText,
- emptyFn,
- createWidget,
- Controller,
- VerticalLayout,
- isArray
-} from "@/core";
+import { shortcut, Widget, extend, i18nText, emptyFn, createWidget, Controller, VerticalLayout, isArray } from "@/core";
import { MultiLayerSingleLevelTree } from "./multilayersingletree.leveltree";
@shortcut()
diff --git a/src/widget/multilayersingletree/multilayersingletree.trigger.js b/src/widget/multilayersingletree/multilayersingletree.trigger.js
index 0deeae1d5..51407adbd 100644
--- a/src/widget/multilayersingletree/multilayersingletree.trigger.js
+++ b/src/widget/multilayersingletree/multilayersingletree.trigger.js
@@ -75,9 +75,7 @@ export class MultiLayerSingleTreeTrigger extends Trigger {
self.editor = this;
},
defaultText: o.defaultText,
- text: isKey(o.value)
- ? this._digest(o.value)
- : o.text,
+ text: isKey(o.value) ? this._digest(o.value) : o.text,
value: o.value,
height: o.height,
tipText: "",
@@ -86,25 +84,19 @@ export class MultiLayerSingleTreeTrigger extends Trigger {
{
eventName: StateEditor.EVENT_FOCUS,
action() {
- self.fireEvent(
- MultiLayerSingleTreeTrigger.EVENT_FOCUS
- );
+ self.fireEvent(MultiLayerSingleTreeTrigger.EVENT_FOCUS);
},
},
{
eventName: StateEditor.EVENT_BLUR,
action() {
- self.fireEvent(
- MultiLayerSingleTreeTrigger.EVENT_BLUR
- );
+ self.fireEvent(MultiLayerSingleTreeTrigger.EVENT_BLUR);
},
},
{
eventName: StateEditor.EVENT_CHANGE,
action() {
- self.fireEvent(
- MultiLayerSingleTreeTrigger.EVENT_SEARCHING
- );
+ self.fireEvent(MultiLayerSingleTreeTrigger.EVENT_SEARCHING);
},
}
],
@@ -126,15 +118,10 @@ export class MultiLayerSingleTreeTrigger extends Trigger {
cls: "bi-card",
listeners: [
{
- eventName:
- MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM,
+ eventName: MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM,
action() {
- self.options.text = self
- .getSearcher()
- .getKeyword();
- self.fireEvent(
- MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM
- );
+ self.options.text = self.getSearcher().getKeyword();
+ self.fireEvent(MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM);
},
}
],
@@ -146,8 +133,7 @@ export class MultiLayerSingleTreeTrigger extends Trigger {
const keyword = obj.keyword;
if (o.itemsCreator === BI.emptyFn) {
callback(self._getSearchItems(keyword));
- o.allowInsertValue &&
- self.popup.setKeyword(keyword);
+ o.allowInsertValue && self.popup.setKeyword(keyword);
} else {
callback();
}
@@ -156,9 +142,7 @@ export class MultiLayerSingleTreeTrigger extends Trigger {
{
eventName: Searcher.EVENT_CHANGE,
action() {
- self.fireEvent(
- MultiLayerSingleTreeTrigger.EVENT_CHANGE
- );
+ self.fireEvent(MultiLayerSingleTreeTrigger.EVENT_CHANGE);
},
}
],
@@ -184,12 +168,7 @@ export class MultiLayerSingleTreeTrigger extends Trigger {
const items = [];
this.tree.traverse(node => {
const find = Func.getSearchResult(
- self.tree.isRoot(node)
- ? []
- : concat(
- [node.text],
- o.allowSearchValue ? [node.value] : []
- ),
+ self.tree.isRoot(node) ? [] : concat([node.text], o.allowSearchValue ? [node.value] : []),
keyword
);
if (find.find.length > 0 || find.match.length > 0) {
diff --git a/src/widget/multiselect/check/multiselect.check.pane.js b/src/widget/multiselect/check/multiselect.check.pane.js
index 6043caf71..6bcbc1c93 100644
--- a/src/widget/multiselect/check/multiselect.check.pane.js
+++ b/src/widget/multiselect/check/multiselect.check.pane.js
@@ -6,7 +6,8 @@ import {
createWidget,
map,
i18nText,
- VerticalAdaptLayout, VTapeLayout
+ VerticalAdaptLayout,
+ VTapeLayout
} from "@/core";
import { TextButton, Label } from "@/base";
import { DisplaySelectedList } from "./multiselect.display";
diff --git a/src/widget/multiselect/check/multiselect.display.js b/src/widget/multiselect/check/multiselect.display.js
index db52ee8b7..3254e4898 100644
--- a/src/widget/multiselect/check/multiselect.display.js
+++ b/src/widget/multiselect/check/multiselect.display.js
@@ -1,11 +1,4 @@
-import {
- shortcut,
- extend,
- emptyFn,
- createWidget,
- VerticalLayout,
- createItems
-} from "@/core";
+import { shortcut, extend, emptyFn, createWidget, VerticalLayout, createItems } from "@/core";
import { Pane, ButtonGroup, Loader, IconTextItem } from "@/base";
import { ListPane } from "@/case";
@@ -51,7 +44,7 @@ export class DisplaySelectedList extends Pane {
}
],
},
- itemsCreator (options, callback) {
+ itemsCreator(options, callback) {
if (options.times === 1) {
cacheItems = [];
}
@@ -61,7 +54,7 @@ export class DisplaySelectedList extends Pane {
cacheItems = cacheItems.slice(100);
self.hasNext = cacheItems.length > 0;
callback(self._createItems(renderedItems));
-
+
return;
}
@@ -70,15 +63,12 @@ export class DisplaySelectedList extends Pane {
const firstItemsCount = 100 + (ob.items.length % 100);
if (ob.items.length > 100) {
cacheItems = ob.items.slice(firstItemsCount);
- self.hasNext =
- firstItemsCount !== ob.items.length;
+ self.hasNext = firstItemsCount !== ob.items.length;
}
- callback(
- self._createItems(ob.items.slice(0, firstItemsCount))
- );
+ callback(self._createItems(ob.items.slice(0, firstItemsCount)));
});
},
- hasNext () {
+ hasNext() {
return self.hasNext;
},
});
diff --git a/src/widget/multiselect/index.js b/src/widget/multiselect/index.js
index 9e0934c14..9236080dd 100644
--- a/src/widget/multiselect/index.js
+++ b/src/widget/multiselect/index.js
@@ -1,3 +1,9 @@
+export { MultiSelectSearchPane } from "./search/multiselect.search.pane";
+export { MultiSelectEditor } from "./trigger/editor.multiselect";
+export { MultiSelectTrigger } from "./multiselect.trigger";
+export { MultiSelectPopupView } from "./multiselect.popup.view";
+export { MultiSelectSearcher } from "./trigger/searcher.multiselect";
+export { MultiSelectCheckSelectedSwitcher } from "./trigger/switcher.checkselected";
export { MultiSelectCombo } from "./multiselect.combo";
export { MultiSelectNoBarCombo } from "./multiselect.combo.nobar";
export { MultiSelectInsertCombo } from "./multiselect.insert.combo";
diff --git a/src/widget/multiselect/loader.js b/src/widget/multiselect/loader.js
index 98b61d890..c63ee1c77 100644
--- a/src/widget/multiselect/loader.js
+++ b/src/widget/multiselect/loader.js
@@ -1,3 +1,4 @@
+import { LoadingBar, ButtonGroup, Loader } from "@/base";
import {
shortcut,
Widget,
@@ -17,7 +18,6 @@ import {
isArray,
each
} from "@/core";
-import { ButtonGroup, Loader } from "@/base";
@shortcut()
export class MultiSelectInnerLoader extends Widget {
@@ -103,21 +103,18 @@ export class MultiSelectInnerLoader extends Widget {
],
value: o.value,
});
- this.button_group.on(
- Controller.EVENT_CHANGE,
- function (type, value, obj) {
- if (type === Events.CLICK) {
- const node = self.cachGroup.getNodeByValue(value);
- if (node) {
- node.setSelected(obj.isSelected());
- }
- }
- self.fireEvent(Controller.EVENT_CHANGE, arguments);
- if (type === Events.CLICK) {
- self.fireEvent(Loader.EVENT_CHANGE, obj);
+ this.button_group.on(Controller.EVENT_CHANGE, function (type, value, obj) {
+ if (type === Events.CLICK) {
+ const node = self.cachGroup.getNodeByValue(value);
+ if (node) {
+ node.setSelected(obj.isSelected());
}
}
- );
+ self.fireEvent(Controller.EVENT_CHANGE, arguments);
+ if (type === Events.CLICK) {
+ self.fireEvent(Loader.EVENT_CHANGE, obj);
+ }
+ });
const renderEngine = Widget._renderEngine;
Widget.registerRenderEngine(BI.Element.renderEngine);
@@ -140,7 +137,7 @@ export class MultiSelectInnerLoader extends Widget {
this.next = createWidget(
extend(
{
- type: "bi.loading_bar",
+ type: LoadingBar.xtype,
},
o.next
)
@@ -159,12 +156,12 @@ export class MultiSelectInnerLoader extends Widget {
});
o.isDefaultInit &&
- isEmpty(o.items) &&
- nextTick(
- bind(function () {
- o.isDefaultInit && isEmpty(o.items) && this._populate();
- }, this)
- );
+ isEmpty(o.items) &&
+ nextTick(
+ bind(function () {
+ o.isDefaultInit && isEmpty(o.items) && this._populate();
+ }, this)
+ );
}
hasNext() {
@@ -218,10 +215,7 @@ export class MultiSelectInnerLoader extends Widget {
return false;
}
- this.options.items = (items || []).slice(
- 0,
- 100 + ((items || []).length % 100)
- );
+ this.options.items = (items || []).slice(0, 100 + ((items || []).length % 100));
this.times = 1;
this.count = 0;
this.count += items.length;
@@ -247,11 +241,7 @@ export class MultiSelectInnerLoader extends Widget {
Widget.registerRenderEngine(BI.Element.renderEngine);
this.cachGroup.populate.call(this.cachGroup, items, keyword);
Widget.registerRenderEngine(renderEngine);
- this.button_group.populate.call(
- this.button_group,
- items.slice(0, firstItemsCount),
- keyword
- );
+ this.button_group.populate.call(this.button_group, items.slice(0, firstItemsCount), keyword);
}
}
diff --git a/src/widget/multiselect/multiselect.combo.js b/src/widget/multiselect/multiselect.combo.js
index a9efd6a3b..7fded29b9 100644
--- a/src/widget/multiselect/multiselect.combo.js
+++ b/src/widget/multiselect/multiselect.combo.js
@@ -1,3 +1,4 @@
+import { MultiSelectPopupView } from "./multiselect.popup.view";
import {
shortcut,
extend,
@@ -23,12 +24,11 @@ import {
values,
filter,
contains,
- isNull
+ isNull,
} from "@/core";
import { Single, Combo } from "@/base";
import { TriggerIconButton } from "@/case";
import { MultiSelectTrigger } from "./multiselect.trigger";
-import { MultiSelectPopupView } from "./multiselect.popup.view";
import { MultiSelectCheckSelectedSwitcher } from "./trigger/switcher.checkselected";
@shortcut()
@@ -125,28 +125,25 @@ export class MultiSelectCombo extends Single {
self._setStartValue("");
self.fireEvent(MultiSelectCombo.EVENT_STOP);
});
- this.trigger.on(
- MultiSelectTrigger.EVENT_SEARCHING,
- keywords => {
- const lastKeyword = last(keywords);
- keywords = initial(keywords || []);
- if (keywords.length > 0) {
- self._joinKeywords(keywords, () => {
- if (BI.endWith(lastKeyword, BI.BlankSplitChar)) {
- self.combo.setValue(self.storeValue);
- assertShowValue();
- self.combo.populate();
- self._setStartValue("");
- } else {
- self.combo.setValue(self.storeValue);
- assertShowValue();
- }
- self._dataChange = true;
- });
- }
- self.fireEvent(MultiSelectCombo.EVENT_SEARCHING);
+ this.trigger.on(MultiSelectTrigger.EVENT_SEARCHING, (keywords) => {
+ const lastKeyword = last(keywords);
+ keywords = initial(keywords || []);
+ if (keywords.length > 0) {
+ self._joinKeywords(keywords, () => {
+ if (BI.endWith(lastKeyword, BI.BlankSplitChar)) {
+ self.combo.setValue(self.storeValue);
+ assertShowValue();
+ self.combo.populate();
+ self._setStartValue("");
+ } else {
+ self.combo.setValue(self.storeValue);
+ assertShowValue();
+ }
+ self._dataChange = true;
+ });
}
- );
+ self.fireEvent(MultiSelectCombo.EVENT_SEARCHING);
+ });
this.trigger.on(MultiSelectTrigger.EVENT_CHANGE, function (value, obj) {
if (obj instanceof BI.MultiSelectBar) {
@@ -162,14 +159,11 @@ export class MultiSelectCombo extends Single {
}
self._dataChange = true;
});
- this.trigger.on(
- MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW,
- () => {
- // counter的值随点击项的改变而改变, 点击counter的时候不需要setValue(counter会请求刷新计数)
- // 只需要更新查看面板的selectedValue用以请求已选数据
- self.numberCounter.updateSelectedValue(self.storeValue);
- }
- );
+ this.trigger.on(MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, () => {
+ // counter的值随点击项的改变而改变, 点击counter的时候不需要setValue(counter会请求刷新计数)
+ // 只需要更新查看面板的selectedValue用以请求已选数据
+ self.numberCounter.updateSelectedValue(self.storeValue);
+ });
this.trigger.on(MultiSelectTrigger.EVENT_COUNTER_CLICK, () => {
if (!self.combo.isViewVisible()) {
self.combo.showView();
@@ -184,7 +178,7 @@ export class MultiSelectCombo extends Single {
el: this.trigger,
adjustLength: 1,
popup: {
- type: "bi.multi_select_popup_view",
+ type: MultiSelectPopupView.xtype,
ref() {
self.popup = this;
self.trigger.setAdapter(this);
@@ -215,7 +209,7 @@ export class MultiSelectCombo extends Single {
self.setValue();
self._defaultState();
},
- }
+ },
],
itemsCreator: o.itemsCreator,
itemHeight: o.itemHeight,
@@ -256,8 +250,7 @@ export class MultiSelectCombo extends Single {
if (self.requesting === true) {
self.wants2Quit = true;
} else {
- self._dataChange &&
- self.fireEvent(MultiSelectCombo.EVENT_CONFIRM);
+ self._dataChange && self.fireEvent(MultiSelectCombo.EVENT_CONFIRM);
}
});
@@ -284,41 +277,30 @@ export class MultiSelectCombo extends Single {
itemsCreator: bind(this._itemsCreator4Trigger, this),
value: this.storeValue,
});
- this.numberCounter.on(
- MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE,
- () => {
- if (!self.combo.isViewVisible()) {
- self.combo.showView();
- }
- }
- );
- this.numberCounter.on(
- MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW,
- function () {
- this.updateSelectedValue(self.storeValue);
+ this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, () => {
+ if (!self.combo.isViewVisible()) {
+ self.combo.showView();
}
- );
+ });
+ this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, function () {
+ this.updateSelectedValue(self.storeValue);
+ });
- this.numberCounter.on(Events.VIEW, b => {
+ this.numberCounter.on(Events.VIEW, (b) => {
nextTick(() => {
// 自动调整宽度
- self.trigger.refreshPlaceHolderWidth(
- b === true ? self.numberCounter.element.outerWidth() + 8 : 0
- );
+ self.trigger.refreshPlaceHolderWidth(b === true ? self.numberCounter.element.outerWidth() + 8 : 0);
});
});
- this.numberCounter.on(
- MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW,
- () => {
- nextTick(() => {
- // 收起时自动调整宽度
- self.trigger.refreshPlaceHolderWidth(0);
- });
- }
- );
+ this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW, () => {
+ nextTick(() => {
+ // 收起时自动调整宽度
+ self.trigger.refreshPlaceHolderWidth(0);
+ });
+ });
- this.trigger.element.click(e => {
+ this.trigger.element.click((e) => {
if (self.trigger.element.find(e.target).length > 0) {
self.numberCounter.hideView();
}
@@ -349,7 +331,7 @@ export class MultiSelectCombo extends Single {
right: o.height,
top: 0,
height: o.height,
- }
+ },
],
});
}
@@ -396,7 +378,7 @@ export class MultiSelectCombo extends Single {
type: MultiSelectCombo.REQ_GET_ALL_DATA,
keywords,
},
- ob => {
+ (ob) => {
const values = map(ob.items, "value");
digest(values);
}
@@ -436,8 +418,7 @@ export class MultiSelectCombo extends Single {
const v = obj.value;
if (isNotNull(tempMap[v])) {
change = true;
- self.storeValue.assist &&
- self.storeValue.assist.push(tempMap[v]);
+ self.storeValue.assist && self.storeValue.assist.push(tempMap[v]);
delete tempMap[v];
}
});
@@ -452,15 +433,14 @@ export class MultiSelectCombo extends Single {
keywords: [this.trigger.getKey()],
selectedValues: filter(this.storeValue.value, (_i, v) => !contains(res.value, v)),
},
- ob => {
+ (ob) => {
const items = map(ob.items, "value");
const selectedMap = self._makeMap(self.storeValue.value);
const notSelectedMap = self._makeMap(res.value);
const newItems = [];
each(items, (i, item) => {
if (isNotNull(selectedMap[items[i]])) {
- self.storeValue.assist &&
- self.storeValue.assist.push(selectedMap[items[i]]);
+ self.storeValue.assist && self.storeValue.assist.push(selectedMap[items[i]]);
delete selectedMap[items[i]];
}
if (isNull(notSelectedMap[items[i]])) {
@@ -481,8 +461,7 @@ export class MultiSelectCombo extends Single {
function adjust() {
if (self.wants2Quit === true) {
- self._dataChange &&
- self.fireEvent(MultiSelectCombo.EVENT_CONFIRM);
+ self._dataChange && self.fireEvent(MultiSelectCombo.EVENT_CONFIRM);
self.wants2Quit = false;
}
self.requesting = false;
@@ -506,8 +485,7 @@ export class MultiSelectCombo extends Single {
each(res.assist, (i, v) => {
if (isNotNull(map[v])) {
change = true;
- self.storeValue.assist &&
- self.storeValue.assist.push(map[v]);
+ self.storeValue.assist && self.storeValue.assist.push(map[v]);
delete map[v];
}
});
diff --git a/src/widget/multiselect/multiselect.combo.nobar.js b/src/widget/multiselect/multiselect.combo.nobar.js
index 332858425..f1df798ad 100644
--- a/src/widget/multiselect/multiselect.combo.nobar.js
+++ b/src/widget/multiselect/multiselect.combo.nobar.js
@@ -23,7 +23,9 @@ import {
values,
filter,
contains,
- isNull, pushDistinct, Selection
+ isNull,
+ pushDistinct,
+ Selection
} from "@/core";
import { Single, Combo } from "@/base";
import { MultiSelectBar, TriggerIconButton } from "@/case";
@@ -126,27 +128,24 @@ export class MultiSelectNoBarCombo extends Single {
self.fireEvent(MultiSelectNoBarCombo.EVENT_STOP);
});
- this.trigger.on(
- MultiSelectTrigger.EVENT_SEARCHING,
- keywords => {
- const lastKeyword = last(keywords);
- keywords = initial(keywords || []);
- if (keywords.length > 0) {
- self._joinKeywords(keywords, () => {
- if (BI.endWith(lastKeyword, BI.BlankSplitChar)) {
- self.combo.setValue(self.storeValue);
- assertShowValue();
- self.combo.populate();
- self._setStartValue("");
- } else {
- self.combo.setValue(self.storeValue);
- assertShowValue();
- }
- self._dataChange = true;
- });
- }
+ this.trigger.on(MultiSelectTrigger.EVENT_SEARCHING, keywords => {
+ const lastKeyword = last(keywords);
+ keywords = initial(keywords || []);
+ if (keywords.length > 0) {
+ self._joinKeywords(keywords, () => {
+ if (BI.endWith(lastKeyword, BI.BlankSplitChar)) {
+ self.combo.setValue(self.storeValue);
+ assertShowValue();
+ self.combo.populate();
+ self._setStartValue("");
+ } else {
+ self.combo.setValue(self.storeValue);
+ assertShowValue();
+ }
+ self._dataChange = true;
+ });
}
- );
+ });
this.trigger.on(MultiSelectTrigger.EVENT_CHANGE, function (value, obj) {
if (obj instanceof MultiSelectBar) {
@@ -161,14 +160,11 @@ export class MultiSelectNoBarCombo extends Single {
self._dataChange = true;
self.fireEvent(MultiSelectNoBarCombo.EVENT_CLICK_ITEM);
});
- this.trigger.on(
- MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW,
- () => {
- // counter的值随点击项的改变而改变, 点击counter的时候不需要setValue(counter会请求刷新计数)
- // 只需要更新查看面板的selectedValue用以请求已选数据
- self.numberCounter.updateSelectedValue(self.storeValue);
- }
- );
+ this.trigger.on(MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, () => {
+ // counter的值随点击项的改变而改变, 点击counter的时候不需要setValue(counter会请求刷新计数)
+ // 只需要更新查看面板的selectedValue用以请求已选数据
+ self.numberCounter.updateSelectedValue(self.storeValue);
+ });
this.trigger.on(MultiSelectTrigger.EVENT_COUNTER_CLICK, () => {
if (!self.combo.isViewVisible()) {
self.combo.showView();
@@ -198,9 +194,7 @@ export class MultiSelectNoBarCombo extends Single {
self._adjust(() => {
assertShowValue();
});
- self.fireEvent(
- MultiSelectNoBarCombo.EVENT_CLICK_ITEM
- );
+ self.fireEvent(MultiSelectNoBarCombo.EVENT_CLICK_ITEM);
},
},
{
@@ -260,8 +254,7 @@ export class MultiSelectNoBarCombo extends Single {
if (self.requesting === true) {
self.wants2Quit = true;
} else {
- self._dataChange &&
- self.fireEvent(MultiSelectNoBarCombo.EVENT_CONFIRM);
+ self._dataChange && self.fireEvent(MultiSelectNoBarCombo.EVENT_CONFIRM);
}
});
@@ -291,39 +284,28 @@ export class MultiSelectNoBarCombo extends Single {
value: o.value,
},
});
- this.numberCounter.on(
- MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE,
- () => {
- if (!self.combo.isViewVisible()) {
- self.combo.showView();
- }
- }
- );
- this.numberCounter.on(
- MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW,
- function () {
- this.updateSelectedValue(self.storeValue);
+ this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, () => {
+ if (!self.combo.isViewVisible()) {
+ self.combo.showView();
}
- );
+ });
+ this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, function () {
+ this.updateSelectedValue(self.storeValue);
+ });
this.numberCounter.on(Events.VIEW, b => {
nextTick(() => {
// 自动调整宽度
- self.trigger.refreshPlaceHolderWidth(
- b === true ? self.numberCounter.element.outerWidth() + 8 : 0
- );
+ self.trigger.refreshPlaceHolderWidth(b === true ? self.numberCounter.element.outerWidth() + 8 : 0);
});
});
- this.numberCounter.on(
- MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW,
- () => {
- nextTick(() => {
- // 收起时自动调整宽度
- self.trigger.refreshPlaceHolderWidth(0);
- });
- }
- );
+ this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW, () => {
+ nextTick(() => {
+ // 收起时自动调整宽度
+ self.trigger.refreshPlaceHolderWidth(0);
+ });
+ });
this.trigger.element.click(e => {
if (self.trigger.element.find(e.target).length > 0) {
@@ -466,8 +448,7 @@ export class MultiSelectNoBarCombo extends Single {
const v = obj.value;
if (isNotNull(tempMap[v])) {
change = true;
- self.storeValue.assist &&
- self.storeValue.assist.push(tempMap[v]);
+ self.storeValue.assist && self.storeValue.assist.push(tempMap[v]);
delete tempMap[v];
}
});
@@ -489,8 +470,7 @@ export class MultiSelectNoBarCombo extends Single {
const newItems = [];
each(items, (i, item) => {
if (isNotNull(selectedMap[items[i]])) {
- self.storeValue.assist &&
- self.storeValue.assist.push(selectedMap[items[i]]);
+ self.storeValue.assist && self.storeValue.assist.push(selectedMap[items[i]]);
delete selectedMap[items[i]];
}
if (isNull(notSelectedMap[items[i]])) {
@@ -511,8 +491,7 @@ export class MultiSelectNoBarCombo extends Single {
function adjust() {
if (self.wants2Quit === true) {
- self._dataChange &&
- self.fireEvent(MultiSelectNoBarCombo.EVENT_CONFIRM);
+ self._dataChange && self.fireEvent(MultiSelectNoBarCombo.EVENT_CONFIRM);
self.wants2Quit = false;
}
self.requesting = false;
@@ -536,8 +515,7 @@ export class MultiSelectNoBarCombo extends Single {
each(res.assist, (i, v) => {
if (isNotNull(map[v])) {
change = true;
- self.storeValue.assist &&
- self.storeValue.assist.push(map[v]);
+ self.storeValue.assist && self.storeValue.assist.push(map[v]);
delete map[v];
}
});
diff --git a/src/widget/multiselect/multiselect.insert.combo.js b/src/widget/multiselect/multiselect.insert.combo.js
index 4d9bb5b3c..fe1599980 100644
--- a/src/widget/multiselect/multiselect.insert.combo.js
+++ b/src/widget/multiselect/multiselect.insert.combo.js
@@ -1,3 +1,5 @@
+import { MultiSelectInsertTrigger } from "./multiselect.insert.trigger";
+import { MultiSelectPopupView } from "./multiselect.popup.view";
import {
shortcut,
extend,
@@ -24,11 +26,12 @@ import {
values,
filter,
contains,
- isNull, endWith, pushDistinct, Selection
+ isNull,
+ endWith,
+ pushDistinct,
+ Selection
} from "@/core";
import { Single, Combo, Msg } from "@/base";
-import { MultiSelectInsertTrigger } from "./multiselect.insert.trigger";
-import { MultiSelectPopupView } from "./multiselect.popup.view";
import { MultiSelectBar, TriggerIconButton } from "@/case";
import { MultiSelectCheckSelectedSwitcher } from "./trigger/switcher.checkselected";
@@ -88,7 +91,7 @@ export class MultiSelectInsertCombo extends Single {
this.requesting = false;
this.trigger = createWidget({
- type: "bi.multi_select_insert_trigger",
+ type: MultiSelectInsertTrigger.xtype,
allowEdit: o.allowEdit,
height: toPix(o.height, o.simple ? 1 : 2),
text: o.text,
@@ -127,72 +130,54 @@ export class MultiSelectInsertCombo extends Single {
});
this.trigger.on(MultiSelectInsertTrigger.EVENT_PAUSE, function () {
self._addItem(assertShowValue, true);
- self.fireEvent(
- MultiSelectInsertCombo.EVENT_ADD_ITEM,
- this.getSearcher().getKeyword()
- );
+ self.fireEvent(MultiSelectInsertCombo.EVENT_ADD_ITEM, this.getSearcher().getKeyword());
});
- this.trigger.on(
- MultiSelectInsertTrigger.EVENT_SEARCHING,
- function (keywords) {
- const lastKeyword = last(keywords);
- keywords = initial(keywords || []);
- if (keywords.length > 0) {
- self._joinKeywords(keywords, () => {
- if (endWith(lastKeyword, BI.BlankSplitChar)) {
- self.combo.setValue(self.storeValue);
- assertShowValue();
- self.combo.populate();
- self._setStartValue("");
- } else {
- self.combo.setValue(self.storeValue);
- assertShowValue();
- }
- self._dataChange = true;
- });
- this.getSearcher().getKeywordsLength() > 2000 &&
- Msg.alert(
- i18nText("BI-Basic_Prompt"),
- i18nText("BI-Basic_Too_Much_Value_Get_Two_Thousand")
- );
- }
- self.fireEvent(MultiSelectInsertCombo.EVENT_SEARCHING);
- }
- );
-
- this.trigger.on(
- MultiSelectInsertTrigger.EVENT_CHANGE,
- function (value, obj) {
- if (obj instanceof MultiSelectBar) {
- self._joinAll(this.getValue(), () => {
+ this.trigger.on(MultiSelectInsertTrigger.EVENT_SEARCHING, function (keywords) {
+ const lastKeyword = last(keywords);
+ keywords = initial(keywords || []);
+ if (keywords.length > 0) {
+ self._joinKeywords(keywords, () => {
+ if (endWith(lastKeyword, BI.BlankSplitChar)) {
+ self.combo.setValue(self.storeValue);
assertShowValue();
- self.fireEvent(MultiSelectInsertCombo.EVENT_CLICK_ITEM);
- });
- } else {
- self._join(this.getValue(), () => {
+ self.combo.populate();
+ self._setStartValue("");
+ } else {
+ self.combo.setValue(self.storeValue);
assertShowValue();
- self.fireEvent(MultiSelectInsertCombo.EVENT_CLICK_ITEM);
- });
- }
- self._dataChange = true;
+ }
+ self._dataChange = true;
+ });
+ this.getSearcher().getKeywordsLength() > 2000 &&
+ Msg.alert(i18nText("BI-Basic_Prompt"), i18nText("BI-Basic_Too_Much_Value_Get_Two_Thousand"));
}
- );
- this.trigger.on(
- MultiSelectInsertTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW,
- () => {
- // counter的值随点击项的改变而改变, 点击counter的时候不需要setValue(counter会请求刷新计数)
- // 只需要更新查看面板的selectedValue用以请求已选数据
- self.numberCounter.updateSelectedValue(self.storeValue);
+ self.fireEvent(MultiSelectInsertCombo.EVENT_SEARCHING);
+ });
+
+ this.trigger.on(MultiSelectInsertTrigger.EVENT_CHANGE, function (value, obj) {
+ if (obj instanceof MultiSelectBar) {
+ self._joinAll(this.getValue(), () => {
+ assertShowValue();
+ self.fireEvent(MultiSelectInsertCombo.EVENT_CLICK_ITEM);
+ });
+ } else {
+ self._join(this.getValue(), () => {
+ assertShowValue();
+ self.fireEvent(MultiSelectInsertCombo.EVENT_CLICK_ITEM);
+ });
}
- );
- this.trigger.on(
- MultiSelectInsertTrigger.EVENT_COUNTER_CLICK,
- () => {
- if (!self.combo.isViewVisible()) {
- self.combo.showView();
- }
+ self._dataChange = true;
+ });
+ this.trigger.on(MultiSelectInsertTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, () => {
+ // counter的值随点击项的改变而改变, 点击counter的时候不需要setValue(counter会请求刷新计数)
+ // 只需要更新查看面板的selectedValue用以请求已选数据
+ self.numberCounter.updateSelectedValue(self.storeValue);
+ });
+ this.trigger.on(MultiSelectInsertTrigger.EVENT_COUNTER_CLICK, () => {
+ if (!self.combo.isViewVisible()) {
+ self.combo.showView();
}
- );
+ });
this.combo = createWidget({
type: Combo.xtype,
@@ -202,7 +187,7 @@ export class MultiSelectInsertCombo extends Single {
adjustLength: 1,
container: o.container,
popup: {
- type: "bi.multi_select_popup_view",
+ type: MultiSelectPopupView.xtype,
ref() {
self.popup = this;
self.trigger.setAdapter(this);
@@ -217,9 +202,7 @@ export class MultiSelectInsertCombo extends Single {
self._adjust(() => {
assertShowValue();
});
- self.fireEvent(
- MultiSelectInsertCombo.EVENT_CLICK_ITEM
- );
+ self.fireEvent(MultiSelectInsertCombo.EVENT_CLICK_ITEM);
},
},
{
@@ -276,8 +259,7 @@ export class MultiSelectInsertCombo extends Single {
if (self.requesting === true) {
self.wants2Quit = true;
} else {
- self._dataChange &&
- self.fireEvent(MultiSelectInsertCombo.EVENT_CONFIRM);
+ self._dataChange && self.fireEvent(MultiSelectInsertCombo.EVENT_CONFIRM);
}
});
@@ -304,39 +286,28 @@ export class MultiSelectInsertCombo extends Single {
itemsCreator: bind(this._itemsCreator4Trigger, this),
value: o.value,
});
- this.numberCounter.on(
- MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE,
- () => {
- if (!self.combo.isViewVisible()) {
- self.combo.showView();
- }
- }
- );
- this.numberCounter.on(
- MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW,
- function () {
- this.updateSelectedValue(self.storeValue);
+ this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, () => {
+ if (!self.combo.isViewVisible()) {
+ self.combo.showView();
}
- );
+ });
+ this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, function () {
+ this.updateSelectedValue(self.storeValue);
+ });
this.numberCounter.on(Events.VIEW, b => {
nextTick(() => {
// 自动调整宽度
- self.trigger.refreshPlaceHolderWidth(
- b === true ? self.numberCounter.element.outerWidth() + 8 : 0
- );
+ self.trigger.refreshPlaceHolderWidth(b === true ? self.numberCounter.element.outerWidth() + 8 : 0);
});
});
- this.numberCounter.on(
- MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW,
- () => {
- nextTick(() => {
- // 收起时自动调整宽度
- self.trigger.refreshPlaceHolderWidth(0);
- });
- }
- );
+ this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW, () => {
+ nextTick(() => {
+ // 收起时自动调整宽度
+ self.trigger.refreshPlaceHolderWidth(0);
+ });
+ });
this.trigger.element.click(e => {
if (self.trigger.element.find(e.target).length > 0) {
@@ -467,8 +438,7 @@ export class MultiSelectInsertCombo extends Single {
const v = obj.value;
if (isNotNull(tempMap[v])) {
change = true;
- self.storeValue.assist &&
- self.storeValue.assist.push(tempMap[v]);
+ self.storeValue.assist && self.storeValue.assist.push(tempMap[v]);
delete tempMap[v];
}
});
@@ -490,8 +460,7 @@ export class MultiSelectInsertCombo extends Single {
const newItems = [];
each(items, (i, item) => {
if (isNotNull(selectedMap[items[i]])) {
- self.storeValue.assist &&
- self.storeValue.assist.push(selectedMap[items[i]]);
+ self.storeValue.assist && self.storeValue.assist.push(selectedMap[items[i]]);
delete selectedMap[items[i]];
}
if (isNull(notSelectedMap[items[i]])) {
@@ -512,8 +481,7 @@ export class MultiSelectInsertCombo extends Single {
function adjust() {
if (self.wants2Quit === true) {
- self._dataChange &&
- self.fireEvent(MultiSelectInsertCombo.EVENT_CONFIRM);
+ self._dataChange && self.fireEvent(MultiSelectInsertCombo.EVENT_CONFIRM);
self.wants2Quit = false;
}
self.requesting = false;
@@ -538,8 +506,7 @@ export class MultiSelectInsertCombo extends Single {
each(res.assist, (i, v) => {
if (isNotNull(map[v])) {
change = true;
- self.storeValue.assist &&
- self.storeValue.assist.push(map[v]);
+ self.storeValue.assist && self.storeValue.assist.push(map[v]);
delete map[v];
}
});
diff --git a/src/widget/multiselect/multiselect.insert.combo.nobar.js b/src/widget/multiselect/multiselect.insert.combo.nobar.js
index b6de5dd52..b3dca3bf5 100644
--- a/src/widget/multiselect/multiselect.insert.combo.nobar.js
+++ b/src/widget/multiselect/multiselect.insert.combo.nobar.js
@@ -24,7 +24,10 @@ import {
values,
filter,
contains,
- isNull, endWith, pushDistinct, Selection
+ isNull,
+ endWith,
+ pushDistinct,
+ Selection
} from "@/core";
import { Single, Combo, Msg } from "@/base";
import { MultiSelectInsertTrigger } from "./multiselect.insert.trigger";
@@ -116,69 +119,51 @@ export class MultiSelectInsertNoBarCombo extends Single {
});
this.trigger.on(MultiSelectInsertTrigger.EVENT_PAUSE, function () {
self._addItem(assertShowValue, true);
- self.fireEvent(
- MultiSelectInsertNoBarCombo.EVENT_ADD_ITEM,
- this.getSearcher().getKeyword()
- );
+ self.fireEvent(MultiSelectInsertNoBarCombo.EVENT_ADD_ITEM, this.getSearcher().getKeyword());
});
- this.trigger.on(
- MultiSelectInsertTrigger.EVENT_SEARCHING,
- function (keywords) {
- const lastKeyword = last(keywords);
- keywords = initial(keywords || []);
- if (keywords.length > 0) {
- self._joinKeywords(keywords, () => {
- if (endWith(lastKeyword, BI.BlankSplitChar)) {
- self.combo.setValue(self.storeValue);
- assertShowValue();
- self.combo.populate();
- self._setStartValue("");
- } else {
- self.combo.setValue(self.storeValue);
- assertShowValue();
- }
- self._dataChange = true;
- });
- this.getSearcher().getKeywordsLength() > 2000 &&
- Msg.alert(
- i18nText("BI-Basic_Prompt"),
- i18nText("BI-Basic_Too_Much_Value_Get_Two_Thousand")
- );
- }
- }
- );
-
- this.trigger.on(
- MultiSelectInsertTrigger.EVENT_CHANGE,
- function (value, obj) {
- if (obj instanceof MultiSelectBar) {
- self._joinAll(this.getValue(), () => {
+ this.trigger.on(MultiSelectInsertTrigger.EVENT_SEARCHING, function (keywords) {
+ const lastKeyword = last(keywords);
+ keywords = initial(keywords || []);
+ if (keywords.length > 0) {
+ self._joinKeywords(keywords, () => {
+ if (endWith(lastKeyword, BI.BlankSplitChar)) {
+ self.combo.setValue(self.storeValue);
assertShowValue();
- });
- } else {
- self._join(this.getValue(), () => {
+ self.combo.populate();
+ self._setStartValue("");
+ } else {
+ self.combo.setValue(self.storeValue);
assertShowValue();
- });
- }
- self._dataChange = true;
+ }
+ self._dataChange = true;
+ });
+ this.getSearcher().getKeywordsLength() > 2000 &&
+ Msg.alert(i18nText("BI-Basic_Prompt"), i18nText("BI-Basic_Too_Much_Value_Get_Two_Thousand"));
}
- );
- this.trigger.on(
- MultiSelectInsertTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW,
- () => {
- // counter的值随点击项的改变而改变, 点击counter的时候不需要setValue(counter会请求刷新计数)
- // 只需要更新查看面板的selectedValue用以请求已选数据
- self.numberCounter.updateSelectedValue(self.storeValue);
+ });
+
+ this.trigger.on(MultiSelectInsertTrigger.EVENT_CHANGE, function (value, obj) {
+ if (obj instanceof MultiSelectBar) {
+ self._joinAll(this.getValue(), () => {
+ assertShowValue();
+ });
+ } else {
+ self._join(this.getValue(), () => {
+ assertShowValue();
+ });
}
- );
- this.trigger.on(
- MultiSelectInsertTrigger.EVENT_COUNTER_CLICK,
- () => {
- if (!self.combo.isViewVisible()) {
- self.combo.showView();
- }
+ self._dataChange = true;
+ });
+ this.trigger.on(MultiSelectInsertTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, () => {
+ // counter的值随点击项的改变而改变, 点击counter的时候不需要setValue(counter会请求刷新计数)
+ // 只需要更新查看面板的selectedValue用以请求已选数据
+ self.numberCounter.updateSelectedValue(self.storeValue);
+ });
+ this.trigger.on(MultiSelectInsertTrigger.EVENT_COUNTER_CLICK, () => {
+ if (!self.combo.isViewVisible()) {
+ self.combo.showView();
}
- );
+ });
this.combo = createWidget({
type: Combo.xtype,
@@ -261,8 +246,7 @@ export class MultiSelectInsertNoBarCombo extends Single {
if (self.requesting === true) {
self.wants2Quit = true;
} else {
- self._dataChange &&
- self.fireEvent(MultiSelectInsertNoBarCombo.EVENT_CONFIRM);
+ self._dataChange && self.fireEvent(MultiSelectInsertNoBarCombo.EVENT_CONFIRM);
}
});
@@ -292,39 +276,28 @@ export class MultiSelectInsertNoBarCombo extends Single {
value: o.value,
},
});
- this.numberCounter.on(
- MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE,
- () => {
- if (!self.combo.isViewVisible()) {
- self.combo.showView();
- }
- }
- );
- this.numberCounter.on(
- MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW,
- function () {
- this.updateSelectedValue(self.storeValue);
+ this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, () => {
+ if (!self.combo.isViewVisible()) {
+ self.combo.showView();
}
- );
+ });
+ this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, function () {
+ this.updateSelectedValue(self.storeValue);
+ });
this.numberCounter.on(Events.VIEW, b => {
nextTick(() => {
// 自动调整宽度
- self.trigger.refreshPlaceHolderWidth(
- b === true ? self.numberCounter.element.outerWidth() + 8 : 0
- );
+ self.trigger.refreshPlaceHolderWidth(b === true ? self.numberCounter.element.outerWidth() + 8 : 0);
});
});
- this.numberCounter.on(
- MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW,
- () => {
- nextTick(() => {
- // 收起时自动调整宽度
- self.trigger.refreshPlaceHolderWidth(0);
- });
- }
- );
+ this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW, () => {
+ nextTick(() => {
+ // 收起时自动调整宽度
+ self.trigger.refreshPlaceHolderWidth(0);
+ });
+ });
this.trigger.element.click(e => {
if (self.trigger.element.find(e.target).length > 0) {
@@ -455,8 +428,7 @@ export class MultiSelectInsertNoBarCombo extends Single {
const v = obj.value;
if (isNotNull(tempMap[v])) {
change = true;
- self.storeValue.assist &&
- self.storeValue.assist.push(tempMap[v]);
+ self.storeValue.assist && self.storeValue.assist.push(tempMap[v]);
delete tempMap[v];
}
});
@@ -478,8 +450,7 @@ export class MultiSelectInsertNoBarCombo extends Single {
const newItems = [];
each(items, (i, item) => {
if (isNotNull(selectedMap[items[i]])) {
- self.storeValue.assist &&
- self.storeValue.assist.push(selectedMap[items[i]]);
+ self.storeValue.assist && self.storeValue.assist.push(selectedMap[items[i]]);
delete selectedMap[items[i]];
}
if (isNull(notSelectedMap[items[i]])) {
@@ -500,8 +471,7 @@ export class MultiSelectInsertNoBarCombo extends Single {
function adjust() {
if (self.wants2Quit === true) {
- self._dataChange &&
- self.fireEvent(MultiSelectInsertNoBarCombo.EVENT_CONFIRM);
+ self._dataChange && self.fireEvent(MultiSelectInsertNoBarCombo.EVENT_CONFIRM);
self.wants2Quit = false;
}
self.requesting = false;
@@ -525,8 +495,7 @@ export class MultiSelectInsertNoBarCombo extends Single {
each(res.assist, (i, v) => {
if (isNotNull(map[v])) {
change = true;
- self.storeValue.assist &&
- self.storeValue.assist.push(map[v]);
+ self.storeValue.assist && self.storeValue.assist.push(map[v]);
delete map[v];
}
});
diff --git a/src/widget/multiselect/multiselect.insert.trigger.js b/src/widget/multiselect/multiselect.insert.trigger.js
index 9b5fd3761..b7be3abf6 100644
--- a/src/widget/multiselect/multiselect.insert.trigger.js
+++ b/src/widget/multiselect/multiselect.insert.trigger.js
@@ -1,12 +1,4 @@
-import {
- shortcut,
- extend,
- emptyFn,
- createWidget,
- Layout,
- HTapeLayout,
- AbsoluteLayout
-} from "@/core";
+import { shortcut, extend, emptyFn, createWidget, Layout, HTapeLayout, AbsoluteLayout } from "@/core";
import { Trigger, Text } from "@/base";
import { MultiSelectInsertSearcher } from "./trigger/searcher.multiselect.insert";
@@ -69,15 +61,9 @@ export class MultiSelectInsertTrigger extends Trigger {
this.searcher.on(MultiSelectInsertSearcher.EVENT_PAUSE, () => {
self.fireEvent(MultiSelectInsertTrigger.EVENT_PAUSE);
});
- this.searcher.on(
- MultiSelectInsertSearcher.EVENT_SEARCHING,
- function () {
- self.fireEvent(
- MultiSelectInsertTrigger.EVENT_SEARCHING,
- arguments
- );
- }
- );
+ this.searcher.on(MultiSelectInsertSearcher.EVENT_SEARCHING, function () {
+ self.fireEvent(MultiSelectInsertTrigger.EVENT_SEARCHING, arguments);
+ });
this.searcher.on(MultiSelectInsertSearcher.EVENT_STOP, () => {
self.fireEvent(MultiSelectInsertTrigger.EVENT_STOP);
});
@@ -115,24 +101,24 @@ export class MultiSelectInsertTrigger extends Trigger {
});
!o.allowEdit &&
- createWidget({
- type: AbsoluteLayout.xtype,
- element: this,
- items: [
- {
- el: {
- type: Text.xtype,
- title() {
- return self.searcher.getState();
+ createWidget({
+ type: AbsoluteLayout.xtype,
+ element: this,
+ items: [
+ {
+ el: {
+ type: Text.xtype,
+ title() {
+ return self.searcher.getState();
+ },
},
- },
- left: 0,
- right: 24,
- top: 0,
- bottom: 0,
- }
- ],
- });
+ left: 0,
+ right: 24,
+ top: 0,
+ bottom: 0,
+ }
+ ],
+ });
}
refreshPlaceHolderWidth(width) {
diff --git a/src/widget/multiselect/multiselect.loader.js b/src/widget/multiselect/multiselect.loader.js
index ed92dfc69..5d7cfe093 100644
--- a/src/widget/multiselect/multiselect.loader.js
+++ b/src/widget/multiselect/multiselect.loader.js
@@ -11,7 +11,10 @@ import {
Controller,
delay,
isNotNull,
- Selection, Direction, LogicFactory, pushDistinct
+ Selection,
+ Direction,
+ LogicFactory,
+ pushDistinct
} from "@/core";
import { SelectList, MultiSelectBar, MultiSelectItem } from "@/case";
import { MultiSelectInnerLoader } from "./loader";
@@ -56,9 +59,7 @@ export class MultiSelectLoader extends Widget {
toolbar: {
type: MultiSelectBar.xtype,
cls: "bi-list-item-active",
- height:
- this.options.itemHeight ||
- BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
+ height: this.options.itemHeight || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
iconWrapperWidth: 36,
},
el: extend(
@@ -74,13 +75,12 @@ export class MultiSelectLoader extends Widget {
itemsCreator(op, callback) {
const startValue = self._startValue;
self.storeValue &&
- (op = extend(op || {}, {
- selectedValues:
- isKey(startValue) &&
- self.storeValue.type === Selection.Multi
- ? self.storeValue.value.concat(startValue)
- : self.storeValue.value,
- }));
+ (op = extend(op || {}, {
+ selectedValues:
+ isKey(startValue) && self.storeValue.type === Selection.Multi
+ ? self.storeValue.value.concat(startValue)
+ : self.storeValue.value,
+ }));
opts.itemsCreator(op, ob => {
hasNext = ob.hasNext;
let firstItems = [];
@@ -92,16 +92,11 @@ export class MultiSelectLoader extends Widget {
text: txt,
value: v,
title: txt,
- selected:
- self.storeValue.type === Selection.Multi,
+ selected: self.storeValue.type === Selection.Multi,
};
});
- if (
- isKey(self._startValue) &&
- !contains(self.storeValue.value, self._startValue)
- ) {
- const txt =
- opts.valueFormatter(startValue) || startValue;
+ if (isKey(self._startValue) && !contains(self.storeValue.value, self._startValue)) {
+ const txt = opts.valueFormatter(startValue) || startValue;
json.unshift({
text: txt,
value: startValue,
@@ -111,18 +106,12 @@ export class MultiSelectLoader extends Widget {
}
firstItems = self._createItems(json);
}
- callback(
- firstItems.concat(self._createItems(ob.items)),
- ob.keyword || ""
- );
+ callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || "");
if (op.times === 1 && self.storeValue) {
isKey(startValue) &&
- (self.storeValue.type === Selection.All
- ? remove(self.storeValue.value, startValue)
- : pushDistinct(
- self.storeValue.value,
- startValue
- ));
+ (self.storeValue.type === Selection.All
+ ? remove(self.storeValue.value, startValue)
+ : pushDistinct(self.storeValue.value, startValue));
self.setValue(self.storeValue);
}
op.times === 1 && self._scrollToTop();
@@ -140,9 +129,7 @@ export class MultiSelectLoader extends Widget {
element: this,
},
LogicFactory.createLogic(
- LogicFactory.createLogicTypeByDirection(
- Direction.Top
- ),
+ LogicFactory.createLogicTypeByDirection(Direction.Top),
extend(
{
scrolly: true,
@@ -150,10 +137,7 @@ export class MultiSelectLoader extends Widget {
},
opts.logic,
{
- items: LogicFactory.createLogicItemsByDirection(
- Direction.Top,
- this.button_group
- ),
+ items: LogicFactory.createLogicItemsByDirection(Direction.Top, this.button_group),
}
)
)
@@ -176,9 +160,7 @@ export class MultiSelectLoader extends Widget {
type: MultiSelectItem.xtype,
logic: this.options.logic,
cls: "bi-list-item-active",
- height:
- this.options.itemHeight ||
- BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
+ height: this.options.itemHeight || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
selected: allSelected,
iconWrapperWidth: 36,
...item,
diff --git a/src/widget/multiselect/multiselect.loader.nobar.js b/src/widget/multiselect/multiselect.loader.nobar.js
index 55a30caa6..bf7030331 100644
--- a/src/widget/multiselect/multiselect.loader.nobar.js
+++ b/src/widget/multiselect/multiselect.loader.nobar.js
@@ -81,44 +81,28 @@ export class MultiSelectNoBarLoader extends Widget {
itemsCreator(op, callback) {
const startValue = self._startValue;
self.storeValue &&
- (op = extend(op || {}, {
- selectedValues:
- isKey(startValue) &&
- self.storeValue.type === Selection.Multi
- ? self.storeValue.value.concat(
- startValue
- )
- : self.storeValue.value,
- }));
+ (op = extend(op || {}, {
+ selectedValues:
+ isKey(startValue) && self.storeValue.type === Selection.Multi
+ ? self.storeValue.value.concat(startValue)
+ : self.storeValue.value,
+ }));
opts.itemsCreator(op, ob => {
hasNext = ob.hasNext;
let firstItems = [];
if (op.times === 1 && self.storeValue) {
- const json = map(
- self.storeValue.value,
- (i, v) => {
- const txt = opts.valueFormatter(v) || v;
-
- return {
- text: txt,
- value: v,
- title: txt,
- selected:
- self.storeValue.type ===
- Selection.Multi,
- };
- }
- );
- if (
- isKey(self._startValue) &&
- !contains(
- self.storeValue.value,
- self._startValue
- )
- ) {
- const txt =
- opts.valueFormatter(startValue) ||
- startValue;
+ const json = map(self.storeValue.value, (i, v) => {
+ const txt = opts.valueFormatter(v) || v;
+
+ return {
+ text: txt,
+ value: v,
+ title: txt,
+ selected: self.storeValue.type === Selection.Multi,
+ };
+ });
+ if (isKey(self._startValue) && !contains(self.storeValue.value, self._startValue)) {
+ const txt = opts.valueFormatter(startValue) || startValue;
json.unshift({
text: txt,
value: startValue,
@@ -128,21 +112,12 @@ export class MultiSelectNoBarLoader extends Widget {
}
firstItems = self._createItems(json);
}
- callback(
- firstItems.concat(self._createItems(ob.items)),
- ob.keyword || ""
- );
+ callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || "");
if (op.times === 1 && self.storeValue) {
isKey(startValue) &&
- (self.storeValue.type === Selection.All
- ? remove(
- self.storeValue.value,
- startValue
- )
- : pushDistinct(
- self.storeValue.value,
- startValue
- ));
+ (self.storeValue.type === Selection.All
+ ? remove(self.storeValue.value, startValue)
+ : pushDistinct(self.storeValue.value, startValue));
self.setValue(self.storeValue);
}
op.times === 1 && self._scrollToTop();
@@ -178,9 +153,7 @@ export class MultiSelectNoBarLoader extends Widget {
type: MultiSelectItem.xtype,
cls: "bi-list-item-active",
logic: this.options.logic,
- height:
- this.options.itemHeight ||
- BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
+ height: this.options.itemHeight || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
iconWrapperWidth: 36,
...item,
...this.options.itemFormatter(item),
@@ -237,6 +210,5 @@ export class MultiSelectNoBarLoader extends Widget {
this.button_group.element.css({ "max-height": toPix(h) });
}
- resetWidth() {
- }
+ resetWidth() {}
}
diff --git a/src/widget/multiselect/multiselect.popup.view.js b/src/widget/multiselect/multiselect.popup.view.js
index c16cbc196..3d935af87 100644
--- a/src/widget/multiselect/multiselect.popup.view.js
+++ b/src/widget/multiselect/multiselect.popup.view.js
@@ -1,11 +1,4 @@
-import {
- shortcut,
- Widget,
- extend,
- emptyFn,
- createWidget,
- i18nText
-} from "@/core";
+import { shortcut, Widget, extend, emptyFn, createWidget, i18nText } from "@/core";
import { MultiPopupView } from "@/case";
import { MultiSelectLoader } from "./multiselect.loader";
@@ -60,23 +53,18 @@ export class MultiSelectPopupView extends Widget {
this.popupView.on(MultiPopupView.EVENT_CHANGE, () => {
self.fireEvent(MultiSelectPopupView.EVENT_CHANGE);
});
- this.popupView.on(
- MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON,
- index => {
- switch (index) {
- case 0:
- self.fireEvent(MultiSelectPopupView.EVENT_CLICK_CLEAR);
- break;
- case 1:
- self.fireEvent(
- MultiSelectPopupView.EVENT_CLICK_CONFIRM
- );
- break;
- default:
- break;
- }
+ this.popupView.on(MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, index => {
+ switch (index) {
+ case 0:
+ self.fireEvent(MultiSelectPopupView.EVENT_CLICK_CLEAR);
+ break;
+ case 1:
+ self.fireEvent(MultiSelectPopupView.EVENT_CLICK_CONFIRM);
+ break;
+ default:
+ break;
}
- );
+ });
}
isAllSelected() {
diff --git a/src/widget/multiselect/multiselect.popup.view.nobar.js b/src/widget/multiselect/multiselect.popup.view.nobar.js
index 5a8d150d7..afd965b64 100644
--- a/src/widget/multiselect/multiselect.popup.view.nobar.js
+++ b/src/widget/multiselect/multiselect.popup.view.nobar.js
@@ -1,11 +1,4 @@
-import {
- shortcut,
- Widget,
- extend,
- emptyFn,
- createWidget,
- i18nText
-} from "@/core";
+import { shortcut, Widget, extend, emptyFn, createWidget, i18nText } from "@/core";
import { MultiPopupView } from "@/case";
import { MultiSelectNoBarLoader } from "./multiselect.loader.nobar";
@@ -60,23 +53,16 @@ export class MultiSelectNoBarPopupView extends Widget {
this.popupView.on(MultiPopupView.EVENT_CHANGE, () => {
self.fireEvent(MultiSelectNoBarPopupView.EVENT_CHANGE);
});
- this.popupView.on(
- MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON,
- index => {
- switch (index) {
- case 0:
- self.fireEvent(
- MultiSelectNoBarPopupView.EVENT_CLICK_CLEAR
- );
- break;
- case 1:
- self.fireEvent(
- MultiSelectNoBarPopupView.EVENT_CLICK_CONFIRM
- );
- break;
- }
+ this.popupView.on(MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, index => {
+ switch (index) {
+ case 0:
+ self.fireEvent(MultiSelectNoBarPopupView.EVENT_CLICK_CLEAR);
+ break;
+ case 1:
+ self.fireEvent(MultiSelectNoBarPopupView.EVENT_CLICK_CONFIRM);
+ break;
}
- );
+ });
}
setStartValue(v) {
diff --git a/src/widget/multiselect/multiselect.trigger.js b/src/widget/multiselect/multiselect.trigger.js
index e938837c6..d0666731d 100644
--- a/src/widget/multiselect/multiselect.trigger.js
+++ b/src/widget/multiselect/multiselect.trigger.js
@@ -1,13 +1,4 @@
-import {
- shortcut,
- extend,
- emptyFn,
- createWidget,
- isFunction,
- Layout,
- HTapeLayout,
- AbsoluteLayout
-} from "@/core";
+import { shortcut, extend, emptyFn, createWidget, isFunction, Layout, HTapeLayout, AbsoluteLayout } from "@/core";
import { Trigger, Text } from "@/base";
import { MultiSelectSearcher } from "./trigger/searcher.multiselect";
@@ -103,30 +94,30 @@ export class MultiSelectTrigger extends Trigger {
});
!o.allowEdit &&
- createWidget({
- type: AbsoluteLayout.xtype,
- element: this,
- items: [
- {
- el: {
- type: Text.xtype,
- title() {
- /** 修正REPORT-73699引入,需要考虑到传递过来的值是方法的情况 */
- const state = self.searcher.getState();
- if (isFunction(state)) {
- return state();
- }
-
- return state;
+ createWidget({
+ type: AbsoluteLayout.xtype,
+ element: this,
+ items: [
+ {
+ el: {
+ type: Text.xtype,
+ title() {
+ /** 修正REPORT-73699引入,需要考虑到传递过来的值是方法的情况 */
+ const state = self.searcher.getState();
+ if (isFunction(state)) {
+ return state();
+ }
+
+ return state;
+ },
},
- },
- left: 0,
- right: 24,
- top: 0,
- bottom: 0,
- }
- ],
- });
+ left: 0,
+ right: 24,
+ top: 0,
+ bottom: 0,
+ }
+ ],
+ });
}
refreshPlaceHolderWidth(width) {
diff --git a/src/widget/multiselect/search/multiselect.search.insert.pane.js b/src/widget/multiselect/search/multiselect.search.insert.pane.js
index ce139fee6..708af5dcd 100644
--- a/src/widget/multiselect/search/multiselect.search.insert.pane.js
+++ b/src/widget/multiselect/search/multiselect.search.insert.pane.js
@@ -1,12 +1,4 @@
-import {
- shortcut,
- Widget,
- extend,
- emptyFn,
- createWidget,
- i18nText,
- Controller, VerticalFillLayout
-} from "@/core";
+import { shortcut, Widget, extend, emptyFn, createWidget, i18nText, Controller, VerticalFillLayout } from "@/core";
import { Label } from "@/base";
import { MultiSelectSearchLoader } from "./multiselect.search.loader";
@@ -78,9 +70,7 @@ export class MultiSelectSearchInsertPane extends Widget {
}
setKeyword(keyword) {
- this.addNotMatchTip.setText(
- i18nText("BI-Basic_Press_Enter_To_Add_Text", keyword)
- );
+ this.addNotMatchTip.setText(i18nText("BI-Basic_Press_Enter_To_Add_Text", keyword));
}
isAllSelected() {
diff --git a/src/widget/multiselect/search/multiselect.search.loader.js b/src/widget/multiselect/search/multiselect.search.loader.js
index b52361dba..e695cca98 100644
--- a/src/widget/multiselect/search/multiselect.search.loader.js
+++ b/src/widget/multiselect/search/multiselect.search.loader.js
@@ -77,9 +77,9 @@ export class MultiSelectSearchLoader extends Widget {
},
itemsCreator(op, callback) {
self.storeValue &&
- (op = extend(op || {}, {
- selectedValues: self.storeValue.value,
- }));
+ (op = extend(op || {}, {
+ selectedValues: self.storeValue.value,
+ }));
opts.itemsCreator(op, ob => {
const keyword = (ob.keyword = opts.keywordGetter());
hasNext = ob.hasNext;
@@ -91,11 +91,7 @@ export class MultiSelectSearchLoader extends Widget {
const context = {
tipText: ob.tipText,
};
- callback(
- firstItems.concat(self._createItems(ob.items)),
- keyword,
- context
- );
+ callback(firstItems.concat(self._createItems(ob.items)), keyword, context);
if (op.times === 1 && self.storeValue) {
self.setValue(self.storeValue);
}
@@ -123,9 +119,7 @@ export class MultiSelectSearchLoader extends Widget {
logic: {
dynamic: false,
},
- height:
- this.options.itemHeight ||
- BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
+ height: this.options.itemHeight || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
selected: allSelected,
cls: "bi-list-item-active",
iconWrapperWidth: 36,
diff --git a/src/widget/multiselect/search/multiselect.search.pane.js b/src/widget/multiselect/search/multiselect.search.pane.js
index 0a8ead08b..1130a1243 100644
--- a/src/widget/multiselect/search/multiselect.search.pane.js
+++ b/src/widget/multiselect/search/multiselect.search.pane.js
@@ -1,12 +1,4 @@
-import {
- shortcut,
- Widget,
- extend,
- emptyFn,
- createWidget,
- Controller,
- AbsoluteLayout
-} from "@/core";
+import { shortcut, Widget, extend, emptyFn, createWidget, Controller, AbsoluteLayout } from "@/core";
import { MultiSelectSearchLoader } from "./multiselect.search.loader";
@shortcut()
@@ -71,8 +63,7 @@ export class MultiSelectSearchPane extends Widget {
return this.loader.isAllSelected();
}
- hasMatched() {
- }
+ hasMatched() {}
setValue(v) {
this.loader.setValue(v);
diff --git a/src/widget/multiselect/trigger/button.checkselected.js b/src/widget/multiselect/trigger/button.checkselected.js
index 275013a86..8254a658e 100644
--- a/src/widget/multiselect/trigger/button.checkselected.js
+++ b/src/widget/multiselect/trigger/button.checkselected.js
@@ -44,10 +44,7 @@ export class MultiSelectCheckSelectedButton extends Single {
});
this.numberCounter.on(TextButton.EVENT_CHANGE, function () {
- self.fireEvent(
- MultiSelectCheckSelectedButton.EVENT_CHANGE,
- arguments
- );
+ self.fireEvent(MultiSelectCheckSelectedButton.EVENT_CHANGE, arguments);
});
this.numberCounter.element.hover(
@@ -119,6 +116,5 @@ export class MultiSelectCheckSelectedButton extends Single {
this._populate(this._assertValue(this.options.value));
}
- getValue() {
- }
+ getValue() {}
}
diff --git a/src/widget/multiselect/trigger/editor.multiselect.js b/src/widget/multiselect/trigger/editor.multiselect.js
index f2e33a410..83446d7f7 100644
--- a/src/widget/multiselect/trigger/editor.multiselect.js
+++ b/src/widget/multiselect/trigger/editor.multiselect.js
@@ -1,13 +1,4 @@
-import {
- shortcut,
- Widget,
- extend,
- i18nText,
- createWidget,
- Controller,
- isEmptyString,
- isEmptyArray
-} from "@/core";
+import { shortcut, Widget, extend, i18nText, createWidget, Controller, isEmptyString, isEmptyArray } from "@/core";
import { StateEditor } from "@/case";
import { SelectPatchEditor } from "./editor/editor.patch";
diff --git a/src/widget/multiselect/trigger/editor/editor.patch.js b/src/widget/multiselect/trigger/editor/editor.patch.js
index 237109ef5..4252990b5 100644
--- a/src/widget/multiselect/trigger/editor/editor.patch.js
+++ b/src/widget/multiselect/trigger/editor/editor.patch.js
@@ -8,7 +8,8 @@ import {
contains,
isKey,
Events,
- trim, replaceAll
+ trim,
+ replaceAll
} from "@/core";
import { Editor, TextAreaEditor } from "@/base";
import { StateEditor } from "@/case";
@@ -79,20 +80,14 @@ export class SelectPatchEditor extends Widget {
{
eventName: Editor.EVENT_FOCUS,
action() {
- self.fireEvent(
- SelectPatchEditor.EVENT_FOCUS,
- arguments
- );
+ self.fireEvent(SelectPatchEditor.EVENT_FOCUS, arguments);
},
},
{
eventName: Editor.EVENT_BLUR,
action() {
self._start = false;
- self.fireEvent(
- SelectPatchEditor.EVENT_BLUR,
- arguments
- );
+ self.fireEvent(SelectPatchEditor.EVENT_BLUR, arguments);
},
}
],
@@ -119,18 +114,11 @@ export class SelectPatchEditor extends Widget {
if (
!this._start ||
!isKey(this._lastValue) ||
- (this._pause === true &&
- this._trimValue(this._lastValue) !==
- this._trimValue(value))
+ (this._pause === true && this._trimValue(this._lastValue) !== this._trimValue(value))
) {
this._start = true;
this._pause = false;
- this.fireEvent(
- Controller.EVENT_CHANGE,
- Events.STARTEDIT,
- this.getValue(),
- this
- );
+ this.fireEvent(Controller.EVENT_CHANGE, Events.STARTEDIT, this.getValue(), this);
}
}
if (this._trimValue(this._lastValue) !== this._trimValue(value)) {
diff --git a/src/widget/multiselect/trigger/searcher.multiselect.insert.js b/src/widget/multiselect/trigger/searcher.multiselect.insert.js
index a2e043a6e..542e5e799 100644
--- a/src/widget/multiselect/trigger/searcher.multiselect.insert.js
+++ b/src/widget/multiselect/trigger/searcher.multiselect.insert.js
@@ -1,15 +1,4 @@
-import {
- shortcut,
- Widget,
- extend,
- emptyFn,
- i18nText,
- createWidget,
- isNotNull,
- isEmptyArray,
- size,
- each
-} from "@/core";
+import { shortcut, Widget, extend, emptyFn, i18nText, createWidget, isNotNull, isEmptyArray, size, each } from "@/core";
import { MultiSelectEditor } from "./editor.multiselect";
import { Searcher } from "@/base";
import { MultiSelectSearchInsertPane } from "../search/multiselect.search.insert.pane";
@@ -121,9 +110,7 @@ export class MultiSelectInsertSearcher extends Widget {
const keywords = this.getKeywords();
self.fireEvent(
MultiSelectInsertSearcher.EVENT_SEARCHING,
- keywords.length > 2000
- ? keywords.slice(0, 2000).concat([BI.BlankSplitChar])
- : keywords.slice(0, 2000)
+ keywords.length > 2000 ? keywords.slice(0, 2000).concat([BI.BlankSplitChar]) : keywords.slice(0, 2000)
);
});
if (isNotNull(o.value)) {
@@ -146,9 +133,7 @@ export class MultiSelectInsertSearcher extends Widget {
getKeywordsLength() {
const keywords = this.editor.getKeywords();
- return keywords[keywords.length - 1] === BI.BlankSplitChar
- ? keywords.length - 1
- : keywords.length;
+ return keywords[keywords.length - 1] === BI.BlankSplitChar ? keywords.length - 1 : keywords.length;
}
getKeyword() {
@@ -184,13 +169,9 @@ export class MultiSelectInsertSearcher extends Widget {
state = "";
each(ob.assist, (i, v) => {
if (i === 0) {
- state +=
- `${
- v === null ? "" : o.valueFormatter(`${v}`) || v}`;
+ state += `${v === null ? "" : o.valueFormatter(`${v}`) || v}`;
} else {
- state +=
- `,${
- v === null ? "" : o.valueFormatter(`${v}`) || v}`;
+ state += `,${v === null ? "" : o.valueFormatter(`${v}`) || v}`;
}
});
this.editor.setState(state);
@@ -204,13 +185,9 @@ export class MultiSelectInsertSearcher extends Widget {
state = "";
each(ob.value, (i, v) => {
if (i === 0) {
- state +=
- `${
- v === null ? "" : o.valueFormatter(`${v}`) || v}`;
+ state += `${v === null ? "" : o.valueFormatter(`${v}`) || v}`;
} else {
- state +=
- `,${
- v === null ? "" : o.valueFormatter(`${v}`) || v}`;
+ state += `,${v === null ? "" : o.valueFormatter(`${v}`) || v}`;
}
});
this.editor.setState(state);
diff --git a/src/widget/multiselect/trigger/searcher.multiselect.js b/src/widget/multiselect/trigger/searcher.multiselect.js
index ef23281c3..1adfff4b1 100644
--- a/src/widget/multiselect/trigger/searcher.multiselect.js
+++ b/src/widget/multiselect/trigger/searcher.multiselect.js
@@ -1,14 +1,4 @@
-import {
- shortcut,
- Widget,
- extend,
- emptyFn,
- i18nText,
- createWidget,
- isNotNull,
- size,
- each
-} from "@/core";
+import { shortcut, Widget, extend, emptyFn, i18nText, createWidget, isNotNull, size, each } from "@/core";
import { MultiSelectEditor } from "./editor.multiselect";
import { Searcher } from "@/base";
import { MultiSelectSearchPane } from "../search/multiselect.search.pane";
@@ -175,13 +165,9 @@ export class MultiSelectSearcher extends Widget {
state = "";
each(ob.assist, (i, v) => {
if (i === 0) {
- state +=
- `${
- v === null ? "" : o.valueFormatter(`${v}`) || v}`;
+ state += `${v === null ? "" : o.valueFormatter(`${v}`) || v}`;
} else {
- state +=
- `,${
- v === null ? "" : o.valueFormatter(`${v}`) || v}`;
+ state += `,${v === null ? "" : o.valueFormatter(`${v}`) || v}`;
}
});
this.editor.setState(state);
@@ -195,13 +181,9 @@ export class MultiSelectSearcher extends Widget {
state = "";
each(ob.value, (i, v) => {
if (i === 0) {
- state +=
- `${
- v === null ? "" : o.valueFormatter(`${v}`) || v}`;
+ state += `${v === null ? "" : o.valueFormatter(`${v}`) || v}`;
} else {
- state +=
- `,${
- v === null ? "" : o.valueFormatter(`${v}`) || v}`;
+ state += `,${v === null ? "" : o.valueFormatter(`${v}`) || v}`;
}
});
this.editor.setState(state);
diff --git a/src/widget/multiselect/trigger/switcher.checkselected.js b/src/widget/multiselect/trigger/switcher.checkselected.js
index 89e4e4fb0..4d5bab1da 100644
--- a/src/widget/multiselect/trigger/switcher.checkselected.js
+++ b/src/widget/multiselect/trigger/switcher.checkselected.js
@@ -1,12 +1,4 @@
-import {
- shortcut,
- Widget,
- extend,
- emptyFn,
- createWidget,
- Events,
- nextTick
-} from "@/core";
+import { shortcut, Widget, extend, emptyFn, createWidget, Events, nextTick } from "@/core";
import { Switcher } from "@/base";
import { MultiSelectCheckSelectedButton } from "./button.checkselected";
import { MultiSelectCheckPane } from "../check/multiselect.check.pane";
@@ -68,19 +60,13 @@ export class MultiSelectCheckSelectedSwitcher extends Widget {
masker: o.masker,
});
this.switcher.on(Switcher.EVENT_TRIGGER_CHANGE, () => {
- self.fireEvent(
- MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE
- );
+ self.fireEvent(MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE);
});
this.switcher.on(Switcher.EVENT_BEFORE_POPUPVIEW, () => {
- self.fireEvent(
- MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW
- );
+ self.fireEvent(MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW);
});
this.switcher.on(Switcher.EVENT_AFTER_HIDEVIEW, () => {
- self.fireEvent(
- MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW
- );
+ self.fireEvent(MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW);
});
this.switcher.on(Switcher.EVENT_AFTER_POPUPVIEW, function () {
const me = this;
@@ -115,8 +101,7 @@ export class MultiSelectCheckSelectedSwitcher extends Widget {
this.button.setValue(v);
}
- getValue() {
- }
+ getValue() {}
populate(items) {
this.switcher.populate.apply(this.switcher, arguments);
diff --git a/src/widget/multiselectlist/multiselectlist.insert.js b/src/widget/multiselectlist/multiselectlist.insert.js
index 71616ccb3..7e60d6aed 100644
--- a/src/widget/multiselectlist/multiselectlist.insert.js
+++ b/src/widget/multiselectlist/multiselectlist.insert.js
@@ -25,7 +25,8 @@ import {
values,
filter,
contains,
- isNull, VerticalFillLayout
+ isNull,
+ VerticalFillLayout
} from "@/core";
import { Single, Searcher } from "@/base";
import { MultiSelectBar } from "@/case";
@@ -34,7 +35,6 @@ import { MultiSelectLoader } from "../multiselect/multiselect.loader";
import { MultiSelectSearchInsertPane } from "../multiselect/search/multiselect.search.insert.pane";
import { SearchEditor } from "@/widget/editor/editor.search";
-
@shortcut()
export class MultiSelectInsertList extends Single {
static xtype = "bi.multi_select_insert_list";
@@ -62,9 +62,9 @@ export class MultiSelectInsertList extends Single {
function assertShowValue() {
isKey(self._startValue) &&
- (self.storeValue.type === Selection.All
- ? remove(self.storeValue.value, self._startValue)
- : pushDistinct(self.storeValue.value, self._startValue));
+ (self.storeValue.type === Selection.All
+ ? remove(self.storeValue.value, self._startValue)
+ : pushDistinct(self.storeValue.value, self._startValue));
// self.trigger.setValue(self.storeValue);
}
@@ -152,14 +152,10 @@ export class MultiSelectInsertList extends Single {
eventName: Searcher.EVENT_PAUSE,
action() {
let keywords = self._getKeywords();
- if (
- keywords[keywords.length - 1] === BI.BlankSplitChar
- ) {
+ if (keywords[keywords.length - 1] === BI.BlankSplitChar) {
keywords = keywords.slice(0, keywords.length - 1);
}
- const keyword = isEmptyArray(keywords)
- ? ""
- : keywords[keywords.length - 1];
+ const keyword = isEmptyArray(keywords) ? "" : keywords[keywords.length - 1];
self._join(
{
type: Selection.Multi,
@@ -167,10 +163,7 @@ export class MultiSelectInsertList extends Single {
},
() => {
if (self.storeValue.type === Selection.Multi) {
- pushDistinct(
- self.storeValue.value,
- keyword
- );
+ pushDistinct(self.storeValue.value, keyword);
}
self._showAdapter();
self.adapter.setValue(self.storeValue);
@@ -178,9 +171,7 @@ export class MultiSelectInsertList extends Single {
assertShowValue();
self.adapter.populate();
self._setStartValue("");
- self.fireEvent(
- MultiSelectInsertList.EVENT_CHANGE
- );
+ self.fireEvent(MultiSelectInsertList.EVENT_CHANGE);
}
);
self._showAdapter();
@@ -203,17 +194,13 @@ export class MultiSelectInsertList extends Single {
self.adapter.setValue(self.storeValue);
assertShowValue();
}
- self.fireEvent(
- MultiSelectInsertList.EVENT_CHANGE
- );
+ self.fireEvent(MultiSelectInsertList.EVENT_CHANGE);
});
self._getKeywordsLength() > 2000 &&
- BI.Msg.alert(
- i18nText("BI-Basic_Prompt"),
- i18nText(
- "BI-Basic_Too_Much_Value_Get_Two_Thousand"
- )
- );
+ BI.Msg.alert(
+ i18nText("BI-Basic_Prompt"),
+ i18nText("BI-Basic_Too_Much_Value_Get_Two_Thousand")
+ );
}
},
},
@@ -223,16 +210,12 @@ export class MultiSelectInsertList extends Single {
if (obj instanceof MultiSelectBar) {
self._joinAll(this.getValue(), () => {
assertShowValue();
- self.fireEvent(
- MultiSelectInsertList.EVENT_CHANGE
- );
+ self.fireEvent(MultiSelectInsertList.EVENT_CHANGE);
});
} else {
self._join(this.getValue(), () => {
assertShowValue();
- self.fireEvent(
- MultiSelectInsertList.EVENT_CHANGE
- );
+ self.fireEvent(MultiSelectInsertList.EVENT_CHANGE);
});
}
},
@@ -279,9 +262,7 @@ export class MultiSelectInsertList extends Single {
keywords = keywords.concat([BI.BlankSplitChar]);
}
- return keywords.length > 2000
- ? keywords.slice(0, 2000).concat([BI.BlankSplitChar])
- : keywords.slice(0, 2000);
+ return keywords.length > 2000 ? keywords.slice(0, 2000).concat([BI.BlankSplitChar]) : keywords.slice(0, 2000);
}
_getKeywordsLength() {
diff --git a/src/widget/multiselectlist/multiselectlist.insert.nobar.js b/src/widget/multiselectlist/multiselectlist.insert.nobar.js
index ac21aa3b4..bac2a74ca 100644
--- a/src/widget/multiselectlist/multiselectlist.insert.nobar.js
+++ b/src/widget/multiselectlist/multiselectlist.insert.nobar.js
@@ -25,7 +25,8 @@ import {
values,
filter,
contains,
- isNull, VTapeLayout
+ isNull,
+ VTapeLayout
} from "@/core";
import { Single, Searcher, Msg } from "@/base";
import { MultiSelectBar } from "@/case";
@@ -34,7 +35,6 @@ import { MultiSelectNoBarLoader } from "../multiselect/multiselect.loader.nobar"
import { MultiSelectSearchInsertPane } from "../multiselect/search/multiselect.search.insert.pane";
import { SearchEditor } from "../editor/editor.search";
-
@shortcut()
export class MultiSelectInsertNoBarList extends Single {
static xtype = "bi.multi_select_insert_no_bar_list";
@@ -64,9 +64,9 @@ export class MultiSelectInsertNoBarList extends Single {
function assertShowValue() {
isKey(self._startValue) &&
- (self.storeValue.type === Selection.All
- ? remove(self.storeValue.value, self._startValue)
- : pushDistinct(self.storeValue.value, self._startValue));
+ (self.storeValue.type === Selection.All
+ ? remove(self.storeValue.value, self._startValue)
+ : pushDistinct(self.storeValue.value, self._startValue));
// self.trigger.setValue(self.storeValue);
}
@@ -155,14 +155,10 @@ export class MultiSelectInsertNoBarList extends Single {
eventName: Searcher.EVENT_PAUSE,
action() {
let keywords = self._getKeywords();
- if (
- keywords[keywords.length - 1] === BI.BlankSplitChar
- ) {
+ if (keywords[keywords.length - 1] === BI.BlankSplitChar) {
keywords = keywords.slice(0, keywords.length - 1);
}
- const keyword = isEmptyArray(keywords)
- ? ""
- : keywords[keywords.length - 1];
+ const keyword = isEmptyArray(keywords) ? "" : keywords[keywords.length - 1];
self._join(
{
type: Selection.Multi,
@@ -170,10 +166,7 @@ export class MultiSelectInsertNoBarList extends Single {
},
() => {
if (self.storeValue.type === Selection.Multi) {
- pushDistinct(
- self.storeValue.value,
- keyword
- );
+ pushDistinct(self.storeValue.value, keyword);
}
self._showAdapter();
self.adapter.setValue(self.storeValue);
@@ -181,9 +174,7 @@ export class MultiSelectInsertNoBarList extends Single {
assertShowValue();
self.adapter.populate();
self._setStartValue("");
- self.fireEvent(
- MultiSelectInsertNoBarList.EVENT_CHANGE
- );
+ self.fireEvent(MultiSelectInsertNoBarList.EVENT_CHANGE);
}
);
},
@@ -205,17 +196,13 @@ export class MultiSelectInsertNoBarList extends Single {
self.adapter.setValue(self.storeValue);
assertShowValue();
}
- self.fireEvent(
- MultiSelectInsertNoBarList.EVENT_CHANGE
- );
+ self.fireEvent(MultiSelectInsertNoBarList.EVENT_CHANGE);
});
self._getKeywordsLength() > 2000 &&
- Msg.alert(
- i18nText("BI-Basic_Prompt"),
- i18nText(
- "BI-Basic_Too_Much_Value_Get_Two_Thousand"
- )
- );
+ Msg.alert(
+ i18nText("BI-Basic_Prompt"),
+ i18nText("BI-Basic_Too_Much_Value_Get_Two_Thousand")
+ );
}
},
},
@@ -225,16 +212,12 @@ export class MultiSelectInsertNoBarList extends Single {
if (obj instanceof MultiSelectBar) {
self._joinAll(this.getValue(), () => {
assertShowValue();
- self.fireEvent(
- MultiSelectInsertNoBarList.EVENT_CHANGE
- );
+ self.fireEvent(MultiSelectInsertNoBarList.EVENT_CHANGE);
});
} else {
self._join(this.getValue(), () => {
assertShowValue();
- self.fireEvent(
- MultiSelectInsertNoBarList.EVENT_CHANGE
- );
+ self.fireEvent(MultiSelectInsertNoBarList.EVENT_CHANGE);
});
}
},
@@ -285,9 +268,7 @@ export class MultiSelectInsertNoBarList extends Single {
keywords = keywords.concat([BI.BlankSplitChar]);
}
- return keywords.length > 2000
- ? keywords.slice(0, 2000).concat([BI.BlankSplitChar])
- : keywords.slice(0, 2000);
+ return keywords.length > 2000 ? keywords.slice(0, 2000).concat([BI.BlankSplitChar]) : keywords.slice(0, 2000);
}
_getKeywordsLength() {
diff --git a/src/widget/multiselectlist/multiselectlist.js b/src/widget/multiselectlist/multiselectlist.js
index 878bc5bc0..caebd8e2f 100644
--- a/src/widget/multiselectlist/multiselectlist.js
+++ b/src/widget/multiselectlist/multiselectlist.js
@@ -24,7 +24,8 @@ import {
values,
filter,
contains,
- isNull, VTapeLayout
+ isNull,
+ VTapeLayout
} from "@/core";
import { Searcher } from "@/base";
import { MultiSelectBar } from "@/case";
@@ -33,7 +34,6 @@ import { MultiSelectSearchPane } from "../multiselect/search/multiselect.search.
import { SelectPatchEditor } from "../multiselect/trigger/editor/editor.patch";
import { SearchEditor } from "../editor/editor.search";
-
@shortcut()
export class MultiSelectList extends Widget {
static xtype = "bi.multi_select_list";
@@ -61,9 +61,9 @@ export class MultiSelectList extends Widget {
function assertShowValue() {
isKey(self._startValue) &&
- (self.storeValue.type === Selection.All
- ? remove(self.storeValue.value, self._startValue)
- : pushDistinct(self.storeValue.value, self._startValue));
+ (self.storeValue.type === Selection.All
+ ? remove(self.storeValue.value, self._startValue)
+ : pushDistinct(self.storeValue.value, self._startValue));
// self.trigger.setValue(self.storeValue);
}
@@ -365,18 +365,12 @@ export class MultiSelectList extends Widget {
}
function adjust() {
- if (
- self.storeValue.type === Selection.All &&
- self.storeValue.value.length >= self._count
- ) {
+ if (self.storeValue.type === Selection.All && self.storeValue.value.length >= self._count) {
self.storeValue = {
type: Selection.Multi,
value: [],
};
- } else if (
- self.storeValue.type === Selection.Multi &&
- self.storeValue.value.length >= self._count
- ) {
+ } else if (self.storeValue.type === Selection.Multi && self.storeValue.value.length >= self._count) {
self.storeValue = {
type: Selection.All,
value: [],
@@ -421,9 +415,7 @@ export class MultiSelectList extends Widget {
return this.adapter.isAllSelected();
}
- resize() {
-
- }
+ resize() {}
setValue(v) {
this.storeValue = v || {};
diff --git a/src/widget/multiselecttree/multiselecttree.js b/src/widget/multiselecttree/multiselecttree.js
index 3e77234cd..8acd50d48 100644
--- a/src/widget/multiselecttree/multiselecttree.js
+++ b/src/widget/multiselecttree/multiselecttree.js
@@ -1,11 +1,5 @@
-import {
- shortcut,
- extend,
- emptyFn,
- createWidget,
- nextTick,
- AbsoluteLayout
-} from "@/core";
+import { MultiTreeSearchPane } from "../multitree/trigger/multi.tree.search.pane";
+import { VerticalFillLayout, shortcut, extend, emptyFn, createWidget, nextTick, AbsoluteLayout } from "@/core";
import { Single, Searcher } from "@/base";
import { MultiSelectTreePopup } from "./multiselecttree.popup";
@@ -47,7 +41,7 @@ export class MultiSelectTree extends Single {
// 搜索中的时候用的是parttree,同adapter中的synctree不一样
this.searcherPane = createWidget({
- type: "bi.multi_tree_search_pane",
+ type: MultiTreeSearchPane.xtype,
cls: "bi-border-left bi-border-right bi-border-bottom",
keywordGetter() {
return self.searcher.getKeyword();
@@ -121,7 +115,7 @@ export class MultiSelectTree extends Single {
});
createWidget({
- type: "bi.vertical_fill",
+ type: VerticalFillLayout.xtype,
element: this,
items: [
{
@@ -159,8 +153,7 @@ export class MultiSelectTree extends Single {
this.adapter.setVisible(false);
}
- resize() {
- }
+ resize() {}
setSelectedValue(v) {
this.storeValue.value = v || {};
diff --git a/src/widget/multiselecttree/multiselecttree.popup.js b/src/widget/multiselecttree/multiselecttree.popup.js
index 805d0571c..7c67d1d6f 100644
--- a/src/widget/multiselecttree/multiselecttree.popup.js
+++ b/src/widget/multiselecttree/multiselecttree.popup.js
@@ -10,8 +10,7 @@ export class MultiSelectTreePopup extends Widget {
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
- baseCls:
- "bi-multi-select-tree-popup bi-border-left bi-border-right bi-border-bottom",
+ baseCls: "bi-multi-select-tree-popup bi-border-left bi-border-right bi-border-bottom",
itemsCreator: emptyFn,
});
}
diff --git a/src/widget/multitree/check/multi.tree.check.pane.js b/src/widget/multitree/check/multi.tree.check.pane.js
index 56ef73fca..e383ee518 100644
--- a/src/widget/multitree/check/multi.tree.check.pane.js
+++ b/src/widget/multitree/check/multi.tree.check.pane.js
@@ -6,7 +6,8 @@ import {
i18nText,
nextTick,
Events,
- VerticalAdaptLayout, VTapeLayout
+ VerticalAdaptLayout,
+ VTapeLayout
} from "@/core";
import { Pane, TextButton, Label } from "@/base";
import { DisplayTree, TreeView } from "@/case";
@@ -123,6 +124,5 @@ export class MultiTreeCheckPane extends Pane {
this.display.setSelectedValue(v.value);
}
- getValue() {
- }
+ getValue() {}
}
diff --git a/src/widget/multitree/multi.tree.combo.js b/src/widget/multitree/multi.tree.combo.js
index 7ae95930e..1eac4b54b 100644
--- a/src/widget/multitree/multi.tree.combo.js
+++ b/src/widget/multitree/multi.tree.combo.js
@@ -16,6 +16,8 @@ import { MultiTreePopup } from "./multi.tree.popup";
import { MultiSelectTrigger } from "../multiselect/multiselect.trigger";
import { TriggerIconButton } from "@/case";
import { MultiSelectCheckSelectedSwitcher } from "../multiselect/trigger/switcher.checkselected";
+import { MultiTreeCheckSelectedButton } from "./trigger/multi.tree.button.checkselected";
+import { MultiTreeCheckPane } from "./check/multi.tree.check.pane";
@shortcut()
export class MultiTreeCombo extends Single {
@@ -42,6 +44,8 @@ export class MultiTreeCombo extends Single {
}
_init() {
+ const self = this,
+ o = this.options;
const triggerBtn = createWidget({
type: TriggerIconButton.xtype,
width: o.height,
@@ -50,8 +54,6 @@ export class MultiTreeCombo extends Single {
});
let clear;
let change;
- const self = this,
- o = this.options;
super._init(...arguments);
let isInit = false;
let want2showCounter = false;
@@ -293,10 +295,12 @@ export class MultiTreeCombo extends Single {
this.numberCounter = createWidget({
type: "bi.multi_select_check_selected_switcher",
el: {
- type: "bi.multi_tree_check_selected_button",
+ // type: "bi.multi_tree_check_selected_button",
+ type: MultiTreeCheckSelectedButton.xtype,
},
popup: {
- type: "bi.multi_tree_check_pane",
+ // type: "bi.multi_tree_check_pane",
+ type: MultiTreeCheckPane.xtype,
},
masker: {
offset: {
diff --git a/src/widget/multitree/multi.tree.insert.combo.js b/src/widget/multitree/multi.tree.insert.combo.js
index 12670343d..43e8f5426 100644
--- a/src/widget/multitree/multi.tree.insert.combo.js
+++ b/src/widget/multitree/multi.tree.insert.combo.js
@@ -1,3 +1,8 @@
+import { MultiTreeSearcher } from "./trigger/searcher.multi.tree";
+import { MultiTreeSearchInsertPane } from "./trigger/multi.tree.search.insert.pane";
+import { MultiTreePopup } from "./multi.tree.popup";
+import { MultiTreeCheckSelectedButton } from "./trigger/multi.tree.button.checkselected";
+import { MultiTreeCheckPane } from "./check/multi.tree.check.pane";
import {
shortcut,
extend,
@@ -11,8 +16,6 @@ import {
deepClone
} from "@/core";
import { Single, Combo } from "@/base";
-import { MultiTreeSearchInsertPane } from "./trigger/multi.tree.search.insert.pane";
-import { MultiTreePopup } from "./multi.tree.popup";
import { MultiSelectTrigger } from "../multiselect/multiselect.trigger";
import { TriggerIconButton } from "@/case";
import { MultiSelectCheckSelectedSwitcher } from "../multiselect/trigger/switcher.checkselected";
@@ -50,7 +53,7 @@ export class MultiTreeInsertCombo extends Single {
this.storeValue = { value: o.value || {} };
this.trigger = createWidget({
- type: "bi.multi_select_trigger",
+ type: MultiSelectTrigger.xtype,
allowEdit: o.allowEdit,
height: toPix(o.height, o.simple ? 1 : 2),
valueFormatter: o.valueFormatter,
@@ -66,18 +69,16 @@ export class MultiTreeInsertCombo extends Single {
},
},
searcher: {
- type: "bi.multi_tree_searcher",
+ type: MultiTreeSearcher.xtype,
itemsCreator: o.itemsCreator,
popup: {
- type: "bi.multi_tree_search_insert_pane",
+ type: MultiTreeSearchInsertPane.xtype,
listeners: [
{
eventName: MultiTreeSearchInsertPane.EVENT_ADD_ITEM,
action() {
- self.storeValue.value[
- self.trigger.getSearcher().getKeyword()
- ] = {};
+ self.storeValue.value[self.trigger.getSearcher().getKeyword()] = {};
self._assertShowValue();
// setValue以更新paras.value, 之后从search popup中拿到的就能有add的值了
self.combo.setValue(self.storeValue);
@@ -87,8 +88,7 @@ export class MultiTreeInsertCombo extends Single {
},
},
{
- eventName:
- MultiTreeSearchInsertPane.EVENT_CLICK_TREE_NODE,
+ eventName: MultiTreeSearchInsertPane.EVENT_CLICK_TREE_NODE,
action() {
self._dataChange = true;
},
@@ -107,7 +107,7 @@ export class MultiTreeInsertCombo extends Single {
el: this.trigger,
adjustLength: 1,
popup: {
- type: "bi.multi_tree_popup_view",
+ type: MultiTreePopup.xtype,
ref() {
self.popup = this;
self.trigger.setAdapter(this);
@@ -135,10 +135,7 @@ export class MultiTreeInsertCombo extends Single {
self.trigger.getSearcher().setState(val);
self.numberCounter.setButtonChecked(val);
self.storeValue = { value: self.combo.getValue() };
- self.fireEvent(
- MultiTreeInsertCombo.EVENT_CLICK_ITEM,
- self.getValue()
- );
+ self.fireEvent(MultiTreeInsertCombo.EVENT_CLICK_ITEM, self.getValue());
self._dataChange = true;
},
},
@@ -177,16 +174,12 @@ export class MultiTreeInsertCombo extends Single {
},
});
- var change = false;
- var clear = false; // 标识当前是否点击了清空
+ let change = false;
+ let clear = false; // 标识当前是否点击了清空
- const isSearching = function () {
- return self.trigger.getSearcher().isSearching();
- };
+ const isSearching = () => self.trigger.getSearcher().isSearching();
- const isPopupView = function () {
- return self.combo.isViewVisible();
- };
+ const isPopupView = () => self.combo.isViewVisible();
this.trigger.on(MultiSelectTrigger.EVENT_FOCUS, () => {
self.fireEvent(MultiTreeInsertCombo.EVENT_FOCUS);
@@ -236,14 +229,9 @@ export class MultiTreeInsertCombo extends Single {
type: BI.Selection.Multi,
value: checked ? { 1: 1 } : {},
};
- this.getSearcher().setState(
- checked ? BI.Selection.Multi : BI.Selection.None
- );
+ this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
self.numberCounter.setButtonChecked(val);
- self.fireEvent(
- MultiTreeInsertCombo.EVENT_CLICK_ITEM,
- self.combo.getValue()
- );
+ self.fireEvent(MultiTreeInsertCombo.EVENT_CLICK_ITEM, self.combo.getValue());
self._dataChange = true;
});
@@ -266,8 +254,7 @@ export class MultiTreeInsertCombo extends Single {
this.combo.on(Combo.EVENT_BEFORE_HIDEVIEW, () => {
if (isSearching()) {
self._stopEditing();
- self._dataChange &&
- self.fireEvent(MultiTreeInsertCombo.EVENT_CONFIRM);
+ self._dataChange && self.fireEvent(MultiTreeInsertCombo.EVENT_CONFIRM);
} else {
if (isPopupView()) {
self._stopEditing();
@@ -275,15 +262,14 @@ export class MultiTreeInsertCombo extends Single {
if (clear === true) {
self.storeValue = { value: {} };
}
- self._dataChange &&
- self.fireEvent(MultiTreeInsertCombo.EVENT_CONFIRM);
+ self._dataChange && self.fireEvent(MultiTreeInsertCombo.EVENT_CONFIRM);
}
}
clear = false;
change = false;
});
- var triggerBtn = createWidget({
+ const triggerBtn = createWidget({
type: TriggerIconButton.xtype,
width: o.height,
height: o.height,
@@ -299,12 +285,12 @@ export class MultiTreeInsertCombo extends Single {
});
this.numberCounter = createWidget({
- type: "bi.multi_select_check_selected_switcher",
+ type: MultiSelectCheckSelectedSwitcher.xtype,
el: {
- type: "bi.multi_tree_check_selected_button",
+ type: MultiTreeCheckSelectedButton.xtype,
},
popup: {
- type: "bi.multi_tree_check_pane",
+ type: MultiTreeCheckPane.xtype,
},
itemsCreator: o.itemsCreator,
masker: {
@@ -318,43 +304,32 @@ export class MultiTreeInsertCombo extends Single {
valueFormatter: o.valueFormatter,
value: o.value,
});
- this.numberCounter.on(
- MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE,
- () => {
- if (!self.combo.isViewVisible()) {
- self.combo.showView();
- }
+ this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, () => {
+ if (!self.combo.isViewVisible()) {
+ self.combo.showView();
}
- );
- this.numberCounter.on(
- MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW,
- () => {
- if (want2showCounter === false) {
- want2showCounter = true;
- }
- if (isInit === true) {
- want2showCounter = null;
- showCounter();
- }
+ });
+ this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, () => {
+ if (want2showCounter === false) {
+ want2showCounter = true;
}
- );
-
- this.numberCounter.on(
- MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW,
- () => {
- nextTick(() => {
- // 收起时自动调整宽度
- self.trigger.refreshPlaceHolderWidth(0);
- });
+ if (isInit === true) {
+ want2showCounter = null;
+ showCounter();
}
- );
+ });
+
+ this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW, () => {
+ nextTick(() => {
+ // 收起时自动调整宽度
+ self.trigger.refreshPlaceHolderWidth(0);
+ });
+ });
this.numberCounter.on(Events.VIEW, b => {
nextTick(() => {
// 自动调整宽度
- self.trigger.refreshPlaceHolderWidth(
- b === true ? self.numberCounter.element.outerWidth() + 8 : 0
- );
+ self.trigger.refreshPlaceHolderWidth(b === true ? self.numberCounter.element.outerWidth() + 8 : 0);
});
});
diff --git a/src/widget/multitree/multi.tree.list.combo.js b/src/widget/multitree/multi.tree.list.combo.js
index 056fbd5fc..f5ef2f738 100644
--- a/src/widget/multitree/multi.tree.list.combo.js
+++ b/src/widget/multitree/multi.tree.list.combo.js
@@ -1,3 +1,6 @@
+import { MultiListTreeSearcher } from "./trigger/searcher.list.multi.tree";
+import { MultiTreeCheckSelectedButton } from "./trigger/multi.tree.button.checkselected";
+import { MultiTreeCheckPane } from "./check/multi.tree.check.pane";
import {
shortcut,
extend,
@@ -14,12 +17,7 @@ import { Single, Combo } from "@/base";
import { MultiTreeSearchInsertPane } from "./trigger/multi.tree.search.insert.pane";
import { MultiTreePopup } from "./multi.tree.popup";
import { MultiSelectTrigger } from "../multiselect/multiselect.trigger";
-import {
- TriggerIconButton,
- ListPartTree,
- ListDisplayTree,
- Listasynctree
-} from "@/case";
+import { TriggerIconButton, ListPartTree, ListDisplayTree, Listasynctree } from "@/case";
import { MultiSelectCheckSelectedSwitcher } from "../multiselect/trigger/switcher.checkselected";
@shortcut()
@@ -57,7 +55,7 @@ export class MultiTreeListCombo extends Single {
this.storeValue = { value: o.value || [] };
this.trigger = createWidget({
- type: "bi.multi_select_trigger",
+ type: MultiSelectTrigger.xtype,
allowEdit: o.allowEdit,
text: o.text,
defaultText: o.defaultText,
@@ -73,12 +71,10 @@ export class MultiTreeListCombo extends Single {
},
},
searcher: {
- type: "bi.multi_list_tree_searcher",
+ type: MultiListTreeSearcher.xtype,
itemsCreator: o.itemsCreator,
popup: {
- type: o.allowInsertValue
- ? "bi.multi_tree_search_insert_pane"
- : "bi.multi_tree_search_pane",
+ type: o.allowInsertValue ? "bi.multi_tree_search_insert_pane" : "bi.multi_tree_search_pane",
el: {
type: ListPartTree.xtype,
},
@@ -86,9 +82,7 @@ export class MultiTreeListCombo extends Single {
{
eventName: MultiTreeSearchInsertPane.EVENT_ADD_ITEM,
action() {
- self.storeValue.value.unshift([
- self.trigger.getSearcher().getKeyword()
- ]);
+ self.storeValue.value.unshift([self.trigger.getSearcher().getKeyword()]);
self._assertShowValue();
// setValue以更新paras.value, 之后从search popup中拿到的就能有add的值了
self.combo.setValue(self.storeValue);
@@ -102,10 +96,10 @@ export class MultiTreeListCombo extends Single {
},
switcher: {
el: {
- type: "bi.multi_tree_check_selected_button",
+ type: MultiTreeCheckSelectedButton.xtype,
},
popup: {
- type: "bi.multi_tree_check_pane",
+ type: MultiTreeCheckPane.xtype,
el: {
type: ListDisplayTree.xtype,
},
@@ -154,10 +148,7 @@ export class MultiTreeListCombo extends Single {
self.trigger.getSearcher().setState(val);
self.numberCounter.setButtonChecked(val);
self.storeValue = { value: self.combo.getValue() };
- self.fireEvent(
- MultiTreeListCombo.EVENT_CLICK_ITEM,
- self.getValue()
- );
+ self.fireEvent(MultiTreeListCombo.EVENT_CLICK_ITEM, self.getValue());
self._dataChange = true;
},
},
@@ -196,17 +187,13 @@ export class MultiTreeListCombo extends Single {
},
});
- var change = false;
- var clear = false; // 标识当前是否点击了清空
-
- const isSearching = function () {
- return self.trigger.getSearcher().isSearching();
- };
+ let change = false;
+ let clear = false; // 标识当前是否点击了清空
- const isPopupView = function () {
- return self.combo.isViewVisible();
- };
+ const isSearching = () => self.trigger.getSearcher().isSearching();
+ const isPopupView = () => self.combo.isViewVisible();
+
this.trigger.on(MultiSelectTrigger.EVENT_FOCUS, () => {
self.fireEvent(MultiTreeListCombo.EVENT_FOCUS);
});
@@ -255,14 +242,9 @@ export class MultiTreeListCombo extends Single {
type: BI.Selection.Multi,
value: checked ? { 1: 1 } : {},
};
- this.getSearcher().setState(
- checked ? BI.Selection.Multi : BI.Selection.None
- );
+ this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
self.numberCounter.setButtonChecked(val);
- self.fireEvent(
- MultiTreeListCombo.EVENT_CLICK_ITEM,
- self.combo.getValue()
- );
+ self.fireEvent(MultiTreeListCombo.EVENT_CLICK_ITEM, self.combo.getValue());
self._dataChange = true;
});
@@ -285,8 +267,7 @@ export class MultiTreeListCombo extends Single {
this.combo.on(Combo.EVENT_BEFORE_HIDEVIEW, () => {
if (isSearching()) {
self.trigger.stopEditing();
- self._dataChange &&
- self.fireEvent(MultiTreeListCombo.EVENT_CONFIRM);
+ self._dataChange && self.fireEvent(MultiTreeListCombo.EVENT_CONFIRM);
} else {
if (isPopupView()) {
self._stopEditing();
@@ -294,15 +275,14 @@ export class MultiTreeListCombo extends Single {
if (clear === true) {
self.storeValue = { value: [] };
}
- self._dataChange &&
- self.fireEvent(MultiTreeListCombo.EVENT_CONFIRM);
+ self._dataChange && self.fireEvent(MultiTreeListCombo.EVENT_CONFIRM);
}
}
clear = false;
change = false;
});
- var triggerBtn = createWidget({
+ const triggerBtn = createWidget({
type: TriggerIconButton.xtype,
width: o.height,
height: o.height,
@@ -318,12 +298,12 @@ export class MultiTreeListCombo extends Single {
});
this.numberCounter = createWidget({
- type: "bi.multi_select_check_selected_switcher",
+ type: MultiSelectCheckSelectedSwitcher.xtype,
el: {
- type: "bi.multi_tree_check_selected_button",
+ type: MultiTreeCheckSelectedButton.xtype,
},
popup: {
- type: "bi.multi_tree_check_pane",
+ type: MultiTreeCheckPane.xtype,
},
itemsCreator: o.itemsCreator,
masker: {
@@ -337,45 +317,34 @@ export class MultiTreeListCombo extends Single {
valueFormatter: o.valueFormatter,
value: o.value,
});
- this.numberCounter.on(
- MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE,
- () => {
- if (!self.combo.isViewVisible()) {
- self.combo.showView();
- }
+ this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, () => {
+ if (!self.combo.isViewVisible()) {
+ self.combo.showView();
}
- );
- this.numberCounter.on(
- MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW,
- () => {
- if (want2showCounter === false) {
- want2showCounter = true;
- }
- if (isInit === true) {
- want2showCounter = null;
- showCounter();
- }
+ });
+ this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, () => {
+ if (want2showCounter === false) {
+ want2showCounter = true;
}
- );
+ if (isInit === true) {
+ want2showCounter = null;
+ showCounter();
+ }
+ });
this.numberCounter.on(Events.VIEW, b => {
nextTick(() => {
// 自动调整宽度
- self.trigger.refreshPlaceHolderWidth(
- b === true ? self.numberCounter.element.outerWidth() + 8 : 0
- );
+ self.trigger.refreshPlaceHolderWidth(b === true ? self.numberCounter.element.outerWidth() + 8 : 0);
});
});
- this.numberCounter.on(
- MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW,
- () => {
- nextTick(() => {
- // 收起时自动调整宽度
- self.trigger.refreshPlaceHolderWidth(0);
- });
- }
- );
+ this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW, () => {
+ nextTick(() => {
+ // 收起时自动调整宽度
+ self.trigger.refreshPlaceHolderWidth(0);
+ });
+ });
this.trigger.element.click(e => {
if (self.trigger.element.find(e.target).length > 0) {
diff --git a/src/widget/multitree/multi.tree.popup.js b/src/widget/multitree/multi.tree.popup.js
index aeb1ced3d..ad450a7cd 100644
--- a/src/widget/multitree/multi.tree.popup.js
+++ b/src/widget/multitree/multi.tree.popup.js
@@ -54,19 +54,19 @@ export class MultiTreePopup extends Pane {
el: this.tree,
});
- this.popupView.on(
- MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON,
- index => {
- switch (index) {
- case 0:
- self.fireEvent(MultiTreePopup.EVENT_CLICK_CLEAR);
- break;
- case 1:
- self.fireEvent(MultiTreePopup.EVENT_CLICK_CONFIRM);
- break;
- }
+ this.popupView.on(MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, index => {
+ switch (index) {
+ case 0:
+ self.fireEvent(MultiTreePopup.EVENT_CLICK_CLEAR);
+ break;
+ case 1:
+ self.fireEvent(MultiTreePopup.EVENT_CLICK_CONFIRM);
+ break;
+
+ default:
+ break;
}
- );
+ });
this.tree.on(TreeView.EVENT_CHANGE, () => {
self.fireEvent(MultiTreePopup.EVENT_CHANGE);
diff --git a/src/widget/multitree/trigger/multi.tree.button.checkselected.js b/src/widget/multitree/trigger/multi.tree.button.checkselected.js
index 7c8e95444..3d7b13299 100644
--- a/src/widget/multitree/trigger/multi.tree.button.checkselected.js
+++ b/src/widget/multitree/trigger/multi.tree.button.checkselected.js
@@ -1,12 +1,4 @@
-import {
- shortcut,
- extend,
- emptyFn,
- createWidget,
- i18nText,
- Controller,
- size
-} from "@/core";
+import { HorizontalLayout, shortcut, extend, emptyFn, createWidget, i18nText, Controller, size } from "@/core";
import { Single, TextButton, IconButton } from "@/base";
import { MultiSelectCheckSelectedButton } from "../../multiselect/trigger/button.checkselected";
@@ -47,14 +39,11 @@ export class MultiTreeCheckSelectedButton extends Single {
});
this.checkSelected.on(TextButton.EVENT_CHANGE, function () {
- self.fireEvent(
- MultiSelectCheckSelectedButton.EVENT_CHANGE,
- arguments
- );
+ self.fireEvent(MultiSelectCheckSelectedButton.EVENT_CHANGE, arguments);
});
createWidget({
- type: "bi.horizontal",
+ type: HorizontalLayout.xtype,
element: this,
items: [this.indicator, this.checkSelected],
});
diff --git a/src/widget/multitree/trigger/multi.tree.search.insert.pane.js b/src/widget/multitree/trigger/multi.tree.search.insert.pane.js
index bb0a8f219..6ae93d971 100644
--- a/src/widget/multitree/trigger/multi.tree.search.insert.pane.js
+++ b/src/widget/multitree/trigger/multi.tree.search.insert.pane.js
@@ -1,12 +1,4 @@
-import {
- shortcut,
- Widget,
- i18nText,
- extend,
- Controller,
- AbsoluteLayout,
- isEmptyArray
-} from "@/core";
+import { shortcut, Widget, i18nText, extend, Controller, AbsoluteLayout, isEmptyArray } from "@/core";
import { TreeView, PartTree } from "@/case";
import { TextButton } from "@/base";
@@ -43,10 +35,7 @@ export class MultiTreeSearchInsertPane extends Widget {
height: this.constants.height,
cls: "bi-high-light",
handler() {
- self.fireEvent(
- MultiTreeSearchInsertPane.EVENT_ADD_ITEM,
- opts.keywordGetter()
- );
+ self.fireEvent(MultiTreeSearchInsertPane.EVENT_ADD_ITEM, opts.keywordGetter());
},
},
top: 5,
@@ -62,10 +51,7 @@ export class MultiTreeSearchInsertPane extends Widget {
op.keyword = opts.keywordGetter();
opts.itemsCreator(op, res => {
callback(res);
- self.setKeyword(
- opts.keywordGetter(),
- res.items
- );
+ self.setKeyword(opts.keywordGetter(), res.items);
});
},
ref(_ref) {
@@ -76,26 +62,19 @@ export class MultiTreeSearchInsertPane extends Widget {
{
eventName: Controller.EVENT_CHANGE,
action() {
- self.fireEvent(
- Controller.EVENT_CHANGE,
- arguments
- );
+ self.fireEvent(Controller.EVENT_CHANGE, arguments);
},
},
{
eventName: TreeView.EVENT_CHANGE,
action() {
- self.fireEvent(
- MultiTreeSearchInsertPane.EVENT_CHANGE
- );
+ self.fireEvent(MultiTreeSearchInsertPane.EVENT_CHANGE);
},
},
{
eventName: PartTree.EVENT_CLICK_TREE_NODE,
action() {
- self.fireEvent(
- MultiTreeSearchInsertPane.EVENT_CLICK_TREE_NODE
- );
+ self.fireEvent(MultiTreeSearchInsertPane.EVENT_CLICK_TREE_NODE);
},
}
],
@@ -115,10 +94,7 @@ export class MultiTreeSearchInsertPane extends Widget {
const isAddTipVisible = isEmptyArray(nodes);
this.addTip.setVisible(isAddTipVisible);
this.partTree.setVisible(!isAddTipVisible);
- isAddTipVisible &&
- this.addTip.setText(
- i18nText("BI-Basic_Click_To_Add_Text", keyword)
- );
+ isAddTipVisible && this.addTip.setText(i18nText("BI-Basic_Click_To_Add_Text", keyword));
}
hasChecked() {
diff --git a/src/widget/multitree/trigger/multi.tree.search.pane.js b/src/widget/multitree/trigger/multi.tree.search.pane.js
index bfea3f11b..63de74987 100644
--- a/src/widget/multitree/trigger/multi.tree.search.pane.js
+++ b/src/widget/multitree/trigger/multi.tree.search.pane.js
@@ -43,9 +43,7 @@ export class MultiTreeSearchPane extends Pane {
{
eventName: PartTree.EVENT_CLICK_TREE_NODE,
action() {
- self.fireEvent(
- MultiTreeSearchPane.EVENT_CLICK_TREE_NODE
- );
+ self.fireEvent(MultiTreeSearchPane.EVENT_CLICK_TREE_NODE);
},
}
],
diff --git a/src/widget/multitree/trigger/searcher.list.multi.tree.js b/src/widget/multitree/trigger/searcher.list.multi.tree.js
index 2356c0971..ae390b49c 100644
--- a/src/widget/multitree/trigger/searcher.list.multi.tree.js
+++ b/src/widget/multitree/trigger/searcher.list.multi.tree.js
@@ -1,15 +1,4 @@
-import {
- shortcut,
- Widget,
- extend,
- emptyFn,
- createWidget,
- isNotNull,
- isNumber,
- size,
- each,
- last
-} from "@/core";
+import { shortcut, Widget, extend, emptyFn, createWidget, isNotNull, isNumber, size, each, last } from "@/core";
import { MultiSelectEditor } from "../../multiselect/trigger/editor.multiselect";
import { MultiSelectSearcher } from "../../multiselect/trigger/searcher.multiselect";
import { Searcher } from "@/base";
@@ -158,11 +147,7 @@ export class MultiListTreeSearcher extends Widget {
let text = "";
each(ob.value, (idx, path) => {
const childValue = last(path);
- text +=
- path === "null"
- ? ""
- : `${o.valueFormatter(`${childValue}`) || childValue
- }; `;
+ text += path === "null" ? "" : `${o.valueFormatter(`${childValue}`) || childValue}; `;
count++;
});
diff --git a/src/widget/multitree/trigger/searcher.multi.tree.js b/src/widget/multitree/trigger/searcher.multi.tree.js
index cfc2a5201..ea8d96086 100644
--- a/src/widget/multitree/trigger/searcher.multi.tree.js
+++ b/src/widget/multitree/trigger/searcher.multi.tree.js
@@ -9,7 +9,8 @@ import {
size,
keys,
each,
- isEmptyObject, Func
+ isEmptyObject,
+ Func
} from "@/core";
import { MultiSelectEditor } from "../../multiselect/trigger/editor.multiselect";
import { MultiSelectSearcher } from "../../multiselect/trigger/searcher.multiselect";
@@ -48,7 +49,7 @@ export class MultiTreeSearcher extends Widget {
const self = this,
o = this.options;
this.editor = createWidget({
- type: "bi.multi_select_editor",
+ type: MultiSelectEditor.xtype,
watermark: o.watermark,
height: o.height,
el: {
@@ -97,13 +98,9 @@ export class MultiTreeSearcher extends Widget {
},
listeners: [
{
- eventName:
- MultiTreeSearchPane.EVENT_CLICK_TREE_NODE,
+ eventName: MultiTreeSearchPane.EVENT_CLICK_TREE_NODE,
action() {
- self.fireEvent(
- MultiTreeSearcher.EVENT_CLICK_TREE_NODE,
- arguments
- );
+ self.fireEvent(MultiTreeSearcher.EVENT_CLICK_TREE_NODE, arguments);
},
}
],
@@ -179,16 +176,10 @@ export class MultiTreeSearcher extends Widget {
const names = BI.Func.getSortedResult(keys(value));
each(names, (idx, name) => {
const childNodes = getChildrenNode(value[name]);
- text +=
- `${(name === "null"
- ? ""
- : o.valueFormatter(`${name}`) || name) +
- (childNodes === ""
- ? isEmptyObject(value[name])
- ? ""
- : ":"
- : `:${childNodes}`)
- }; `;
+ text += `${
+ (name === "null" ? "" : o.valueFormatter(`${name}`) || name) +
+ (childNodes === "" ? (isEmptyObject(value[name]) ? "" : ":") : `:${childNodes}`)
+ }; `;
if (childNodes === "") {
count++;
}
@@ -203,7 +194,7 @@ export class MultiTreeSearcher extends Widget {
function getChildrenNode(ob) {
let text = "";
- const size = size(ob);
+ const _size = size(ob);
let index = 0;
const names = Func.getSortedResult(keys(ob));
@@ -211,11 +202,9 @@ export class MultiTreeSearcher extends Widget {
index++;
const childNodes = getChildrenNode(ob[name]);
text +=
- (name === "null"
- ? ""
- : o.valueFormatter(`${name}`) || name) +
+ (name === "null" ? "" : o.valueFormatter(`${name}`) || name) +
(childNodes === "" ? "" : `:${childNodes}`) +
- (index === size ? "" : ",");
+ (index === _size ? "" : ",");
if (childNodes === "") {
count++;
}
diff --git a/src/widget/numbereditor/number.editor.js b/src/widget/numbereditor/number.editor.js
index 6e89f07df..1adc95ce4 100644
--- a/src/widget/numbereditor/number.editor.js
+++ b/src/widget/numbereditor/number.editor.js
@@ -1,23 +1,41 @@
-import { shortcut, Widget, extend, emptyFn, createWidget, toPix, parseFloat, HTapeLayout, GridLayout, isNumeric, clamp, MIN, MAX, KeyCode, add } from "@/core";
+import {
+ shortcut,
+ Widget,
+ extend,
+ emptyFn,
+ createWidget,
+ toPix,
+ parseFloat,
+ HTapeLayout,
+ GridLayout,
+ isNumeric,
+ clamp,
+ MIN,
+ MAX,
+ KeyCode,
+ add
+} from "@/core";
import { SignEditor } from "@/case";
import { TextEditor } from "../editor";
import { IconButton } from "@/base";
@shortcut()
export class NumberEditor extends Widget {
- static xtype = "bi.number_editor"
+ static xtype = "bi.number_editor";
- static EVENT_CONFIRM = "EVENT_CONFIRM"
- static EVENT_CHANGE = "EVENT_CHANGE"
+ static EVENT_CONFIRM = "EVENT_CONFIRM";
+ static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig(conf) {
return extend(super._defaultConfig(...arguments), {
- baseCls: `bi-number-editor bi-focus-shadow ${conf.simple ? "bi-border-bottom" : "bi-border bi-border-radius"}`,
+ baseCls: `bi-number-editor bi-focus-shadow ${
+ conf.simple ? "bi-border-bottom" : "bi-border bi-border-radius"
+ }`,
validationChecker: emptyFn,
- valueFormatter (v) {
+ valueFormatter(v) {
return v;
},
- valueParser (v) {
+ valueParser(v) {
return v;
},
value: 0,
@@ -50,27 +68,28 @@ export class NumberEditor extends Widget {
return o.validationChecker(parsedValue);
},
errorText: o.errorText,
- listeners: [{
- eventName: SignEditor.EVENT_QUICK_DOWN,
- action: e => {
- if ([KeyCode.UP, KeyCode.DOWN].includes(e.keyCode)) {
- e.preventDefault();
- }
- },
- },
- {
- eventName: SignEditor.EVENT_KEY_DOWN,
- action: keycode => {
- if (keycode === KeyCode.UP) {
- this._finetuning(o.step);
-
- return;
- }
- if (keycode === KeyCode.DOWN) {
- this._finetuning(-o.step);
- }
+ listeners: [
+ {
+ eventName: SignEditor.EVENT_QUICK_DOWN,
+ action: e => {
+ if ([KeyCode.UP, KeyCode.DOWN].includes(e.keyCode)) {
+ e.preventDefault();
+ }
+ },
},
- }
+ {
+ eventName: SignEditor.EVENT_KEY_DOWN,
+ action: keycode => {
+ if (keycode === KeyCode.UP) {
+ this._finetuning(o.step);
+
+ return;
+ }
+ if (keycode === KeyCode.DOWN) {
+ this._finetuning(-o.step);
+ }
+ },
+ }
],
});
this.editor.on(TextEditor.EVENT_CHANGE, () => {
@@ -98,7 +117,9 @@ export class NumberEditor extends Widget {
forceNotSelected: true,
trigger: "lclick,",
debounce: false,
- cls: `${o.simple ? "solid-triangle-top-font " : "add-up-font bi-border-left "}top-button bi-list-item-active2 icon-size-12`,
+ cls: `${
+ o.simple ? "solid-triangle-top-font " : "add-up-font bi-border-left "
+ }top-button bi-list-item-active2 icon-size-12`,
});
this.topBtn.on(IconButton.EVENT_CHANGE, () => {
this._finetuning(o.step);
@@ -110,7 +131,9 @@ export class NumberEditor extends Widget {
trigger: "lclick,",
forceNotSelected: true,
debounce: false,
- cls: `${o.simple ? "solid-triangle-bottom-font " : "minus-down-font bi-border-left "}bottom-button bi-list-item-active2 icon-size-12`,
+ cls: `${
+ o.simple ? "solid-triangle-bottom-font " : "minus-down-font bi-border-left "
+ }bottom-button bi-list-item-active2 icon-size-12`,
});
this.bottomBtn.on(IconButton.EVENT_CHANGE, () => {
this._finetuning(-o.step);
@@ -122,20 +145,24 @@ export class NumberEditor extends Widget {
height: toPix(o.height, 2),
element: this,
items: [
- this.editor, {
+ this.editor,
+ {
el: {
type: GridLayout.xtype,
columns: 1,
rows: 2,
- items: [{
- column: 0,
- row: 0,
- el: this.topBtn,
- }, {
- column: 0,
- row: 1,
- el: this.bottomBtn,
- }],
+ items: [
+ {
+ column: 0,
+ row: 0,
+ el: this.topBtn,
+ },
+ {
+ column: 0,
+ row: 1,
+ el: this.bottomBtn,
+ }
+ ],
},
width: 23,
}
@@ -165,10 +192,7 @@ export class NumberEditor extends Widget {
}
_finetuning(addValue) {
- const {
- max,
- min,
- } = this.options;
+ const { max, min } = this.options;
let v = parseFloat(this.getValue());
v = add(v, addValue);
v = clamp(v, min, max);
diff --git a/src/widget/numberinterval/numberinterval.js b/src/widget/numberinterval/numberinterval.js
index ae0a22ae9..89085cd75 100644
--- a/src/widget/numberinterval/numberinterval.js
+++ b/src/widget/numberinterval/numberinterval.js
@@ -1,11 +1,25 @@
-import { shortcut, extend, i18nText, createWidget, toPix, isNumeric, AbsoluteLayout, isEmptyString, isNotNull, isNull, isIE, getIEVersion } from "@/core";
+import {
+ HorizontalFillLayout,
+ shortcut,
+ extend,
+ i18nText,
+ createWidget,
+ toPix,
+ isNumeric,
+ AbsoluteLayout,
+ isEmptyString,
+ isNotNull,
+ isNull,
+ isIE,
+ getIEVersion,
+} from "@/core";
import { Single, Label, Bubbles } from "@/base";
import { IconCombo } from "@/case";
import { NumberIntervalSingleEidtor } from "./singleeditor/single.editor";
@shortcut()
export class NumberInterval extends Single {
- static xtype = "bi.number_interval"
+ static xtype = "bi.number_interval";
constants = {
typeError: "typeBubble",
@@ -23,16 +37,16 @@ export class NumberInterval extends Single {
adjustYOffset: 2,
};
- static EVENT_CHANGE = "EVENT_CHANGE"
- static EVENT_CONFIRM = "EVENT_CONFIRM"
- static EVENT_VALID = "EVENT_VALID"
- static EVENT_ERROR = "EVENT_ERROR"
+ static EVENT_CHANGE = "EVENT_CHANGE";
+ static EVENT_CONFIRM = "EVENT_CONFIRM";
+ static EVENT_VALID = "EVENT_VALID";
+ static EVENT_ERROR = "EVENT_ERROR";
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
-
+
return extend(conf, {
- extraCls: `bi-number-interval${(isIE() && getIEVersion() < 10) ? " hack" : ""}`,
+ extraCls: `bi-number-interval${isIE() && getIEVersion() < 10 ? " hack" : ""}`,
height: 24,
validation: "valid",
closeMin: true,
@@ -47,29 +61,31 @@ export class NumberInterval extends Single {
o = this.options;
super._init(...arguments);
this.smallEditor = createWidget({
- type: "bi.number_interval_single_editor",
+ type: NumberIntervalSingleEidtor.xtype,
height: toPix(o.height, o.simple ? 1 : 2),
watermark: o.watermark,
allowBlank: o.allowBlank,
value: o.min,
level: "warning",
tipType: "success",
- title () {
+ title() {
return self.smallEditor && self.smallEditor.getValue();
},
- quitChecker () {
+ quitChecker() {
return false;
},
- validationChecker (v) {
+ validationChecker(v) {
if (!isNumeric(v)) {
self.smallEditorBubbleType = c.typeError;
-
+
return false;
}
-
+
return true;
},
- cls: `number-interval-small-editor bi-focus-shadow ${o.simple ? "bi-border-bottom" : "bi-border bi-border-corner-left-radius"}`,
+ cls: `number-interval-small-editor bi-focus-shadow ${
+ o.simple ? "bi-border-bottom" : "bi-border bi-border-corner-left-radius"
+ }`,
});
this.smallTip = createWidget({
@@ -81,35 +97,39 @@ export class NumberInterval extends Single {
createWidget({
type: AbsoluteLayout.xtype,
element: this.smallEditor,
- items: [{
- el: this.smallTip,
- top: 0,
- right: 5,
- }],
+ items: [
+ {
+ el: this.smallTip,
+ top: 0,
+ right: 5,
+ },
+ ],
});
this.bigEditor = createWidget({
- type: "bi.number_interval_single_editor",
+ type: NumberIntervalSingleEidtor.xtype,
height: toPix(o.height, o.simple ? 1 : 2),
watermark: o.watermark,
allowBlank: o.allowBlank,
value: o.max,
- title () {
+ title() {
return self.bigEditor && self.bigEditor.getValue();
},
- quitChecker () {
+ quitChecker() {
return false;
},
- validationChecker (v) {
+ validationChecker(v) {
if (!isNumeric(v)) {
self.bigEditorBubbleType = c.typeError;
-
+
return false;
}
-
+
return true;
},
- cls: `number-interval-big-editor bi-focus-shadow${o.simple ? " bi-border-bottom" : " bi-border bi-border-corner-right-radius"}`,
+ cls: `number-interval-big-editor bi-focus-shadow${
+ o.simple ? " bi-border-bottom" : " bi-border bi-border-corner-right-radius"
+ }`,
});
this.bigTip = createWidget({
@@ -121,26 +141,33 @@ export class NumberInterval extends Single {
createWidget({
type: AbsoluteLayout.xtype,
element: this.bigEditor,
- items: [{
- el: this.bigTip,
- top: 0,
- right: 5,
- }],
+ items: [
+ {
+ el: this.bigTip,
+ top: 0,
+ right: 5,
+ },
+ ],
});
this.smallCombo = createWidget({
type: IconCombo.xtype,
- cls: `number-interval-small-combo${o.simple ? "" : " bi-border-top bi-border-bottom bi-border-right bi-border-corner-right-radius"}`,
+ cls: `number-interval-small-combo${
+ o.simple ? "" : " bi-border-top bi-border-bottom bi-border-right bi-border-corner-right-radius"
+ }`,
height: toPix(o.height, o.simple ? 0 : 2),
width: toPix(c.width, c.border),
- items: [{
- text: `(${i18nText("BI-Less_Than")})`,
- iconCls: "less-font",
- value: 0,
- }, {
- text: `(${i18nText("BI-Less_And_Equal")})`,
- value: 1,
- iconCls: "less-equal-font",
- }],
+ items: [
+ {
+ text: `(${i18nText("BI-Less_Than")})`,
+ iconCls: "less-font",
+ value: 0,
+ },
+ {
+ text: `(${i18nText("BI-Less_And_Equal")})`,
+ value: 1,
+ iconCls: "less-equal-font",
+ },
+ ],
});
if (o.closeMin === true) {
this.smallCombo.setValue(1);
@@ -149,18 +176,23 @@ export class NumberInterval extends Single {
}
this.bigCombo = createWidget({
type: IconCombo.xtype,
- cls: `number-interval-big-combo${o.simple ? "" : " bi-border-top bi-border-bottom bi-border-left bi-border-corner-left-radius"}`,
+ cls: `number-interval-big-combo${
+ o.simple ? "" : " bi-border-top bi-border-bottom bi-border-left bi-border-corner-left-radius"
+ }`,
height: toPix(o.height, o.simple ? 0 : 2),
width: toPix(c.width, c.border),
- items: [{
- text: `(${i18nText("BI-Less_Than")})`,
- iconCls: "less-font",
- value: 0,
- }, {
- text: `(${i18nText("BI-Less_And_Equal")})`,
- value: 1,
- iconCls: "less-equal-font",
- }],
+ items: [
+ {
+ text: `(${i18nText("BI-Less_Than")})`,
+ iconCls: "less-font",
+ value: 0,
+ },
+ {
+ text: `(${i18nText("BI-Less_And_Equal")})`,
+ value: 1,
+ iconCls: "less-equal-font",
+ },
+ ],
});
if (o.closeMax === true) {
this.bigCombo.setValue(1);
@@ -178,38 +210,47 @@ export class NumberInterval extends Single {
tipType: "warning",
});
this.left = createWidget({
- type: "bi.horizontal_fill",
+ type: HorizontalFillLayout.xtype,
columnSize: ["fill", ""],
- items: [{
- el: self.smallEditor,
- }, {
- el: self.smallCombo,
- }],
-
+ items: [
+ {
+ el: self.smallEditor,
+ },
+ {
+ el: self.smallCombo,
+ },
+ ],
});
this.right = createWidget({
- type: "bi.horizontal_fill",
+ type: HorizontalFillLayout.xtype,
columnSize: ["", "fill"],
- items: [{
- el: self.bigCombo,
- }, {
- el: self.bigEditor,
- // BI-23883 间距考虑边框
- // lgap: 1
- }],
+ items: [
+ {
+ el: self.bigCombo,
+ },
+ {
+ el: self.bigEditor,
+ // BI-23883 间距考虑边框
+ // lgap: 1
+ },
+ ],
});
createWidget({
element: self,
- type: "bi.horizontal_fill",
+ type: HorizontalFillLayout.xtype,
columnSize: ["fill", "", "fill"],
- items: [{
- el: self.left,
- }, {
- el: self.label,
- }, {
- el: self.right,
- }],
+ items: [
+ {
+ el: self.left,
+ },
+ {
+ el: self.label,
+ },
+ {
+ el: self.right,
+ },
+ ],
});
// createWidget({
@@ -275,13 +316,13 @@ export class NumberInterval extends Single {
if (!self.smallEditor.isValid() || !self.bigEditor.isValid()) {
self.element.removeClass("number-error");
o.validation = "invalid";
-
+
return c.typeError;
}
if (isEmptyString(self.smallEditor.getValue()) || isEmptyString(self.bigEditor.getValue())) {
self.element.removeClass("number-error");
o.validation = "valid";
-
+
return "";
}
const smallValue = parseFloat(self.smallEditor.getValue()),
@@ -292,28 +333,28 @@ export class NumberInterval extends Single {
if (smallValue > bigValue) {
self.element.addClass("number-error");
o.validation = "invalid";
-
+
return c.numberError;
}
self.element.removeClass("number-error");
o.validation = "valid";
-
+
return "";
}
if (smallValue > bigValue) {
self.element.addClass("number-error");
o.validation = "invalid";
-
+
return c.numberError;
} else if (smallValue === bigValue) {
self.element.addClass("number-error");
o.validation = "invalid";
-
+
return c.signalError;
}
self.element.removeClass("number-error");
o.validation = "valid";
-
+
return "";
}
@@ -327,26 +368,26 @@ export class NumberInterval extends Single {
w.on(NumberIntervalSingleEidtor.EVENT_FOCUS, () => {
self._setTitle("");
switch (self._checkValidation()) {
- case c.typeError:
- Bubbles.show(c.typeError, i18nText("BI-Numerical_Interval_Input_Data"), self, {
- offsetStyle: "left",
- adjustYOffset: c.adjustYOffset,
- });
- break;
- case c.numberError:
- Bubbles.show(c.numberError, i18nText("BI-Numerical_Interval_Number_Value"), self, {
- offsetStyle: "left",
- adjustYOffset: c.adjustYOffset,
- });
- break;
- case c.signalError:
- Bubbles.show(c.signalError, i18nText("BI-Numerical_Interval_Signal_Value"), self, {
- offsetStyle: "left",
- adjustYOffset: c.adjustYOffset,
- });
- break;
- default:
- return;
+ case c.typeError:
+ Bubbles.show(c.typeError, i18nText("BI-Numerical_Interval_Input_Data"), self, {
+ offsetStyle: "left",
+ adjustYOffset: c.adjustYOffset,
+ });
+ break;
+ case c.numberError:
+ Bubbles.show(c.numberError, i18nText("BI-Numerical_Interval_Number_Value"), self, {
+ offsetStyle: "left",
+ adjustYOffset: c.adjustYOffset,
+ });
+ break;
+ case c.signalError:
+ Bubbles.show(c.signalError, i18nText("BI-Numerical_Interval_Signal_Value"), self, {
+ offsetStyle: "left",
+ adjustYOffset: c.adjustYOffset,
+ });
+ break;
+ default:
+ return;
}
});
}
@@ -359,17 +400,17 @@ export class NumberInterval extends Single {
Bubbles.hide(c.numberError);
Bubbles.hide(c.signalError);
switch (self._checkValidation()) {
- case c.typeError:
- self._setTitle(i18nText("BI-Numerical_Interval_Input_Data"));
- break;
- case c.numberError:
- self._setTitle(i18nText("BI-Numerical_Interval_Number_Value"));
- break;
- case c.signalError:
- self._setTitle(i18nText("BI-Numerical_Interval_Signal_Value"));
- break;
- default:
- self._setTitle("");
+ case c.typeError:
+ self._setTitle(i18nText("BI-Numerical_Interval_Input_Data"));
+ break;
+ case c.numberError:
+ self._setTitle(i18nText("BI-Numerical_Interval_Number_Value"));
+ break;
+ case c.signalError:
+ self._setTitle(i18nText("BI-Numerical_Interval_Signal_Value"));
+ break;
+ default:
+ self._setTitle("");
}
});
}
@@ -392,22 +433,22 @@ export class NumberInterval extends Single {
c = this.constants;
w.on(NumberIntervalSingleEidtor.EVENT_VALID, () => {
switch (self._checkValidation()) {
- case c.numberError:
- Bubbles.show(c.numberError, i18nText("BI-Numerical_Interval_Number_Value"), self, {
- offsetStyle: "left",
- adjustYOffset: c.adjustYOffset,
- });
- self.fireEvent(NumberInterval.EVENT_ERROR);
- break;
- case c.signalError:
- Bubbles.show(c.signalError, i18nText("BI-Numerical_Interval_Signal_Value"), self, {
- offsetStyle: "left",
- adjustYOffset: c.adjustYOffset,
- });
- self.fireEvent(NumberInterval.EVENT_ERROR);
- break;
- default:
- self.fireEvent(NumberInterval.EVENT_VALID);
+ case c.numberError:
+ Bubbles.show(c.numberError, i18nText("BI-Numerical_Interval_Number_Value"), self, {
+ offsetStyle: "left",
+ adjustYOffset: c.adjustYOffset,
+ });
+ self.fireEvent(NumberInterval.EVENT_ERROR);
+ break;
+ case c.signalError:
+ Bubbles.show(c.signalError, i18nText("BI-Numerical_Interval_Signal_Value"), self, {
+ offsetStyle: "left",
+ adjustYOffset: c.adjustYOffset,
+ });
+ self.fireEvent(NumberInterval.EVENT_ERROR);
+ break;
+ default:
+ self.fireEvent(NumberInterval.EVENT_VALID);
}
});
}
@@ -417,26 +458,26 @@ export class NumberInterval extends Single {
c = this.constants;
w.on(NumberIntervalSingleEidtor.EVENT_CHANGE, () => {
switch (self._checkValidation()) {
- case c.typeError:
- Bubbles.show(c.typeError, i18nText("BI-Numerical_Interval_Input_Data"), self, {
- offsetStyle: "left",
- adjustYOffset: c.adjustYOffset,
- });
- break;
- case c.numberError:
- Bubbles.show(c.numberError, i18nText("BI-Numerical_Interval_Number_Value"), self, {
- offsetStyle: "left",
- adjustYOffset: c.adjustYOffset,
- });
- break;
- case c.signalError:
- Bubbles.show(c.signalError, i18nText("BI-Numerical_Interval_Signal_Value"), self, {
- offsetStyle: "left",
- adjustYOffset: c.adjustYOffset,
- });
- break;
- default:
- break;
+ case c.typeError:
+ Bubbles.show(c.typeError, i18nText("BI-Numerical_Interval_Input_Data"), self, {
+ offsetStyle: "left",
+ adjustYOffset: c.adjustYOffset,
+ });
+ break;
+ case c.numberError:
+ Bubbles.show(c.numberError, i18nText("BI-Numerical_Interval_Number_Value"), self, {
+ offsetStyle: "left",
+ adjustYOffset: c.adjustYOffset,
+ });
+ break;
+ case c.signalError:
+ Bubbles.show(c.signalError, i18nText("BI-Numerical_Interval_Signal_Value"), self, {
+ offsetStyle: "left",
+ adjustYOffset: c.adjustYOffset,
+ });
+ break;
+ default:
+ break;
}
self.fireEvent(NumberInterval.EVENT_CHANGE);
});
@@ -450,22 +491,22 @@ export class NumberInterval extends Single {
c = this.constants;
w.on(IconCombo.EVENT_CHANGE, () => {
switch (self._checkValidation()) {
- case c.typeError:
- self._setTitle(i18nText("BI-Numerical_Interval_Input_Data"));
- self.fireEvent(NumberInterval.EVENT_ERROR);
- break;
- case c.numberError:
- self._setTitle(i18nText("BI-Numerical_Interval_Number_Value"));
- self.fireEvent(NumberInterval.EVENT_ERROR);
- break;
- case c.signalError:
- self._setTitle(i18nText("BI-Numerical_Interval_Signal_Value"));
- self.fireEvent(NumberInterval.EVENT_ERROR);
- break;
- default:
- self.fireEvent(NumberInterval.EVENT_CHANGE);
- self.fireEvent(NumberInterval.EVENT_CONFIRM);
- self.fireEvent(NumberInterval.EVENT_VALID);
+ case c.typeError:
+ self._setTitle(i18nText("BI-Numerical_Interval_Input_Data"));
+ self.fireEvent(NumberInterval.EVENT_ERROR);
+ break;
+ case c.numberError:
+ self._setTitle(i18nText("BI-Numerical_Interval_Number_Value"));
+ self.fireEvent(NumberInterval.EVENT_ERROR);
+ break;
+ case c.signalError:
+ self._setTitle(i18nText("BI-Numerical_Interval_Signal_Value"));
+ self.fireEvent(NumberInterval.EVENT_ERROR);
+ break;
+ default:
+ self.fireEvent(NumberInterval.EVENT_CHANGE);
+ self.fireEvent(NumberInterval.EVENT_CONFIRM);
+ self.fireEvent(NumberInterval.EVENT_VALID);
}
});
}
@@ -568,7 +609,7 @@ export class NumberInterval extends Single {
} else {
value.closeMax = true;
}
-
+
return value;
}
diff --git a/src/widget/numberinterval/singleeditor/single.editor.js b/src/widget/numberinterval/singleeditor/single.editor.js
index 80126ad53..1e477b245 100644
--- a/src/widget/numberinterval/singleeditor/single.editor.js
+++ b/src/widget/numberinterval/singleeditor/single.editor.js
@@ -3,15 +3,15 @@ import { Single, Editor } from "@/base";
@shortcut()
export class NumberIntervalSingleEidtor extends Single {
- static xtype = "bi.number_interval_single_editor"
+ static xtype = "bi.number_interval_single_editor";
- static EVENT_FOCUS = "EVENT_FOCUS"
- static EVENT_BLUR = "EVENT_BLUR"
- static EVENT_ERROR = "EVENT_ERROR"
- static EVENT_VALID = "EVENT_VALID"
- static EVENT_CHANGE = "EVENT_CHANGE"
- static EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM"
- static EVENT_CONFIRM = "EVENT_CONFIRM"
+ static EVENT_FOCUS = "EVENT_FOCUS";
+ static EVENT_BLUR = "EVENT_BLUR";
+ static EVENT_ERROR = "EVENT_ERROR";
+ static EVENT_VALID = "EVENT_VALID";
+ static EVENT_CHANGE = "EVENT_CHANGE";
+ static EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM";
+ static EVENT_CONFIRM = "EVENT_CONFIRM";
props = {
baseCls: "bi-number-interval-single-editor",
@@ -25,55 +25,65 @@ export class NumberIntervalSingleEidtor extends Single {
return {
type: VerticalLayout.xtype,
- items: [{
- type: Editor.xtype,
- simple: o.simple,
- ref (_ref) {
- self.editor = _ref;
- },
- height: o.height,
- watermark: o.watermark,
- allowBlank: o.allowBlank,
- value: o.value,
- quitChecker: o.quitChecker,
- validationChecker: o.validationChecker,
- listeners: [{
- eventName: Editor.EVENT_ERROR,
- action () {
- self.fireEvent(NumberIntervalSingleEidtor.EVENT_ERROR, arguments);
+ items: [
+ {
+ type: Editor.xtype,
+ simple: o.simple,
+ ref(_ref) {
+ self.editor = _ref;
},
- }, {
- eventName: Editor.EVENT_FOCUS,
- action () {
- self.fireEvent(NumberIntervalSingleEidtor.EVENT_FOCUS, arguments);
- },
- }, {
- eventName: Editor.EVENT_BLUR,
- action () {
- self.fireEvent(NumberIntervalSingleEidtor.EVENT_BLUR, arguments);
- },
- }, {
- eventName: Editor.EVENT_VALID,
- action () {
- self.fireEvent(NumberIntervalSingleEidtor.EVENT_VALID, arguments);
- },
- }, {
- eventName: Editor.EVENT_CHANGE,
- action () {
- self.fireEvent(NumberIntervalSingleEidtor.EVENT_CHANGE, arguments);
- },
- }, {
- eventName: Editor.EVENT_CONFIRM,
- action () {
- self.fireEvent(NumberIntervalSingleEidtor.EVENT_CONFIRM, arguments);
- },
- }, {
- eventName: Editor.EVENT_CHANGE_CONFIRM,
- action () {
- self.fireEvent(NumberIntervalSingleEidtor.EVENT_CHANGE_CONFIRM, arguments);
- },
- }],
- }],
+ height: o.height,
+ watermark: o.watermark,
+ allowBlank: o.allowBlank,
+ value: o.value,
+ quitChecker: o.quitChecker,
+ validationChecker: o.validationChecker,
+ listeners: [
+ {
+ eventName: Editor.EVENT_ERROR,
+ action() {
+ self.fireEvent(NumberIntervalSingleEidtor.EVENT_ERROR, arguments);
+ },
+ },
+ {
+ eventName: Editor.EVENT_FOCUS,
+ action() {
+ self.fireEvent(NumberIntervalSingleEidtor.EVENT_FOCUS, arguments);
+ },
+ },
+ {
+ eventName: Editor.EVENT_BLUR,
+ action() {
+ self.fireEvent(NumberIntervalSingleEidtor.EVENT_BLUR, arguments);
+ },
+ },
+ {
+ eventName: Editor.EVENT_VALID,
+ action() {
+ self.fireEvent(NumberIntervalSingleEidtor.EVENT_VALID, arguments);
+ },
+ },
+ {
+ eventName: Editor.EVENT_CHANGE,
+ action() {
+ self.fireEvent(NumberIntervalSingleEidtor.EVENT_CHANGE, arguments);
+ },
+ },
+ {
+ eventName: Editor.EVENT_CONFIRM,
+ action() {
+ self.fireEvent(NumberIntervalSingleEidtor.EVENT_CONFIRM, arguments);
+ },
+ },
+ {
+ eventName: Editor.EVENT_CHANGE_CONFIRM,
+ action() {
+ self.fireEvent(NumberIntervalSingleEidtor.EVENT_CHANGE_CONFIRM, arguments);
+ },
+ }
+ ],
+ }
+ ],
};
}
diff --git a/src/widget/searchmultitextvaluecombo/index.js b/src/widget/searchmultitextvaluecombo/index.js
new file mode 100644
index 000000000..24e5e4312
--- /dev/null
+++ b/src/widget/searchmultitextvaluecombo/index.js
@@ -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";
diff --git a/src/widget/searchmultitextvaluecombo/multitextvalue.combo.search.js b/src/widget/searchmultitextvaluecombo/multitextvalue.combo.search.js
index 4fdbf42ee..e830aa352 100644
--- a/src/widget/searchmultitextvaluecombo/multitextvalue.combo.search.js
+++ b/src/widget/searchmultitextvaluecombo/multitextvalue.combo.search.js
@@ -1,29 +1,77 @@
-/**
- *
- * @class BI.SearchMultiTextValueCombo
- * @extends BI.Single
- */
-BI.SearchMultiTextValueCombo = BI.inherit(BI.Single, {
-
- _defaultConfig: function () {
- return BI.extend(BI.SearchMultiTextValueCombo.superclass._defaultConfig.apply(this, arguments), {
+import {
+ shortcut,
+ extend,
+ isKey,
+ Selection,
+ remove,
+ pushDistinct,
+ deepClone,
+ createWidget,
+ toPix,
+ isNotNull,
+ last,
+ initial,
+ endWith,
+ bind,
+ nextTick,
+ AbsoluteLayout,
+ contains,
+ map,
+ makeObject,
+ each,
+ values,
+ isNull,
+ Func,
+ filter,
+ isNotEmptyArray,
+ isArray,
+ find,
+ BlankSplitChar
+} from "@/core";
+import { Single, Combo } from "@/base";
+import { MultiSelectBar, TriggerIconButton } from "@/case";
+import { MultiSelectTrigger } from "@/widget/multiselect/multiselect.trigger";
+import { MultiSelectPopupView } from "@/widget/multiselect/multiselect.popup.view";
+import { MultiSelectCombo } from "@/widget/multiselect/multiselect.combo";
+import { SearchMultiSelectTrigger } from "@/widget/searchmultitextvaluecombo/multitextvalue.combo.trigger.search";
+import { SearchMultiSelectPopupView } from "@/widget/searchmultitextvaluecombo/multitextvalue.popup.view.search";
+
+@shortcut()
+export class SearchMultiTextValueCombo extends Single {
+ static xtype = "bi.search_multi_text_value_combo";
+
+ static REQ_GET_DATA_LENGTH = 1;
+ static REQ_GET_ALL_DATA = -1;
+ static EVENT_CONFIRM = "EVENT_CONFIRM";
+
+ _defaultConfig() {
+ return extend(super._defaultConfig(...arguments), {
baseCls: "bi-multi-select-combo bi-search-multi-text-value-combo",
height: 24,
- items: []
+ items: [],
});
- },
-
- _init: function () {
- var self = this, o = this.options;
- BI.SearchMultiTextValueCombo.superclass._init.apply(this, arguments);
- var assertShowValue = function () {
- BI.isKey(self._startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, self._startValue) : BI.pushDistinct(self.storeValue.value, self._startValue));
- self._updateAllValue();
- self._checkError();
- self.trigger.getSearcher().setState(self.storeValue);
- self.trigger.getCounter().setButtonChecked(self.storeValue);
+ }
+
+ _init() {
+ const o = this.options;
+ const triggerBtn = createWidget({
+ type: TriggerIconButton.xtype,
+ width: o.height,
+ height: o.height,
+ cls: "multi-select-trigger-icon-button",
+ });
+ super._init(...arguments);
+ const assertShowValue = () => {
+ isKey(this._startValue) &&
+ (this.storeValue.type === Selection.All
+ ? remove(this.storeValue.value, this._startValue)
+ : pushDistinct(this.storeValue.value, this._startValue));
+ this._updateAllValue();
+ this._checkError();
+ this.trigger.getSearcher().setState(this.storeValue);
+ this.trigger.getCounter().setButtonChecked(this.storeValue);
};
- this.storeValue = BI.deepClone(o.value || {});
+ this.storeValue = deepClone(o.value || {});
this._updateAllValue();
this._assertValue(this.storeValue);
@@ -32,10 +80,10 @@ BI.SearchMultiTextValueCombo = BI.inherit(BI.Single, {
// 标记正在请求数据
this.requesting = false;
- this.trigger = BI.createWidget({
- type: "bi.search_multi_select_trigger",
+ this.trigger = createWidget({
+ type: SearchMultiSelectTrigger.xtype,
text: o.text,
- height: BI.toPix(o.height, o.simple ? 1 : 2),
+ height: toPix(o.height, o.simple ? 1 : 2),
// adapter: this.popup,
masker: {
offset: {
@@ -45,437 +93,431 @@ BI.SearchMultiTextValueCombo = BI.inherit(BI.Single, {
bottom: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT + 1,
},
},
- allValueGetter: function () {
- return self.allValue;
- },
+ allValueGetter: () => this.allValue,
valueFormatter: o.valueFormatter,
- itemsCreator: function (op, callback) {
- self._itemsCreator(op, function (res) {
- if (op.times === 1 && BI.isNotNull(op.keywords)) {
+ itemsCreator: (op, callback) => {
+ this._itemsCreator(op, (res, ...args) => {
+ if (op.times === 1 && isNotNull(op.keywords)) {
// 预防trigger内部把当前的storeValue改掉
- self.trigger.setValue(BI.deepClone(self.getValue()));
+ this.trigger.setValue(deepClone(this.getValue()));
}
- callback.apply(self, arguments);
+
+ callback.apply(this, [res, ...args]);
});
},
value: this.storeValue,
- warningTitle: o.warningTitle
+ warningTitle: o.warningTitle,
});
- this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () {
- self._setStartValue("");
- this.getSearcher().setValue(self.storeValue);
+ this.trigger.on(MultiSelectTrigger.EVENT_START, () => {
+ this._setStartValue("");
+ this.trigger.getSearcher().setValue(this.storeValue);
});
- this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () {
- self._setStartValue("");
+ this.trigger.on(MultiSelectTrigger.EVENT_STOP, () => {
+ this._setStartValue("");
});
- this.trigger.on(BI.MultiSelectTrigger.EVENT_SEARCHING, function (keywords) {
- var last = BI.last(keywords);
- keywords = BI.initial(keywords || []);
+ this.trigger.on(MultiSelectTrigger.EVENT_SEARCHING, keywords => {
+ const _last = last(keywords);
+ keywords = initial(keywords || []);
if (keywords.length > 0) {
- self._joinKeywords(keywords, function () {
- if (BI.endWith(last, BI.BlankSplitChar)) {
- self.combo.setValue(self.storeValue);
+ this._joinKeywords(keywords, () => {
+ if (endWith(_last, BlankSplitChar)) {
+ this.combo.setValue(this.storeValue);
assertShowValue();
- self.combo.populate();
- self._setStartValue("");
+ this.combo.populate();
+ this._setStartValue("");
} else {
- self.combo.setValue(self.storeValue);
+ this.combo.setValue(this.storeValue);
assertShowValue();
}
- self._dataChange = true;
+ this._dataChange = true;
});
}
});
- this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function (value, obj) {
- if (obj instanceof BI.MultiSelectBar) {
- self._joinAll(this.getValue(), function () {
+ this.trigger.on(MultiSelectTrigger.EVENT_CHANGE, (value, obj) => {
+ if (obj instanceof MultiSelectBar) {
+ this._joinAll(this.getValue(), () => {
assertShowValue();
});
} else {
- self._join(this.getValue(), function () {
+ this._join(this.getValue(), () => {
assertShowValue();
});
}
- self._dataChange = true;
+ this._dataChange = true;
});
- this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
- this.getCounter().setValue(self.storeValue);
+ this.trigger.on(MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, () => {
+ this.trigger.getCounter().setValue(this.storeValue);
});
- this.trigger.on(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK, function () {
- if (!self.combo.isViewVisible()) {
- self.combo.showView();
+ this.trigger.on(MultiSelectTrigger.EVENT_COUNTER_CLICK, () => {
+ if (!this.combo.isViewVisible()) {
+ this.combo.showView();
}
});
- this.combo = BI.createWidget({
- type: "bi.combo",
+ this.combo = createWidget({
+ type: Combo.xtype,
cls: o.simple ? "bi-border-bottom" : "bi-border bi-border-radius",
toggle: false,
container: o.container,
el: this.trigger,
adjustLength: 1,
popup: {
- type: "bi.search_multi_select_popup_view",
- ref: function () {
- self.popup = this;
- self.trigger.setAdapter(this);
+ type: SearchMultiSelectPopupView.xtype,
+ ref: _ref => {
+ this.popup = _ref;
+ this.trigger.setAdapter(_ref);
},
- listeners: [{
- eventName: BI.MultiSelectPopupView.EVENT_CHANGE,
- action: function () {
- self._dataChange = true;
- self.storeValue = this.getValue();
- self._adjust(function () {
- assertShowValue();
- });
- }
- }, {
- eventName: BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM,
- action: function () {
- self._defaultState();
- }
- }, {
- eventName: BI.MultiSelectPopupView.EVENT_CLICK_CLEAR,
- action: function () {
- self._dataChange = true;
- self.setValue();
- self._defaultState();
+ listeners: [
+ {
+ eventName: MultiSelectPopupView.EVENT_CHANGE,
+ action: () => {
+ this._dataChange = true;
+ this.storeValue = this.popup.getValue();
+ this._adjust(() => {
+ assertShowValue();
+ });
+ },
+ },
+ {
+ eventName: MultiSelectPopupView.EVENT_CLICK_CONFIRM,
+ action: () => {
+ this._defaultState();
+ },
+ },
+ {
+ eventName: MultiSelectPopupView.EVENT_CLICK_CLEAR,
+ action: () => {
+ this._dataChange = true;
+ this.setValue();
+ this._defaultState();
+ },
}
- }],
- itemsCreator: BI.bind(self._itemsCreator, this),
+ ],
+ itemsCreator: bind(this._itemsCreator, this),
valueFormatter: o.valueFormatter,
- onLoaded: function () {
- BI.nextTick(function () {
- self.combo.adjustWidth();
- self.combo.adjustHeight();
- self.trigger.getCounter().adjustView();
- self.trigger.getSearcher().adjustView();
+ onLoaded: () => {
+ nextTick(() => {
+ this.combo.adjustWidth();
+ this.combo.adjustHeight();
+ this.trigger.getCounter().adjustView();
+ this.trigger.getSearcher().adjustView();
});
- }
+ },
},
value: o.value,
- hideChecker: function (e) {
- return triggerBtn.element.find(e.target).length === 0;
- }
+ hideChecker: e => triggerBtn.element.find(e.target).length === 0,
});
- this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
- if (!this.isViewVisible()) {
- self._dataChange = false;// 标记数据是否发生变化
+ this.combo.on(Combo.EVENT_BEFORE_POPUPVIEW, () => {
+ if (!this.combo.isViewVisible()) {
+ this._dataChange = false; // 标记数据是否发生变化
}
- this.setValue(self.storeValue);
- BI.nextTick(function () {
- self._populate();
+ this.setValue(this.storeValue);
+ nextTick(() => {
+ this._populate();
});
});
// 当退出的时候如果还在处理请求,则等请求结束后再对外发确定事件
this.wants2Quit = false;
- this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () {
+ this.combo.on(Combo.EVENT_AFTER_HIDEVIEW, () => {
// important:关闭弹出时又可能没有退出编辑状态
- self.trigger.stopEditing();
- if (self.requesting === true) {
- self.wants2Quit = true;
+ this.trigger.stopEditing();
+ if (this.requesting === true) {
+ this.wants2Quit = true;
} else {
/**
* 在存在标红的情况,如果popover没有发生改变就确认需要同步trigger的值,否则对外value值和trigger样式不统一
*/
assertShowValue();
- self._dataChange && self.fireEvent(BI.SearchMultiTextValueCombo.EVENT_CONFIRM);
+ this._dataChange && this.fireEvent(SearchMultiTextValueCombo.EVENT_CONFIRM);
}
});
- var triggerBtn = BI.createWidget({
- type: "bi.trigger_icon_button",
- width: o.height,
- height: o.height,
- cls: "multi-select-trigger-icon-button"
- });
- triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () {
- self.trigger.getCounter().hideView();
- if (self.combo.isViewVisible()) {
- self.combo.hideView();
+ triggerBtn.on(TriggerIconButton.EVENT_CHANGE, () => {
+ this.trigger.getCounter().hideView();
+ if (this.combo.isViewVisible()) {
+ this.combo.hideView();
} else {
- self.combo.showView();
+ this.combo.showView();
}
});
- BI.createWidget({
- type: "bi.absolute",
+ createWidget({
+ type: AbsoluteLayout.xtype,
element: this,
- items: [{
- el: this.combo,
- left: 0,
- right: 0,
- top: 0,
- bottom: 0
- }, {
- el: triggerBtn,
- right: 0,
- top: 0,
- bottom: 0
- }]
+ items: [
+ {
+ el: this.combo,
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0,
+ },
+ {
+ el: triggerBtn,
+ right: 0,
+ top: 0,
+ bottom: 0,
+ }
+ ],
});
this._checkError();
- },
+ }
- _defaultState: function () {
+ _defaultState() {
this.trigger.stopEditing();
this.combo.hideView();
- },
+ }
- _assertValue: function (val) {
- var o = this.options;
+ _assertValue(val) {
+ const o = this.options;
val || (val = {});
- val.type || (val.type = BI.Selection.Multi);
+ val.type || (val.type = Selection.Multi);
val.value || (val.value = []);
- BI.remove(val.value, function (idx, value) {
- return !BI.contains(BI.map(o.items, "value"), value);
- });
- },
-
- _makeMap: function (values) {
- return BI.makeObject(values || []);
- },
+ remove(val.value, (idx, value) => !contains(map(o.items, "value"), value));
+ }
- _joinKeywords: function (keywords, callback) {
- var self = this, o = this.options;
- this._assertValue(this.storeValue);
- this.requesting = true;
- this._itemsCreator({
- type: BI.SearchMultiTextValueCombo.REQ_GET_ALL_DATA,
- keywords: keywords
- }, function (ob) {
- var values = BI.map(ob.items, "value");
- digest(values);
- });
+ _makeMap(values) {
+ return makeObject(values || []);
+ }
- function digest (items) {
- var selectedMap = self._makeMap(items);
- BI.each(keywords, function (i, val) {
- if (BI.isNotNull(selectedMap[val])) {
- self.storeValue.type === BI.Selection.Multi ? BI.pushDistinct(self.storeValue.value, val) : BI.remove(self.storeValue.value, val);
+ _joinKeywords(keywords, callback) {
+ const digest = items => {
+ const selectedMap = this._makeMap(items);
+ each(keywords, (i, val) => {
+ if (isNotNull(selectedMap[val])) {
+ this.storeValue.type === Selection.Multi
+ ? pushDistinct(this.storeValue.value, val)
+ : remove(this.storeValue.value, val);
}
});
- self._adjust(callback);
- }
- },
+ this._adjust(callback);
+ };
- _joinAll: function (res, callback) {
- var self = this, o = this.options;
+ this._assertValue(this.storeValue);
+ this.requesting = true;
+ this._itemsCreator(
+ {
+ type: SearchMultiTextValueCombo.REQ_GET_ALL_DATA,
+ keywords,
+ },
+ ob => {
+ const values = map(ob.items, "value");
+ digest(values);
+ }
+ );
+ }
+
+ _joinAll(res, callback) {
this._assertValue(res);
this.requesting = true;
- this._itemsCreator({
- type: BI.SearchMultiTextValueCombo.REQ_GET_ALL_DATA,
- keywords: [this.trigger.getKey()]
- }, function (ob) {
- var items = BI.map(ob.items, "value");
- if (self.storeValue.type === res.type) {
- var change = false;
- var map = self._makeMap(self.storeValue.value);
- BI.each(items, function (i, v) {
- if (BI.isNotNull(map[v])) {
- change = true;
- self.storeValue.assist && self.storeValue.assist.push(map[v]);
- delete map[v];
+ this._itemsCreator(
+ {
+ type: SearchMultiTextValueCombo.REQ_GET_ALL_DATA,
+ keywords: [this.trigger.getKey()],
+ },
+ ob => {
+ const items = map(ob.items, "value");
+ if (this.storeValue.type === res.type) {
+ let change = false;
+ const _map = this._makeMap(this.storeValue.value);
+ each(items, (i, v) => {
+ if (isNotNull(_map[v])) {
+ change = true;
+ this.storeValue.assist && this.storeValue.assist.push(_map[v]);
+ delete _map[v];
+ }
+ });
+ change && (this.storeValue.value = values(_map));
+ this._adjust(callback);
+
+ return;
+ }
+ const selectedMap = this._makeMap(this.storeValue.value);
+ const notSelectedMap = this._makeMap(res.value);
+ const newItems = [];
+ each(items, (i, item) => {
+ if (isNotNull(selectedMap[items[i]])) {
+ this.storeValue.assist && this.storeValue.assist.push(selectedMap[items[i]]);
+ delete selectedMap[items[i]];
+ }
+ if (isNull(notSelectedMap[items[i]])) {
+ remove(this.storeValue.assist, item);
+ newItems.push(item);
}
});
- change && (self.storeValue.value = BI.values(map));
- self._adjust(callback);
- return;
+ this.storeValue.value = newItems.concat(values(selectedMap));
+ this._adjust(callback);
}
- var selectedMap = self._makeMap(self.storeValue.value);
- var notSelectedMap = self._makeMap(res.value);
- var newItems = [];
- BI.each(items, function (i, item) {
- if (BI.isNotNull(selectedMap[items[i]])) {
- self.storeValue.assist && self.storeValue.assist.push(selectedMap[items[i]]);
- delete selectedMap[items[i]];
- }
- if (BI.isNull(notSelectedMap[items[i]])) {
- BI.remove(self.storeValue.assist, item);
- newItems.push(item);
- }
- });
- self.storeValue.value = newItems.concat(BI.values(selectedMap));
- self._adjust(callback);
- });
- },
-
- _adjust: function (callback) {
- var self = this, o = this.options;
- if (!this._count) {
- this._itemsCreator({
- type: BI.SearchMultiTextValueCombo.REQ_GET_DATA_LENGTH
- }, function (res) {
- self._count = res.count;
- adjust();
- callback();
- });
- } else {
- adjust();
- callback();
-
- }
+ );
+ }
- function adjust () {
- if (self.storeValue.type === BI.Selection.All && self.storeValue.value.length >= self._count) {
- self.storeValue = {
- type: BI.Selection.Multi,
- value: []
+ _adjust(callback) {
+ const adjust = () => {
+ if (this.storeValue.type === Selection.All && this.storeValue.value.length >= this._count) {
+ this.storeValue = {
+ type: Selection.Multi,
+ value: [],
};
- } else if (self.storeValue.type === BI.Selection.Multi && self.storeValue.value.length >= self._count) {
- self.storeValue = {
- type: BI.Selection.All,
- value: []
+ } else if (this.storeValue.type === Selection.Multi && this.storeValue.value.length >= this._count) {
+ this.storeValue = {
+ type: Selection.All,
+ value: [],
};
}
- self._updateAllValue();
- self._checkError();
- if (self.wants2Quit === true) {
- self._dataChange && self.fireEvent(BI.SearchMultiTextValueCombo.EVENT_CONFIRM);
- self.wants2Quit = false;
+ this._updateAllValue();
+ this._checkError();
+ if (this.wants2Quit === true) {
+ this._dataChange && this.fireEvent(SearchMultiTextValueCombo.EVENT_CONFIRM);
+ this.wants2Quit = false;
}
- self.requesting = false;
+ this.requesting = false;
+ };
+ if (!this._count) {
+ this._itemsCreator(
+ {
+ type: SearchMultiTextValueCombo.REQ_GET_DATA_LENGTH,
+ },
+ res => {
+ this._count = res.count;
+ adjust();
+ callback();
+ }
+ );
+ } else {
+ adjust();
+ callback();
}
- },
+ }
- _join: function (res, callback) {
- var self = this, o = this.options;
+ _join(res, callback) {
this._assertValue(res);
this._assertValue(this.storeValue);
if (this.storeValue.type === res.type) {
- var map = this._makeMap(this.storeValue.value);
- BI.each(res.value, function (i, v) {
+ const map = this._makeMap(this.storeValue.value);
+ each(res.value, (i, v) => {
if (!map[v]) {
- self.storeValue.value.push(v);
- BI.remove(self.storeValue.assist, v);
+ this.storeValue.value.push(v);
+ remove(this.storeValue.assist, v);
map[v] = v;
}
});
- var change = false;
- BI.each(res.assist, function (i, v) {
- if (BI.isNotNull(map[v])) {
+ let change = false;
+ each(res.assist, (i, v) => {
+ if (isNotNull(map[v])) {
change = true;
- self.storeValue.assist && self.storeValue.assist.push(map[v]);
+ this.storeValue.assist && this.storeValue.assist.push(map[v]);
delete map[v];
}
});
- change && (this.storeValue.value = BI.values(map));
- self._adjust(callback);
+ change && (this.storeValue.value = values(map));
+ this._adjust(callback);
+
return;
}
this._joinAll(res, callback);
- },
+ }
- _setStartValue: function (value) {
+ _setStartValue(value) {
this._startValue = value;
this.popup.setStartValue(value);
- },
+ }
- _getItemsByTimes: function (items, times) {
- var res = [];
- for (var i = (times - 1) * 100; items[i] && i < times * 100; i++) {
+ _getItemsByTimes(items, times) {
+ const res = [];
+ for (let i = (times - 1) * 100; items[i] && i < times * 100; i++) {
res.push(items[i]);
}
+
return res;
- },
+ }
- _hasNextByTimes: function (items, times) {
+ _hasNextByTimes(items, times) {
return times * 100 < items.length;
- },
+ }
- _itemsCreator: function (options, callback) {
- var self = this, o = this.options;
- var items = o.items;
- var keywords = (options.keywords || []).slice();
+ _itemsCreator(options, callback) {
+ const o = this.options;
+ let items = o.items;
+ const keywords = (options.keywords || []).slice();
if (options.keyword) {
keywords.push(options.keyword);
}
- BI.each(keywords, function (i, kw) {
- var search = BI.Func.getSearchResult(items, kw);
+ each(keywords, (i, kw) => {
+ const search = Func.getSearchResult(items, kw);
items = search.match.concat(search.find);
});
- if (options.selectedValues) {// 过滤
- var filter = BI.makeObject(options.selectedValues, true);
- items = BI.filter(items, function (i, ob) {
- return !filter[ob.value];
- });
+ if (options.selectedValues) {
+ // 过滤
+ const _filter = makeObject(options.selectedValues, true);
+ items = filter(items, (i, ob) => !_filter[ob.value]);
}
- if (options.type == BI.MultiSelectCombo.REQ_GET_ALL_DATA) {
+ if (options.type == MultiSelectCombo.REQ_GET_ALL_DATA) {
callback({
- items: items
+ items,
});
+
return;
}
- if (options.type == BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) {
- callback({count: items.length});
+ if (options.type == MultiSelectCombo.REQ_GET_DATA_LENGTH) {
+ callback({ count: items.length });
+
return;
}
callback({
- items: self._getItemsByTimes(items, options.times),
- hasNext: self._hasNextByTimes(items, options.times)
+ items: this._getItemsByTimes(items, options.times),
+ hasNext: this._hasNextByTimes(items, options.times),
});
- },
-
- _checkError: function () {
- var v = this.storeValue.value || [];
- if(BI.isNotEmptyArray(v)) {
- v = BI.isArray(v) ? v : [v];
- var result = BI.find(this.allValue, function (idx, value) {
- return !BI.contains(v, value);
- });
- if (BI.isNull(result)) {
- BI.isNotNull(this.trigger) && (this.trigger.setTipType("success"));
+ }
+
+ _checkError() {
+ let v = this.storeValue.value || [];
+ if (isNotEmptyArray(v)) {
+ v = isArray(v) ? v : [v];
+ const result = find(this.allValue, (idx, value) => !contains(v, value));
+ if (isNull(result)) {
+ isNotNull(this.trigger) && this.trigger.setTipType("success");
this.element.removeClass("combo-error");
} else {
- BI.isNotNull(this.trigger) && (this.trigger.setTipType("warning"));
+ isNotNull(this.trigger) && this.trigger.setTipType("warning");
this.element.addClass("combo-error");
}
} else {
- if(v.length === this.allValue.length){
- BI.isNotNull(this.trigger) && (this.trigger.setTipType("success"));
+ if (v.length === this.allValue.length) {
+ isNotNull(this.trigger) && this.trigger.setTipType("success");
this.element.removeClass("combo-error");
- }else {
- BI.isNotNull(this.trigger) && (this.trigger.setTipType("warning"));
+ } else {
+ isNotNull(this.trigger) && this.trigger.setTipType("warning");
this.element.addClass("combo-error");
}
}
- },
+ }
- _updateAllValue: function () {
+ _updateAllValue() {
this.storeValue = this.storeValue || {};
- this.allValue = BI.deepClone(this.storeValue.value || []);
- },
+ this.allValue = deepClone(this.storeValue.value || []);
+ }
- setValue: function (v) {
- this.storeValue = BI.deepClone(v || {});
+ setValue(v) {
+ this.storeValue = deepClone(v || {});
this._updateAllValue();
this._assertValue(this.storeValue);
this.combo.setValue(this.storeValue);
this._checkError();
- },
+ }
- getValue: function () {
- return BI.deepClone(this.storeValue);
- },
+ getValue() {
+ return deepClone(this.storeValue);
+ }
- _populate: function () {
+ _populate() {
this._count = null;
this.combo.populate();
- },
+ }
- populate: function (items) {
+ populate(items) {
this.options.items = items;
this._populate();
}
-});
-
-BI.extend(BI.SearchMultiTextValueCombo, {
- REQ_GET_DATA_LENGTH: 1,
- REQ_GET_ALL_DATA: -1
-});
-
-BI.SearchMultiTextValueCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
-
-BI.shortcut("bi.search_multi_text_value_combo", BI.SearchMultiTextValueCombo);
+}
diff --git a/src/widget/searchmultitextvaluecombo/multitextvalue.combo.trigger.search.js b/src/widget/searchmultitextvaluecombo/multitextvalue.combo.trigger.search.js
index 3256994ae..1005412b7 100644
--- a/src/widget/searchmultitextvaluecombo/multitextvalue.combo.trigger.search.js
+++ b/src/widget/searchmultitextvaluecombo/multitextvalue.combo.trigger.search.js
@@ -1,31 +1,53 @@
-BI.SearchMultiSelectTrigger = BI.inherit(BI.Trigger, {
-
- constants: {
- height: 14,
- rgap: 4,
- lgap: 4
- },
-
- _defaultConfig: function () {
- return BI.extend(BI.SearchMultiSelectTrigger.superclass._defaultConfig.apply(this, arguments), {
+import {
+ shortcut,
+ extend,
+ emptyFn,
+ createWidget,
+ Events,
+ nextTick,
+ HTapeLayout,
+ RightVerticalAdaptLayout
+} from "@/core";
+import { Trigger } from "@/base";
+import { MultiSelectCheckSelectedSwitcher } from "@/widget/multiselect/trigger/switcher.checkselected";
+import { MultiSelectSearcher } from "@/widget/multiselect/trigger/searcher.multiselect";
+import { SearchMultiSelectSearcher } from "@/widget/searchmultitextvaluecombo/trigger/searcher.multitextvalue";
+
+@shortcut()
+export class SearchMultiSelectTrigger extends Trigger {
+ static xtype = "bi.search_multi_select_trigger";
+
+ constants = { height: 14, rgap: 4, lgap: 4 };
+
+ static EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK";
+ static EVENT_COUNTER_CLICK = "EVENT_COUNTER_CLICK";
+ 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";
+ static EVENT_BEFORE_COUNTER_POPUPVIEW = "EVENT_BEFORE_COUNTER_POPUPVIEW";
+
+ _defaultConfig() {
+ return extend(super._defaultConfig(...arguments), {
baseCls: "bi-multi-select-trigger",
- itemsCreator: BI.emptyFn,
- valueFormatter: BI.emptyFn,
+ itemsCreator: emptyFn,
+ valueFormatter: emptyFn,
searcher: {},
switcher: {},
adapter: null,
- masker: {}
+ masker: {},
});
- },
+ }
- _init: function () {
- BI.SearchMultiSelectTrigger.superclass._init.apply(this, arguments);
+ _init() {
+ super._init(...arguments);
- var self = this, o = this.options;
+ const o = this.options;
- this.searcher = BI.createWidget(o.searcher, {
- type: "bi.search_multi_select_searcher",
+ this.searcher = createWidget(o.searcher, {
+ type: SearchMultiSelectSearcher.xtype,
height: o.height,
itemsCreator: o.itemsCreator,
valueFormatter: o.valueFormatter,
@@ -36,119 +58,114 @@ BI.SearchMultiSelectTrigger = BI.inherit(BI.Trigger, {
value: o.value,
text: o.text,
tipType: o.tipType,
- warningTitle: o.warningTitle
+ warningTitle: o.warningTitle,
});
- this.searcher.on(BI.MultiSelectSearcher.EVENT_START, function () {
- self.fireEvent(BI.SearchMultiSelectTrigger.EVENT_START);
+ this.searcher.on(MultiSelectSearcher.EVENT_START, () => {
+ this.fireEvent(SearchMultiSelectTrigger.EVENT_START);
});
- this.searcher.on(BI.MultiSelectSearcher.EVENT_PAUSE, function () {
- self.fireEvent(BI.SearchMultiSelectTrigger.EVENT_PAUSE);
+ this.searcher.on(MultiSelectSearcher.EVENT_PAUSE, () => {
+ this.fireEvent(SearchMultiSelectTrigger.EVENT_PAUSE);
});
- this.searcher.on(BI.MultiSelectSearcher.EVENT_SEARCHING, function () {
- self.fireEvent(BI.SearchMultiSelectTrigger.EVENT_SEARCHING, arguments);
+ this.searcher.on(MultiSelectSearcher.EVENT_SEARCHING, (...args) => {
+ this.fireEvent(SearchMultiSelectTrigger.EVENT_SEARCHING, ...args);
});
- this.searcher.on(BI.MultiSelectSearcher.EVENT_STOP, function () {
- self.fireEvent(BI.SearchMultiSelectTrigger.EVENT_STOP);
+ this.searcher.on(MultiSelectSearcher.EVENT_STOP, () => {
+ this.fireEvent(SearchMultiSelectTrigger.EVENT_STOP);
});
- this.searcher.on(BI.MultiSelectSearcher.EVENT_CHANGE, function () {
- self.fireEvent(BI.SearchMultiSelectTrigger.EVENT_CHANGE, arguments);
+ this.searcher.on(MultiSelectSearcher.EVENT_CHANGE, (...args) => {
+ this.fireEvent(SearchMultiSelectTrigger.EVENT_CHANGE, ...args);
});
- this.numberCounter = BI.createWidget(o.switcher, {
- type: "bi.multi_select_check_selected_switcher",
+ this.numberCounter = createWidget(o.switcher, {
+ type: MultiSelectCheckSelectedSwitcher.xtype,
valueFormatter: o.valueFormatter,
itemsCreator: o.itemsCreator,
adapter: o.adapter,
masker: o.masker,
- value: o.value
+ value: o.value,
});
- this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, function () {
- self.fireEvent(BI.SearchMultiSelectTrigger.EVENT_COUNTER_CLICK);
+ this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, () => {
+ this.fireEvent(SearchMultiSelectTrigger.EVENT_COUNTER_CLICK);
});
- this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, function () {
- self.fireEvent(BI.SearchMultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW);
+ this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, () => {
+ this.fireEvent(SearchMultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW);
});
- var wrapNumberCounter = BI.createWidget({
- type: "bi.right_vertical_adapt",
+ const wrapNumberCounter = createWidget({
+ type: RightVerticalAdaptLayout.xtype,
hgap: 4,
- items: [{
- el: this.numberCounter
- }]
+ items: [
+ {
+ el: this.numberCounter,
+ }
+ ],
});
- var wrapper = BI.createWidget({
- type: "bi.htape",
+ const wrapper = createWidget({
+ type: HTapeLayout.xtype,
element: this,
items: [
{
el: this.searcher,
- width: "fill"
- }, {
+ width: "fill",
+ },
+ {
el: wrapNumberCounter,
- width: 0
- }, {
- el: BI.createWidget(),
- width: 24
- }]
+ width: 0,
+ },
+ {
+ el: createWidget(),
+ width: 24,
+ }
+ ],
});
- this.numberCounter.on(BI.Events.VIEW, function (b) {
- BI.nextTick(function () {// 自动调整宽度
- wrapper.attr("items")[1].width = (b === true ? self.numberCounter.element.outerWidth() + 8 : 0);
+ this.numberCounter.on(Events.VIEW, b => {
+ nextTick(() => {
+ // 自动调整宽度
+ wrapper.attr("items")[1].width = b === true ? this.numberCounter.element.outerWidth() + 8 : 0;
wrapper.resize();
});
});
- this.element.click(function (e) {
- if (self.element.find(e.target).length > 0) {
- self.numberCounter.hideView();
+ this.element.click(e => {
+ if (this.element.find(e.target).length > 0) {
+ this.numberCounter.hideView();
}
});
- },
+ }
- getCounter: function () {
+ getCounter() {
return this.numberCounter;
- },
+ }
- getSearcher: function () {
+ getSearcher() {
return this.searcher;
- },
+ }
- stopEditing: function () {
+ stopEditing() {
this.searcher.stopSearch();
this.numberCounter.hideView();
- },
+ }
- setAdapter: function (adapter) {
+ setAdapter(adapter) {
this.searcher.setAdapter(adapter);
this.numberCounter.setAdapter(adapter);
- },
+ }
- setValue: function (ob) {
+ setValue(ob) {
this.searcher.setValue(ob);
this.numberCounter.setValue(ob);
- },
+ }
- setTipType: function (v) {
+ setTipType(v) {
this.searcher.setTipType(v);
- },
+ }
- getKey: function () {
+ getKey() {
return this.searcher.getKey();
- },
+ }
- getValue: function () {
+ getValue() {
return this.searcher.getValue();
}
-});
-
-BI.SearchMultiSelectTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK";
-BI.SearchMultiSelectTrigger.EVENT_COUNTER_CLICK = "EVENT_COUNTER_CLICK";
-BI.SearchMultiSelectTrigger.EVENT_CHANGE = "EVENT_CHANGE";
-BI.SearchMultiSelectTrigger.EVENT_START = "EVENT_START";
-BI.SearchMultiSelectTrigger.EVENT_STOP = "EVENT_STOP";
-BI.SearchMultiSelectTrigger.EVENT_PAUSE = "EVENT_PAUSE";
-BI.SearchMultiSelectTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
-BI.SearchMultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW = "EVENT_BEFORE_COUNTER_POPUPVIEW";
-
-BI.shortcut("bi.search_multi_select_trigger", BI.SearchMultiSelectTrigger);
+}
diff --git a/src/widget/searchmultitextvaluecombo/multitextvalue.loader.search.js b/src/widget/searchmultitextvaluecombo/multitextvalue.loader.search.js
index 59113111e..cc8b80a85 100644
--- a/src/widget/searchmultitextvaluecombo/multitextvalue.loader.search.js
+++ b/src/widget/searchmultitextvaluecombo/multitextvalue.loader.search.js
@@ -1,184 +1,208 @@
-/**
- * 多选加载数据面板
- * Created by guy on 15/11/2.
- * @class BI.SearchMultiSelectLoader
- * @extends Widget
- */
-BI.SearchMultiSelectLoader = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.SearchMultiSelectLoader.superclass._defaultConfig.apply(this, arguments), {
+import {
+ shortcut,
+ Widget,
+ extend,
+ emptyFn,
+ createWidget,
+ isKey,
+ Selection,
+ map,
+ contains,
+ remove,
+ pushDistinct,
+ Controller,
+ VerticalLayout,
+ createItems,
+ delay,
+ isNotNull
+} from "@/core";
+import { ButtonGroup, Loader } from "@/base";
+import { SelectList, MultiSelectBar, MultiSelectItem } from "@/case";
+
+@shortcut()
+export class SearchMultiSelectLoader extends Widget {
+ static xtype = "bi.search_multi_select_loader";
+
+ static EVENT_CHANGE = "EVENT_CHANGE";
+
+ _defaultConfig() {
+ return extend(super._defaultConfig(...arguments), {
baseCls: "bi-multi-select-loader",
logic: {
- dynamic: true
+ dynamic: true,
},
el: {
- height: 400
+ height: 400,
},
- valueFormatter: BI.emptyFn,
- itemsCreator: BI.emptyFn,
+ valueFormatter: emptyFn,
+ itemsCreator: emptyFn,
itemHeight: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
- onLoaded: BI.emptyFn
+ onLoaded: emptyFn,
});
- },
+ }
- _init: function () {
- BI.SearchMultiSelectLoader.superclass._init.apply(this, arguments);
+ _init() {
+ super._init(...arguments);
- var self = this, opts = this.options;
- var hasNext = false;
+ const opts = this.options;
+ let hasNext = false;
this.storeValue = opts.value || {};
this._assertValue(this.storeValue);
- this.button_group = BI.createWidget({
- type: "bi.select_list",
+ this.button_group = createWidget({
+ type: SelectList.xtype,
element: this,
logic: opts.logic,
toolbar: {
- type: "bi.multi_select_bar",
+ type: MultiSelectBar.xtype,
cls: "bi-list-item-active",
height: this.options.itemHeight,
- iconWrapperWidth: 36
+ iconWrapperWidth: 36,
},
- el: BI.extend({
- onLoaded: opts.onLoaded,
- el: {
- type: "bi.loader",
- isDefaultInit: false,
- logic: {
- dynamic: true,
- scrolly: true
- },
+ el: extend(
+ {
+ onLoaded: opts.onLoaded,
el: {
- chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
- behaviors: {
- redmark: function () {
- return true;
- }
+ type: Loader.xtype,
+ isDefaultInit: false,
+ logic: {
+ dynamic: true,
+ scrolly: true,
},
- layouts: [{
- type: "bi.vertical"
- }]
- }
- }
- }, opts.el),
- itemsCreator: function (op, callback) {
- var startValue = self._startValue;
- 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) {
+ el: {
+ chooseType: ButtonGroup.CHOOSE_TYPE_MULTI,
+ behaviors: {
+ redmark: () => true,
+ },
+ layouts: [
+ {
+ type: VerticalLayout.xtype,
+ }
+ ],
+ },
+ },
+ },
+ 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;
- var firstItems = [];
- if (op.times === 1 && self.storeValue) {
- var json = BI.map(self.storeValue.value, function (i, v) {
- var txt = opts.valueFormatter(v) || v;
+ let firstItems = [];
+ if (op.times === 1 && this.storeValue) {
+ const json = map(this.storeValue.value, (i, v) => {
+ const txt = opts.valueFormatter(v) || v;
+
return {
text: txt,
value: v,
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)) {
- var txt = opts.valueFormatter(startValue) || startValue;
+ if (isKey(this._startValue) && !contains(this.storeValue.value, this._startValue)) {
+ const txt = opts.valueFormatter(startValue) || startValue;
json.unshift({
text: txt,
value: startValue,
title: txt,
- selected: true
+ selected: true,
});
}
- firstItems = self._createItems(json);
+ firstItems = this._createItems(json);
}
- callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || "");
- if (op.times === 1 && self.storeValue) {
- BI.isKey(startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, startValue) : BI.pushDistinct(self.storeValue.value, startValue));
- self.setValue(self.storeValue);
+
+ callback(firstItems.concat(this._createItems(ob.items)), ob.keyword || "");
+ 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 () {
- return hasNext;
- },
- value: this.storeValue
+ hasNext: () => hasNext,
+ value: this.storeValue,
});
- this.button_group.on(BI.Controller.EVENT_CHANGE, function () {
- self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ this.button_group.on(Controller.EVENT_CHANGE, (...args) => {
+ this.fireEvent(Controller.EVENT_CHANGE, ...args);
});
- this.button_group.on(BI.SelectList.EVENT_CHANGE, function () {
- self.fireEvent(BI.SearchMultiSelectLoader.EVENT_CHANGE, arguments);
+ this.button_group.on(SelectList.EVENT_CHANGE, (...args) => {
+ this.fireEvent(SearchMultiSelectLoader.EVENT_CHANGE, ...args);
});
- },
+ }
- _createItems: function (items) {
- return BI.createItems(items, {
- type: "bi.multi_select_item",
+ _createItems(items) {
+ return createItems(items, {
+ type: MultiSelectItem.xtype,
logic: this.options.logic,
cls: "bi-list-item-active",
height: this.options.itemHeight,
selected: this.isAllSelected(),
- iconWrapperWidth: 36
+ iconWrapperWidth: 36,
});
- },
+ }
- _scrollToTop: function () {
- var self = this;
- BI.delay(function () {
- self.button_group.element.scrollTop(0);
+ _scrollToTop() {
+ delay(() => {
+ this.button_group.element.scrollTop(0);
}, 30);
- },
+ }
- isAllSelected: function () {
+ isAllSelected() {
return this.button_group.isAllSelected();
- },
+ }
- _assertValue: function (val) {
+ _assertValue(val) {
val || (val = {});
- val.type || (val.type = BI.Selection.Multi);
+ val.type || (val.type = Selection.Multi);
val.value || (val.value = []);
- },
+ }
- setStartValue: function (v) {
+ setStartValue(v) {
this._startValue = v;
- },
+ }
- setValue: function (v) {
+ setValue(v) {
this.storeValue = v || {};
this._assertValue(this.storeValue);
this.button_group.setValue(this.storeValue);
- },
+ }
- getValue: function () {
+ getValue() {
return this.button_group.getValue();
- },
+ }
- getAllButtons: function () {
+ getAllButtons() {
return this.button_group.getAllButtons();
- },
+ }
- empty: function () {
+ empty() {
this.button_group.empty();
- },
+ }
- populate: function (items) {
- if (BI.isNotNull(items)) {
+ populate(items) {
+ if (isNotNull(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);
- },
+ }
- resetWidth: function (w) {
+ resetWidth(w) {
this.button_group.resetWidth(w);
}
-});
-
-BI.SearchMultiSelectLoader.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.search_multi_select_loader", BI.SearchMultiSelectLoader);
\ No newline at end of file
+}
diff --git a/src/widget/searchmultitextvaluecombo/multitextvalue.popup.view.search.js b/src/widget/searchmultitextvaluecombo/multitextvalue.popup.view.search.js
index cb8027f0c..9d6577f70 100644
--- a/src/widget/searchmultitextvaluecombo/multitextvalue.popup.view.search.js
+++ b/src/widget/searchmultitextvaluecombo/multitextvalue.popup.view.search.js
@@ -1,92 +1,98 @@
-BI.SearchMultiSelectPopupView = BI.inherit(BI.Widget, {
+import { shortcut, Widget, extend, emptyFn, createWidget, i18nText } from "@/core";
+import { MultiPopupView } from "@/case";
+import { SearchMultiSelectLoader } from "@/widget/searchmultitextvaluecombo/multitextvalue.loader.search";
- _defaultConfig: function () {
- return BI.extend(BI.SearchMultiSelectPopupView.superclass._defaultConfig.apply(this, arguments), {
+@shortcut()
+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",
maxWidth: "auto",
minWidth: 135,
maxHeight: 400,
- valueFormatter: BI.emptyFn,
- itemsCreator: BI.emptyFn,
- onLoaded: BI.emptyFn
+ valueFormatter: emptyFn,
+ itemsCreator: emptyFn,
+ onLoaded: emptyFn,
});
- },
+ }
- _init: function () {
- BI.SearchMultiSelectPopupView.superclass._init.apply(this, arguments);
- var self = this, opts = this.options;
+ _init() {
+ super._init(...arguments);
+ const opts = this.options;
- this.loader = BI.createWidget({
- type: "bi.search_multi_select_loader",
+ this.loader = createWidget({
+ type: SearchMultiSelectLoader.xtype,
itemsCreator: opts.itemsCreator,
valueFormatter: opts.valueFormatter,
onLoaded: opts.onLoaded,
- value: opts.value
+ value: opts.value,
});
- this.popupView = BI.createWidget({
- type: "bi.multi_popup_view",
+ this.popupView = createWidget({
+ type: MultiPopupView.xtype,
stopPropagation: false,
maxWidth: opts.maxWidth,
minWidth: opts.minWidth,
maxHeight: opts.maxHeight,
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,
- value: opts.value
+ value: opts.value,
});
- this.popupView.on(BI.MultiPopupView.EVENT_CHANGE, function () {
- self.fireEvent(BI.SearchMultiSelectPopupView.EVENT_CHANGE);
+ this.popupView.on(MultiPopupView.EVENT_CHANGE, () => {
+ this.fireEvent(SearchMultiSelectPopupView.EVENT_CHANGE);
});
- this.popupView.on(BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, function (index) {
+
+ this.popupView.on(MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, index => {
switch (index) {
- case 0:
- self.fireEvent(BI.SearchMultiSelectPopupView.EVENT_CLICK_CLEAR);
- break;
- case 1:
- self.fireEvent(BI.SearchMultiSelectPopupView.EVENT_CLICK_CONFIRM);
- break;
+ case 0:
+ this.fireEvent(SearchMultiSelectPopupView.EVENT_CLICK_CLEAR);
+ break;
+ case 1:
+ this.fireEvent(SearchMultiSelectPopupView.EVENT_CLICK_CONFIRM);
+ break;
+ default:
+ break;
}
});
- },
+ }
- isAllSelected: function () {
+ isAllSelected() {
return this.loader.isAllSelected();
- },
+ }
- setStartValue: function (v) {
+ setStartValue(v) {
this.loader.setStartValue(v);
- },
+ }
- setValue: function (v) {
+ setValue(v) {
this.popupView.setValue(v);
- },
+ }
- getValue: function () {
+ getValue() {
return this.popupView.getValue();
- },
+ }
- populate: function (items) {
- this.popupView.populate.apply(this.popupView, arguments);
- },
+ populate(items) {
+ this.popupView.populate(...arguments);
+ }
- resetHeight: function (h) {
+ resetHeight(h) {
this.popupView.resetHeight(h);
- },
+ }
- resetWidth: function (w) {
+ resetWidth(w) {
this.popupView.resetWidth(w);
- },
+ }
- setDirection: function (direction, position) {
+ 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);
+ }
+}
diff --git a/src/widget/searchmultitextvaluecombo/trigger/searcher.multitextvalue.js b/src/widget/searchmultitextvaluecombo/trigger/searcher.multitextvalue.js
index 506532b3c..ff78e3646 100644
--- a/src/widget/searchmultitextvaluecombo/trigger/searcher.multitextvalue.js
+++ b/src/widget/searchmultitextvaluecombo/trigger/searcher.multitextvalue.js
@@ -1,175 +1,180 @@
-BI.SearchMultiSelectSearcher = BI.inherit(BI.Widget, {
-
- _defaultConfig: function () {
- return BI.extend(BI.SearchMultiSelectSearcher.superclass._defaultConfig.apply(this, arguments), {
+import { shortcut, Widget, extend, emptyFn, createWidget, isNotNull, Selection, size, each } from "@/core";
+import { Searcher } from "@/base";
+import { MultiSelectEditor } from "@/widget/multiselect/trigger/editor.multiselect";
+import { MultiSelectSearchPane } from "@/widget/multiselect/search/multiselect.search.pane";
+
+@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",
- itemsCreator: BI.emptyFn,
+ itemsCreator: emptyFn,
el: {},
popup: {},
- valueFormatter: BI.emptyFn,
+ valueFormatter: emptyFn,
adapter: null,
- masker: {}
+ masker: {},
});
- },
+ }
- _init: function () {
- BI.SearchMultiSelectSearcher.superclass._init.apply(this, arguments);
- var self = this, o = this.options;
- this.editor = BI.createWidget(o.el, {
- type: "bi.multi_select_editor",
+ _init() {
+ super._init(...arguments);
+ const o = this.options;
+ this.editor = createWidget(o.el, {
+ type: MultiSelectEditor.xtype,
height: o.height,
text: o.text,
tipType: o.tipType,
- warningTitle: o.warningTitle
+ warningTitle: o.warningTitle,
});
- this.searcher = BI.createWidget({
- type: "bi.searcher",
+ this.searcher = createWidget({
+ type: Searcher.xtype,
element: this,
height: o.height,
isAutoSearch: false,
isAutoSync: false,
- onSearch: function (op, callback) {
+ onSearch: (op, callback) => {
callback();
},
el: this.editor,
- popup: BI.extend({
- type: "bi.multi_select_search_pane",
- valueFormatter: o.valueFormatter,
- keywordGetter: function () {
- return self.editor.getValue();
- },
- itemsCreator: function (op, callback) {
- var keyword = self.editor.getValue();
- op.keywords = [keyword];
- o.itemsCreator(op, callback);
+ popup: extend(
+ {
+ type: MultiSelectSearchPane.xtype,
+ valueFormatter: o.valueFormatter,
+ keywordGetter: () => this.editor.getValue(),
+ itemsCreator: (op, callback) => {
+ const keyword = this.editor.getValue();
+ op.keywords = [keyword];
+ o.itemsCreator(op, callback);
+ },
+ value: o.value,
},
- value: o.value
- }, o.popup),
+ o.popup
+ ),
adapter: o.adapter,
- masker: o.masker
+ masker: o.masker,
});
- this.searcher.on(BI.Searcher.EVENT_START, function () {
- self.fireEvent(BI.SearchMultiSelectSearcher.EVENT_START);
+ this.searcher.on(Searcher.EVENT_START, () => {
+ this.fireEvent(SearchMultiSelectSearcher.EVENT_START);
});
- this.searcher.on(BI.Searcher.EVENT_PAUSE, function () {
- if (this.hasMatched()) {
-
- }
- self.fireEvent(BI.SearchMultiSelectSearcher.EVENT_PAUSE);
+ this.searcher.on(Searcher.EVENT_PAUSE, () => {
+ this.fireEvent(SearchMultiSelectSearcher.EVENT_PAUSE);
});
- this.searcher.on(BI.Searcher.EVENT_STOP, function () {
- self.fireEvent(BI.SearchMultiSelectSearcher.EVENT_STOP);
+ this.searcher.on(Searcher.EVENT_STOP, () => {
+ this.fireEvent(SearchMultiSelectSearcher.EVENT_STOP);
});
- this.searcher.on(BI.Searcher.EVENT_CHANGE, function () {
- self.fireEvent(BI.SearchMultiSelectSearcher.EVENT_CHANGE, arguments);
+ this.searcher.on(Searcher.EVENT_CHANGE, (...args) => {
+ this.fireEvent(SearchMultiSelectSearcher.EVENT_CHANGE, ...args);
});
- this.searcher.on(BI.Searcher.EVENT_SEARCHING, function () {
- var keywords = this.getKeywords();
- self.fireEvent(BI.SearchMultiSelectSearcher.EVENT_SEARCHING, keywords);
+ this.searcher.on(Searcher.EVENT_SEARCHING, () => {
+ const keywords = this.searcher.getKeywords();
+ this.fireEvent(SearchMultiSelectSearcher.EVENT_SEARCHING, keywords);
});
- if(BI.isNotNull(o.value)) {
+ if (isNotNull(o.value)) {
this.setState(o.value);
}
- },
+ }
- adjustView: function () {
+ adjustView() {
this.searcher.adjustView();
- },
+ }
- isSearching: function () {
+ isSearching() {
return this.searcher.isSearching();
- },
+ }
- stopSearch: function () {
+ stopSearch() {
this.searcher.stopSearch();
- },
+ }
- getKeyword: function () {
+ getKeyword() {
return this.editor.getValue();
- },
+ }
- hasMatched: function () {
+ hasMatched() {
return this.searcher.hasMatched();
- },
+ }
- hasChecked: function () {
+ hasChecked() {
return this.searcher.getView() && this.searcher.getView().hasChecked();
- },
+ }
- setAdapter: function (adapter) {
+ setAdapter(adapter) {
this.searcher.setAdapter(adapter);
- },
+ }
- setState: function (obj) {
- var o = this.options;
- var ob = {};
+ setState(obj) {
+ let state;
+ const o = this.options;
+ const ob = {};
ob.type = obj.type;
ob.value = o.allValueGetter() || [];
ob.assist = obj.assist;
- if (ob.type === BI.Selection.All) {
+ if (ob.type === Selection.All) {
if (ob.value.length === 0) {
- this.editor.setState(BI.Selection.All);
- } else if (BI.size(ob.assist) <= 20) {
- var state = "";
- BI.each(ob.assist, function (i, v) {
+ this.editor.setState(Selection.All);
+ } else if (size(ob.assist) <= 20) {
+ state = "";
+ each(ob.assist, (i, v) => {
if (i === 0) {
- state += "" + (o.valueFormatter(v + "") || v);
+ state += `${o.valueFormatter(`${v}`) || v}`;
} else {
- state += "," + (o.valueFormatter(v + "") || v);
+ state += `,${o.valueFormatter(`${v}`) || v}`;
}
});
this.editor.setState(state);
} else {
- this.editor.setState(BI.Selection.Multi);
+ this.editor.setState(Selection.Multi);
}
} else {
if (ob.value.length === 0) {
- this.editor.setState(BI.Selection.None);
- } else if (BI.size(ob.value) <= 20) {
- var state = "";
- BI.each(ob.value, function (i, v) {
+ this.editor.setState(Selection.None);
+ } else if (size(ob.value) <= 20) {
+ state = "";
+ each(ob.value, (i, v) => {
if (i === 0) {
- state += "" + (o.valueFormatter(v + "") || v);
+ state += `${o.valueFormatter(`${v}`) || v}`;
} else {
- state += "," + (o.valueFormatter(v + "") || v);
+ state += `,${o.valueFormatter(`${v}`) || v}`;
}
});
this.editor.setState(state);
} else {
- this.editor.setState(BI.Selection.Multi);
+ this.editor.setState(Selection.Multi);
}
}
- },
+ }
- setTipType: function (v) {
+ setTipType(v) {
this.editor.setTipType(v);
- },
+ }
- setValue: function (ob) {
+ setValue(ob) {
this.setState(ob);
this.searcher.setValue(ob);
- },
+ }
- getKey: function () {
+ getKey() {
return this.editor.getValue();
- },
+ }
- getValue: function () {
+ getValue() {
return this.searcher.getValue();
- },
+ }
- populate: function (items) {
- this.searcher.populate.apply(this.searcher, arguments);
+ populate(...items) {
+ this.searcher.populate(items);
}
-});
-
-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);
+}
diff --git a/src/widget/selecttree/selecttree.combo.js b/src/widget/selecttree/selecttree.combo.js
index 4e80f3c3b..506025c22 100644
--- a/src/widget/selecttree/selecttree.combo.js
+++ b/src/widget/selecttree/selecttree.combo.js
@@ -1,7 +1,3 @@
-/**
- * @class SelectTreeCombo
- * @extends Widget
- */
import {
shortcut,
Widget,
@@ -21,6 +17,11 @@ import { Combo } from "@/base";
import { SingleTreeTrigger } from "@/widget/singletree/singletree.trigger";
import { SelectTreePopup } from "./selecttree.popup";
+/**
+ * @class SelectTreeCombo
+ * @extends Widget
+ */
+
@shortcut()
export class SelectTreeCombo extends Widget {
static xtype = "bi.select_tree_combo";
@@ -37,7 +38,8 @@ export class SelectTreeCombo extends Widget {
}
_init() {
- const self = this, o = this.options;
+ const self = this,
+ o = this.options;
super._init(...arguments);
this.trigger = createWidget({
diff --git a/src/widget/selecttree/selecttree.expander.js b/src/widget/selecttree/selecttree.expander.js
index 9220d8811..85b027110 100644
--- a/src/widget/selecttree/selecttree.expander.js
+++ b/src/widget/selecttree/selecttree.expander.js
@@ -1,12 +1,4 @@
-import {
- shortcut,
- Widget,
- extend,
- createWidget,
- Controller,
- Events,
- contains
-} from "@/core";
+import { shortcut, Widget, extend, createWidget, Controller, Events, contains } from "@/core";
import { Expander } from "@/base";
@shortcut()
diff --git a/src/widget/selecttree/selecttree.popup.js b/src/widget/selecttree/selecttree.popup.js
index b9ea1e2e2..4a543efa9 100644
--- a/src/widget/selecttree/selecttree.popup.js
+++ b/src/widget/selecttree/selecttree.popup.js
@@ -5,7 +5,12 @@ import {
each,
createWidget,
Controller,
- isArray, isNotEmptyArray, UUID, defaults, Tree, VerticalLayout
+ isArray,
+ isNotEmptyArray,
+ UUID,
+ defaults,
+ Tree,
+ VerticalLayout
} from "@/core";
import { Pane } from "@/base";
import { BasicTreeItem, BasicTreeNode, LevelTree, TreeExpander } from "@/case";
@@ -37,11 +42,7 @@ export class SelectTreePopup extends Pane {
};
node.id = node.id || UUID();
- if (
- node.isParent === true ||
- node.parent === true ||
- isNotEmptyArray(node.children)
- ) {
+ if (node.isParent === true || node.parent === true || isNotEmptyArray(node.children)) {
extend.type = BasicTreeNode.xtype;
extend.selectable = true;
defaults(node, extend);
@@ -102,8 +103,6 @@ export class SelectTreePopup extends Pane {
populate(items) {
super.populate(...arguments);
- this.tree.populate(
- this._formatItems(Tree.transformToTreeFormat(items))
- );
+ this.tree.populate(this._formatItems(Tree.transformToTreeFormat(items)));
}
}
diff --git a/src/widget/singleselect/search/singleselect.search.loader.js b/src/widget/singleselect/search/singleselect.search.loader.js
index 56ab10f3c..3d88e3095 100644
--- a/src/widget/singleselect/search/singleselect.search.loader.js
+++ b/src/widget/singleselect/search/singleselect.search.loader.js
@@ -1,4 +1,18 @@
-import { shortcut, Widget, extend, emptyFn, createWidget, i18nText, isUndefined, Controller, VerticalLayout, map, isArray, isKey, Func } from "@/core";
+import {
+ shortcut,
+ Widget,
+ extend,
+ emptyFn,
+ createWidget,
+ i18nText,
+ isUndefined,
+ Controller,
+ VerticalLayout,
+ map,
+ isArray,
+ isKey,
+ Func
+} from "@/core";
import { ButtonGroup, Loader } from "@/base";
import { SingleSelectList } from "../singleselect.list";
import { SingleSelectItem, SingleSelectRadioItem } from "@/case";
@@ -49,7 +63,7 @@ export class SingleSelectSearchLoader extends Widget {
el: {
chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE,
behaviors: {
- redmark () {
+ redmark() {
return true;
},
},
@@ -61,7 +75,7 @@ export class SingleSelectSearchLoader extends Widget {
},
},
},
- itemsCreator (op, callback) {
+ itemsCreator(op, callback) {
self.storeValue &&
(op = extend(op || {}, {
selectedValues: [self.storeValue],
@@ -83,7 +97,7 @@ export class SingleSelectSearchLoader extends Widget {
}
});
},
- hasNext () {
+ hasNext() {
return hasNext;
},
});
@@ -97,20 +111,22 @@ export class SingleSelectSearchLoader extends Widget {
_createItems(items) {
const o = this.options;
-
- return map(items, (i, item) => extend(
- {
- type: o.allowNoSelect ? SingleSelectItem.xtype : SingleSelectRadioItem.xtype,
- logic: o.logic,
- cls: "bi-list-item-active",
- height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
- selected: false,
- iconWrapperWidth: 26,
- hgap: o.allowNoSelect ? 10 : 0,
- title: item.title || item.text,
- },
- item
- ));
+
+ return map(items, (i, item) =>
+ extend(
+ {
+ type: o.allowNoSelect ? SingleSelectItem.xtype : SingleSelectRadioItem.xtype,
+ logic: o.logic,
+ cls: "bi-list-item-active",
+ height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
+ selected: false,
+ iconWrapperWidth: 26,
+ hgap: o.allowNoSelect ? 10 : 0,
+ title: item.title || item.text,
+ },
+ item
+ )
+ );
}
_filterValues(src) {
@@ -127,7 +143,7 @@ export class SingleSelectSearchLoader extends Widget {
const search = Func.getSearchResult(newValues, keyword);
values = search.match.concat(search.find);
}
-
+
return map(values, (i, v) => {
return {
text: v.text,
diff --git a/src/widget/singleselect/search/singleselect.search.pane.insert.js b/src/widget/singleselect/search/singleselect.search.pane.insert.js
index 5c7ca6e5d..e2940fff5 100644
--- a/src/widget/singleselect/search/singleselect.search.pane.insert.js
+++ b/src/widget/singleselect/search/singleselect.search.pane.insert.js
@@ -1,4 +1,14 @@
-import { shortcut, Widget, extend, emptyFn, createWidget, i18nText, Controller, VerticalFillLayout, VerticalLayout } from "@/core";
+import {
+ shortcut,
+ Widget,
+ extend,
+ emptyFn,
+ createWidget,
+ i18nText,
+ Controller,
+ VerticalFillLayout,
+ VerticalLayout
+} from "@/core";
import { Label } from "@/base";
import { SingleSelectSearchLoader } from "./singleselect.search.loader";
@@ -38,7 +48,7 @@ export class SingleSelectSearchInsertPane extends Widget {
allowNoSelect: o.allowNoSelect,
keywordGetter: o.keywordGetter,
valueFormatter: o.valueFormatter,
- itemsCreator (op, callback) {
+ itemsCreator(op, callback) {
o.itemsCreator.apply(self, [
op,
function (res) {
diff --git a/src/widget/singleselect/search/singleselect.search.pane.js b/src/widget/singleselect/search/singleselect.search.pane.js
index d11421f34..8075c2917 100644
--- a/src/widget/singleselect/search/singleselect.search.pane.js
+++ b/src/widget/singleselect/search/singleselect.search.pane.js
@@ -38,7 +38,7 @@ export class SingleSelectSearchPane extends Widget {
allowNoSelect: o.allowNoSelect,
keywordGetter: o.keywordGetter,
valueFormatter: o.valueFormatter,
- itemsCreator (op, callback) {
+ itemsCreator(op, callback) {
o.itemsCreator.apply(self, [
op,
function (res) {
diff --git a/src/widget/singleselect/singleselect.combo.js b/src/widget/singleselect/singleselect.combo.js
index 2d1d2b013..fcc20d869 100644
--- a/src/widget/singleselect/singleselect.combo.js
+++ b/src/widget/singleselect/singleselect.combo.js
@@ -1,4 +1,18 @@
-import { shortcut, extend, emptyFn, isKey, createWidget, toPix, isNotNull, nextTick, AbsoluteLayout, makeObject, map, each, remove } from "@/core";
+import {
+ shortcut,
+ extend,
+ emptyFn,
+ isKey,
+ createWidget,
+ toPix,
+ isNotNull,
+ nextTick,
+ AbsoluteLayout,
+ makeObject,
+ map,
+ each,
+ remove
+} from "@/core";
import { Single, Combo } from "@/base";
import { SingleSelectTrigger } from "./singleselect.trigger";
import { SingleSelectPopupView } from "./singleselect.popup.view";
@@ -42,7 +56,7 @@ export class SingleSelectCombo extends Single {
this.requesting = false;
this.trigger = createWidget({
- type: "bi.single_select_trigger",
+ type: SingleSelectTrigger.xtype,
height: toPix(o.height, o.simple ? 1 : 2),
// adapter: this.popup,
allowNoSelect: o.allowNoSelect,
@@ -81,15 +95,12 @@ export class SingleSelectCombo extends Single {
this.fireEvent(SingleSelectCombo.EVENT_SEARCHING);
});
- this.trigger.on(
- SingleSelectTrigger.EVENT_CHANGE,
- (value, obj) => {
- this.storeValue = this.trigger.getValue();
- assertShowValue();
- this._defaultState();
- this._dataChange = true;
- }
- );
+ this.trigger.on(SingleSelectTrigger.EVENT_CHANGE, (value, obj) => {
+ this.storeValue = this.trigger.getValue();
+ assertShowValue();
+ this._defaultState();
+ this._dataChange = true;
+ });
this.trigger.on(SingleSelectTrigger.EVENT_COUNTER_CLICK, () => {
if (!this.combo.isViewVisible()) {
this.combo.showView();
@@ -104,24 +115,26 @@ export class SingleSelectCombo extends Single {
el: this.trigger,
adjustLength: 1,
popup: {
- type: "bi.single_select_popup_view",
+ type: SingleSelectPopupView.xtype,
allowNoSelect: o.allowNoSelect,
ref: _ref => {
this.popup = _ref;
this.trigger.setAdapter(_ref);
},
- listeners: [{
- eventName: SingleSelectPopupView.EVENT_CHANGE,
- action: () => {
- this._dataChange = true;
- this.storeValue = this.popup.getValue();
- this._adjust(() => {
- assertShowValue();
- this._defaultState();
- });
- this.fireEvent(SingleSelectCombo.EVENT_CLICK_ITEM);
- },
- }],
+ listeners: [
+ {
+ eventName: SingleSelectPopupView.EVENT_CHANGE,
+ action: () => {
+ this._dataChange = true;
+ this.storeValue = this.popup.getValue();
+ this._adjust(() => {
+ assertShowValue();
+ this._defaultState();
+ });
+ this.fireEvent(SingleSelectCombo.EVENT_CLICK_ITEM);
+ },
+ }
+ ],
itemsCreator: o.itemsCreator,
itemWrapper: o.itemWrapper,
valueFormatter: o.valueFormatter,
@@ -156,8 +169,7 @@ export class SingleSelectCombo extends Single {
if (this.requesting === true) {
this.wants2Quit = true;
} else {
- this._dataChange &&
- this.fireEvent(SingleSelectCombo.EVENT_CONFIRM);
+ this._dataChange && this.fireEvent(SingleSelectCombo.EVENT_CONFIRM);
}
});
@@ -177,19 +189,20 @@ export class SingleSelectCombo extends Single {
createWidget({
type: AbsoluteLayout.xtype,
element: this,
- items: [{
- el: this.combo,
- left: 0,
- right: 0,
- top: 0,
- bottom: 0,
- },
- {
- el: triggerBtn,
- right: 0,
- top: 0,
- bottom: 0,
- }
+ items: [
+ {
+ el: this.combo,
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0,
+ },
+ {
+ el: triggerBtn,
+ right: 0,
+ top: 0,
+ bottom: 0,
+ }
],
});
}
@@ -209,14 +222,15 @@ export class SingleSelectCombo extends Single {
const o = this.options;
this._assertValue(this.storeValue);
this.requesting = true;
- o.itemsCreator({
- type: SingleSelectCombo.REQ_GET_ALL_DATA,
- keywords,
- },
- ob => {
- const values = map(ob.items, "value");
- digest(values);
- }
+ o.itemsCreator(
+ {
+ type: SingleSelectCombo.REQ_GET_ALL_DATA,
+ keywords,
+ },
+ ob => {
+ const values = map(ob.items, "value");
+ digest(values);
+ }
);
const digest = items => {
@@ -233,8 +247,7 @@ export class SingleSelectCombo extends Single {
_adjust(callback) {
const adjust = () => {
if (this.wants2Quit === true) {
- this._dataChange &&
- this.fireEvent(SingleSelectCombo.EVENT_CONFIRM);
+ this._dataChange && this.fireEvent(SingleSelectCombo.EVENT_CONFIRM);
this.wants2Quit = false;
}
this.requesting = false;
@@ -242,14 +255,15 @@ export class SingleSelectCombo extends Single {
const o = this.options;
if (!this._count) {
- o.itemsCreator({
- type: SingleSelectCombo.REQ_GET_DATA_LENGTH,
- },
- res => {
- this._count = res.count;
- adjust();
- callback();
- }
+ o.itemsCreator(
+ {
+ type: SingleSelectCombo.REQ_GET_DATA_LENGTH,
+ },
+ res => {
+ this._count = res.count;
+ adjust();
+ callback();
+ }
);
} else {
adjust();
diff --git a/src/widget/singleselect/singleselect.insert.combo.js b/src/widget/singleselect/singleselect.insert.combo.js
index 991735404..eb528ec7a 100644
--- a/src/widget/singleselect/singleselect.insert.combo.js
+++ b/src/widget/singleselect/singleselect.insert.combo.js
@@ -1,4 +1,17 @@
-import { shortcut, extend, emptyFn, i18nText, isKey, createWidget, toPix, isNotNull, nextTick, AbsoluteLayout, makeObject } from "@/core";
+import { SingleSelectSearchInsertPane } from "./search";
+import {
+ shortcut,
+ extend,
+ emptyFn,
+ i18nText,
+ isKey,
+ createWidget,
+ toPix,
+ isNotNull,
+ nextTick,
+ AbsoluteLayout,
+ makeObject
+} from "@/core";
import { Single, Combo } from "@/base";
import { SingleSelectTrigger } from "./singleselect.trigger";
import { SingleSelectPopupView } from "./singleselect.popup.view";
@@ -50,7 +63,7 @@ export class SingleSelectInsertCombo extends Single {
allowEdit: o.allowEdit,
// adapter: this.popup,
valueFormatter: o.valueFormatter,
- itemsCreator (op, callback) {
+ itemsCreator(op, callback) {
o.itemsCreator(op, function (res) {
if (op.times === 1 && isNotNull(op.keywords)) {
// 预防trigger内部把当前的storeValue改掉
@@ -63,7 +76,7 @@ export class SingleSelectInsertCombo extends Single {
value: this.storeValue,
searcher: {
popup: {
- type: "bi.single_select_search_insert_pane",
+ type: SingleSelectSearchInsertPane.xtype,
},
},
});
@@ -93,15 +106,12 @@ export class SingleSelectInsertCombo extends Single {
self.fireEvent(SingleSelectInsertCombo.EVENT_SEARCHING);
});
- this.trigger.on(
- SingleSelectTrigger.EVENT_CHANGE,
- function (value, obj) {
- self.storeValue = this.getValue();
- assertShowValue();
- self._defaultState();
- self._dataChange = true;
- }
- );
+ this.trigger.on(SingleSelectTrigger.EVENT_CHANGE, function (value, obj) {
+ self.storeValue = this.getValue();
+ assertShowValue();
+ self._defaultState();
+ self._dataChange = true;
+ });
this.trigger.on(SingleSelectTrigger.EVENT_COUNTER_CLICK, () => {
if (!self.combo.isViewVisible()) {
self.combo.showView();
@@ -118,30 +128,28 @@ export class SingleSelectInsertCombo extends Single {
popup: {
type: SingleSelectPopupView.xtype,
allowNoSelect: o.allowNoSelect,
- ref () {
+ ref() {
self.popup = this;
self.trigger.setAdapter(this);
},
listeners: [
{
eventName: SingleSelectPopupView.EVENT_CHANGE,
- action () {
+ action() {
self._dataChange = true;
self.storeValue = this.getValue();
self._adjust(() => {
assertShowValue();
self._defaultState();
});
- self.fireEvent(
- SingleSelectInsertCombo.EVENT_CLICK_ITEM
- );
+ self.fireEvent(SingleSelectInsertCombo.EVENT_CLICK_ITEM);
},
}
],
itemsCreator: o.itemsCreator,
itemWrapper: o.itemWrapper,
valueFormatter: o.valueFormatter,
- onLoaded () {
+ onLoaded() {
nextTick(() => {
self.combo.adjustWidth();
self.combo.adjustHeight();
@@ -149,7 +157,7 @@ export class SingleSelectInsertCombo extends Single {
});
},
},
- hideChecker (e) {
+ hideChecker(e) {
return triggerBtn.element.find(e.target).length === 0;
},
value: o.value,
@@ -172,8 +180,7 @@ export class SingleSelectInsertCombo extends Single {
if (self.requesting === true) {
self.wants2Quit = true;
} else {
- self._dataChange &&
- self.fireEvent(SingleSelectInsertCombo.EVENT_CONFIRM);
+ self._dataChange && self.fireEvent(SingleSelectInsertCombo.EVENT_CONFIRM);
}
});
@@ -229,8 +236,7 @@ export class SingleSelectInsertCombo extends Single {
function adjust() {
if (self.wants2Quit === true) {
- self._dataChange &&
- self.fireEvent(SingleSelectInsertCombo.EVENT_CONFIRM);
+ self._dataChange && self.fireEvent(SingleSelectInsertCombo.EVENT_CONFIRM);
self.wants2Quit = false;
}
self.requesting = false;
diff --git a/src/widget/singleselect/singleselect.list.js b/src/widget/singleselect/singleselect.list.js
index 13c51656b..7b3cec4dd 100644
--- a/src/widget/singleselect/singleselect.list.js
+++ b/src/widget/singleselect/singleselect.list.js
@@ -35,7 +35,7 @@ export class SingleSelectList extends Widget {
this.list = createWidget(o.el, {
type: ListPane.xtype,
items: o.items,
- itemsCreator (op, callback) {
+ itemsCreator(op, callback) {
op.times === 1 && self.toolbar && self.toolbar.setVisible(false);
o.itemsCreator(op, function (items) {
callback.apply(self, arguments);
@@ -79,13 +79,13 @@ export class SingleSelectList extends Widget {
height: this._constants.itemHeight,
forceNotSelected: true,
text: i18nText("BI-Basic_No_Select"),
- ref (_ref) {
+ ref(_ref) {
self.toolbar = _ref;
},
listeners: [
{
eventName: Controller.EVENT_CHANGE,
- action (type) {
+ action(type) {
if (type === Events.CLICK) {
self.list.setValue();
self.fireEvent(SingleSelectList.EVENT_CHANGE);
diff --git a/src/widget/singleselect/singleselect.loader.js b/src/widget/singleselect/singleselect.loader.js
index 678f4a681..4719b635e 100644
--- a/src/widget/singleselect/singleselect.loader.js
+++ b/src/widget/singleselect/singleselect.loader.js
@@ -1,4 +1,16 @@
-import { shortcut, Widget, extend, emptyFn, createWidget, isUndefined, map, isKey, Controller, VerticalLayout, delay } from "@/core";
+import {
+ shortcut,
+ Widget,
+ extend,
+ emptyFn,
+ createWidget,
+ isUndefined,
+ map,
+ isKey,
+ Controller,
+ VerticalLayout,
+ delay
+} from "@/core";
import { ButtonGroup, Loader } from "@/base";
import { SingleSelectList } from "./singleselect.list";
import { SingleSelectItem, SingleSelectRadioItem } from "@/case";
@@ -52,7 +64,7 @@ export class SingleSelectLoader extends Widget {
el: {
chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE,
behaviors: {
- redmark () {
+ redmark() {
return true;
},
},
@@ -66,7 +78,7 @@ export class SingleSelectLoader extends Widget {
},
opts.el
),
- itemsCreator (op, callback) {
+ itemsCreator(op, callback) {
const startValue = self._startValue;
!isUndefined(self.storeValue) &&
(op = extend(op || {}, {
@@ -78,7 +90,7 @@ export class SingleSelectLoader extends Widget {
if (op.times === 1 && !isUndefined(self.storeValue)) {
const json = map([self.storeValue], (i, v) => {
const txt = opts.valueFormatter(v) || v;
-
+
return (
opts.itemWrapper({
text: txt,
@@ -103,7 +115,7 @@ export class SingleSelectLoader extends Widget {
op.times === 1 && self._scrollToTop();
});
},
- hasNext () {
+ hasNext() {
return hasNext;
},
value: this.storeValue,
@@ -126,20 +138,22 @@ export class SingleSelectLoader extends Widget {
_createItems(items) {
const o = this.options;
-
- return map(items, (i, item) => extend(
- {
- type: o.allowNoSelect ? SingleSelectItem.xtype : SingleSelectRadioItem.xtype,
- logic: o.logic,
- cls: "bi-list-item-active",
- height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
- selected: false,
- iconWrapperWidth: 26,
- textHgap: o.allowNoSelect ? 10 : 0,
- title: item.title || item.text,
- },
- item
- ));
+
+ return map(items, (i, item) =>
+ extend(
+ {
+ type: o.allowNoSelect ? SingleSelectItem.xtype : SingleSelectRadioItem.xtype,
+ logic: o.logic,
+ cls: "bi-list-item-active",
+ height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
+ selected: false,
+ iconWrapperWidth: 26,
+ textHgap: o.allowNoSelect ? 10 : 0,
+ title: item.title || item.text,
+ },
+ item
+ )
+ );
}
_scrollToTop() {
diff --git a/src/widget/singleselect/singleselect.popup.view.js b/src/widget/singleselect/singleselect.popup.view.js
index c03d71522..405ce363f 100644
--- a/src/widget/singleselect/singleselect.popup.view.js
+++ b/src/widget/singleselect/singleselect.popup.view.js
@@ -1,3 +1,4 @@
+import { SingleSelectLoader } from "./singleselect.loader";
import { shortcut, Widget, extend, emptyFn, createWidget } from "@/core";
import { MultiPopupView } from "@/case";
import { PopupView } from "@/base";
@@ -27,7 +28,7 @@ export class SingleSelectPopupView extends Widget {
const opts = this.options;
this.loader = createWidget({
- type: "bi.single_select_loader",
+ type: SingleSelectLoader.xtype,
allowNoSelect: opts.allowNoSelect,
itemsCreator: opts.itemsCreator,
itemWrapper: opts.itemWrapper,
diff --git a/src/widget/singleselect/singleselectlist.insert.js b/src/widget/singleselect/singleselectlist.insert.js
index e2dc37b9b..ca8553d79 100644
--- a/src/widget/singleselect/singleselectlist.insert.js
+++ b/src/widget/singleselect/singleselectlist.insert.js
@@ -1,3 +1,4 @@
+import { SingleSelectSearchInsertPane } from "./search";
import {
shortcut,
extend,
@@ -68,14 +69,14 @@ export class SingleSelectInsertList extends Single {
});
this.searcherPane = createWidget({
- type: "bi.single_select_search_insert_pane",
+ type: SingleSelectSearchInsertPane.xtype,
allowNoSelect: o.allowNoSelect,
cls: "bi-border-left bi-border-right bi-border-bottom",
valueFormatter: o.valueFormatter,
- keywordGetter () {
+ keywordGetter() {
return self.trigger.getKeyword();
},
- itemsCreator (op, callback) {
+ itemsCreator(op, callback) {
op.keywords = [self.trigger.getKeyword()];
if (isNotEmptyString(op.keywords[0])) {
this.setKeyword(op.keywords[0]);
@@ -93,14 +94,14 @@ export class SingleSelectInsertList extends Single {
type: SearchEditor.xtype,
watermark: i18nText("BI-Basic_Search_And_Patch_Paste"),
},
- ref (ref) {
+ ref(ref) {
self.editor = ref;
},
height: o.searcherHeight,
},
isAutoSearch: false,
isAutoSync: false,
- onSearch (op, callback) {
+ onSearch(op, callback) {
callback();
},
adapter: this.adapter,
@@ -110,7 +111,7 @@ export class SingleSelectInsertList extends Single {
listeners: [
{
eventName: Searcher.EVENT_START,
- action () {
+ action() {
self._showSearcherPane();
self._setStartValue();
this.setValue(deepClone(self.storeValue));
@@ -118,7 +119,7 @@ export class SingleSelectInsertList extends Single {
},
{
eventName: Searcher.EVENT_STOP,
- action () {
+ action() {
self._showAdapter();
self._setStartValue();
self.adapter.setValue(self.storeValue);
@@ -128,7 +129,7 @@ export class SingleSelectInsertList extends Single {
},
{
eventName: Searcher.EVENT_PAUSE,
- action () {
+ action() {
const keyword = this.getKeyword();
self.storeValue = keyword;
self._showAdapter();
@@ -142,7 +143,7 @@ export class SingleSelectInsertList extends Single {
},
{
eventName: Searcher.EVENT_CHANGE,
- action () {
+ action() {
self.storeValue = this.getValue();
self.fireEvent(SingleSelectInsertList.EVENT_CHANGE);
},
diff --git a/src/widget/singleselect/trigger/editor.singleselect.js b/src/widget/singleselect/trigger/editor.singleselect.js
index 635b7481e..8320c4634 100644
--- a/src/widget/singleselect/trigger/editor.singleselect.js
+++ b/src/widget/singleselect/trigger/editor.singleselect.js
@@ -1,4 +1,14 @@
-import { shortcut, Widget, extend, i18nText, createWidget, Controller, isEmptyString, isEmptyArray, BlankSplitChar } from "@/core";
+import {
+ shortcut,
+ Widget,
+ extend,
+ i18nText,
+ createWidget,
+ Controller,
+ isEmptyString,
+ isEmptyArray,
+ BlankSplitChar
+} from "@/core";
import { StateEditor } from "@/case";
import { SelectPatchEditor } from "../../multiselect";
diff --git a/src/widget/singleselect/trigger/searcher.singleselect.js b/src/widget/singleselect/trigger/searcher.singleselect.js
index 82b581942..31ebc6f67 100644
--- a/src/widget/singleselect/trigger/searcher.singleselect.js
+++ b/src/widget/singleselect/trigger/searcher.singleselect.js
@@ -1,3 +1,4 @@
+import { SingleSelectSearchPane } from "../search";
import { shortcut, Widget, extend, emptyFn, createWidget, isNotNull, isUndefined, Selection } from "@/core";
import { SingleSelectEditor } from "./editor.singleselect";
import { Searcher } from "@/base";
@@ -33,22 +34,23 @@ export class SingleSelectSearcher extends Widget {
const self = this,
o = this.options;
this.editor = createWidget(o.el, {
- type: "bi.single_select_editor",
+ type: SingleSelectEditor.xtype,
height: o.height,
watermark: o.watermark,
text: o.text,
- listeners: [{
- eventName: SingleSelectEditor.EVENT_FOCUS,
- action: () => {
- this.fireEvent(SingleSelectSearcher.EVENT_FOCUS);
+ listeners: [
+ {
+ eventName: SingleSelectEditor.EVENT_FOCUS,
+ action: () => {
+ this.fireEvent(SingleSelectSearcher.EVENT_FOCUS);
+ },
},
- },
- {
- eventName: SingleSelectEditor.EVENT_BLUR,
- action: () => {
- this.fireEvent(SingleSelectSearcher.EVENT_BLUR);
- },
- }
+ {
+ eventName: SingleSelectEditor.EVENT_BLUR,
+ action: () => {
+ this.fireEvent(SingleSelectSearcher.EVENT_BLUR);
+ },
+ }
],
});
@@ -63,20 +65,21 @@ export class SingleSelectSearcher extends Widget {
},
el: this.editor,
- popup: extend({
- type: "bi.single_select_search_pane",
- allowNoSelect: o.allowNoSelect,
- valueFormatter: o.valueFormatter,
- keywordGetter: () => this.editor.getValue(),
- itemsCreator(op, callback) {
- const keyword = self.editor.getValue();
- op.keywords = [keyword];
- this.setKeyword(keyword);
- o.itemsCreator(op, callback);
+ popup: extend(
+ {
+ type: SingleSelectSearchPane.xtype,
+ allowNoSelect: o.allowNoSelect,
+ valueFormatter: o.valueFormatter,
+ keywordGetter: () => this.editor.getValue(),
+ itemsCreator(op, callback) {
+ const keyword = self.editor.getValue();
+ op.keywords = [keyword];
+ this.setKeyword(keyword);
+ o.itemsCreator(op, callback);
+ },
+ value: o.value,
},
- value: o.value,
- },
- o.popup
+ o.popup
),
adapter: o.adapter,
diff --git a/src/widget/singleslider/button/editor.sign.text.js b/src/widget/singleslider/button/editor.sign.text.js
index 09eb164db..da7c44cb9 100644
--- a/src/widget/singleslider/button/editor.sign.text.js
+++ b/src/widget/singleslider/button/editor.sign.text.js
@@ -24,7 +24,7 @@ export class SignTextEditor extends Widget {
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
-
+
return extend(conf, {
baseCls: `${conf.baseCls || ""} bi-sign-initial-editor`,
validationChecker: emptyFn,
diff --git a/src/widget/singleslider/button/iconbutton.slider.js b/src/widget/singleslider/button/iconbutton.slider.js
index c1b5ce6f8..d68233b10 100644
--- a/src/widget/singleslider/button/iconbutton.slider.js
+++ b/src/widget/singleslider/button/iconbutton.slider.js
@@ -8,7 +8,7 @@ export class SliderIconButton extends Widget {
baseCls: "bi-single-slider-button slider-button bi-high-light-border",
height: 8,
width: 8,
- }
+ };
constants = {
LARGE_SIZE: 16,
NORMAL_SIZE: 12,
diff --git a/src/widget/singleslider/index.js b/src/widget/singleslider/index.js
index dc4943c0c..1142afc23 100644
--- a/src/widget/singleslider/index.js
+++ b/src/widget/singleslider/index.js
@@ -1,5 +1,5 @@
-export { SingleSlider } from "./singleslider";
-export { SingleSliderLabel } from "./singleslider.label";
-export { SingleSliderNormal } from "./singleslider.normal";
-export { SignTextEditor } from "./button/editor.sign.text";
-export { SliderIconButton } from "./button/iconbutton.slider";
+export { SingleSlider } from "./singleslider";
+export { SingleSliderLabel } from "./singleslider.label";
+export { SingleSliderNormal } from "./singleslider.normal";
+export { SignTextEditor } from "./button/editor.sign.text";
+export { SliderIconButton } from "./button/iconbutton.slider";
diff --git a/src/widget/singleslider/singleslider.js b/src/widget/singleslider/singleslider.js
index 0a2b7496e..3a8f38623 100644
--- a/src/widget/singleslider/singleslider.js
+++ b/src/widget/singleslider/singleslider.js
@@ -1,3 +1,5 @@
+import { SliderIconButton } from "./button/iconbutton.slider";
+import { SignTextEditor } from "./button/editor.sign.text";
import {
shortcut,
createWidget,
@@ -32,7 +34,7 @@ export class SingleSlider extends Single {
TRACK_HEIGHT: 24,
TRACK_GAP_HALF: 7,
TRACK_GAP: 14,
- }
+ };
props = {
baseCls: "bi-single-slider bi-slider-track",
@@ -74,7 +76,7 @@ export class SingleSlider extends Single {
this.track = this._createTrackWrapper();
this.slider = createWidget({
- type: "bi.single_slider_button",
+ type: SliderIconButton.xtype,
});
this._draggable(this.slider);
const sliderVertical = createWidget({
@@ -98,17 +100,9 @@ export class SingleSlider extends Single {
});
// 这边其实是有问题的,拖拽区域是个圆,在圆的边缘拖拽后放开,这边计算出来的蓝条宽度实际上会比放开时长一点或者短一点
sliderVertical.element.click(e => {
- if (
- this.enable &&
- this.isEnabled() &&
- sliderVertical.element[0] === e.originalEvent.target
- ) {
- const offset =
- e.clientX -
- this.element.offset().left -
- c.SLIDER_WIDTH_HALF;
- const trackLength =
- this.track.element[0].scrollWidth - c.TRACK_GAP;
+ if (this.enable && this.isEnabled() && sliderVertical.element[0] === e.originalEvent.target) {
+ const offset = e.clientX - this.element.offset().left - c.SLIDER_WIDTH_HALF;
+ const trackLength = this.track.element[0].scrollWidth - c.TRACK_GAP;
let percent = 0;
if (offset < 0) {
percent = 0;
@@ -129,7 +123,7 @@ export class SingleSlider extends Single {
}
});
this.label = createWidget({
- type: "bi.sign_text_editor",
+ type: SignTextEditor.xtype,
cls: "slider-editor-button",
text: o.unit,
width: toPix(c.EDITOR_WIDTH, 2),
@@ -140,9 +134,7 @@ export class SingleSlider extends Single {
});
this.label.element.hover(
() => {
- this.label.element
- .removeClass("bi-border")
- .addClass("bi-border");
+ this.label.element.removeClass("bi-border").addClass("bi-border");
},
() => {
this.label.element.removeClass("bi-border");
@@ -158,7 +150,7 @@ export class SingleSlider extends Single {
this.fireEvent(SingleSlider.EVENT_CHANGE);
});
this._setVisible(false);
-
+
return {
type: AbsoluteLayout.xtype,
items: [
@@ -216,7 +208,7 @@ export class SingleSlider extends Single {
offset = 0,
defaultSize = 0;
const mouseMoveTracker = new MouseMoveTracker(
- (deltaX => {
+ deltaX => {
if (mouseMoveTracker.isDragging()) {
startDrag = true;
offset += deltaX;
@@ -232,8 +224,8 @@ export class SingleSlider extends Single {
this.label.setValue(v);
this.value = v;
}
- }),
- (() => {
+ },
+ () => {
if (startDrag === true) {
size = optimizeSize(size);
const percent = (size * 100) / this._getGrayTrackLength();
@@ -247,7 +239,7 @@ export class SingleSlider extends Single {
widget.element.removeClass("dragging");
mouseMoveTracker.releaseMouseMoves();
this.fireEvent(SingleSlider.EVENT_CHANGE);
- }),
+ },
window
);
widget.element.on("mousedown", function (event) {
@@ -306,11 +298,11 @@ export class SingleSlider extends Single {
if (o.digit === false) {
valid = true;
} else {
- const dotText = (`${v}`).split(".")[1] || "";
+ const dotText = `${v}`.split(".")[1] || "";
valid = dotText.length === o.digit;
}
}
-
+
return valid;
}
@@ -343,7 +335,7 @@ export class SingleSlider extends Single {
_getValueByPercent(percent) {
const thousandth = parseInt(percent * 10);
-
+
return ((this.max - this.min) * thousandth) / 1000 + this.min;
}
@@ -375,13 +367,9 @@ export class SingleSlider extends Single {
_setEnable(b) {
super._setEnable.apply(this, [b]);
if (b) {
- this.blueTrack.element
- .removeClass("disabled-blue-track")
- .addClass("blue-track");
+ this.blueTrack.element.removeClass("disabled-blue-track").addClass("blue-track");
} else {
- this.blueTrack.element
- .removeClass("blue-track")
- .addClass("disabled-blue-track");
+ this.blueTrack.element.removeClass("blue-track").addClass("disabled-blue-track");
}
}
@@ -409,21 +397,9 @@ export class SingleSlider extends Single {
this._setVisible(true);
this.enable = true;
if (o.digit) {
- this.label.setErrorText(
- i18nText(
- "BI-Basic_Please_Enter_Number_Between",
- this.min,
- this.max
- )
- );
+ this.label.setErrorText(i18nText("BI-Basic_Please_Enter_Number_Between", this.min, this.max));
} else {
- this.label.setErrorText(
- i18nText(
- "BI-Basic_Please_Enter_Integer_Number_Between",
- this.min,
- this.max
- )
- );
+ this.label.setErrorText(i18nText("BI-Basic_Please_Enter_Integer_Number_Between", this.min, this.max));
}
if (isNumeric(this.value) || isNotEmptyString(this.value)) {
diff --git a/src/widget/singleslider/singleslider.label.js b/src/widget/singleslider/singleslider.label.js
index 1253c5681..7e95212f2 100644
--- a/src/widget/singleslider/singleslider.label.js
+++ b/src/widget/singleslider/singleslider.label.js
@@ -1,3 +1,4 @@
+import { SliderIconButton } from "./button/iconbutton.slider";
import {
shortcut,
createWidget,
@@ -30,7 +31,7 @@ export class SingleSliderLabel extends Single {
TRACK_HEIGHT: 24,
TRACK_GAP_HALF: 7,
TRACK_GAP: 14,
- }
+ };
props = {
baseCls: "bi-single-slider-label bi-slider-track",
digit: false,
@@ -71,7 +72,7 @@ export class SingleSliderLabel extends Single {
this.track = this._createTrackWrapper();
this.slider = createWidget({
- type: "bi.single_slider_button",
+ type: SliderIconButton.xtype,
});
this._draggable(this.slider);
const sliderVertical = createWidget({
@@ -93,17 +94,9 @@ export class SingleSliderLabel extends Single {
height: c.SLIDER_HEIGHT,
});
sliderVertical.element.click(e => {
- if (
- this.enable &&
- this.isEnabled() &&
- sliderVertical.element[0] === e.originalEvent.target
- ) {
- const offset =
- e.clientX -
- this.element.offset().left -
- c.SLIDER_WIDTH_HALF;
- const trackLength =
- this.track.element[0].scrollWidth - c.TRACK_GAP;
+ if (this.enable && this.isEnabled() && sliderVertical.element[0] === e.originalEvent.target) {
+ const offset = e.clientX - this.element.offset().left - c.SLIDER_WIDTH_HALF;
+ const trackLength = this.track.element[0].scrollWidth - c.TRACK_GAP;
let percent = 0;
if (offset < 0) {
percent = 0;
@@ -130,7 +123,7 @@ export class SingleSliderLabel extends Single {
});
this._setVisible(false);
-
+
return {
type: AbsoluteLayout.xtype,
items: [
@@ -188,7 +181,7 @@ export class SingleSliderLabel extends Single {
offset = 0,
defaultSize = 0;
const mouseMoveTracker = new MouseMoveTracker(
- (deltaX => {
+ deltaX => {
if (mouseMoveTracker.isDragging()) {
startDrag = true;
offset += deltaX;
@@ -205,8 +198,8 @@ export class SingleSliderLabel extends Single {
this.value = v;
this.fireEvent(SingleSliderLabel.EVENT_CHANGE);
}
- }),
- (() => {
+ },
+ () => {
if (startDrag === true) {
size = optimizeSize(size);
const percent = (size * 100) / this._getGrayTrackLength();
@@ -220,7 +213,7 @@ export class SingleSliderLabel extends Single {
widget.element.removeClass("dragging");
mouseMoveTracker.releaseMouseMoves();
this.fireEvent(SingleSliderLabel.EVENT_CHANGE);
- }),
+ },
window
);
widget.element.on("mousedown", function (event) {
@@ -305,7 +298,7 @@ export class SingleSliderLabel extends Single {
_getValueByPercent(percent) {
const thousandth = parseInt(percent * 10);
-
+
return ((this.max - this.min) * thousandth) / 1000 + this.min;
}
@@ -316,13 +309,9 @@ export class SingleSliderLabel extends Single {
_setEnable(b) {
super._setEnable.apply(this, [b]);
if (b) {
- this.blueTrack.element
- .removeClass("disabled-blue-track")
- .addClass("blue-track");
+ this.blueTrack.element.removeClass("disabled-blue-track").addClass("blue-track");
} else {
- this.blueTrack.element
- .removeClass("blue-track")
- .addClass("disabled-blue-track");
+ this.blueTrack.element.removeClass("blue-track").addClass("disabled-blue-track");
}
}
diff --git a/src/widget/singleslider/singleslider.normal.js b/src/widget/singleslider/singleslider.normal.js
index 993e86043..c7e4dde99 100644
--- a/src/widget/singleslider/singleslider.normal.js
+++ b/src/widget/singleslider/singleslider.normal.js
@@ -1,3 +1,4 @@
+import { SliderIconButton } from "./button/iconbutton.slider";
import {
shortcut,
createWidget,
@@ -27,7 +28,7 @@ export class SingleSliderNormal extends Single {
TRACK_HEIGHT: 24,
TRACK_GAP_HALF: 7,
TRACK_GAP: 14,
- }
+ };
props = {
baseCls: "bi-single-slider-normal bi-slider-track",
min: 0,
@@ -52,7 +53,7 @@ export class SingleSliderNormal extends Single {
const track = this._createTrack();
this.slider = createWidget({
- type: "bi.single_slider_button",
+ type: SliderIconButton.xtype,
});
this._draggable(this.slider);
@@ -75,17 +76,9 @@ export class SingleSliderNormal extends Single {
height: c.SLIDER_HEIGHT,
});
sliderVertical.element.click(e => {
- if (
- this.enable &&
- this.isEnabled() &&
- sliderVertical.element[0] === e.originalEvent.target
- ) {
- const offset =
- e.clientX -
- this.element.offset().left -
- c.SLIDER_WIDTH_HALF;
- const trackLength =
- this.track.element[0].scrollWidth - c.TRACK_GAP;
+ if (this.enable && this.isEnabled() && sliderVertical.element[0] === e.originalEvent.target) {
+ const offset = e.clientX - this.element.offset().left - c.SLIDER_WIDTH_HALF;
+ const trackLength = this.track.element[0].scrollWidth - c.TRACK_GAP;
let percent = 0;
if (offset < 0) {
percent = 0;
@@ -147,7 +140,7 @@ export class SingleSliderNormal extends Single {
offset = 0,
defaultSize = 0;
const mouseMoveTracker = new MouseMoveTracker(
- (deltaX => {
+ deltaX => {
if (mouseMoveTracker.isDragging()) {
startDrag = true;
offset += deltaX;
@@ -162,8 +155,8 @@ export class SingleSliderNormal extends Single {
this.value = v;
this.fireEvent(SingleSliderNormal.EVENT_DRAG, v);
}
- }),
- (() => {
+ },
+ () => {
if (startDrag === true) {
size = optimizeSize(size);
const percent = (size * 100) / this._getGrayTrackLength();
@@ -177,7 +170,7 @@ export class SingleSliderNormal extends Single {
widget.element.removeClass("dragging");
mouseMoveTracker.releaseMouseMoves();
this.fireEvent(SingleSlider.EVENT_CHANGE);
- }),
+ },
window
);
widget.element.on("mousedown", function (event) {
@@ -275,7 +268,7 @@ export class SingleSliderNormal extends Single {
_getValueByPercent(percent) {
const thousandth = parseInt(percent * 10);
-
+
return ((this.max - this.min) * thousandth) / 1000 + this.min;
}
@@ -286,13 +279,9 @@ export class SingleSliderNormal extends Single {
_setEnable(b) {
super._setEnable.apply(this, [b]);
if (b) {
- this.blueTrack.element
- .removeClass("disabled-blue-track")
- .addClass("blue-track");
+ this.blueTrack.element.removeClass("disabled-blue-track").addClass("blue-track");
} else {
- this.blueTrack.element
- .removeClass("blue-track")
- .addClass("disabled-blue-track");
+ this.blueTrack.element.removeClass("blue-track").addClass("disabled-blue-track");
}
}
diff --git a/src/widget/singletree/singletree.combo.js b/src/widget/singletree/singletree.combo.js
index cfa92ea91..66cc15d95 100644
--- a/src/widget/singletree/singletree.combo.js
+++ b/src/widget/singletree/singletree.combo.js
@@ -10,7 +10,8 @@ import {
isEmptyArray,
isEmptyString,
isArray,
- contains, find
+ contains,
+ find
} from "@/core";
import { Combo } from "@/base";
import { SingleTreeTrigger } from "./singletree.trigger";
@@ -25,11 +26,7 @@ export class SingleTreeCombo extends Widget {
_defaultConfig(config) {
return extend(super._defaultConfig(...arguments), {
- baseCls:
- `bi-single-tree-combo ${
- config.simple
- ? "bi-border-bottom"
- : "bi-border bi-border-radius"}`,
+ baseCls: `bi-single-tree-combo ${config.simple ? "bi-border-bottom" : "bi-border bi-border-radius"}`,
trigger: {},
height: 24,
text: "",
diff --git a/src/widget/singletree/singletree.popup.js b/src/widget/singletree/singletree.popup.js
index 87438cb2f..65bcc5241 100644
--- a/src/widget/singletree/singletree.popup.js
+++ b/src/widget/singletree/singletree.popup.js
@@ -1,11 +1,4 @@
-import {
- shortcut,
- extend,
- i18nText,
- createWidget,
- Controller,
- isArray, VerticalLayout
-} from "@/core";
+import { shortcut, extend, i18nText, createWidget, Controller, isArray, VerticalLayout } from "@/core";
import { Pane } from "@/base";
import { LevelTree } from "@/case";
diff --git a/src/widget/singletree/singletree.trigger.js b/src/widget/singletree/singletree.trigger.js
index a328a147c..e7f4cc916 100644
--- a/src/widget/singletree/singletree.trigger.js
+++ b/src/widget/singletree/singletree.trigger.js
@@ -1,12 +1,4 @@
-import {
- shortcut,
- extend,
- emptyFn,
- createWidget,
- contains,
- isArray,
- some
-} from "@/core";
+import { shortcut, extend, emptyFn, createWidget, contains, isArray, some } from "@/core";
import { Trigger } from "@/base";
import { SelectTextTrigger } from "@/case";
diff --git a/src/widget/textvaluedownlistcombo/combo.textvaluedownlist.js b/src/widget/textvaluedownlistcombo/combo.textvaluedownlist.js
index 956e18552..97d4a3e94 100644
--- a/src/widget/textvaluedownlistcombo/combo.textvaluedownlist.js
+++ b/src/widget/textvaluedownlistcombo/combo.textvaluedownlist.js
@@ -1,99 +1,118 @@
-/**
- * @class BI.TextValueDownListCombo
- * @extend BI.Widget
- */
-BI.TextValueDownListCombo = BI.inherit(BI.Widget, {
- _defaultConfig: function (config) {
- return BI.extend(BI.TextValueDownListCombo.superclass._defaultConfig.apply(this, arguments), {
- baseCls: "bi-text-value-down-list-combo bi-border-radius " + (config.simple ? "bi-border-bottom" : "bi-border"),
+import { DownListSelectTextTrigger } from "./trigger.textvaluedownlist";
+import {
+ shortcut,
+ Widget,
+ extend,
+ isNotNull,
+ createWidget,
+ Selection,
+ toPix,
+ isNull,
+ deepClone,
+ each,
+ flatten,
+ has
+} from "@/core";
+import { DownListCombo } from "../downlist";
+
+@shortcut()
+export class TextValueDownListCombo extends Widget {
+ static xtype = "bi.text_value_down_list_combo";
+
+ static EVENT_CHANGE = "EVENT_CHANGE";
+
+ _defaultConfig(config) {
+ return extend(super._defaultConfig(...arguments), {
+ baseCls: `bi-text-value-down-list-combo bi-border-radius ${
+ config.simple ? "bi-border-bottom" : "bi-border"
+ }`,
height: 24,
});
- },
+ }
- _init: function () {
- var self = this, o = this.options;
- BI.TextValueDownListCombo.superclass._init.apply(this, arguments);
+ _init() {
+ const o = this.options;
+ super._init(...arguments);
this._createValueMap();
- var value;
- if(BI.isNotNull(o.value)) {
+ let value;
+ if (isNotNull(o.value)) {
value = this._digest(o.value);
}
- this.combo = BI.createWidget({
- type: "bi.down_list_combo",
+ this.combo = createWidget({
+ type: DownListCombo.xtype,
element: this,
- chooseType: BI.Selection.Single,
+ chooseType: Selection.Single,
adjustLength: 2,
- width: BI.toPix(o.width, 2),
- height: BI.toPix(o.height, 2),
+ width: toPix(o.width, 2),
+ height: toPix(o.height, 2),
el: {
- type: "bi.down_list_select_text_trigger",
- ref: function (_ref) {
- self.trigger = _ref;
+ type: DownListSelectTextTrigger.xtype,
+ ref: _ref => {
+ this.trigger = _ref;
},
cls: "text-value-down-list-trigger",
- height: BI.toPix(o.height, 2),
+ height: toPix(o.height, 2),
items: o.items,
text: o.text,
- value: value
+ value,
},
- value: BI.isNull(value) ? [] : [value],
- items: BI.deepClone(o.items)
+ value: isNull(value) ? [] : [value],
+ items: deepClone(o.items),
});
- this.combo.on(BI.DownListCombo.EVENT_CHANGE, function () {
- var currentVal = self.combo.getValue()[0].value;
- if (currentVal !== self.value) {
- self.setValue(currentVal);
- self.fireEvent(BI.TextValueDownListCombo.EVENT_CHANGE);
+ this.combo.on(DownListCombo.EVENT_CHANGE, () => {
+ const currentVal = this.combo.getValue()[0].value;
+ if (currentVal !== this.value) {
+ this.setValue(currentVal);
+ this.fireEvent(TextValueDownListCombo.EVENT_CHANGE);
}
});
- this.combo.on(BI.DownListCombo.EVENT_SON_VALUE_CHANGE, function () {
- var currentVal = self.combo.getValue()[0].childValue;
- if (currentVal !== self.value) {
- self.setValue(currentVal);
- self.fireEvent(BI.TextValueDownListCombo.EVENT_CHANGE);
+ this.combo.on(DownListCombo.EVENT_SON_VALUE_CHANGE, () => {
+ const currentVal = this.combo.getValue()[0].childValue;
+ if (currentVal !== this.value) {
+ this.setValue(currentVal);
+ this.fireEvent(TextValueDownListCombo.EVENT_CHANGE);
}
});
- },
+ }
- _createValueMap: function () {
- var self = this;
+ _createValueMap() {
this.valueMap = {};
- BI.each(BI.flatten(this.options.items), function (idx, item) {
- if (BI.has(item, "el")) {
- BI.each(item.children, function (id, it) {
- self.valueMap[it.value] = {value: item.el.value, childValue: it.value};
+ each(flatten(this.options.items), (idx, item) => {
+ if (has(item, "el")) {
+ each(item.children, (id, it) => {
+ this.valueMap[it.value] = { value: item.el.value, childValue: it.value };
});
} else {
- self.valueMap[item.value] = {value: item.value};
+ this.valueMap[item.value] = { value: item.value };
}
});
- },
+ }
- _digest: function (v) {
+ _digest(v) {
this.value = v;
+
return this.valueMap[v];
- },
+ }
- setValue: function (v) {
+ setValue(v) {
v = this._digest(v);
this.combo.setValue([v]);
this.trigger?.setValue(v);
- },
+ }
+
+ getValue() {
+ const v = this.combo.getValue()[0];
- getValue: function () {
- var v = this.combo.getValue()[0];
return [v.childValue || v.value];
- },
+ }
- populate: function (items) {
- this.options.items = BI.flatten(items);
+ populate(items) {
+ this.options.items = flatten(items);
this.combo.populate(items);
this._createValueMap();
}
-});
-BI.TextValueDownListCombo.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.text_value_down_list_combo", BI.TextValueDownListCombo);
+}
diff --git a/src/widget/textvaluedownlistcombo/index.js b/src/widget/textvaluedownlistcombo/index.js
new file mode 100644
index 000000000..740fc4bea
--- /dev/null
+++ b/src/widget/textvaluedownlistcombo/index.js
@@ -0,0 +1,2 @@
+export { TextValueDownListCombo } from "./combo.textvaluedownlist";
+export { DownListSelectTextTrigger } from "./trigger.textvaluedownlist";
diff --git a/src/widget/textvaluedownlistcombo/trigger.textvaluedownlist.js b/src/widget/textvaluedownlistcombo/trigger.textvaluedownlist.js
index b335ce5c1..31faad5e8 100644
--- a/src/widget/textvaluedownlistcombo/trigger.textvaluedownlist.js
+++ b/src/widget/textvaluedownlistcombo/trigger.textvaluedownlist.js
@@ -1,55 +1,54 @@
-/**
- * 选择字段trigger, downlist专用
- * 显示形式为 父亲值(儿子值)
- *
- * @class BI.DownListSelectTextTrigger
- * @extends BI.Trigger
- */
-BI.DownListSelectTextTrigger = BI.inherit(BI.Trigger, {
+import { shortcut, extend, createWidget, isNull, flatten, deepClone, each, has, concat } from "@/core";
+import { Trigger } from "@/base";
+import { SelectTextTrigger } from "@/case";
- _defaultConfig: function () {
- return BI.extend(BI.DownListSelectTextTrigger.superclass._defaultConfig.apply(this, arguments), {
+@shortcut()
+export class DownListSelectTextTrigger extends Trigger {
+ static xtype = "bi.down_list_select_text_trigger";
+
+ _defaultConfig() {
+ return extend(super._defaultConfig(...arguments), {
baseCls: "bi-down-list-select-text-trigger",
height: 24,
- text: ""
+ text: "",
});
- },
+ }
- _init: function () {
- BI.DownListSelectTextTrigger.superclass._init.apply(this, arguments);
- var o = this.options;
- this.trigger = BI.createWidget({
- type: "bi.select_text_trigger",
+ _init() {
+ super._init(...arguments);
+ const o = this.options;
+ this.trigger = createWidget({
+ type: SelectTextTrigger.xtype,
element: this,
height: o.height,
items: this._formatItemArray(o.items),
text: o.text,
- value: BI.isNull(o.value) ? "" : o.value.childValue || o.value.value
+ value: isNull(o.value) ? "" : o.value.childValue || o.value.value,
});
- },
+ }
- _formatItemArray: function () {
- var sourceArray = BI.flatten(BI.deepClone(this.options.items));
- var targetArray = [];
- BI.each(sourceArray, function (idx, item) {
- if(BI.has(item, "el")) {
- BI.each(item.children, function (id, it) {
- it.text = item.el.text + "(" + it.text + ")";
+ _formatItemArray() {
+ const sourceArray = flatten(deepClone(this.options.items));
+ let targetArray = [];
+ each(sourceArray, (idx, item) => {
+ if (has(item, "el")) {
+ each(item.children, (id, it) => {
+ it.text = `${item.el.text}(${it.text})`;
});
- targetArray = BI.concat(targetArray, item.children);
- }else{
+ targetArray = concat(targetArray, item.children);
+ } else {
targetArray.push(item);
}
});
+
return targetArray;
- },
+ }
- setValue: function (vals) {
+ setValue(vals) {
this.trigger.setValue(vals.childValue || vals.value);
- },
+ }
- populate: function (items) {
+ populate(items) {
this.trigger.populate(this._formatItemArray(items));
}
-});
-BI.shortcut("bi.down_list_select_text_trigger", BI.DownListSelectTextTrigger);
\ No newline at end of file
+}
diff --git a/src/widget/time/datetime.popup.js b/src/widget/time/datetime.popup.js
index 017b8c0eb..f70181e26 100644
--- a/src/widget/time/datetime.popup.js
+++ b/src/widget/time/datetime.popup.js
@@ -1,82 +1,107 @@
-import { shortcut, Widget, i18nText, CenterAdaptLayout, GridLayout, isNull, isEmptyObject, isEmptyString } from "@/core";
+import {
+ VTapeLayout,
+ shortcut,
+ Widget,
+ i18nText,
+ CenterAdaptLayout,
+ GridLayout,
+ isNull,
+ isEmptyObject,
+ isEmptyString
+} from "@/core";
import { TextButton } from "@/base";
import { DynamicDateTimeSelect } from "../dynamicdatetime";
@shortcut()
export class TimePopup extends Widget {
- static xtype = "bi.time_popup"
+ static xtype = "bi.time_popup";
props = {
baseCls: "bi-date-time-popup",
height: 68,
};
- static BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE"
- static BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE"
- static BUTTON_NOW_EVENT_CHANGE = "BUTTON_NOW_EVENT_CHANGE"
- static CALENDAR_EVENT_CHANGE = "CALENDAR_EVENT_CHANGE"
+ static BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE";
+ static BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE";
+ static BUTTON_NOW_EVENT_CHANGE = "BUTTON_NOW_EVENT_CHANGE";
+ static CALENDAR_EVENT_CHANGE = "CALENDAR_EVENT_CHANGE";
render() {
const o = this.options;
return {
- type: "bi.vtape",
- items: [{
- el: {
- type: CenterAdaptLayout.xtype,
- cls: "bi-split-top",
- items: [{
- type: DynamicDateTimeSelect.xtype,
- value: o.value,
- ref: _ref => {
- this.timeSelect = _ref;
- },
- }],
- },
- hgap: 10,
- height: 44,
- }, {
- el: {
- type: GridLayout.xtype,
- items: [
- [{
- type: TextButton.xtype,
- cls: "bi-high-light bi-split-top",
- shadow: true,
- text: i18nText("BI-Basic_Clears"),
- listeners: [{
- eventName: TextButton.EVENT_CHANGE,
- action: () => {
- this.fireEvent(TimePopup.BUTTON_CLEAR_EVENT_CHANGE);
+ type: VTapeLayout.xtype,
+ items: [
+ {
+ el: {
+ type: CenterAdaptLayout.xtype,
+ cls: "bi-split-top",
+ items: [
+ {
+ type: DynamicDateTimeSelect.xtype,
+ value: o.value,
+ ref: _ref => {
+ this.timeSelect = _ref;
},
- }],
- }, {
- type: TextButton.xtype,
- cls: "bi-split-left bi-split-right bi-high-light bi-split-top",
- shadow: true,
- text: i18nText("BI-Basic_Now"),
- listeners: [{
- eventName: TextButton.EVENT_CHANGE,
- action: () => {
- this.fireEvent(TimePopup.BUTTON_NOW_EVENT_CHANGE);
+ }
+ ],
+ },
+ hgap: 10,
+ height: 44,
+ },
+ {
+ el: {
+ type: GridLayout.xtype,
+ items: [
+ [
+ {
+ type: TextButton.xtype,
+ cls: "bi-high-light bi-split-top",
+ shadow: true,
+ text: i18nText("BI-Basic_Clears"),
+ listeners: [
+ {
+ eventName: TextButton.EVENT_CHANGE,
+ action: () => {
+ this.fireEvent(TimePopup.BUTTON_CLEAR_EVENT_CHANGE);
+ },
+ }
+ ],
},
- }],
- }, {
- type: TextButton.xtype,
- cls: "bi-high-light bi-split-top",
- shadow: true,
- text: i18nText("BI-Basic_OK"),
- listeners: [{
- eventName: TextButton.EVENT_CHANGE,
- action: () => {
- this.fireEvent(TimePopup.BUTTON_OK_EVENT_CHANGE);
+ {
+ type: TextButton.xtype,
+ cls: "bi-split-left bi-split-right bi-high-light bi-split-top",
+ shadow: true,
+ text: i18nText("BI-Basic_Now"),
+ listeners: [
+ {
+ eventName: TextButton.EVENT_CHANGE,
+ action: () => {
+ this.fireEvent(TimePopup.BUTTON_NOW_EVENT_CHANGE);
+ },
+ }
+ ],
},
- }],
- }]
- ],
- },
- height: 24,
- }],
+ {
+ type: TextButton.xtype,
+ cls: "bi-high-light bi-split-top",
+ shadow: true,
+ text: i18nText("BI-Basic_OK"),
+ listeners: [
+ {
+ eventName: TextButton.EVENT_CHANGE,
+ action: () => {
+ this.fireEvent(TimePopup.BUTTON_OK_EVENT_CHANGE);
+ },
+ }
+ ],
+ }
+ ]
+ ],
+ },
+ height: 24,
+ }
+ ],
};
}
diff --git a/src/widget/time/time.combo.js b/src/widget/time/time.combo.js
index 5cf7d74fe..f6375da3a 100644
--- a/src/widget/time/time.combo.js
+++ b/src/widget/time/time.combo.js
@@ -1,17 +1,27 @@
-import { shortcut, toPix, getDate, isNotEmptyString, isEqual, isEmptyString, AbsoluteLayout } from "@/core";
+import {
+ HorizontalFillLayout,
+ shortcut,
+ toPix,
+ getDate,
+ isNotEmptyString,
+ isEqual,
+ isEmptyString,
+ AbsoluteLayout
+} from "@/core";
+import { TimeTrigger } from "./time.trigger";
import { Single, IconButton, Combo } from "@/base";
import { TimePopup } from "./datetime.popup";
@shortcut()
export class TimeCombo extends Single {
- static xtype = "bi.time_combo"
+ static xtype = "bi.time_combo";
- static EVENT_KEY_DOWN = "EVENT_KEY_DOWN"
- static EVENT_CONFIRM = "EVENT_CONFIRM"
- static EVENT_CHANGE = "EVENT_CHANGE"
- static EVENT_VALID = "EVENT_VALID"
- static EVENT_ERROR = "EVENT_ERROR"
- static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"
+ static EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
+ static EVENT_CONFIRM = "EVENT_CONFIRM";
+ static EVENT_CHANGE = "EVENT_CHANGE";
+ static EVENT_VALID = "EVENT_VALID";
+ static EVENT_ERROR = "EVENT_ERROR";
+ static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
constants = {
popupHeight: 80,
@@ -19,7 +29,7 @@ export class TimeCombo extends Single {
comboAdjustHeight: 1,
border: 1,
iconWidth: 24,
- }
+ };
props = {
baseCls: "bi-time-combo",
@@ -40,169 +50,191 @@ export class TimeCombo extends Single {
this.storeValue = opts.value;
const popup = {
- type: "bi.time_popup",
+ type: TimePopup.xtype,
value: opts.value,
- listeners: [{
- eventName: TimePopup.BUTTON_CLEAR_EVENT_CHANGE,
- action: () => {
- this.setValue();
- this.hidePopupView();
- this.fireEvent(TimeCombo.EVENT_CONFIRM);
- },
- }, {
- eventName: TimePopup.BUTTON_OK_EVENT_CHANGE,
- action: () => {
- this.setValue(this.popup.getValue());
- this.hidePopupView();
- this.fireEvent(TimeCombo.EVENT_CONFIRM);
+ listeners: [
+ {
+ eventName: TimePopup.BUTTON_CLEAR_EVENT_CHANGE,
+ action: () => {
+ this.setValue();
+ this.hidePopupView();
+ this.fireEvent(TimeCombo.EVENT_CONFIRM);
+ },
},
- }, {
- eventName: TimePopup.BUTTON_NOW_EVENT_CHANGE,
- action: () => {
- this._setNowTime();
+ {
+ eventName: TimePopup.BUTTON_OK_EVENT_CHANGE,
+ action: () => {
+ this.setValue(this.popup.getValue());
+ this.hidePopupView();
+ this.fireEvent(TimeCombo.EVENT_CONFIRM);
+ },
},
- }],
+ {
+ eventName: TimePopup.BUTTON_NOW_EVENT_CHANGE,
+ action: () => {
+ this._setNowTime();
+ },
+ }
+ ],
ref: _ref => {
this.popup = _ref;
},
};
-
+
return {
type: AbsoluteLayout.xtype,
- items: [{
- el: {
- type: Combo.xtype,
- cls: "bi-border bi-border-radius",
- container: opts.container,
- toggle: false,
- isNeedAdjustHeight: opts.isNeedAdjustHeight,
- isNeedAdjustWidth: opts.isNeedAdjustWidth,
+ items: [
+ {
el: {
- type: "bi.horizontal_fill",
- columnSize: ["fill", this.constants.iconWidth],
- height: toPix(opts.height, 2),
- items: [{
- type: "bi.time_trigger",
+ type: Combo.xtype,
+ cls: "bi-border bi-border-radius",
+ container: opts.container,
+ toggle: false,
+ isNeedAdjustHeight: opts.isNeedAdjustHeight,
+ isNeedAdjustWidth: opts.isNeedAdjustWidth,
+ el: {
+ type: HorizontalFillLayout.xtype,
+ columnSize: ["fill", this.constants.iconWidth],
height: toPix(opts.height, 2),
- allowEdit: opts.allowEdit,
- watermark: opts.watermark,
- format: opts.format,
- value: opts.value,
- ref: _ref => {
- this.trigger = _ref;
- },
- listeners: [{
- eventName: "EVENT_KEY_DOWN",
- action: () => {
- if (this.combo.isViewVisible()) {
- this.combo.hideView();
- }
- this.fireEvent(TimeCombo.EVENT_KEY_DOWN, arguments);
- },
- }, {
- eventName: "EVENT_STOP",
- action: () => {
- if (!this.combo.isViewVisible()) {
- this.combo.showView();
- }
- },
- }, {
- eventName: "EVENT_FOCUS",
- action: () => {
- this.storeTriggerValue = this.trigger.getKey();
- if (!this.combo.isViewVisible()) {
- this.combo.showView();
- }
- this.fireEvent("EVENT_FOCUS");
- },
- }, {
- eventName: "EVENT_BLUR",
- action: () => {
- this.fireEvent("EVENT_BLUR");
- },
- }, {
- eventName: "EVENT_ERROR",
- action: () => {
- const date = getDate();
- this.storeValue = {
- hour: date.getHours(),
- minute: date.getMinutes(),
- second: date.getSeconds(),
- };
- this.fireEvent("EVENT_ERROR");
- },
- }, {
- eventName: "EVENT_VALID",
- action: () => {
- this.fireEvent("EVENT_VALID");
- },
- }, {
- eventName: "EVENT_CHANGE",
- action: () => {
- this.fireEvent("EVENT_CHANGE");
- },
- }, {
- eventName: "EVENT_CONFIRM",
- action: () => {
- if (this.combo.isViewVisible()) {
- return;
- }
- const dateStore = this.storeTriggerValue;
- const dateObj = this.trigger.getKey();
- if (isNotEmptyString(dateObj) && !isEqual(dateObj, dateStore)) {
- this.storeValue = this.trigger.getValue();
- this.setValue(this.trigger.getValue());
- } else if (isEmptyString(dateObj)) {
- this.storeValue = null;
- this.trigger.setValue();
- }
- this.fireEvent("EVENT_CONFIRM");
- },
- }],
- }, {
- el: {
- type: IconButton.xtype,
- cls: "bi-trigger-icon-button time-font",
- width: this.constants.iconWidth,
- listeners: [{
- eventName: IconButton.EVENT_CHANGE,
- action: () => {
- if (this.combo.isViewVisible()) {
- // this.combo.hideView();
- } else {
- this.combo.showView();
+ items: [
+ {
+ type: TimeTrigger.xtype,
+ height: toPix(opts.height, 2),
+ allowEdit: opts.allowEdit,
+ watermark: opts.watermark,
+ format: opts.format,
+ value: opts.value,
+ ref: _ref => {
+ this.trigger = _ref;
+ },
+ listeners: [
+ {
+ eventName: "EVENT_KEY_DOWN",
+ action: () => {
+ if (this.combo.isViewVisible()) {
+ this.combo.hideView();
+ }
+ this.fireEvent(TimeCombo.EVENT_KEY_DOWN, arguments);
+ },
+ },
+ {
+ eventName: "EVENT_STOP",
+ action: () => {
+ if (!this.combo.isViewVisible()) {
+ this.combo.showView();
+ }
+ },
+ },
+ {
+ eventName: "EVENT_FOCUS",
+ action: () => {
+ this.storeTriggerValue = this.trigger.getKey();
+ if (!this.combo.isViewVisible()) {
+ this.combo.showView();
+ }
+ this.fireEvent("EVENT_FOCUS");
+ },
+ },
+ {
+ eventName: "EVENT_BLUR",
+ action: () => {
+ this.fireEvent("EVENT_BLUR");
+ },
+ },
+ {
+ eventName: "EVENT_ERROR",
+ action: () => {
+ const date = getDate();
+ this.storeValue = {
+ hour: date.getHours(),
+ minute: date.getMinutes(),
+ second: date.getSeconds(),
+ };
+ this.fireEvent("EVENT_ERROR");
+ },
+ },
+ {
+ eventName: "EVENT_VALID",
+ action: () => {
+ this.fireEvent("EVENT_VALID");
+ },
+ },
+ {
+ eventName: "EVENT_CHANGE",
+ action: () => {
+ this.fireEvent("EVENT_CHANGE");
+ },
+ },
+ {
+ eventName: "EVENT_CONFIRM",
+ action: () => {
+ if (this.combo.isViewVisible()) {
+ return;
+ }
+ const dateStore = this.storeTriggerValue;
+ const dateObj = this.trigger.getKey();
+ if (isNotEmptyString(dateObj) && !isEqual(dateObj, dateStore)) {
+ this.storeValue = this.trigger.getValue();
+ this.setValue(this.trigger.getValue());
+ } else if (isEmptyString(dateObj)) {
+ this.storeValue = null;
+ this.trigger.setValue();
+ }
+ this.fireEvent("EVENT_CONFIRM");
+ },
}
+ ],
+ },
+ {
+ el: {
+ type: IconButton.xtype,
+ cls: "bi-trigger-icon-button time-font",
+ width: this.constants.iconWidth,
+ listeners: [
+ {
+ eventName: IconButton.EVENT_CHANGE,
+ action: () => {
+ if (this.combo.isViewVisible()) {
+ // this.combo.hideView();
+ } else {
+ this.combo.showView();
+ }
+ },
+ }
+ ],
+ ref: _ref => {
+ this.triggerBtn = _ref;
+ },
},
- }],
- ref: _ref => {
- this.triggerBtn = _ref;
+ }
+ ],
+ },
+ adjustLength: this.constants.comboAdjustHeight,
+ popup: {
+ el: popup,
+ width: opts.isNeedAdjustWidth ? opts.width : this.constants.popupWidth,
+ stopPropagation: false,
+ },
+ hideChecker: e => this.triggerBtn.element.find(e.target).length === 0,
+ listeners: [
+ {
+ eventName: Combo.EVENT_BEFORE_POPUPVIEW,
+ action: () => {
+ this.popup.setValue(this.storeValue);
+ this.fireEvent(TimeCombo.EVENT_BEFORE_POPUPVIEW);
},
- },
- }],
- },
- adjustLength: this.constants.comboAdjustHeight,
- popup: {
- el: popup,
- width: opts.isNeedAdjustWidth ? opts.width : this.constants.popupWidth,
- stopPropagation: false,
- },
- hideChecker: e => this.triggerBtn.element.find(e.target).length === 0,
- listeners: [{
- eventName: Combo.EVENT_BEFORE_POPUPVIEW,
- action: () => {
- this.popup.setValue(this.storeValue);
- this.fireEvent(TimeCombo.EVENT_BEFORE_POPUPVIEW);
+ }
+ ],
+ ref: _ref => {
+ this.combo = _ref;
},
- }],
- ref: _ref => {
- this.combo = _ref;
},
- },
- top: 0,
- left: 0,
- right: 0,
- bottom: 0,
- }],
+ top: 0,
+ left: 0,
+ right: 0,
+ bottom: 0,
+ }
+ ],
};
}
diff --git a/src/widget/time/time.trigger.js b/src/widget/time/time.trigger.js
index 2fc2b0751..526678025 100644
--- a/src/widget/time/time.trigger.js
+++ b/src/widget/time/time.trigger.js
@@ -1,15 +1,43 @@
-import { shortcut, i18nText, bind, isNotNull, isNotEmptyString, isEqual, AbsoluteLayout, any, print, parseDateTime, isEmptyObject, getDate, isNotEmptyObject } from "@/core";
+import {
+ shortcut,
+ i18nText,
+ bind,
+ isNotNull,
+ isNotEmptyString,
+ isEqual,
+ AbsoluteLayout,
+ any,
+ print,
+ parseDateTime,
+ isEmptyObject,
+ getDate,
+ isNotEmptyObject
+} from "@/core";
import { Trigger, Text } from "@/base";
import { SignEditor } from "@/case";
@shortcut()
export class TimeTrigger extends Trigger {
- static xtype = "bi.time_trigger"
+ static xtype = "bi.time_trigger";
_const = {
COMPARE_FORMAT: "%H:%M:%S",
COMPLETE_COMPARE_FORMAT: "%Y-%M-%d %H:%M:%S %P",
- FORMAT_ARRAY: ["%H:%M:%S", "%I:%M:%S", "%l:%M:%S", "%k:%M:%S", "%l:%M:%S %p", "%l:%M:%S %P", "%H:%M:%S %p", "%H:%M:%S %P", "%l:%M", "%k:%M", "%I:%M", "%H:%M", "%M:%S"],
+ FORMAT_ARRAY: [
+ "%H:%M:%S",
+ "%I:%M:%S",
+ "%l:%M:%S",
+ "%k:%M:%S",
+ "%l:%M:%S %p",
+ "%l:%M:%S %P",
+ "%H:%M:%S %p",
+ "%H:%M:%S %P",
+ "%l:%M",
+ "%k:%M",
+ "%I:%M",
+ "%H:%M",
+ "%M:%S"
+ ],
DEFAULT_DATE_STRING: "2000-01-01",
DEFAULT_HOUR: "00",
};
@@ -28,109 +56,132 @@ export class TimeTrigger extends Trigger {
const o = this.options;
this.storeTriggerValue = "";
this.storeValue = o.value;
-
+
return {
type: AbsoluteLayout.xtype,
- items: [{
- el: {
- type: SignEditor.xtype,
- height: o.height,
- validationChecker: v => this._dateCheck(v),
- quitChecker () {
- return false;
- },
- ref: _ref => {
- this.editor = _ref;
- },
- value: this._formatValue(o.value),
- hgap: 4,
- allowBlank: true,
- watermark: o.watermark,
- title: bind(this._getTitle, this),
- listeners: [{
- eventName: "EVENT_KEY_DOWN",
- action: (...args) => {
- this.fireEvent("EVENT_KEY_DOWN", ...args);
- },
- }, {
- eventName: "EVENT_FOCUS",
- action: () => {
- this.storeTriggerValue = this.getKey();
- this.fireEvent("EVENT_FOCUS");
- },
- }, {
- eventName: "EVENT_BLUR",
- action: () => {
- this.fireEvent("EVENT_BLUR");
+ items: [
+ {
+ el: {
+ type: SignEditor.xtype,
+ height: o.height,
+ validationChecker: v => this._dateCheck(v),
+ quitChecker() {
+ return false;
},
- }, {
- eventName: "EVENT_STOP",
- action: () => {
- this.fireEvent("EVENT_STOP");
+ ref: _ref => {
+ this.editor = _ref;
},
- }, {
- eventName: "EVENT_VALID",
- action: () => {
- this.fireEvent("EVENT_VALID");
- },
- }, {
- eventName: "EVENT_ERROR",
- action: () => {
- this.fireEvent("EVENT_ERROR");
- },
- }, {
- eventName: "EVENT_CONFIRM",
- action: () => {
- const value = this.editor.getValue();
- if (isNotNull(value)) {
- this.editor.setState(value);
+ value: this._formatValue(o.value),
+ hgap: 4,
+ allowBlank: true,
+ watermark: o.watermark,
+ title: bind(this._getTitle, this),
+ listeners: [
+ {
+ eventName: "EVENT_KEY_DOWN",
+ action: (...args) => {
+ this.fireEvent("EVENT_KEY_DOWN", ...args);
+ },
+ },
+ {
+ eventName: "EVENT_FOCUS",
+ action: () => {
+ this.storeTriggerValue = this.getKey();
+ this.fireEvent("EVENT_FOCUS");
+ },
+ },
+ {
+ eventName: "EVENT_BLUR",
+ action: () => {
+ this.fireEvent("EVENT_BLUR");
+ },
+ },
+ {
+ eventName: "EVENT_STOP",
+ action: () => {
+ this.fireEvent("EVENT_STOP");
+ },
+ },
+ {
+ eventName: "EVENT_VALID",
+ action: () => {
+ this.fireEvent("EVENT_VALID");
+ },
+ },
+ {
+ eventName: "EVENT_ERROR",
+ action: () => {
+ this.fireEvent("EVENT_ERROR");
+ },
+ },
+ {
+ eventName: "EVENT_CONFIRM",
+ action: () => {
+ const value = this.editor.getValue();
+ if (isNotNull(value)) {
+ this.editor.setState(value);
+ }
+ if (isNotEmptyString(value) && !isEqual(this.storeTriggerValue, this.getKey())) {
+ const date = value.match(/\d+/g);
+ this.storeValue = {
+ hour: date[0] | 0,
+ minute: date[1] | 0,
+ second: date[2] | 0,
+ };
+ }
+ this.fireEvent("EVENT_CONFIRM");
+ },
+ },
+ {
+ eventName: "EVENT_START",
+ action: () => {
+ this.fireEvent("EVENT_START");
+ },
+ },
+ {
+ eventName: "EVENT_CHANGE",
+ action: () => {
+ this.fireEvent("EVENT_CHANGE");
+ },
}
- if (isNotEmptyString(value) && !isEqual(this.storeTriggerValue, this.getKey())) {
- const date = value.match(/\d+/g);
- this.storeValue = {
- hour: date[0] | 0,
- minute: date[1] | 0,
- second: date[2] | 0,
- };
- }
- this.fireEvent("EVENT_CONFIRM");
- },
- }, {
- eventName: "EVENT_START",
- action: () => {
- this.fireEvent("EVENT_START");
- },
- }, {
- eventName: "EVENT_CHANGE",
- action: () => {
- this.fireEvent("EVENT_CHANGE");
- },
- }],
- },
- left: 0,
- right: 0,
- top: 0,
- bottom: 0,
- }, {
- el: {
- type: Text.xtype,
- invisible: o.allowEdit,
- cls: "show-text",
- title: bind(this._getTitle, this),
- hgap: 4,
+ ],
+ },
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0,
},
- left: 0,
- right: 0,
- top: 0,
- bottom: 0,
- }],
+ {
+ el: {
+ type: Text.xtype,
+ invisible: o.allowEdit,
+ cls: "show-text",
+ title: bind(this._getTitle, this),
+ hgap: 4,
+ },
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0,
+ }
+ ],
};
}
_dateCheck(date) {
const c = this._const;
-
- return any(c.FORMAT_ARRAY, (idx, format) => print(parseDateTime(`${c.DEFAULT_DATE_STRING} ${this._getCompleteHMS(date, format)}`, c.COMPLETE_COMPARE_FORMAT), format) === date);
+
+ return any(
+ c.FORMAT_ARRAY,
+ (idx, format) =>
+ print(
+ parseDateTime(
+ `${c.DEFAULT_DATE_STRING} ${this._getCompleteHMS(date, format)}`,
+ c.COMPLETE_COMPARE_FORMAT
+ ),
+ format
+ ) === date
+ );
}
_getCompleteHMS(str, format) {
@@ -142,7 +193,7 @@ export class TimeTrigger extends Trigger {
default:
break;
}
-
+
return str;
}
@@ -152,8 +203,11 @@ export class TimeTrigger extends Trigger {
return this.options.watermark;
}
const date = getDate();
-
- return print(getDate(date.getFullYear(), 0, 1, storeValue.hour, storeValue.minute, storeValue.second), this._getFormatString());
+
+ return print(
+ getDate(date.getFullYear(), 0, 1, storeValue.hour, storeValue.minute, storeValue.second),
+ this._getFormatString()
+ );
}
_getFormatString() {
@@ -162,8 +216,13 @@ export class TimeTrigger extends Trigger {
_formatValue(v) {
const now = getDate();
-
- return isNotEmptyObject(v) ? print(getDate(now.getFullYear(), now.getMonth(), now.getDay(), v.hour, v.minute, v.second), this._getFormatString()) : "";
+
+ return isNotEmptyObject(v)
+ ? print(
+ getDate(now.getFullYear(), now.getMonth(), now.getDay(), v.hour, v.minute, v.second),
+ this._getFormatString()
+ )
+ : "";
}
getKey() {
diff --git a/src/widget/timeinterval/dateinterval.js b/src/widget/timeinterval/dateinterval.js
index a591d4a4d..c2aee06f1 100644
--- a/src/widget/timeinterval/dateinterval.js
+++ b/src/widget/timeinterval/dateinterval.js
@@ -1,10 +1,21 @@
-import { shortcut, extend, createWidget, i18nText, print, parseDateTime, checkDateVoid, checkDateLegal, isNotNull } from "@/core";
+import {
+ HorizontalFillLayout,
+ shortcut,
+ extend,
+ createWidget,
+ i18nText,
+ print,
+ parseDateTime,
+ checkDateVoid,
+ checkDateLegal,
+ isNotNull
+} from "@/core";
import { Single, Label, Bubbles } from "@/base";
import { DynamicDateCombo } from "../dynamicdate";
@shortcut()
export class DateInterval extends Single {
- static xtype = "bi.date_interval"
+ static xtype = "bi.date_interval";
constants = {
height: 24,
@@ -14,15 +25,14 @@ export class DateInterval extends Single {
timeErrorCls: "time-error",
};
- static EVENT_VALID = "EVENT_VALID"
- static EVENT_ERROR = "EVENT_ERROR"
- static EVENT_CHANGE = "EVENT_CHANGE"
- static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW"
-
+ static EVENT_VALID = "EVENT_VALID";
+ static EVENT_ERROR = "EVENT_ERROR";
+ static EVENT_CHANGE = "EVENT_CHANGE";
+ static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW";
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
-
+
return extend(conf, {
extraCls: "bi-date-interval",
minDate: "1900-01-01",
@@ -39,23 +49,27 @@ export class DateInterval extends Single {
this.right = this._createCombo(o.value.end, o.watermark?.end);
return {
- type: "bi.horizontal_fill",
+ type: HorizontalFillLayout.xtype,
columnSize: ["fill", "", "fill"],
- items: [{
- el: this.left,
- }, {
- el: {
- type: Label.xtype,
- height: o.height,
- hgap: 5,
- text: "-",
- ref: _ref => {
- this.label = _ref;
+ items: [
+ {
+ el: this.left,
+ },
+ {
+ el: {
+ type: Label.xtype,
+ height: o.height,
+ hgap: 5,
+ text: "-",
+ ref: _ref => {
+ this.label = _ref;
+ },
},
},
- }, {
- el: this.right,
- }],
+ {
+ el: this.right,
+ }
+ ],
};
}
@@ -71,12 +85,14 @@ export class DateInterval extends Single {
watermark,
value: v,
height: o.height,
- listeners: [{
- eventName: DynamicDateCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW,
- action: () => {
- this.fireEvent(DateInterval.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
- },
- }],
+ listeners: [
+ {
+ eventName: DynamicDateCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW,
+ action: () => {
+ this.fireEvent(DateInterval.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
+ },
+ }
+ ],
});
combo.on(DynamicDateCombo.EVENT_ERROR, () => {
this._clearTitle();
@@ -138,42 +154,51 @@ export class DateInterval extends Single {
this.fireEvent(DateInterval.EVENT_CHANGE);
}
});
-
+
return combo;
}
_dateCheck(date) {
- return print(parseDateTime(date, "%Y-%x-%d"), "%Y-%x-%d") === date ||
+ return (
+ print(parseDateTime(date, "%Y-%x-%d"), "%Y-%x-%d") === date ||
print(parseDateTime(date, "%Y-%X-%d"), "%Y-%X-%d") === date ||
print(parseDateTime(date, "%Y-%x-%e"), "%Y-%x-%e") === date ||
- print(parseDateTime(date, "%Y-%X-%e"), "%Y-%X-%e") === date;
+ print(parseDateTime(date, "%Y-%X-%e"), "%Y-%X-%e") === date
+ );
}
_checkVoid(obj) {
const o = this.options;
-
+
return !checkDateVoid(obj.year, obj.month, obj.day, o.minDate, o.maxDate)[0];
}
_check(smallDate, bigDate) {
const smallObj = smallDate.match(/\d+/g),
bigObj = bigDate.match(/\d+/g);
-
- return this._dateCheck(smallDate) && checkDateLegal(smallDate) && this._checkVoid({
- year: smallObj[0],
- month: smallObj[1],
- day: smallObj[2],
- }) && this._dateCheck(bigDate) && checkDateLegal(bigDate) && this._checkVoid({
- year: bigObj[0],
- month: bigObj[1],
- day: bigObj[2],
- });
+
+ return (
+ this._dateCheck(smallDate) &&
+ checkDateLegal(smallDate) &&
+ this._checkVoid({
+ year: smallObj[0],
+ month: smallObj[1],
+ day: smallObj[2],
+ }) &&
+ this._dateCheck(bigDate) &&
+ checkDateLegal(bigDate) &&
+ this._checkVoid({
+ year: bigObj[0],
+ month: bigObj[1],
+ day: bigObj[2],
+ })
+ );
}
_compare(smallDate, bigDate) {
smallDate = print(parseDateTime(smallDate, "%Y-%X-%d"), "%Y-%X-%d");
bigDate = print(parseDateTime(bigDate, "%Y-%X-%d"), "%Y-%X-%d");
-
+
return isNotNull(smallDate) && isNotNull(bigDate) && smallDate > bigDate;
}
diff --git a/src/widget/timeinterval/timeinterval.js b/src/widget/timeinterval/timeinterval.js
index 23ca310e3..b1c9848c2 100644
--- a/src/widget/timeinterval/timeinterval.js
+++ b/src/widget/timeinterval/timeinterval.js
@@ -1,10 +1,21 @@
-import { shortcut, extend, createWidget, i18nText, print, parseDateTime, checkDateVoid, checkDateLegal, isNotNull } from "@/core";
+import {
+ HorizontalFillLayout,
+ shortcut,
+ extend,
+ createWidget,
+ i18nText,
+ print,
+ parseDateTime,
+ checkDateVoid,
+ checkDateLegal,
+ isNotNull
+} from "@/core";
import { Single, Label, Bubbles } from "@/base";
import { DynamicDateTimeCombo } from "../dynamicdatetime";
@shortcut()
export class TimeInterval extends Single {
- static xtype = "bi.time_interval"
+ static xtype = "bi.time_interval";
constants = {
height: 24,
@@ -14,13 +25,13 @@ export class TimeInterval extends Single {
timeErrorCls: "time-error",
};
- static EVENT_VALID = "EVENT_VALID"
- static EVENT_ERROR = "EVENT_ERROR"
- static EVENT_CHANGE = "EVENT_CHANGE"
+ static EVENT_VALID = "EVENT_VALID";
+ static EVENT_ERROR = "EVENT_ERROR";
+ static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
-
+
return extend(conf, {
extraCls: "bi-time-interval",
minDate: "1900-01-01",
@@ -37,23 +48,27 @@ export class TimeInterval extends Single {
this.right = this._createCombo(o.value.end, o.watermark?.end);
return {
- type: "bi.horizontal_fill",
+ type: HorizontalFillLayout.xtype,
columnSize: ["fill", "", "fill"],
- items: [{
- el: this.left,
- }, {
- el: {
- type: Label.xtype,
- height: o.height,
- hgap: 5,
- text: "-",
- ref: _ref => {
- this.label = _ref;
+ items: [
+ {
+ el: this.left,
+ },
+ {
+ el: {
+ type: Label.xtype,
+ height: o.height,
+ hgap: 5,
+ text: "-",
+ ref: _ref => {
+ this.label = _ref;
+ },
},
},
- }, {
- el: this.right,
- }],
+ {
+ el: this.right,
+ }
+ ],
};
}
@@ -81,7 +96,12 @@ export class TimeInterval extends Single {
Bubbles.hide("error");
const smallDate = this.left.getKey(),
bigDate = this.right.getKey();
- if (this.left.isValid() && this.right.isValid() && this._check(smallDate, bigDate) && this._compare(smallDate, bigDate)) {
+ if (
+ this.left.isValid() &&
+ this.right.isValid() &&
+ this._check(smallDate, bigDate) &&
+ this._compare(smallDate, bigDate)
+ ) {
this._setTitle(i18nText("BI-Time_Interval_Error_Text"));
this.element.addClass(this.constants.timeErrorCls);
Bubbles.show("error", i18nText("BI-Time_Interval_Error_Text"), this, {
@@ -98,7 +118,12 @@ export class TimeInterval extends Single {
Bubbles.hide("error");
const smallDate = this.left.getKey(),
bigDate = this.right.getKey();
- if (this.left.isValid() && this.right.isValid() && this._check(smallDate, bigDate) && this._compare(smallDate, bigDate)) {
+ if (
+ this.left.isValid() &&
+ this.right.isValid() &&
+ this._check(smallDate, bigDate) &&
+ this._compare(smallDate, bigDate)
+ ) {
this._setTitle(i18nText("BI-Time_Interval_Error_Text"));
this.element.addClass(this.constants.timeErrorCls);
Bubbles.show("error", i18nText("BI-Time_Interval_Error_Text"), this, {
@@ -121,7 +146,12 @@ export class TimeInterval extends Single {
Bubbles.hide("error");
const smallDate = this.left.getKey(),
bigDate = this.right.getKey();
- if (this.left.isValid() && this.right.isValid() && this._check(smallDate, bigDate) && this._compare(smallDate, bigDate)) {
+ if (
+ this.left.isValid() &&
+ this.right.isValid() &&
+ this._check(smallDate, bigDate) &&
+ this._compare(smallDate, bigDate)
+ ) {
this._setTitle(i18nText("BI-Time_Interval_Error_Text"));
this.element.addClass(this.constants.timeErrorCls);
this.fireEvent(TimeInterval.EVENT_ERROR);
@@ -131,42 +161,51 @@ export class TimeInterval extends Single {
this.fireEvent(TimeInterval.EVENT_CHANGE);
}
});
-
+
return combo;
}
_dateCheck(date) {
- return print(parseDateTime(date, "%Y-%x-%d %H:%M:%S"), "%Y-%x-%d %H:%M:%S") === date ||
+ return (
+ print(parseDateTime(date, "%Y-%x-%d %H:%M:%S"), "%Y-%x-%d %H:%M:%S") === date ||
print(parseDateTime(date, "%Y-%X-%d %H:%M:%S"), "%Y-%X-%d %H:%M:%S") === date ||
print(parseDateTime(date, "%Y-%x-%e %H:%M:%S"), "%Y-%x-%e %H:%M:%S") === date ||
- print(parseDateTime(date, "%Y-%X-%e %H:%M:%S"), "%Y-%X-%e %H:%M:%S") === date;
+ print(parseDateTime(date, "%Y-%X-%e %H:%M:%S"), "%Y-%X-%e %H:%M:%S") === date
+ );
}
_checkVoid(obj) {
const o = this.options;
-
+
return !checkDateVoid(obj.year, obj.month, obj.day, o.minDate, o.maxDate)[0];
}
_check(smallDate, bigDate) {
const smallObj = smallDate.match(/\d+/g),
bigObj = bigDate.match(/\d+/g);
-
- return this._dateCheck(smallDate) && checkDateLegal(smallDate) && this._checkVoid({
- year: smallObj[0],
- month: smallObj[1],
- day: smallObj[2],
- }) && this._dateCheck(bigDate) && checkDateLegal(bigDate) && this._checkVoid({
- year: bigObj[0],
- month: bigObj[1],
- day: bigObj[2],
- });
+
+ return (
+ this._dateCheck(smallDate) &&
+ checkDateLegal(smallDate) &&
+ this._checkVoid({
+ year: smallObj[0],
+ month: smallObj[1],
+ day: smallObj[2],
+ }) &&
+ this._dateCheck(bigDate) &&
+ checkDateLegal(bigDate) &&
+ this._checkVoid({
+ year: bigObj[0],
+ month: bigObj[1],
+ day: bigObj[2],
+ })
+ );
}
_compare(smallDate, bigDate) {
smallDate = print(parseDateTime(smallDate, "%Y-%X-%d %H:%M:%S"), "%Y-%X-%d %H:%M:%S");
bigDate = print(parseDateTime(bigDate, "%Y-%X-%d %H:%M:%S"), "%Y-%X-%d %H:%M:%S");
-
+
return isNotNull(smallDate) && isNotNull(bigDate) && smallDate > bigDate;
}
diff --git a/src/widget/timeinterval/timeperiods.js b/src/widget/timeinterval/timeperiods.js
index 1eb2cef6a..2c8d90a96 100644
--- a/src/widget/timeinterval/timeperiods.js
+++ b/src/widget/timeinterval/timeperiods.js
@@ -1,77 +1,90 @@
-import { shortcut, extend } from "@/core";
+import { HorizontalFillLayout, shortcut, extend } from "@/core";
import { Single, Label } from "@/base";
import { TimeCombo } from "../time";
@shortcut()
export class TimePeriods extends Single {
- static xtype = "bi.time_periods"
+ static xtype = "bi.time_periods";
props = {
extraCls: "bi-time-interval",
value: {},
};
- static EVENT_CONFIRM = "EVENT_CONFIRM"
- static EVENT_CHANGE = "EVENT_CHANGE"
-
+ static EVENT_CONFIRM = "EVENT_CONFIRM";
+ static EVENT_CHANGE = "EVENT_CHANGE";
render() {
const o = this.options;
return {
- type: "bi.horizontal_fill",
+ type: HorizontalFillLayout.xtype,
columnSize: ["fill", "", "fill"],
- items: [{
- el: extend({
- ref: _ref => {
- this.left = _ref;
- },
- }, this._createCombo(o.value.start, o.watermark?.start)),
- }, {
- el: {
- type: Label.xtype,
- height: o.height,
- hgap: 5,
- text: "-",
- ref: _ref => {
- this.label = _ref;
- },
+ items: [
+ {
+ el: extend(
+ {
+ ref: _ref => {
+ this.left = _ref;
+ },
+ },
+ this._createCombo(o.value.start, o.watermark?.start)
+ ),
},
- }, {
- el: extend({
- ref: _ref => {
- this.right = _ref;
+ {
+ el: {
+ type: Label.xtype,
+ height: o.height,
+ hgap: 5,
+ text: "-",
+ ref: _ref => {
+ this.label = _ref;
+ },
},
- }, this._createCombo(o.value.end, o.watermark?.end)),
- }],
+ },
+ {
+ el: extend(
+ {
+ ref: _ref => {
+ this.right = _ref;
+ },
+ },
+ this._createCombo(o.value.end, o.watermark?.end)
+ ),
+ }
+ ],
};
}
_createCombo(v, watermark) {
const o = this.options;
-
+
return {
type: TimeCombo.xtype,
value: v,
height: o.height,
watermark,
- listeners: [{
- eventName: TimeCombo.EVENT_BEFORE_POPUPVIEW,
- action: () => {
- this.left.hidePopupView();
- this.right.hidePopupView();
- },
- }, {
- eventName: TimeCombo.EVENT_CHANGE,
- action: () => {
- this.fireEvent(TimePeriods.EVENT_CHANGE);
+ listeners: [
+ {
+ eventName: TimeCombo.EVENT_BEFORE_POPUPVIEW,
+ action: () => {
+ this.left.hidePopupView();
+ this.right.hidePopupView();
+ },
},
- }, {
- eventName: TimeCombo.EVENT_CONFIRM,
- action: () => {
- this.fireEvent(TimePeriods.EVENT_CONFIRM);
+ {
+ eventName: TimeCombo.EVENT_CHANGE,
+ action: () => {
+ this.fireEvent(TimePeriods.EVENT_CHANGE);
+ },
},
- }],
+ {
+ eventName: TimeCombo.EVENT_CONFIRM,
+ action: () => {
+ this.fireEvent(TimePeriods.EVENT_CONFIRM);
+ },
+ }
+ ],
};
}
diff --git a/src/widget/year/card.dynamic.year.js b/src/widget/year/card.dynamic.year.js
index 8edcb0047..24949a579 100644
--- a/src/widget/year/card.dynamic.year.js
+++ b/src/widget/year/card.dynamic.year.js
@@ -1,3 +1,9 @@
+import { checkDateVoid, i18nText, isNotEmptyString, parseDateTime, shortcut, VerticalLayout, Widget } from "@/core";
+import { Bubbles, Label } from "@/base";
+import { DynamicDateCard } from "@/widget/dynamicdate/dynamicdate.card";
+import { DynamicDateHelper } from "@/widget/dynamicdate/dynamicdate.caculate";
+import { DynamicDateParamItem } from "@/widget/dynamicdate/dynamicdate.param.item";
+
/**
* 年份展示面板
*
@@ -5,9 +11,6 @@
* @class BI.YearCard
* @extends BI.Trigger
*/
-import { checkDateVoid, i18nText, isNotEmptyString, parseDateTime, shortcut, VerticalLayout, Widget } from "@/core";
-import { Bubbles, Label } from "@/base";
-import { DynamicDateCard, DynamicDateHelper, DynamicDateParamItem } from "@/widget";
@shortcut()
export class DynamicYearCard extends Widget {
@@ -15,35 +18,41 @@ export class DynamicYearCard extends Widget {
static EVENT_CHANGE = "EVENT_CHANGE";
props = {
baseCls: "bi-year-card",
- }
+ };
render() {
return {
type: VerticalLayout.xtype,
ref: _ref => {
this.wrapper = _ref;
},
- items: [{
- type: Label.xtype,
- text: i18nText("BI-Multi_Date_Relative_Current_Time"),
- textAlign: "left",
- height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
- }, {
- type: DynamicDateParamItem.xtype,
- ref: _ref => {
- this.item = _ref;
+ items: [
+ {
+ type: Label.xtype,
+ text: i18nText("BI-Multi_Date_Relative_Current_Time"),
+ textAlign: "left",
+ height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
},
- listeners: [{
- eventName: "EVENT_CHANGE",
- action: () => {
- this.fireEvent("EVENT_CHANGE");
- },
- }, {
- eventName: "EVENT_INPUT_CHANGE",
- action: () => {
- Bubbles.hide("dynamic-year-error");
+ {
+ type: DynamicDateParamItem.xtype,
+ ref: _ref => {
+ this.item = _ref;
},
- }],
- }],
+ listeners: [
+ {
+ eventName: "EVENT_CHANGE",
+ action: () => {
+ this.fireEvent("EVENT_CHANGE");
+ },
+ },
+ {
+ eventName: "EVENT_INPUT_CHANGE",
+ action: () => {
+ Bubbles.hide("dynamic-year-error");
+ },
+ }
+ ],
+ }
+ ],
vgap: 10,
hgap: 10,
};
@@ -67,10 +76,8 @@ export class DynamicYearCard extends Widget {
const o = this.options;
const start = parseDateTime(o.min, "%Y-%X-%d");
const end = parseDateTime(o.max, "%Y-%X-%d");
-
- return i18nText("BI-Basic_Year_Range_Error",
- start.getFullYear(),
- end.getFullYear());
+
+ return i18nText("BI-Basic_Year_Range_Error", start.getFullYear(), end.getFullYear());
}
setMinDate(minDate) {
@@ -92,9 +99,9 @@ export class DynamicYearCard extends Widget {
_getValue() {
const value = this.item.getValue();
-
+
return {
- year: (value.offset === 0 ? -value.value : +value.value),
+ year: value.offset === 0 ? -value.value : +value.value,
};
}
diff --git a/src/widget/year/card.year.js b/src/widget/year/card.year.js
index 2eb1149de..5af1fa99c 100644
--- a/src/widget/year/card.year.js
+++ b/src/widget/year/card.year.js
@@ -1,4 +1,20 @@
-import { shortcut, Widget, extend, createWidget, getDate, bind, Controller, isKey, HTapeLayout, CenterAdaptLayout, Layout, each, isNotEmptyString, checkDateVoid, parseInt } from "@/core";
+import {
+ shortcut,
+ Widget,
+ extend,
+ createWidget,
+ getDate,
+ bind,
+ Controller,
+ isKey,
+ HTapeLayout,
+ CenterAdaptLayout,
+ Layout,
+ each,
+ isNotEmptyString,
+ checkDateVoid,
+ parseInt
+} from "@/core";
import { YearCalendar } from "@/case";
import { IconButton, Navigation } from "@/base";
@@ -31,7 +47,7 @@ export class StaticYearCard extends Widget {
year: y + v * 12,
});
calendar.setValue(this._year);
-
+
return calendar;
}
@@ -49,10 +65,8 @@ export class StaticYearCard extends Widget {
listeners: [
{
eventName: IconButton.EVENT_CHANGE,
- action :() => {
- this.navigation.setSelect(
- this.navigation.getSelect() - 1
- );
+ action: () => {
+ this.navigation.setSelect(this.navigation.getSelect() - 1);
this._checkLeftValid();
this._checkRightValid();
},
@@ -69,10 +83,8 @@ export class StaticYearCard extends Widget {
listeners: [
{
eventName: IconButton.EVENT_CHANGE,
- action :() => {
- this.navigation.setSelect(
- this.navigation.getSelect() + 1
- );
+ action: () => {
+ this.navigation.setSelect(this.navigation.getSelect() + 1);
this._checkLeftValid();
this._checkRightValid();
},
@@ -136,14 +148,14 @@ export class StaticYearCard extends Widget {
_checkLeftValid() {
const valid = true;
this.backBtn.setEnable(valid);
-
+
return valid;
}
_checkRightValid() {
const valid = true;
this.preBtn.setEnable(valid);
-
+
return valid;
}
diff --git a/src/widget/year/combo.year.js b/src/widget/year/combo.year.js
index a2ef773b9..4ec9661bb 100644
--- a/src/widget/year/combo.year.js
+++ b/src/widget/year/combo.year.js
@@ -1,8 +1,8 @@
+import { IconButton, Combo } from "@/base";
import { shortcut, Widget, toPix, getDate, isNotNull, AbsoluteLayout, HorizontalFillLayout, extend } from "@/core";
import { DynamicYearTrigger } from "@/widget/year/trigger.year";
-import { DynamicDateCombo } from "@/widget";
-import { Combo } from "@/base";
import { DynamicYearPopup } from "@/widget/year/popup.year";
+import { DynamicDateCombo } from "@/widget/dynamicdate/dynamicdate.combo";
@shortcut()
export class DynamicYearCombo extends Widget {
@@ -12,18 +12,18 @@ export class DynamicYearCombo extends Widget {
static EVENT_ERROR = "EVENT_ERROR";
static EVENT_VALID = "EVENT_VALID";
static EVENT_FOCUS = "EVENT_FOCUS";
- _const ={
+ _const = {
iconWidth: 24,
- }
+ };
- props={
+ props = {
baseCls: "bi-year-combo",
behaviors: {},
minDate: "1900-01-01", // 最小日期
maxDate: "2099-12-31", // 最大日期
height: 24,
supportDynamic: true,
- }
+ };
_init() {
const o = this.options;
@@ -94,36 +94,41 @@ export class DynamicYearCombo extends Widget {
ref: _ref => {
this.popup = _ref;
},
- listeners: [{
- eventName: DynamicYearPopup.EVENT_CHANGE,
- action:() => {
- this.setValue(this.popup.getValue());
- this.combo.hideView();
- this.fireEvent(DynamicYearCombo.EVENT_CONFIRM);
- },
- }, {
- eventName: DynamicYearPopup.BUTTON_CLEAR_EVENT_CHANGE,
- action: () => {
- this.setValue();
- this.combo.hideView();
- this.fireEvent(DynamicYearCombo.EVENT_CONFIRM);
+ listeners: [
+ {
+ eventName: DynamicYearPopup.EVENT_CHANGE,
+ action: () => {
+ this.setValue(this.popup.getValue());
+ this.combo.hideView();
+ this.fireEvent(DynamicYearCombo.EVENT_CONFIRM);
+ },
},
- }, {
- eventName: DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE,
- action: () => {
- const date = getDate();
- this.setValue({ type: DynamicYearCombo.Static, value: { year: date.getFullYear() } });
- this.combo.hideView();
- this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
+ {
+ eventName: DynamicYearPopup.BUTTON_CLEAR_EVENT_CHANGE,
+ action: () => {
+ this.setValue();
+ this.combo.hideView();
+ this.fireEvent(DynamicYearCombo.EVENT_CONFIRM);
+ },
},
- }, {
- eventName: DynamicYearPopup.BUTTON_OK_EVENT_CHANGE,
- action: () => {
- this.setValue(this.popup.getValue());
- this.combo.hideView();
- this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
+ {
+ eventName: DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE,
+ action: () => {
+ const date = getDate();
+ this.setValue({ type: DynamicYearCombo.Static, value: { year: date.getFullYear() } });
+ this.combo.hideView();
+ this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
+ },
},
- }],
+ {
+ eventName: DynamicYearPopup.BUTTON_OK_EVENT_CHANGE,
+ action: () => {
+ this.setValue(this.popup.getValue());
+ this.combo.hideView();
+ this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
+ },
+ }
+ ],
behaviors: o.behaviors,
min: o.minDate,
max: o.maxDate,
@@ -141,31 +146,36 @@ export class DynamicYearCombo extends Widget {
BI.createWidget({
type: AbsoluteLayout.xtype,
element: this,
- items: [{
- el: {
- type: HorizontalFillLayout.xtype,
- columnSize: ["", "fill"],
- cls: `${o.simple ? "bi-border-bottom" : "bi-border bi-border-radius"} bi-focus-shadow`,
- ref: _ref => {
- this.comboWrapper = _ref;
- },
- items: [{
- el: {
- type: "bi.icon_button",
- cls: "bi-trigger-icon-button date-change-h-font",
- width: this._const.iconWidth,
- height: toPix(o.height, border),
- ref: _ref => {
- this.changeIcon = _ref;
- },
+ items: [
+ {
+ el: {
+ type: HorizontalFillLayout.xtype,
+ columnSize: ["", "fill"],
+ cls: `${o.simple ? "bi-border-bottom" : "bi-border bi-border-radius"} bi-focus-shadow`,
+ ref: _ref => {
+ this.comboWrapper = _ref;
},
- }, this.combo],
- },
- top: 0,
- left: 0,
- right: 0,
- bottom: 0,
- }],
+ items: [
+ {
+ el: {
+ type: IconButton.xtype,
+ cls: "bi-trigger-icon-button date-change-h-font",
+ width: this._const.iconWidth,
+ height: toPix(o.height, border),
+ ref: _ref => {
+ this.changeIcon = _ref;
+ },
+ },
+ },
+ this.combo
+ ],
+ },
+ top: 0,
+ left: 0,
+ right: 0,
+ bottom: 0,
+ }
+ ],
});
this._checkDynamicValue(o.value);
}
diff --git a/src/widget/year/index.js b/src/widget/year/index.js
index bc5810fe7..060417a74 100644
--- a/src/widget/year/index.js
+++ b/src/widget/year/index.js
@@ -1,5 +1,5 @@
-export { DynamicYearCard } from "./card.dynamic.year";
-export { StaticYearCard } from "./card.year";
-export { DynamicYearCombo } from "./combo.year";
-export { DynamicYearPopup } from "./popup.year";
-export { DynamicYearTrigger } from "./trigger.year";
+export { DynamicYearCard } from "./card.dynamic.year";
+export { StaticYearCard } from "./card.year";
+export { DynamicYearCombo } from "./combo.year";
+export { DynamicYearPopup } from "./popup.year";
+export { DynamicYearTrigger } from "./trigger.year";
diff --git a/src/widget/year/popup.year.js b/src/widget/year/popup.year.js
index 9ce8e1d9a..df9911766 100644
--- a/src/widget/year/popup.year.js
+++ b/src/widget/year/popup.year.js
@@ -1,7 +1,22 @@
-import { shortcut, Widget, toPix, i18nText, VerticalLayout, GridLayout, print, getDate, checkDateVoid, createItems } from "@/core";
+import {
+ shortcut,
+ Widget,
+ toPix,
+ i18nText,
+ VerticalLayout,
+ GridLayout,
+ print,
+ getDate,
+ checkDateVoid,
+ createItems
+} from "@/core";
import { TextButton, Tab } from "@/base";
-import { DynamicDateCombo, DynamicDateHelper, DynamicYearCard, DynamicYearCombo, StaticYearCard } from "@/widget";
import { LinearSegment } from "@/case";
+import { DynamicDateCombo } from "@/widget/dynamicdate/dynamicdate.combo";
+import { DynamicDateHelper } from "@/widget/dynamicdate/dynamicdate.caculate";
+import { DynamicYearCard } from "@/widget/year/card.dynamic.year";
+import { DynamicYearCombo } from "@/widget/year/combo.year";
+import { StaticYearCard } from "@/widget/year/card.year";
@shortcut()
export class DynamicYearPopup extends Widget {
@@ -24,7 +39,7 @@ export class DynamicYearPopup extends Widget {
render() {
this.storeValue = { type: DynamicYearCombo.Static };
-
+
return {
type: VerticalLayout.xtype,
items: [
@@ -39,29 +54,21 @@ export class DynamicYearPopup extends Widget {
{
type: TextButton.xtype,
cls: "bi-split-top bi-high-light",
- textHeight: toPix(
- BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
- 1
- ),
+ textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
shadow: true,
text: i18nText("BI-Basic_Clear"),
listeners: [
{
eventName: TextButton.EVENT_CHANGE,
- action :() => {
- this.fireEvent(
- DynamicYearPopup.BUTTON_CLEAR_EVENT_CHANGE
- );
+ action: () => {
+ this.fireEvent(DynamicYearPopup.BUTTON_CLEAR_EVENT_CHANGE);
},
}
],
},
{
type: TextButton.xtype,
- textHeight: toPix(
- BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
- 1
- ),
+ textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
cls: "bi-split-left bi-split-right bi-high-light bi-split-top",
shadow: true,
text: i18nText("BI-Basic_Current_Year"),
@@ -72,10 +79,8 @@ export class DynamicYearPopup extends Widget {
listeners: [
{
eventName: TextButton.EVENT_CHANGE,
- action :() => {
- this.fireEvent(
- DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE
- );
+ action: () => {
+ this.fireEvent(DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE);
},
}
],
@@ -83,32 +88,19 @@ export class DynamicYearPopup extends Widget {
{
type: TextButton.xtype,
cls: "bi-split-top bi-high-light",
- textHeight: toPix(
- BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
- 1
- ),
+ textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
shadow: true,
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(
- BI.DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE
- );
+ action: () => {
+ const type = this.dateTab.getSelect();
+ if (type === DynamicDateCombo.Dynamic) {
+ this.dynamicPane.checkValidation(true) &&
+ this.fireEvent(BI.DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE);
} else {
- this.fireEvent(
- DynamicYearPopup.BUTTON_OK_EVENT_CHANGE
- );
+ this.fireEvent(DynamicYearPopup.BUTTON_OK_EVENT_CHANGE);
}
},
}
@@ -128,9 +120,7 @@ export class DynamicYearPopup extends Widget {
this.yearButton.setValue(i18nText("BI-Basic_Current_Year"));
this.yearButton.setEnable(!this._checkYearValid());
} else {
- let date = DynamicDateHelper.getCalculation(
- this.dynamicPane.getInputValue()
- );
+ let date = DynamicDateHelper.getCalculation(this.dynamicPane.getInputValue());
date = print(date, "%Y");
this.yearButton.setValue(date);
this.yearButton.setEnable(false);
@@ -140,19 +130,13 @@ export class DynamicYearPopup extends Widget {
_checkYearValid() {
const o = this.options;
const today = getDate();
-
- return !!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() {
const o = this.options;
-
+
return {
type: Tab.xtype,
logic: {
@@ -192,7 +176,7 @@ export class DynamicYearPopup extends Widget {
listeners: [
{
eventName: "EVENT_CHANGE",
- action : () => {
+ action: () => {
this._setInnerValue(this.year, v);
},
}
@@ -212,9 +196,7 @@ export class DynamicYearPopup extends Widget {
{
eventName: StaticYearCard.EVENT_CHANGE,
action: () => {
- this.fireEvent(
- DynamicYearPopup.EVENT_CHANGE
- );
+ this.fireEvent(DynamicYearPopup.EVENT_CHANGE);
},
}
],
@@ -227,7 +209,7 @@ export class DynamicYearPopup extends Widget {
listeners: [
{
eventName: Tab.EVENT_CHANGE,
- action :() => {
+ action: () => {
const v = this.dateTab.getSelect();
switch (v) {
case DynamicYearCombo.Static: {
@@ -238,14 +220,8 @@ export class DynamicYearPopup extends Widget {
}
case DynamicYearCombo.Dynamic:
default:
- if (
- this.storeValue &&
- this.storeValue.type ===
- DynamicYearCombo.Dynamic
- ) {
- this.dynamicPane.setValue(
- this.storeValue.value
- );
+ if (this.storeValue && this.storeValue.type === DynamicYearCombo.Dynamic) {
+ this.dynamicPane.setValue(this.storeValue.value);
} else {
this.dynamicPane.setValue({
year: 0,
@@ -263,14 +239,8 @@ export class DynamicYearPopup extends Widget {
_checkTodayValid() {
const o = this.options;
const today = getDate();
-
- return !!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];
}
setMinDate(minDate) {
diff --git a/src/widget/year/trigger.year.js b/src/widget/year/trigger.year.js
index 17db67598..3d75124ed 100644
--- a/src/widget/year/trigger.year.js
+++ b/src/widget/year/trigger.year.js
@@ -1,7 +1,23 @@
-import { shortcut, extend, i18nText, bind, createWidget, isPositiveInteger, checkDateVoid, parseDateTime, isNotNull, isNotEmptyString, parseInt, print, getDate, HorizontalFillLayout } from "@/core";
+import {
+ shortcut,
+ extend,
+ i18nText,
+ bind,
+ createWidget,
+ isPositiveInteger,
+ checkDateVoid,
+ parseDateTime,
+ isNotNull,
+ isNotEmptyString,
+ parseInt,
+ print,
+ getDate,
+ HorizontalFillLayout
+} from "@/core";
import { Trigger, TextButton } from "@/base";
import { SignEditor, TriggerIconButton } from "@/case";
-import { DynamicDateCombo, DynamicDateHelper } from "@/widget";
+import { DynamicDateCombo } from "@/widget/dynamicdate/dynamicdate.combo";
+import { DynamicDateHelper } from "@/widget/dynamicdate/dynamicdate.caculate";
@shortcut()
export class DynamicYearTrigger extends Trigger {
@@ -41,26 +57,18 @@ export class DynamicYearTrigger extends Trigger {
type: SignEditor.xtype,
simple: o.simple,
height: o.height,
- validationChecker: v => (
- v === "" ||
- (isPositiveInteger(v) &&
- !checkDateVoid(v, 1, 1, o.min, o.max)[0])
- ),
+ validationChecker: v => v === "" || (isPositiveInteger(v) && !checkDateVoid(v, 1, 1, o.min, o.max)[0]),
quitChecker: () => false,
hgap: c.hgap,
vgap: c.vgap,
watermark: o.watermark,
allowBlank: true,
- errorText:v => {
+ errorText: v => {
if (isPositiveInteger(v)) {
const start = parseDateTime(o.min, "%Y-%X-%d");
const end = parseDateTime(o.max, "%Y-%X-%d");
- return i18nText(
- "BI-Basic_Year_Range_Error",
- start.getFullYear(),
- end.getFullYear()
- );
+ return i18nText("BI-Basic_Year_Range_Error", start.getFullYear(), end.getFullYear());
}
return i18nText("BI-Year_Trigger_Invalid_Text");
@@ -137,11 +145,9 @@ export class DynamicYearTrigger extends Trigger {
value +=
Math.abs(obj.year) +
i18nText("BI-Basic_Year") +
- (obj.year < 0
- ? i18nText("BI-Basic_Front")
- : i18nText("BI-Basic_Behind"));
+ (obj.year < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
}
-
+
return value;
}
@@ -158,7 +164,7 @@ export class DynamicYearTrigger extends Trigger {
if (!this.editor.isValid()) {
return "";
}
-
+
switch (type) {
case DynamicDateCombo.Dynamic: {
const text = this._getText(value);
@@ -166,13 +172,13 @@ export class DynamicYearTrigger extends Trigger {
date = DynamicDateHelper.getCalculation(value);
const dateStr = BI.print(date, "%Y");
- return BI.isEmptyString(text) ? dateStr : (`${text}:${dateStr}`);
+ return BI.isEmptyString(text) ? dateStr : `${text}:${dateStr}`;
}
-
+
case DynamicDateCombo.Static:
default:
value = value || {};
-
+
return value.year;
}
}
diff --git a/src/widget/yearinterval/yearinterval.js b/src/widget/yearinterval/yearinterval.js
index 952c655d4..42172300f 100644
--- a/src/widget/yearinterval/yearinterval.js
+++ b/src/widget/yearinterval/yearinterval.js
@@ -1,4 +1,14 @@
-import { shortcut, HorizontalFillLayout, createWidget, i18nText, print, parseDateTime, checkDateVoid, isNotNull, checkDateLegal } from "@/core";
+import {
+ shortcut,
+ HorizontalFillLayout,
+ createWidget,
+ i18nText,
+ print,
+ parseDateTime,
+ checkDateVoid,
+ isNotNull,
+ checkDateLegal
+} from "@/core";
import { Single, Label, Bubbles } from "@/base";
import { DynamicYearCombo } from "../year";
@@ -111,20 +121,17 @@ export class YearInterval extends Single {
this.fireEvent(YearInterval.EVENT_CHANGE);
}
});
-
+
return combo;
}
_dateCheck(date) {
- return (
- print(parseDateTime(date, "%Y"), "%Y") === date ||
- print(parseDateTime(date, "%Y"), "%Y") === date
- );
+ return print(parseDateTime(date, "%Y"), "%Y") === date || print(parseDateTime(date, "%Y"), "%Y") === date;
}
_checkVoid(obj) {
const o = this.options;
-
+
return !checkDateVoid(obj.year, 1, 1, o.minDate, o.maxDate)[0];
}
@@ -163,10 +170,8 @@ export class YearInterval extends Single {
_compare(smallDate, bigDate) {
smallDate = print(parseDateTime(smallDate, "%Y"), "%Y");
bigDate = print(parseDateTime(bigDate, "%Y"), "%Y");
-
- return (
- isNotNull(smallDate) && isNotNull(bigDate) && smallDate > bigDate
- );
+
+ return isNotNull(smallDate) && isNotNull(bigDate) && smallDate > bigDate;
}
_setTitle(v) {
@@ -189,14 +194,9 @@ export class YearInterval extends Single {
) {
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",
- }
- );
+ Bubbles.show("error", i18nText("BI-Time_Interval_Error_Text"), this, {
+ offsetStyle: "center",
+ });
this.fireEvent(YearInterval.EVENT_ERROR);
} else {
this._clearTitle();
diff --git a/src/widget/yearmonth/card.dynamic.yearmonth.js b/src/widget/yearmonth/card.dynamic.yearmonth.js
index 786b22a00..9b799caf4 100644
--- a/src/widget/yearmonth/card.dynamic.yearmonth.js
+++ b/src/widget/yearmonth/card.dynamic.yearmonth.js
@@ -1,166 +1,188 @@
-/**
- * 年月展示面板
- *
- * Created by GUY on 2015/9/2.
- * @class BI.YearCard
- * @extends BI.Trigger
- */
-BI.DynamicYearMonthCard = BI.inherit(BI.Widget, {
-
- props: {
- baseCls: "bi-year-month-card"
- },
-
- render: function () {
- var self = this;
+import {
+ shortcut,
+ Widget,
+ i18nText,
+ bind,
+ VerticalLayout,
+ parseDateTime,
+ extend,
+ checkDateVoid,
+ isNotEmptyString
+} from "@/core";
+import { DynamicDateCard, DynamicDateParamItem, DynamicDateHelper } from "../dynamicdate";
+import { Label, Bubbles } from "@/base";
+
+@shortcut()
+export class DynamicYearMonthCard extends Widget {
+ static xtype = "bi.dynamic_year_month_card";
+
+ static EVENT_CHANGE = "EVENT_CHANGE";
+
+ props = { baseCls: "bi-year-month-card" };
+
+ render() {
return {
- type: "bi.vertical",
- items: [{
- type: "bi.label",
- text: BI.i18nText("BI-Multi_Date_Relative_Current_Time"),
- textAlign: "left",
- height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
- }, {
- type: "bi.vertical",
- ref: function (_ref) {
- self.wrapper = _ref;
+ type: VerticalLayout.xtype,
+ items: [
+ {
+ type: Label.xtype,
+ text: i18nText("BI-Multi_Date_Relative_Current_Time"),
+ textAlign: "left",
+ height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
},
- items: [{
- el: {
- type: "bi.dynamic_date_param_item",
- validationChecker: BI.bind(self._checkDate, self),
- 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-month-error");
- }
- }]
- },
- bgap: 10,
- }, {
- type: "bi.dynamic_date_param_item",
- dateType: BI.DynamicDateCard.TYPE.MONTH,
- ref: function () {
- self.month = this;
+ {
+ type: VerticalLayout.xtype,
+ ref: _ref => {
+ this.wrapper = _ref;
},
- listeners: [{
- eventName: "EVENT_CHANGE",
- action: function () {
- self.fireEvent("EVENT_CHANGE");
- }
- }, {
- eventName: "EVENT_INPUT_CHANGE",
- action: function () {
- BI.Bubbles.hide("dynamic-year-month-error");
+ items: [
+ {
+ el: {
+ type: DynamicDateParamItem.xtype,
+ validationChecker: bind(this._checkDate, this),
+ ref: _ref => {
+ this.year = _ref;
+ },
+ listeners: [
+ {
+ eventName: "EVENT_CHANGE",
+ action: () => {
+ this.fireEvent("EVENT_CHANGE");
+ },
+ },
+ {
+ eventName: "EVENT_INPUT_CHANGE",
+ action: () => {
+ Bubbles.hide("dynamic-year-month-error");
+ },
+ }
+ ],
+ },
+ bgap: 10,
+ },
+ {
+ type: DynamicDateParamItem.xtype,
+ dateType: DynamicDateCard.TYPE.MONTH,
+ ref: _ref => {
+ this.month = _ref;
+ },
+ listeners: [
+ {
+ eventName: "EVENT_CHANGE",
+ action: () => {
+ this.fireEvent("EVENT_CHANGE");
+ },
+ },
+ {
+ eventName: "EVENT_INPUT_CHANGE",
+ action: () => {
+ Bubbles.hide("dynamic-year-month-error");
+ },
+ }
+ ],
}
- }]
- }]
- }],
+ ],
+ }
+ ],
vgap: 10,
- hgap: 10
+ hgap: 10,
};
- },
+ }
+
+ _getErrorText() {
+ const o = this.options;
+ const start = parseDateTime(o.min, "%Y-%X-%d");
+ const end = parseDateTime(o.max, "%Y-%X-%d");
- _getErrorText: function () {
- var o = this.options;
- var start = BI.parseDateTime(o.min, "%Y-%X-%d");
- var end = BI.parseDateTime(o.max, "%Y-%X-%d");
- return BI.i18nText("BI-Basic_Year_Month_Range_Error",
+ return i18nText(
+ "BI-Basic_Year_Month_Range_Error",
start.getFullYear(),
start.getMonth() + 1,
end.getFullYear(),
end.getMonth() + 1
);
- },
+ }
- _checkDate: function (obj) {
- var o = this.options;
- var date = BI.DynamicDateHelper.getCalculation(BI.extend(this._getValue(), this._digestDateTypeValue(obj)));
+ _checkDate(obj) {
+ const o = this.options;
+ 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) {
- var valueMap = {};
+ _digestDateTypeValue(value) {
+ const valueMap = {};
switch (value.dateType) {
- case BI.DynamicDateCard.TYPE.YEAR:
- valueMap.year = (value.offset === 0 ? -value.value : +value.value);
- break;
- case BI.DynamicDateCard.TYPE.MONTH:
- valueMap.month = (value.offset === 0 ? -value.value : +value.value);
- break;
- default:
- break;
+ case DynamicDateCard.TYPE.YEAR:
+ valueMap.year = value.offset === 0 ? -value.value : +value.value;
+ break;
+ case DynamicDateCard.TYPE.MONTH:
+ valueMap.month = value.offset === 0 ? -value.value : +value.value;
+ break;
+ default:
+ break;
}
+
return valueMap;
- },
+ }
- _createValue: function (type, v) {
+ _createValue(type, v) {
return {
dateType: type,
value: Math.abs(v),
- offset: v > 0 ? 1 : 0
+ offset: v > 0 ? 1 : 0,
};
- },
+ }
- setMinDate: function(minDate) {
- if (BI.isNotEmptyString(this.options.min)) {
+ setMinDate(minDate) {
+ if (isNotEmptyString(this.options.min)) {
this.options.min = minDate;
}
- },
+ }
- setMaxDate: function (maxDate) {
- if (BI.isNotEmptyString(this.options.max)) {
+ setMaxDate(maxDate) {
+ if (isNotEmptyString(this.options.max)) {
this.options.max = maxDate;
}
- },
+ }
+
+ setValue(v) {
+ v = v || { year: 0, month: 0 };
+ this.year.setValue(this._createValue(DynamicDateCard.TYPE.YEAR, v.year));
+ this.month.setValue(this._createValue(DynamicDateCard.TYPE.MONTH, v.month));
+ }
- setValue: function (v) {
- v = v || {year: 0, month: 0};
- this.year.setValue(this._createValue(BI.DynamicDateCard.TYPE.YEAR, v.year));
- this.month.setValue(this._createValue(BI.DynamicDateCard.TYPE.MONTH, v.month));
- },
+ _getValue() {
+ const year = this.year.getValue();
+ const month = this.month.getValue();
- _getValue: function () {
- var year = this.year.getValue();
- var month = this.month.getValue();
return {
- year: (year.offset === 0 ? -year.value : year.value),
- month: (month.offset === 0 ? -month.value : month.value)
+ year: year.offset === 0 ? -year.value : year.value,
+ month: month.offset === 0 ? -month.value : month.value,
};
- },
+ }
- getInputValue: function () {
+ getInputValue() {
return this._getValue();
- },
+ }
- getValue: function () {
+ getValue() {
return this.checkValidation() ? this._getValue() : {};
- },
+ }
- checkValidation: function (show) {
- var errorText;
- var yearInvalid = !this.year.checkValidation();
- var monthInvalid = !this.month.checkValidation();
- var invalid = yearInvalid || monthInvalid;
+ checkValidation(show) {
+ let errorText;
+ const yearInvalid = !this.year.checkValidation();
+ const monthInvalid = !this.month.checkValidation();
+ let invalid = yearInvalid || monthInvalid;
if (invalid) {
- errorText = BI.i18nText("BI-Please_Input_Natural_Number");
+ errorText = i18nText("BI-Please_Input_Natural_Number");
} else {
invalid = !this._checkDate(this._getValue());
errorText = this._getErrorText();
}
- invalid && show && BI.Bubbles.show("dynamic-year-month-error", errorText, this.wrapper);
+ invalid && show && Bubbles.show("dynamic-year-month-error", errorText, this.wrapper);
return !invalid;
- },
-});
-BI.DynamicYearMonthCard.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.dynamic_year_month_card", BI.DynamicYearMonthCard);
\ No newline at end of file
+ }
+}
diff --git a/src/widget/yearmonth/card.static.yearmonth.js b/src/widget/yearmonth/card.static.yearmonth.js
index 6ba4a94bc..d83de53c1 100644
--- a/src/widget/yearmonth/card.static.yearmonth.js
+++ b/src/widget/yearmonth/card.static.yearmonth.js
@@ -1,171 +1,209 @@
-BI.StaticYearMonthCard = BI.inherit(BI.Widget, {
+import {
+ shortcut,
+ Widget,
+ chunk,
+ map,
+ toPix,
+ extend,
+ VerticalLayout,
+ CenterAdaptLayout,
+ parseDateTime,
+ each,
+ checkDateVoid,
+ contains,
+ getDate,
+ parseInt
+} from "@/core";
+import { TextItem, ButtonGroup } from "@/base";
+import { YearPicker } from "../date/calendar";
- props: {
- baseCls: "bi-static-year-month-card",
- behaviors: {}
- },
+@shortcut()
+export class StaticYearMonthCard extends Widget {
+ static xtype = "bi.static_year_month_card";
- _createMonths: function () {
- var self = this;
+ static EVENT_CHANGE = "EVENT_CHANGE";
+
+ props = { baseCls: "bi-static-year-month-card", behaviors: {} };
+
+ _createMonths() {
// 纵向排列月
- var month = [1, 7, 2, 8, 3, 9, 4, 10, 5, 11, 6, 12];
- var items = BI.chunk(month, 2);
- return BI.map(items, function (i, item) {
- return BI.map(item, function (j, td) {
+ const month = [1, 7, 2, 8, 3, 9, 4, 10, 5, 11, 6, 12];
+ const items = chunk(month, 2);
+
+ return map(items, (i, item) =>
+ map(item, (j, td) => {
return {
- type: "bi.text_item",
+ type: TextItem.xtype,
cls: "bi-list-item-select",
textAlign: "center",
whiteSpace: "nowrap",
once: false,
forceSelected: true,
- height: BI.toPix(BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, 1),
+ height: toPix(BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, 1),
width: 38,
value: td,
text: td,
- ref: function (_ref) {
- self.monthMap[j === 0 ? i : i + 6] = _ref;
- }
+ ref: _ref => {
+ this.monthMap[j === 0 ? i : i + 6] = _ref;
+ },
};
- });
- });
- },
+ })
+ );
+ }
- render: function () {
- var self = this, o = this.options;
+ render() {
+ const o = this.options;
this.monthMap = {};
+
return {
- type: "bi.vertical",
- items: [{
- type: "bi.year_picker",
- cls: "bi-split-bottom",
- min: o.min,
- max: o.max,
- ref: function () {
- self.yearPicker = this;
- },
- behaviors: o.behaviors,
- height: 30,
- listeners: [{
- eventName: BI.YearPicker.EVENT_CHANGE,
- action: function () {
- var value = this.getValue();
- self._checkMonthStatus(value);
- self._setYear(value);
- }
- }]
- }, {
- el: {
- type: "bi.button_group",
- behaviors: o.behaviors,
- ref: function () {
- self.month = this;
+ type: VerticalLayout.xtype,
+ items: [
+ {
+ type: YearPicker.xtype,
+ cls: "bi-split-bottom",
+ min: o.min,
+ max: o.max,
+ ref: _ref => {
+ this.yearPicker = _ref;
},
- items: this._createMonths(),
- layouts: [BI.LogicFactory.createLogic("table", BI.extend({
- dynamic: true
- }, {
- columns: 2,
- rows: 6,
- columnSize: [1 / 2, 1 / 2],
- rowSize: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT + 1
- })), {
- type: "bi.center_adapt",
- vgap: 1,
- hgap: 2
- }],
- value: o.value,
- listeners: [{
- eventName: BI.ButtonGroup.EVENT_CHANGE,
- action: function () {
- self.selectedYear = self.yearPicker.getValue();
- self.selectedMonth = this.getValue()[0];
- self.fireEvent(BI.StaticYearMonthCard.EVENT_CHANGE);
+ behaviors: o.behaviors,
+ height: 30,
+ listeners: [
+ {
+ eventName: YearPicker.EVENT_CHANGE,
+ action: () => {
+ const value = this.yearPicker.getValue();
+ this._checkMonthStatus(value);
+ this._setYear(value);
+ },
}
- }]
+ ],
},
- vgap: 5
- }]
+ {
+ el: {
+ type: ButtonGroup.xtype,
+ behaviors: o.behaviors,
+ ref: _ref => {
+ this.month = _ref;
+ },
+ items: this._createMonths(),
+ layouts: [
+ BI.LogicFactory.createLogic(
+ "table",
+ extend(
+ {
+ dynamic: true,
+ },
+ {
+ columns: 2,
+ rows: 6,
+ columnSize: [1 / 2, 1 / 2],
+ rowSize: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT + 1,
+ }
+ )
+ ),
+ {
+ type: CenterAdaptLayout.xtype,
+ vgap: 1,
+ hgap: 2,
+ }
+ ],
+ value: o.value,
+ listeners: [
+ {
+ eventName: ButtonGroup.EVENT_CHANGE,
+ action: () => {
+ this.selectedYear = this.yearPicker.getValue();
+ this.selectedMonth = this.month.getValue()[0];
+ this.fireEvent(StaticYearMonthCard.EVENT_CHANGE);
+ },
+ }
+ ],
+ },
+ vgap: 5,
+ }
+ ],
};
- },
+ }
- created: function() {
+ created() {
this._checkMonthStatus(this.selectedYear);
- },
-
- _checkMonthStatus: function (year) {
- var o = this.options;
- var minDate = BI.parseDateTime(o.min, "%Y-%X-%d"), maxDate = BI.parseDateTime(o.max, "%Y-%X-%d");
- var minYear = minDate.getFullYear(), maxYear = maxDate.getFullYear();
- var minMonth = 0;
- var maxMonth = 11;
+ }
+
+ _checkMonthStatus(year) {
+ const o = this.options;
+ const minDate = parseDateTime(o.min, "%Y-%X-%d"),
+ maxDate = parseDateTime(o.max, "%Y-%X-%d");
+ const minYear = minDate.getFullYear(),
+ maxYear = maxDate.getFullYear();
+ let minMonth = 0;
+ let maxMonth = 11;
minYear === year && (minMonth = minDate.getMonth());
maxYear === year && (maxMonth = maxDate.getMonth());
- var yearInvalid = year < minYear || year > maxYear;
- BI.each(this.monthMap, function (month, obj) {
- var monthInvalid = month < minMonth || month > maxMonth;
+ const yearInvalid = year < minYear || year > maxYear;
+ each(this.monthMap, (month, obj) => {
+ const monthInvalid = month < minMonth || month > maxMonth;
obj.setEnable(!yearInvalid && !monthInvalid);
});
- },
+ }
+
+ _setYear(year) {
+ const o = this.options;
- _setYear: function (year) {
- var o = this.options;
-
- var dateVoid = BI.checkDateVoid(year, this.selectedMonth, 1, o.min, o.max);
+ const dateVoid = checkDateVoid(year, this.selectedMonth, 1, o.min, o.max);
// 在切换年的时候,如果月份不在区间内了,取消选中
- if (BI.contains(["y", "m"], dateVoid[0])) {
+ if (contains(["y", "m"], dateVoid[0])) {
this.selectedYear = year;
this.month.setValue();
+
return;
}
this.selectedYear = year;
this.month.setValue(this.selectedMonth);
- },
+ }
- setMinDate: function (minDate) {
+ setMinDate(minDate) {
if (this.options.min !== minDate) {
this.options.min = minDate;
this.yearPicker.setMinDate(minDate);
this._checkMonthStatus(this.selectedYear);
}
- },
+ }
- setMaxDate: function (maxDate) {
+ setMaxDate(maxDate) {
if (this.options.max !== maxDate) {
this.options.max = maxDate;
this.yearPicker.setMaxDate(maxDate);
this._checkMonthStatus(this.selectedYear);
}
- },
+ }
- getValue: function () {
+ getValue() {
return {
year: this.selectedYear,
- month: this.selectedMonth
+ month: this.selectedMonth,
};
- },
+ }
- setValue: function (obj) {
- var o = this.options;
- var newObj = {};
+ setValue(obj) {
+ const o = this.options;
+ const newObj = {};
newObj.year = obj.year || 0;
newObj.month = obj.month || 0;
- if (newObj.year === 0 || newObj.month === 0 || BI.checkDateVoid(newObj.year, newObj.month, 1, o.min, o.max)[0]) {
- var year = newObj.year || BI.getDate().getFullYear();
+ if (newObj.year === 0 || newObj.month === 0 || checkDateVoid(newObj.year, newObj.month, 1, o.min, o.max)[0]) {
+ const year = newObj.year || getDate().getFullYear();
this.selectedYear = year;
this.selectedMonth = "";
this.yearPicker.setValue(year);
this.month.setValue();
} else {
- this.selectedYear = BI.parseInt(newObj.year);
- this.selectedMonth = BI.parseInt(newObj.month);
+ this.selectedYear = parseInt(newObj.year);
+ this.selectedMonth = parseInt(newObj.month);
this.yearPicker.setValue(this.selectedYear);
this.month.setValue(this.selectedMonth);
}
this._checkMonthStatus(this.selectedYear);
}
-});
-BI.StaticYearMonthCard.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.static_year_month_card", BI.StaticYearMonthCard);
+}
diff --git a/src/widget/yearmonth/combo.yearmonth.js b/src/widget/yearmonth/combo.yearmonth.js
index 0fc8cab5c..55e0c24da 100644
--- a/src/widget/yearmonth/combo.yearmonth.js
+++ b/src/widget/yearmonth/combo.yearmonth.js
@@ -1,69 +1,98 @@
-BI.DynamicYearMonthCombo = BI.inherit(BI.Single, {
+import {
+ shortcut,
+ createWidget,
+ toPix,
+ isEqual,
+ isNotEmptyString,
+ getDate,
+ AbsoluteLayout,
+ HorizontalFillLayout,
+ isNotNull,
+ isNotEmptyObject,
+ checkDateVoid
+} from "@/core";
+import { Single, Combo, IconButton } from "@/base";
+import { DynamicYearMonthTrigger } from "./trigger.yearmonth";
+import { DynamicYearMonthPopup } from "./popup.yearmonth";
+import { DynamicDateCombo } from "../dynamicdate";
- props: {
+@shortcut()
+export class DynamicYearMonthCombo extends Single {
+ static xtype = "bi.dynamic_year_month_combo";
+
+ static EVENT_ERROR = "EVENT_ERROR";
+ static EVENT_VALID = "EVENT_VALID";
+ static EVENT_FOCUS = "EVENT_FOCUS";
+ static EVENT_CONFIRM = "EVENT_CONFIRM";
+ static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+
+ static Static = 1;
+ static Dynamic = 2;
+
+ props = {
baseCls: "bi-year-month-combo",
behaviors: {},
- minDate: "1900-01-01", // 最小日期
- maxDate: "2099-12-31", // 最大日期
+ minDate: "1900-01-01",
+ maxDate: "2099-12-31",
height: 24,
supportDynamic: true,
isNeedAdjustHeight: false,
- isNeedAdjustWidth: false
- },
+ isNeedAdjustWidth: false,
+ };
- _init: function () {
- var self = this, o = this.options;
- BI.DynamicYearMonthCombo.superclass._init.apply(this, arguments);
+ _init() {
+ const o = this.options;
+ super._init(...arguments);
this.storeValue = o.value;
this.storeTriggerValue = "";
- var border = o.simple ? 1 : 2;
- this.trigger = BI.createWidget({
- type: "bi.dynamic_year_month_trigger",
+ const border = o.simple ? 1 : 2;
+ this.trigger = createWidget({
+ type: DynamicYearMonthTrigger.xtype,
simple: o.simple,
min: o.minDate,
max: o.maxDate,
- height: BI.toPix(o.height, border),
+ height: toPix(o.height, border),
value: o.value || "",
watermark: o.watermark,
});
- this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_KEY_DOWN, function () {
- self.combo.isViewVisible() && self.combo.hideView();
+ this.trigger.on(DynamicYearMonthTrigger.EVENT_KEY_DOWN, () => {
+ this.combo.isViewVisible() && this.combo.hideView();
});
- this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_START, function () {
- self.combo.isViewVisible() && self.combo.hideView();
+ this.trigger.on(DynamicYearMonthTrigger.EVENT_START, () => {
+ this.combo.isViewVisible() && this.combo.hideView();
});
- this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_STOP, function () {
- self.combo.showView();
+ this.trigger.on(DynamicYearMonthTrigger.EVENT_STOP, () => {
+ this.combo.showView();
});
- this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_ERROR, function () {
- self.combo.isViewVisible() && self.combo.hideView();
- self.comboWrapper.element.addClass("error");
- self.fireEvent(BI.DynamicYearMonthCombo.EVENT_ERROR);
+ this.trigger.on(DynamicYearMonthTrigger.EVENT_ERROR, () => {
+ this.combo.isViewVisible() && this.combo.hideView();
+ this.comboWrapper.element.addClass("error");
+ this.fireEvent(DynamicYearMonthCombo.EVENT_ERROR);
});
- this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_VALID, function () {
- self.comboWrapper.element.removeClass("error");
- self.fireEvent(BI.DynamicYearMonthCombo.EVENT_VALID);
+ this.trigger.on(DynamicYearMonthTrigger.EVENT_VALID, () => {
+ this.comboWrapper.element.removeClass("error");
+ this.fireEvent(DynamicYearMonthCombo.EVENT_VALID);
});
- this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_CONFIRM, function () {
- var dateStore = self.storeTriggerValue;
- var dateObj = self.trigger.getKey();
- if (BI.isEqual(dateObj, dateStore)) {
+ this.trigger.on(DynamicYearMonthTrigger.EVENT_CONFIRM, () => {
+ const dateStore = this.storeTriggerValue;
+ const dateObj = this.trigger.getKey();
+ if (isEqual(dateObj, dateStore)) {
return;
}
- if (BI.isNotEmptyString(dateObj) && !BI.isEqual(dateObj, dateStore)) {
- self.storeValue = self.trigger.getValue();
- self.setValue(self.trigger.getValue());
+ if (isNotEmptyString(dateObj) && !isEqual(dateObj, dateStore)) {
+ this.storeValue = this.trigger.getValue();
+ this.setValue(this.trigger.getValue());
}
- self._checkDynamicValue(self.storeValue);
- self.fireEvent(BI.DynamicYearMonthCombo.EVENT_CONFIRM);
+ this._checkDynamicValue(this.storeValue);
+ this.fireEvent(DynamicYearMonthCombo.EVENT_CONFIRM);
});
- this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_FOCUS, function () {
- self.storeTriggerValue = self.trigger.getKey();
- self.fireEvent(BI.DynamicYearMonthCombo.EVENT_FOCUS);
+ this.trigger.on(DynamicYearMonthTrigger.EVENT_FOCUS, () => {
+ this.storeTriggerValue = this.trigger.getKey();
+ this.fireEvent(DynamicYearMonthCombo.EVENT_FOCUS);
});
- this.combo = BI.createWidget({
- type: "bi.combo",
+ this.combo = createWidget({
+ type: Combo.xtype,
container: o.container,
isNeedAdjustHeight: o.isNeedAdjustHeight,
isNeedAdjustWidth: o.isNeedAdjustWidth,
@@ -74,175 +103,171 @@ BI.DynamicYearMonthCombo = BI.inherit(BI.Single, {
minWidth: 100,
stopPropagation: false,
el: {
- type: "bi.dynamic_year_month_popup",
+ type: DynamicYearMonthPopup.xtype,
width: o.isNeedAdjustWidth ? o.width : undefined,
supportDynamic: o.supportDynamic,
- ref: function () {
- self.popup = this;
+ ref: _ref => {
+ this.popup = _ref;
},
listeners: [
{
- eventName: BI.DynamicYearMonthPopup.EVENT_CHANGE,
- action: function () {
- self.setValue(self.popup.getValue());
- self.combo.hideView();
- self.fireEvent(BI.DynamicYearMonthCombo.EVENT_CONFIRM);
- }
- }, {
- eventName: BI.DynamicYearMonthPopup.BUTTON_CLEAR_EVENT_CHANGE,
- action: function () {
- self.setValue();
- self.comboWrapper.element.removeClass("error");
- self.combo.hideView();
- self.fireEvent(BI.DynamicYearMonthCombo.EVENT_CONFIRM);
- }
- }, {
- eventName: BI.DynamicYearMonthPopup.BUTTON_lABEL_EVENT_CHANGE,
- action: function () {
- var date = BI.getDate();
- self.setValue({
- type: BI.DynamicYearMonthCombo.Static,
- value: { year: date.getFullYear(), month: date.getMonth() + 1 }
+ eventName: DynamicYearMonthPopup.EVENT_CHANGE,
+ action: () => {
+ this.setValue(this.popup.getValue());
+ this.combo.hideView();
+ this.fireEvent(DynamicYearMonthCombo.EVENT_CONFIRM);
+ },
+ },
+ {
+ eventName: DynamicYearMonthPopup.BUTTON_CLEAR_EVENT_CHANGE,
+ action: () => {
+ this.setValue();
+ this.comboWrapper.element.removeClass("error");
+ this.combo.hideView();
+ this.fireEvent(DynamicYearMonthCombo.EVENT_CONFIRM);
+ },
+ },
+ {
+ eventName: DynamicYearMonthPopup.BUTTON_lABEL_EVENT_CHANGE,
+ action: () => {
+ const date = getDate();
+ this.setValue({
+ type: DynamicYearMonthCombo.Static,
+ value: {
+ year: date.getFullYear(),
+ month: date.getMonth() + 1,
+ },
});
- self.combo.hideView();
- self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
- }
- }, {
- eventName: BI.DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE,
- action: function () {
- var value = self.popup.getValue();
- if (self._checkValue(value)) {
- self.setValue(value);
+ this.combo.hideView();
+ this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
+ },
+ },
+ {
+ eventName: DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE,
+ action: () => {
+ const value = this.popup.getValue();
+ if (this._checkValue(value)) {
+ this.setValue(value);
}
- self.combo.hideView();
- self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
- }
+ this.combo.hideView();
+ this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
+ },
}
],
behaviors: o.behaviors,
min: o.minDate,
- max: o.maxDate
+ max: o.maxDate,
},
- value: o.value || ""
- }
+ value: o.value || "",
+ },
});
- this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
- self.popup.setMinDate(o.minDate);
- self.popup.setMaxDate(o.maxDate);
- self.popup.setValue(self.storeValue);
- self.fireEvent(BI.DynamicYearMonthCombo.EVENT_BEFORE_POPUPVIEW);
+ this.combo.on(Combo.EVENT_BEFORE_POPUPVIEW, () => {
+ this.popup.setMinDate(o.minDate);
+ this.popup.setMaxDate(o.maxDate);
+ this.popup.setValue(this.storeValue);
+ this.fireEvent(DynamicYearMonthCombo.EVENT_BEFORE_POPUPVIEW);
});
- BI.createWidget({
- type: "bi.absolute",
+ createWidget({
+ type: AbsoluteLayout.xtype,
element: this,
items: [
{
el: {
- type: "bi.horizontal_fill",
+ type: HorizontalFillLayout.xtype,
columnSize: ["", "fill"],
- cls: (o.simple ? "bi-border-bottom" : "bi-border bi-border-radius") + " bi-focus-shadow",
- ref: function () {
- self.comboWrapper = this;
+ cls: `${o.simple ? "bi-border-bottom" : "bi-border bi-border-radius"} bi-focus-shadow`,
+ ref: _ref => {
+ this.comboWrapper = _ref;
},
items: [
{
el: {
- type: "bi.icon_button",
+ type: IconButton.xtype,
cls: "bi-trigger-icon-button date-change-h-font",
- width: BI.toPix(o.height, border),
- height: BI.toPix(o.height, border),
- ref: function () {
- self.changeIcon = this;
- }
- }
- }, this.combo
- ]
+ width: toPix(o.height, border),
+ height: toPix(o.height, border),
+ ref: _ref => {
+ this.changeIcon = _ref;
+ },
+ },
+ },
+ this.combo
+ ],
},
top: 0,
left: 0,
right: 0,
- bottom: 0
+ bottom: 0,
}
- ]
+ ],
});
this._checkDynamicValue(o.value);
- },
+ }
- _checkDynamicValue: function (v) {
- var type = null;
- if (BI.isNotNull(v)) {
+ _checkDynamicValue(v) {
+ let type = null;
+ if (isNotNull(v)) {
type = v.type;
}
switch (type) {
- case BI.DynamicYearMonthCombo.Dynamic:
- this.changeIcon.setVisible(true);
- break;
- default:
- this.changeIcon.setVisible(false);
- break;
+ case DynamicYearMonthCombo.Dynamic:
+ this.changeIcon.setVisible(true);
+ break;
+ default:
+ this.changeIcon.setVisible(false);
+ break;
}
- },
+ }
- _checkValue: function (v) {
- var o = this.options;
+ _checkValue(v) {
+ const o = this.options;
switch (v.type) {
- case BI.DynamicDateCombo.Dynamic:
- return BI.isNotEmptyObject(v.value);
- case BI.DynamicDateCombo.Static:
- var value = v.value || {};
-
- return !BI.checkDateVoid(value.year, value.month, 1, o.minDate, o.maxDate)[0];
- default:
- return true;
+ case DynamicDateCombo.Dynamic:
+ return isNotEmptyObject(v.value);
+ case DynamicDateCombo.Static: {
+ const value = v.value || {};
+
+ return !checkDateVoid(value.year, value.month, 1, o.minDate, o.maxDate)[0];
+ }
+ default:
+ return true;
}
- },
+ }
- setMinDate: function (minDate) {
- var o = this.options;
+ setMinDate(minDate) {
+ const o = this.options;
o.minDate = minDate;
this.trigger.setMinDate(minDate);
this.popup && this.popup.setMinDate(minDate);
- },
+ }
- setMaxDate: function (maxDate) {
- var o = this.options;
+ setMaxDate(maxDate) {
+ const o = this.options;
o.maxDate = maxDate;
this.trigger.setMaxDate(maxDate);
this.popup && this.popup.setMaxDate(maxDate);
- },
+ }
- hideView: function () {
+ hideView() {
this.combo.hideView();
- },
+ }
- setValue: function (v) {
+ setValue(v) {
this.storeValue = v;
this.trigger.setValue(v);
this._checkDynamicValue(v);
- },
+ }
- getValue: function () {
+ getValue() {
return this.storeValue;
- },
+ }
- getKey: function () {
+ getKey() {
return this.trigger.getKey();
- },
+ }
- isStateValid: function () {
+ isStateValid() {
return this.trigger.isStateValid();
}
-
-});
-BI.DynamicYearMonthCombo.EVENT_ERROR = "EVENT_ERROR";
-BI.DynamicYearMonthCombo.EVENT_VALID = "EVENT_VALID";
-BI.DynamicYearMonthCombo.EVENT_FOCUS = "EVENT_FOCUS";
-BI.DynamicYearMonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
-BI.DynamicYearMonthCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
-BI.shortcut("bi.dynamic_year_month_combo", BI.DynamicYearMonthCombo);
-
-BI.extend(BI.DynamicYearMonthCombo, {
- Static: 1,
- Dynamic: 2
-});
+}
diff --git a/src/widget/yearmonth/index.js b/src/widget/yearmonth/index.js
new file mode 100644
index 000000000..3ca4f52c1
--- /dev/null
+++ b/src/widget/yearmonth/index.js
@@ -0,0 +1,5 @@
+export { DynamicYearMonthCard } from "./card.dynamic.yearmonth";
+export { StaticYearMonthCard } from "./card.static.yearmonth";
+export { DynamicYearMonthCombo } from "./combo.yearmonth";
+export { DynamicYearMonthPopup } from "./popup.yearmonth";
+export { DynamicYearMonthTrigger } from "./trigger.yearmonth";
diff --git a/src/widget/yearmonth/popup.yearmonth.js b/src/widget/yearmonth/popup.yearmonth.js
index 1b80214d7..0366a9d3f 100644
--- a/src/widget/yearmonth/popup.yearmonth.js
+++ b/src/widget/yearmonth/popup.yearmonth.js
@@ -1,241 +1,288 @@
-/**
- * 年月
- *
- * Created by GUY on 2015/9/2.
- * @class BI.DynamicYearMonthPopup
- * @extends BI.Trigger
- */
-BI.DynamicYearMonthPopup = BI.inherit(BI.Widget, {
- constants: {
- tabHeight: 40,
- },
-
- props: {
+import {
+ shortcut,
+ Widget,
+ toPix,
+ i18nText,
+ VerticalLayout,
+ GridLayout,
+ print,
+ getDate,
+ checkDateVoid,
+ createItems
+} from "@/core";
+import { DynamicYearMonthCombo } from "./combo.yearmonth";
+import { TextButton, Tab } from "@/base";
+import { DynamicDateCombo, DynamicDateHelper } from "../dynamicdate";
+import { DynamicYearCombo } from "../year/combo.year";
+import { StaticYearMonthCard } from "./card.static.yearmonth";
+import { LinearSegment } from "@/case";
+import { DynamicYearMonthCard } from "./card.dynamic.yearmonth";
+
+//
+
+@shortcut()
+export class DynamicYearMonthPopup extends Widget {
+ static xtype = "bi.dynamic_year_month_popup";
+
+ constants = { tabHeight: 40 };
+ props = {
baseCls: "bi-year-month-popup",
behaviors: {},
- min: "1900-01-01", // 最小日期
- max: "2099-12-31", // 最大日期,
+ min: "1900-01-01",
+ max: "2099-12-31",
width: 180,
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() {
+ this.storeValue = { type: DynamicYearMonthCombo.Static };
- render: function () {
- var self = this, opts = this.options, c = this.constants;
- this.storeValue = {type: BI.DynamicYearMonthCombo.Static};
return {
- type: "bi.vertical",
- items: [{
- el: this._getTabJson()
- }, {
- el: {
- type: "bi.grid",
- items: [[{
- type: "bi.text_button",
- cls: "bi-split-top bi-high-light",
- textHeight: BI.toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
- shadow: true,
- text: BI.i18nText("BI-Basic_Clear"),
- listeners: [{
- eventName: BI.TextButton.EVENT_CHANGE,
- action: function () {
- self.fireEvent(BI.DynamicYearMonthPopup.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_Month"),
- disabled: this._checkTodayValid(),
- ref: function () {
- self.textButton = this;
- },
- listeners: [{
- eventName: BI.TextButton.EVENT_CHANGE,
- action: function () {
- self.fireEvent(BI.DynamicYearMonthPopup.BUTTON_lABEL_EVENT_CHANGE);
- }
- }]
- }, {
- type: "bi.text_button",
- cls: "bi-split-top bi-high-light",
- textHeight: BI.toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
- shadow: true,
- 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.DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE);
- } else {
- self.fireEvent(BI.DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE);
- }
- }
- }]
- }]],
- height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT
+ type: VerticalLayout.xtype,
+ items: [
+ {
+ el: this._getTabJson(),
},
- }]
+ {
+ el: {
+ type: GridLayout.xtype,
+ items: [
+ [
+ {
+ type: TextButton.xtype,
+ cls: "bi-split-top bi-high-light",
+ textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
+ shadow: true,
+ text: i18nText("BI-Basic_Clear"),
+ listeners: [
+ {
+ eventName: TextButton.EVENT_CHANGE,
+ action: () => {
+ this.fireEvent(DynamicYearMonthPopup.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_Month"),
+ disabled: this._checkTodayValid(),
+ ref: _ref => {
+ this.textButton = _ref;
+ },
+ listeners: [
+ {
+ eventName: TextButton.EVENT_CHANGE,
+ action: () => {
+ this.fireEvent(DynamicYearMonthPopup.BUTTON_lABEL_EVENT_CHANGE);
+ },
+ }
+ ],
+ },
+ {
+ type: TextButton.xtype,
+ cls: "bi-split-top bi-high-light",
+ textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
+ shadow: true,
+ 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(DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE);
+ } else {
+ this.fireEvent(DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE);
+ }
+ },
+ }
+ ],
+ }
+ ]
+ ],
+ height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
+ },
+ }
+ ],
};
- },
+ }
- _setInnerValue: function () {
- if (this.dateTab.getSelect() === BI.DynamicDateCombo.Static) {
- this.textButton.setValue(BI.i18nText("BI-Basic_Current_Month"));
+ _setInnerValue() {
+ if (this.dateTab.getSelect() === DynamicDateCombo.Static) {
+ this.textButton.setValue(i18nText("BI-Basic_Current_Month"));
this.textButton.setEnable(!this._checkTodayValid());
} else {
- var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getInputValue());
- date = BI.print(date, "%Y-%x");
+ let date = DynamicDateHelper.getCalculation(this.dynamicPane.getInputValue());
+ date = print(date, "%Y-%x");
this.textButton.setValue(date);
this.textButton.setEnable(false);
}
- },
+ }
- _checkTodayValid: function () {
- var o = this.options;
- var today = BI.getDate();
- return !!BI.checkDateVoid(today.getFullYear(), today.getMonth() + 1, today.getDate(), o.min, o.max)[0];
- },
+ _checkTodayValid() {
+ const o = this.options;
+ const today = getDate();
+
+ return !!checkDateVoid(today.getFullYear(), today.getMonth() + 1, today.getDate(), o.min, o.max)[0];
+ }
+
+ _getTabJson() {
+ const o = this.options;
- _getTabJson: function () {
- var self = this, o = this.options;
return {
- type: "bi.tab",
+ type: Tab.xtype,
logic: {
- dynamic: true
+ dynamic: true,
},
- ref: function () {
- self.dateTab = this;
+ ref: _ref => {
+ this.dateTab = _ref;
},
tab: {
- type: "bi.linear_segment",
+ type: LinearSegment.xtype,
cls: "bi-split-bottom",
invisible: !o.supportDynamic,
height: this.constants.tabHeight,
- items: BI.createItems([{
- text: BI.i18nText("BI-Basic_Year_Month"),
- value: BI.DynamicYearCombo.Static
- }, {
- text: BI.i18nText("BI-Basic_Dynamic_Title"),
- value: BI.DynamicYearCombo.Dynamic
- }], {
- textAlign: "center"
- })
+ items: createItems(
+ [
+ {
+ text: i18nText("BI-Basic_Year_Month"),
+ value: BI.DynamicYearCombo.Static,
+ },
+ {
+ text: i18nText("BI-Basic_Dynamic_Title"),
+ value: BI.DynamicYearCombo.Dynamic,
+ }
+ ],
+ {
+ textAlign: "center",
+ }
+ ),
},
- cardCreator: function (v) {
+ cardCreator: v => {
switch (v) {
- case BI.DynamicYearCombo.Dynamic:
- return {
- type: "bi.dynamic_year_month_card",
- cls: "dynamic-year-month-pane",
- min: self.options.min,
- max: self.options.max,
- listeners: [{
+ case BI.DynamicYearCombo.Dynamic:
+ return {
+ type: DynamicYearMonthCard.xtype,
+ cls: "dynamic-year-month-pane",
+ min: this.options.min,
+ max: this.options.max,
+ listeners: [
+ {
eventName: "EVENT_CHANGE",
- action: function () {
- self._setInnerValue(self.year, v);
- }
- }],
- ref: function () {
- self.dynamicPane = this;
+ action: () => {
+ this._setInnerValue(this.year, v);
+ },
}
- };
- case BI.DynamicYearCombo.Static:
- default:
- return {
- type: "bi.static_year_month_card",
- behaviors: o.behaviors,
- min: self.options.min,
- max: self.options.max,
- listeners: [{
- eventName: BI.StaticYearMonthCard.EVENT_CHANGE,
- action: function () {
- self.fireEvent(BI.DynamicYearMonthPopup.EVENT_CHANGE);
- }
- }],
- ref: function () {
- self.year = this;
+ ],
+ ref: _ref => {
+ this.dynamicPane = _ref;
+ },
+ };
+ case BI.DynamicYearCombo.Static:
+ default:
+ return {
+ type: StaticYearMonthCard.xtype,
+ behaviors: o.behaviors,
+ min: this.options.min,
+ max: this.options.max,
+ listeners: [
+ {
+ eventName: StaticYearMonthCard.EVENT_CHANGE,
+ action: () => {
+ this.fireEvent(DynamicYearMonthPopup.EVENT_CHANGE);
+ },
}
- };
+ ],
+ ref: _ref => {
+ this.year = _ref;
+ },
+ };
}
},
- listeners: [{
- eventName: BI.Tab.EVENT_CHANGE,
- action: function () {
- var v = self.dateTab.getSelect();
- switch (v) {
- case BI.DynamicYearCombo.Static:
- var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue());
- self.year.setValue({year: date.getFullYear(), month: date.getMonth() + 1});
- self._setInnerValue();
+ listeners: [
+ {
+ eventName: Tab.EVENT_CHANGE,
+ action: () => {
+ const v = this.dateTab.getSelect();
+ switch (v) {
+ case BI.DynamicYearCombo.Static: {
+ const date = DynamicDateHelper.getCalculation(this.dynamicPane.getValue());
+ this.year.setValue({
+ year: date.getFullYear(),
+ month: date.getMonth() + 1,
+ });
+ this._setInnerValue();
break;
+ }
case BI.DynamicYearCombo.Dynamic:
default:
- if(self.storeValue && self.storeValue.type === BI.DynamicYearCombo.Dynamic) {
- self.dynamicPane.setValue(self.storeValue.value);
- }else{
- self.dynamicPane.setValue({
- year: 0
+ if (this.storeValue && this.storeValue.type === BI.DynamicYearCombo.Dynamic) {
+ this.dynamicPane.setValue(this.storeValue.value);
+ } else {
+ this.dynamicPane.setValue({
+ year: 0,
});
}
- self._setInnerValue();
+ this._setInnerValue();
break;
- }
+ }
+ },
}
- }]
+ ],
};
- },
+ }
- setMinDate: function (minDate) {
+ setMinDate(minDate) {
if (this.options.min !== minDate) {
this.options.min = minDate;
this.year && this.year.setMinDate(minDate);
this.dynamicPane && this.dynamicPane.setMinDate(minDate);
}
- },
+ }
- setMaxDate: function (maxDate) {
+ setMaxDate(maxDate) {
if (this.options.max !== maxDate) {
this.options.max = maxDate;
this.year && this.year.setMaxDate(maxDate);
this.dynamicPane && this.dynamicPane.setMaxDate(maxDate);
}
- },
+ }
- setValue: function (v) {
+ setValue(v) {
this.storeValue = v;
- var self = this;
- var type, value;
v = v || {};
- type = v.type || BI.DynamicDateCombo.Static;
- value = v.value || v;
+ const type = v.type || DynamicDateCombo.Static;
+ const value = v.value || v;
+
this.dateTab.setSelect(type);
switch (type) {
- case BI.DynamicDateCombo.Dynamic:
- this.dynamicPane.setValue(value);
- self._setInnerValue();
- break;
- case BI.DynamicDateCombo.Static:
- default:
- this.year.setValue(value);
- this.textButton.setValue(BI.i18nText("BI-Basic_Current_Month"));
- this.textButton.setEnable(!this._checkTodayValid());
- break;
+ case DynamicDateCombo.Dynamic:
+ this.dynamicPane.setValue(value);
+ this._setInnerValue();
+ break;
+ case DynamicDateCombo.Static:
+ default:
+ this.year.setValue(value);
+ this.textButton.setValue(i18nText("BI-Basic_Current_Month"));
+ this.textButton.setEnable(!this._checkTodayValid());
+ break;
}
- },
+ }
- getValue: function () {
+ getValue() {
return {
type: this.dateTab.getSelect(),
- value: this.dateTab.getValue()
+ value: this.dateTab.getValue(),
};
}
-
-});
-BI.DynamicYearMonthPopup.BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE";
-BI.DynamicYearMonthPopup.BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE";
-BI.DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE";
-BI.DynamicYearMonthPopup.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.dynamic_year_month_popup", BI.DynamicYearMonthPopup);
\ No newline at end of file
+}
diff --git a/src/widget/yearmonth/trigger.yearmonth.js b/src/widget/yearmonth/trigger.yearmonth.js
index 7995a007b..d89fa5139 100644
--- a/src/widget/yearmonth/trigger.yearmonth.js
+++ b/src/widget/yearmonth/trigger.yearmonth.js
@@ -1,101 +1,158 @@
-BI.DynamicYearMonthTrigger = BI.inherit(BI.Trigger, {
- _const: {
- hgap: 4,
- vgap: 2,
- iconWidth: 24
- },
+import {
+ shortcut,
+ bind,
+ createWidget,
+ i18nText,
+ HTapeLayout,
+ CenterLayout,
+ HorizontalFillLayout,
+ isEmptyString,
+ parseDateTime,
+ isPositiveInteger,
+ checkDateVoid,
+ isNotEmptyString,
+ getDate,
+ print,
+ isNotNull,
+ checkDateLegal,
+ parseInt,
+ isNull
+} from "@/core";
+import { Trigger, TextButton } from "@/base";
+import { TriggerIconButton, SignEditor } from "@/case";
+import { DynamicDateCombo, DynamicDateHelper } from "../dynamicdate";
- props: () => ({
- extraCls: "bi-year-month-trigger",
- min: "1900-01-01", // 最小日期
- max: "2099-12-31", // 最大日期
- height: 24,
- watermark: {
- year: BI.i18nText("BI-Basic_Unrestricted"),
- month: BI.i18nText("BI-Basic_Unrestricted"),
- },
- }),
+@shortcut()
+export class DynamicYearMonthTrigger extends Trigger {
+ static xtype = "bi.dynamic_year_month_trigger";
- beforeInit: function (callback) {
- var o = this.options;
- o.title = BI.bind(this._titleCreator, this);
+ _const = { hgap: 4, vgap: 2, iconWidth: 24 };
+
+ static EVENT_VALID = "EVENT_VALID";
+ 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";
+
+ props() {
+ return {
+ extraCls: "bi-year-month-trigger",
+ min: "1900-01-01", // 最小日期
+ max: "2099-12-31", // 最大日期
+ height: 24,
+ watermark: {
+ year: i18nText("BI-Basic_Unrestricted"),
+ month: i18nText("BI-Basic_Unrestricted"),
+ },
+ };
+ }
+
+ beforeInit(callback) {
+ const o = this.options;
+ o.title = bind(this._titleCreator, this);
callback();
- },
+ }
- _init: function () {
- BI.DynamicYearMonthTrigger.superclass._init.apply(this, arguments);
- var o = this.options;
+ _init() {
+ super._init(...arguments);
+ const o = this.options;
this.yearEditor = this._createEditor(true);
this.monthEditor = this._createEditor(false);
- BI.createWidget({
+ createWidget({
element: this,
- type: "bi.htape",
- items: [{
- type: "bi.center",
- items: [{
- type: "bi.horizontal_fill",
- columnSize: ["fill", ""],
- items: [this.yearEditor, {
- el: {
- type: "bi.text_button",
- text: BI.i18nText("BI-Multi_Date_Year"),
+ type: HTapeLayout.xtype,
+ items: [
+ {
+ type: CenterLayout.xtype,
+ items: [
+ {
+ type: HorizontalFillLayout.xtype,
+ columnSize: ["fill", ""],
+ items: [
+ this.yearEditor,
+ {
+ el: {
+ type: TextButton.xtype,
+ text: i18nText("BI-Multi_Date_Year"),
+ },
+ }
+ ],
},
- }]
- }, {
- type: "bi.horizontal_fill",
- columnSize: ["fill", ""],
- items: [this.monthEditor, {
- el: {
- type: "bi.text_button",
- text: BI.i18nText("BI-Multi_Date_Month"),
- },
- }]
- }]
- }, {
- el: {
- type: "bi.trigger_icon_button",
- width: this._const.iconWidth
+ {
+ type: HorizontalFillLayout.xtype,
+ columnSize: ["fill", ""],
+ items: [
+ this.monthEditor,
+ {
+ el: {
+ type: TextButton.xtype,
+ text: i18nText("BI-Multi_Date_Month"),
+ },
+ }
+ ],
+ }
+ ],
},
- width: this._const.iconWidth
- }]
+ {
+ el: {
+ type: TriggerIconButton.xtype,
+ width: this._const.iconWidth,
+ },
+ width: this._const.iconWidth,
+ }
+ ],
});
this.setValue(o.value);
- },
+ }
- _createEditor: function (isYear) {
- var self = this, o = this.options, c = this._const;
- var editor = BI.createWidget({
- type: "bi.sign_editor",
+ _createEditor(isYear) {
+ const o = this.options,
+ c = this._const;
+ const editor = createWidget({
+ type: SignEditor.xtype,
simple: o.simple,
height: o.height,
- validationChecker: function (v) {
+ validationChecker: v => {
if (isYear) {
- var month = self.monthEditor.getValue();
- if(BI.isEmptyString(month)) {
- month = parseInt(v, 10) === BI.parseDateTime(o.min, "%Y-%X-%d").getFullYear() ? (BI.parseDateTime(o.min, "%Y-%X-%d").getMonth() + 1) : 1;
+ let month = this.monthEditor.getValue();
+ if (isEmptyString(month)) {
+ month =
+ parseInt(v, 10) === parseDateTime(o.min, "%Y-%X-%d").getFullYear()
+ ? parseDateTime(o.min, "%Y-%X-%d").getMonth() + 1
+ : 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 <= 12) && (BI.isEmptyString(year) ? true : !BI.checkDateVoid(self.yearEditor.getValue(), v, 1, o.min, o.max)[0]));
- },
- quitChecker: function () {
- return false;
+ return (
+ v === "" ||
+ (isPositiveInteger(v) &&
+ v >= 1 &&
+ v <= 12 &&
+ (isEmptyString(year)
+ ? true
+ : !checkDateVoid(this.yearEditor.getValue(), v, 1, o.min, o.max)[0]))
+ );
},
+ quitChecker: () => false,
watermark: isYear ? o.watermark?.year : o.watermark.month,
- errorText: function (v) {
- var year = isYear ? v : self.yearEditor.getValue();
- var month = isYear ? self.monthEditor.getValue() : v;
- if (!BI.isPositiveInteger(year) || !BI.isPositiveInteger(month) || month > 12) {
- return BI.i18nText("BI-Year_Trigger_Invalid_Text");
+ errorText: v => {
+ const year = isYear ? v : this.yearEditor.getValue();
+ const month = isYear ? this.monthEditor.getValue() : v;
+ if (!isPositiveInteger(year) || !isPositiveInteger(month) || month > 12) {
+ return i18nText("BI-Year_Trigger_Invalid_Text");
}
- var start = BI.parseDateTime(o.min, "%Y-%X-%d");
- var end = BI.parseDateTime(o.max, "%Y-%X-%d");
+ const start = parseDateTime(o.min, "%Y-%X-%d");
+ const end = parseDateTime(o.max, "%Y-%X-%d");
- return BI.i18nText("BI-Basic_Year_Month_Range_Error",
+ return i18nText(
+ "BI-Basic_Year_Month_Range_Error",
start.getFullYear(),
start.getMonth() + 1,
end.getFullYear(),
@@ -104,192 +161,202 @@ BI.DynamicYearMonthTrigger = BI.inherit(BI.Trigger, {
},
hgap: c.hgap,
vgap: c.vgap,
- allowBlank: true
+ allowBlank: true,
});
- editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () {
- self.fireEvent(BI.DynamicYearMonthTrigger.EVENT_KEY_DOWN);
+ editor.on(SignEditor.EVENT_KEY_DOWN, () => {
+ this.fireEvent(DynamicYearMonthTrigger.EVENT_KEY_DOWN);
});
- editor.on(BI.SignEditor.EVENT_FOCUS, function () {
- self.fireEvent(BI.DynamicYearMonthTrigger.EVENT_FOCUS);
+ editor.on(SignEditor.EVENT_FOCUS, () => {
+ this.fireEvent(DynamicYearMonthTrigger.EVENT_FOCUS);
});
- editor.on(BI.SignEditor.EVENT_STOP, function () {
- self.fireEvent(BI.DynamicYearMonthTrigger.EVENT_STOP);
+ editor.on(SignEditor.EVENT_STOP, () => {
+ this.fireEvent(DynamicYearMonthTrigger.EVENT_STOP);
});
- editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
- self._doEditorConfirm(editor);
- self.fireEvent(BI.DynamicYearMonthTrigger.EVENT_CONFIRM);
+ editor.on(SignEditor.EVENT_CONFIRM, () => {
+ this._doEditorConfirm(editor);
+ this.fireEvent(DynamicYearMonthTrigger.EVENT_CONFIRM);
});
- editor.on(BI.SignEditor.EVENT_SPACE, function () {
+ editor.on(SignEditor.EVENT_SPACE, () => {
if (editor.isValid()) {
editor.blur();
}
});
- editor.on(BI.SignEditor.EVENT_START, function () {
- self.fireEvent(BI.DynamicYearMonthTrigger.EVENT_START);
+ editor.on(SignEditor.EVENT_START, () => {
+ this.fireEvent(DynamicYearMonthTrigger.EVENT_START);
});
- editor.on(BI.SignEditor.EVENT_ERROR, function () {
- self.fireEvent(BI.DynamicYearMonthTrigger.EVENT_ERROR);
+ editor.on(SignEditor.EVENT_ERROR, () => {
+ this.fireEvent(DynamicYearMonthTrigger.EVENT_ERROR);
});
- editor.on(BI.SignEditor.EVENT_VALID, function () {
- var year = self.yearEditor.getValue();
- var month = self.monthEditor.getValue();
- if(BI.isNotEmptyString(year) && BI.isNotEmptyString(month)) {
- if(BI.isPositiveInteger(year) && month >= 1 && month <= 12 && !BI.checkDateVoid(year, month, 1, o.min, o.max)[0]) {
- self.fireEvent(BI.DynamicYearMonthTrigger.EVENT_VALID);
+ editor.on(SignEditor.EVENT_VALID, () => {
+ const year = this.yearEditor.getValue();
+ const month = this.monthEditor.getValue();
+ if (isNotEmptyString(year) && isNotEmptyString(month)) {
+ if (
+ isPositiveInteger(year) &&
+ month >= 1 &&
+ month <= 12 &&
+ !checkDateVoid(year, month, 1, o.min, o.max)[0]
+ ) {
+ this.fireEvent(DynamicYearMonthTrigger.EVENT_VALID);
}
}
});
- editor.on(BI.SignEditor.EVENT_CHANGE, function () {
- if(isYear) {
- self._autoSwitch(editor);
+ editor.on(SignEditor.EVENT_CHANGE, () => {
+ if (isYear) {
+ this._autoSwitch(editor);
}
});
return editor;
- },
+ }
- _titleCreator: function () {
- var storeValue = this.storeValue || {};
- var type = storeValue.type || BI.DynamicDateCombo.Static;
- var value = storeValue.value;
- if(!this.monthEditor.isValid() || !this.yearEditor.isValid()) {
+ _titleCreator() {
+ const storeValue = this.storeValue || {};
+ const type = storeValue.type || DynamicDateCombo.Static;
+ let value = storeValue.value;
+ if (!this.monthEditor.isValid() || !this.yearEditor.isValid()) {
return "";
}
switch (type) {
- case BI.DynamicDateCombo.Dynamic:
- var text = this._getText(value);
- var date = BI.getDate();
- date = BI.DynamicDateHelper.getCalculation(value);
- var dateStr = BI.print(date, "%Y-%x");
- return BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr);
- case BI.DynamicDateCombo.Static:
- default:
- value = value || {};
- return this._getStaticTitle(value);
+ case DynamicDateCombo.Dynamic: {
+ const text = this._getText(value);
+ let date = getDate();
+ date = DynamicDateHelper.getCalculation(value);
+ const dateStr = print(date, "%Y-%x");
+
+ return isEmptyString(text) ? dateStr : `${text}:${dateStr}`;
+ }
+ case DynamicDateCombo.Static:
+ default:
+ value = value || {};
+
+ return this._getStaticTitle(value);
}
- },
+ }
- _doEditorConfirm: function (editor) {
- var value = editor.getValue();
- if (BI.isNotNull(value)) {
+ _doEditorConfirm(editor) {
+ const value = editor.getValue();
+ if (isNotNull(value)) {
editor.setValue(value);
}
- var monthValue = this.monthEditor.getValue();
+ const monthValue = this.monthEditor.getValue();
this.storeValue = {
- type: BI.DynamicDateCombo.Static,
+ type: DynamicDateCombo.Static,
value: {
year: this.yearEditor.getValue(),
- month: BI.isEmptyString(this.monthEditor.getValue()) ? "" : monthValue
- }
+ month: isEmptyString(this.monthEditor.getValue()) ? "" : monthValue,
+ },
};
- },
+ }
- _yearCheck: function (v) {
- var date = BI.print(BI.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;
- },
+ _yearCheck(v) {
+ const date = print(parseDateTime(v, "%Y-%X-%d"), "%Y-%X-%d");
+
+ return print(parseDateTime(v, "%Y"), "%Y") === v && date >= this.options.min && date <= this.options.max;
+ }
- _autoSwitch: function (editor) {
- var v = editor.getValue();
- if (BI.isNotEmptyString(v) && BI.checkDateLegal(v)) {
+ _autoSwitch(editor) {
+ const v = editor.getValue();
+ if (isNotEmptyString(v) && checkDateLegal(v)) {
if (v.length === 4 && this._yearCheck(v)) {
this._doEditorConfirm(editor);
- this.fireEvent(BI.DynamicYearMonthTrigger.EVENT_CONFIRM);
+ this.fireEvent(DynamicYearMonthTrigger.EVENT_CONFIRM);
this.monthEditor.focus();
}
}
- },
+ }
- _getText: function (obj) {
- var value = "";
- if(BI.isNotNull(obj.year) && BI.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"));
+ _getText(obj) {
+ let value = "";
+ if (isNotNull(obj.year) && parseInt(obj.year) !== 0) {
+ value +=
+ Math.abs(obj.year) +
+ i18nText("BI-Basic_Year") +
+ (obj.year < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
}
- if(BI.isNotNull(obj.month) && BI.parseInt(obj.month) !== 0) {
- value += Math.abs(obj.month) + BI.i18nText("BI-Basic_Month") + (obj.month < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind"));
+ if (isNotNull(obj.month) && parseInt(obj.month) !== 0) {
+ value +=
+ Math.abs(obj.month) +
+ i18nText("BI-Basic_Month") +
+ (obj.month < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
}
+
return value;
- },
+ }
- _setInnerValue: function (date, text) {
+ _setInnerValue(date, text) {
this.yearEditor.setValue(date.getFullYear());
this.monthEditor.setValue(date.getMonth() + 1);
- },
+ }
- _getStaticTitle: function (value) {
+ _getStaticTitle(value) {
value = value || {};
- var hasYear = !(BI.isNull(value.year) || BI.isEmptyString(value.year));
- var hasMonth = !(BI.isNull(value.month) || BI.isEmptyString(value.month));
+ const hasYear = !(isNull(value.year) || isEmptyString(value.year));
+ const hasMonth = !(isNull(value.month) || isEmptyString(value.month));
switch ((hasYear << 1) | hasMonth) {
- // !hasYear && !hasMonth
- case 0:
- return "";
+ // !hasYear && !hasMonth
+ case 0:
+ return "";
// !hasYear && hasMonth
- case 1:
- return value.month;
+ case 1:
+ return value.month;
// hasYear && !hasMonth
- case 2:
- return value.year;
+ case 2:
+ return value.year;
// hasYear && hasMonth
- case 3:
- default:
- return value.year + "-" + value.month;
+ case 3:
+ default:
+ return `${value.year}-${value.month}`;
}
- },
+ }
- setMinDate: function (minDate) {
- if (BI.isNotEmptyString(this.options.min)) {
+ setMinDate(minDate) {
+ if (isNotEmptyString(this.options.min)) {
this.options.min = minDate;
}
- },
+ }
- setMaxDate: function (maxDate) {
- if (BI.isNotEmptyString(this.options.max)) {
+ setMaxDate(maxDate) {
+ if (isNotEmptyString(this.options.max)) {
this.options.max = maxDate;
}
- },
+ }
- setValue: function (v) {
- var type, value;
- var date = BI.getDate();
+ setValue(v) {
+ let type, value;
+ let date = getDate();
this.storeValue = v;
- if (BI.isNotNull(v)) {
- type = v.type || BI.DynamicDateCombo.Static;
+ if (isNotNull(v)) {
+ type = v.type || DynamicDateCombo.Static;
value = v.value || v;
}
switch (type) {
- case BI.DynamicDateCombo.Dynamic:
- var text = this._getText(value);
- date = BI.DynamicDateHelper.getCalculation(value);
- this._setInnerValue(date, text);
- break;
- case BI.DynamicDateCombo.Static:
- default:
- value = value || {};
- var month = BI.isNull(value.month) ? null : value.month;
- this.yearEditor.setValue(value.year);
- this.monthEditor.setValue(month);
- break;
+ case DynamicDateCombo.Dynamic: {
+ const text = this._getText(value);
+ date = DynamicDateHelper.getCalculation(value);
+ this._setInnerValue(date, text);
+ break;
+ }
+ case DynamicDateCombo.Static:
+ default: {
+ value = value || {};
+ const month = isNull(value.month) ? null : value.month;
+ this.yearEditor.setValue(value.year);
+ this.monthEditor.setValue(month);
+ break;
}
- },
+ }
+ }
- getValue: function () {
+ getValue() {
return this.storeValue;
- },
+ }
- getKey: function () {
- return this.yearEditor.getValue() + "-" + this.monthEditor.getValue();
- },
+ getKey() {
+ return `${this.yearEditor.getValue()}-${this.monthEditor.getValue()}`;
+ }
- isStateValid: function () {
+ isStateValid() {
return this.yearEditor.isValid() && this.monthEditor.isValid();
}
-});
-BI.DynamicYearMonthTrigger.EVENT_VALID = "EVENT_VALID";
-BI.DynamicYearMonthTrigger.EVENT_FOCUS = "EVENT_FOCUS";
-BI.DynamicYearMonthTrigger.EVENT_ERROR = "EVENT_ERROR";
-BI.DynamicYearMonthTrigger.EVENT_START = "EVENT_START";
-BI.DynamicYearMonthTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
-BI.DynamicYearMonthTrigger.EVENT_STOP = "EVENT_STOP";
-BI.DynamicYearMonthTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
-BI.shortcut("bi.dynamic_year_month_trigger", BI.DynamicYearMonthTrigger);
+}
diff --git a/src/widget/yearmonthinterval/yearmonthinterval.js b/src/widget/yearmonthinterval/yearmonthinterval.js
index 814123f67..e5736aa85 100644
--- a/src/widget/yearmonthinterval/yearmonthinterval.js
+++ b/src/widget/yearmonthinterval/yearmonthinterval.js
@@ -1,188 +1,234 @@
-BI.YearMonthInterval = BI.inherit(BI.Single, {
- constants: {
+import {
+ shortcut,
+ HorizontalFillLayout,
+ createWidget,
+ i18nText,
+ print,
+ parseDateTime,
+ checkDateVoid,
+ isNotNull,
+ checkDateLegal
+} from "@/core";
+import { Single, Label, Bubbles } from "@/base";
+import { DynamicYearMonthCombo } from "../yearmonth/combo.yearmonth";
+
+@shortcut()
+export class YearMonthInterval extends Single {
+ static xtype = "bi.year_month_interval";
+
+ static EVENT_VALID = "EVENT_VALID";
+ static EVENT_ERROR = "EVENT_ERROR";
+ static EVENT_CHANGE = "EVENT_CHANGE";
+ static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+
+ constants = {
width: 25,
lgap: 15,
offset: -15,
- timeErrorCls: "time-error"
- },
-
- props: {
+ timeErrorCls: "time-error",
+ };
+ props = {
extraCls: "bi-year-month-interval",
minDate: "1900-01-01",
maxDate: "2099-12-31",
supportDynamic: true,
- height: 24
- },
+ height: 24,
+ };
- render: function () {
- var self = this, o = this.options;
+ render() {
+ const o = this.options;
o.value = o.value || {};
this.left = this._createCombo(o.value.start, o.watermark?.start);
this.right = this._createCombo(o.value.end, o.watermark?.end);
-
+
return {
- type: "bi.horizontal_fill",
+ type: HorizontalFillLayout.xtype,
columnSize: ["fill", "", "fill"],
- items: [{
- el: self.left
- }, {
- el: {
- type: "bi.label",
- height: o.height,
- hgap: 5,
- text: "-",
- ref: function (_ref) {
- self.label = _ref;
- }
+ items: [
+ {
+ el: this.left,
+ },
+ {
+ el: {
+ type: Label.xtype,
+ height: o.height,
+ hgap: 5,
+ text: "-",
+ ref: _ref => {
+ this.label = _ref;
+ },
+ },
+ },
+ {
+ el: this.right,
}
- }, {
- el: self.right
- }]
+ ],
};
- },
+ }
- _createCombo: function (v, watermark) {
- var self = this, o = this.options;
- var combo = BI.createWidget({
- type: "bi.dynamic_year_month_combo",
+ _createCombo(v, watermark) {
+ const o = this.options;
+ const combo = createWidget({
+ type: DynamicYearMonthCombo.xtype,
supportDynamic: o.supportDynamic,
height: o.height,
minDate: o.minDate,
maxDate: o.maxDate,
behaviors: o.behaviors,
value: v,
- watermark: watermark,
- listeners: [{
- eventName: BI.DynamicYearMonthCombo.EVENT_BEFORE_POPUPVIEW,
- action: function () {
- self.fireEvent(BI.YearMonthInterval.EVENT_BEFORE_POPUPVIEW);
+ watermark,
+ listeners: [
+ {
+ eventName: DynamicYearMonthCombo.EVENT_BEFORE_POPUPVIEW,
+ action: () => {
+ this.fireEvent(YearMonthInterval.EVENT_BEFORE_POPUPVIEW);
+ },
}
- }]
+ ],
});
- combo.on(BI.DynamicYearMonthCombo.EVENT_ERROR, function () {
- self._clearTitle();
- BI.Bubbles.hide("error");
- self.element.removeClass(self.constants.timeErrorCls);
- self.fireEvent(BI.YearMonthInterval.EVENT_ERROR);
+ combo.on(DynamicYearMonthCombo.EVENT_ERROR, () => {
+ this._clearTitle();
+ Bubbles.hide("error");
+ this.element.removeClass(this.constants.timeErrorCls);
+ this.fireEvent(YearMonthInterval.EVENT_ERROR);
});
- combo.on(BI.DynamicYearMonthCombo.EVENT_VALID, function () {
- self._checkValid();
+ combo.on(DynamicYearMonthCombo.EVENT_VALID, () => {
+ this._checkValid();
});
- combo.on(BI.DynamicYearMonthCombo.EVENT_FOCUS, function () {
- self._checkValid();
+ combo.on(DynamicYearMonthCombo.EVENT_FOCUS, () => {
+ this._checkValid();
});
- combo.on(BI.DynamicYearMonthCombo.EVENT_CONFIRM, function () {
- BI.Bubbles.hide("error");
- var smallDate = self.left.getKey(), bigDate = self.right.getKey();
- if (self.left.isStateValid() && self.right.isStateValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) {
- self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text"));
- self.element.addClass(self.constants.timeErrorCls);
- self.fireEvent(BI.YearMonthInterval.EVENT_ERROR);
- }else{
- self._clearTitle();
- self.element.removeClass(self.constants.timeErrorCls);
- self.fireEvent(BI.YearMonthInterval.EVENT_CHANGE);
+ combo.on(DynamicYearMonthCombo.EVENT_CONFIRM, () => {
+ Bubbles.hide("error");
+ const smallDate = this.left.getKey(),
+ bigDate = this.right.getKey();
+ if (
+ this.left.isStateValid() &&
+ this.right.isStateValid() &&
+ this._check(smallDate, bigDate) &&
+ this._compare(smallDate, bigDate)
+ ) {
+ this._setTitle(i18nText("BI-Time_Interval_Error_Text"));
+ this.element.addClass(this.constants.timeErrorCls);
+ this.fireEvent(YearMonthInterval.EVENT_ERROR);
+ } else {
+ this._clearTitle();
+ this.element.removeClass(this.constants.timeErrorCls);
+ this.fireEvent(YearMonthInterval.EVENT_CHANGE);
}
});
- return combo;
- },
+ return combo;
+ }
- _dateCheck: function (date) {
- return BI.print(BI.parseDateTime(date, "%Y-%x"), "%Y-%x") === date || BI.print(BI.parseDateTime(date, "%Y-%X"), "%Y-%X") === date;
- },
+ _dateCheck(date) {
+ return (
+ print(parseDateTime(date, "%Y-%x"), "%Y-%x") === date ||
+ print(parseDateTime(date, "%Y-%X"), "%Y-%X") === date
+ );
+ }
+ _checkVoid(obj) {
+ const o = this.options;
- // 判是否在最大最小之间
- _checkVoid: function (obj) {
- var o = this.options;
- return !BI.checkDateVoid(obj.year, obj.month, 1, o.minDate, o.maxDate)[0];
- },
+ return !checkDateVoid(obj.year, obj.month, 1, o.minDate, o.maxDate)[0];
+ }
- // 判格式合法
- _check: function (smallDate, bigDate) {
- var smallObj = smallDate.match(/\d+/g), bigObj = bigDate.match(/\d+/g);
+ _check(smallDate, bigDate) {
+ const smallObj = smallDate.match(/\d+/g),
+ bigObj = bigDate.match(/\d+/g);
- var smallDate4Check = "";
- if (BI.isNotNull(smallObj)) {
- smallDate4Check = (smallObj[0] || "") + "-" + (smallObj[1] || 1);
+ let smallDate4Check = "";
+ if (isNotNull(smallObj)) {
+ smallDate4Check = `${smallObj[0] || ""}-${smallObj[1] || 1}`;
}
- var bigDate4Check = "";
- if (BI.isNotNull(bigObj)) {
- bigDate4Check = (bigObj[0] || "") + "-" + (bigObj[1] || 1);
+ let bigDate4Check = "";
+ if (isNotNull(bigObj)) {
+ bigDate4Check = `${bigObj[0] || ""}-${bigObj[1] || 1}`;
}
- return this._dateCheck(smallDate4Check) && BI.checkDateLegal(smallDate4Check) && this._checkVoid({
- year: smallObj[0],
- month: smallObj[1] || 1,
- day: 1
- }) && this._dateCheck(bigDate4Check) && BI.checkDateLegal(bigDate4Check) && this._checkVoid({
- year: bigObj[0],
- month: bigObj[1] || 1,
- day: 1
- });
- },
-
- _compare: function (smallDate, bigDate) {
- smallDate = BI.print(BI.parseDateTime(smallDate, "%Y-%X"), "%Y-%X");
- bigDate = BI.print(BI.parseDateTime(bigDate, "%Y-%X"), "%Y-%X");
- return BI.isNotNull(smallDate) && BI.isNotNull(bigDate) && smallDate > bigDate;
- },
- _setTitle: function (v) {
+ return (
+ this._dateCheck(smallDate4Check) &&
+ checkDateLegal(smallDate4Check) &&
+ this._checkVoid({
+ year: smallObj[0],
+ month: smallObj[1] || 1,
+ day: 1,
+ }) &&
+ this._dateCheck(bigDate4Check) &&
+ checkDateLegal(bigDate4Check) &&
+ this._checkVoid({
+ year: bigObj[0],
+ month: bigObj[1] || 1,
+ day: 1,
+ })
+ );
+ }
+
+ _compare(smallDate, bigDate) {
+ smallDate = print(parseDateTime(smallDate, "%Y-%X"), "%Y-%X");
+ bigDate = print(parseDateTime(bigDate, "%Y-%X"), "%Y-%X");
+
+ return isNotNull(smallDate) && isNotNull(bigDate) && smallDate > bigDate;
+ }
+
+ _setTitle(v) {
this.setTitle(v);
- },
- _clearTitle: function () {
+ }
+
+ _clearTitle() {
this.setTitle("");
- },
- _checkValid: function () {
- var self = this;
-
- BI.Bubbles.hide("error");
- var smallDate = self.left.getKey(), bigDate = self.right.getKey();
- if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) {
- self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text"));
- self.element.addClass(self.constants.timeErrorCls);
- BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, {
- offsetStyle: "center"
+ }
+
+ _checkValid() {
+ Bubbles.hide("error");
+ const smallDate = this.left.getKey(),
+ bigDate = this.right.getKey();
+ if (
+ this.left.isValid() &&
+ this.right.isValid() &&
+ this._check(smallDate, bigDate) &&
+ this._compare(smallDate, bigDate)
+ ) {
+ 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",
});
- self.fireEvent(BI.YearMonthInterval.EVENT_ERROR);
+ this.fireEvent(YearMonthInterval.EVENT_ERROR);
} else {
- self._clearTitle();
- self.element.removeClass(self.constants.timeErrorCls);
+ this._clearTitle();
+ this.element.removeClass(this.constants.timeErrorCls);
}
- },
+ }
- setMinDate: function (minDate) {
- var o = this.options;
+ setMinDate(minDate) {
+ const o = this.options;
o.minDate = minDate;
this.left.setMinDate(minDate);
this.right.setMinDate(minDate);
- },
+ }
- setMaxDate: function (maxDate) {
- var o = this.options;
+ setMaxDate(maxDate) {
+ const o = this.options;
o.maxDate = maxDate;
this.left.setMaxDate(maxDate);
this.right.setMaxDate(maxDate);
- },
+ }
- setValue: function (date) {
+ setValue(date) {
date = date || {};
this.left.setValue(date.start);
this.right.setValue(date.end);
this._checkValid();
- },
- getValue: function () {
- return {start: this.left.getValue(), end: this.right.getValue()};
}
-});
-BI.YearMonthInterval.EVENT_VALID = "EVENT_VALID";
-BI.YearMonthInterval.EVENT_ERROR = "EVENT_ERROR";
-BI.YearMonthInterval.EVENT_CHANGE = "EVENT_CHANGE";
-BI.YearMonthInterval.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
-BI.shortcut("bi.year_month_interval", BI.YearMonthInterval);
+
+ getValue() {
+ return { start: this.left.getValue(), end: this.right.getValue() };
+ }
+}
diff --git a/src/widget/yearquarter/card.dynamic.yearquarter.js b/src/widget/yearquarter/card.dynamic.yearquarter.js
index 9e66e5202..667d7f8c3 100644
--- a/src/widget/yearquarter/card.dynamic.yearquarter.js
+++ b/src/widget/yearquarter/card.dynamic.yearquarter.js
@@ -1,166 +1,213 @@
-/**
- * 年季度展示面板
- *
- * Created by GUY on 2015/9/2.
- * @class BI.YearCard
- * @extends BI.Trigger
- */
-BI.DynamicYearQuarterCard = BI.inherit(BI.Widget, {
-
- props: {
- baseCls: "bi-year-quarter-card"
- },
-
- render: function () {
- var self = this;
+import {
+ shortcut,
+ Widget,
+ i18nText,
+ bind,
+ VerticalLayout,
+ parseDateTime,
+ extend,
+ checkDateVoid,
+ isNotEmptyString,
+ getQuarter
+} from "@/core";
+import { DynamicDateCard, DynamicDateParamItem, DynamicDateHelper } from "../dynamicdate";
+import { Label, Bubbles } from "@/base";
+
+@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 {
- type: "bi.vertical",
- items: [{
- type: "bi.label",
- text: BI.i18nText("BI-Multi_Date_Relative_Current_Time"),
- textAlign: "left",
- height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
- }, {
- type: "bi.vertical",
- ref: function (_ref) {
- self.wrapper = _ref;
+ type: VerticalLayout.xtype,
+ items: [
+ {
+ type: Label.xtype,
+ text: i18nText("BI-Multi_Date_Relative_Current_Time"),
+ textAlign: "left",
+ height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
},
- items: [{
- el: {
- type: "bi.dynamic_date_param_item",
- validationChecker: BI.bind(self._checkDate, self),
- 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;
+ {
+ type: VerticalLayout.xtype,
+ ref: _ref => {
+ this.wrapper = _ref;
},
- listeners: [{
- eventName: "EVENT_CHANGE",
- action: function () {
- self.fireEvent("EVENT_CHANGE");
- }
- }, {
- eventName: "EVENT_INPUT_CHANGE",
- action: function () {
- BI.Bubbles.hide("dynamic-year-quarter-error");
+ items: [
+ {
+ el: {
+ type: DynamicDateParamItem.xtype,
+ validationChecker: bind(this._checkDate, this),
+ ref: _ref => {
+ this.year = _ref;
+ },
+ 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,
- hgap: 10
+ hgap: 10,
};
- },
+ }
- _getErrorText: function () {
- var o = this.options;
- var start = BI.parseDateTime(o.min, "%Y-%X-%d");
- var end = BI.parseDateTime(o.max, "%Y-%X-%d");
- return BI.i18nText("BI-Basic_Year_Quarter_Range_Error",
+ _getErrorText() {
+ const o = this.options;
+ const start = parseDateTime(o.min, "%Y-%X-%d");
+ const end = parseDateTime(o.max, "%Y-%X-%d");
+
+ return i18nText(
+ "BI-Basic_Year_Quarter_Range_Error",
start.getFullYear(),
- BI.getQuarter(start),
+ getQuarter(start),
end.getFullYear(),
- BI.getQuarter(end)
+ getQuarter(end)
);
- },
+ }
- _checkDate: function (obj) {
- var o = this.options;
- var date = BI.DynamicDateHelper.getCalculation(BI.extend(this._getValue(), this._digestDateTypeValue(obj)));
+ _checkDate(obj) {
+ const o = this.options;
+ 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) {
- var valueMap = {};
+ _digestDateTypeValue(value) {
+ const valueMap = {};
switch (value.dateType) {
- case BI.DynamicDateCard.TYPE.YEAR:
- valueMap.year = (value.offset === 0 ? -value.value : +value.value);
- break;
- case BI.DynamicDateCard.TYPE.QUARTER:
- valueMap.quarter = (value.offset === 0 ? -value.value : +value.value);
- break;
- default:
- break;
+ case DynamicDateCard.TYPE.YEAR:
+ valueMap.year =
+ value.offset === 0 ? -value.value : +value.value;
+ break;
+ case DynamicDateCard.TYPE.QUARTER:
+ valueMap.quarter =
+ value.offset === 0 ? -value.value : +value.value;
+ break;
+ default:
+ break;
}
+
return valueMap;
- },
+ }
- _createValue: function (type, v) {
+ _createValue(type, v) {
return {
dateType: type,
value: Math.abs(v),
- offset: v > 0 ? 1 : 0
+ offset: v > 0 ? 1 : 0,
};
- },
+ }
- setMinDate: function(minDate) {
- if (BI.isNotEmptyString(this.options.min)) {
+ setMinDate(minDate) {
+ if (isNotEmptyString(this.options.min)) {
this.options.min = minDate;
}
- },
+ }
- setMaxDate: function (maxDate) {
- if (BI.isNotEmptyString(this.options.max)) {
+ setMaxDate(maxDate) {
+ if (isNotEmptyString(this.options.max)) {
this.options.max = maxDate;
}
- },
+ }
- setValue: function (v) {
- v = v || {year: 0, quarter: 0};
- this.year.setValue(this._createValue(BI.DynamicDateCard.TYPE.YEAR, v.year));
- this.quarter.setValue(this._createValue(BI.DynamicDateCard.TYPE.QUARTER, v.quarter));
- },
+ setValue(v) {
+ v = v || { year: 0, quarter: 0 };
+ this.year.setValue(
+ this._createValue(DynamicDateCard.TYPE.YEAR, v.year)
+ );
+ this.quarter.setValue(
+ this._createValue(DynamicDateCard.TYPE.QUARTER, v.quarter)
+ );
+ }
- _getValue: function () {
- var year = this.year.getValue();
- var quarter = this.quarter.getValue();
+ _getValue() {
+ const year = this.year.getValue();
+ const quarter = this.quarter.getValue();
+
return {
- year: (year.offset === 0 ? -year.value : year.value),
- quarter: (quarter.offset === 0 ? -quarter.value : quarter.value)
+ year: year.offset === 0 ? -year.value : year.value,
+ quarter: quarter.offset === 0 ? -quarter.value : quarter.value,
};
- },
+ }
- getInputValue: function () {
+ getInputValue() {
return this._getValue();
- },
+ }
- getValue: function () {
+ getValue() {
return this.checkValidation() ? this._getValue() : {};
- },
+ }
- checkValidation: function (show) {
- var errorText;
- var yearInvalid = !this.year.checkValidation();
- var quarterInvalid = !this.quarter.checkValidation();
- var invalid = yearInvalid || quarterInvalid;
+ checkValidation(show) {
+ let errorText;
+ const yearInvalid = !this.year.checkValidation();
+ const quarterInvalid = !this.quarter.checkValidation();
+ let invalid = yearInvalid || quarterInvalid;
if (invalid) {
- errorText = BI.i18nText("BI-Please_Input_Natural_Number");
+ errorText = i18nText("BI-Please_Input_Natural_Number");
} else {
invalid = !this._checkDate(this._getValue());
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;
- },
-});
-BI.DynamicYearQuarterCard.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.dynamic_year_quarter_card", BI.DynamicYearQuarterCard);
\ No newline at end of file
+ }
+}
diff --git a/src/widget/yearquarter/card.static.yearquarter.js b/src/widget/yearquarter/card.static.yearquarter.js
index cf54c6fcf..811b430e4 100644
--- a/src/widget/yearquarter/card.static.yearquarter.js
+++ b/src/widget/yearquarter/card.static.yearquarter.js
@@ -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: {
- baseCls: "bi-static-year-quarter-card",
- behaviors: {}
- },
+@shortcut()
+export class StaticYearQuarterCard extends Widget {
+ static xtype = "bi.static_year_quarter_card";
- _createQuarter: function () {
- var self = this;
- var items = [{
- text: BI.getQuarterName(1),
- value: 1
- }, {
- text: BI.getQuarterName(2),
- value: 2
- }, {
- text: BI.getQuarterName(3),
- value: 3
- }, {
- text: BI.getQuarterName(4),
- value: 4
- }];
- return BI.map(items, function (j, item) {
- return BI.extend(item, {
- type: "bi.text_item",
- cls: "bi-border-radius bi-list-item-select",
- textAlign: "center",
- whiteSpace: "nowrap",
- once: false,
- forceSelected: true,
- height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
- ref: function (_ref) {
- self.quarterMap[j + 1] = _ref;
- }
- });
- });
- },
+ props = { baseCls: "bi-static-year-quarter-card", behaviors: {} };
+
+ static EVENT_CHANGE = "EVENT_CHANGE";
+
+ _createQuarter() {
+ const items = [
+ {
+ text: getQuarterName(1),
+ value: 1,
+ },
+ {
+ text: getQuarterName(2),
+ value: 2,
+ },
+ {
+ text: getQuarterName(3),
+ value: 3,
+ },
+ {
+ text: getQuarterName(4),
+ value: 4,
+ }
+ ];
+
+ return map(items, (j, item) => extend(item, {
+ 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 () {
- var self = this, o = this.options;
+ render() {
+ const o = this.options;
this.quarterMap = {};
+
return {
- type: "bi.vertical",
- items: [{
- type: "bi.year_picker",
- cls: "bi-split-bottom",
- ref: function () {
- self.yearPicker = this;
- },
- 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;
+ type: VerticalLayout.xtype,
+ items: [
+ {
+ type: YearPicker.xtype,
+ cls: "bi-split-bottom",
+ ref: _ref => {
+ this.yearPicker = _ref;
},
- items: this._createQuarter(),
- layouts: [{
- type: "bi.vertical",
- vgap: 10,
- hgap: 12,
- }],
- value: o.value,
- listeners: [{
- eventName: BI.ButtonGroup.EVENT_CHANGE,
- action: function () {
- self.selectedYear = self.yearPicker.getValue();
- self.selectedQuarter = this.getValue()[0];
- self.fireEvent(BI.StaticYearQuarterCard.EVENT_CHANGE);
+ min: o.min,
+ max: o.max,
+ behaviors: o.behaviors,
+ height: 30,
+ listeners: [
+ {
+ eventName: YearPicker.EVENT_CHANGE,
+ action: () => {
+ const value = this.yearPicker.getValue();
+ this._checkQuarterStatus(value);
+ this.setValue({
+ year: value,
+ 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) {
- var o = this.options;
- var minDate = BI.parseDateTime(o.min, "%Y-%X-%d"), maxDate = BI.parseDateTime(o.max, "%Y-%X-%d");
- var minYear = minDate.getFullYear(), maxYear = maxDate.getFullYear();
- var minQuarter = 1; var maxQuarter = 4;
- minYear === year && (minQuarter = BI.parseInt(BI.getQuarter(minDate)));
- maxYear === year && (maxQuarter = BI.parseInt(BI.getQuarter(maxDate)));
- var yearInvalid = year < minYear || year > maxYear;
- BI.each(this.quarterMap, function (quarter, obj) {
- var quarterInvalid = quarter < minQuarter || quarter > maxQuarter;
+ _checkQuarterStatus(year) {
+ const o = this.options;
+ const minDate = parseDateTime(o.min, "%Y-%X-%d"),
+ maxDate = parseDateTime(o.max, "%Y-%X-%d");
+ const minYear = minDate.getFullYear(),
+ maxYear = maxDate.getFullYear();
+ let minQuarter = 1;
+ let maxQuarter = 4;
+ minYear === year && (minQuarter = parseInt(getQuarter(minDate)));
+ 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);
});
- },
+ }
- setMinDate: function (minDate) {
+ setMinDate(minDate) {
if (this.options.min !== minDate) {
this.options.min = minDate;
this.yearPicker.setMinDate(minDate);
this._checkQuarterStatus(this.selectedYear);
}
- },
+ }
- setMaxDate: function (maxDate) {
+ setMaxDate(maxDate) {
if (this.options.max !== maxDate) {
this.options.max = maxDate;
this.yearPicker.setMaxDate(maxDate);
this._checkQuarterStatus(this.selectedYear);
}
- },
-
+ }
- getValue: function () {
+ getValue() {
return {
year: this.selectedYear,
- quarter: this.selectedQuarter
+ quarter: this.selectedQuarter,
};
- },
+ }
- setValue: function (obj) {
- var o = this.options;
- var newObj = {};
+ setValue(obj) {
+ const o = this.options;
+ const newObj = {};
newObj.year = obj.year || 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]) {
- var year = newObj.year || BI.getDate().getFullYear();
+ if (
+ 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.selectedQuarter = "";
this.yearPicker.setValue(year);
this.quarter.setValue();
} else {
- this.selectedYear = BI.parseInt(newObj.year);
- this.selectedQuarter = BI.parseInt(newObj.quarter);
+ this.selectedYear = parseInt(newObj.year);
+ this.selectedQuarter = parseInt(newObj.quarter);
this.yearPicker.setValue(this.selectedYear);
this.quarter.setValue(this.selectedQuarter);
}
this._checkQuarterStatus(this.selectedYear);
}
-});
-BI.StaticYearQuarterCard.EVENT_CHANGE = "EVENT_CHANGE";
-BI.shortcut("bi.static_year_quarter_card", BI.StaticYearQuarterCard);
+}
diff --git a/src/widget/yearquarter/combo.yearquarter.js b/src/widget/yearquarter/combo.yearquarter.js
index b7f04c4bd..8255bf054 100644
--- a/src/widget/yearquarter/combo.yearquarter.js
+++ b/src/widget/yearquarter/combo.yearquarter.js
@@ -1,72 +1,101 @@
-BI.DynamicYearQuarterCombo = BI.inherit(BI.Widget, {
+import {
+ shortcut,
+ Widget,
+ createWidget,
+ toPix,
+ isEqual,
+ isNotEmptyString,
+ getDate,
+ AbsoluteLayout,
+ HorizontalFillLayout,
+ isNotNull,
+ isNotEmptyObject,
+ checkDateVoid,
+ getQuarter
+} from "@/core";
+import { DynamicYearQuarterTrigger } from "./trigger.yearquarter";
+import { DynamicYearMonthCombo } from "../yearmonth/combo.yearmonth";
+import { DynamicYearQuarterPopup } from "./popup.yearquarter";
+import { DynamicDateCombo } from "../dynamicdate";
+import { Combo, IconButton } from "@/base";
- _consts: {
- iconWidth: 24
- },
- props: {
+@shortcut()
+export class DynamicYearQuarterCombo extends Widget {
+ static xtype = "bi.dynamic_year_quarter_combo";
+
+ _consts = { iconWidth: 24 };
+ props = {
baseCls: "bi-year-quarter-combo",
behaviors: {},
- minDate: "1900-01-01", // 最小日期
- maxDate: "2099-12-31", // 最大日期
+ minDate: "1900-01-01",
+ maxDate: "2099-12-31",
height: 24,
supportDynamic: true,
isNeedAdjustHeight: false,
- isNeedAdjustWidth: false
- },
+ isNeedAdjustWidth: false,
+ };
+
+ static EVENT_CONFIRM = "EVENT_CONFIRM";
+ static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+ static EVENT_ERROR = "EVENT_ERROR";
+ static EVENT_VALID = "EVENT_VALID";
+ static EVENT_FOCUS = "EVENT_FOCUS";
+ static Static = 1;
+ static Dynamic = 2;
- _init: function () {
- var self = this, o = this.options;
- BI.DynamicYearQuarterCombo.superclass._init.apply(this, arguments);
+ _init() {
+ const o = this.options;
+ super._init(...arguments);
this.storeValue = o.value;
- var border = o.simple ? 1 : 2;
- self.storeTriggerValue = "";
- this.trigger = BI.createWidget({
- type: "bi.dynamic_year_quarter_trigger",
+ const border = o.simple ? 1 : 2;
+ this.storeTriggerValue = "";
+ this.trigger = createWidget({
+ type: DynamicYearQuarterTrigger.xtype,
simple: o.simple,
min: o.minDate,
max: o.maxDate,
- height: BI.toPix(o.height, border),
+ height: toPix(o.height, border),
value: o.value || "",
watermark: o.watermark,
});
- this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_KEY_DOWN, function () {
- self.combo.isViewVisible() && self.combo.hideView();
+ this.trigger.on(DynamicYearQuarterTrigger.EVENT_KEY_DOWN, () => {
+ this.combo.isViewVisible() && this.combo.hideView();
});
- this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_START, function () {
- self.combo.isViewVisible() && self.combo.hideView();
+ this.trigger.on(DynamicYearQuarterTrigger.EVENT_START, () => {
+ this.combo.isViewVisible() && this.combo.hideView();
});
- this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_STOP, function () {
- self.combo.showView();
+ this.trigger.on(DynamicYearQuarterTrigger.EVENT_STOP, () => {
+ this.combo.showView();
});
- this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_ERROR, function () {
- self.combo.isViewVisible() && self.combo.hideView();
- self.comboWrapper.element.addClass("error");
- self.fireEvent(BI.DynamicYearQuarterCombo.EVENT_ERROR);
+ this.trigger.on(DynamicYearQuarterTrigger.EVENT_ERROR, () => {
+ this.combo.isViewVisible() && this.combo.hideView();
+ this.comboWrapper.element.addClass("error");
+ this.fireEvent(DynamicYearQuarterCombo.EVENT_ERROR);
});
- this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_VALID, function () {
- self.comboWrapper.element.removeClass("error");
- self.fireEvent(BI.DynamicYearMonthCombo.EVENT_VALID);
+ this.trigger.on(DynamicYearQuarterTrigger.EVENT_VALID, () => {
+ this.comboWrapper.element.removeClass("error");
+ this.fireEvent(DynamicYearMonthCombo.EVENT_VALID);
});
- this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_CONFIRM, function () {
- var dateStore = self.storeTriggerValue;
- var dateObj = self.trigger.getKey();
- if (BI.isEqual(dateObj, dateStore)) {
+ this.trigger.on(DynamicYearQuarterTrigger.EVENT_CONFIRM, () => {
+ const dateStore = this.storeTriggerValue;
+ const dateObj = this.trigger.getKey();
+ if (isEqual(dateObj, dateStore)) {
return;
}
- if (BI.isNotEmptyString(dateObj) && !BI.isEqual(dateObj, dateStore)) {
- self.storeValue = self.trigger.getValue();
- self.setValue(self.trigger.getValue());
+ if (isNotEmptyString(dateObj) && !isEqual(dateObj, dateStore)) {
+ this.storeValue = this.trigger.getValue();
+ this.setValue(this.trigger.getValue());
}
- self._checkDynamicValue(self.storeValue);
- self.fireEvent(BI.DynamicYearQuarterCombo.EVENT_CONFIRM);
+ this._checkDynamicValue(this.storeValue);
+ this.fireEvent(DynamicYearQuarterCombo.EVENT_CONFIRM);
});
- this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_FOCUS, function () {
- self.storeTriggerValue = self.trigger.getKey();
- self.fireEvent(BI.DynamicYearQuarterCombo.EVENT_FOCUS);
+ this.trigger.on(DynamicYearQuarterTrigger.EVENT_FOCUS, () => {
+ this.storeTriggerValue = this.trigger.getKey();
+ this.fireEvent(DynamicYearQuarterCombo.EVENT_FOCUS);
});
- this.combo = BI.createWidget({
- type: "bi.combo",
+ this.combo = createWidget({
+ type: Combo.xtype,
container: o.container,
isNeedAdjustHeight: o.isNeedAdjustHeight,
isNeedAdjustWidth: o.isNeedAdjustWidth,
@@ -77,175 +106,171 @@ BI.DynamicYearQuarterCombo = BI.inherit(BI.Widget, {
minWidth: 85,
stopPropagation: false,
el: {
- type: "bi.dynamic_year_quarter_popup",
+ type: DynamicYearQuarterPopup.xtype,
width: o.isNeedAdjustWidth ? o.width : undefined,
supportDynamic: o.supportDynamic,
- ref: function () {
- self.popup = this;
+ ref: _ref => {
+ this.popup = _ref;
},
listeners: [
{
- eventName: BI.DynamicYearQuarterPopup.EVENT_CHANGE,
- action: function () {
- self.setValue(self.popup.getValue());
- self.combo.hideView();
- self.fireEvent(BI.DynamicYearQuarterCombo.EVENT_CONFIRM);
- }
- }, {
- eventName: BI.DynamicYearQuarterPopup.BUTTON_CLEAR_EVENT_CHANGE,
- action: function () {
- self.setValue();
- self.comboWrapper.element.removeClass("error");
- self.combo.hideView();
- self.fireEvent(BI.DynamicYearQuarterCombo.EVENT_CONFIRM);
- }
- }, {
- eventName: BI.DynamicYearQuarterPopup.BUTTON_lABEL_EVENT_CHANGE,
- action: function () {
- var date = BI.getDate();
- self.setValue({
- type: BI.DynamicYearMonthCombo.Static,
- value: { year: date.getFullYear(), quarter: BI.getQuarter(date) }
+ eventName: DynamicYearQuarterPopup.EVENT_CHANGE,
+ action: () => {
+ this.setValue(this.popup.getValue());
+ this.combo.hideView();
+ this.fireEvent(DynamicYearQuarterCombo.EVENT_CONFIRM);
+ },
+ },
+ {
+ eventName: DynamicYearQuarterPopup.BUTTON_CLEAR_EVENT_CHANGE,
+ action: () => {
+ this.setValue();
+ this.comboWrapper.element.removeClass("error");
+ this.combo.hideView();
+ this.fireEvent(DynamicYearQuarterCombo.EVENT_CONFIRM);
+ },
+ },
+ {
+ eventName: DynamicYearQuarterPopup.BUTTON_lABEL_EVENT_CHANGE,
+ action: () => {
+ const date = getDate();
+ this.setValue({
+ type: DynamicYearMonthCombo.Static,
+ value: {
+ year: date.getFullYear(),
+ quarter: getQuarter(date),
+ },
});
- self.combo.hideView();
- self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
- }
- }, {
- eventName: BI.DynamicYearQuarterPopup.BUTTON_OK_EVENT_CHANGE,
- action: function () {
- var value = self.popup.getValue();
- if (self._checkValue(value)) {
- self.setValue(value);
+ this.combo.hideView();
+ this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
+ },
+ },
+ {
+ eventName: DynamicYearQuarterPopup.BUTTON_OK_EVENT_CHANGE,
+ action: () => {
+ const value = this.popup.getValue();
+ if (this._checkValue(value)) {
+ this.setValue(value);
}
- self.combo.hideView();
- self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
- }
+ this.combo.hideView();
+ this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
+ },
}
],
behaviors: o.behaviors,
min: o.minDate,
- max: o.maxDate
+ max: o.maxDate,
},
- value: o.value || ""
- }
+ value: o.value || "",
+ },
});
- this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
- self.popup.setMinDate(o.minDate);
- self.popup.setMaxDate(o.maxDate);
- self.popup.setValue(self.storeValue);
- self.fireEvent(BI.DynamicYearQuarterCombo.EVENT_BEFORE_POPUPVIEW);
+ this.combo.on(Combo.EVENT_BEFORE_POPUPVIEW, () => {
+ this.popup.setMinDate(o.minDate);
+ this.popup.setMaxDate(o.maxDate);
+ this.popup.setValue(this.storeValue);
+ this.fireEvent(DynamicYearQuarterCombo.EVENT_BEFORE_POPUPVIEW);
});
- BI.createWidget({
- type: "bi.absolute",
+ createWidget({
+ type: AbsoluteLayout.xtype,
element: this,
items: [
{
el: {
- type: "bi.horizontal_fill",
+ type: HorizontalFillLayout.xtype,
columnSize: ["", "fill"],
- cls: (o.simple ? "bi-border-bottom" : "bi-border bi-border-radius") + " bi-focus-shadow",
- ref: function () {
- self.comboWrapper = this;
+ cls: `${o.simple ? "bi-border-bottom" : "bi-border bi-border-radius"} bi-focus-shadow`,
+ ref: _ref => {
+ this.comboWrapper = _ref;
},
items: [
{
el: {
- type: "bi.icon_button",
+ type: IconButton.xtype,
cls: "bi-trigger-icon-button date-change-h-font",
width: this._consts.iconWidth,
- height: BI.toPix(o.height, border),
- ref: function () {
- self.changeIcon = this;
- }
- }
- }, this.combo
- ]
+ height: toPix(o.height, border),
+ ref: _ref => {
+ this.changeIcon = _ref;
+ },
+ },
+ },
+ this.combo
+ ],
},
top: 0,
left: 0,
right: 0,
- bottom: 0
+ bottom: 0,
}
- ]
+ ],
});
this._checkDynamicValue(o.value);
- },
+ }
- _checkDynamicValue: function (v) {
- var type = null;
- if (BI.isNotNull(v)) {
+ _checkDynamicValue(v) {
+ let type = null;
+ if (isNotNull(v)) {
type = v.type;
}
switch (type) {
- case BI.DynamicYearQuarterCombo.Dynamic:
- this.changeIcon.setVisible(true);
- break;
- default:
- this.changeIcon.setVisible(false);
- break;
+ case DynamicYearQuarterCombo.Dynamic:
+ this.changeIcon.setVisible(true);
+ break;
+ default:
+ this.changeIcon.setVisible(false);
+ break;
}
- },
+ }
- _checkValue: function (v) {
- var o = this.options;
+ _checkValue(v) {
+ const o = this.options;
+ let value;
switch (v.type) {
- case BI.DynamicDateCombo.Dynamic:
- return BI.isNotEmptyObject(v.value);
- case BI.DynamicDateCombo.Static:
- var value = v.value || {};
-
- return !BI.checkDateVoid(value.year, (value.quarter - 1) * 3 + 1, 1, o.minDate, o.maxDate)[0];
- default:
- return true;
+ case DynamicDateCombo.Dynamic:
+ return isNotEmptyObject(v.value);
+ case DynamicDateCombo.Static:
+ value = v.value || {};
+
+ return !checkDateVoid(value.year, (value.quarter - 1) * 3 + 1, 1, o.minDate, o.maxDate)[0];
+ default:
+ return true;
}
- },
+ }
- setMinDate: function (minDate) {
- var o = this.options;
+ setMinDate(minDate) {
+ const o = this.options;
o.minDate = minDate;
this.trigger.setMinDate(minDate);
this.popup && this.popup.setMinDate(minDate);
- },
+ }
- setMaxDate: function (maxDate) {
- var o = this.options;
+ setMaxDate(maxDate) {
+ const o = this.options;
o.maxDate = maxDate;
this.trigger.setMaxDate(maxDate);
this.popup && this.popup.setMaxDate(maxDate);
- },
+ }
- hideView: function () {
+ hideView() {
this.combo.hideView();
- },
+ }
- getKey: function () {
+ getKey() {
return this.trigger.getKey();
- },
+ }
- setValue: function (v) {
+ setValue(v) {
this.storeValue = v;
this.trigger.setValue(v);
this._checkDynamicValue(v);
- },
+ }
- getValue: function () {
+ getValue() {
return this.storeValue;
- },
+ }
- isStateValid: function () {
+ isStateValid() {
return this.trigger.isStateValid();
}
-
-});
-BI.DynamicYearQuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
-BI.DynamicYearQuarterCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
-BI.DynamicYearQuarterCombo.EVENT_ERROR = "EVENT_ERROR";
-BI.DynamicYearQuarterCombo.EVENT_VALID = "EVENT_VALID";
-BI.DynamicYearQuarterCombo.EVENT_FOCUS = "EVENT_FOCUS";
-BI.shortcut("bi.dynamic_year_quarter_combo", BI.DynamicYearQuarterCombo);
-
-BI.extend(BI.DynamicYearQuarterCombo, {
- Static: 1,
- Dynamic: 2
-});
+}
diff --git a/src/widget/yearquarter/index.js b/src/widget/yearquarter/index.js
new file mode 100644
index 000000000..29b16b492
--- /dev/null
+++ b/src/widget/yearquarter/index.js
@@ -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";
+
diff --git a/src/widget/yearquarter/popup.yearquarter.js b/src/widget/yearquarter/popup.yearquarter.js
index 6cfbc519a..4a1d13d1f 100644
--- a/src/widget/yearquarter/popup.yearquarter.js
+++ b/src/widget/yearquarter/popup.yearquarter.js
@@ -1,235 +1,327 @@
-BI.DynamicYearQuarterPopup = BI.inherit(BI.Widget, {
- constants: {
- tabHeight: 40,
- buttonHeight: 24
- },
+import {
+ shortcut,
+ Widget,
+ 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";
+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",
behaviors: {},
- min: "1900-01-01", // 最小日期
- max: "2099-12-31", // 最大日期,
+ min: "1900-01-01",
+ max: "2099-12-31",
width: 180,
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 () {
- var self = this, opts = this.options, c = this.constants;
- this.storeValue = {type: BI.DynamicYearQuarterCombo.Static};
+ render() {
+ this.storeValue = { type: DynamicYearQuarterCombo.Static };
+
return {
- type: "bi.vertical",
- items: [{
- 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
+ type: VerticalLayout.xtype,
+ items: [
+ {
+ el: this._getTabJson(),
},
- }]
+ {
+ 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 () {
- if (this.dateTab.getSelect() === BI.DynamicYearQuarterCombo.Static) {
- this.textButton.setValue(BI.i18nText("BI-Basic_Current_Quarter"));
+ _setInnerValue() {
+ if (this.dateTab.getSelect() === DynamicYearQuarterCombo.Static) {
+ this.textButton.setValue(i18nText("BI-Basic_Current_Quarter"));
this.textButton.setEnable(!this._checkTodayValid());
} else {
- var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getInputValue());
- date = BI.print(date, "%Y-%Q");
+ let date = DynamicDateHelper.getCalculation(
+ this.dynamicPane.getInputValue()
+ );
+ date = print(date, "%Y-%Q");
this.textButton.setValue(date);
this.textButton.setEnable(false);
}
- },
+ }
- _checkTodayValid: function () {
- var o = this.options;
- var today = BI.getDate();
- return !!BI.checkDateVoid(today.getFullYear(), today.getMonth() + 1, today.getDate(), o.min, o.max)[0];
- },
+ _checkTodayValid() {
+ const o = this.options;
+ const today = getDate();
+
+ return !!checkDateVoid(
+ today.getFullYear(),
+ today.getMonth() + 1,
+ today.getDate(),
+ o.min,
+ o.max
+ )[0];
+ }
- _getTabJson: function () {
- var self = this, o = this.options;
+ _getTabJson() {
+ const o = this.options;
+
return {
- type: "bi.tab",
+ type: Tab.xtype,
logic: {
- dynamic: true
+ dynamic: true,
},
- ref: function () {
- self.dateTab = this;
+ ref: _ref => {
+ this.dateTab = _ref;
},
tab: {
- type: "bi.linear_segment",
+ type: LinearSegment.xtype,
cls: "bi-split-bottom",
invisible: !o.supportDynamic,
height: this.constants.tabHeight,
- items: BI.createItems([{
- text: BI.i18nText("BI-Basic_Year_Quarter"),
- value: BI.DynamicYearQuarterCombo.Static
- }, {
- text: BI.i18nText("BI-Basic_Dynamic_Title"),
- value: BI.DynamicYearQuarterCombo.Dynamic
- }], {
- textAlign: "center"
- })
+ items: createItems(
+ [
+ {
+ text: i18nText("BI-Basic_Year_Quarter"),
+ value: DynamicYearQuarterCombo.Static,
+ },
+ {
+ text: i18nText("BI-Basic_Dynamic_Title"),
+ value: DynamicYearQuarterCombo.Dynamic,
+ }
+ ],
+ {
+ textAlign: "center",
+ }
+ ),
},
- cardCreator: function (v) {
+ cardCreator: v => {
switch (v) {
- case BI.DynamicYearQuarterCombo.Dynamic:
- return {
- type: "bi.dynamic_year_quarter_card",
- cls: "dynamic-year-quarter-pane",
- min: self.options.min,
- max: self.options.max,
- listeners: [{
+ case DynamicYearQuarterCombo.Dynamic:
+ return {
+ type: DynamicYearQuarterCard.xtype,
+ cls: "dynamic-year-quarter-pane",
+ min: this.options.min,
+ max: this.options.max,
+ listeners: [
+ {
eventName: "EVENT_CHANGE",
- action: function () {
- self._setInnerValue(self.year, v);
- }
- }],
- ref: function () {
- self.dynamicPane = this;
+ action: () => {
+ this._setInnerValue(this.year, v);
+ },
}
- };
- case BI.DynamicYearQuarterCombo.Static:
- default:
- return {
- type: "bi.static_year_quarter_card",
- behaviors: o.behaviors,
- min: self.options.min,
- max: self.options.max,
- listeners: [{
- eventName: BI.DynamicYearCard.EVENT_CHANGE,
- action: function () {
- self.fireEvent(BI.DynamicYearQuarterPopup.EVENT_CHANGE);
- }
- }],
- ref: function () {
- self.year = this;
+ ],
+ ref: _ref => {
+ this.dynamicPane = _ref;
+ },
+ };
+ case DynamicYearQuarterCombo.Static:
+ default:
+ return {
+ type: StaticYearQuarterCard.xtype,
+ behaviors: o.behaviors,
+ min: this.options.min,
+ max: this.options.max,
+ listeners: [
+ {
+ eventName: DynamicYearCard.EVENT_CHANGE,
+ action: () => {
+ this.fireEvent(
+ DynamicYearQuarterPopup.EVENT_CHANGE
+ );
+ },
}
- };
+ ],
+ ref: _ref => {
+ this.year = _ref;
+ },
+ };
}
},
- listeners: [{
- eventName: BI.Tab.EVENT_CHANGE,
- action: function () {
- var v = self.dateTab.getSelect();
- switch (v) {
- case BI.DynamicYearQuarterCombo.Static:
- var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue());
- self.year.setValue({year: date.getFullYear(), quarter: BI.getQuarter(date)});
- self._setInnerValue();
+ listeners: [
+ {
+ eventName: Tab.EVENT_CHANGE,
+ action: () => {
+ const v = this.dateTab.getSelect();
+ let date;
+ switch (v) {
+ case DynamicYearQuarterCombo.Static:
+ date = DynamicDateHelper.getCalculation(
+ this.dynamicPane.getValue()
+ );
+ this.year.setValue({
+ year: date.getFullYear(),
+ quarter: getQuarter(date),
+ });
+ this._setInnerValue();
break;
- case BI.DynamicYearQuarterCombo.Dynamic:
+ case DynamicYearQuarterCombo.Dynamic:
default:
- if(self.storeValue && self.storeValue.type === BI.DynamicYearQuarterCombo.Dynamic) {
- self.dynamicPane.setValue(self.storeValue.value);
- }else{
- self.dynamicPane.setValue({
- year: 0
+ if (
+ this.storeValue &&
+ this.storeValue.type ===
+ DynamicYearQuarterCombo.Dynamic
+ ) {
+ this.dynamicPane.setValue(
+ this.storeValue.value
+ );
+ } else {
+ this.dynamicPane.setValue({
+ year: 0,
});
}
- self._setInnerValue();
+ this._setInnerValue();
break;
- }
+ }
+ },
}
- }]
+ ],
};
- },
+ }
- setMinDate: function (minDate) {
+ setMinDate(minDate) {
if (this.options.min !== minDate) {
this.options.min = minDate;
this.year && this.year.setMinDate(minDate);
this.dynamicPane && this.dynamicPane.setMinDate(minDate);
}
- },
+ }
- setMaxDate: function (maxDate) {
+ setMaxDate(maxDate) {
if (this.options.max !== maxDate) {
this.options.max = maxDate;
this.year && this.year.setMaxDate(maxDate);
this.dynamicPane && this.dynamicPane.setMaxDate(maxDate);
}
- },
+ }
- setValue: function (v) {
+ setValue(v) {
this.storeValue = v;
- var self = this;
- var type, value;
v = v || {};
- type = v.type || BI.DynamicDateCombo.Static;
- value = v.value || v;
+ const type = v.type || DynamicDateCombo.Static;
+ const value = v.value || v;
this.dateTab.setSelect(type);
switch (type) {
- case BI.DynamicDateCombo.Dynamic:
- this.dynamicPane.setValue(value);
- self._setInnerValue();
- break;
- case BI.DynamicDateCombo.Static:
- default:
- this.year.setValue(value);
- this.textButton.setValue(BI.i18nText("BI-Basic_Current_Quarter"));
- this.textButton.setEnable(!this._checkTodayValid());
- break;
+ case DynamicDateCombo.Dynamic:
+ this.dynamicPane.setValue(value);
+ this._setInnerValue();
+ break;
+ case DynamicDateCombo.Static:
+ default:
+ this.year.setValue(value);
+ this.textButton.setValue(i18nText("BI-Basic_Current_Quarter"));
+ this.textButton.setEnable(!this._checkTodayValid());
+ break;
}
- },
+ }
- getValue: function () {
+ getValue() {
return {
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);
\ No newline at end of file
+}
diff --git a/src/widget/yearquarter/trigger.yearquarter.js b/src/widget/yearquarter/trigger.yearquarter.js
index 876856379..4020036c5 100644
--- a/src/widget/yearquarter/trigger.yearquarter.js
+++ b/src/widget/yearquarter/trigger.yearquarter.js
@@ -1,277 +1,373 @@
-BI.DynamicYearQuarterTrigger = BI.inherit(BI.Trigger, {
- _const: {
- hgap: 4,
- vgap: 2,
- iconWidth: 24
- },
+import {
+ shortcut,
+ i18nText,
+ createWidget,
+ 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";
+import { DynamicYearMonthTrigger } from "../yearmonth/trigger.yearmonth";
+import { DynamicYearQuarterCombo } from "./combo.yearquarter";
- props: () => ({
- extraCls: "bi-year-quarter-trigger",
- min: "1900-01-01", // 最小日期
- max: "2099-12-31", // 最大日期
- height: 24,
- watermark: {
- year: BI.i18nText("BI-Basic_Unrestricted"),
- quarter: BI.i18nText("BI-Basic_Unrestricted"),
- },
- }),
+@shortcut()
+export class DynamicYearQuarterTrigger extends Trigger {
+ static xtype = "bi.dynamic_year_quarter_trigger";
- _init: function () {
- BI.DynamicYearQuarterTrigger.superclass._init.apply(this, arguments);
- var o = this.options;
+ _const = { hgap: 4, vgap: 2, iconWidth: 24 };
+
+ 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.quarterEditor = this._createEditor(false);
// 暂时的解决方法
- var height = o.height + 2;
+ // const height = o.height + 2;
- BI.createWidget({
+ createWidget({
element: this,
- type: "bi.htape",
- items: [{
- type: "bi.center",
- items: [{
- type: "bi.horizontal_fill",
- columnSize: ["fill", ""],
- items: [this.yearEditor, {
- el: {
- type: "bi.text_button",
- text: BI.i18nText("BI-Multi_Date_Year"),
- },
- }]
- }, {
- type: "bi.horizontal_fill",
- columnSize: ["fill", ""],
- items: [this.quarterEditor, {
- el: {
- type: "bi.text_button",
- text: BI.i18nText("BI-Multi_Date_Quarter"),
+ type: HTapeLayout.xtype,
+ items: [
+ {
+ type: CenterLayout.xtype,
+ items: [
+ {
+ type: HorizontalFillLayout.xtype,
+ columnSize: ["fill", ""],
+ items: [
+ this.yearEditor,
+ {
+ el: {
+ type: TextButton.xtype,
+ text: i18nText("BI-Multi_Date_Year"),
+ },
+ }
+ ],
},
- }]
- }]
- }, {
- el: {
- type: "bi.trigger_icon_button",
- width: this._const.iconWidth,
+ {
+ type: HorizontalFillLayout.xtype,
+ columnSize: ["fill", ""],
+ items: [
+ this.quarterEditor,
+ {
+ 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);
- },
+ }
- _createEditor: function (isYear) {
- var self = this, o = this.options, c = this._const;
- var editor = BI.createWidget({
- type: "bi.sign_editor",
+ _createEditor(isYear) {
+ const o = this.options,
+ c = this._const;
+ const editor = createWidget({
+ type: SignEditor.xtype,
simple: o.simple,
height: o.height,
- validationChecker: function (v) {
- if(isYear) {
- var month = self.quarterEditor.getValue();
- if(BI.isEmptyString(month)) {
- month = parseInt(v, 10) === BI.parseDateTime(o.min, "%Y-%X-%d").getFullYear() ? BI.parseDateTime(o.min, "%Y-%X-%d").getMonth() + 1 : 1;
+ validationChecker: v => {
+ if (isYear) {
+ let month = this.quarterEditor.getValue();
+ if (isEmptyString(month)) {
+ month =
+ parseInt(v, 10) ===
+ parseDateTime(o.min, "%Y-%X-%d").getFullYear()
+ ? parseDateTime(o.min, "%Y-%X-%d").getMonth() +
+ 1
+ : 1;
} else {
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]));
- },
- quitChecker: function () {
- return false;
+ return (
+ v === "" ||
+ (isPositiveInteger(v) &&
+ v >= 1 &&
+ v <= 4 &&
+ (isEmptyString(year)
+ ? true
+ : !checkDateVoid(
+ this.yearEditor.getValue(),
+ (v - 1) * 3 + 1,
+ 1,
+ o.min,
+ o.max
+ )[0]))
+ );
},
- errorText: function (v) {
- var year = isYear ? v : self.yearEditor.getValue();
- var quarter = isYear ? self.quarterEditor.getValue() : v;
- if (!BI.isPositiveInteger(year) || !BI.isPositiveInteger(quarter) || quarter > 4) {
- return BI.i18nText("BI-Year_Trigger_Invalid_Text");
+ quitChecker: () => false,
+ errorText: v => {
+ const year = isYear ? v : this.yearEditor.getValue();
+ const quarter = isYear ? this.quarterEditor.getValue() : v;
+ if (
+ !isPositiveInteger(year) ||
+ !isPositiveInteger(quarter) ||
+ quarter > 4
+ ) {
+ return i18nText("BI-Year_Trigger_Invalid_Text");
}
- var start = BI.parseDateTime(o.min, "%Y-%X-%d");
- var end = BI.parseDateTime(o.max, "%Y-%X-%d");
+ const start = parseDateTime(o.min, "%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(),
- BI.getQuarter(start),
+ getQuarter(start),
end.getFullYear(),
- BI.getQuarter(end)
+ getQuarter(end)
);
},
watermark: isYear ? o.watermark?.year : o.watermark?.quarter,
hgap: c.hgap,
vgap: c.vgap,
- allowBlank: true
+ allowBlank: true,
});
- editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () {
- self.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_KEY_DOWN);
+ editor.on(SignEditor.EVENT_KEY_DOWN, () => {
+ this.fireEvent(DynamicYearQuarterTrigger.EVENT_KEY_DOWN);
});
- editor.on(BI.SignEditor.EVENT_FOCUS, function () {
- self.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_FOCUS);
+ editor.on(SignEditor.EVENT_FOCUS, () => {
+ this.fireEvent(DynamicYearQuarterTrigger.EVENT_FOCUS);
});
- editor.on(BI.SignEditor.EVENT_STOP, function () {
- self.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_STOP);
+ editor.on(SignEditor.EVENT_STOP, () => {
+ this.fireEvent(DynamicYearQuarterTrigger.EVENT_STOP);
});
- editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
- self._doEditorConfirm(editor);
- self.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_CONFIRM);
+ editor.on(SignEditor.EVENT_CONFIRM, () => {
+ this._doEditorConfirm(editor);
+ this.fireEvent(DynamicYearQuarterTrigger.EVENT_CONFIRM);
});
- editor.on(BI.SignEditor.EVENT_SPACE, function () {
+ editor.on(SignEditor.EVENT_SPACE, () => {
if (editor.isValid()) {
editor.blur();
}
});
- editor.on(BI.SignEditor.EVENT_START, function () {
- self.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_START);
+ editor.on(SignEditor.EVENT_START, () => {
+ this.fireEvent(DynamicYearQuarterTrigger.EVENT_START);
});
- editor.on(BI.SignEditor.EVENT_ERROR, function () {
- self.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_ERROR);
+ editor.on(SignEditor.EVENT_ERROR, () => {
+ this.fireEvent(DynamicYearQuarterTrigger.EVENT_ERROR);
});
- editor.on(BI.SignEditor.EVENT_VALID, function () {
- var year = self.yearEditor.getValue();
- var quarter = self.quarterEditor.getValue();
- if(BI.isNotEmptyString(year) && BI.isNotEmptyString(quarter)) {
- if(BI.isPositiveInteger(year) && quarter >= 1 && quarter <= 4 && !BI.checkDateVoid(year, (quarter - 1) * 3 + 1, 1, o.min, o.max)[0]) {
- self.fireEvent(BI.DynamicYearMonthTrigger.EVENT_VALID);
+ editor.on(SignEditor.EVENT_VALID, () => {
+ const year = this.yearEditor.getValue();
+ const quarter = this.quarterEditor.getValue();
+ if (isNotEmptyString(year) && isNotEmptyString(quarter)) {
+ if (
+ isPositiveInteger(year) &&
+ quarter >= 1 &&
+ quarter <= 4 &&
+ !checkDateVoid(
+ year,
+ (quarter - 1) * 3 + 1,
+ 1,
+ o.min,
+ o.max
+ )[0]
+ ) {
+ this.fireEvent(DynamicYearMonthTrigger.EVENT_VALID);
}
}
});
- editor.on(BI.SignEditor.EVENT_CHANGE, function () {
- if(isYear) {
- self._autoSwitch(editor);
+ editor.on(SignEditor.EVENT_CHANGE, () => {
+ if (isYear) {
+ this._autoSwitch(editor);
}
});
return editor;
- },
+ }
- _doEditorConfirm: function (editor) {
- var value = editor.getValue();
- if (BI.isNotNull(value)) {
+ _doEditorConfirm(editor) {
+ const value = editor.getValue();
+ if (isNotNull(value)) {
editor.setValue(value);
}
- var quarterValue = this.quarterEditor.getValue();
+ const quarterValue = this.quarterEditor.getValue();
this.storeValue = {
- type: BI.DynamicYearQuarterCombo.Static,
+ type: DynamicYearQuarterCombo.Static,
value: {
year: this.yearEditor.getValue(),
- quarter: BI.isEmptyString(this.quarterEditor.getValue()) ? "" : quarterValue
- }
+ quarter: isEmptyString(this.quarterEditor.getValue())
+ ? ""
+ : quarterValue,
+ },
};
this.setTitle(this._getStaticTitle(this.storeValue.value));
- },
+ }
- _yearCheck: function (v) {
- var date = BI.print(BI.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;
- },
+ _yearCheck(v) {
+ const date = print(parseDateTime(v, "%Y-%X-%d"), "%Y-%X-%d");
+
+ return (
+ print(parseDateTime(v, "%Y"), "%Y") === v &&
+ date >= this.options.min &&
+ date <= this.options.max
+ );
+ }
- _autoSwitch: function (editor) {
- var v = editor.getValue();
- if (BI.isNotEmptyString(v) && BI.checkDateLegal(v)) {
+ _autoSwitch(editor) {
+ const v = editor.getValue();
+ if (isNotEmptyString(v) && checkDateLegal(v)) {
if (v.length === 4 && this._yearCheck(v)) {
this._doEditorConfirm(editor);
- this.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_CONFIRM);
+ this.fireEvent(DynamicYearQuarterTrigger.EVENT_CONFIRM);
this.quarterEditor.focus();
}
}
- },
+ }
- _getStaticTitle: function (value) {
+ _getStaticTitle(value) {
value = value || {};
- var hasYear = !(BI.isNull(value.year) || BI.isEmptyString(value.year));
- var hasMonth = !(BI.isNull(value.quarter) || BI.isEmptyString(value.quarter));
+ const hasYear = !(isNull(value.year) || isEmptyString(value.year));
+ const hasMonth = !(isNull(value.quarter) || isEmptyString(value.quarter));
switch ((hasYear << 1) | hasMonth) {
- // !hasYear && !hasMonth
- case 0:
- return "";
+ // !hasYear && !hasMonth
+ case 0:
+ return "";
// !hasYear && hasMonth
- case 1:
- return value.quarter;
+ case 1:
+ return value.quarter;
// hasYear && !hasMonth
- case 2:
- return value.year;
+ case 2:
+ return value.year;
// hasYear && hasMonth
- case 3:
- default:
- return value.year + "-" + value.quarter;
+ case 3:
+ default:
+ return `${value.year}-${value.quarter}`;
}
- },
+ }
- _getText: function (obj) {
- var value = "";
- if(BI.isNotNull(obj.year) && BI.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"));
+ _getText(obj) {
+ let value = "";
+ if (isNotNull(obj.year) && parseInt(obj.year) !== 0) {
+ 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) {
- value += Math.abs(obj.quarter) + BI.i18nText("BI-Basic_Single_Quarter") + (obj.quarter < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind"));
+ if (isNotNull(obj.quarter) && parseInt(obj.quarter) !== 0) {
+ value +=
+ Math.abs(obj.quarter) +
+ i18nText("BI-Basic_Single_Quarter") +
+ (obj.quarter < 0
+ ? i18nText("BI-Basic_Front")
+ : i18nText("BI-Basic_Behind"));
}
+
return value;
- },
+ }
- _setInnerValue: function (date, text) {
- var dateStr = BI.print(date, "%Y-%Q");
+ _setInnerValue(date, text) {
+ const dateStr = print(date, "%Y-%Q");
this.yearEditor.setValue(date.getFullYear());
- this.quarterEditor.setValue(BI.getQuarter(date));
- this.setTitle(BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr));
- },
+ this.quarterEditor.setValue(getQuarter(date));
+ this.setTitle(isEmptyString(text) ? dateStr : `${text}:${dateStr}`);
+ }
- setMinDate: function (minDate) {
- if (BI.isNotEmptyString(this.options.min)) {
+ setMinDate(minDate) {
+ if (isNotEmptyString(this.options.min)) {
this.options.min = minDate;
}
- },
+ }
- setMaxDate: function (maxDate) {
- if (BI.isNotEmptyString(this.options.max)) {
+ setMaxDate(maxDate) {
+ if (isNotEmptyString(this.options.max)) {
this.options.max = maxDate;
}
- },
+ }
- setValue: function (v) {
- var type, value;
- var date = BI.getDate();
+ setValue(v) {
+ let type, value, text, quarter;
+ let date = getDate();
this.storeValue = v;
- if (BI.isNotNull(v)) {
- type = v.type || BI.DynamicYearQuarterCombo.Static;
+ if (isNotNull(v)) {
+ type = v.type || DynamicYearQuarterCombo.Static;
value = v.value || v;
}
switch (type) {
- case BI.DynamicYearQuarterCombo.Dynamic:
- var text = this._getText(value);
- date = BI.DynamicDateHelper.getCalculation(value);
- this._setInnerValue(date, text);
- break;
- case BI.DynamicYearQuarterCombo.Static:
- default:
- value = value || {};
- var quarter = BI.isNull(value.quarter) ? null : value.quarter;
- this.yearEditor.setValue(value.year);
- this.quarterEditor.setValue(quarter);
- this.setTitle(this._getStaticTitle(value));
- break;
+ case DynamicYearQuarterCombo.Dynamic:
+ text = this._getText(value);
+ date = DynamicDateHelper.getCalculation(value);
+ this._setInnerValue(date, text);
+ break;
+ case DynamicYearQuarterCombo.Static:
+ default:
+ value = value || {};
+ quarter = isNull(value.quarter) ? null : value.quarter;
+ this.yearEditor.setValue(value.year);
+ this.quarterEditor.setValue(quarter);
+ this.setTitle(this._getStaticTitle(value));
+ break;
}
- },
+ }
- getValue: function () {
+ getValue() {
return this.storeValue;
- },
+ }
- getKey: function () {
- return this.yearEditor.getValue() + "-" + this.quarterEditor.getValue();
- },
+ getKey() {
+ return `${this.yearEditor.getValue()}-${this.quarterEditor.getValue()}`;
+ }
- isStateValid: function () {
+ isStateValid() {
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);
+}
diff --git a/src/widget/yearquarterinterval/yearquarterinterval.js b/src/widget/yearquarterinterval/yearquarterinterval.js
index 02a0c67d7..16fa9f4a5 100644
--- a/src/widget/yearquarterinterval/yearquarterinterval.js
+++ b/src/widget/yearquarterinterval/yearquarterinterval.js
@@ -1,193 +1,248 @@
-/**
- * @author windy
- * @version 2.0
- * Created by windy on 2021/1/25
- */
-BI.YearQuarterInterval = BI.inherit(BI.Single, {
- constants: {
+import {
+ shortcut,
+ HorizontalFillLayout,
+ createWidget,
+ i18nText,
+ print,
+ 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,
width: 25,
lgap: 15,
offset: -15,
- timeErrorCls: "time-error"
- },
-
- props: {
+ timeErrorCls: "time-error",
+ };
+ props = {
extraCls: "bi-year-quarter-interval",
minDate: "1900-01-01",
maxDate: "2099-12-31",
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 () {
- var self = this, o = this.options;
+ render() {
+ const o = this.options;
o.value = o.value || {};
this.left = this._createCombo(o.value.start, o.watermark?.start);
this.right = this._createCombo(o.value.end, o.watermark?.end);
-
return {
- type: "bi.horizontal_fill",
+ type: HorizontalFillLayout.xtype,
columnSize: ["fill", "", "fill"],
- items: [{
- el: self.left
- }, {
- el: {
- type: "bi.label",
- height: o.height,
- hgap: 5,
- text: "-",
- ref: function (_ref) {
- self.label = _ref;
- }
+ items: [
+ {
+ el: this.left,
+ },
+ {
+ el: {
+ type: Label.xtype,
+ height: o.height,
+ hgap: 5,
+ text: "-",
+ ref: _ref => {
+ this.label = _ref;
+ },
+ },
+ },
+ {
+ el: this.right,
}
- }, {
- el: self.right
- }]
+ ],
};
- },
+ }
- _createCombo: function (v, watermark) {
- var self = this, o = this.options;
- var combo = BI.createWidget({
- type: "bi.dynamic_year_quarter_combo",
+ _createCombo(v, watermark) {
+ const o = this.options;
+ const combo = createWidget({
+ type: DynamicYearQuarterCombo.xtype,
supportDynamic: o.supportDynamic,
minDate: o.minDate,
maxDate: o.maxDate,
behaviors: o.behaviors,
value: v,
height: o.height,
- watermark: watermark,
- listeners: [{
- eventName: BI.DynamicYearQuarterCombo.EVENT_BEFORE_POPUPVIEW,
- action: function () {
- self.fireEvent(BI.YearQuarterInterval.EVENT_BEFORE_POPUPVIEW);
+ watermark,
+ listeners: [
+ {
+ eventName: DynamicYearQuarterCombo.EVENT_BEFORE_POPUPVIEW,
+ action: () => {
+ this.fireEvent(
+ YearQuarterInterval.EVENT_BEFORE_POPUPVIEW
+ );
+ },
}
- }]
+ ],
});
- combo.on(BI.DynamicYearQuarterCombo.EVENT_ERROR, function () {
- self._clearTitle();
- BI.Bubbles.hide("error");
- self.element.removeClass(self.constants.timeErrorCls);
- self.fireEvent(BI.YearQuarterInterval.EVENT_ERROR);
+ combo.on(DynamicYearQuarterCombo.EVENT_ERROR, () => {
+ this._clearTitle();
+ Bubbles.hide("error");
+ this.element.removeClass(this.constants.timeErrorCls);
+ this.fireEvent(YearQuarterInterval.EVENT_ERROR);
});
- combo.on(BI.DynamicYearQuarterCombo.EVENT_VALID, function () {
- self._checkValid();
+ combo.on(DynamicYearQuarterCombo.EVENT_VALID, () => {
+ this._checkValid();
});
- combo.on(BI.DynamicYearQuarterCombo.EVENT_FOCUS, function () {
- self._checkValid();
+ combo.on(DynamicYearQuarterCombo.EVENT_FOCUS, () => {
+ this._checkValid();
});
- combo.on(BI.DynamicYearQuarterCombo.EVENT_CONFIRM, function () {
- BI.Bubbles.hide("error");
- var smallDate = self.left.getKey(), bigDate = self.right.getKey();
- if (self.left.isStateValid() && self.right.isStateValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) {
- self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text"));
- self.element.addClass(self.constants.timeErrorCls);
- self.fireEvent(BI.YearQuarterInterval.EVENT_ERROR);
- }else{
- self._clearTitle();
- self.element.removeClass(self.constants.timeErrorCls);
- self.fireEvent(BI.YearQuarterInterval.EVENT_CHANGE);
+ combo.on(DynamicYearQuarterCombo.EVENT_CONFIRM, () => {
+ Bubbles.hide("error");
+ const smallDate = this.left.getKey(),
+ bigDate = this.right.getKey();
+ if (
+ this.left.isStateValid() &&
+ this.right.isStateValid() &&
+ this._check(smallDate, bigDate) &&
+ this._compare(smallDate, bigDate)
+ ) {
+ 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;
- },
-
-
- _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: function (obj) {
- var o = this.options;
- return !BI.checkDateVoid(obj.year, (obj.quarter - 1) * 3 + 1, 1, o.minDate, o.maxDate)[0];
- },
+ _checkVoid(obj) {
+ const o = this.options;
+
+ return !checkDateVoid(
+ obj.year,
+ (obj.quarter - 1) * 3 + 1,
+ 1,
+ o.minDate,
+ o.maxDate
+ )[0];
+ }
- // 判格式合法
- _check: function (smallDate, bigDate) {
- var smallObj = smallDate.match(/\d+/g), bigObj = bigDate.match(/\d+/g);
+ _check(smallDate, bigDate) {
+ const smallObj = smallDate.match(/\d+/g),
+ bigObj = bigDate.match(/\d+/g);
- var smallDate4Check = "";
- if (BI.isNotNull(smallObj)) {
- smallDate4Check = (smallObj[0] || "") + "-" + (smallObj[1] || 1);
+ let smallDate4Check = "";
+ if (isNotNull(smallObj)) {
+ smallDate4Check = `${smallObj[0] || ""}-${smallObj[1] || 1}`;
}
- var bigDate4Check = "";
- if (BI.isNotNull(bigObj)) {
- bigDate4Check = (bigObj[0] || "") + "-" + (bigObj[1] || 1);
+ let bigDate4Check = "";
+ if (isNotNull(bigObj)) {
+ bigDate4Check = `${bigObj[0] || ""}-${bigObj[1] || 1}`;
}
- return this._dateCheck(smallDate4Check) && BI.checkDateLegal(smallDate4Check) && this._checkVoid({
- year: smallObj[0],
- quarter: smallObj[1] || 1
- }) && this._dateCheck(bigDate4Check) && BI.checkDateLegal(bigDate4Check) && this._checkVoid({
- year: bigObj[0],
- quarter: bigObj[1] || 1
- });
- },
-
- _compare: function (smallDate, bigDate) {
- smallDate = BI.print(BI.parseDateTime(smallDate, "%Y-%Q"), "%Y-%Q");
- bigDate = BI.print(BI.parseDateTime(bigDate, "%Y-%Q"), "%Y-%Q");
- return BI.isNotNull(smallDate) && BI.isNotNull(bigDate) && smallDate > bigDate;
- },
- _setTitle: function (v) {
+ return (
+ this._dateCheck(smallDate4Check) &&
+ checkDateLegal(smallDate4Check) &&
+ this._checkVoid({
+ year: smallObj[0],
+ quarter: smallObj[1] || 1,
+ }) &&
+ this._dateCheck(bigDate4Check) &&
+ checkDateLegal(bigDate4Check) &&
+ this._checkVoid({
+ year: bigObj[0],
+ quarter: bigObj[1] || 1,
+ })
+ );
+ }
+
+ _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);
- },
- _clearTitle: function () {
+ }
+
+ _clearTitle() {
this.setTitle("");
- },
- _checkValid: function () {
- var self = this;
-
- BI.Bubbles.hide("error");
- var smallDate = self.left.getKey(), bigDate = self.right.getKey();
- if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) {
- self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text"));
- self.element.addClass(self.constants.timeErrorCls);
- BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, {
- offsetStyle: "center"
- });
- self.fireEvent(BI.YearQuarterInterval.EVENT_ERROR);
+ }
+
+ _checkValid() {
+ Bubbles.hide("error");
+ const smallDate = this.left.getKey(),
+ bigDate = this.right.getKey();
+ if (
+ this.left.isValid() &&
+ this.right.isValid() &&
+ this._check(smallDate, bigDate) &&
+ this._compare(smallDate, bigDate)
+ ) {
+ 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 {
- self._clearTitle();
- self.element.removeClass(self.constants.timeErrorCls);
+ this._clearTitle();
+ this.element.removeClass(this.constants.timeErrorCls);
}
- },
+ }
- setMinDate: function (minDate) {
- var o = this.options;
+ setMinDate(minDate) {
+ const o = this.options;
o.minDate = minDate;
this.left.setMinDate(minDate);
this.right.setMinDate(minDate);
- },
+ }
- setMaxDate: function (maxDate) {
- var o = this.options;
+ setMaxDate(maxDate) {
+ const o = this.options;
o.maxDate = maxDate;
this.left.setMaxDate(maxDate);
this.right.setMaxDate(maxDate);
- },
+ }
- setValue: function (date) {
+ setValue(date) {
date = date || {};
this.left.setValue(date.start);
this.right.setValue(date.end);
this._checkValid();
- },
- getValue: function () {
- return {start: this.left.getValue(), end: this.right.getValue()};
}
-});
-BI.YearQuarterInterval.EVENT_VALID = "EVENT_VALID";
-BI.YearQuarterInterval.EVENT_ERROR = "EVENT_ERROR";
-BI.YearQuarterInterval.EVENT_CHANGE = "EVENT_CHANGE";
-BI.YearQuarterInterval.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
-BI.shortcut("bi.year_quarter_interval", BI.YearQuarterInterval);
+
+ getValue() {
+ return { start: this.left.getValue(), end: this.right.getValue() };
+ }
+}
diff --git a/webpack/attachments.js b/webpack/attachments.js
index acb30ad2a..f04bf8ed7 100644
--- a/webpack/attachments.js
+++ b/webpack/attachments.js
@@ -19,25 +19,25 @@ const basicAttachmentMap = {
"src/less/theme/**/*.less",
lodashJs,
jqueryJs,
- "src/core/**/*.js",
- "src/data/**/*.js",
+ // "src/core/**/*.js",
+ // "src/data/**/*.js",
]),
// 最基础的控件
base: sync([
"src/less/base/**/*.less",
- "src/third/**/*.js",
- "src/base/**/*.js",
+ // "src/third/**/*.js",
+ // "src/base/**/*.js",
]),
// 实现好的一些基础实例
- case: sync([
- "src/case/**/*.js",
+ "case": sync([
+ // "src/case/**/*.js",
"src/less/case/**/*.less",
]),
widget: sync([
"src/less/widget/**/*.less",
"src/less/component/**/*.less",
- "src/widget/**/*.js",
- "src/component/**/*.js",
+ // "src/widget/**/*.js",
+ // "src/component/**/*.js",
]),
router: sync([
"src/router/**/*.js",
@@ -238,6 +238,7 @@ const demo = [].concat(
basicAttachmentMap.core,
basicAttachmentMap.fix,
basicAttachmentMap.config,
+ sync(["src/bundle.js"]),
basicAttachmentMap.base,
basicAttachmentMap.case,
basicAttachmentMap.widget,