createTable.vue
1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<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>
import { createTable } from "@/api/tool/gen"
const visible = ref(false)
const content = ref("")
const { proxy } = getCurrentInstance()
const emit = defineEmits(["ok"])
/** 显示弹框 */
function show() {
visible.value = true
}
/** 导入按钮操作 */
function handleImportTable() {
if (content.value === "") {
proxy.$modal.msgError("请输入建表语句")
return
}
createTable({ sql: content.value }).then(res => {
proxy.$modal.msgSuccess(res.msg)
if (res.code === 200) {
visible.value = false
emit("ok")
}
})
}
defineExpose({
show,
})
</script>