feat: code gen
This commit is contained in:
parent
b34b4b495d
commit
942e99e518
@ -3,14 +3,14 @@ import type { GenInfo } from '#/api/tool/gen/model';
|
|||||||
|
|
||||||
import { inject, type Ref, unref } from 'vue';
|
import { inject, type Ref, unref } from 'vue';
|
||||||
|
|
||||||
import { Space } from 'ant-design-vue';
|
import { message, Space } from 'ant-design-vue';
|
||||||
import { cloneDeep } from 'lodash-es';
|
import { cloneDeep } from 'lodash-es';
|
||||||
|
|
||||||
import { useVbenVxeGrid, type VxeGridProps } from '#/adapter';
|
import { useVbenVxeGrid, type VxeGridProps } from '#/adapter';
|
||||||
import { editSave } from '#/api/tool/gen';
|
import { editSave } from '#/api/tool/gen';
|
||||||
|
|
||||||
import { toCurrentStep } from '../mitt';
|
import { toCurrentStep } from '../mitt';
|
||||||
import { vxeTableColumns } from './gen-data';
|
import { validRules, vxeTableColumns } from './gen-data';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 从父组件注入
|
* 从父组件注入
|
||||||
@ -19,12 +19,19 @@ const genInfoData = inject('genInfoData') as Ref<GenInfo['info']>;
|
|||||||
|
|
||||||
const gridOptions: VxeGridProps = {
|
const gridOptions: VxeGridProps = {
|
||||||
columns: vxeTableColumns,
|
columns: vxeTableColumns,
|
||||||
// height: 'auto',
|
|
||||||
keepSource: true,
|
keepSource: true,
|
||||||
pagerConfig: {},
|
editConfig: { trigger: 'click', mode: 'cell', showStatus: true },
|
||||||
|
editRules: validRules,
|
||||||
rowConfig: {
|
rowConfig: {
|
||||||
isHover: true,
|
isHover: true,
|
||||||
keyField: 'id',
|
keyField: 'id',
|
||||||
|
isCurrent: true, // 高亮当前行
|
||||||
|
},
|
||||||
|
columnConfig: {
|
||||||
|
resizable: true,
|
||||||
|
},
|
||||||
|
proxyConfig: {
|
||||||
|
enabled: true,
|
||||||
},
|
},
|
||||||
data: genInfoData.value.columns,
|
data: genInfoData.value.columns,
|
||||||
round: true,
|
round: true,
|
||||||
@ -32,11 +39,18 @@ const gridOptions: VxeGridProps = {
|
|||||||
showOverflow: true,
|
showOverflow: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const [BasicTable] = useVbenVxeGrid({ gridOptions });
|
const [BasicTable, tableApi] = useVbenVxeGrid({ gridOptions });
|
||||||
|
|
||||||
async function handleSubmit() {
|
async function handleSubmit() {
|
||||||
try {
|
try {
|
||||||
|
const hasError = await tableApi.grid.validate();
|
||||||
|
if (hasError) {
|
||||||
|
message.error('校验未通过');
|
||||||
|
return;
|
||||||
|
}
|
||||||
const requestData = cloneDeep(unref(genInfoData));
|
const requestData = cloneDeep(unref(genInfoData));
|
||||||
|
// 从表格获取最新的
|
||||||
|
requestData.columns = tableApi.grid.getData();
|
||||||
// 树表需要添加这个参数
|
// 树表需要添加这个参数
|
||||||
if (requestData && requestData.tplCategory === 'tree') {
|
if (requestData && requestData.tplCategory === 'tree') {
|
||||||
const { treeCode, treeName, treeParentCode } = requestData;
|
const { treeCode, treeName, treeParentCode } = requestData;
|
||||||
|
@ -91,10 +91,12 @@ export const vxeTableColumns: VxeGridProps['columns'] = [
|
|||||||
field: 'columnName',
|
field: 'columnName',
|
||||||
showOverflow: 'tooltip',
|
showOverflow: 'tooltip',
|
||||||
fixed: 'left',
|
fixed: 'left',
|
||||||
|
width: 150,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '字段描述',
|
title: '字段描述',
|
||||||
field: 'columnComment',
|
field: 'columnComment',
|
||||||
|
width: 150,
|
||||||
slots: {
|
slots: {
|
||||||
edit: ({ row }) => {
|
edit: ({ row }) => {
|
||||||
return <Input v-model:value={row.columnComment}></Input>;
|
return <Input v-model:value={row.columnComment}></Input>;
|
||||||
@ -105,6 +107,7 @@ export const vxeTableColumns: VxeGridProps['columns'] = [
|
|||||||
{
|
{
|
||||||
title: 'db类型',
|
title: 'db类型',
|
||||||
field: 'columnType',
|
field: 'columnType',
|
||||||
|
width: 120,
|
||||||
showOverflow: 'tooltip',
|
showOverflow: 'tooltip',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -119,6 +122,7 @@ export const vxeTableColumns: VxeGridProps['columns'] = [
|
|||||||
}));
|
}));
|
||||||
return (
|
return (
|
||||||
<Select
|
<Select
|
||||||
|
class="w-full"
|
||||||
getPopupContainer={getPopupContainer}
|
getPopupContainer={getPopupContainer}
|
||||||
options={javaTypeOptions}
|
options={javaTypeOptions}
|
||||||
v-model:value={row.javaType}
|
v-model:value={row.javaType}
|
||||||
@ -222,6 +226,7 @@ export const vxeTableColumns: VxeGridProps['columns'] = [
|
|||||||
edit: ({ row }) => {
|
edit: ({ row }) => {
|
||||||
return (
|
return (
|
||||||
<Select
|
<Select
|
||||||
|
class="w-full"
|
||||||
getPopupContainer={getPopupContainer}
|
getPopupContainer={getPopupContainer}
|
||||||
options={queryTypeOptions}
|
options={queryTypeOptions}
|
||||||
v-model:value={row.queryType}
|
v-model:value={row.queryType}
|
||||||
@ -265,6 +270,7 @@ export const vxeTableColumns: VxeGridProps['columns'] = [
|
|||||||
edit: ({ row }) => {
|
edit: ({ row }) => {
|
||||||
return (
|
return (
|
||||||
<Select
|
<Select
|
||||||
|
class="w-full"
|
||||||
getPopupContainer={getPopupContainer}
|
getPopupContainer={getPopupContainer}
|
||||||
options={componentsOptions}
|
options={componentsOptions}
|
||||||
v-model:value={row.htmlType}
|
v-model:value={row.htmlType}
|
||||||
@ -304,6 +310,7 @@ export const vxeTableColumns: VxeGridProps['columns'] = [
|
|||||||
return (
|
return (
|
||||||
<Select
|
<Select
|
||||||
allowClear={true}
|
allowClear={true}
|
||||||
|
class="w-full"
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
getPopupContainer={getPopupContainer}
|
getPopupContainer={getPopupContainer}
|
||||||
onDeselect={onDeselect}
|
onDeselect={onDeselect}
|
||||||
|
Loading…
Reference in New Issue
Block a user