@things-factory/operato-wms 4.3.414 → 4.3.415
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/pages/manifest/create-loading-manifest.js +463 -37
- package/client/pages/manifest/existing-manifest-list.js +270 -0
- package/client/pages/manifest/generate-manifest-popup.js +199 -0
- package/client/pages/manifest/loading-manifest-detail.js +141 -50
- package/client/pages/manifest/loading-manifest-list.js +13 -3
- package/client/pages/manifest/select-manifest-popup.js +157 -0
- package/client/pages/order/release-order/tracking-information-popup.js +10 -3
- package/client/route.js +3 -0
- package/helps/release-note.md +4 -12
- package/package.json +4 -4
- package/things-factory.config.js +4 -0
- package/translations/en.json +16 -1
- package/translations/ko.json +14 -0
- package/translations/ms.json +14 -0
- package/translations/zh.json +14 -0
|
@@ -1,14 +1,32 @@
|
|
|
1
1
|
import '@things-factory/grist-ui'
|
|
2
2
|
import '@things-factory/barcode-ui'
|
|
3
|
+
import './generate-manifest-popup'
|
|
4
|
+
import './select-manifest-popup'
|
|
5
|
+
import '@things-factory/import-ui/client/components/import-pop-up'
|
|
3
6
|
|
|
4
7
|
import gql from 'graphql-tag'
|
|
5
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
css,
|
|
10
|
+
html
|
|
11
|
+
} from 'lit-element'
|
|
6
12
|
|
|
7
13
|
import { MultiColumnFormStyles } from '@things-factory/form-ui'
|
|
8
|
-
import {
|
|
9
|
-
|
|
14
|
+
import {
|
|
15
|
+
i18next,
|
|
16
|
+
localize
|
|
17
|
+
} from '@things-factory/i18n-base'
|
|
18
|
+
import { openPopup } from '@things-factory/layout-base'
|
|
19
|
+
import {
|
|
20
|
+
client,
|
|
21
|
+
CustomAlert,
|
|
22
|
+
navigate,
|
|
23
|
+
PageView
|
|
24
|
+
} from '@things-factory/shell'
|
|
10
25
|
import { CommonButtonStyles } from '@things-factory/styles'
|
|
11
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
isMobileDevice,
|
|
28
|
+
sleep
|
|
29
|
+
} from '@things-factory/utils'
|
|
12
30
|
|
|
13
31
|
import { ORDER_STATUS } from '../constants'
|
|
14
32
|
|
|
@@ -22,6 +40,7 @@ class CreateLoadingManifest extends localize(i18next)(PageView) {
|
|
|
22
40
|
flex-direction: column;
|
|
23
41
|
overflow-x: auto;
|
|
24
42
|
}
|
|
43
|
+
|
|
25
44
|
.container {
|
|
26
45
|
flex: 1;
|
|
27
46
|
display: flex;
|
|
@@ -58,6 +77,17 @@ class CreateLoadingManifest extends localize(i18next)(PageView) {
|
|
|
58
77
|
font-size: var(--grist-title-icon-size);
|
|
59
78
|
color: var(--grist-title-icon-color);
|
|
60
79
|
}
|
|
80
|
+
.box {
|
|
81
|
+
display: flex;
|
|
82
|
+
flex-direction: column;
|
|
83
|
+
color: rgb(58, 88, 119);
|
|
84
|
+
margin-left: 30px;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.box h4 {
|
|
88
|
+
margin-top: 5px;
|
|
89
|
+
margin-bottom: 5px;
|
|
90
|
+
}
|
|
61
91
|
|
|
62
92
|
h2 + data-grist {
|
|
63
93
|
padding-top: var(--grist-title-with-grid-padding);
|
|
@@ -70,7 +100,13 @@ class CreateLoadingManifest extends localize(i18next)(PageView) {
|
|
|
70
100
|
return {
|
|
71
101
|
shippingData: Object,
|
|
72
102
|
shippingGristConfig: Object,
|
|
73
|
-
|
|
103
|
+
name: String,
|
|
104
|
+
shippingProvider: String,
|
|
105
|
+
id: String,
|
|
106
|
+
audioCtx: Object,
|
|
107
|
+
selectedManifest: Object,
|
|
108
|
+
_removePackages: Array,
|
|
109
|
+
scannedNo: Number
|
|
74
110
|
}
|
|
75
111
|
}
|
|
76
112
|
|
|
@@ -79,11 +115,27 @@ class CreateLoadingManifest extends localize(i18next)(PageView) {
|
|
|
79
115
|
title: i18next.t('title.manifest'),
|
|
80
116
|
actions: [
|
|
81
117
|
{
|
|
82
|
-
title: i18next.t('button.
|
|
83
|
-
action:
|
|
118
|
+
title: i18next.t('button.existing_manifest'),
|
|
119
|
+
action: async () => {
|
|
120
|
+
this._clearManifestInfo()
|
|
121
|
+
await sleep(1010)
|
|
122
|
+
navigate('existing_manifest_list')
|
|
123
|
+
},
|
|
124
|
+
...CommonButtonStyles.submit
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
title: i18next.t('button.create_new_manifest'),
|
|
128
|
+
action: this._popupGenerateManifest.bind(this),
|
|
84
129
|
...CommonButtonStyles.submit
|
|
85
130
|
}
|
|
86
|
-
]
|
|
131
|
+
],
|
|
132
|
+
importable: {
|
|
133
|
+
handler: this.importableData.bind(this)
|
|
134
|
+
},
|
|
135
|
+
exportable: {
|
|
136
|
+
name: i18next.t('title.manifest'),
|
|
137
|
+
data: this.exportableData.bind(this)
|
|
138
|
+
}
|
|
87
139
|
}
|
|
88
140
|
}
|
|
89
141
|
|
|
@@ -98,6 +150,10 @@ class CreateLoadingManifest extends localize(i18next)(PageView) {
|
|
|
98
150
|
custom-input
|
|
99
151
|
@keypress="${e => {
|
|
100
152
|
if (e.keyCode === 13) {
|
|
153
|
+
if (!this.selectedManifest.name) {
|
|
154
|
+
this._showToast({ message: i18next.t('text.please_select_an_existing_manifest_or_create_a_new_one') })
|
|
155
|
+
return
|
|
156
|
+
}
|
|
101
157
|
e.preventDefault()
|
|
102
158
|
if (this.trackingNoInput.value) {
|
|
103
159
|
this._fetchManifestItems(this.trackingNoInput.value)
|
|
@@ -108,6 +164,12 @@ class CreateLoadingManifest extends localize(i18next)(PageView) {
|
|
|
108
164
|
</fieldset>
|
|
109
165
|
</form>
|
|
110
166
|
|
|
167
|
+
<div class="box">
|
|
168
|
+
<h4>${i18next.t('label.manifest_no')} : ${this.selectedManifest?.name}</h4>
|
|
169
|
+
<h4>${i18next.t('label.courier')} : ${this.selectedManifest?.shippingProvider}</h4>
|
|
170
|
+
<h4>${i18next.t('label.scanned')} : ${this.scannedNo}</h4>
|
|
171
|
+
</div>
|
|
172
|
+
|
|
111
173
|
<div class="container">
|
|
112
174
|
<div class="grist">
|
|
113
175
|
<h2><mwc-icon>list_alt</mwc-icon>${i18next.t('title.manifest_items')}</h2>
|
|
@@ -126,6 +188,9 @@ class CreateLoadingManifest extends localize(i18next)(PageView) {
|
|
|
126
188
|
super()
|
|
127
189
|
this.shippingData = { records: [] }
|
|
128
190
|
this.audioCtx = new (window.AudioContext || window.webkitAudioContext)()
|
|
191
|
+
this._removePackages = []
|
|
192
|
+
this.scannedNo = 0
|
|
193
|
+
this.shippingGristConfig = {}
|
|
129
194
|
}
|
|
130
195
|
|
|
131
196
|
get shippingGrist() {
|
|
@@ -140,13 +205,30 @@ class CreateLoadingManifest extends localize(i18next)(PageView) {
|
|
|
140
205
|
return this.shadowRoot.querySelector('barcode-scanable-input[name=trackingNo]')?.shadowRoot.querySelector('input')
|
|
141
206
|
}
|
|
142
207
|
|
|
208
|
+
get columns() {
|
|
209
|
+
return [...this.shippingGristConfig.columns, ...this.importGristConfig.columns]
|
|
210
|
+
}
|
|
211
|
+
|
|
143
212
|
pageUpdated(changes, lifecycle, before) {
|
|
213
|
+
if (lifecycle?.params) {
|
|
214
|
+
const manifestInfo = {
|
|
215
|
+
name: lifecycle.params.name,
|
|
216
|
+
shippingProvider: lifecycle.params.shippingProvider,
|
|
217
|
+
id: lifecycle.params.id
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
this.selectedManifest = manifestInfo
|
|
221
|
+
this._clearManifestInfo()
|
|
222
|
+
}
|
|
223
|
+
|
|
144
224
|
if (this.active) {
|
|
145
225
|
this._focusOnTrackingNoInput()
|
|
146
226
|
}
|
|
147
227
|
}
|
|
148
228
|
|
|
149
229
|
pageInitialized() {
|
|
230
|
+
this._clearManifestInfo()
|
|
231
|
+
|
|
150
232
|
this.shippingGristConfig = {
|
|
151
233
|
list: { fields: ['refNo', 'trackingNo', 'transporter'] },
|
|
152
234
|
pagination: { infinite: true },
|
|
@@ -158,9 +240,14 @@ class CreateLoadingManifest extends localize(i18next)(PageView) {
|
|
|
158
240
|
icon: 'close',
|
|
159
241
|
handlers: {
|
|
160
242
|
click: (columns, data, column, record, rowIndex) => {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
243
|
+
if (this.shippingData.records.length > 0 && record.name) {
|
|
244
|
+
const newData = data.records.filter((_, idx) => idx !== rowIndex)
|
|
245
|
+
this.shippingData = { ...this.shippingData, records: newData }
|
|
246
|
+
this._removePackages.push(record.name)
|
|
247
|
+
this.scannedNo -= 1
|
|
248
|
+
this._updateManifestDetails()
|
|
249
|
+
this.shippingGrist.dirtyData.records = newData
|
|
250
|
+
}
|
|
164
251
|
}
|
|
165
252
|
}
|
|
166
253
|
},
|
|
@@ -176,6 +263,7 @@ class CreateLoadingManifest extends localize(i18next)(PageView) {
|
|
|
176
263
|
name: 'trackingNo',
|
|
177
264
|
label: true,
|
|
178
265
|
header: i18next.t('field.tracking_no'),
|
|
266
|
+
imex: { header: i18next.t('field.tracking_no'), key: 'trackingNo', width: 30, type: 'string' },
|
|
179
267
|
width: 200
|
|
180
268
|
},
|
|
181
269
|
{
|
|
@@ -183,6 +271,7 @@ class CreateLoadingManifest extends localize(i18next)(PageView) {
|
|
|
183
271
|
name: 'transporter',
|
|
184
272
|
label: true,
|
|
185
273
|
header: i18next.t('field.transporter'),
|
|
274
|
+
imex: { header: i18next.t('field.transporter'), key: 'transporter', width: 30, type: 'string' },
|
|
186
275
|
width: 200
|
|
187
276
|
},
|
|
188
277
|
{
|
|
@@ -201,6 +290,38 @@ class CreateLoadingManifest extends localize(i18next)(PageView) {
|
|
|
201
290
|
}
|
|
202
291
|
]
|
|
203
292
|
}
|
|
293
|
+
|
|
294
|
+
this.importGristConfig = {
|
|
295
|
+
list: { fields: ['refNo', 'trackingNo', 'transporter'] },
|
|
296
|
+
pagination: { infinite: true },
|
|
297
|
+
columns: [
|
|
298
|
+
{ type: 'gutter', gutterName: 'sequence' },
|
|
299
|
+
{
|
|
300
|
+
type: 'string',
|
|
301
|
+
name: 'trackingNo',
|
|
302
|
+
label: true,
|
|
303
|
+
header: i18next.t('field.tracking_no'),
|
|
304
|
+
imex: { header: i18next.t('field.tracking_no'), key: 'trackingNo', width: 30, type: 'string' },
|
|
305
|
+
width: 200
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
type: 'string',
|
|
309
|
+
name: 'transporter',
|
|
310
|
+
label: true,
|
|
311
|
+
header: i18next.t('field.transporter'),
|
|
312
|
+
imex: { header: i18next.t('field.transporter'), key: 'transporter', width: 30, type: 'string' },
|
|
313
|
+
width: 200
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
type: 'string',
|
|
317
|
+
name: 'remark',
|
|
318
|
+
label: true,
|
|
319
|
+
header: i18next.t('field.remark'),
|
|
320
|
+
imex: { header: i18next.t('field.remark'), key: 'remarks', width: 100, type: 'string' },
|
|
321
|
+
width: 300
|
|
322
|
+
}
|
|
323
|
+
]
|
|
324
|
+
}
|
|
204
325
|
}
|
|
205
326
|
|
|
206
327
|
async _fetchManifestItems() {
|
|
@@ -234,13 +355,28 @@ class CreateLoadingManifest extends localize(i18next)(PageView) {
|
|
|
234
355
|
})
|
|
235
356
|
if (!response.errors) {
|
|
236
357
|
const orderPackage = response.data.orderPackage
|
|
358
|
+
const manifestTransport = this.selectedManifest.shippingProvider
|
|
237
359
|
|
|
238
360
|
if (orderPackage) {
|
|
239
361
|
let manifestItems = this.shippingData.records || []
|
|
240
362
|
|
|
241
363
|
if (manifestItems.some(itm => itm.trackingNo == orderPackage.trackingNo)) {
|
|
242
364
|
this._playSound('error')
|
|
243
|
-
|
|
365
|
+
let result = await CustomAlert({
|
|
366
|
+
type: 'warning',
|
|
367
|
+
title: i18next.t('title.failed'),
|
|
368
|
+
text: [
|
|
369
|
+
i18next.t('text.tracking_no_duplicated') +
|
|
370
|
+
'\n' +
|
|
371
|
+
i18next.t('text.please_take_necessary_action_to_prevent_any_potential_issues')
|
|
372
|
+
],
|
|
373
|
+
confirmButton: { text: i18next.t('button.back') }
|
|
374
|
+
})
|
|
375
|
+
if (result.value) return
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
if (manifestTransport?.toLowerCase() !== orderPackage.transporter?.toLowerCase()) {
|
|
379
|
+
this._popupSelectManifest(orderPackage)
|
|
244
380
|
return
|
|
245
381
|
}
|
|
246
382
|
|
|
@@ -266,7 +402,10 @@ class CreateLoadingManifest extends localize(i18next)(PageView) {
|
|
|
266
402
|
|
|
267
403
|
if (orderPackage.manifestedAt != null) {
|
|
268
404
|
this._playSound('error')
|
|
269
|
-
this._showToast({
|
|
405
|
+
this._showToast({
|
|
406
|
+
message: i18next.t('text.tracking_no_already_exist_in_other_manifest_list'),
|
|
407
|
+
duration: 3000
|
|
408
|
+
})
|
|
270
409
|
return
|
|
271
410
|
}
|
|
272
411
|
|
|
@@ -277,6 +416,10 @@ class CreateLoadingManifest extends localize(i18next)(PageView) {
|
|
|
277
416
|
orderNo: orderPackage.releaseGood.refNo
|
|
278
417
|
})
|
|
279
418
|
this.shippingData = { records: manifestItems }
|
|
419
|
+
if (this.trackingNoInput.value) {
|
|
420
|
+
this.scannedNo += 1
|
|
421
|
+
}
|
|
422
|
+
this._addTrackingNo()
|
|
280
423
|
|
|
281
424
|
this._playSound()
|
|
282
425
|
} else {
|
|
@@ -285,6 +428,7 @@ class CreateLoadingManifest extends localize(i18next)(PageView) {
|
|
|
285
428
|
}
|
|
286
429
|
|
|
287
430
|
this._clearTrackingNoInput()
|
|
431
|
+
this.pageUpdated()
|
|
288
432
|
} else {
|
|
289
433
|
this._playSound('error')
|
|
290
434
|
}
|
|
@@ -294,29 +438,98 @@ class CreateLoadingManifest extends localize(i18next)(PageView) {
|
|
|
294
438
|
}
|
|
295
439
|
}
|
|
296
440
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
441
|
+
_focusOnTrackingNoInput() {
|
|
442
|
+
setTimeout(() => this.trackingNoInput.focus(), 50)
|
|
443
|
+
}
|
|
300
444
|
|
|
301
|
-
|
|
302
|
-
|
|
445
|
+
async _addTrackingNo() {
|
|
446
|
+
const response = await client.mutate({
|
|
447
|
+
mutation: gql`
|
|
448
|
+
mutation addTrackingNo($manifestId: String, $trackingNo: String, $shippingProvider: String) {
|
|
449
|
+
addTrackingNo(manifestId: $manifestId, trackingNo: $trackingNo, shippingProvider: $shippingProvider)
|
|
450
|
+
}
|
|
451
|
+
`,
|
|
452
|
+
variables: {
|
|
453
|
+
manifestId: this.selectedManifest.id,
|
|
454
|
+
trackingNo: this.trackingNoInput.value.trim(),
|
|
455
|
+
shippingProvider: this.selectedManifest.shippingProvider
|
|
456
|
+
}
|
|
457
|
+
})
|
|
303
458
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
459
|
+
if (!response.errors) {
|
|
460
|
+
this.trackingNoInput.value = ''
|
|
461
|
+
this._focusOnTrackingNoInput()
|
|
462
|
+
} else {
|
|
463
|
+
let errorMessage = response.errors[0].message
|
|
464
|
+
if (errorMessage.includes('amp;')) {
|
|
465
|
+
response.errors[0].message = errorMessage.replace('amp;', '')
|
|
466
|
+
this._showToast({ message: response.errors[0].message })
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
312
470
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
471
|
+
_popupSelectManifest(orderPackage) {
|
|
472
|
+
openPopup(
|
|
473
|
+
html`
|
|
474
|
+
<select-manifest-popup
|
|
475
|
+
.shippingCourier="${orderPackage.transporter}"
|
|
476
|
+
@manifestSelected="${e => {
|
|
477
|
+
this._popupGenerateManifest(true)
|
|
478
|
+
}}"
|
|
479
|
+
style="height:200px;"
|
|
480
|
+
>
|
|
481
|
+
</select-manifest-popup>
|
|
482
|
+
`,
|
|
483
|
+
{
|
|
484
|
+
backdrop: true,
|
|
485
|
+
size: 'small',
|
|
486
|
+
title: i18next.t('title.new_courier')
|
|
487
|
+
}
|
|
488
|
+
)
|
|
489
|
+
|
|
490
|
+
this.pageUpdated()
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
async _popupGenerateManifest(popupSelect) {
|
|
494
|
+
let selectManifest = popupSelect
|
|
495
|
+
await sleep(1010)
|
|
496
|
+
openPopup(
|
|
497
|
+
html`
|
|
498
|
+
<generate-manifest-popup
|
|
499
|
+
.isManifestNew="${selectManifest}"
|
|
500
|
+
@manifestGenerated="${async e => {
|
|
501
|
+
this.selectedManifest = e.detail.generatedManifest
|
|
502
|
+
this.pageUpdated()
|
|
503
|
+
}}"
|
|
504
|
+
style="height:120px;"
|
|
505
|
+
>
|
|
506
|
+
</generate-manifest-popup>
|
|
507
|
+
`,
|
|
508
|
+
{
|
|
509
|
+
backdrop: true,
|
|
510
|
+
size: 'small',
|
|
511
|
+
title: i18next.t('title.create_new_manifest')
|
|
317
512
|
}
|
|
513
|
+
)
|
|
514
|
+
|
|
515
|
+
this._clearPage()
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
async exportableData() {
|
|
519
|
+
try {
|
|
520
|
+
let data = []
|
|
521
|
+
|
|
522
|
+
var headerSetting = [
|
|
523
|
+
...this.shippingGristConfig.columns
|
|
524
|
+
.filter(column => column.type !== 'gutter' && column.name !== undefined && column.imex !== undefined)
|
|
525
|
+
.map(column => {
|
|
526
|
+
return column.imex
|
|
527
|
+
})
|
|
528
|
+
]
|
|
529
|
+
|
|
530
|
+
return { header: headerSetting, data: data }
|
|
318
531
|
} catch (e) {
|
|
319
|
-
this.
|
|
532
|
+
this.showToast(e)
|
|
320
533
|
}
|
|
321
534
|
}
|
|
322
535
|
|
|
@@ -334,10 +547,214 @@ class CreateLoadingManifest extends localize(i18next)(PageView) {
|
|
|
334
547
|
})
|
|
335
548
|
}
|
|
336
549
|
|
|
337
|
-
|
|
338
|
-
if (!this.
|
|
339
|
-
|
|
340
|
-
|
|
550
|
+
async _updateManifestDetails() {
|
|
551
|
+
if ((!this._selectedStatus || this._selectedStatus == this._status) && this._removePackages?.length == 0) {
|
|
552
|
+
return
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
try {
|
|
556
|
+
const response = await client.mutate({
|
|
557
|
+
mutation: gql`
|
|
558
|
+
mutation updateManifest(
|
|
559
|
+
$manifestId: String
|
|
560
|
+
$status: String
|
|
561
|
+
$shippingProvider: String
|
|
562
|
+
$isPreventDeleteManifest: Boolean
|
|
563
|
+
$removePackages: [String!]
|
|
564
|
+
) {
|
|
565
|
+
updateManifest(
|
|
566
|
+
manifestId: $manifestId
|
|
567
|
+
status: $status
|
|
568
|
+
shippingProvider: $shippingProvider
|
|
569
|
+
isPreventDeleteManifest: $isPreventDeleteManifest
|
|
570
|
+
removePackages: $removePackages
|
|
571
|
+
)
|
|
572
|
+
}
|
|
573
|
+
`,
|
|
574
|
+
variables: {
|
|
575
|
+
manifestId: this.selectedManifest.id,
|
|
576
|
+
status: this._selectedStatus,
|
|
577
|
+
isPreventDeleteManifest: true,
|
|
578
|
+
removePackages: this._removePackages
|
|
579
|
+
}
|
|
580
|
+
})
|
|
581
|
+
|
|
582
|
+
if (!response.errors) {
|
|
583
|
+
this._showToast({ message: i18next.t('text.tracking_no_deleted') })
|
|
584
|
+
}
|
|
585
|
+
} catch (e) {
|
|
586
|
+
this._showToast(e)
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
importableData(records) {
|
|
591
|
+
if (!this.selectedManifest.name) {
|
|
592
|
+
this._showToast({ message: i18next.t('text.please_select_an_existing_manifest_or_create_a_new_one') })
|
|
593
|
+
return
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
let rows = {
|
|
597
|
+
selectable: { multiple: true }
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
setTimeout(() => {
|
|
601
|
+
openPopup(
|
|
602
|
+
html`
|
|
603
|
+
<import-pop-up
|
|
604
|
+
.records=${records}
|
|
605
|
+
.config=${{
|
|
606
|
+
rows,
|
|
607
|
+
columns: [...this.importGristConfig.columns.filter(column => column.imex !== undefined)]
|
|
608
|
+
}}
|
|
609
|
+
.importHandler="${this.importHandler.bind(this)}"
|
|
610
|
+
></import-pop-up>
|
|
611
|
+
`,
|
|
612
|
+
{
|
|
613
|
+
backdrop: true,
|
|
614
|
+
size: 'large',
|
|
615
|
+
title: i18next.t('title.import_manifest')
|
|
616
|
+
}
|
|
617
|
+
)
|
|
618
|
+
}, 500)
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
async importHandler(records) {
|
|
622
|
+
try {
|
|
623
|
+
const newRecord = await this._validateProducts(records)
|
|
624
|
+
let recordsWithRemarks
|
|
625
|
+
|
|
626
|
+
if (newRecord) {
|
|
627
|
+
recordsWithRemarks = newRecord
|
|
628
|
+
} else {
|
|
629
|
+
recordsWithRemarks = records
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
const hasRemarks = recordsWithRemarks.some(itm => itm.remark)
|
|
633
|
+
|
|
634
|
+
if (!hasRemarks) {
|
|
635
|
+
const response = await client.mutate({
|
|
636
|
+
mutation: gql`
|
|
637
|
+
mutation submitTrackingNos($patches: [ManifestItem!]!, $manifestId: String) {
|
|
638
|
+
submitTrackingNos(patches: $patches, manifestId: $manifestId) {
|
|
639
|
+
id
|
|
640
|
+
name
|
|
641
|
+
trackingNo
|
|
642
|
+
transporter
|
|
643
|
+
releaseGood {
|
|
644
|
+
id
|
|
645
|
+
name
|
|
646
|
+
refNo
|
|
647
|
+
status
|
|
648
|
+
}
|
|
649
|
+
bizplace {
|
|
650
|
+
id
|
|
651
|
+
name
|
|
652
|
+
}
|
|
653
|
+
status
|
|
654
|
+
manifestedAt
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
`,
|
|
658
|
+
variables: { patches: records, manifestId: this.selectedManifest.id }
|
|
659
|
+
})
|
|
660
|
+
|
|
661
|
+
let updatedRecords = response.data.submitTrackingNos.map(itm => {
|
|
662
|
+
return {
|
|
663
|
+
...itm,
|
|
664
|
+
bizplaceName: itm.bizplace.name,
|
|
665
|
+
refNo: itm.releaseGood.refNo
|
|
666
|
+
}
|
|
667
|
+
})
|
|
668
|
+
|
|
669
|
+
this.shippingData = {
|
|
670
|
+
records: [...this.shippingData.records, ...updatedRecords]
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
this.scannedNo = this.shippingData.records.length
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
history.back()
|
|
677
|
+
|
|
678
|
+
if (hasRemarks) {
|
|
679
|
+
this.importableData(recordsWithRemarks)
|
|
680
|
+
}
|
|
681
|
+
} catch (e) {
|
|
682
|
+
this._showToast(e)
|
|
683
|
+
history.back()
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
async _validateProducts(records = []) {
|
|
688
|
+
if (!records?.length) throw new Error(i18next.t('text.no_tracking_no'))
|
|
689
|
+
|
|
690
|
+
records.forEach(item => {
|
|
691
|
+
if (!item.trackingNo || !item.transporter) {
|
|
692
|
+
item.remark = 'Missing information'
|
|
693
|
+
}
|
|
694
|
+
})
|
|
695
|
+
|
|
696
|
+
const duplicatedTrackingNos = records.filter((item, index, array) => {
|
|
697
|
+
return array.findIndex(otherItem => otherItem.trackingNo === item.trackingNo) !== index
|
|
698
|
+
})
|
|
699
|
+
|
|
700
|
+
if (duplicatedTrackingNos?.length > 0) {
|
|
701
|
+
duplicatedTrackingNos.forEach(item => {
|
|
702
|
+
const index = records.findIndex(record => record.trackingNo === item.trackingNo)
|
|
703
|
+
if (index !== -1) {
|
|
704
|
+
records[index].remark = 'Tracking No duplicated'
|
|
705
|
+
}
|
|
706
|
+
})
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
const recordsWithoutRemark = records.filter(item => !item.remark)
|
|
710
|
+
const recordsWithRemark = records.filter(item => item.remark)
|
|
711
|
+
let response
|
|
712
|
+
|
|
713
|
+
if (recordsWithoutRemark.length > 0) {
|
|
714
|
+
response = await client.query({
|
|
715
|
+
query: gql`
|
|
716
|
+
query validateTrackingNo($patches: [ManifestItem!]!) {
|
|
717
|
+
validateTrackingNo(patches: $patches) {
|
|
718
|
+
cuFlag
|
|
719
|
+
trackingNo
|
|
720
|
+
transporter
|
|
721
|
+
remark
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
`,
|
|
725
|
+
variables: { patches: recordsWithoutRemark }
|
|
726
|
+
})
|
|
727
|
+
|
|
728
|
+
const existingOrderPackages = response.data.validateTrackingNo
|
|
729
|
+
|
|
730
|
+
const gristRecords = this.shippingGrist.data.records
|
|
731
|
+
|
|
732
|
+
existingOrderPackages.forEach(record => {
|
|
733
|
+
const matchingOrderPackage = existingOrderPackages.find(
|
|
734
|
+
orderPackage => orderPackage.trackingNo === record.trackingNo
|
|
735
|
+
)
|
|
736
|
+
|
|
737
|
+
if (gristRecords.some(gristRecord => gristRecord.trackingNo === record.trackingNo)) {
|
|
738
|
+
this._showToast({
|
|
739
|
+
message:
|
|
740
|
+
i18next.t('text.tracking_no_duplicated') +
|
|
741
|
+
'\n' +
|
|
742
|
+
i18next.t('text.please_take_necessary_action_to_prevent_any_potential_issues'),
|
|
743
|
+
duration: 3000
|
|
744
|
+
})
|
|
745
|
+
record.remark = 'Tracking No duplicated'
|
|
746
|
+
} else if (matchingOrderPackage?.manifest) {
|
|
747
|
+
record.remark = 'Tracking No exist in another manifest'
|
|
748
|
+
} else if (record.transporter.toLowerCase() !== this.selectedManifest.shippingProvider.toLowerCase()) {
|
|
749
|
+
record.remark = 'Tracking No not allowed in this manifest'
|
|
750
|
+
}
|
|
751
|
+
})
|
|
752
|
+
|
|
753
|
+
existingOrderPackages.push(...recordsWithRemark)
|
|
754
|
+
|
|
755
|
+
if (existingOrderPackages.some(item => item.remark)) {
|
|
756
|
+
return existingOrderPackages
|
|
757
|
+
}
|
|
341
758
|
}
|
|
342
759
|
}
|
|
343
760
|
|
|
@@ -356,15 +773,24 @@ class CreateLoadingManifest extends localize(i18next)(PageView) {
|
|
|
356
773
|
_clearPage() {
|
|
357
774
|
this._clearTrackingNoInput()
|
|
358
775
|
this.shippingData = { ...this.shippingData, records: [] }
|
|
776
|
+
this.scannedNo = 0
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
_clearManifestInfo() {
|
|
780
|
+
this.name = ''
|
|
781
|
+
this.shippingProvider = ''
|
|
782
|
+
this.id = ''
|
|
783
|
+
this.shippingData = { ...this.shippingData, records: [] }
|
|
784
|
+
this.scannedNo = 0
|
|
359
785
|
}
|
|
360
786
|
|
|
361
|
-
_showToast({ type, message }) {
|
|
787
|
+
_showToast({ type, message, duration }) {
|
|
362
788
|
document.dispatchEvent(
|
|
363
789
|
new CustomEvent('notify', {
|
|
364
790
|
detail: {
|
|
365
791
|
type,
|
|
366
792
|
message,
|
|
367
|
-
option: { timer:
|
|
793
|
+
option: { timer: duration ? duration : 1500 }
|
|
368
794
|
}
|
|
369
795
|
})
|
|
370
796
|
)
|