提交 0e167c54 编写于 作者: Mosher's avatar Mosher

update:更新多项选择视图逻辑

上级 85348837
...@@ -24,11 +24,9 @@ export class MPickupView extends PickupView { ...@@ -24,11 +24,9 @@ export class MPickupView extends PickupView {
*/ */
public declare props: MPickupViewProps; public declare props: MPickupViewProps;
public select: IParam = {};
public onMoveRight() { public onMoveRight() {
const { selections, selectedData } = toRefs(this.state); const { selections, selectedData } = toRefs(this.state);
selections.value.push(selectedData.value); selections.value = selectedData.value;
} }
public onMoveLeft() { public onMoveLeft() {
...@@ -44,8 +42,13 @@ export class MPickupView extends PickupView { ...@@ -44,8 +42,13 @@ export class MPickupView extends PickupView {
} }
public onAllMoveLeft() { public onAllMoveLeft() {
const { selections } = toRefs(this.state); const { selections, selectedData } = toRefs(this.state);
selections.value.splice(0, selections.value.length); selections.value = [];
selectedData.value = [];
}
protected onRightPanelClick(item: IParam, event: MouseEvent) {
console.log("选中右侧面板数据", item, event);
} }
/** /**
...@@ -61,6 +64,7 @@ export class MPickupView extends PickupView { ...@@ -61,6 +64,7 @@ export class MPickupView extends PickupView {
onMoveLeft: this.onMoveLeft.bind(this), onMoveLeft: this.onMoveLeft.bind(this),
onAllMoveRight: this.onAllMoveRight.bind(this), onAllMoveRight: this.onAllMoveRight.bind(this),
onAllMoveLeft: this.onAllMoveLeft.bind(this), onAllMoveLeft: this.onAllMoveLeft.bind(this),
onRightPanelClick: this.onRightPanelClick.bind(this)
}; };
} }
} }
\ No newline at end of file
...@@ -87,14 +87,6 @@ export class ControlBase { ...@@ -87,14 +87,6 @@ export class ControlBase {
}); });
} }
/**
* 使用部件初始化模块
*
* @protected
* @memberof ControlBase
*/
protected useCtrlInit(): void {};
/** /**
* 获取当前激活数据 * 获取当前激活数据
* *
...@@ -133,8 +125,6 @@ export class ControlBase { ...@@ -133,8 +125,6 @@ export class ControlBase {
this.useControlContextParams(); this.useControlContextParams();
// 使用计数器服务 // 使用计数器服务
this.useCounterService(); this.useCounterService();
// 使用部件初始化模块
this.useCtrlInit();
return { return {
state: this.state, state: this.state,
name: this.state.controlName, name: this.state.controlName,
......
...@@ -358,24 +358,8 @@ export class GridControl extends MDControl { ...@@ -358,24 +358,8 @@ export class GridControl extends MDControl {
* @memberof GridControl * @memberof GridControl
*/ */
public handleDefaultSelect() { public handleDefaultSelect() {
const { selectedData, selectFirstDefault, items } = this.state; const { selectFirstDefault, items } = this.state;
const { selectedRowKeys, selections } = toRefs(this.state); if (selectFirstDefault && items && items.length) {
if (selectedData?.length > 0) {
const _selectedRowKeys: string[] = [];
const _selections: IParam[] = [];
selectedData.forEach((selected: IParam) => {
if (selected.srfkey) {
_selectedRowKeys.push(selected.srfkey);
const item = items.find((item: IParam) => item.srfkey === selected.srfkey);
if (item) {
_selections.push(item);
}
}
});
selectedRowKeys.value = [..._selectedRowKeys];
selections.value = [..._selections];
} else if (selectFirstDefault) {
if (items && items.length > 0) {
this.emit("ctrlEvent", { this.emit("ctrlEvent", {
tag: this.props.name, tag: this.props.name,
action: "selectionChange", action: "selectionChange",
...@@ -383,7 +367,6 @@ export class GridControl extends MDControl { ...@@ -383,7 +367,6 @@ export class GridControl extends MDControl {
}); });
} }
} }
}
/** /**
* @description 处理数据聚合 * @description 处理数据聚合
......
...@@ -71,13 +71,6 @@ export interface MDControlState extends MainControlState { ...@@ -71,13 +71,6 @@ export interface MDControlState extends MainControlState {
*/ */
rowActiveMode: 0 | 1 | 2; rowActiveMode: 0 | 1 | 2;
/**
* @description 选中数据(选择视图传递)
* @type {IParam[]}
* @memberof MDControlState
*/
selectedData: IParam[];
/** /**
* @description 选中数据 * @description 选中数据
* @type {IParam[]} * @type {IParam[]}
......
...@@ -26,11 +26,9 @@ export class MDControl extends MainControl { ...@@ -26,11 +26,9 @@ export class MDControl extends MainControl {
this.state.rowEditState = toRef(this.props, 'rowEditState') as any; this.state.rowEditState = toRef(this.props, 'rowEditState') as any;
this.state.rowActiveMode = toRef(this.props, 'rowActiveMode') as any; this.state.rowActiveMode = toRef(this.props, 'rowActiveMode') as any;
this.state.selectFirstDefault = toRef(this.props, 'selectFirstDefault') as any; this.state.selectFirstDefault = toRef(this.props, 'selectFirstDefault') as any;
} watch(() => this.props.selectedData, (newVal: IParam[], oldVal: any) => {
this.handleSelectedData(newVal, oldVal);
protected useCtrlInit() { });
super.useCtrlInit();
this.handleSelectedData();
} }
/** /**
...@@ -39,22 +37,22 @@ export class MDControl extends MainControl { ...@@ -39,22 +37,22 @@ export class MDControl extends MainControl {
* @private * @private
* @memberof MDControl * @memberof MDControl
*/ */
protected handleSelectedData() { protected handleSelectedData(newVal: IParam[], oldVal: any) {
const { viewParams } = this.state; const { selections, selectedRowKeys, items } = toRefs(this.state);
// 存在该字段则表示在选择视图中 selections.value = [];
if (viewParams && viewParams.selectedData) { const _selectedRowKeys: string[] = [];
const data = viewParams.selectedData[0]; const _selections: IParam[] = [];
const keys = data?.srfkey?.split(',') || []; newVal.forEach((selected: IParam) => {
this.state.selectedData = []; if (selected.srfkey) {
if (keys.length) { _selectedRowKeys.push(selected.srfkey);
keys.forEach((key: string) => { const item = items.value.find((item: IParam) => item.srfkey === selected.srfkey);
this.state.selectedData.push({ srfkey: key }); if (item) {
}); _selections.push(item);
} else {
// 无值时给一个空对象,确保清空选中数据
this.state.selectedData.push({});
} }
} }
});
selectedRowKeys.value = [..._selectedRowKeys];
selections.value = [..._selections];
} }
/** /**
......
...@@ -18,16 +18,6 @@ export class PickupViewPanelControl extends MainControl { ...@@ -18,16 +18,6 @@ export class PickupViewPanelControl extends MainControl {
*/ */
public declare state: PickupViewPanelControlState; public declare state: PickupViewPanelControlState;
/**
* 设置部件状态
*
* @memberof PickupViewPanelControl
*/
public setState(): void {
super.setState();
this.state.selectedData = toRef(this.props, 'selectedData') as any;
}
/** /**
* @description * @description
* @param {PickupViewPanelControlProps} props * @param {PickupViewPanelControlProps} props
......
export const viewState = { export const viewState = {
// 实际选中数据
selections: [],
// 右侧面板选中数据
rightPanelSelections: [],
{{> @macro/front-end/views/view-base-config.hbs}} {{> @macro/front-end/views/view-base-config.hbs}}
}; };
\ No newline at end of file
...@@ -30,7 +30,7 @@ const emit = defineEmits<ViewEmit>(); ...@@ -30,7 +30,7 @@ const emit = defineEmits<ViewEmit>();
// 安装功能模块,提供状态和能力方法 // 安装功能模块,提供状态和能力方法
const mpickupView = new MPickupView(viewState, props, emit).moduleInstall(); const mpickupView = new MPickupView(viewState, props, emit).moduleInstall();
const { state, onCancel, onConfirm, onCtrlEvent, onMoveRight, onMoveLeft, onAllMoveRight, onAllMoveLeft } = mpickupView; const { state, onCancel, onConfirm, onCtrlEvent, onMoveRight, onMoveLeft, onAllMoveRight, onAllMoveLeft, onRightPanelClick } = mpickupView;
</script> </script>
<template> <template>
...@@ -63,6 +63,7 @@ const { state, onCancel, onConfirm, onCtrlEvent, onMoveRight, onMoveLeft, onAllM ...@@ -63,6 +63,7 @@ const { state, onCancel, onConfirm, onCtrlEvent, onMoveRight, onMoveLeft, onAllM
:controlAction="state.{{name}}.action" :controlAction="state.{{name}}.action"
:viewSubject="state.viewSubject" :viewSubject="state.viewSubject"
:multiple="true" :multiple="true"
:selectedData="state.selections"
:parent="mpickupView" :parent="mpickupView"
@onCtrlEvent="onCtrlEvent" @onCtrlEvent="onCtrlEvent"
></{{codeName}}PickupViewPanel> ></{{codeName}}PickupViewPanel>
...@@ -78,7 +79,9 @@ const { state, onCancel, onConfirm, onCtrlEvent, onMoveRight, onMoveLeft, onAllM ...@@ -78,7 +79,9 @@ const { state, onCancel, onConfirm, onCtrlEvent, onMoveRight, onMoveLeft, onAllM
</a-space> </a-space>
</a-col> </a-col>
<a-col :span="5" class="split__right"> <a-col :span="5" class="split__right">
<div v-for="(item,index) in state.selections" :key="index">\{{item.srfmajortext}}</div> <div v-for="(item, index) in state.selections" :key="index" class="selection-item" @click="(event) => onRightPanelClick(item, event)">
<span class="text">\{{item.srfmajortext}}</span>
</div>
</a-col> </a-col>
</a-row> </a-row>
<template v-slot:footer> <template v-slot:footer>
......
...@@ -22,7 +22,7 @@ interface Props { ...@@ -22,7 +22,7 @@ interface Props {
viewParams?: IParam; viewParams?: IParam;
openType?: "ROUTE" | "MODAL" | "EMBED"; openType?: "ROUTE" | "MODAL" | "EMBED";
viewSubject?: Subject<IActionParam>; viewSubject?: Subject<IActionParam>;
selectedData?: string; selectedData?: IParam[];
multiple?: boolean; multiple?: boolean;
} }
...@@ -113,6 +113,7 @@ const { state, grid, onCtrlEvent, onQuickGroupEvent, onQuickSearchEvent } = pick ...@@ -113,6 +113,7 @@ const { state, grid, onCtrlEvent, onQuickGroupEvent, onQuickSearchEvent } = pick
:showBusyIndicator="true" :showBusyIndicator="true"
:viewParams="state.viewParams" :viewParams="state.viewParams"
:controlAction="state.{{name}}.action" :controlAction="state.{{name}}.action"
:selectedData="selectedData"
:viewSubject="state.viewSubject" :viewSubject="state.viewSubject"
:parent="pickupGridView" :parent="pickupGridView"
@ctrlEvent="onCtrlEvent" @ctrlEvent="onCtrlEvent"
......
...@@ -22,7 +22,7 @@ interface Props { ...@@ -22,7 +22,7 @@ interface Props {
viewParams?: IParam; viewParams?: IParam;
openType?: "ROUTE" | "MODAL" | "EMBED"; openType?: "ROUTE" | "MODAL" | "EMBED";
viewSubject?: Subject<IActionParam>; viewSubject?: Subject<IActionParam>;
selectedData?: string; selectedData?: IParam[];
} }
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
...@@ -111,6 +111,7 @@ const { state, tree, onCtrlEvent, onQuickGroupEvent, onQuickSearchEvent } = pick ...@@ -111,6 +111,7 @@ const { state, tree, onCtrlEvent, onQuickGroupEvent, onQuickSearchEvent } = pick
:controlAction="state.{{name}}.action" :controlAction="state.{{name}}.action"
:viewSubject="state.viewSubject" :viewSubject="state.viewSubject"
:parent="pickupTreeView" :parent="pickupTreeView"
:selectedData="selectedData"
@ctrlEvent="onCtrlEvent" @ctrlEvent="onCtrlEvent"
></{{codeName}}Tree> ></{{codeName}}Tree>
{{/eq}} {{/eq}}
......
...@@ -14,6 +14,7 @@ interface Props { ...@@ -14,6 +14,7 @@ interface Props {
multiple?: boolean; multiple?: boolean;
rowEditState?: boolean; rowEditState?: boolean;
rowActiveMode?: 0 | 1 | 2; rowActiveMode?: 0 | 1 | 2;
selectedData: IParam[];
selectFirstDefault?: boolean; selectFirstDefault?: boolean;
controlAction: ControlAction; controlAction: ControlAction;
showBusyIndicator?: boolean; showBusyIndicator?: boolean;
......
...@@ -14,7 +14,7 @@ interface Props { ...@@ -14,7 +14,7 @@ interface Props {
showBusyIndicator?: boolean; showBusyIndicator?: boolean;
isSingleSelect?: boolean; isSingleSelect?: boolean;
viewMode?: number; viewMode?: number;
selectedData?: string; selectedData?: IParam[];
isShowButton?: boolean; isShowButton?: boolean;
viewSubject: Subject<IActionParam>; viewSubject: Subject<IActionParam>;
multiple?: boolean; multiple?: boolean;
...@@ -51,7 +51,7 @@ defineExpose({ name, state}); ...@@ -51,7 +51,7 @@ defineExpose({ name, state});
:context="state.context" :context="state.context"
:viewParams="state.viewParams" :viewParams="state.viewParams"
:isShowButton="state.isShowButton" :isShowButton="state.isShowButton"
:selectedData="state.selectedData" :selectedData="selectedData"
:viewSubject="state.viewSubject" :viewSubject="state.viewSubject"
:multiple="multiple" :multiple="multiple"
@viewEvent="onViewEvent" @viewEvent="onViewEvent"
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册