createTable.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <template>
  2. <!-- 创建表 -->
  3. <el-dialog title="创建表" :visible.sync="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. <div slot="footer" class="dialog-footer">
  7. <el-button type="primary" @click="handleCreateTable">确 定</el-button>
  8. <el-button @click="visible = false">取 消</el-button>
  9. </div>
  10. </el-dialog>
  11. </template>
  12. <script>
  13. import { createTable } from "@/api/tool/gen";
  14. export default {
  15. data() {
  16. return {
  17. // 遮罩层
  18. visible: false,
  19. // 文本内容
  20. content: ""
  21. };
  22. },
  23. methods: {
  24. // 显示弹框
  25. show() {
  26. this.visible = true;
  27. },
  28. /** 创建按钮操作 */
  29. handleCreateTable() {
  30. if (this.content === "") {
  31. this.$modal.msgError("请输入建表语句");
  32. return;
  33. }
  34. createTable({ sql: this.content }).then(res => {
  35. this.$modal.msgSuccess(res.msg);
  36. if (res.code === 200) {
  37. this.visible = false;
  38. this.$emit("ok");
  39. }
  40. });
  41. }
  42. }
  43. };
  44. </script>