<template>
  <el-button
    :type="multipleSelection.data.length ? 'primary' : 'info'"
    :disabled="!multipleSelection.data.length"
    @click="del()"
    >删 除</el-button
  >
</template>
<script>
import { mapGetters, mapActions } from "vuex";
import { warningAlert } from "../../utils/alert";

export default {
  props: {
    multipleSelection2: {
      type: Array,
      default: () => {},
    },
  },
  components: {},
  data() {
    return {
      multipleSelection: formInit(),
    };
  },
  watch: {
    multipleSelection2: {
      immediate: true,
      handler(newV) {
        this.multipleSelection = !!newV;
        this.multipleSelection = formInit(this.multipleSelection2);
      },
    },
  },
  computed: {
    ...mapGetters({}),
  },
  methods: {
    ...mapActions({}),
    del() {
      this.$confirm("继续操作将永久删除, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$emit("del");
        })
        .catch(() => {
          warningAlert("取消删除");
        });
    },
  },
  mounted() {},
};
function formInit(data = []) {
  return {
    data,
  };
}
</script>
<style scoped>
</style>