createTable.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <template>
  2. <!-- 创建表 -->
  3. <el-dialog title="创建表" v-model="visible" width="800px" top="5vh" append-to-body>
  4. <span>创建表语句(支持多个建表语句):</span>
  5. <el-input type="textarea" :rows="10" placeholder="请输入文本" v-model="content"></el-input>
  6. <template #footer>
  7. <div class="dialog-footer">
  8. <el-button type="primary" @click="handleImportTable">确 定</el-button>
  9. <el-button @click="visible = false">取 消</el-button>
  10. </div>
  11. </template>
  12. </el-dialog>
  13. </template>
  14. <script setup>
  15. import { createTable } from "@/api/tool/gen"
  16. const visible = ref(false)
  17. const content = ref("")
  18. const { proxy } = getCurrentInstance()
  19. const emit = defineEmits(["ok"])
  20. /** 显示弹框 */
  21. function show() {
  22. visible.value = true
  23. }
  24. /** 导入按钮操作 */
  25. function handleImportTable() {
  26. if (content.value === "") {
  27. proxy.$modal.msgError("请输入建表语句")
  28. return
  29. }
  30. createTable({ sql: content.value }).then(res => {
  31. proxy.$modal.msgSuccess(res.msg)
  32. if (res.code === 200) {
  33. visible.value = false
  34. emit("ok")
  35. }
  36. })
  37. }
  38. defineExpose({
  39. show,
  40. })
  41. </script>