routeInfo.vue
12.2 KB
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
224
225
226
227
228
229
230
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
<template>
<div ref="barEcharts" class="route-info-container">
<!-- 航线设置规则信息查询条件 -->
<el-row style="padding: 0 50px">
<el-col>
<yl-form
ref="ruleForm"
:formConfig="formConfig"
:queryForm="queryForm"
:inline="false"
formWidth="auto"
@blur="blurEvent"
>
<yl-draggable
:routeList="routeList"
:dragOptions="dragOptions"
></yl-draggable>
</yl-form>
</el-col>
</el-row>
<!-- 航线设置规则信息 -->
<el-row>
<el-col :span="24">
<el-divider content-position="left">航线维度设置</el-divider>
</el-col>
<el-col>
<route-info
:routesInfo="routesInfo"
:cargoType="cargoType"
:cargoStatus="cargoStatus"
:puporpux="puporpux"
:serviceCode="serviceCode"
:handlingCode="handlingCode"
:subCategory="subCategory"
:status="getRouter"
@collapse="collapseChange"
@location="changeLocation"
@destinationSite="changeDestinationSite"
@cargoType="changeCargoType"
@cargoStatus="changeCargoStatus"
@puporpux="changePuporpux"
@serviceCode="changeServiceCode"
@handlingCode="changeHandlingCode"
@subCategory="changeSubCategory"
@addRlue="addRlue"
>
</route-info>
</el-col>
</el-row>
</div>
</template>
<script>
import YlForm from "@/components/YlForm";
import RouteInfo from "./components/routeInfo";
import YlDraggable from "@/components/YlDraggable";
import { formConfig, routeRuleForm } from "./formConfig";
import { removeDuplicates, filterRepeat } from "@/utils";
import {
allDictData, // 获取全部字典
findDestinationFltRuleByFlightNo, // 航线维度设置详情
findByFlightId, // 通过id查询目的航班维度配置详情
updateOrAddFlight, // 修改
delFlightId, // 删除航线规则配置
enableOrDisable, // 是否停用/开启航线规则配置
batchUpdateOrAddFlight, // 更新航线优先级
queryRouteByFltNo, // 通过航班号查询航线
} from "@/api/destinationFlight";
import indexMixins from "./mixins";
import { routeData, routeInfo } from "./routeData";
export default {
components: {
YlForm,
RouteInfo,
YlDraggable,
},
mixins: [indexMixins],
data() {
return {
dragOptions: {
// 航线优先级拖拽配置
animation: 200,
group: "description",
disabled: false, // 是否禁止拖拽
ghostClass: "ghost",
},
formConfig: formConfig, // 表单配置项
queryForm: {
// 表单参数
},
routeList: [], // 航线
routesInfo: [], // 航线规则信息
cargoType: [], // 申报类别
cargoStatus: [], // 货物类型
puporpux: [], // 取件扫描号
serviceCode: [], // Service Code
handlingCode: [], // Handling Code
subCategory: [], // Sub Category
};
},
/*
判断有日期的找到了就走有日期的,如果日期级别的没有找到再去走一次普通级别的接口
*/
created() {
this.getAllDictData(); // 获取全部字典
let _this = this;
// 航班配舱维度规则设置查询条件
let queryCondition = {
// 航班配舱设置
flightAllocConfig: {
querySpecifyData: _this.$route.query.querySpecifyData,
noDateParmas: {
flightDate: "",
flightRoute: "",
purposeOfFlightNo: _this.$route.query.purposeOfFlightNo,
status: "",
},
dateParmas: {
flightDate: _this.$route.query.flightDate,
flightRoute: "",
flightRouteListStr: "",
purposeOfFlightNo: _this.$route.query.purposeOfFlightNo,
status: "",
},
queryParmas: function () {
// 非日期级别
if (this.querySpecifyData == "2") {
_this
.noDateLevelRoute(this.noDateParmas)
.then(({ routeList, dataList }) => {
const result = routeList.map((item1) => {
const item2 = dataList.find((item2) => {
if (item1.route === item2.flightRoute) {
item2.config = true;
return item2;
}
});
if (item2) {
// 有数据的合并对象,
return { ...item1, ...item2 };
} else {
item1.config = false;
return item1; // 没有的返回当前的
}
});
// 处理属性
result.map((item) => {
if (item.config) {
_this.hasOwnProperty(item, "typeOfGoods");
_this.hasOwnProperty(item, "puporpuxCode");
_this.hasOwnProperty(item, "serviceCode");
_this.hasOwnProperty(item, "handlingCode");
_this.hasOwnProperty(item, "subCategory");
_this.setattrVal(item); // 设置属性值
}
});
_this.routesInfo = result;
});
}
// 日期级别
if (this.querySpecifyData == "1") {
_this.dateLevelRoute(this.dateParmas).then((res) => {
const { configFlag, dateFlightRoute } = res;
if (configFlag == false) {
// 航班航线有规则配置的
const dateListHas = dateFlightRoute.filter(
(item) => item.config == true
);
// 航班航线没有规则配置的
const dateListNo = dateFlightRoute.filter(
(item) => item.config == false
);
_this
.noDateLevelRoute(this.noDateParmas)
.then(({ dataList }) => {
console.log(dateListNo);
console.log(dataList);
const result = dateListNo.map((item1) => {
const item2 = dataList.find((item2) => {
if (item1.route === item2.flightRoute) {
item2.config = true;
return item2;
}
});
if (item2) {
// 有数据的合并对象,
return { ...item1, ...item2 };
} else {
item1.config = false;
return item1; // 没有的返回当前的
}
});
let dateList = dateListHas.concat(result);
// 处理属性
dateList.map((item) => {
if (item.config) {
_this.hasOwnProperty(item, "typeOfGoods");
_this.hasOwnProperty(item, "puporpuxCode");
_this.hasOwnProperty(item, "serviceCode");
_this.hasOwnProperty(item, "handlingCode");
_this.hasOwnProperty(item, "subCategory");
_this.setattrVal(item); // 设置属性值
}
});
_this.routesInfo = dateList;
});
}
});
}
},
},
// 航班信息维护
flightInformationMaintenance: {
noDateParmas: {
purposeOfFlightNo: _this.$route.query.purposeOfFlightNo,
flightRouteListStr: _this.$route.query.flightRouteListStr,
status: "",
},
dateParmas: {
purposeOfFlightNo: _this.$route.query.purposeOfFlightNo,
flightDate: _this.$route.query.flightDate,
flightRouteListStr: _this.$route.query.flightRouteListStr,
status: "",
},
queryParmas: function () {
// White Tail
if (_this.$route.query.flightKindName == "White Tail") {
_this.noDateLevelRoute(this.noDateParmas);
}
// Purple Tail
if (_this.$route.query.flightKindName == "Purple Tail") {
_this.dateLevelRoute(this.dateParmas);
}
},
},
// 航班顺位设置
flightRandConfig: {
noDateParmas: {
flightRoute: "",
flightRouteListStr: "",
purposeOfFlightNo: _this.$route.query.purposeOfFlightNo,
status: "",
},
dateParmas: {
flightDate: _this.$route.query.flightDate,
flightRoute: "",
purposeOfFlightNo: _this.$route.query.purposeOfFlightNo,
status: "",
},
queryParmas: function () {
// 普通级别
if (_this.$route.query.pageName == "flightRandConfig") {
_this.noDateLevelRoute(this.noDateParmas);
_this.dateLevelRoute(this.dateParmas);
}
},
},
};
// 航班配舱设置
queryCondition.flightAllocConfig.queryParmas();
// 航班信息维护
queryCondition.flightInformationMaintenance.queryParmas();
// 航班顺位设置
queryCondition.flightRandConfig.queryParmas();
},
mounted() {},
methods: {
// 普通级别的
noDateLevelRoute(parmas) {
return new Promise((resolve, reject) => {
findDestinationFltRuleByFlightNo(parmas)
.then((res) => {
const { code, data, msg } = res;
if (code != 200) {
this.msgError(msg);
return;
}
let routeList = data.routeList; // 航班航线基本信息
// 普通级别航班航线维度规则详情
const dataList = removeDuplicates(data.list, {
duplicate: "flightRoute", // 去重字段
sort: false, // 是否要排序
sortType: "Number", // 排序类型
sortAttr: "routePriority", // 排序字段
});
resolve({ routeList: routeList, dataList: dataList.unique });
})
.catch(() => {});
});
},
// 日期级别的
dateLevelRoute(parmas) {
return new Promise((resolve, reject) => {
findDestinationFltRuleByFlightNo(parmas).then((res) => {
const { code, data, msg } = res;
if (code != 200) {
this.msgError(msg);
return;
}
this.routeList = data.routeList; // 航班航线基本信息
// 日期级别航班航线维度规则详情
const dataList = removeDuplicates(data.list, {
duplicate: "flightRoute", // 去重字段
sort: false, // 是否要排序
sortType: "Number", // 排序类型
sortAttr: "routePriority", // 排序字段
});
let config = false; // 有缺省的航线配置
const result = this.routeList.map((item1) => {
const item2 = dataList.unique.find((item2) => {
if (item2.flightRoute === item1.route) {
config = item2.config = true;
if (this.$route.query.pageName == "flightAllocConfig") {
item2.remark = true;
} else {
item2.remark = false;
}
return item2;
}
}); // 返回当前相等的一条数据
if (item2) {
return { ...item1, ...item2 };
} else {
config = item1.config = false;
return item1; // 没有的返回当前的
}
});
let configFlag = result.every((item) => item.config == true);
// 返回日期级别查询结果
resolve({ configFlag: configFlag, dateFlightRoute: result });
});
});
},
// 新增规则
addRlue(index) {
// 如果当前航班号的航线下没有数据给
this.setattrVal(routeRuleForm);
const mergeObj = {
...this.routesInfo[index],
...routeRuleForm,
};
this.$set(this.routesInfo, index, mergeObj); // 给新增规则赋上默认数据
console.log("新增规则:", this.routesInfo);
},
},
};
</script>
<style lang="scss" scoped>
.route-info-container {
padding: 20px;
}
</style>