seaProcess.vue 11 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
<template>
  <div class="app-seaProcess">
    <!-- 海运流程图 -->
    <el-scrollbar :vertical="true" viewClass="shipping-chart">
      <div v-for="(nodes,index) in processData" :key="index" class="chart-nodes">
        <div class="node-area">
          <div v-for="node in nodes" :key="node.title" @click="nodeClick(index, node)" class="node-div">
            <div>
              <img :src="getImgSrc(node)" alt="" :width="width" :height="height">
              <p>{{node.title}}</p>
            </div>
          </div>
        </div>
        <div class="arrow-area" v-if="index !== (processData.length-1)">
          <img src="@/assets/images/shipping/jt-start.png" alt="" v-if="index >= currIndex">
          <img src="@/assets/images/shipping/jt-end.png" alt="" v-if="index < currIndex">
        </div>
      </div>
    </el-scrollbar>

    <!-- 弹窗 -->
    <el-dialog custom-class="shipping-dialog" :title="dialogConfig.title" :visible.sync="dialogConfig.dialogVisible" :width="dialogConfig.width" :fullscreen="dialogConfig.fullscreen" :close-on-click-modal=false :modal-append-to-body=false append-to-body>
      <component v-bind:is="currentComponent" v-if="dialogConfig.dialogVisible" @closeDialog="closeDialog" v-bind="$attrs" v-on="$listeners" :shipmentObj="shipmentObj" :currNode="currNode"></component>
    </el-dialog>
  </div>
</template>

<script>
import bookingWidget from "./nodePage/booking.vue";
import trailerWidget from "./nodePage/trailer.vue";
import preinstallWidget from "./nodePage/preinstall.vue";
import agentWidget from "./nodePage/agent.vue";
import cabinetWidget from "./nodePage/cabinet/index.vue";
import cusDeclarationWidget from "./nodePage/cusDeclaration.vue";
import shipWidget from "./nodePage/ship.vue";
import subMaterialWidget from "./nodePage/subMaterial.vue";
import bargeWidget from "./nodePage/barge.vue";
import departureWidget from "./nodePage/departure.vue";
import blCopyWidget from "./nodePage/blCopy.vue";
import clrDocumentWidget from "./nodePage/clrDocument.vue";
import arrivalWidget from "./nodePage/arrival.vue";
import cusClearanceWidget from "./nodePage/cusClearance.vue";
import twoWayTakeoffWidget from "./nodePage/twoWayTakeoff.vue";
import twoWayArrivalWidget from "./nodePage/twoWayArrival.vue";
zhoutong's avatar
zhoutong committed
45
import unloadingWidget from "./nodePage/unloading/startUnloading.vue";
zhoutong's avatar
zhoutong committed
46 47
import settlementWidget from "./nodePage/settlement.vue";
import reviewWidget from "./nodePage/review.vue";
wanglianghe's avatar
wanglianghe committed
48 49
import shipmentWidget from "./nodePage/shipment.vue";
import checkoutWidget from "./nodePage/checkout.vue";
zhoutong's avatar
zhoutong committed
50
import tallyWidget from "./nodePage/tally/index.vue";
zhoutong's avatar
zhoutong committed
51
import mergePkgWidget from "./nodePage/mergePkg/index.vue";
zhoutong's avatar
zhoutong committed
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
import {checkPermi} from '@/utils/permission'

/**
 * 海运流程图
 */
