updateArrival.vue 3.49 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 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
<template>
  <div class="shipping-update-error">
    <div class="message-title">{{headerTitle}}</div>
    <el-form ref="arrivalForm" :rules="rules" :model="airArrivalInfo" label-width="120px">
      <el-form-item :label="$t('实际二程起飞时间')" prop="actSecondTime">
        <el-date-picker type="datetime" :placeholder="$t('请选择日期')" v-model="airArrivalInfo.actSecondTime" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
      </el-form-item>
      <el-form-item :label="$t('预计到港时间')" prop="estTime">
        <el-date-picker type="datetime" :placeholder="$t('请选择日期')" v-model="airArrivalInfo.estTime" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
      </el-form-item>
      <el-form-item :label="$t('实际到港时间')" prop="actTime">
        <el-date-picker type="datetime" :placeholder="$t('请选择日期')" v-model="airArrivalInfo.actTime" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
      </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 { updateOrderArrival, updateAllOrderArrival } from "@/api/ecw/boxAir";

export default {
  name: "updateError",
  inheritAttrs: false,
  components: {},
  props: {
    shipmentObj: Object,
    arrivalInfo: Object,
  },
  data() {
    return {
      // 到港对象
      airArrivalInfo: {},
      // 校验
      rules: {
        actSecondTime: [
          { required: true, message: this.$t("必填"), trigger: "change" },
        ],
        actTime: [
          { required: true, message: this.$t("必填"), trigger: "change" },
        ]
      },
      headerTitle: "",
    };
  },
  watch: {
    arrivalInfo: {
      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.arrivalInfo.type == 'selected'){
            let param = {
              shipmentId: this.shipmentObj.id,
              orderIdList: this.arrivalInfo.orderList
            }
            updateOrderArrival({...this.airArrivalInfo, ...param}).then(()=>{
              this.$message.success("成功");
              this.cancel()
            })
          }else{
            let param = {
              shipmentId: this.shipmentObj.id
            }
            updateAllOrderArrival({...this.airArrivalInfo, ...param}).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>