<template>
  <section>
    <nav-bar title="困料管理"></nav-bar>
    <section class="content mgt186">
    </section>
    <section class="submit-bar">
      <button class="btn submit-button" :disabled="disabled1" @click="_createChargingTask('1')">1号车充电</button>
      <button class="btn submit-button" :disabled="disabled1" @click="_createChargingTask('2')">2号车充电</button>
      <button class="btn submit-button" @click="toQuit">退出</button>
    </section>
  </section>
</template>

<script>
import NavBar from '@components/NavBar.vue'
import {createChargingTask} from '@config/getData1'
export default {
  name: 'CreateChargingTask',
  components: {
    NavBar
  },
  data () {
    return {
      disabled1: false
    }
  },
  created () {
  },
  methods: {
    /** 确认 */
    async _createChargingTask (type) {
      this.disabled1 = true
      try {
        let res = await createChargingTask(type)
        if (res.code === '1') {
          this.toast(res.desc)
          this.toCancle()
        } else {
          this.Dialog(res.desc)
        }
        this.disabled1 = false
      } catch (e) {
        this.disabled1 = false
      }
    },
    toQuit () {
      this.$router.push('/home')
    }
  }
}
</script>
