updateError.vue 4.48 KB
Newer Older
huhaiqing's avatar
huhaiqing 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
<template>
  <div class="shipping-update-error">
    <!-- 更新报关异常状态 -->
    <div class="message-title">{{headerTitle}}</div>
    <el-form ref="updateErrorForm" :rules="rules" :model="updateObj" label-width="140px">
      <el-form-item :label="$t('更新类型')" prop="type">
        <el-radio-group v-model="updateObj.type">
          <el-radio v-for="item in this.getDictDatas(this.DICT_TYPE.BOX_SHIPPING_UPDATE_TYPE)" :key="item.value" :label="item.value">{{$l(item, 'label')}}</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item :label="$t('更新订单状态')">
        <el-radio-group v-model="updateObj.updateOrder">
          <el-radio v-for="item in types" :key="item.value" :label="item.value">{{$l(item, 'label')}}</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item prop="customize">
        <el-input v-model="updateObj.customize" :placeholder="$t('请输入')" :disabled="!isEnter"></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 { updateAbnormalOrder } from "@/api/ecw/box";
import { serviceMsg } from "./shippingSea/utils";

export default {
  name: "updateError",
  inheritAttrs: false,
  components: {},
  props: {
    shipmentObj: Object,
    errorInfo: Object,
  },
  data() {
    return {
      updateObj: {},
      rules: {
        type: [{ required: true, message: this.$t("必填"), trigger: "change" }],
      },
      types: [],
      isEnter: false,
      headerTitle: "",
    };
  },
  methods: {
    onSubmit() {
      this.$refs["updateErrorForm"].validate((valid) => {
        if (valid) {
          let text = "";
          // 自定义
huhaiqing's avatar
huhaiqing committed
56 57 58 59 60 61 62 63 64
          if (this.updateObj.updateOrder) {
            if (this.updateObj.updateOrder === "0") {
              text = this.updateObj.customize;
            } else {
              const dict = this.types.find(
                (item) => item.value === this.updateObj.updateOrder
              );
              text = this.$l(dict, "label");
            }
huhaiqing's avatar
huhaiqing committed
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
          }

          const { orderList } = this.errorInfo;
          updateAbnormalOrder({
            shipmentId: this.shipmentObj.id,
            orderIdList: orderList.map((item) => item.orderId) ?? [],
            type: this.updateObj.type,
            text,
          }).then((res) => {
            serviceMsg(res, this).then(() => {
              this.$emit("closeDialog", "detail");
            });
          });
        }
      });
    },
    cancel() {
      this.$emit("closeDialog");
    },
  },
  watch: {
    errorInfo: {
      handler: function (val) {
huhaiqing's avatar
huhaiqing committed
88 89 90 91 92 93 94 95 96 97 98 99 100
        const { errorType, orderList, operate } = val;

        if (operate === "single") {
          this.headerTitle = this.$t(
            "确定给{selfNo}下的{orderNos}更新状态吗?",
            {
              selfNo: this.shipmentObj.selfNo,
              orderNos: orderList.map((item) => item.orderNo).join(",") ?? "",
            }
          );
        } else {
          this.headerTitle = this.$t(
            `确定给{selfNo}下的${
Marcus's avatar
Marcus committed
101
              operate === "all" ? this.$t("所有订单") : this.$t("所选订单")
huhaiqing's avatar
huhaiqing committed
102 103 104 105 106 107 108
            }更新状态吗?`,
            {
              selfNo: this.shipmentObj.selfNo,
            }
          );
        }

huhaiqing's avatar
huhaiqing committed
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
        switch (errorType) {
          // 报关异常
          case "customs":
            this.types = this.getDictDatas(
              this.DICT_TYPE.BOX_CUSTOMS_ERROR_TYPE
            );
            break;
          case "shipping":
            this.types = this.getDictDatas(
              this.DICT_TYPE.BOX_SHIPPING_ERROR_TYPE
            );
            break;
          case "arrival":
            this.types = this.getDictDatas(
              this.DICT_TYPE.BOX_ARRIVAL_ERROR_TYPE
            );
            break;
        }
      },
      immediate: true,
    },
    "updateObj.updateOrder"(val) {
      if (val === "0") {
        this.isEnter = true;
        this.rules.customize = [
          { required: true, message: this.$t("必填"), trigger: "change" },
        ];
      } else {
        this.isEnter = false;
        this.rules.customize = [];
        this.$refs["updateErrorForm"].clearValidate("customize");
      }
    },
  },
};
</script>

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