<script>
import { operationStatus } from "@/api/expend/customerExpend";
export default {
  name: "OpenOrClose",
  props: {
    selectData: {
      type: Array,
      default: () => [],
    },
  },
  data() {
    return {
      title: "行打开/关闭",
      loading: false,
    };
  },
  computed: {
    disabled: {
      get() {
        const { selectData } = this;
        if (selectData.length < 1) {
          return true;
        }
        return false;
      },
      set() {},
    },
  },
  methods: {
    //操作状态
    useClick() {
      const { selectData } = this;
      this.$modal.confirm("确认操作行状态吗？").then(async () => {
        try {
          this.$modal.loading("处理中,请稍后...");
          let { code, msg } = await operationStatus(selectData);
          if (code == 200) {
            this.$notify.success(msg);
            this.$emit("success");
          }
        } catch (error) {
        } finally {
          this.$modal.closeLoading();
        }
      });
    },
  },
  created() {},
};
</script>

<template>
  <el-button
    v-loading="loading"
    @click="useClick"
    :disabled="disabled"
    v-bind="$attrs"
    >{{ title }}</el-button
  >
</template>
