<!-- 确认删除框 -->
<template>
  <Modal v-model="visible" width="360"
         @on-cancel="$emit('update:show', false)">
    <p slot="header" style="color:#f60;">
      <Icon type="ios-information-circle"></Icon>
      <span>删除确认!</span>
    </p>
    <div style="text-align:center">
      <p>该操作不可撤回，确定删除吗？</p>
    </div>
    <div slot="footer">
      <Button type="error" :loading="delLoading"  @click="delSubmit">
        <span v-if="!delLoading">删 除</span>
        <span v-else>Loading...</span>
      </Button>
      <Button @click="$emit('update:show', false)" >取 消</Button>
    </div>
  </Modal>
</template>

<script>
let _this;
export default {
  data(){
    return{
      visible:false,
      delLoading:false,
      deleteid:'',
      deletename:''
    }
  },props: {
    show: Boolean,
    value:Object
  },methods: {
    delSubmit(){
      this.delLoading = true
      if(this.deletename=="basedata/dictionary"){
        this.$remove('api/v1/'+this.deletename+'/delete/'+this.deleteid).then(response=>{//GET请求，从后台获取数据
          this.$emit('update:show', false)
          this.$Message.success("删除成功!")
          this.delLoading = false
        }).catch(err=>{
          console.log(err);
        });
      }else {
        this.$post('api/v1/'+this.deletename+'/delete/'+this.deleteid).then(response=>{//GET请求，从后台获取数据
          this.$emit('update:show', false)
          this.$Message.success("删除成功!")
          this.delLoading = false
        }).catch(err=>{
          this.$Message.error("删除失败!")
          this.delLoading = false
          console.log(err);
        });
      }
    }
  },mounted: function(){
    _this = this;
  },watch:{
    show(){
      this.visible = this.show
      if(this.show){
        this.deleteid = this.value.deleteid
        this.deletename = this.value.deletename
      }
    }
  }
}
</script>

<style scoped>

</style>
