<template>
  <el-popconfirm
    v-if="popip"
    :title="title"
    :icon="icon"
    :icon-color="iconColor"
    @onConfirm="confirm"
    @onCancel="cancel"
  >
    <el-button slot="reference" :type="type" v-bind="$attrs">{{
      txt
    }}</el-button>
  </el-popconfirm>

  <el-button
    v-else
    slot="reference"
    :type="type"
    v-bind="$attrs"
    @click="$emit('click')"
    >{{ txt }}</el-button
  >
</template>

<script>
export default {
  name: 'BaseBtn',
  props: {
    popip: {
      type: Boolean,
      default: false
    },
    title: {
      type: String,
      default: '确定删除此记录？'
    },
    icon: {
      type: String,
      default: 'el-icon-warning-outline'
    },
    iconColor: {
      type: String,
      default: '#c01'
    },
    txt: {
      type: String,
      default: ''
    },
    type: {
      type: String,
      default: ''
    }
  },
  methods: {
    confirm() {
      this.$emit('ok');
    },
    cancel() {
      this.$emit('cancel');
    }
  }
};
</script>

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