index.vue
19.9 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
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
<template>
<div class="search-wrap">
<div class="search-box">
<el-form
class="fedexFormStyle queryTextarea-box"
ref="sreachForm"
:model="sreachFormData"
label-position="top"
size="small"
:rules="rules"
>
<el-row :gutter="6">
<el-col :span="5">
<Formitem label="提單號碼(支持多個提單號查詢)" prop="deliveryNo">
<!-- <el-input
type="text"
id="inputInner--deliveryNo"
v-model="sreachFormData.deliveryNo"
clearable
>
</el-input> -->
<el-input
type="textarea"
class="inputShadow"
id="inputInner--deliveryNo"
resize="none"
:rows="consignmentCodeRows"
v-model="sreachFormData.deliveryNo"
clearable
placeholder=""
@focus="consignmentCodeFocus"
@blur="consignmentCodeBlur"
></el-input>
<el-badge
v-if="
consignmentCodeRows == 1 &&
sreachFormData.consignmentCode.length > 1
"
type="info"
:value="`+${sreachFormData.consignmentCode.length}`"
class="item texttareaTip"
></el-badge>
</Formitem>
</el-col>
<el-col :span="4">
<Formitem label="提交時間(從)" prop="commitTimeFrom">
<el-date-picker
v-model="sreachFormData.commitTimeFrom"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
type="date"
id="inputInner--commitTimeFrom"
placeholder=""
prefix-icon="none"
@change="checkDate1"
></el-date-picker>
<!-- :picker-options="startPickerOptions"> -->
<!-- </el-date-picker> -->
</Formitem>
</el-col>
<el-col :span="4">
<Formitem label="提交時間(至)" prop="commitTimeTo">
<el-date-picker
v-model="sreachFormData.commitTimeTo"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
type="date"
id="inputInner--commitTimeTo"
placeholder=""
prefix-icon="none"
@change="checkDate2"
></el-date-picker>
<!-- :picker-options="endPickerOptions">
</el-date-picker> -->
</Formitem>
</el-col>
<el-col :span="2" class="search-btn">
<el-button @click="searchTable">
<img src="../../assets/images/select.svg" alt="" />
</el-button>
</el-col>
</el-row>
</el-form>
<span class="textCenter export-btn">
<el-button
class="entrySaveButton"
:loading="exportLoading"
@click="exportBtn()"
>
導出
</el-button>
</span>
</div>
<el-table
:data="tableData"
style="width: 100%"
:height="tableMaxheight"
:row-class-name="tableRowClassName"
v-loading="tableLoading"
class="queryTable"
@sort-change="handleSortChange"
>
<el-table-column
v-for="(item, index) in tableHeaderList"
:key="index"
:prop="item.prop"
:label="item.label"
:min-width="item.width"
:fixed="item.fixed ? item.fixed : false"
:align="item.align"
:sortable="item.sort"
>
<template slot-scope="scope">
<template v-if="item.tem == 'operStatusAndTime1'">
<div>
{{ scope.row.operStatus }}
</div>
<div>
{{ scope.row.commitTime }}
</div>
</template>
<!-- 传送时间 -->
<template v-else-if="item.tem == 'delStatus'">
<div class="query_page_popover">
<el-popover
v-if="scope.row.failedMsg"
trigger="hover"
placement="bottom"
:open-delay="1000"
>
<p>{{ scope.row.failedMsg }}</p>
<div slot="reference" class="name-wrapper">
{{ scope.row.delStatusAndTime }}
</div>
</el-popover>
<span v-else>{{ scope.row.delStatusAndTime }}</span>
</div>
</template>
<!-- 是否適用在目的地進口清關 -->
<template v-else-if="item.tem == 'isClear'">
<span v-if="scope.row.isClear == 0"> N </span>
<span v-else-if="scope.row.isClear == 1">Y</span>
</template>
<!-- 操作 -->
<template v-else-if="item.tem == 'opt'">
<el-dropdown trigger="click">
<span style="cursor: pointer">
<img src="../../assets/images/declareOpt.png" alt="" />
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item @click.native="viewDeclare(scope.row)">
查看
</el-dropdown-item>
<el-dropdown-item
v-if="scope.row.operStatus == '已提交'"
@click.native="reEditDeclare(scope.row)"
>
重新编辑
</el-dropdown-item>
<el-dropdown-item v-else @click.native="editDeclare(scope.row)">
編輯
</el-dropdown-item>
<el-dropdown-item
:disabled="scope.row.operStatus == '已提交'"
@click.native="deleteDeclare(scope.row)"
>
刪除
</el-dropdown-item>
<el-dropdown-item @click.native="downloadFiles(scope.row)"
>下載附件</el-dropdown-item
>
</el-dropdown-menu>
</el-dropdown>
</template>
<span v-else>{{ scope.row[item.prop] }}</span>
</template>
</el-table-column>
</el-table>
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="page.curPage"
:page-sizes="[20, 30, 50, 100]"
:page-size="page.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="page.total"
>
</el-pagination>
<detail-dialog ref="detailDialogRef"></detail-dialog>
<detail-drawer
ref="detailDrawerRef"
:pageIndex="pageIndex"
@viewPdf="openViewPdf"
></detail-drawer>
</div>
</template>
<script>
import {
getTableFindAll,
declareDeleteById,
reedit,
} from "@/api/declareTable.js";
import detailDrawer from "../declarationInput/detailDrawer.vue";
import detailDialog from "./detailDialog.vue";
import { tableHeaderKeys } from "./tableHeaderKey.js";
import { downLoadXlsx, downLoadViewPdf } from "@/utils/zipdownload";
export default {
name: "declareQuery",
components: {
detailDialog,
detailDrawer,
},
data() {
return {
pageIndex: "query",
tableData: [], //运单数据
tableHeaderList: tableHeaderKeys,
sreachFormData: {
deliveryNo: "",
commitTimeFrom: "",
commitTimeTo: "",
consignmentCode: [],
},
oldSreachFormData: {
deliveryNo: "",
commitTimeFrom: "",
commitTimeTo: "",
consignmentCode: [],
},
startDate: new Date() - 3,
endDate: new Date(),
page: {
curPage: 1,
pageSize: 20,
total: 0, //数据总和
},
tableSelect: true,
tableLoading: false, //表格loading
exportLoading: false,
defQuery: 0,
consignmentCodeRows: 1,
startPickerOptions: {
disabledDate: (time) => {
if (
this.sreachFormData.commitTimeTo != "" &&
this.sreachFormData.commitTimeTo != null
) {
let commitTimeTo = new Date(
this.sreachFormData.commitTimeTo
).getTime();
return time.getTime() > commitTimeTo;
} else {
return !time.getTime();
}
},
},
endPickerOptions: {
disabledDate: (time) => {
if (
this.sreachFormData.commitTimeFrom != "" &&
this.sreachFormData.commitTimeFrom != null
) {
let commitTimeFrom = new Date(
this.sreachFormData.commitTimeFrom
).getTime();
return time.getTime() < commitTimeFrom - 24 * 60 * 60 * 1000;
} else {
return !time.getTime();
}
},
},
sortOrder: 0, //查询排序 默认根据操作状态呢降序排序
};
},
computed: {
tableMaxheight() {
return window.innerHeight - 300;
},
getOldDate() {
let oldDate = new Date(new Date().getTime() - 3600 * 1000 * 24 * 2);
return (
oldDate.getFullYear() +
"-" +
(oldDate.getMonth() + 1).toString().padStart(2, 0) +
"-" +
oldDate.getDate().toString().padStart(2, 0)
);
},
getNewDate() {
let nowDate = new Date();
return (
nowDate.getFullYear() +
"-" +
(nowDate.getMonth() + 1).toString().padStart(2, 0) +
"-" +
nowDate.getDate().toString().padStart(2, 0)
);
},
rules() {
let rules = {
commitTimeFrom: [
{
validator: (rule, value, callback) => {
if (!value) {
this.$refs.sreachForm.clearValidate(["commitTimeTo"]);
this.tableSelect = true;
}
// new Date(year, month, day, hour, minute, second, millisecond);
if (value && this.sreachFormData.commitTimeTo) {
if (
new Date(value + " 00:00:00").getTime() >
new Date(
this.sreachFormData.commitTimeTo + " 00:00:00"
).getTime()
) {
callback("開始時間不能晚於截止時間");
this.tableSelect = false;
} else {
callback();
this.tableSelect = true;
}
}
},
trigger: "change",
},
],
commitTimeTo: [
{
validator: (rule, value, callback) => {
if (!value) {
this.$refs.sreachForm.clearValidate(["commitTimeFrom"]);
this.tableSelect = true;
}
if (value && this.sreachFormData.commitTimeFrom) {
if (
new Date(value + " 00:00:00").getTime() <
new Date(
this.sreachFormData.commitTimeFrom + " 00:00:00"
).getTime()
) {
callback("截止時間不能早於開始時間");
this.tableSelect = false;
} else {
callback();
this.tableSelect = true;
}
}
},
trigger: "change",
},
],
};
return rules;
},
},
created() {},
mounted() {
// let oldDate = new Date(new Date().getTime() - 3600 * 1000 * 24 * 2);
// let nowDate = new Date();
this.sreachFormData.commitTimeFrom = this.getOldDate;
this.sreachFormData.commitTimeTo = this.getNewDate;
// this.$set(this.sreachFormData,'commitTimeFrom', );
// this.$set(this.sreachFormData,'commitTimeTo', nowDate.getFullYear() + '-' + (nowDate.getMonth()+1) + '-' + (nowDate.getDate()));
this.sreachData(null);
},
methods: {
// 查询
sreachData(paramsData) {
// this.$refs["sreachForm"].validate((valid, object) => {
if (this.tableSelect) {
if (!paramsData) {
paramsData = {
...this.sreachFormData,
deliveryNo: this.sreachFormData.consignmentCode.join(";"),
page: this.page.curPage,
query: this.defQuery,
size: this.page.pageSize,
sort: this.sortOrder,
};
this.oldSreachFormData = {
...this.sreachFormData,
};
}
if (paramsData.deliveryNo.split(";").length > 1000) {
this.$alert("單次最多可查詢1000個提單號碼", "提示", {
confirmButtonText: "確定",
type: "warning",
});
return;
} else {
this.tableLoading = true;
delete paramsData.consignmentCode;
getTableFindAll(paramsData)
.then((res) => {
if (res.code == 200) {
this.tableData = res.data.list;
this.page.total = res.data.total;
} else {
this.msgWarning(res.msg);
}
})
.finally(() => {
this.tableLoading = false;
});
}
}
// });
},
checkDate1() {
this.$refs.sreachForm.validateField("commitTimeFrom", (valid) => {
if (!valid) {
this.$refs.sreachForm.validateField("commitTimeTo");
}
});
},
checkDate2() {
this.$refs.sreachForm.validateField("commitTimeTo", (valid) => {
if (!valid) {
this.$refs.sreachForm.validateField("commitTimeFrom");
}
});
},
// column 当前列数据 prop 当前排序的字段 order 排序规则
handleSortChange({ column, prop, order }) {
if (prop == "operStatusAndTime1") {
this.sortOrder = order ? (order == "descending" ? 2 : 1) : 0;
} else if (prop == "delStatus") {
this.sortOrder = order ? (order == "descending" ? 4 : 3) : 0;
}
this.page.curPage = 1;
let paramsData = {
...this.oldSreachFormData,
page: this.page.curPage,
query: this.defQuery,
size: this.page.pageSize,
sort: this.sortOrder,
};
this.sreachData(paramsData);
},
// 查询按钮
searchTable() {
this.page.curPage = 1;
this.defQuery = "";
this.sreachData(null);
},
// 改变偶数行背景色
tableRowClassName({ row, rowIndex }) {
if ((rowIndex + 1) % 2 === 0) {
return "bgc-row";
}
return "";
},
//操作
deleteDeclare(row) {
this.$confirm("是否確認刪除", "提示", {
confirmButtonText: "確定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
declareDeleteById(row.id).then((res) => {
if (res.code == 200) {
this.$message({
type: "success",
message: "刪除成功!",
});
this.sreachData(null);
} else {
this.msgWarning(res.msg);
}
});
})
.catch(() => {
// this.$message({
// type: 'info',
// message: '刪除失敗'
// });
});
},
// 改变页面条数
handleSizeChange(val) {
this.page.pageSize = val;
this.sreachData(null);
},
// 切换页码
handleCurrentChange(val) {
this.page.curPage = val;
this.sreachData(null);
},
// 导出
exportBtn() {
let paramsData = {
...this.oldSreachFormData,
query: this.defQuery,
sort: this.sortOrder,
};
this.exportLoading = true;
downLoadXlsx("/icleartw/declare/export", paramsData, "提單表")
.then(() => {
this.$message.success("導出成功");
this.exportLoading = false;
})
.catch(() => {
this.exportLoading = false;
});
},
// 查看
viewDeclare(row) {
this.$refs.detailDrawerRef.openDrawer(row, "table");
},
// 下载附件
downloadFiles(row) {
this.$refs.detailDialogRef.openDialog(row);
},
// 编辑
editDeclare(row) {
this.$router
.push({
name: "declarationInput",
params: {
step: JSON.stringify(row.saveStep),
id: JSON.stringify(row.id),
},
})
.catch(() => {});
},
//重新编辑
reEditDeclare(row) {
this.$store.dispatch("AppLoading", true);
reedit(row.id)
.then((res) => {
if ((res.code = 200)) {
this.$router
.push({
name: "declarationInput",
params: {
step: 1,
id: JSON.stringify(res.data.id),
},
})
.catch(() => {});
} else {
$message.error(res.msg);
}
})
.catch(() => {})
.finally(() => {
this.$store.dispatch("AppLoading", false);
});
},
//文本域切换
consignmentCodeFocus() {
this.consignmentCodeRows = 5;
this.$nextTick(() => {
let inputInner = document.querySelector(
"#inputInner--deliveryNo"
).parentNode;
let inputOuter = document.querySelector("#inputOuter--deliveryNo");
inputInner.classList.add("consignmentCode-textarea");
document.querySelector("#inputInner--deliveryNo").focus();
setTimeout(() => {
inputOuter.classList.add("active");
inputOuter.classList.add("activeBorder");
}, 100);
});
},
consignmentCodeBlur(val) {
this.consignmentCodeRows = 1;
this.$nextTick(() => {
let inputInner = document.querySelector(
"#inputInner--deliveryNo"
).parentNode;
inputInner.classList.remove("consignmentCode-textarea");
});
this.sreachFormData.consignmentCode = val.target.value.split("\n");
let arr = [];
this.sreachFormData.consignmentCode.forEach((item) => {
if (item != "" && item != null) {
arr.push(item);
}
});
this.sreachFormData.consignmentCode = arr;
}, // 查看pdf
openViewPdf(file) {
file.findLoading = true;
downLoadViewPdf(
"/icleartw/cusFile/previewFile",
{ fileId: file.id },
file.name + file.type
)
.then(() => {})
.finally(() => {
file.findLoading = false;
});
},
},
};
</script>
<style>
.el-dropdown-menu__item.is-disabled {
color: #bbb;
}
</style>
<style lang="scss" scoped>
@import "@/assets/styles/variables.scss";
.search-wrap {
height: calc(100% - 28px);
margin: 12px 12px 16px 16px;
background-color: #fff;
padding: 20px;
.search-box {
margin-bottom: 12px;
position: relative;
.export-btn {
position: absolute;
right: 12px;
top: 0;
}
}
::v-deep .el-table .bgc-row {
background: #f2f2f2;
}
.el-pagination {
text-align: right;
margin-top: 10px;
::v-deep .el-input.is-focus .el-input__inner {
border: 1px solid $fedexColor;
}
::v-deep .el-input .el-input__inner:hover {
border: 1px solid $fedexColor;
}
::v-deep .el-input__inner:focus {
border: 1px solid $fedexColor;
}
::v-deep .el-pager li.active {
color: $fedexColor;
}
::v-deep .el-pager li:hover {
color: $fedexColor;
}
}
// .el-table__body-wrapper {
// overflow: auto;
// }
}
.search-btn {
::v-deep .el-button {
border: 1px solid #cccccc;
height: 50px;
width: 90px;
.el-icon-search {
color: #cccccc;
font-size: 20px;
}
}
.el-button:hover,
.el-button:focus {
background: #f3f1f1;
}
}
.texttareaTip {
position: absolute;
top: 50%;
right: 20px;
transform: translate(0, -50%);
z-index: 10;
}
.consignmentCode-textarea {
position: absolute;
top: 25px;
left: 1px;
z-index: 10;
min-height: 170px !important;
border: 2px solid $fedexBorder;
background-color: $fedexTablebackgroundColor;
transition: all 0.2s ease;
}
.queryTable {
::v-deep .cell {
text-align: center;
white-space: pre-line;
}
}
</style>