diff --git a/package.json b/package.json index fad3e653b..509c809e2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fineui", - "version": "2.0.20220921174940", + "version": "2.0.20220921223412", "description": "fineui", "main": "dist/fineui_without_conflict.min.js", "types": "dist/lib/index.d.ts", diff --git a/src/component/treevaluechooser/abstract.treevaluechooser.js b/src/component/treevaluechooser/abstract.treevaluechooser.js index 53e31298f..123185e08 100644 --- a/src/component/treevaluechooser/abstract.treevaluechooser.js +++ b/src/component/treevaluechooser/abstract.treevaluechooser.js @@ -851,6 +851,40 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, { return this._getChildren(parentValues).length; }, + assertSelectedValue: function (selectedValues, items = []) { + if (BI.isPlainObject(selectedValues)) { + return selectedValues; + } + + var tree = BI.Tree.transformToTreeFormat(items); + var value2ParentMap = {}; + BI.Tree.traversal(tree, function (index, node, pNode) { + value2ParentMap[node.value] = pNode; + }); + + var result = {}; + BI.each(selectedValues, function (index, value) { + var curr = value; + var 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), {}); + } + }); + // 执行完一条路径,check一下 + var lengths = BI.size(BI.get(result, parentPath.slice(0, -1))); + if (lengths === value2ParentMap[value]?.children?.length) { + BI.set(result, parentPath.slice(0, -1), {}); + } + }); + + return result; + }, + buildCompleteTree: function (selectedValues) { var self = this; var result = {}; diff --git a/src/component/treevaluechooser/combo.treevaluechooser.js b/src/component/treevaluechooser/combo.treevaluechooser.js index 33cb4e520..7b42f3d74 100644 --- a/src/component/treevaluechooser/combo.treevaluechooser.js +++ b/src/component/treevaluechooser/combo.treevaluechooser.js @@ -30,7 +30,7 @@ BI.TreeValueChooserCombo = BI.inherit(BI.AbstractTreeValueChooser, { text: o.text, defaultText: o.defaultText, allowEdit: o.allowEdit, - value: o.value, + value: this.assertSelectedValue(o.value, o.items), watermark: o.watermark, element: this, itemsCreator: BI.bind(this._itemsCreator, this), diff --git a/src/component/treevaluechooser/pane.treevaluechooser.js b/src/component/treevaluechooser/pane.treevaluechooser.js index 66486711a..8171c04d8 100644 --- a/src/component/treevaluechooser/pane.treevaluechooser.js +++ b/src/component/treevaluechooser/pane.treevaluechooser.js @@ -30,7 +30,8 @@ BI.TreeValueChooserPane = BI.inherit(BI.AbstractTreeValueChooser, { self.fireEvent(BI.TreeValueChooserPane.EVENT_CHANGE); }); if (BI.isNotNull(o.value)) { - this.pane.setSelectedValue(o.value); + var selectedValues = this.assertSelectedValue(o.value, o.items); + this.pane.setSelectedValue(selectedValues); } if (BI.isNotNull(o.items)) { this._initData(o.items); diff --git a/src/less/base/single/html.less b/src/less/base/single/html.less index 3159bc630..0a4279397 100644 --- a/src/less/base/single/html.less +++ b/src/less/base/single/html.less @@ -18,8 +18,6 @@ canvas, video { display: inline-block; - *display: inline; - *zoom: 1 } audio:not([controls]) { display: none; @@ -180,7 +178,6 @@ border: 0; padding: 0; white-space: normal; - *margin-left: -7px } button, input, @@ -189,7 +186,6 @@ font-size: 100%; margin: 0; vertical-align: baseline; - *vertical-align: middle } button, input { @@ -201,7 +197,6 @@ input[type="submit"] { -webkit-appearance: button; cursor: pointer; - *overflow: visible } button[disabled], input[disabled] { @@ -211,8 +206,8 @@ input[type="radio"] { box-sizing: border-box; padding: 0; - *height: 13px; - *width: 13px + height: 13px; + width: 13px } input[type="search"] { -webkit-appearance: textfield; @@ -237,4 +232,4 @@ border-collapse: collapse; border-spacing: 0 } -} \ No newline at end of file +} diff --git a/src/less/base/tree/ztree.less b/src/less/base/tree/ztree.less index 6f6fa77c7..e300e0be4 100644 --- a/src/less/base/tree/ztree.less +++ b/src/less/base/tree/ztree.less @@ -130,7 +130,6 @@ margin: 0; font-size: 12px; border: 1px #7EC4CC solid; - *border: 0px } .ztree li span { @@ -315,42 +314,36 @@ margin-right: 2px; background-position: -110px -16px; vertical-align: top; - *vertical-align: middle } .ztree li span.button.ico_close { margin-right: 2px; background-position: -110px 0; vertical-align: top; - *vertical-align: middle } .ztree li span.button.ico_docu { margin-right: 2px; background-position: -110px -32px; vertical-align: top; - *vertical-align: middle } .ztree li span.button.edit { margin-right: 2px; background-position: -110px -48px; vertical-align: top; - *vertical-align: middle } .ztree li span.button.remove { margin-right: 2px; background-position: -110px -64px; vertical-align: top; - *vertical-align: middle } .ztree li span.button.ico_loading { width: 0px; margin-right: 2px; vertical-align: top; - *vertical-align: middle } ul.tmpTargetzTree {