<template>
  <div>
    <el-form ref="reviewForm" :model="reviewObj" label-width="120px">
      <el-form-item label="申请理由">
        <el-input v-model="reviewObj.applyReason" type="textarea" rows="2" placeholder="请输入申请理由"></el-input>
      </el-form-item>
    </el-form>
    <el-row class="operate-button">
      <el-button type="success" @click="onSubmit">发起申请</el-button>
      <el-button @click="cancel">关闭</el-button>
    </el-row>
  </div>
</template>

<script>
import { approvalCreate, serviceMsg } from "@/api/ecw/boxSea";

/**
 * 预装反审
 */
export default {
  name: "review",
  inheritAttrs: false,
  data() {
    return {
      // 反审对象
      reviewObj: {},
    };
  },
  methods: {
    /** 提交 */
    onSubmit() {
      this.$refs["reviewForm"].validate((valid) => {
        if (valid) {
          approvalCreate({
            shipmentId: this.$attrs.shipmentObj.id,
            ...this.reviewObj,
            approvalStatus: -1,
            approvalType: 4,
          }).then((res) => {
            serviceMsg(res, this).then(() => {
              this.cancel("submit");
            });
          });
        }
      });
    },
    /** 取消 */
    cancel(type) {
      this.$emit("closeDialog", type);
    },
  },
};
</script>
