<template>
  <el-dialog
      title="提示"
      :visible.sync="dialogVisible"
      width="30%"
  >
    <span>确认操作</span>
    <span slot="footer" class="dialog-footer">
      <el-button @click="dialogVisible = false">取 消</el-button>
      <el-button :disabled="noDoubleClick? checkLoading: false" type="primary" @click="confirmHandle">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import {confirmAll} from '@/api/table.js'

export default {
  name: 'Cancledialog',
  props: {
    /**
     * 禁止双击
     * 默认为不禁止
     **/
    noDoubleClick: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      dialogVisible: false,
      data: {},
      url: '',
      checkLoading: false
    }
  },
  methods: {
    updataClick(data, url) {
      const _that = this
      _that.dialogVisible = true
      _that.data = data
      _that.url = url
    },
    confirmHandle() {
      const _that = this;
      if (_that.noDoubleClick) {
        _that.checkLoading = true
      }
      confirmAll(_that.data, _that.url).then(response => {
        _that.dialogVisible = false
        // console.log('confirmAll',response.data)
        _that.checkLoading = false
        _that.$message({
          message: '成功',
          type: 'success'
        })

        _that.$emit('tableRefresh', '')
      })
    }
  }
}
</script>

<style scoped>

</style>
