<template>
  <div class="pa-3">
    <div class="box d-flex flex-column">
      <v-textarea
        v-model="code"
        label="请输入执行代码"
        outlined
        rows="10"
        dense
      ></v-textarea>
      <v-btn
        class="buttons align-self-center"
        rounded
        color="primary"
        :loading="loading"
        @click="handleSubmit"
      >
        <v-icon left>mdi-cloud-upload-outline</v-icon>
        提交
      </v-btn>
    </div>
  </div>
</template>

<script>
import { api } from '@/api/dataGovernance'
export default {
  name: 'execute-script',
  data () {
    return {
      code: null,
      loading: false
    }
  },
  methods: {
    async handleSubmit () {
      this.loading = true
      try {
        await api.savePythonCode({
          code: this.code
        })
        this.$snackbar.success('保存成功')
      } catch (error) {
        this.$snackbar.error(error)
      } finally {
        this.loading = false
      }
    }
  }

}
</script>

<style lang="scss" scoped>
</style>
