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

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

@ -111,7 +111,16 @@
</template> </template>
<template #body="scope"> <template #body="scope">
<template v-if="tree"> <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> </template>
<q-tr <q-tr
v-else v-else
@ -287,6 +296,7 @@ const props = defineProps({
foreignKey: { type: String, default: 'parent' }, // foreignKey: { type: String, default: 'parent' }, //
orderBy: { type: String, default: 'order' }, // orderBy: { type: String, default: 'order' }, //
refreshData: { type: Boolean, default: false }, // primaryKey refreshData: { type: Boolean, default: false }, // primaryKey
dbClickOperation: { type: String, default: 'view' }, // vieweditcloneexpand
sortBy: { sortBy: {
// ['userName', '-lastModifyDate']- // ['userName', '-lastModifyDate']-
type: Array, type: Array,
@ -716,17 +726,7 @@ const buttonObj = reactive({
return false; return false;
}, },
click: (args) => { click: (args) => {
if (!args.selected) { edit(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);
});
}
}, },
}, },
clone: { clone: {
@ -741,18 +741,7 @@ const buttonObj = reactive({
return false; return false;
}, },
click: (args) => { click: (args) => {
const selected = args.selected; clone(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);
});
}
}, },
}, },
remove: { remove: {
@ -1400,6 +1389,12 @@ const rowClick = (evt: any, row: any, index: any) => {
const rowDbClick = (evt, row, index) => { const rowDbClick = (evt, row, index) => {
if (props.onRowDbClick) { if (props.onRowDbClick) {
emit('rowDbClick', evt, row, index); 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 { } else {
view(); view();
} }
@ -1573,7 +1568,11 @@ const onRequest = async (ops: any) => {
setRowDataExtraProperty(table.rows); setRowDataExtraProperty(table.rows);
stickyHeaderColumn(100); stickyHeaderColumn(100);
emit('afterRequestData'); 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; 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 = () => { const getElement = () => {
return tableRef?.value?.$el; return tableRef?.value?.$el;
}; };
@ -2686,6 +2712,7 @@ defineExpose({
cleanSelected, cleanSelected,
cleanTicked, cleanTicked,
view, view,
edit,
getElement, getElement,
}); });

Loading…
Cancel
Save