<template>
  <div v-loading="loading">
    <div class="white-box">
      <el-button type="primary" @click="onSubmit" :loading="submitButtonStat">清空数据</el-button>
      <el-button type="primary" @click="onClearCache" :loading="clearCacheButtonStat">清空缓存</el-button>
      <el-button type="primary" @click="onClearTableCache" :loading="clearTableCacheButtonStat">清空数据表结构缓存</el-button>
    </div>
  </div>
</template>

<script>
import Vue from 'vue'
import network from './../../utils/network'
import tool from './../../utils/tool'

export default {
  name: 'config_clear-data',
  created () {

  },
  mounted () {
  },
  data () {
    return {
      loading: false,
      submitButtonStat: false,
      clearCacheButtonStat: false,
      clearTableCacheButtonStat: false,
    }
  },
  methods: {
    onSubmit () {
      this.submitButtonStat = true
      network.getData('config/clear-data').then(response => {
        this.$message({
          message: response,
          type: 'success'
        })
        this.submitButtonStat = false
      }).catch(response => {
        this.submitButtonStat = false
      })
    },
    onClearCache () {
      this.clearCacheButtonStat = true
      network.getData('config/clear-cache').then(response => {
        this.$message({
          message: response,
          type: 'success'
        })
        this.clearCacheButtonStat = false
      }).catch(response => {
        this.clearCacheButtonStat = false
      })
    },
    onClearTableCache () {
      this.clearTableCacheButtonStat = true
      network.getData('config/clear-table-cache').then(response => {
        this.$message({
          message: response,
          type: 'success'
        })
        this.clearTableCacheButtonStat = false
      }).catch(response => {
        this.clearTableCacheButtonStat = false
      })
    },
  }
}
</script>

<style scoped>

</style>