updateClear.vue 3.36 KB
Newer Older
zhoutong's avatar
zhoutong committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
<template>
  <div class="shipping-update-error">
    <div class="message-title">{{headerTitle}}</div>
    <el-form ref="arrivalForm" :rules="rules" :model="cusClearanceObj" label-width="120px">
      <el-form-item :label="$t('预计清关时间')" prop="clEstTime">
        <el-date-picker type="datetime" :placeholder="$t('请选择日期')" v-model="cusClearanceObj.clEstTime" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
      </el-form-item>
      <el-form-item :label="$t('清关时间')" prop="clClearTime">
        <el-date-picker type="datetime" :placeholder="$t('请选择日期')" v-model="cusClearanceObj.clClearTime" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
        <p class="message-area" v-show="showMsg">{{$t('清关时间与预计时间不符,如有异常请登记')}}</p>
      </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>
zhoutong's avatar
zhoutong committed
22
import { updateOrderClearance, updateAllOrderClearance } from "@/api/ecw/boxAir";
zhoutong's avatar
zhoutong committed
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37

export default {
  name: "updateError",
  inheritAttrs: false,
  components: {},
  props: {
    shipmentObj: Object,
    clearInfo: Object,
  },
  data() {
    return {
      // 到港对象
      cusClearanceObj: {},
      // 校验
      rules: {
zhoutong's avatar
zhoutong committed
38
        clEstTime: [
zhoutong's avatar
zhoutong committed
39 40
          { required: true, message: this.$t("必填"), trigger: "change" },
        ],
zhoutong's avatar
zhoutong committed
41
        clClearTime: [
zhoutong's avatar
zhoutong committed
42 43 44 45 46 47 48
          { required: true, message: this.$t("必填"), trigger: "change" },
        ]
      },
      headerTitle: "",
    };
  },
  watch: {
zhoutong's avatar
zhoutong committed
49
    clearInfo: {
zhoutong's avatar
zhoutong committed
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
      handler: function (val) {
        const { orderList, type } = val;

        if (type === "selected") {
          this.headerTitle = this.$t(
            "确定给{selfNo}下的{orderNos}更新状态吗?",
            {
              selfNo: this.shipmentObj.selfNo,
              orderNos: orderList.map((item) => item.orderNo).join(",") ?? "",
            }
          );
        } else {
          this.headerTitle = this.$t(
            `确定给{selfNo}下的${
              type === "all" ? this.$t("所有订单") : this.$t("所选订单")
            }更新状态吗?`,
            {
              selfNo: this.shipmentObj.selfNo,
            }
          );
        }
      },
      immediate: true,
    },
  },
  methods: {
    onSubmit() {
      this.$refs["arrivalForm"].validate((valid) => {
        if (valid) {
          if(this.clearInfo.type == 'selected'){
            let param = {
              shipmentId: this.shipmentObj.id,
              orderIdList: this.clearInfo.orderList
            }
            updateOrderClearance({...this.cusClearanceObj, ...param}).then(()=>{
              this.$message.success("成功");
              this.cancel()
            })
          }else{
            let param = {
              shipmentId: this.shipmentObj.id
            }
zhoutong's avatar
zhoutong committed
92
            updateAllOrderClearance({...this.cusClearanceObj, ...param}).then(()=>{
zhoutong's avatar
zhoutong committed
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
              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>