<template>
  <div class="shipping-update-error">
    <div class="message-title">{{$t(`您确定撤销${cancelClearInfo.orderNo}已清关状态吗?`)}}</div>
    <el-form ref="arrivalForm" :rules="rules" :model="cusClearanceObj" label-width="120px">
      <el-form-item :label="$t('撤销理由')" prop="clEstTime">
        <el-input v-model="cusClearanceObj.applyReason" type="textarea" :rows="4"></el-input>
      </el-form-item>
    </el-form>

    <el-row class="operate-button">
      <el-button type="primary" @click="onSubmit">{{$t('确定')}}</el-button>
      <el-button @click="cancel">{{$t('取消')}}</el-button>
    </el-row>
  </div>
</template>

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

export default {
  name: "updateError",
  inheritAttrs: false,
  components: {},
  props: {
    shipmentObj: Object,
    cancelClearInfo: Object,
  },
  data() {
    return {
      // 到港对象
      cusClearanceObj: {},
      // 校验
      rules: {
        applyReason: [
          { required: true, message: this.$t("必填"), trigger: "change" },
        ]
      }
    };
  },
  methods: {
    onSubmit() {
      this.$refs["arrivalForm"].validate((valid) => {
        if (valid) {
          approvalCreate({
            shipmentId: this.shipmentObj.id,
            approvalStatus: 0,
            approvalType: 21,
            orderId: this.cancelClearInfo.orderId,
            applyReason: this.cusClearanceObj.applyReason
          }).then(()=>{
              this.$message.success("成功");
              this.cancel()
            })
        }
      });
    },
    cancel() {
      this.$emit("closeDialog");
    },
  },
};
</script>

<style lang="scss" scoped>
.shipping-update-error {
  .message-title {
    text-align: center;
    font-size: 20px;
    margin: 0 20px 10px;
  }
}
</style>
