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
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
<template>
<div class="app-seaProcess">
<!-- 海运流程图 -->
<el-scrollbar :vertical="true" viewClass="shipping-chart">
<div v-for="(nodes,index) in seaBaseData" :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">
<template v-if="!node.unNode">
<img :src="getImgSrc(node)" alt="">
<p>{{node.title}}</p>
</template>
<template v-else-if="node.unNode">
<el-button type="primary" @click="nodeClick(index, node)" style="width:100px;">{{node.title}}</el-button>
</template>
</div>
</div>
<div class="arrow-area" v-if="index !== (seaBaseData.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" :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 preinstallReviewWidget from "./nodePage/preinstallReview.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 unloadingWidget from "./nodePage/unloading/index.vue";
import settlementWidget from "./nodePage/settlement.vue";
/**
* 海运流程图
*/
export default {
name: "shippingChart",
inheritAttrs: false,
components: {
bookingWidget,
trailerWidget,
preinstallWidget,
agentWidget,
cabinetWidget,
cusDeclarationWidget,
shipWidget,
subMaterialWidget,
bargeWidget,
departureWidget,
blCopyWidget,
clrDocumentWidget,
arrivalWidget,
cusClearanceWidget,
unloadingWidget,
settlementWidget,
preinstallReviewWidget,
},
props: {
shipmentObj: Object,
seaBaseData: Array,
},
data() {
return {
// 弹窗配置
dialogConfig: {
dialogVisible: false,
title: "",
width: "",
fullscreen: false,
},
// 当前组件
currentComponent: "",
// 当前步骤节点坐标
currIndex: 0,
// 当前节点
currNode: {},
};
},
created() {},
methods: {
/** 关闭弹窗 */
closeDialog(type) {
this.$set(this.dialogConfig, "dialogVisible", false);
if (type === "submit") {
this.$emit("getBoxInfo");
}
},
/** 节点点击 */
nodeClick(currIndex, node) {
if (currIndex > this.currIndex) {
this.$message.error("请先完成上一步");
return;
}
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":
// 驳船
case "barge":
// 清关文件
case "clrDocument":
this.$set(this.dialogConfig, "width", "700px");
break;
// AGENT
case "agent":
this.$set(this.dialogConfig, "title", "代理商设置");
break;
// 预装
case "preinstall":
// 预装反审
const status = this.shipmentObj[node.keyName];
if ([23, 24].includes(status)) {
this.currentComponent = `preinstallReviewWidget`;
this.$set(this.dialogConfig, "width", "700px");
this.$set(this.dialogConfig, "title", "预装反审");
} else {
this.$set(this.dialogConfig, "fullscreen", true);
this.$set(this.dialogConfig, "title", "出货安排(预装)");
}
break;
}
this.$set(this.dialogConfig, "dialogVisible", true);
},
/* 获取图片路径 */
getImgSrc(node) {
return node.imgSrc[node.currStatus ?? "start"];
},
},
watch: {
/* 监听发货对象 */
shipmentObj(val) {
// 迭代每个节点
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 } = node;
if (!keyName) 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";
// 已完成节点个数
++nodeIndex;
}
}
// 如果相等标识改步骤已完成
if (nodeIndex === nodes.length) {
// 加1表示为已完成步骤后一步
this.currIndex = i + 1;
}
}
},
},
};
</script>
<style lang="scss">
.app-seaProcess {
.shipping-chart {
width: max-content;
display: flex;
padding: 10px 0;
.chart-nodes {
display: flex;
align-items: center;
justify-content: center;
.node-area {
display: flex;
flex-direction: column;
align-items: center;
.node-div {
margin-top: 10px;
cursor: pointer;
p {
margin-top: -10px;
margin-bottom: 0px;
text-align: center;
}
}
}
.arrow-area {
margin: 0 10px;
}
}
}
}
</style>