feat: 更新表单内容

This commit is contained in:
bunny 2025-04-15 20:26:48 +08:00
parent 782f709bd1
commit 32e84f5433
3 changed files with 20 additions and 26 deletions

View File

@ -2,32 +2,12 @@ import { defineStore } from 'pinia';
import { generator, getVmsPathList } from '@/api/vms';
interface VmsStore {
generators: any;
serverOptions: string[];
webOptions: string[];
formValue: {
author: string;
packageName: string;
requestMapping: string;
className: string;
tableName: string;
simpleDateFormat: string;
tablePrefixes: string;
path: string[];
};
formOption: {
generatorServer: string[];
generatorWeb: string[];
};
}
export const useVmsStore = defineStore('vmsStore', {
// 开启持久化
// persist: true,
persist: {
paths: ['formValue', 'formOption'],
},
// persist: {
// paths: ['formValue', 'formOption'],
// },
state: () => ({
generators: [],
@ -46,6 +26,7 @@ export const useVmsStore = defineStore('vmsStore', {
tableName: '',
simpleDateFormat: 'yyyy-MM-dd HH:mm:ss',
tablePrefixes: 't_,sys_,qrtz_,log_',
comment: '',
path: [],
},

View File

@ -37,10 +37,16 @@ const { formValue, formOption } = storeToRefs(vmsStore);
<n-grid :cols="24" :x-gap="24">
<n-form-item-gi :span="8" label="去除开头前缀" path="tablePrefixes">
<n-input v-model:value="formValue.tablePrefixes" placeholder="电话号码" />
<n-input v-model:value="formValue.tablePrefixes" placeholder="去除开头前缀" />
</n-form-item-gi>
<n-form-item-gi :span="8" label="生成后端" path="generatorServer">
<n-form-item-gi :span="8" label="修改注释名称" path="comment">
<n-input v-model:value="formValue.comment" placeholder="修改注释名称" />
</n-form-item-gi>
</n-grid>
<n-grid :cols="24" :x-gap="24">
<n-form-item-gi :span="12" label="生成后端" path="generatorServer">
<n-checkbox-group v-model:value="formOption.generatorServer">
<n-space>
<n-checkbox
@ -61,7 +67,7 @@ const { formValue, formOption } = storeToRefs(vmsStore);
</n-checkbox-group>
</n-form-item-gi>
<n-form-item-gi :span="8" label="生成前端" path="generatorWeb">
<n-form-item-gi :span="12" label="生成前端" path="generatorWeb">
<n-checkbox-group v-model:value="formOption.generatorWeb">
<n-space>
<n-checkbox

View File

@ -1,15 +1,19 @@
<script lang="ts" setup>
import { NCard, NTabPane, NTabs } from 'naive-ui';
import { storeToRefs } from 'pinia';
import { onMounted, reactive } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useTableStore } from '@/store/modules/table';
import { useVmsStore } from '@/store/modules/vms';
import Index from '@/views/generator-code/components/column-field/index.vue';
import GeneratorForm from '@/views/generator-code/components/generator/index.vue';
const router = useRouter();
const route = useRoute();
const tableStore = useTableStore();
const vmsStore = useVmsStore();
const { formValue, formOption } = storeToRefs(vmsStore);
//
const tableInfo = reactive({
@ -28,6 +32,9 @@ const getTableData = async () => {
const tableName: any = route.query.tableName;
const tableMetaData = await tableStore.getTableMetaData(tableName);
Object.assign(tableInfo, tableMetaData);
//
formValue.value.comment = tableInfo.comment;
};
onMounted(() => {