Browse Source

表格优化提交

main
likunming 1 year ago
parent
commit
b8ba319d6e
  1. 2
      io.sc.platform.core.frontend/package.json
  2. 3
      io.sc.platform.core.frontend/src/platform/components/grid/WGrid.vue
  3. 88
      io.sc.platform.core.frontend/src/platform/components/toolbar/WToolbar.vue
  4. 35
      io.sc.platform.core.frontend/src/platform/types/ToolbarApiArgsType.ts
  5. 8
      io.sc.platform.core.frontend/src/platform/types/index.ts

2
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",

3
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(() => {

88
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)"
>
<q-item-section>
@ -57,7 +77,17 @@
<q-btn
v-else
:padding="dense ? padding : undefined"
:disable="btn.data.enableIf ? !btn.data.enableIf(selectedComputed, tickedComputed, grid) : false"
:disable="
btn.data.enableIf
? !btn.data.enableIf({
firstSelected: firstSelectedComputed,
selected: selectedComputed,
firstTicked: firstTickedComputed,
ticked: tickedComputed,
grid: grid,
})
: false
"
no-wrap
no-caps
outline
@ -106,7 +136,17 @@
v-close-popup
clickable
:dense="dense"
:disable="childrenBtn.data.enableIf ? !childrenBtn.data.enableIf(selectedComputed, tickedComputed, grid) : false"
:disable="
childrenBtn.data.enableIf
? !childrenBtn.data.enableIf({
firstSelected: firstSelectedComputed,
selected: selectedComputed,
firstTicked: firstTickedComputed,
ticked: tickedComputed,
grid: grid,
})
: false
"
@click="buttonClick(childrenBtn.data)"
>
<q-item-section>
@ -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,
});
});
}
}

35
io.sc.platform.core.frontend/src/platform/types/ToolbarApiArgsType.ts

@ -0,0 +1,35 @@
export type ToolbarEnableIfArgsType = {
firstSelected: object;// 表格选中记录第一条
selected: Array<any>;// 表格选中记录
firstTicked: object;// 表格勾选记录第一条
ticked: Array<any>;// 表格勾选记录
grid: object;// 表格ref对象
};
export type ToolbarBeforeClickArgsType = {
firstSelected: object;// 表格选中记录第一条
selected: Array<any>;// 表格选中记录
firstTicked: object;// 表格勾选记录第一条
ticked: Array<any>;// 表格勾选记录
grid: object;// 表格ref对象
context: object;// beforeClick、click、afterClick事件上下文
};
export type ToolbarClickArgsType = {
firstSelected: object;// 表格选中记录第一条
selected: Array<any>;// 表格选中记录
firstTicked: object;// 表格勾选记录第一条
ticked: Array<any>;// 表格勾选记录
grid: object;// 表格ref对象
_click: Function;// 内置按钮默认click事件的实现函数
context: object;// beforeClick、click、afterClick事件上下文
};
export type ToolbarAfterClickArgsType = {
firstSelected: object;// 表格选中记录第一条
selected: Array<any>;// 表格选中记录
firstTicked: object;// 表格勾选记录第一条
ticked: Array<any>;// 表格勾选记录
grid: object;// 表格ref对象
context: object;// beforeClick、click、afterClick事件上下文
};

8
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';

Loading…
Cancel
Save