From 97bd7d28df9a39151663edb73b6f86807341cb90 Mon Sep 17 00:00:00 2001 From: "jlj05024111@163.com" Date: Wed, 11 Jun 2025 19:34:58 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E5=A4=9A?= =?UTF-8?q?=E9=A1=B9=E6=95=B0=E6=8D=AE=E9=80=89=E6=8B=A9=E6=A0=91=E8=A7=86?= =?UTF-8?q?=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/controller/src/control/tree.ts | 29 +++++++++++++++++++ .../ability/view/i-mpickup-view-ability.ts | 19 +++++++++++- .../nerve/control/pickup-view-panel-nerve.ts | 11 +++++-- .../neuron/nerve/view/mpickup-view-nerve.ts | 12 +++++++- packages/controller/src/view/mpickup-view.ts | 20 ++++++++++++- .../views/mpickup-view/mpickup-view.scss | 11 ++++++- 6 files changed, 95 insertions(+), 7 deletions(-) diff --git a/packages/controller/src/control/tree.ts b/packages/controller/src/control/tree.ts index dbe0cf70e8b..8288009ff00 100644 --- a/packages/controller/src/control/tree.ts +++ b/packages/controller/src/control/tree.ts @@ -67,6 +67,35 @@ export class TreeController extends MDController { await this.service.init(this.context); } + /** + * 将树形数据转为一维数组 + * + * @param {ITreeNodeData} data + * @return {*} {IData[]} + * @memberof TreeController + */ + convertTreeDataToArray(data: ITreeNodeData[]): IData[] { + const result: IData[] = []; + for (const child of data) { + result.push(child); + if (child.children) { + result.push(...this.convertTreeDataToArray(child.children)); + } + } + return result; + } + + async selectAll(): Promise { + const list = this.convertTreeDataToArray(this.treeNodes); + const tempMap = new Map(); + list.forEach(item => { + tempMap.set(item.id, item); + }); + this.selectedData = Array.from(tempMap.values()); + await this.nerve.self.evt.emit('selectionChange', this.selectedData); + return this.selectedData; + } + /** * 获取数据 * @author lxm diff --git a/packages/controller/src/interface/ability/view/i-mpickup-view-ability.ts b/packages/controller/src/interface/ability/view/i-mpickup-view-ability.ts index 0282d16c05c..40ecce2cc9f 100644 --- a/packages/controller/src/interface/ability/view/i-mpickup-view-ability.ts +++ b/packages/controller/src/interface/ability/view/i-mpickup-view-ability.ts @@ -9,4 +9,21 @@ import { IViewAbility } from './i-view-ability'; * @interface IPickupViewAbility * @extends {IViewAbility} */ -export type IMPickupViewAbility = IViewAbility; +export interface IMPickupViewAbility extends IViewAbility { + /** + * 获取选中数据 + * + * @author lxm + * @date 2022-09-12 19:09:39 + * @returns {*} {Promise} + */ + getSelectData(): IData[]; + + /** + * 设置选中数据 + * + * @param {IData[]} data + * @memberof IMPickupViewAbility + */ + setSelectData(data: IData[]): void; +} diff --git a/packages/controller/src/neuron/nerve/control/pickup-view-panel-nerve.ts b/packages/controller/src/neuron/nerve/control/pickup-view-panel-nerve.ts index 3e4f75aafac..e796a914c66 100644 --- a/packages/controller/src/neuron/nerve/control/pickup-view-panel-nerve.ts +++ b/packages/controller/src/neuron/nerve/control/pickup-view-panel-nerve.ts @@ -1,4 +1,9 @@ -import { Neuron, PickupGridViewNeuron, PickupViewPanelNeuron } from '../..'; +import { + Neuron, + PickupGridViewNeuron, + PickupTreeViewNeuron, + PickupViewPanelNeuron, +} from '../..'; import { PickupViewPanelController } from '../../..'; import { ViewPanelNerve } from './view-panel-nerve'; @@ -15,7 +20,7 @@ export class PickupViewPanelNerve extends ViewPanelNerve< PickupViewPanelNeuron, PickupViewPanelController > { - declare embedView: PickupGridViewNeuron; + declare embedView: PickupGridViewNeuron | PickupTreeViewNeuron; protected createNeuron(): PickupViewPanelNeuron { return new PickupViewPanelNeuron(this.bindAbility()); @@ -34,7 +39,7 @@ export class PickupViewPanelNerve extends ViewPanelNerve< super.connect(name, neuron); // 监听嵌入视图,选择类视图会抛数据选择变更事件 if (name === 'embedView') { - this.embedView = neuron as PickupGridViewNeuron; + this.embedView = neuron as PickupGridViewNeuron | PickupTreeViewNeuron; this.embedView.evt.on('selectionChange', data => { this.self.evt.asyncEmit('selectionChange', data); }); diff --git a/packages/controller/src/neuron/nerve/view/mpickup-view-nerve.ts b/packages/controller/src/neuron/nerve/view/mpickup-view-nerve.ts index c79f2645e7d..235c4966a17 100644 --- a/packages/controller/src/neuron/nerve/view/mpickup-view-nerve.ts +++ b/packages/controller/src/neuron/nerve/view/mpickup-view-nerve.ts @@ -1,4 +1,4 @@ -import { MPickupViewNeuron } from '../..'; +import { MPickupViewNeuron, Neuron, PickupViewPanelNeuron } from '../..'; import { MPickupViewController } from '../../..'; import { PickupViewNerve } from './pickup-view-nerve'; @@ -15,7 +15,17 @@ export class MPickupViewNerve extends PickupViewNerve< MPickupViewNeuron, MPickupViewController > { + declare pickUpView: PickupViewPanelNeuron; + protected createNeuron(): MPickupViewNeuron { return new MPickupViewNeuron(this.bindAbility()); } + + protected bindAbility() { + return { + ...super.bindAbility(), + getSelectData: this.controller.onGetSelectionData.bind(this.controller), + setSelectData: this.controller.onSelectionChange.bind(this.controller), + }; + } } diff --git a/packages/controller/src/view/mpickup-view.ts b/packages/controller/src/view/mpickup-view.ts index edaac1fc2fb..12e208774d3 100644 --- a/packages/controller/src/view/mpickup-view.ts +++ b/packages/controller/src/view/mpickup-view.ts @@ -1,4 +1,5 @@ import { MPickupViewModel } from '@ibiz-template/model'; +import { ITreeNodeData, TreeNodeData } from '@ibiz-template/service'; import { MPickupViewNerve } from '../neuron'; import { PickupViewController } from './pickup-view'; @@ -54,6 +55,16 @@ export class MPickupViewController extends PickupViewController 0) { + // 针对树节点数据进行优化 + const tempData = data.map(item => { + if (item instanceof TreeNodeData) { + return (item as ITreeNodeData).deData || {}; + } + return item; + }); // 去重,过滤已经选中的数据 - const addData = data.filter(item => { + const addData = tempData.filter(item => { return !this.selfSelection.find( selection => selection.srfkey === item.srfkey, ); diff --git a/packages/theme/style/components/views/mpickup-view/mpickup-view.scss b/packages/theme/style/components/views/mpickup-view/mpickup-view.scss index d2630cb8ade..8bc0cbd61be 100644 --- a/packages/theme/style/components/views/mpickup-view/mpickup-view.scss +++ b/packages/theme/style/components/views/mpickup-view/mpickup-view.scss @@ -28,12 +28,21 @@ @include e(list-item) { @include flex(row, space-between); + align-items: center; padding: getCssVar('mpickup-view-right', 'item-padding'); border-bottom: getCssVar('mpickup-view-right', 'item-border-bottom'); - + > i { + flex-shrink: 0; cursor: pointer; } + @include m('text'){ + flex: 1; + width: 100%; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } @include when(selected) { color: getCssVar('mpickup-view-right', 'item-selected-color'); -- Gitee From b96fd2a8f0fdae4c44d1fbdb2ecacfbba599e5ff Mon Sep 17 00:00:00 2001 From: "jlj05024111@163.com" Date: Wed, 11 Jun 2025 19:42:44 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/controller/src/neuron/nerve/view/mpickup-view-nerve.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/controller/src/neuron/nerve/view/mpickup-view-nerve.ts b/packages/controller/src/neuron/nerve/view/mpickup-view-nerve.ts index 235c4966a17..27a31d0e181 100644 --- a/packages/controller/src/neuron/nerve/view/mpickup-view-nerve.ts +++ b/packages/controller/src/neuron/nerve/view/mpickup-view-nerve.ts @@ -1,4 +1,4 @@ -import { MPickupViewNeuron, Neuron, PickupViewPanelNeuron } from '../..'; +import { MPickupViewNeuron, PickupViewPanelNeuron } from '../..'; import { MPickupViewController } from '../../..'; import { PickupViewNerve } from './pickup-view-nerve'; -- Gitee