From e3ecaac8b90bf46a025a7b42d3fdc25ab2074381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=2EKing-=E7=8E=8B=E5=87=AF=E5=A3=AE?= Date: Tue, 18 Jul 2023 16:21:12 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-100874=20fix:=E3=80=90=E4=B8=93=E9=A2=98?= =?UTF-8?q?=E3=80=91=E3=80=90=E6=9D=83=E9=99=90=E5=A4=8D=E7=94=A8=E3=80=91?= =?UTF-8?q?=E6=9D=83=E9=99=90=E5=A4=8D=E7=94=A8=E6=97=B6=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E4=B8=8B=E9=80=89=E4=B8=AD=E9=83=A8=E9=97=A8?= =?UTF-8?q?=EF=BC=8C=E6=90=9C=E7=B4=A2=E7=8A=B6=E6=80=81=E4=B8=8B=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E5=85=B6=E4=B8=AD1=E4=B8=AA=E8=81=8C=E5=8A=A1?= =?UTF-8?q?=EF=BC=8C=E5=8F=96=E6=B6=88=E6=90=9C=E7=B4=A2=E5=90=8E=E5=8F=91?= =?UTF-8?q?=E7=8E=B0=E8=81=8C=E5=8A=A1=E8=BF=98=E6=98=AF=E9=80=89=E4=B8=AD?= =?UTF-8?q?=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../abstract.treevaluechooser.js | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/packages/fineui/src/component/treevaluechooser/abstract.treevaluechooser.js b/packages/fineui/src/component/treevaluechooser/abstract.treevaluechooser.js index 61323f27c..90bf612d4 100644 --- a/packages/fineui/src/component/treevaluechooser/abstract.treevaluechooser.js +++ b/packages/fineui/src/component/treevaluechooser/abstract.treevaluechooser.js @@ -174,6 +174,7 @@ export class AbstractTreeValueChooser extends Widget { } _reqSelectedTreeNode(op, callback) { + const self = this; const selectedValues = deepClone(op.selectedValues); const notSelectedValue = op.notSelectedValue || {}; const keyword = op.keyword || ""; @@ -188,7 +189,7 @@ export class AbstractTreeValueChooser extends Widget { dealWithSelectedValues(selectedValues); callback(selectedValues); - const dealWithSelectedValues = selectedValues => { + function dealWithSelectedValues(selectedValues) { let p = parentValues.concat(notSelectedValue); // 存储的值中存在这个值就把它删掉 // 例如选中了中国-江苏-南京, 取消中国或江苏或南京 @@ -197,18 +198,18 @@ export class AbstractTreeValueChooser extends Widget { // 如果搜索的值在父亲链中 if (isSearchValueInParent(p)) { // 例如选中了 中国-江苏, 搜索江苏, 取消江苏(干掉了江苏) - this._deleteNode(selectedValues, p); + self._deleteNode(selectedValues, p); } else { const searched = []; // 要找到所有以notSelectedValue为叶子节点的链路 const find = search(parentValues, notSelectedValue, [], searched); if (find && isNotEmptyArray(searched)) { each(searched, (i, arr) => { - const node = this._getNode(selectedValues, arr); + const node = self._getNode(selectedValues, arr); if (node) { // 例如选中了 中国-江苏, 搜索江苏, 取消中国(实际上只想删除中国-江苏,因为搜的是江苏) // 例如选中了 中国-江苏-南京,搜索南京,取消中国(实际上只想删除中国-江苏-南京,因为搜的是南京) - this._deleteNode(selectedValues, arr); + self._deleteNode(selectedValues, arr); } else { // 例如选中了 中国-江苏,搜索南京,取消中国(实际上只想删除中国-江苏-南京,因为搜的是南京) expandSelectedValue(selectedValues, arr, last(arr)); @@ -239,14 +240,14 @@ export class AbstractTreeValueChooser extends Widget { // 添加去掉搜索的结果集 if (result.length > 0) { each(result, (i, strs) => { - this._buildTree(selectedValues, strs); + self._buildTree(selectedValues, strs); }); } } } }; - const expandSelectedValue = (selectedValues, parents, notSelectedValue) => { + function expandSelectedValue(selectedValues, parents, notSelectedValue) { let next = selectedValues; const childrenCount = []; const path = []; @@ -259,7 +260,7 @@ export class AbstractTreeValueChooser extends Widget { } if (isEmpty(next)) { const split = parents.slice(0, i); - const expanded = this._getChildren(split); + const expanded = self._getChildren(split); path.push(split); childrenCount.push(expanded.length); // 如果只有一个值且取消的就是这个值 @@ -270,7 +271,7 @@ export class AbstractTreeValueChooser extends Widget { ) { for (let j = childrenCount.length - 1; j >= 0; j--) { if (childrenCount[j] === 1) { - this._deleteNode(selectedValues, path[j]); + self._deleteNode(selectedValues, path[j]); } else { break; } @@ -295,16 +296,16 @@ export class AbstractTreeValueChooser extends Widget { }); }; - const search = (parents, current, result, searched) => { + function search(parents, current, result, searched) { const newParents = clone(parents); newParents.push(current); - if (this._isMatch(parents, current, keyword)) { + if (self._isMatch(parents, current, keyword)) { searched && searched.push(newParents); return true; } - const children = this._getChildren(newParents); + const children = self._getChildren(newParents); const notSearch = []; let can = false; @@ -327,9 +328,9 @@ export class AbstractTreeValueChooser extends Widget { return can; }; - const isSearchValueInParent = parentValues => { + function isSearchValueInParent(parentValues) { for (let i = 0, len = parentValues.length; i < len; i++) { - if (this._isMatch(parentValues.slice(0, i), parentValues[i], keyword)) { + if (self._isMatch(parentValues.slice(0, i), parentValues[i], keyword)) { return true; } }