feat 代码生成支持目录写入

This commit is contained in:
lbw 2023-02-09 21:30:05 +08:00
parent b98be31d55
commit 117ba1832e
2 changed files with 20 additions and 6 deletions

View File

@ -52,6 +52,14 @@ export const useTableFieldSubmitApi = (dsName: string, tableName: string, fieldL
return request.put('/gen/table/field/' + dsName + '/' + tableName, fieldList)
}
export const useGeneratorCodeApi = (tableIds: any) => {
return request({
url: '/gen/generator/code',
method: 'get',
params: { tableIds: tableIds }
})
}
export const useGeneratorPreviewApi = (tableId: any) => {
return request({
url: '/gen/generator/preview',

View File

@ -56,8 +56,8 @@
<el-col :span="18" class="mb20">
<el-form-item label="生成方式" prop="generatorType">
<el-radio-group v-model="dataForm.generatorType">
<el-radio :label="0">zip压缩包</el-radio>
<el-radio :label="1">自定义路径</el-radio>
<el-radio-button :label="0">ZIP 压缩包</el-radio-button>
<el-radio-button :label="1">自定义路径</el-radio-button>
</el-radio-group>
</el-form-item>
</el-col>
@ -83,7 +83,7 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
import { putObj, useTableApi } from '/@/api/gen/table'
import { putObj, useTableApi, useGeneratorCodeApi } from '/@/api/gen/table'
import { useMessage } from '/@/hooks/message';
import { downBlobFile } from '/@/utils/other';
@ -158,7 +158,7 @@ const submitHandle = () => {
putObj(dataForm).then(() => {
visible.value = false
emit('refreshDataList')
useMessage().success(t('common.editSuccessText'))
useMessage().success(t('common.optSuccessText'))
})
})
}
@ -174,11 +174,17 @@ const generatorHandle = () => {
await submitHandle()
// zip
if (dataForm.generatorType === 0) {
downBlobFile('/gen/generator/download?tableIds=' + [dataForm.id].join(','), {}, `${dataForm.tableName}.zip`)
visible.value = false
return
}
//
if (dataForm.generatorType === 1) {
useGeneratorCodeApi([dataForm.id].join(',')).then(() => {
useMessage().success(t('common.optSuccessText'))
visible.value = false
})
}
})
}