From b8ba319d6e7fb05e25898c44557429c028986377 Mon Sep 17 00:00:00 2001 From: likunming Date: Fri, 15 Mar 2024 16:47:08 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E4=BC=98=E5=8C=96=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- io.sc.platform.core.frontend/package.json | 2 +- .../src/platform/components/grid/WGrid.vue | 3 - .../platform/components/toolbar/WToolbar.vue | 88 +++++++++++++++++-- .../src/platform/types/ToolbarApiArgsType.ts | 35 ++++++++ .../src/platform/types/index.ts | 8 +- 5 files changed, 124 insertions(+), 12 deletions(-) create mode 100644 io.sc.platform.core.frontend/src/platform/types/ToolbarApiArgsType.ts diff --git a/io.sc.platform.core.frontend/package.json b/io.sc.platform.core.frontend/package.json index 2ee0b238..4b63a274 100644 --- a/io.sc.platform.core.frontend/package.json +++ b/io.sc.platform.core.frontend/package.json @@ -1,6 +1,6 @@ { "name": "platform-core", - "version": "8.1.142", + "version": "8.1.143", "description": "前端核心包,用于快速构建前端的脚手架", "//main": "库的主文件", "main": "dist/platform-core.js", diff --git a/io.sc.platform.core.frontend/src/platform/components/grid/WGrid.vue b/io.sc.platform.core.frontend/src/platform/components/grid/WGrid.vue index fb33cc93..d2eaa528 100644 --- a/io.sc.platform.core.frontend/src/platform/components/grid/WGrid.vue +++ b/io.sc.platform.core.frontend/src/platform/components/grid/WGrid.vue @@ -1057,7 +1057,6 @@ function findParents(arrData: any, name: any) { } const handlerMoreRowColumnTitle = () => { - console.info('columnTitleState======', columnTitleState); tableColumns.value.forEach((tableColumn: any) => { columnToMap(tableColumn); }); @@ -1116,8 +1115,6 @@ const handlerMoreRowColumnTitle = () => { arr.forEach((item) => { columnTitleState.columnTitleArr.push(item[1]); }); - - console.info('columnTitleState======', columnTitleState); }; const selectionComputed = computed(() => { diff --git a/io.sc.platform.core.frontend/src/platform/components/toolbar/WToolbar.vue b/io.sc.platform.core.frontend/src/platform/components/toolbar/WToolbar.vue index 27b443d9..cc548300 100644 --- a/io.sc.platform.core.frontend/src/platform/components/toolbar/WToolbar.vue +++ b/io.sc.platform.core.frontend/src/platform/components/toolbar/WToolbar.vue @@ -16,7 +16,17 @@ :label="dense ? '' : btn.data[0].label" :icon="dense ? undefined : btn.data[0].icon" :split="btn.data[0].click ? true : false" - :disable="btn.data[0].enableIf ? !btn.data[0].enableIf(selectedComputed, tickedComputed, grid) : false" + :disable=" + btn.data[0].enableIf + ? !btn.data[0].enableIf({ + firstSelected: firstSelectedComputed, + selected: selectedComputed, + firstTicked: firstTickedComputed, + ticked: tickedComputed, + grid: grid, + }) + : false + " class="class-action-item" @click="buttonClick(btn.data[0])" > @@ -43,7 +53,17 @@ v-close-popup clickable :dense="dense" - :disable="childrenBtn.enableIf ? !childrenBtn.enableIf(selectedComputed, tickedComputed, grid) : false" + :disable=" + childrenBtn.enableIf + ? !childrenBtn.enableIf({ + firstSelected: firstSelectedComputed, + selected: selectedComputed, + firstTicked: firstTickedComputed, + ticked: tickedComputed, + grid: grid, + }) + : false + " @click="buttonClick(childrenBtn)" > @@ -57,7 +77,17 @@ @@ -304,9 +344,21 @@ const loadingComputed = computed(() => { } }; }); +const firstSelectedComputed = computed(() => { + if (Object.keys(props.grid).length > 0 && props.grid.getSelectedRows().length > 0) { + return props.grid.getSelectedRows()[0]; + } + return undefined; +}); const selectedComputed = computed(() => { return Object.keys(props.grid).length > 0 ? props.grid.getSelectedRows() : []; }); +const firstTickedComputed = computed(() => { + if (Object.keys(props.grid).length > 0 && props.grid.getTickedRows().length > 0) { + return props.grid.getTickedRows()[0]; + } + return undefined; +}); const tickedComputed = computed(() => { return Object.keys(props.grid).length > 0 ? props.grid.getTickedRows() : []; }); @@ -314,13 +366,35 @@ const buttonClick = async (button) => { let beforeResult = true; const context = {}; if (button.beforeClick) { - beforeResult = await button.beforeClick(selectedComputed.value, tickedComputed.value, props.grid, context); + beforeResult = await button.beforeClick({ + firstSelected: firstSelectedComputed.value, + selected: selectedComputed.value, + firstTicked: firstTickedComputed.value, + ticked: tickedComputed.value, + grid: props.grid, + context: context, + }); } if (beforeResult && button.click) { - await button.click(selectedComputed.value, tickedComputed.value, props.grid, button._click, context); + await button.click({ + firstSelected: firstSelectedComputed.value, + selected: selectedComputed.value, + firstTicked: firstTickedComputed.value, + ticked: tickedComputed.value, + grid: props.grid, + _click: button._click, + context: context, + }); if (button.afterClick) { nextTick(() => { - button.afterClick(selectedComputed.value, tickedComputed.value, props.grid, context); + button.afterClick({ + firstSelected: firstSelectedComputed.value, + selected: selectedComputed.value, + firstTicked: firstTickedComputed.value, + ticked: tickedComputed.value, + grid: props.grid, + context: context, + }); }); } } diff --git a/io.sc.platform.core.frontend/src/platform/types/ToolbarApiArgsType.ts b/io.sc.platform.core.frontend/src/platform/types/ToolbarApiArgsType.ts new file mode 100644 index 00000000..115c030f --- /dev/null +++ b/io.sc.platform.core.frontend/src/platform/types/ToolbarApiArgsType.ts @@ -0,0 +1,35 @@ +export type ToolbarEnableIfArgsType = { + firstSelected: object;// 表格选中记录第一条 + selected: Array;// 表格选中记录 + firstTicked: object;// 表格勾选记录第一条 + ticked: Array;// 表格勾选记录 + grid: object;// 表格ref对象 +}; + +export type ToolbarBeforeClickArgsType = { + firstSelected: object;// 表格选中记录第一条 + selected: Array;// 表格选中记录 + firstTicked: object;// 表格勾选记录第一条 + ticked: Array;// 表格勾选记录 + grid: object;// 表格ref对象 + context: object;// beforeClick、click、afterClick事件上下文 +}; + +export type ToolbarClickArgsType = { + firstSelected: object;// 表格选中记录第一条 + selected: Array;// 表格选中记录 + firstTicked: object;// 表格勾选记录第一条 + ticked: Array;// 表格勾选记录 + grid: object;// 表格ref对象 + _click: Function;// 内置按钮默认click事件的实现函数 + context: object;// beforeClick、click、afterClick事件上下文 +}; + +export type ToolbarAfterClickArgsType = { + firstSelected: object;// 表格选中记录第一条 + selected: Array;// 表格选中记录 + firstTicked: object;// 表格勾选记录第一条 + ticked: Array;// 表格勾选记录 + grid: object;// 表格ref对象 + context: object;// beforeClick、click、afterClick事件上下文 +}; \ No newline at end of file diff --git a/io.sc.platform.core.frontend/src/platform/types/index.ts b/io.sc.platform.core.frontend/src/platform/types/index.ts index 82c2820a..48e3887b 100644 --- a/io.sc.platform.core.frontend/src/platform/types/index.ts +++ b/io.sc.platform.core.frontend/src/platform/types/index.ts @@ -24,5 +24,11 @@ export type { DisableIfArgsType, UpdateModelValueEventArgsType, ChangeEventArgsType, - CodeMirrorButtonClickEventArgsType + CodeMirrorButtonClickArgsType } from './FormApiArgsType'; +export type { + ToolbarEnableIfArgsType, + ToolbarBeforeClickArgsType, + ToolbarClickArgsType, + ToolbarAfterClickArgsType +} from './ToolbarApiArgsType';