<script>
import { submit } 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() {
      if(this.selectData.length != 1){
        this.$modal.msgWarning("请选择一条数据进行提交！");
        return;
      }
      let that = this;
      this.$modal.confirm('确认提交吗？').then(async function() {
        that.loading = true;
        return await submit(that.selectData[0]);
      }).then(() => {
        that.$modal.msgSuccess("提交成功");
        that.loading = false;
      }).catch(() => {
        that.loading = false;
      });
    },
  },
  created() {},
};
</script>

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