jinlin
2024-12-02 18f682f736914e427070b9bb769df538ad9f6d1c
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
47
48
49
50
51
52
53
54
55
56
57
58
<template>
  <div>
    <el-form :inline="true" label-width="150px">
      <el-form-item label="Sql" prop="sql" label-width="150px">
        <textarea v-model="sql" style="width: 660px;height:200px"></textarea>
      </el-form-item>
      <el-button type="primary" @click="check()">查询</el-button>
      <el-button type="primary" @click="logDownload()">日志下载</el-button>
    </el-form>
    <el-table :data="tableData" height="100px" v-adaptive="{bottomOffset:30}"
              :header-cell-style="{'text-align':'center'}">
      <el-table-column v-for="column in tableColumns" :key="column.prop" :prop="column.prop" :label="column.label">
      </el-table-column>
    </el-table>
  </div>
</template>
 
<script>
 
  import qs from "qs";
  import Cookies from "js-cookie";
 
  export default {
    data() {
      return {
        sql: ''
      }
    },
    props: {
      tableData: {
        type: Array,
      },
      tableColumns: {
        type: Array,
      }
    },
    methods: {
      async check() {
        let params = {
          sql: this.sql
        }
        let res = await this.$http.get('/sys/mysql/check', {params: params})
        if (res.success) {
          console.log(res)
          this.tableData = res.data.tableData
          this.tableColumns = res.data.tableColumns
      }
    },
    async logDownload() {
      let param = qs.stringify({
        'token': Cookies.get('token')
      })
      let apiURL = `/sys/mysql/logDownload`
      window.location.href = `${window.SITE_CONFIG['apiURL']}${apiURL}?${param}`
    }
  }
  }
</script>