|
@@ -55,6 +55,7 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
|
|
+import axios from 'axios';
|
|
import ItemDrawer from '../template/ItemDrawer.vue'
|
|
import ItemDrawer from '../template/ItemDrawer.vue'
|
|
import { ref, watch } from 'vue'
|
|
import { ref, watch } from 'vue'
|
|
import database from '@/api/codeGenerate/database'
|
|
import database from '@/api/codeGenerate/database'
|
|
@@ -102,7 +103,7 @@ const emit = defineEmits(['update:modelValue', 'confirm', 'cancel'])
|
|
|
|
|
|
const drawerVisible = ref(props.modelValue)
|
|
const drawerVisible = ref(props.modelValue)
|
|
const dataSourceOptions = ref<Array<{ id: string; title: string }>>([])
|
|
const dataSourceOptions = ref<Array<{ id: string; title: string }>>([])
|
|
- const templateOptions = ref<Array<{ id: string; name: string }>>([])
|
|
|
|
|
|
+const templateOptions = ref<Array<{ id: string; name: string }>>([])
|
|
const previewCodeVisible = ref(false)
|
|
const previewCodeVisible = ref(false)
|
|
const activeData = ref<{ record: any; type: 'edit' | 'create' | 'detail'; visible: boolean }>({
|
|
const activeData = ref<{ record: any; type: 'edit' | 'create' | 'detail'; visible: boolean }>({
|
|
record: {},
|
|
record: {},
|
|
@@ -169,22 +170,26 @@ const openDrawer = (type: 'edit' | 'create' | 'detail', record = {}) => {
|
|
const generateCode = async () => {
|
|
const generateCode = async () => {
|
|
try {
|
|
try {
|
|
await formRef.value.validate()
|
|
await formRef.value.validate()
|
|
- await database.codeDownloadApi({ ...form.value, templateIds: form.value.templateIds })
|
|
|
|
- // const blob = new Blob([response.data], { type: 'application/octet-stream' })
|
|
|
|
- // const url = window.URL.createObjectURL(blob)
|
|
|
|
- // const a = document.createElement('a')
|
|
|
|
- // a.href = url
|
|
|
|
- // a.download = 'generated_code.zip' // Adjust the file name as needed
|
|
|
|
- // document.body.appendChild(a)
|
|
|
|
- // a.click()
|
|
|
|
- // a.remove()
|
|
|
|
- // window.URL.revokeObjectURL(url)
|
|
|
|
- // console.log('文件下载成功')
|
|
|
|
|
|
+
|
|
|
|
+ const res = await database.codeDownloadApi({ ...form.value, templateIds: form.value.templateIds })
|
|
|
|
+ console.log('d', res.data)
|
|
|
|
+ const blob = new Blob([res.data], { type: 'application/zip' })
|
|
|
|
+ const url = window.URL.createObjectURL(blob)
|
|
|
|
+ const a = document.createElement('a')
|
|
|
|
+ a.href = url
|
|
|
|
+ a.download = 'generated_code.zip' // 根据需要调整文件名
|
|
|
|
+ document.body.appendChild(a)
|
|
|
|
+ a.click()
|
|
|
|
+ a.remove()
|
|
|
|
+ window.URL.revokeObjectURL(url)
|
|
|
|
+ console.log('文件下载成功')
|
|
} catch (error) {
|
|
} catch (error) {
|
|
console.error('文件下载失败:', error)
|
|
console.error('文件下载失败:', error)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+const updateParams = () => {}
|
|
|
|
+
|
|
getDataBaseOptions()
|
|
getDataBaseOptions()
|
|
loadTemplates()
|
|
loadTemplates()
|
|
</script>
|
|
</script>
|