CMVR-IOT-UI/src/views/tool/gen/createTable.vue

47 lines
1.2 KiB
Vue
Raw Normal View History

2025-08-21 14:11:58 +08:00
<template>
<!-- 创建表 -->
<el-dialog title="创建表" v-model="visible" width="800px" top="5vh" append-to-body>
<span>创建表语句(支持多个建表语句)</span>
<el-input type="textarea" :rows="10" placeholder="请输入文本" v-model="content"></el-input>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="handleImportTable"> </el-button>
<el-button @click="visible = false"> </el-button>
</div>
</template>
</el-dialog>
</template>
<script setup>
2026-07-28 16:26:07 +08:00
import { createTable } from "@/api/tool/gen"
2025-08-21 14:11:58 +08:00
2026-07-28 16:26:07 +08:00
const visible = ref(false)
const content = ref("")
const { proxy } = getCurrentInstance()
const emit = defineEmits(["ok"])
2025-08-21 14:11:58 +08:00
/** 显示弹框 */
function show() {
2026-07-28 16:26:07 +08:00
visible.value = true
2025-08-21 14:11:58 +08:00
}
/** 导入按钮操作 */
function handleImportTable() {
if (content.value === "") {
2026-07-28 16:26:07 +08:00
proxy.$modal.msgError("请输入建表语句")
return
2025-08-21 14:11:58 +08:00
}
2026-07-28 16:26:07 +08:00
createTable({ sql: content.value, tplWebType: 'element-plus' }).then(res => {
proxy.$modal.msgSuccess(res.msg)
2025-08-21 14:11:58 +08:00
if (res.code === 200) {
2026-07-28 16:26:07 +08:00
visible.value = false
emit("ok")
2025-08-21 14:11:58 +08:00
}
2026-07-28 16:26:07 +08:00
})
2025-08-21 14:11:58 +08:00
}
defineExpose({
show,
2026-07-28 16:26:07 +08:00
})
2025-08-21 14:11:58 +08:00
</script>