Browse Source

表格优化提交

main
likunming 8 months ago
parent
commit
9d5fa66c05
  1. 16
      io.sc.platform.core.frontend/src/platform/components/grid/TreeGridRow.vue
  2. 77
      io.sc.platform.core.frontend/src/platform/components/grid/WGrid.vue

16
io.sc.platform.core.frontend/src/platform/components/grid/TreeGridRow.vue

@ -88,6 +88,8 @@
:grid-props="gridProps"
:row-key="props.rowKey"
:grid="props.grid"
:grid-row-click="props.gridRowClick"
:grid-row-db-click="gridRowDbClick"
></TreeGridRow>
</template>
</template>
@ -130,6 +132,14 @@ const props = defineProps({
return {};
},
},
gridRowClick: {
type: Function,
default: () => {},
},
gridRowDbClick: {
type: Function,
default: () => {},
},
});
const table = inject('table');
@ -568,11 +578,7 @@ const click = (evt, row, rowIndex) => {
}
};
const dbClick = (evt, row, rowIndex) => {
if (props.gridProps.onRowDbClick) {
props.gridProps.onRowDbClick(evt, row, rowIndex);
} else {
props.grid.view();
}
props.gridRowDbClick(evt, row, rowIndex);
};
</script>

77
io.sc.platform.core.frontend/src/platform/components/grid/WGrid.vue

@ -111,7 +111,16 @@
</template>
<template #body="scope">
<template v-if="tree">
<TreeGridRow :columns-map="tableColumnsMap" :row="scope.row" :cols="scope.cols" :grid-props="props" :row-key="rowKey_" :grid="instance"></TreeGridRow>
<TreeGridRow
:columns-map="tableColumnsMap"
:row="scope.row"
:cols="scope.cols"
:grid-props="props"
:row-key="rowKey_"
:grid="instance"
:grid-row-click="rowClick"
:grid-row-db-click="rowDbClick"
></TreeGridRow>
</template>
<q-tr
v-else
@ -287,6 +296,7 @@ const props = defineProps({
foreignKey: { type: String, default: 'parent' }, //
orderBy: { type: String, default: 'order' }, //
refreshData: { type: Boolean, default: false }, // primaryKey
dbClickOperation: { type: String, default: 'view' }, // vieweditcloneexpand
sortBy: {
// ['userName', '-lastModifyDate']-
type: Array,
@ -716,17 +726,7 @@ const buttonObj = reactive({
return false;
},
click: (args) => {
if (!args.selected) {
NotifyManager.warn(t('action.edit.tip'));
} else {
dialogRef.value.show();
dialog.dialogTitle = t('action.edit');
nextTick(() => {
dialogFormRef.value.setStatus(PageStatusEnum.编辑);
dialogFormRef.value.setData(args.selected);
emit('afterEditorOpen', args.selected);
});
}
edit(args.selected);
},
},
clone: {
@ -741,18 +741,7 @@ const buttonObj = reactive({
return false;
},
click: (args) => {
const selected = args.selected;
if (!selected) {
NotifyManager.warn(t('action.copy.tip'));
} else {
selected[props.primaryKey] = undefined;
dialogRef.value.show();
dialog.dialogTitle = t('action.copy');
nextTick(() => {
dialogFormRef.value.setStatus('clone');
dialogFormRef.value.setData(selected);
});
}
clone(args.selected);
},
},
remove: {
@ -1400,6 +1389,12 @@ const rowClick = (evt: any, row: any, index: any) => {
const rowDbClick = (evt, row, index) => {
if (props.onRowDbClick) {
emit('rowDbClick', evt, row, index);
} else if (!Tools.isEmpty(row) && props.dbClickOperation === buttonObj.edit.name) {
edit(row);
} else if (!Tools.isEmpty(row) && props.dbClickOperation === buttonObj.clone.name) {
clone(row);
} else if (!Tools.isEmpty(row) && props.dbClickOperation === buttonObj.expand.name) {
row['expand'] = Tools.isEmpty(row['expand']) ? true : !row['expand'];
} else {
view();
}
@ -1573,7 +1568,11 @@ const onRequest = async (ops: any) => {
setRowDataExtraProperty(table.rows);
stickyHeaderColumn(100);
emit('afterRequestData');
table.treeExpand = false;
// table.treeExpand = false;
//
if (table.treeExpand) {
expandFun(table.rows, false);
}
};
/**
@ -2652,6 +2651,33 @@ const getCascadeParents = (propertyName: string) => {
return result;
};
const edit = (selected) => {
if (!selected) {
NotifyManager.warn(t('action.edit.tip'));
} else {
dialogRef.value.show();
dialog.dialogTitle = t('action.edit');
nextTick(() => {
dialogFormRef.value.setStatus(PageStatusEnum.编辑);
dialogFormRef.value.setData(selected);
emit('afterEditorOpen', selected);
});
}
};
const clone = (selected) => {
if (!selected) {
NotifyManager.warn(t('action.copy.tip'));
} else {
selected[props.primaryKey] = undefined;
dialogRef.value.show();
dialog.dialogTitle = t('action.copy');
nextTick(() => {
dialogFormRef.value.setStatus('clone');
dialogFormRef.value.setData(selected);
});
}
};
const getElement = () => {
return tableRef?.value?.$el;
};
@ -2686,6 +2712,7 @@ defineExpose({
cleanSelected,
cleanTicked,
view,
edit,
getElement,
});

Loading…
Cancel
Save