<template>
  <div>
    <!-- <i style="font-weight:bold" class="el-icon-delete" @click="() => append()"></i> -->
    <el-button v-if="data" size="small" :icon="data.isused === 1?'el-icon-circle-close':'el-icon-circle-check'" @click="() => append()">{{data.isused === 1?'停 用':'启 用'}}</el-button>
  </div>
</template>

<script>
export default {
  props:['data'],
  data () {
    return {
      form:{
        sequence:0
      }
    }
  },
  mounted () {
  },
  methods:{
    append () {
      this.$confirm(`是否${this.data.isused === 1?'停用':'启用'}当前区域?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async () => {
        this.form = Object.assign({},this.form,this.data)
        this.form.areaname = this.form.label 
        this.form.isused === 1?this.form.isused = 0:this.form.isused = 1
        const res = await this.$api.requested({
          "classname": "webmanage.sale.salearea.salearea",
          "method": "insertormodify_area",
          "content": this.form
        })
        this.tool.showMessage(res,()=>{
          this.$emit('onStartArea',this.data.isused)
        })
      }).catch(() => {     
      });
    }
  }
}

</script>
<style>
</style>
<style scoped>
.item_width-full{
  width:100%
}
.dialog-footer{
  margin-top:32px;
  text-align: center;
}
</style>