export default {
  name: "shippingChart",
  inheritAttrs: false,
  components: {
    bookingWidget,
    trailerWidget,
    preinstallWidget,
    agentWidget,
    cabinetWidget,
    cusDeclarationWidget,
    shipWidget,
    subMaterialWidget,
    bargeWidget,
    departureWidget,
    blCopyWidget,
    clrDocumentWidget,
    arrivalWidget,
    cusClearanceWidget,
    twoWayTakeoffWidget,
    twoWayArrivalWidget,
    unloadingWidget,
    settlementWidget,
wanglianghe's avatar
wanglianghe committed
79 80
    shipmentWidget,
    checkoutWidget,
zhoutong's avatar
zhoutong committed
81 82
    reviewWidget,
    tallyWidget,
zhoutong's avatar
zhoutong committed
83
    mergePkgWidget
zhoutong's avatar
zhoutong committed
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 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
  },
  props: {
    shipmentObj: Object,
    seaBaseData: Array,
    width: {
      type: String,
      default: "76px",
    },
    height: {
      type: String,
      default: "76px",
    },
  },
  data() {
    return {
      // 弹窗配置
      dialogConfig: {
        dialogVisible: false,
        title: "",
        width: "",
        fullscreen: false,
      },
      // 当前组件
      currentComponent: "",
      // 当前步骤节点坐标
      currIndex: 0,
      // 当前节点
      currNode: {},
      // 数据
      processData: this.seaBaseData,
      errorMsg: this.$t('请先完成上一步')
    };
  },
  created() {},
  /* computed: {
    isShowAgent() {
      return (type) => {
        if (type === "agent") {
          const { preInstallInfo } = this.shipmentObj;
          const user = this.$store.state.user;
          if (preInstallInfo && preInstallInfo.noticeUser === user.id)
            return true;
          return false;
        }
        return true;
      };
    },
  }, */
  methods: {
    /** 关闭弹窗 */
    closeDialog(type) {
      this.$set(this.dialogConfig, "dialogVisible", false);
      if (type === "submit") {
        this.$emit("getBoxInfo");
      }
    },
    /** 节点点击 */
    nodeClick(currIndex, node) {
zhoutong's avatar
zhoutong committed
142
      if (!checkPermi(['boxAir:'+node.type+':action'])) {
143 144 145
        this.$message.error(this.$t("没有此操作的权限"));
        return;
      }
146 147 148 149 150 151
      if(node.type == 'checkout'){
        if(this.shipmentObj.airShipmentStatus != 175){
          this.$message.error(this.$t("请先完成出货操作"));
          return;
        }
      }
152
      console.log(currIndex,this.currIndex)
153 154 155 156
      if (currIndex > this.currIndex) {
        this.$message.error(this.errorMsg);
        return;
      }
zhoutong's avatar
zhoutong committed
157 158 159 160 161 162 163 164
      this.currNode = node;
      this.currentComponent = `${node.type}Widget`;
      this.$set(this.dialogConfig, "width", "500px");
      this.$set(this.dialogConfig, "title", node.title);
      this.$set(this.dialogConfig, "fullscreen", false);
      switch (node.type) {
        // 订舱
        case "booking":
zhoutong's avatar
zhoutong committed
165 166 167 168 169 170
          break;
        // 合包
        case "mergePkg":
          this.$set(this.dialogConfig, "fullscreen", true);
          this.$set(this.dialogConfig, "title", this.$t("合包列表"));
          break;
dragondean@qq.com's avatar
dragondean@qq.com committed
171 172 173 174 175 176 177 178
        // 出货
        case "shipment":
          if (this.shipmentObj[node.keyName] == 175) {
            this.currentComponent = `reviewWidget`;
            this.$set(this.dialogConfig, "width", "700px");
            this.$set(this.dialogConfig, "title", this.$t("出货反审"));
          }
          break;
zhoutong's avatar
zhoutong committed
179 180 181 182
        // 清关文件
        case "clrDocument":
          this.$set(this.dialogConfig, "width", "700px");
          break;
zhoutong's avatar
zhoutong committed
183 184 185 186
        // 报关
        case "cusDeclaration":
          this.$set(this.dialogConfig, "width", "700px");
          break;
187 188 189 190
        // 清关
        case "cusClearance":
          this.$set(this.dialogConfig, "width", "700px");
          break;
zhoutong's avatar
zhoutong committed
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
        // AGENT
        case "agent":
          this.$set(this.dialogConfig, "title", this.$t("代理商设置"));
          break;
        // 理货
        case "tally":
          this.$set(this.dialogConfig, "fullscreen", true);
          break;
        // 预装
        case "preinstall":
          // 预装反审
          const preStatus = this.shipmentObj[node.keyName];
          if ([25].includes(preStatus)) {
            this.currentComponent = `reviewWidget`;
            this.$set(this.dialogConfig, "width", "700px");
zhoutong's avatar
zhoutong committed
206
            this.$set(this.dialogConfig, "title", this.$t("分拣反审"));
zhoutong's avatar
zhoutong committed
207 208
          } else {
            this.$set(this.dialogConfig, "fullscreen", true);
209
            this.$set(this.dialogConfig, "title", this.$t("空运-分拣"));
zhoutong's avatar
zhoutong committed
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
          }
        // 装柜
        case "cabinet":
          // 装柜反审
          const cabStatus = this.shipmentObj[node.keyName];
          if ([47].includes(cabStatus)) {
            this.currentComponent = `reviewWidget`;
            this.$set(this.dialogConfig, "width", "700px");
            this.$set(this.dialogConfig, "title", this.$t("装柜反审"));
          }
          break;
        // 卸柜
        case "unloading":
          // 卸柜反审
          const unStatus = this.shipmentObj[node.keyName];
          if ([186].includes(unStatus)) {
            this.currentComponent = `reviewWidget`;
            this.$set(this.dialogConfig, "width", "700px");
228
            this.$set(this.dialogConfig, "title", this.$t("到仓反审"));
zhoutong's avatar
zhoutong committed
229 230
          }else{
            this.$set(this.dialogConfig, "fullscreen", true);
zhoutong's avatar
zhoutong committed
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355
          }
          break;
      }
      this.$set(this.dialogConfig, "dialogVisible", true);
    },
    /* 获取图片路径 */
    getImgSrc(node) {
      return node.imgSrc[node.currStatus ?? "start"];
    },
  },
  watch: {
    /* 监听发货对象 */
    shipmentObj(val) {
      let newNodes = [],
        finish = 0;
      // 迭代每个节点
      for (let i = 0; i < this.seaBaseData.length; i++) {
        const nodes = this.seaBaseData[i];
        let nodeIndex = 0;
        for (let j = 0; j < nodes.length; j++) {
          const node = nodes[j];
          const { keyName, voName, status, type } = node;

          // agent
          if (!keyName && type === "agent") {
            if (val[voName]) {
              // 已完成agent节点
              node.currStatus = "end";
              ++nodeIndex;
            }
            continue;
          }

          const { start, wait, end } = status;

          if (start.includes(val[keyName])) {
            node.currStatus = "start";
          }

          if (start.includes(val[keyName]) && val[voName]) {
            node.currStatus = "wait";
          }

          if (wait.includes(val[keyName])) {
            node.currStatus = "wait";
          }

          if (end.includes(val[keyName])) {
            node.currStatus = "end";
            // 判断是否存在异常未处理
            if (
              (type === "cusDeclaration" && val.customsHasAbnormal) ||
              (type === "departure" && val.shippingHasAbnormal) ||
              (type === "arrival" && val.arrivalHasAbnormal)
            ) {
              this.errorMsg = this.$t('请先处理完出货异常,再进行操作')
              continue;
            }
            // 报关
            if (type === "cusDeclaration") {
              const { dcCustomsStatus, dcCheckStatus } = val;
              // 查验状态并且是退场/部分退场
              if (dcCustomsStatus === 3 && [1, 2].includes(dcCheckStatus)) {
                // 只有审核通过并且已处理才算完成
                if (val.checkExamineStatus === 2 && val.checkDealStatus === 1) {
                  // 已完成节点个数
                  ++nodeIndex;
                } else {
                  continue;
                }
              }
            }
            // 已完成节点个数
            ++nodeIndex;
          }
        }
        // 如果相等标识该步骤已完成
        if (nodeIndex === nodes.length) {
          // 加1表示为已完成步骤后一步
          finish = finish + 1;
        }
        newNodes.push(nodes);
      }
      this.currIndex = finish;
      this.processData = newNodes;
    },
  },
};
</script>

<style lang="scss">
.app-seaProcess {
  .shipping-chart {
    display: flex;
    padding: 10px 10px;
    min-width: 1300px;
    width: max-content;

    .chart-nodes {
      display: flex;
      align-items: center;
      justify-content: center;
      .node-area {
        display: flex;
        flex-direction: column;
        align-items: center;

        .node-div {
          text-align: center;
          margin-top: 10px;
          cursor: pointer;
          p {
            margin-top: -10px;
            margin-bottom: 0px;
            text-align: center;
          }
        }
      }
      .arrow-area {
        margin: 0 6px;
      }
    }
  }
}
</style>