<script>
import { DOCUMENTSRETURN } from "@/api/business/purchase/task";
export default {
  name: "DocumentsReturnDialog",
  components: {},
  data() {
    return {
      size: "mini",
      visible: false,
      loading: false,
      params: { baskCause: "", documentIds: [] },
    };
  },
  computed: {},
  watch: {},
  methods: {
    //
    open(prop) {
      this.visible = true;
      const documentIds = prop.map((item) => item.id);
      this.params.documentIds = documentIds;
    },
    //
    hide() {
      this.visible = false;
      this.params.baskCause = "";
      this.params.documentIds = [];
    },
    //
    async submit(prop) {
      try {
        this.loading = true;
        const { baskCause, documentIds } = prop;
        const { code, msg } = await DOCUMENTSRETURN({
          baskCause,
          documentIds,
        });
        if (code === 200) {
          this.hide();
          this.$emit("success");
          
        } else {
          this.$notify.warning({ title: msg });
        }
      } catch (err) {
        //
      } finally {
        this.loading = false;
      }
    },
  },
  created() {},
  mounted() {},
  destroyed() {},
};
</script>

<template>
  <el-dialog width="25%" :visible.sync="visible" title="退回需求" @close="hide">
    <el-alert
      title="请填写退单原因"
      type="info"
      show-icon
      :closable="false"
      style="margin-bottom: 10px"
    >
    </el-alert>
    <el-input v-model="params.baskCause" :size="size"></el-input>
    <span slot="footer">
      <el-button :size="size" @click="visible = false">取 消</el-button>
      <el-button :size="size" type="primary" @click="submit(params)"
        >确 定</el-button
      >
    </span>
  </el-dialog>
</template>

<style scoped></style>
