
<script>
import { ROWClOSE } from "@/api/business/purchase/task";
export default {
  name:'lineClose',
  props:{
    selectData: {
      type: [Array],
      require: true,
    },
  },
  data(){
    return {
      title:'行关闭',
      visible: false,
      loading: false,
      params: { closeCause:'' },
    }
  },
  computed:{
    disabled:{
      get(){
        return this.selectData.length < 1;
      },
      set(){},
    }
  },
  watch: {},
  methods: {
    open(prop){

      this.visible = true;
      
    },
    async submit(selectData){
      try {

        let params = {
          documentIds: selectData.map(item => item.id),
          baskCause: this.params.closeCause,
        }

        let { code, msg } = await ROWClOSE(params);

        if (code === 200) {
          this.visible = false;
          this.$emit("success");
          this.$notify.success({ title: msg });
        }

      } catch (error) {

      }
    },
    hide(){
      this.visible = false;
      this.params.closeCause = "";
    },
  },
  created() {},
  mounted() {},
  destroyed() {},

}
</script>

<template>
  <el-button
    v-bind="$attrs"
    v-on="$listeners"
    :disabled="disabled"
    @click="open(selectData)"
  >
    {{ title }}
    <el-dialog
      :title="title"
      :visible.sync="visible"
      width="25%"
      append-to-body
      @close="hide"
    >
      <div slot="footer">
        <el-button
          :size="$attrs.size"
          :loading="loading"
          @click="visible = false"
          >取 消</el-button
        >
        <el-button
          type="primary"
          :size="$attrs.size"
          :loading="loading"
          @click="submit(selectData)"
          >确 认</el-button
        >
      </div>
      <el-alert
        title="行关闭后无法打开，请确认是否关闭，关闭原因:"
        type="warning"
        show-icon
        :closable="false"
        style="margin-bottom: 10px"
      >
      </el-alert>
      <el-form
        :size="$attrs.size"
        :model="params"
        label-width="0px"
        label-position="right"
        style="padding: 0"
      >
        <el-form-item prop="" label="">
          <el-input v-model="params.closeCause"> </el-input>
        </el-form-item>
      </el-form>
    </el-dialog>
  </el-button>
</template>
