ruoyi-plus-vben5/apps/web-antd/src/views/tool/gen/edit-steps/gen-config.vue

73 lines
1.4 KiB
Vue
Raw Normal View History

2024-09-24 10:18:07 +08:00
<script setup lang="ts">
import type { Ref } from 'vue';
import type { VxeGridProps } from '#/adapter/vxe-table';
2024-09-24 10:18:07 +08:00
import type { GenInfo } from '#/api/tool/gen/model';
import { inject } from 'vue';
2024-09-24 10:18:07 +08:00
import { useVbenVxeGrid } from '#/adapter/vxe-table';
2024-09-24 10:18:07 +08:00
2024-10-05 18:21:02 +08:00
import { validRules, vxeTableColumns } from './gen-data';
2024-09-24 10:18:07 +08:00
/**
* 从父组件注入
*/
2024-09-26 11:35:16 +08:00
const genInfoData = inject('genInfoData') as Ref<GenInfo['info']>;
2024-09-24 10:18:07 +08:00
2024-10-05 17:27:40 +08:00
const gridOptions: VxeGridProps = {
columns: vxeTableColumns,
keepSource: true,
2024-10-05 18:21:02 +08:00
editConfig: { trigger: 'click', mode: 'cell', showStatus: true },
editRules: validRules,
2024-10-05 17:27:40 +08:00
rowConfig: {
keyField: 'id',
2024-10-05 18:21:02 +08:00
isCurrent: true, // 高亮当前行
},
columnConfig: {
resizable: true,
},
proxyConfig: {
enabled: true,
2024-10-05 17:27:40 +08:00
},
2024-11-11 09:12:10 +08:00
toolbarConfig: {
enabled: false,
2024-11-11 09:12:10 +08:00
},
2024-10-20 11:17:14 +08:00
height: 'auto',
pagerConfig: {
enabled: false,
},
2024-10-05 17:27:40 +08:00
data: genInfoData.value.columns,
};
2024-10-05 18:21:02 +08:00
const [BasicTable, tableApi] = useVbenVxeGrid({ gridOptions });
2024-10-05 17:27:40 +08:00
/**
* 校验表格数据
*/
async function validateTable() {
const hasError = await tableApi.grid.validate();
return !hasError;
}
/**
* 获取表格数据
*/
function getTableRecords() {
return tableApi?.grid?.getData?.() ?? [];
2024-09-24 10:18:07 +08:00
}
defineExpose({
validateTable,
getTableRecords,
});
2024-09-24 10:18:07 +08:00
</script>
<template>
<div class="flex flex-col gap-[16px]">
<div class="h-[calc(100vh-200px)] overflow-y-hidden">
2024-11-11 09:12:10 +08:00
<BasicTable />
</div>
2024-09-24 10:18:07 +08:00
</div>
</template>