@things-factory/operato-wms 4.3.332 → 4.3.335
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/order/release-order/b2c/b2c-order-requests.js +17 -1
- package/client/pages/order/release-order/b2c/b2c-release-order-detail.js +2093 -0
- package/client/pages/order/release-order/b2c/create-b2c-release-order.js +2354 -0
- package/client/pages/outbound/packing-product.js +153 -9
- package/client/pages/outbound/worksheet-picking.js +88 -22
- package/client/pages/outbound/worksheet-sorting.js +47 -6
- package/client/route.js +8 -1
- package/package.json +5 -5
- package/things-factory.config.js +11 -5
- package/translations/en.json +18 -0
- package/translations/ko.json +24 -0
- package/translations/ms.json +24 -0
- package/translations/zh.json +24 -0
|
@@ -0,0 +1,2354 @@
|
|
|
1
|
+
import '@things-factory/biz-ui'
|
|
2
|
+
import '@things-factory/grist-ui'
|
|
3
|
+
import '@things-factory/import-ui'
|
|
4
|
+
import '@things-factory/component-ui'
|
|
5
|
+
import '../../../components/select-inventory-popup'
|
|
6
|
+
import '../../../components/select-product-popup'
|
|
7
|
+
|
|
8
|
+
import gql from 'graphql-tag'
|
|
9
|
+
import {
|
|
10
|
+
css,
|
|
11
|
+
html
|
|
12
|
+
} from 'lit-element'
|
|
13
|
+
|
|
14
|
+
import { getCodeByName } from '@things-factory/code-base'
|
|
15
|
+
import {
|
|
16
|
+
MultiColumnFormStyles,
|
|
17
|
+
SingleColumnFormStyles
|
|
18
|
+
} from '@things-factory/form-ui'
|
|
19
|
+
import {
|
|
20
|
+
i18next,
|
|
21
|
+
localize
|
|
22
|
+
} from '@things-factory/i18n-base'
|
|
23
|
+
import { openPopup } from '@things-factory/layout-base'
|
|
24
|
+
import {
|
|
25
|
+
client,
|
|
26
|
+
CustomAlert,
|
|
27
|
+
navigate,
|
|
28
|
+
PageView
|
|
29
|
+
} from '@things-factory/shell'
|
|
30
|
+
import { CommonButtonStyles } from '@things-factory/styles'
|
|
31
|
+
import { isMobileDevice } from '@things-factory/utils'
|
|
32
|
+
|
|
33
|
+
import { fetchSettingRule } from '../../../../fetch-setting-value'
|
|
34
|
+
import {
|
|
35
|
+
GROUP_TYPES,
|
|
36
|
+
ORDER_INVENTORY_STATUS,
|
|
37
|
+
ORDER_TYPES,
|
|
38
|
+
PICKING_STANDARD,
|
|
39
|
+
RO_TYPES
|
|
40
|
+
} from '../../../constants'
|
|
41
|
+
|
|
42
|
+
class CreateB2CReleaseOrder extends localize(i18next)(PageView) {
|
|
43
|
+
static get properties() {
|
|
44
|
+
return {
|
|
45
|
+
/* RO Form Fields */
|
|
46
|
+
_isLmd: Boolean,
|
|
47
|
+
_isLmdExists: Boolean,
|
|
48
|
+
_ownTransport: Boolean,
|
|
49
|
+
_warehouseTransport: Boolean,
|
|
50
|
+
_crossDocking: Boolean,
|
|
51
|
+
_exportOption: Boolean,
|
|
52
|
+
refNo: String,
|
|
53
|
+
refNo2: String,
|
|
54
|
+
refNo3: String,
|
|
55
|
+
releaseDate: Date,
|
|
56
|
+
collectionOrderNo: String,
|
|
57
|
+
_bizplaces: Object,
|
|
58
|
+
_bizplaceId: String,
|
|
59
|
+
_bizplaceName: String,
|
|
60
|
+
/* RO Form Fields */
|
|
61
|
+
|
|
62
|
+
_files: Array,
|
|
63
|
+
|
|
64
|
+
_bundleSettingData: Array,
|
|
65
|
+
_pickingStd: String,
|
|
66
|
+
_productBundleName: String,
|
|
67
|
+
_selectedInventories: Array,
|
|
68
|
+
inventoryGristConfig: Object,
|
|
69
|
+
inventoryData: Object,
|
|
70
|
+
bundleData: Object,
|
|
71
|
+
crossDockingProducts: Array,
|
|
72
|
+
_releaseByBundleQty: Number,
|
|
73
|
+
_releaseByBundleUomValue: Number,
|
|
74
|
+
_releaseOrderNo: String,
|
|
75
|
+
_ganNo: String,
|
|
76
|
+
_checkTransport: Boolean,
|
|
77
|
+
_packingOption: Boolean,
|
|
78
|
+
_enableTransportationServiceSetting: Boolean,
|
|
79
|
+
_selectedCP: String,
|
|
80
|
+
|
|
81
|
+
/* Shipping Form Field */
|
|
82
|
+
_contactPointId: String,
|
|
83
|
+
_contactPointName: String,
|
|
84
|
+
_companyName: String,
|
|
85
|
+
_attentionTo: String,
|
|
86
|
+
_deliveryPostCode: Array,
|
|
87
|
+
_deliveryState: String,
|
|
88
|
+
_deliveryCity: String,
|
|
89
|
+
_deliveryContact: String,
|
|
90
|
+
_deliveryFullAddress: String,
|
|
91
|
+
_selectedPostCode: String,
|
|
92
|
+
_selectedDeliveryCountry: String,
|
|
93
|
+
_selectedBillingCountry: String,
|
|
94
|
+
_billingCountry: String,
|
|
95
|
+
_billingPostCode: Array,
|
|
96
|
+
_billingState: String,
|
|
97
|
+
_billingCity: String,
|
|
98
|
+
_billingContact: String,
|
|
99
|
+
_billingFullAddress: String,
|
|
100
|
+
_selectedBillingPostCode: String,
|
|
101
|
+
_switchDeliveryCountryInput: Boolean,
|
|
102
|
+
_switchBillingCountryInput: Boolean,
|
|
103
|
+
_allCountry: Array,
|
|
104
|
+
_containerClosureDate: Date,
|
|
105
|
+
_recallToggle: Boolean,
|
|
106
|
+
_savedStrategy: String,
|
|
107
|
+
|
|
108
|
+
// refractor
|
|
109
|
+
_contactPointInfo: Object,
|
|
110
|
+
|
|
111
|
+
/* Tab Toggle*/
|
|
112
|
+
_showReleasedOrderInfo: Boolean,
|
|
113
|
+
_showShippingInfo: Boolean,
|
|
114
|
+
_disableBillingAddress: Boolean,
|
|
115
|
+
_showExportInfo: Boolean,
|
|
116
|
+
|
|
117
|
+
// Type
|
|
118
|
+
_selectBy: String
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
static get styles() {
|
|
123
|
+
return [
|
|
124
|
+
MultiColumnFormStyles,
|
|
125
|
+
SingleColumnFormStyles,
|
|
126
|
+
css`
|
|
127
|
+
:host {
|
|
128
|
+
display: flex;
|
|
129
|
+
flex-direction: column;
|
|
130
|
+
overflow-x: auto;
|
|
131
|
+
}
|
|
132
|
+
.container {
|
|
133
|
+
flex: 1;
|
|
134
|
+
display: flex;
|
|
135
|
+
overflow-y: auto;
|
|
136
|
+
}
|
|
137
|
+
.picking-std-container {
|
|
138
|
+
margin-top: 0px;
|
|
139
|
+
}
|
|
140
|
+
[options-wrap] * {
|
|
141
|
+
vertical-align: middle;
|
|
142
|
+
}
|
|
143
|
+
[options-wrap] input[type='checkbox'] {
|
|
144
|
+
left: 0;
|
|
145
|
+
}
|
|
146
|
+
[options-wrap] input[type='checkbox'] + label {
|
|
147
|
+
margin-right: 20px;
|
|
148
|
+
padding-left: 0;
|
|
149
|
+
}
|
|
150
|
+
[title] {
|
|
151
|
+
margin-top: -5px;
|
|
152
|
+
margin-bottom: -5px;
|
|
153
|
+
}
|
|
154
|
+
[attachment-wrap] {
|
|
155
|
+
display: flex;
|
|
156
|
+
flex-direction: row;
|
|
157
|
+
justify-content: center;
|
|
158
|
+
grid-column: span 24;
|
|
159
|
+
}
|
|
160
|
+
[attachment-wrap] label {
|
|
161
|
+
width: 8%;
|
|
162
|
+
}
|
|
163
|
+
[attachment-wrap] file-uploader {
|
|
164
|
+
flex: 1;
|
|
165
|
+
margin: 0 var(--margin-wide) 0 var(--margin-narrow);
|
|
166
|
+
}
|
|
167
|
+
.grist {
|
|
168
|
+
background-color: var(--main-section-background-color);
|
|
169
|
+
display: flex;
|
|
170
|
+
flex-direction: column;
|
|
171
|
+
flex: 1;
|
|
172
|
+
overflow-y: auto;
|
|
173
|
+
}
|
|
174
|
+
data-grist {
|
|
175
|
+
overflow-y: hidden;
|
|
176
|
+
flex: 1;
|
|
177
|
+
}
|
|
178
|
+
h2 {
|
|
179
|
+
padding: var(--subtitle-padding);
|
|
180
|
+
font: var(--subtitle-font);
|
|
181
|
+
color: var(--subtitle-text-color);
|
|
182
|
+
border-bottom: var(--subtitle-border-bottom);
|
|
183
|
+
}
|
|
184
|
+
.grist h2 {
|
|
185
|
+
margin: var(--grist-title-margin);
|
|
186
|
+
border: var(--grist-title-border);
|
|
187
|
+
font: var(--grist-title-font);
|
|
188
|
+
color: var(--secondary-color);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.grist h2 mwc-icon {
|
|
192
|
+
vertical-align: middle;
|
|
193
|
+
margin: var(--grist-title-icon-margin);
|
|
194
|
+
font-size: var(--grist-title-icon-size);
|
|
195
|
+
color: var(--grist-title-icon-color);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
h2 + data-grist {
|
|
199
|
+
padding-top: var(--grist-title-with-grid-padding);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.summary {
|
|
203
|
+
background-color: var(--main-section-background-color);
|
|
204
|
+
display: flex;
|
|
205
|
+
flex-direction: column;
|
|
206
|
+
overflow-y: auto;
|
|
207
|
+
align-items: flex-end;
|
|
208
|
+
padding: var(--data-list-item-padding);
|
|
209
|
+
display: grid;
|
|
210
|
+
font-size: 14px;
|
|
211
|
+
color: #394e64;
|
|
212
|
+
grid-template-columns: repeat(2, 1fr);
|
|
213
|
+
grid-auto-rows: minmax(24px, auto);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.label-remindContainerDeparture {
|
|
217
|
+
margin-left: 20px;
|
|
218
|
+
width: 50%;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
[hidden] {
|
|
222
|
+
display: none;
|
|
223
|
+
}
|
|
224
|
+
@media screen and (max-width: 460px) {
|
|
225
|
+
[attachment-wrap] {
|
|
226
|
+
grid-column: span 12;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
@media screen and (min-width: 1201px) and (max-width: 2000px) {
|
|
230
|
+
[attachment-wrap] {
|
|
231
|
+
grid-column: span 36;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
@media screen and (min-width: 2001px) {
|
|
235
|
+
[attachment-wrap] {
|
|
236
|
+
grid-column: span 48;
|
|
237
|
+
}
|
|
238
|
+
[attachment-wrap] label {
|
|
239
|
+
width: 6%;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.section-header {
|
|
244
|
+
grid-column: span 36 / auto !important;
|
|
245
|
+
text-align: left !important;
|
|
246
|
+
margin-top: 10px !important;
|
|
247
|
+
font-weight: 600 !important;
|
|
248
|
+
}
|
|
249
|
+
.quick-find-content-container {
|
|
250
|
+
margin: 0 15px;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
@media screen and (max-width: 480px) {
|
|
254
|
+
.section-header {
|
|
255
|
+
grid-column: span 12 / auto !important;
|
|
256
|
+
}
|
|
257
|
+
.quick-find-content-container {
|
|
258
|
+
margin: 0;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
`
|
|
262
|
+
]
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
get context() {
|
|
266
|
+
return {
|
|
267
|
+
title: i18next.t('title.create_release_order'),
|
|
268
|
+
actions: [
|
|
269
|
+
{
|
|
270
|
+
title: i18next.t('button.submit'),
|
|
271
|
+
action: this._generateReleaseOrder.bind(this),
|
|
272
|
+
...CommonButtonStyles.submit
|
|
273
|
+
}
|
|
274
|
+
],
|
|
275
|
+
exportable: {
|
|
276
|
+
name: i18next.t('title.create_release_order'),
|
|
277
|
+
data: this._exportableData.bind(this)
|
|
278
|
+
},
|
|
279
|
+
importable: {
|
|
280
|
+
handler: this._importableData.bind(this)
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
render() {
|
|
286
|
+
const RELEASE_ORDER_TABS = {
|
|
287
|
+
RELEASE_ORDER_INFO: i18next.t('label.order'),
|
|
288
|
+
SHIPPING_INFO: i18next.t('label.shipment')
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
const orderSet = {
|
|
292
|
+
[RELEASE_ORDER_TABS.RELEASE_ORDER_INFO]: {},
|
|
293
|
+
[RELEASE_ORDER_TABS.SHIPPING_INFO]: {}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
return html`
|
|
297
|
+
<div class="quick-find-content-container" >
|
|
298
|
+
<quick-find-content
|
|
299
|
+
id="order-items-list"
|
|
300
|
+
name="quickFindContent"
|
|
301
|
+
.data="${orderSet}"
|
|
302
|
+
@tabChanged="${e => {
|
|
303
|
+
this._tabChange(e.detail.currentTabKey)
|
|
304
|
+
}}"
|
|
305
|
+
></quick-find-content>
|
|
306
|
+
</div>
|
|
307
|
+
|
|
308
|
+
<form name="releaseOrder" class="multi-column-form" autocomplete="off" ?hidden="${this._showReleasedOrderInfo}">
|
|
309
|
+
<fieldset>
|
|
310
|
+
<legend>${i18next.t('title.release_order')}</legend>
|
|
311
|
+
|
|
312
|
+
<label>${i18next.t('label.options')}</label>
|
|
313
|
+
<div options-wrap>
|
|
314
|
+
<input
|
|
315
|
+
id="lmd"
|
|
316
|
+
type="checkbox"
|
|
317
|
+
name="lmd"
|
|
318
|
+
?checked="${this._isLmd}"
|
|
319
|
+
?disabled="${!this._isLmdExists}"
|
|
320
|
+
@change="${e => {
|
|
321
|
+
this._isLmd = e.currentTarget.checked
|
|
322
|
+
}}"
|
|
323
|
+
/>
|
|
324
|
+
<label for="lmd" ?hidden="${this._importedOrder}">${i18next.t('label.lmd')}</label>
|
|
325
|
+
</div>
|
|
326
|
+
|
|
327
|
+
<label>${i18next.t('label.company')}</label>
|
|
328
|
+
<input type="hidden" name="bizplaceId" value="${this._bizplaceId}" />
|
|
329
|
+
<input
|
|
330
|
+
type="text"
|
|
331
|
+
name="bizplaceName"
|
|
332
|
+
value="${this._bizplaceName}"
|
|
333
|
+
@click="${this._openBizplacesSelector.bind(this)}"
|
|
334
|
+
/>
|
|
335
|
+
|
|
336
|
+
<label>${i18next.t('label.ref_no')}</label>
|
|
337
|
+
<input name="refNo" .value="${this.refNo}"/>
|
|
338
|
+
|
|
339
|
+
<label>${i18next.t('label.ref_no_2')}</label>
|
|
340
|
+
<input name="refNo2" .value="${this.refNo2}" />
|
|
341
|
+
|
|
342
|
+
<label>${i18next.t('label.ref_no_3')}</label>
|
|
343
|
+
<input name="refNo3" .value="${this.refNo3}" />
|
|
344
|
+
|
|
345
|
+
<label>${i18next.t('label.release_date')}</label>
|
|
346
|
+
<input
|
|
347
|
+
name="releaseDate"
|
|
348
|
+
type="date"
|
|
349
|
+
min="${this._getStdDate()}"
|
|
350
|
+
.value="${this.releaseDate}"
|
|
351
|
+
required
|
|
352
|
+
?disabled="${this._crossDocking}"
|
|
353
|
+
|
|
354
|
+
@change="${this._validateDate}"
|
|
355
|
+
/>
|
|
356
|
+
${
|
|
357
|
+
this._crossDocking
|
|
358
|
+
? html`
|
|
359
|
+
<label for="ganNo">${i18next.t('label.arrival_notice')}</label>
|
|
360
|
+
<input readonly name="ganNo" value="${this._ganNo}" />
|
|
361
|
+
`
|
|
362
|
+
: ''
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
<div attachment-wrap>
|
|
366
|
+
<label>${i18next.t('label.invoice')}</label>
|
|
367
|
+
<file-uploader
|
|
368
|
+
class="align-file-uploader"
|
|
369
|
+
name="attachments"
|
|
370
|
+
id="uploadInvoice"
|
|
371
|
+
label="${i18next.t('label.select_file')}"
|
|
372
|
+
accept="*"
|
|
373
|
+
multiple="true"
|
|
374
|
+
|
|
375
|
+
custom-input
|
|
376
|
+
></file-uploader>
|
|
377
|
+
</div>
|
|
378
|
+
|
|
379
|
+
<div attachment-wrap>
|
|
380
|
+
<label ?hidden="${this._isLmd}">${i18next.t('label.awb')}</label>
|
|
381
|
+
<file-uploader
|
|
382
|
+
class="align-file-uploader"
|
|
383
|
+
name="attachments"
|
|
384
|
+
id="uploadAwb"
|
|
385
|
+
label="${i18next.t('label.select_file')}"
|
|
386
|
+
accept="*"
|
|
387
|
+
multiple="true"
|
|
388
|
+
?hidden="${this._isLmd}"
|
|
389
|
+
|
|
390
|
+
custom-input
|
|
391
|
+
></file-uploader>
|
|
392
|
+
</div>
|
|
393
|
+
</fieldset>
|
|
394
|
+
</form>
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
<form name="shippingInfo" ?hidden="${this._showShippingInfo}" class="multi-column-form" autocomplete="off">
|
|
398
|
+
<legend>${i18next.t('title.shipping_information')}</legend>
|
|
399
|
+
|
|
400
|
+
<label>${i18next.t('label.attention_to')}</label>
|
|
401
|
+
<input name="attentionTo" required .value="${this._attentionTo}" />
|
|
402
|
+
<!-- delivery -->
|
|
403
|
+
<label class="section-header">${i18next.t('label.delivery_address')}</label>
|
|
404
|
+
|
|
405
|
+
<label>${i18next.t('label.country')}</label>
|
|
406
|
+
<select
|
|
407
|
+
name="country"
|
|
408
|
+
@change=${e => {
|
|
409
|
+
this._validateCountry(e)
|
|
410
|
+
}}
|
|
411
|
+
>
|
|
412
|
+
${this._allCountry?.map(
|
|
413
|
+
(country, key) => html`<option value=${country.description}>${country.name}</option>`
|
|
414
|
+
)}
|
|
415
|
+
</select>
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
<label>${i18next.t('label.zip_postal_code')}</label>
|
|
419
|
+
|
|
420
|
+
${
|
|
421
|
+
this._switchDeliveryCountryInput
|
|
422
|
+
? html` <input id="deliveryPostalCode" name="postalCode" required .value="" /> `
|
|
423
|
+
: html`<select
|
|
424
|
+
name="postalCode"
|
|
425
|
+
@change=${e => {
|
|
426
|
+
this._getStateAndCityByPostCode(e.target.value, e.target.name)
|
|
427
|
+
}}
|
|
428
|
+
>
|
|
429
|
+
<option value=""></option>
|
|
430
|
+
${this._deliveryPostCode?.map(
|
|
431
|
+
(country, key) =>
|
|
432
|
+
html`<option value=${country.postalCode} ?selected=${this._selectedPostCode === country.postalCode}>
|
|
433
|
+
${country.postalCode}
|
|
434
|
+
</option>`
|
|
435
|
+
)}
|
|
436
|
+
</select>`
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
<label>${i18next.t('label.state')}</label>
|
|
441
|
+
<input name="state" required .value="${this._deliveryState}" />
|
|
442
|
+
|
|
443
|
+
<label>${i18next.t('label.city')}</label>
|
|
444
|
+
<input name="city" required .value="${this._deliveryCity}" />
|
|
445
|
+
|
|
446
|
+
<label>${i18next.t('label.delivery_address')}</label>
|
|
447
|
+
<textarea name="deliveryAddress1" required .value="${this._deliveryFullAddress}"></textarea>
|
|
448
|
+
|
|
449
|
+
<label>${i18next.t('label.contact')}</label>
|
|
450
|
+
<input name="phone1" required .value="${this._deliveryContact}" />
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
<!-- billing -->
|
|
454
|
+
<label class="section-header">${i18next.t('label.billing_address')}</label>
|
|
455
|
+
|
|
456
|
+
<label>${i18next.t('label.country')}</label>
|
|
457
|
+
<select
|
|
458
|
+
name="billingCountry"
|
|
459
|
+
?disabled=${this._disableBillingAddress ? true : false}
|
|
460
|
+
@change=${e => {
|
|
461
|
+
this._validateBillingCountry(e)
|
|
462
|
+
}}
|
|
463
|
+
>
|
|
464
|
+
${this._allCountry?.map((country, key) => html`<option value=${country.description}>${country.name}</option>`)}
|
|
465
|
+
</select>
|
|
466
|
+
|
|
467
|
+
<label>${i18next.t('label.zip_postal_code')}</label>
|
|
468
|
+
|
|
469
|
+
${
|
|
470
|
+
this._switchBillingCountryInput
|
|
471
|
+
? html`
|
|
472
|
+
<input
|
|
473
|
+
?disabled=${this._disableBillingAddress ? true : false}
|
|
474
|
+
name="billingPostalCode"
|
|
475
|
+
required
|
|
476
|
+
.value=""
|
|
477
|
+
/>
|
|
478
|
+
`
|
|
479
|
+
: html`<select
|
|
480
|
+
?disabled=${this._disableBillingAddress ? true : false}
|
|
481
|
+
name="billingPostalCode"
|
|
482
|
+
@change=${e => {
|
|
483
|
+
this._getStateAndCityByPostCode(e.target.value, e.target.name)
|
|
484
|
+
}}
|
|
485
|
+
>
|
|
486
|
+
<option value=${this._selectedBillingPostCode ? this._selectedBillingPostCode : ''} selected>
|
|
487
|
+
${this._selectedBillingPostCode ? this._selectedBillingPostCode : ''}
|
|
488
|
+
</option>
|
|
489
|
+
${this._billingPostCode?.map(
|
|
490
|
+
(country, key) => html`<option value=${country.postalCode}>${country.postalCode}</option>`
|
|
491
|
+
)}
|
|
492
|
+
</select>`
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
<label>${i18next.t('label.state')}</label>
|
|
496
|
+
<input ?disabled=${this._disableBillingAddress ? true : false} name="billingState" required
|
|
497
|
+
.value="${this._billingState}" />
|
|
498
|
+
|
|
499
|
+
<label>${i18next.t('label.city')}</label>
|
|
500
|
+
<input ?disabled=${this._disableBillingAddress ? true : false} name="billingCity" required
|
|
501
|
+
.value="${this._billingCity}" />
|
|
502
|
+
|
|
503
|
+
<label>${i18next.t('label.billing_address')}</label>
|
|
504
|
+
<textarea ?disabled=${this._disableBillingAddress ? true : false} name="billingAddress" required
|
|
505
|
+
.value="${this._billingFullAddress}"></textarea>
|
|
506
|
+
|
|
507
|
+
<input type="checkbox" id="matchDeliveryAddress" name="matchDeliveryAddressInput" @click=${e => {
|
|
508
|
+
e.currentTarget.checked ? (this._disableBillingAddress = true) : (this._disableBillingAddress = false)
|
|
509
|
+
}} />
|
|
510
|
+
<label for="matchDeliveryAddress">${i18next.t('label.match_delivery_address')}</label>
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
</form>
|
|
514
|
+
|
|
515
|
+
<div class="container">
|
|
516
|
+
|
|
517
|
+
<div class="grist">
|
|
518
|
+
|
|
519
|
+
<!-- release product list-->
|
|
520
|
+
<data-grist
|
|
521
|
+
id="inventory-grist"
|
|
522
|
+
.mode=${isMobileDevice() ? 'LIST' : 'GRID'}
|
|
523
|
+
.config=${this.inventoryGristConfig}
|
|
524
|
+
.data=${this.inventoryData}
|
|
525
|
+
@record-change="${this._onProductChangeHandler.bind(this)}"
|
|
526
|
+
@field-change="${this._onInventoryFieldChanged.bind(this)}"
|
|
527
|
+
></data-grist>
|
|
528
|
+
|
|
529
|
+
<h2 ?hidden=${!this.bundleData.records?.length}>
|
|
530
|
+
<mwc-icon>list_alt</mwc-icon>${this._productBundleName || i18next.t('title.product_bundle_detail')}
|
|
531
|
+
</h2>
|
|
532
|
+
|
|
533
|
+
<data-grist
|
|
534
|
+
id="bundle-grist"
|
|
535
|
+
?hidden=${!this.bundleData.records?.length}
|
|
536
|
+
.mode=${isMobileDevice() ? 'LIST' : 'GRID'}
|
|
537
|
+
.config=${this.bundleGristConfig}
|
|
538
|
+
.data="${this.bundleData}"
|
|
539
|
+
@field-change="${this._onBundleFieldChanged.bind(this)}"
|
|
540
|
+
></data-grist>
|
|
541
|
+
</div>
|
|
542
|
+
</div>
|
|
543
|
+
</div>
|
|
544
|
+
`
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
get releaseOrderForm() {
|
|
548
|
+
return this.shadowRoot.querySelector('form[name=releaseOrder]')
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
get shippingInfoForm() {
|
|
552
|
+
return this.shadowRoot.querySelector('form[name=shippingInfo]')
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
get getDeliveryAddressInfoForm() {
|
|
556
|
+
return this.shadowRoot.querySelector('form[name=deliveryAddressInfo]')
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
get getBillingAddressInfoForm() {
|
|
560
|
+
return this.shadowRoot.querySelector('form[name=billingAddressInfo]')
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
get _containerClosureDateInput() {
|
|
564
|
+
return this.shadowRoot.querySelector('input[name=containerClosureDate]')
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
get _conLeavingDateInput() {
|
|
568
|
+
return this.shadowRoot.querySelector('input[name=containerClosureDate]')
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
get shippingOrderForm() {
|
|
572
|
+
return this.shadowRoot.querySelector('form[name=shippingOrder]')
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
get exportInfoForm() {
|
|
576
|
+
return this.shadowRoot.querySelector('form[name=exportInfo]')
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
get _ownTransportInput() {
|
|
580
|
+
return this.shadowRoot.querySelector('input[name=ownTransport]')
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
get _cityInput() {
|
|
584
|
+
return this.shadowRoot.querySelector('input[name=city]')
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
get _stateInput() {
|
|
588
|
+
return this.shadowRoot.querySelector('input[name=state]')
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
get _recallInput() {
|
|
592
|
+
return this.shadowRoot.querySelector('input[name=recall]')
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
get _cityBillingInput() {
|
|
596
|
+
return this.shadowRoot.querySelector('input[id=billingCity]')
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
get _stateBillingInput() {
|
|
600
|
+
return this.shadowRoot.querySelector('input[name=billingState]')
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
get _warehouseTransportInput() {
|
|
604
|
+
return this.shadowRoot.querySelector('input[name=warehouseTransport]')
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
get _getBillingPostalCodeInput() {
|
|
608
|
+
return this.shadowRoot.querySelector('select[name=billingPostalCode]')
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
get _exportOptionInput() {
|
|
612
|
+
return this.shadowRoot.querySelector('input[name=exportOption]')
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
get inventoryGrist() {
|
|
616
|
+
return this.shadowRoot.querySelector('data-grist#inventory-grist')
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
get bundleGrist() {
|
|
620
|
+
return this.shadowRoot.querySelector('data-grist#bundle-grist')
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
get _invoiceDocument() {
|
|
624
|
+
return this.shadowRoot.querySelector('#uploadInvoice')
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
get _awbDocument() {
|
|
628
|
+
return this.shadowRoot.querySelector('#uploadAwb')
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
get bizplaceIdInput() {
|
|
632
|
+
return this.shadowRoot.querySelector('input[name=bizplaceId]')
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
get bizplaceNameInput() {
|
|
636
|
+
return this.shadowRoot.querySelector('input[name=bizplaceName]')
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
get selectByProductInput() {
|
|
640
|
+
return this.shadowRoot.querySelector('input[id=pick-by-prod]')
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
get selectByPalletInput() {
|
|
644
|
+
return this.shadowRoot.querySelector('input[id=pick-by-pallet]')
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
get matchDeliveryAddressInput() {
|
|
648
|
+
return this.shadowRoot?.querySelector('input[name=matchDeliveryAddressInput]')
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
get deliveryCountryInput() {
|
|
652
|
+
return this.shadowRoot?.querySelector('select[name=country]')
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
get deliveryPostalCodeSelectInput() {
|
|
656
|
+
return this.shadowRoot?.querySelector('select[name=postalCode]')
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
get deliveryPostalCodeInput() {
|
|
660
|
+
return this.shadowRoot?.querySelector('input[name=postalCode]')
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
get deliveryStateInput() {
|
|
664
|
+
return this.shadowRoot?.querySelector('input[name=state]')
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
get deliveryCityInput() {
|
|
668
|
+
return this.shadowRoot?.querySelector('input[name=city]')
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
get deliveryAddressInput() {
|
|
672
|
+
return this.shadowRoot?.querySelector('textarea[name=deliveryAddress1]')
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
get deliveryContactInput() {
|
|
676
|
+
return this.shadowRoot?.querySelector('input[name=phone1]')
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
get billingCountryInput() {
|
|
680
|
+
return this.shadowRoot?.querySelector('select[name=billingCountry]')
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
get billingPostalCodeSelectInput() {
|
|
684
|
+
return this.shadowRoot?.querySelector('select[name=billingPostalCode]')
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
get billingPostalCodeInput() {
|
|
688
|
+
return this.shadowRoot?.querySelector('input[name=billingPostalCode]')
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
get billingStateInput() {
|
|
692
|
+
return this.shadowRoot?.querySelector('input[name=billingState]')
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
get billingCityInput() {
|
|
696
|
+
return this.shadowRoot?.querySelector('input[name=billingCity]')
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
get billingAddressInput() {
|
|
700
|
+
return this.shadowRoot?.querySelector('textarea[name=billingAddress]')
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
get attentionToInput() {
|
|
704
|
+
return this.shadowRoot?.querySelector('input[name=attentionTo]')
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
get _inventoryColumns() {
|
|
708
|
+
return this.inventoryGrist.columns
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
get quickFindContent() {
|
|
712
|
+
return this.shadowRoot?.querySelector('quick-find-content[name=quickFindContent]')
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
constructor() {
|
|
716
|
+
super()
|
|
717
|
+
this.initProperties()
|
|
718
|
+
this._getAllPostCode()
|
|
719
|
+
this.fetchCountry()
|
|
720
|
+
this._pickingStd = PICKING_STANDARD.SELECT_BY_PRODUCT.value
|
|
721
|
+
this._bundleSettingData = []
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
async updated(changeProps) {
|
|
725
|
+
if (changeProps.has('_pickingStd')) {
|
|
726
|
+
this.switchPickingType()
|
|
727
|
+
|
|
728
|
+
if (this.crossDockingProducts?.length > 0) {
|
|
729
|
+
this.inventoryData = {
|
|
730
|
+
...this.inventoryData,
|
|
731
|
+
records: this.crossDockingProducts
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
if (changeProps.has('_files') && this._files?.length) {
|
|
737
|
+
this._document.reset()
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
pageUpdated(changes) {
|
|
742
|
+
if (changes.active) {
|
|
743
|
+
const matches = location.pathname.match(/(?<=create_release_order\/)(.*)/g)
|
|
744
|
+
if (matches?.length) {
|
|
745
|
+
this._ganNo = matches[0]
|
|
746
|
+
} else {
|
|
747
|
+
this._ganNo = null
|
|
748
|
+
}
|
|
749
|
+
this._crossDocking = Boolean(this._ganNo)
|
|
750
|
+
if (this._crossDocking) {
|
|
751
|
+
this._pickingStd = PICKING_STANDARD.SELECT_BY_PRODUCT.value
|
|
752
|
+
} else {
|
|
753
|
+
this.crossDockingProducts = []
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
_clearView() {
|
|
759
|
+
this.releaseOrderForm.reset()
|
|
760
|
+
this.inventoryData = { ...this.inventoryData, records: [] }
|
|
761
|
+
if (this._document?._files) {
|
|
762
|
+
this._document.reset()
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
async pageInitialized() {
|
|
767
|
+
let [enableTransportationServiceSetting, bizplaces, packingTypes] = await Promise.all([
|
|
768
|
+
fetchSettingRule('enable-transportation-service'),
|
|
769
|
+
this.fetchBizplaces(),
|
|
770
|
+
getCodeByName('PACKING_TYPES')
|
|
771
|
+
])
|
|
772
|
+
|
|
773
|
+
this.checkActiveLmd()
|
|
774
|
+
|
|
775
|
+
this.quickFindContent.currentTabKey = i18next.t('label.order')
|
|
776
|
+
this._disableBillingAddress = false
|
|
777
|
+
this._enableTransportationServiceSetting = enableTransportationServiceSetting
|
|
778
|
+
this._bizplaces = bizplaces
|
|
779
|
+
this.packingTypes = packingTypes
|
|
780
|
+
|
|
781
|
+
this.bundleGristConfig = {
|
|
782
|
+
list: {
|
|
783
|
+
fields: ['batchId', 'productSku', 'product', 'remainQty', 'releaseQty', 'remainUomValue', 'releaseUomValue']
|
|
784
|
+
},
|
|
785
|
+
pagination: { infinite: true },
|
|
786
|
+
rows: {
|
|
787
|
+
handlers: {
|
|
788
|
+
click: (columns, data, column, record, rowIndex) => {
|
|
789
|
+
if (column.name) {
|
|
790
|
+
this._updateReleaseQtyUomValue(record)
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
},
|
|
795
|
+
columns: [
|
|
796
|
+
{
|
|
797
|
+
type: 'string',
|
|
798
|
+
name: 'batchId',
|
|
799
|
+
header: i18next.t('field.batch_id'),
|
|
800
|
+
width: 150
|
|
801
|
+
},
|
|
802
|
+
{
|
|
803
|
+
type: 'string',
|
|
804
|
+
name: 'productSku',
|
|
805
|
+
header: i18next.t('field.sku'),
|
|
806
|
+
width: 150
|
|
807
|
+
},
|
|
808
|
+
{
|
|
809
|
+
type: 'string',
|
|
810
|
+
name: 'product',
|
|
811
|
+
header: i18next.t('field.product'),
|
|
812
|
+
width: 300
|
|
813
|
+
},
|
|
814
|
+
{
|
|
815
|
+
type: 'string',
|
|
816
|
+
name: 'packingType',
|
|
817
|
+
header: i18next.t('field.packing_type'),
|
|
818
|
+
width: 150
|
|
819
|
+
},
|
|
820
|
+
{
|
|
821
|
+
type: 'integer',
|
|
822
|
+
name: 'remainQty',
|
|
823
|
+
header: i18next.t('field.available_qty'),
|
|
824
|
+
width: 120
|
|
825
|
+
},
|
|
826
|
+
{
|
|
827
|
+
type: 'integer',
|
|
828
|
+
name: 'releaseQty',
|
|
829
|
+
header: i18next.t('field.assigned_qty'),
|
|
830
|
+
width: 120
|
|
831
|
+
},
|
|
832
|
+
{
|
|
833
|
+
type: 'float',
|
|
834
|
+
name: 'remainUomValue',
|
|
835
|
+
header: i18next.t('field.available_uom_value'),
|
|
836
|
+
width: 150
|
|
837
|
+
},
|
|
838
|
+
{
|
|
839
|
+
type: 'string',
|
|
840
|
+
name: 'releaseUomValueWithUom',
|
|
841
|
+
header: i18next.t('field.assigned_uom_value'),
|
|
842
|
+
width: 150
|
|
843
|
+
}
|
|
844
|
+
]
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
initProperties() {
|
|
849
|
+
this._exportOption = false
|
|
850
|
+
this.refNo = ''
|
|
851
|
+
this.refNo2 = ''
|
|
852
|
+
this.refNo3 = ''
|
|
853
|
+
this.releaseDate = ''
|
|
854
|
+
this.collectionOrderNo = ''
|
|
855
|
+
this._files = []
|
|
856
|
+
this._allCountry = []
|
|
857
|
+
this.inventoryData = { ...this.inventoryData, records: [] }
|
|
858
|
+
this.bundleData = { ...this.bundleData, records: [] }
|
|
859
|
+
this._showReleasedOrderInfo = false
|
|
860
|
+
this._showShippingInfo = true
|
|
861
|
+
this._attentionTo = ''
|
|
862
|
+
this._companyName = ''
|
|
863
|
+
this._deliveryState = ''
|
|
864
|
+
this._deliveryCity = ''
|
|
865
|
+
this._deliveryFullAddress = ''
|
|
866
|
+
this._deliveryContact = ''
|
|
867
|
+
this._billingState = ''
|
|
868
|
+
this._billingCity = ''
|
|
869
|
+
this._billingFullAddress = ''
|
|
870
|
+
this._billingContact = ''
|
|
871
|
+
this._switchDeliveryCountryInput = false
|
|
872
|
+
this._switchBillingCountryInput = false
|
|
873
|
+
this._disableBillingAddress = false
|
|
874
|
+
this._showExportInfo = true
|
|
875
|
+
this._selectedDeliveryCountry = 'MY'
|
|
876
|
+
this._selectedBillingCountry = 'MY'
|
|
877
|
+
this._containerClosureDate = ''
|
|
878
|
+
this._recallToggle = false
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
resetPage() {
|
|
882
|
+
this.bundleData = {}
|
|
883
|
+
this.matchDeliveryAddressInput.checked = false
|
|
884
|
+
this.quickFindContent.currentTabKey = i18next.t('label.order')
|
|
885
|
+
|
|
886
|
+
// this.initProperties()
|
|
887
|
+
this._clearGristConditions()
|
|
888
|
+
this._getAllPostCode()
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
async switchPickingType() {
|
|
892
|
+
this.resetPage()
|
|
893
|
+
this.inventoryGristConfig = {
|
|
894
|
+
pagination: { infinite: true },
|
|
895
|
+
rows: {
|
|
896
|
+
selectable: { multiple: true },
|
|
897
|
+
classifier: (record, rowIndex) => {
|
|
898
|
+
return {
|
|
899
|
+
emphasized: record.isCrossDocking || record.isError
|
|
900
|
+
}
|
|
901
|
+
},
|
|
902
|
+
handlers: {
|
|
903
|
+
click: (columns, data, column, record, rowIndex) => {
|
|
904
|
+
if (record.groupType === GROUP_TYPES.BUNDLE.value && record.releaseQty) {
|
|
905
|
+
this.fetchInventoriesByBundle(record.product.id, record.releaseQty)
|
|
906
|
+
this._productBundleName = `${record.product.name}`
|
|
907
|
+
} else {
|
|
908
|
+
this.bundleData = {}
|
|
909
|
+
this._productBundleName = null
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
},
|
|
914
|
+
list: { fields: ['inventory', 'product', 'location', 'releaseQty'] },
|
|
915
|
+
columns: [
|
|
916
|
+
{ type: 'gutter', gutterName: 'sequence' },
|
|
917
|
+
{
|
|
918
|
+
type: 'gutter',
|
|
919
|
+
gutterName: 'button',
|
|
920
|
+
icon: 'close',
|
|
921
|
+
handlers: {
|
|
922
|
+
click: (columns, data, column, record, rowIndex) => {
|
|
923
|
+
try {
|
|
924
|
+
if (record.isCrossDocking) throw new Error(i18next.t('text.cannot_delete_cross_docking_products'))
|
|
925
|
+
const newData = data.records.filter((_, idx) => idx !== rowIndex)
|
|
926
|
+
this.inventoryData = { ...this.inventoryData, records: newData }
|
|
927
|
+
|
|
928
|
+
this.inventoryGrist.dirtyData.records = newData
|
|
929
|
+
this._updateInventoryGristConfig()
|
|
930
|
+
} catch (e) {
|
|
931
|
+
this._showToast(e)
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
},
|
|
936
|
+
{
|
|
937
|
+
type: 'string',
|
|
938
|
+
name: 'productSKU',
|
|
939
|
+
header: i18next.t('field.sku'),
|
|
940
|
+
width: 100
|
|
941
|
+
},
|
|
942
|
+
{
|
|
943
|
+
type: 'object',
|
|
944
|
+
name: 'product',
|
|
945
|
+
header: i18next.t('field.product'),
|
|
946
|
+
handlers: {
|
|
947
|
+
click: (columns, data, column, record, rowIndex) => {
|
|
948
|
+
this._selectBy = 'product'
|
|
949
|
+
this._openBulkProductSelection(this._selectBy, rowIndex, record)
|
|
950
|
+
}
|
|
951
|
+
},
|
|
952
|
+
width: 200
|
|
953
|
+
},
|
|
954
|
+
{
|
|
955
|
+
type: 'string',
|
|
956
|
+
name: 'productBrand',
|
|
957
|
+
header: i18next.t('field.brand'),
|
|
958
|
+
width: 100
|
|
959
|
+
},
|
|
960
|
+
{
|
|
961
|
+
type: 'code',
|
|
962
|
+
name: 'packingType',
|
|
963
|
+
header: i18next.t('field.packing_type'),
|
|
964
|
+
record: {
|
|
965
|
+
codeName: 'PACKING_TYPES'
|
|
966
|
+
},
|
|
967
|
+
width: 100
|
|
968
|
+
},
|
|
969
|
+
{
|
|
970
|
+
type: 'number',
|
|
971
|
+
name: 'packingSize',
|
|
972
|
+
header: i18next.t('field.packing_size'),
|
|
973
|
+
width: 140
|
|
974
|
+
},
|
|
975
|
+
{
|
|
976
|
+
type: 'string',
|
|
977
|
+
name: 'uom',
|
|
978
|
+
header: i18next.t('field.uom'),
|
|
979
|
+
width: 100
|
|
980
|
+
},
|
|
981
|
+
{
|
|
982
|
+
type: 'integer',
|
|
983
|
+
name: 'remainQty',
|
|
984
|
+
header: i18next.t('field.available_qty'),
|
|
985
|
+
width: 140
|
|
986
|
+
},
|
|
987
|
+
{
|
|
988
|
+
type: 'integer',
|
|
989
|
+
name: 'releaseQty',
|
|
990
|
+
header: i18next.t('field.release_qty'),
|
|
991
|
+
imex: { header: i18next.t('field.release_qty'), key: 'releaseQty', width: 25, type: 'float' },
|
|
992
|
+
record: { editable: true, options: { min: 0 } },
|
|
993
|
+
width: 140
|
|
994
|
+
},
|
|
995
|
+
{
|
|
996
|
+
type: 'string',
|
|
997
|
+
name: 'remainUomValueWithUom',
|
|
998
|
+
header: i18next.t('field.available_uom_value'),
|
|
999
|
+
width: 140
|
|
1000
|
+
},
|
|
1001
|
+
{
|
|
1002
|
+
type: 'float',
|
|
1003
|
+
name: 'releaseUomValue',
|
|
1004
|
+
header: i18next.t('field.release_uom_value'),
|
|
1005
|
+
imex: { header: i18next.t('field.release_uom_value'), key: 'releaseUomValue', width: 25, type: 'float' },
|
|
1006
|
+
record: { editable: true, options: { min: 0 } },
|
|
1007
|
+
width: 140
|
|
1008
|
+
}
|
|
1009
|
+
]
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
_getStdDate() {
|
|
1014
|
+
let date = new Date()
|
|
1015
|
+
date.setDate(date.getDate())
|
|
1016
|
+
return date.toISOString().split('T')[0]
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
_validateDate(e) {
|
|
1020
|
+
let inputDate = e.currentTarget.value
|
|
1021
|
+
let todayDate = this._getStdDate()
|
|
1022
|
+
if (inputDate < todayDate) {
|
|
1023
|
+
this._showToast({
|
|
1024
|
+
message: 'Invalid date'
|
|
1025
|
+
})
|
|
1026
|
+
}
|
|
1027
|
+
return inputDate
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
_onInventoryFieldChanged(e) {
|
|
1031
|
+
let columnName = e.detail.column.name
|
|
1032
|
+
let roundedUomValue = e.detail.record.roundedUomValue || 0
|
|
1033
|
+
let releaseQty = 0
|
|
1034
|
+
|
|
1035
|
+
if (columnName == 'releaseUomValue' || columnName == 'releaseQty' || columnName == 'inventory') {
|
|
1036
|
+
if (e.detail.record.isCrossDocking) return
|
|
1037
|
+
if (e.detail.record.groupType === GROUP_TYPES.BUNDLE.value) {
|
|
1038
|
+
this._productBundleName = `${e.detail.record.product.name}`
|
|
1039
|
+
this.fetchInventoriesByBundle(e.detail.record.product.id, e.detail.after)
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
if (columnName == 'inventory') {
|
|
1043
|
+
if (
|
|
1044
|
+
e.detail.after.remainUomValue &&
|
|
1045
|
+
e.detail.after.remainQty &&
|
|
1046
|
+
e.detail.after.remainUomValue > 0 &&
|
|
1047
|
+
e.detail.after.remainQty > 0
|
|
1048
|
+
) {
|
|
1049
|
+
releaseQty = e.detail.record.releaseQty || 0
|
|
1050
|
+
|
|
1051
|
+
roundedUomValue = releaseQty * (e.detail.after.remainUomValue / e.detail.after.remainQty)
|
|
1052
|
+
|
|
1053
|
+
roundedUomValue = parseFloat(roundedUomValue.toFixed(2))
|
|
1054
|
+
}
|
|
1055
|
+
} else {
|
|
1056
|
+
let packageUomValue = e.detail.record.remainUomValue / e.detail.record.remainQty
|
|
1057
|
+
if (
|
|
1058
|
+
e.detail.record.remainUomValue &&
|
|
1059
|
+
e.detail.record.remainQty &&
|
|
1060
|
+
e.detail.record.remainUomValue > 0 &&
|
|
1061
|
+
e.detail.record.remainQty > 0
|
|
1062
|
+
) {
|
|
1063
|
+
if (columnName === 'releaseQty') {
|
|
1064
|
+
releaseQty = e.detail.after || 0
|
|
1065
|
+
} else {
|
|
1066
|
+
releaseQty = Math.round(e.detail.after / packageUomValue)
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
roundedUomValue = releaseQty * packageUomValue
|
|
1070
|
+
roundedUomValue = parseFloat(roundedUomValue.toFixed(2))
|
|
1071
|
+
this.releaseQty = releaseQty
|
|
1072
|
+
this.releaseUomValue = roundedUomValue
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
this.inventoryData = {
|
|
1078
|
+
...this.inventoryData,
|
|
1079
|
+
...this.inventoryGrist.dirtyData,
|
|
1080
|
+
records: this.inventoryGrist.dirtyData.records.map((record, idx) => {
|
|
1081
|
+
if (
|
|
1082
|
+
(columnName == 'releaseUomValue' || columnName == 'releaseQty' || columnName == 'inventory') &&
|
|
1083
|
+
idx === e.detail.row
|
|
1084
|
+
) {
|
|
1085
|
+
if (this.releaseQty > e.detail.record.remainQty && this.releaseUomValue > e.detail.record.releaseUomValue) {
|
|
1086
|
+
record.releaseQty = e.detail.record.releaseQty
|
|
1087
|
+
record.releaseUomValue = e.detail.record.releaseUomValue
|
|
1088
|
+
} else {
|
|
1089
|
+
record.releaseQty = releaseQty
|
|
1090
|
+
record.releaseUomValue = roundedUomValue
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
let returnObj = {
|
|
1095
|
+
...record,
|
|
1096
|
+
...record.inventory,
|
|
1097
|
+
name: record.name ? record.name : idx
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
if (this._pickingStd === PICKING_STANDARD.SELECT_BY_PRODUCT.value) {
|
|
1101
|
+
returnObj = {
|
|
1102
|
+
...returnObj,
|
|
1103
|
+
id: idx,
|
|
1104
|
+
product: {
|
|
1105
|
+
id: record?.inventory?.productId,
|
|
1106
|
+
name: record?.inventory?.productName
|
|
1107
|
+
},
|
|
1108
|
+
productDetail: {
|
|
1109
|
+
id: record?.inventory?.productDetailId
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
return returnObj
|
|
1115
|
+
})
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
this._updateInventoryGristConfig()
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
_onBundleFieldChanged(e) {
|
|
1122
|
+
const columnName = e.detail.column.name
|
|
1123
|
+
if (columnName === 'releaseQty' || columnName === 'releaseUomValue') {
|
|
1124
|
+
let totalReleaseQty = 0
|
|
1125
|
+
let totalReleaseUomValue = 0
|
|
1126
|
+
|
|
1127
|
+
// get product id that related to current bundle
|
|
1128
|
+
let _productIds = this.bundleGrist.dirtyData.records.map(record => record.productId)
|
|
1129
|
+
_productIds = _productIds.filter((value, index) => _productIds.indexOf(value) === index)
|
|
1130
|
+
|
|
1131
|
+
let productGroup = _productIds.map(id => {
|
|
1132
|
+
return {
|
|
1133
|
+
productId: id,
|
|
1134
|
+
productReleaseQty: 0,
|
|
1135
|
+
productReleaseUomValue: 0
|
|
1136
|
+
}
|
|
1137
|
+
})
|
|
1138
|
+
|
|
1139
|
+
if (columnName === 'releaseQty') {
|
|
1140
|
+
this.bundleData = {
|
|
1141
|
+
...this.bundleData,
|
|
1142
|
+
records: this.bundleGrist.dirtyData.records.map(record => {
|
|
1143
|
+
let releaseQty = record.releaseQty
|
|
1144
|
+
let releaseUomValue = (record.remainUomValue / record.remainQty) * record.releaseQty
|
|
1145
|
+
|
|
1146
|
+
productGroup.forEach(group => {
|
|
1147
|
+
if (group.productId === record.productId) {
|
|
1148
|
+
releaseUomValue = Math.round(releaseUomValue * 100) / 100
|
|
1149
|
+
|
|
1150
|
+
if (releaseQty > record.remainQty || Number.isNaN(releaseQty)) {
|
|
1151
|
+
releaseQty = record.remainQty
|
|
1152
|
+
releaseUomValue = record.remainUomValue
|
|
1153
|
+
} else if (releaseQty < 0) {
|
|
1154
|
+
releaseQty = 0
|
|
1155
|
+
releaseUomValue = 0
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
totalReleaseQty += releaseQty
|
|
1159
|
+
totalReleaseUomValue += releaseUomValue
|
|
1160
|
+
}
|
|
1161
|
+
})
|
|
1162
|
+
|
|
1163
|
+
return {
|
|
1164
|
+
...record,
|
|
1165
|
+
releaseQty,
|
|
1166
|
+
releaseUomValue,
|
|
1167
|
+
assigned: !!record.releaseQty
|
|
1168
|
+
}
|
|
1169
|
+
})
|
|
1170
|
+
}
|
|
1171
|
+
} else if (columnName === 'releaseUomValue') {
|
|
1172
|
+
this.bundleData = {
|
|
1173
|
+
records: this.bundleGrist.dirtyData.records.map(data => {
|
|
1174
|
+
let releaseQty = Math.round((data.remainQty * data.releaseUomValue) / data.uomValue)
|
|
1175
|
+
let releaseUomValue = data.releaseUomValue
|
|
1176
|
+
|
|
1177
|
+
if (releaseUomValue > data.uomValue || Number.isNaN(releaseUomValue)) {
|
|
1178
|
+
releaseQty = data.remainQty
|
|
1179
|
+
releaseUomValue = data.uomValue
|
|
1180
|
+
} else if (releaseUomValue < 0) {
|
|
1181
|
+
releaseQty = 0
|
|
1182
|
+
releaseUomValue = 0
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
totalReleaseQty += releaseQty
|
|
1186
|
+
totalReleaseUomValue += releaseUomValue
|
|
1187
|
+
|
|
1188
|
+
return {
|
|
1189
|
+
...data,
|
|
1190
|
+
releaseQty: Math.round((releaseQty * data.uomValue) / data.uomValue),
|
|
1191
|
+
releaseUomValue,
|
|
1192
|
+
assigned: Boolean(data.releaseUomValue)
|
|
1193
|
+
}
|
|
1194
|
+
})
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
this.releaseQty = totalReleaseQty
|
|
1198
|
+
this.releaseUomValue = Math.round(totalReleaseUomValue * 100) / 100
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
async _onProductChangeHandler(event) {
|
|
1203
|
+
const changeRecord = event.detail.after
|
|
1204
|
+
const changedColumn = event.detail.column.name
|
|
1205
|
+
|
|
1206
|
+
try {
|
|
1207
|
+
if (changedColumn === 'releaseQty') {
|
|
1208
|
+
this._validateReleaseQty(changeRecord.releaseQty, changeRecord.remainQty)
|
|
1209
|
+
} else if (changedColumn === 'releaseUomValue') {
|
|
1210
|
+
this._validateReleaseUomValue(changeRecord.releaseUomValue, changeRecord.remainUomValue)
|
|
1211
|
+
}
|
|
1212
|
+
this._updateInventoryGristConfig()
|
|
1213
|
+
} catch (e) {
|
|
1214
|
+
const beforeValue = event.detail.before && event.detail.before[event.detail.column.name]
|
|
1215
|
+
if (beforeValue) {
|
|
1216
|
+
event.detail.after[event.detail.column.name] = beforeValue
|
|
1217
|
+
} else {
|
|
1218
|
+
delete event.detail.after[event.detail.column.name]
|
|
1219
|
+
}
|
|
1220
|
+
this._showToast(e)
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
_validateReleaseQty(releaseQty, remainQty) {
|
|
1225
|
+
if (remainQty === undefined) throw new Error(i18next.t('text.there_is_no_selected_items'))
|
|
1226
|
+
if (releaseQty > remainQty) {
|
|
1227
|
+
throw new Error(i18next.t('text.available_quantity_insufficient'))
|
|
1228
|
+
} else if (releaseQty <= 0) {
|
|
1229
|
+
throw new Error(i18next.t('text.invalid_quantity_input'))
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
_validateReleaseUomValue(releaseUomValue, remainUomValue) {
|
|
1234
|
+
if (remainUomValue === undefined) throw new Error(i18next.t('text.there_is_no_selected_items'))
|
|
1235
|
+
if (releaseUomValue > remainUomValue) {
|
|
1236
|
+
throw new Error(i18next.t('text.available_uom_value_insufficient'))
|
|
1237
|
+
} else if (releaseUomValue <= 0) {
|
|
1238
|
+
throw new Error(i18next.t('text.invalid_uom_value_input'))
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
_updateReleaseQtyUomValue(record) {
|
|
1243
|
+
this._releaseByBundleQty = record.releaseQty
|
|
1244
|
+
this._releaseByBundleUomValue = record.releaseUomValue
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
async fetchBizplaces() {
|
|
1248
|
+
const filters = []
|
|
1249
|
+
const response = await client.query({
|
|
1250
|
+
query: gql`
|
|
1251
|
+
query partnersBizplaces($filters: [Filter!]) {
|
|
1252
|
+
partnersBizplaces(filters: $filters) {
|
|
1253
|
+
items {
|
|
1254
|
+
id
|
|
1255
|
+
name
|
|
1256
|
+
description
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
`,
|
|
1261
|
+
variables: { filters }
|
|
1262
|
+
})
|
|
1263
|
+
|
|
1264
|
+
if (!response.errors) {
|
|
1265
|
+
const bizplaces = response.data.partnersBizplaces.items
|
|
1266
|
+
if (bizplaces.length == 1) {
|
|
1267
|
+
this._bizplaceId = bizplaces[0].id
|
|
1268
|
+
this._bizplaceName = bizplaces[0].name
|
|
1269
|
+
|
|
1270
|
+
this.switchPickingType()
|
|
1271
|
+
} else {
|
|
1272
|
+
this._bizplaceId = ''
|
|
1273
|
+
this._bizplaceName = ''
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
return bizplaces
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
async fetchCountry() {
|
|
1281
|
+
const response = await client.query({
|
|
1282
|
+
query: gql`
|
|
1283
|
+
query geoCountriesWithoutParam {
|
|
1284
|
+
geoCountriesWithoutParam {
|
|
1285
|
+
items {
|
|
1286
|
+
id
|
|
1287
|
+
name
|
|
1288
|
+
description
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
`
|
|
1293
|
+
})
|
|
1294
|
+
|
|
1295
|
+
if (!response.error) {
|
|
1296
|
+
this._allCountry = response.data.geoCountriesWithoutParam.items
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
async fetchInventoriesByBundle(productBundleId, bundleReleaseQty) {
|
|
1301
|
+
const page = 1
|
|
1302
|
+
const limit = 99999
|
|
1303
|
+
const pagination = { page, limit }
|
|
1304
|
+
const filters = [
|
|
1305
|
+
{
|
|
1306
|
+
name: 'productBundleId',
|
|
1307
|
+
operator: 'eq',
|
|
1308
|
+
value: productBundleId
|
|
1309
|
+
},
|
|
1310
|
+
{
|
|
1311
|
+
name: 'bizplace_id',
|
|
1312
|
+
operator: 'eq',
|
|
1313
|
+
value: this._bizplaceId
|
|
1314
|
+
},
|
|
1315
|
+
{
|
|
1316
|
+
name: 'bundleReleaseQty',
|
|
1317
|
+
operator: 'eq',
|
|
1318
|
+
value: bundleReleaseQty
|
|
1319
|
+
}
|
|
1320
|
+
]
|
|
1321
|
+
const sortings = []
|
|
1322
|
+
|
|
1323
|
+
const response = await client.query({
|
|
1324
|
+
query: gql`
|
|
1325
|
+
query inventoriesByBundle($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
|
|
1326
|
+
inventoriesByBundle(filters: $filters, pagination: $pagination, sortings: $sortings) {
|
|
1327
|
+
bundleGroup {
|
|
1328
|
+
batchId
|
|
1329
|
+
bundleId
|
|
1330
|
+
bundleQty
|
|
1331
|
+
productId
|
|
1332
|
+
productDetailId
|
|
1333
|
+
productSku
|
|
1334
|
+
productName
|
|
1335
|
+
productDescription
|
|
1336
|
+
remainQty
|
|
1337
|
+
remainUomValue
|
|
1338
|
+
releaseQty
|
|
1339
|
+
releaseUomValue
|
|
1340
|
+
releaseUomValueWithUom
|
|
1341
|
+
packingType
|
|
1342
|
+
uom
|
|
1343
|
+
}
|
|
1344
|
+
bundleSetting {
|
|
1345
|
+
productId
|
|
1346
|
+
bundleId
|
|
1347
|
+
bundleQty
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
`,
|
|
1352
|
+
variables: {
|
|
1353
|
+
filters,
|
|
1354
|
+
pagination,
|
|
1355
|
+
sortings
|
|
1356
|
+
}
|
|
1357
|
+
})
|
|
1358
|
+
if (!response.errors) {
|
|
1359
|
+
const data = {
|
|
1360
|
+
records: response.data.inventoriesByBundle.bundleGroup.map(item => {
|
|
1361
|
+
return {
|
|
1362
|
+
...item,
|
|
1363
|
+
product: `${item.productName} (${item.productDescription})`
|
|
1364
|
+
}
|
|
1365
|
+
})
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
const bundleSettingData = response.data.inventoriesByBundle.bundleSetting.map(setting => {
|
|
1369
|
+
return {
|
|
1370
|
+
...setting,
|
|
1371
|
+
releaseQty: bundleReleaseQty * setting.bundleQty,
|
|
1372
|
+
productReleaseQty: 0,
|
|
1373
|
+
productReleaseUomValue: 0
|
|
1374
|
+
}
|
|
1375
|
+
})
|
|
1376
|
+
|
|
1377
|
+
this.bundleData = {
|
|
1378
|
+
...data
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
return data
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
async _generateReleaseOrder() {
|
|
1386
|
+
try {
|
|
1387
|
+
this._validateForm()
|
|
1388
|
+
this._validateInventories()
|
|
1389
|
+
|
|
1390
|
+
let shippingOrderInfo = {}
|
|
1391
|
+
|
|
1392
|
+
let contactPointInfo = this._serializeForm(this.shippingInfoForm)
|
|
1393
|
+
|
|
1394
|
+
shippingOrderInfo = {
|
|
1395
|
+
...contactPointInfo
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
delete shippingOrderInfo['']
|
|
1399
|
+
delete shippingOrderInfo.matchDeliveryAddressInput
|
|
1400
|
+
|
|
1401
|
+
// If match delivery address is ticked, all the billing address info will be the same with delivery address info
|
|
1402
|
+
if (this._disableBillingAddress) {
|
|
1403
|
+
shippingOrderInfo.billingAddress = shippingOrderInfo.deliveryAddress1
|
|
1404
|
+
shippingOrderInfo.billingPostalCode = shippingOrderInfo.postalCode
|
|
1405
|
+
shippingOrderInfo.billingCity = shippingOrderInfo.city
|
|
1406
|
+
shippingOrderInfo.billingState = shippingOrderInfo.state
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
let result = await CustomAlert({
|
|
1410
|
+
title: i18next.t('title.are_you_sure'),
|
|
1411
|
+
text: i18next.t('text.create_release_order'),
|
|
1412
|
+
confirmButton: { text: i18next.t('button.submit') },
|
|
1413
|
+
cancelButton: { text: i18next.t('button.cancel') }
|
|
1414
|
+
})
|
|
1415
|
+
|
|
1416
|
+
if (!result.value) return
|
|
1417
|
+
|
|
1418
|
+
if (this._crossDocking) {
|
|
1419
|
+
result = await CustomAlert({
|
|
1420
|
+
title: i18next.t('label.cross_docking'),
|
|
1421
|
+
text: i18next.t('text.create_release_order'),
|
|
1422
|
+
confirmButton: { text: i18next.t('button.submit') },
|
|
1423
|
+
cancelButton: { text: i18next.t('button.cancel') }
|
|
1424
|
+
})
|
|
1425
|
+
|
|
1426
|
+
if (!result.value) return
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
let releaseGood = this._serializeForm(this.releaseOrderForm)
|
|
1430
|
+
delete releaseGood.warehouseTransport
|
|
1431
|
+
delete releaseGood.lmd
|
|
1432
|
+
|
|
1433
|
+
releaseGood.orderInventories = await this._getOrderInventories()
|
|
1434
|
+
releaseGood.type = RO_TYPES.B2C.value
|
|
1435
|
+
releaseGood.orderMethod = this._pickingStd
|
|
1436
|
+
releaseGood.exportOption = false
|
|
1437
|
+
releaseGood.lmdOption = this._isLmd
|
|
1438
|
+
releaseGood.courierOption = true
|
|
1439
|
+
releaseGood.packingOption = true
|
|
1440
|
+
|
|
1441
|
+
delete releaseGood.bizplaceId
|
|
1442
|
+
delete releaseGood.bizplaceName
|
|
1443
|
+
|
|
1444
|
+
const response = await client.mutate({
|
|
1445
|
+
mutation: gql`
|
|
1446
|
+
mutation ($releaseGood: NewReleaseGood, $invoiceAttachment: [Upload!], $awbAttachment: [Upload!]) {
|
|
1447
|
+
generateReleaseGood(
|
|
1448
|
+
releaseGood: $releaseGood
|
|
1449
|
+
awbAttachment: $awbAttachment
|
|
1450
|
+
invoiceAttachment: $invoiceAttachment
|
|
1451
|
+
) {
|
|
1452
|
+
id
|
|
1453
|
+
name
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
`,
|
|
1457
|
+
variables: {
|
|
1458
|
+
releaseGood: {
|
|
1459
|
+
...releaseGood,
|
|
1460
|
+
...(shippingOrderInfo || {}),
|
|
1461
|
+
partnerBizplaceId: this._bizplaceId
|
|
1462
|
+
},
|
|
1463
|
+
//if user uploads AWB first and then checks LMD option, remove AWB
|
|
1464
|
+
awbAttachment: this._isLmd ? undefined : this._awbDocument?.files ? this._awbDocument.files : undefined,
|
|
1465
|
+
invoiceAttachment: this._invoiceDocument?.files ? this._invoiceDocument.files : undefined
|
|
1466
|
+
},
|
|
1467
|
+
context: { hasUpload: true }
|
|
1468
|
+
})
|
|
1469
|
+
|
|
1470
|
+
if (!response.errors) {
|
|
1471
|
+
this.resetPage()
|
|
1472
|
+
this._resetShippingInfoForm()
|
|
1473
|
+
this._deliveryPostCode = []
|
|
1474
|
+
this._billingPostCode = []
|
|
1475
|
+
this._selectedPostCode = ''
|
|
1476
|
+
this._selectedBillingPostCode = ''
|
|
1477
|
+
|
|
1478
|
+
navigate(`b2c_release_order_detail/${response.data.generateReleaseGood.name}`)
|
|
1479
|
+
this._showToast({ message: i18next.t('text.release_order_created') })
|
|
1480
|
+
} else {
|
|
1481
|
+
let overLimitError = response.errors.find(err => err?.extensions?.exception?.errorCode == 'rol1')
|
|
1482
|
+
if (overLimitError) {
|
|
1483
|
+
let refreshData = JSON.parse(overLimitError.extensions.exception.detail.data)
|
|
1484
|
+
|
|
1485
|
+
let data = this.inventoryData.records
|
|
1486
|
+
refreshData.forEach(dt => {
|
|
1487
|
+
let idx = data.findIndex(
|
|
1488
|
+
x => x.productId == dt.productId && x.batchId == dt.batchId && x.packingType == dt.packingType
|
|
1489
|
+
)
|
|
1490
|
+
|
|
1491
|
+
if (idx >= 0) {
|
|
1492
|
+
data[idx].remainQty = dt.availableQty
|
|
1493
|
+
data[idx].inventory.remainQty = dt.availableQty
|
|
1494
|
+
data[idx].remainUomValue = dt.availableUomValue
|
|
1495
|
+
data[idx].inventory.remainUomValue = dt.availableUomValue
|
|
1496
|
+
data[idx].isError = data[idx].releaseQty > dt.availableQty
|
|
1497
|
+
data[idx].remainUomValueWithUom = `${dt.availableUomValue} ${dt.uom}`
|
|
1498
|
+
data[idx].inventory.remainUomValueWithUom = `${dt.availableUomValue} ${dt.uom}`
|
|
1499
|
+
}
|
|
1500
|
+
})
|
|
1501
|
+
|
|
1502
|
+
this.inventoryData = {
|
|
1503
|
+
...this.inventoryData,
|
|
1504
|
+
records: data
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
} catch (e) {
|
|
1509
|
+
this._showToast(e)
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
_validateForm() {
|
|
1514
|
+
if (!this.releaseOrderForm.checkValidity()) {
|
|
1515
|
+
throw new Error(i18next.t('text.release_order_form_invalid'))
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
if (this._isLmd) {
|
|
1519
|
+
const checkShipmentFields = (
|
|
1520
|
+
attentionToInput,
|
|
1521
|
+
postalCodeInput,
|
|
1522
|
+
stateInput,
|
|
1523
|
+
cityInput,
|
|
1524
|
+
addressInput,
|
|
1525
|
+
contactInput
|
|
1526
|
+
) => {
|
|
1527
|
+
if (
|
|
1528
|
+
!attentionToInput.value &&
|
|
1529
|
+
!postalCodeInput.value &&
|
|
1530
|
+
!stateInput.value &&
|
|
1531
|
+
!cityInput.value &&
|
|
1532
|
+
!addressInput.value &&
|
|
1533
|
+
!contactInput.value
|
|
1534
|
+
) {
|
|
1535
|
+
throw new Error(i18next.t('text.please_fill_in_the_shipping_information_in_shipment_tab'))
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
if (!attentionToInput.value) {
|
|
1539
|
+
throw new Error(i18next.t('text.attention_to_is_empty_please_fill_in_the_data_before_proceed_create_order'))
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
if (!postalCodeInput.value) {
|
|
1543
|
+
throw new Error(
|
|
1544
|
+
i18next.t('text.zip/postal_code_is_empty_please_fill_in_the_data_before_proceed_create_order')
|
|
1545
|
+
)
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
if (!stateInput.value) {
|
|
1549
|
+
throw new Error(i18next.t('text.state_is_empty_please_fill_in_the_data_before_proceed_create_order'))
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
if (!cityInput.value) {
|
|
1553
|
+
throw new Error(i18next.t('text.city_is_empty_please_fill_in_the_data_before_proceed_create_order'))
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
if (!addressInput.value) {
|
|
1557
|
+
throw new Error(
|
|
1558
|
+
i18next.t('text.delivery_address_is_empty_please_fill_in_the_data_before_proceed_create_order')
|
|
1559
|
+
)
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
if (!contactInput.value) {
|
|
1563
|
+
throw new Error(i18next.t('text.contact_is_empty_please_fill_in_the_data_before_proceed_create_order'))
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
if (this.deliveryCountryInput.value == 'MY') {
|
|
1568
|
+
checkShipmentFields(
|
|
1569
|
+
this.attentionToInput,
|
|
1570
|
+
this.deliveryPostalCodeSelectInput,
|
|
1571
|
+
this.deliveryStateInput,
|
|
1572
|
+
this.deliveryCityInput,
|
|
1573
|
+
this.deliveryAddressInput,
|
|
1574
|
+
this.deliveryContactInput
|
|
1575
|
+
)
|
|
1576
|
+
} else {
|
|
1577
|
+
checkShipmentFields(
|
|
1578
|
+
this.attentionToInput,
|
|
1579
|
+
this.deliveryPostalCodeInput,
|
|
1580
|
+
this.deliveryStateInput,
|
|
1581
|
+
this.deliveryCityInput,
|
|
1582
|
+
this.deliveryAddressInput,
|
|
1583
|
+
this.deliveryContactInput
|
|
1584
|
+
)
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1587
|
+
// if (!this.matchDeliveryAddressInput.checked) {
|
|
1588
|
+
// if (this.billingCountryInput.value == 'MY') {
|
|
1589
|
+
// checkShipmentFields(
|
|
1590
|
+
// this.billingPostalCodeSelectInput,
|
|
1591
|
+
// this.billingStateInput,
|
|
1592
|
+
// this.billingCityInput,
|
|
1593
|
+
// this.billingAddressInput
|
|
1594
|
+
// )
|
|
1595
|
+
// } else if (!this.billingCountryInput.value == 'MY') {
|
|
1596
|
+
// checkShipmentFields(
|
|
1597
|
+
// this.billingPostalCodeInput,
|
|
1598
|
+
// this.billingStateInput,
|
|
1599
|
+
// this.billingCityInput,
|
|
1600
|
+
// this.billingAddressInput
|
|
1601
|
+
// )
|
|
1602
|
+
// }
|
|
1603
|
+
// }
|
|
1604
|
+
if (!this.billingAddressInput.value && !this.matchDeliveryAddressInput.checked) {
|
|
1605
|
+
throw new Error(i18next.t('text.billing_address_is_empty_please_fill_in_the_data_before_proceed_create_order'))
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1609
|
+
if (this.shippingOrderForm && !this.shippingOrderForm.checkValidity()) {
|
|
1610
|
+
throw new Error(i18next.t('text.shipping_order_form_invalid'))
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1613
|
+
if (this._invoiceDocument?.files?.length > 1) {
|
|
1614
|
+
throw new Error(i18next.t('text.only_one_file_is_allowed_for_both_invoice_upload'))
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
if (this._awbDocument?.files?.length > 1) {
|
|
1618
|
+
throw new Error(i18next.t('text.only_one_file_is_allowed_for_both_AWB_upload'))
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
_validateInventories() {
|
|
1623
|
+
const inventories = this.inventoryGrist?.dirtyData?.records
|
|
1624
|
+
if (!inventories?.length) throw new Error(i18next.t('text.no_products'))
|
|
1625
|
+
// required field (batchId, packingType, uomValue, unit, packQty)
|
|
1626
|
+
if (!inventories.every(record => record.releaseQty && record.batchId && record.packingType)) {
|
|
1627
|
+
throw new Error(i18next.t('text.empty_value_in_list'))
|
|
1628
|
+
}
|
|
1629
|
+
|
|
1630
|
+
if (inventories.some(({ releaseQty }) => releaseQty < 0)) {
|
|
1631
|
+
throw new Error(i18next.t('text.x_should_be_positive', { state: { x: i18next.t('label.release_qty') } }))
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1634
|
+
if (inventories.some(({ releaseUomValue }) => releaseUomValue < 0)) {
|
|
1635
|
+
throw new Error(i18next.t('text.x_should_be_positive', { state: { x: i18next.t('label.release_uom_value') } }))
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
|
+
if (inventories.some(record => record.releaseQty > record.remainQty)) {
|
|
1639
|
+
throw new Error(i18next.t('text.invalid_quantity_input'))
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
if (this._pickingStd === PICKING_STANDARD.SELECT_BY_PALLET.value) {
|
|
1643
|
+
// duplication of pallet id
|
|
1644
|
+
const palletIds = inventories.map(inv => inv.palletId)
|
|
1645
|
+
if (palletIds.some((palletId, idx, palletIds) => palletIds.indexOf(palletId) !== idx)) {
|
|
1646
|
+
throw new Error(i18next.t('text.lot_id_is_duplicated'))
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
|
|
1650
|
+
if (inventories.some(record => record.locationType == 'DAMAGE') && recall == false) {
|
|
1651
|
+
throw new Error(i18next.t('text.there_are_damaged_inventories'))
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
|
|
1655
|
+
async _openBulkProductSelection(type, rowIndex, record) {
|
|
1656
|
+
if (this._bizplaceId) {
|
|
1657
|
+
openPopup(
|
|
1658
|
+
html`
|
|
1659
|
+
<select-inventory-popup
|
|
1660
|
+
.bizplaceId="${this._bizplaceId}"
|
|
1661
|
+
.selectMultipleProducts="${true}"
|
|
1662
|
+
.switchTypePane="${type}"
|
|
1663
|
+
.inventoryData="${this.inventoryGrist.dirtyData.records}"
|
|
1664
|
+
@selected="${e => {
|
|
1665
|
+
let newRecords = []
|
|
1666
|
+
for (let i = 0; i < e.detail.multipleProducts.length; i++) {
|
|
1667
|
+
newRecords.push(e.detail.multipleProducts[i])
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1670
|
+
if (newRecords.length > 1) {
|
|
1671
|
+
this.inventoryData = {
|
|
1672
|
+
...this.inventoryData,
|
|
1673
|
+
records: [...this.inventoryGrist.dirtyData.records, ...newRecords]
|
|
1674
|
+
}
|
|
1675
|
+
} else {
|
|
1676
|
+
// update existing inventory data records
|
|
1677
|
+
this.inventoryGrist.dirtyData.records.splice(rowIndex, 1, {
|
|
1678
|
+
...this.inventoryGrist.dirtyData.records[rowIndex],
|
|
1679
|
+
...newRecords[0]
|
|
1680
|
+
})
|
|
1681
|
+
this.inventoryData = {
|
|
1682
|
+
...this.inventoryData,
|
|
1683
|
+
records: [...this.inventoryGrist.dirtyData.records]
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
}}"
|
|
1687
|
+
></select-inventory-popup>
|
|
1688
|
+
`,
|
|
1689
|
+
{
|
|
1690
|
+
backdrop: true,
|
|
1691
|
+
size: 'large',
|
|
1692
|
+
title: i18next.t('title.select_item')
|
|
1693
|
+
}
|
|
1694
|
+
)
|
|
1695
|
+
} else {
|
|
1696
|
+
this._showToast({ message: i18next.t('text.company_selection_is_empty') })
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
_updateInventoryGristConfig() {
|
|
1701
|
+
if (this._pickingStd === PICKING_STANDARD.SELECT_BY_PRODUCT.value) {
|
|
1702
|
+
const _selectedInv = (this.inventoryGrist.dirtyData.records || [])
|
|
1703
|
+
.filter(record => !record.isCrossDocking)
|
|
1704
|
+
.map(record => {
|
|
1705
|
+
return {
|
|
1706
|
+
batchId: record?.inventory?.batchId,
|
|
1707
|
+
packingType: record?.inventory?.packingType,
|
|
1708
|
+
packingSize: record?.inventory?.packingSize,
|
|
1709
|
+
productId: record?.inventory?.productId,
|
|
1710
|
+
productDetailId: record?.inventory?.productDetailId,
|
|
1711
|
+
groupType: record?.inventory?.groupType,
|
|
1712
|
+
releaseQty: record.releaseQty || 0,
|
|
1713
|
+
releaseUomValue: record.releaseUomValue || 0
|
|
1714
|
+
}
|
|
1715
|
+
})
|
|
1716
|
+
|
|
1717
|
+
this.inventoryGristConfig = {
|
|
1718
|
+
...this.inventoryGristConfig,
|
|
1719
|
+
columns: this.inventoryGristConfig.columns.map(column => {
|
|
1720
|
+
if (column.name === 'inventory') {
|
|
1721
|
+
column.record.options.basicArgs = {
|
|
1722
|
+
...column.record.options.basicArgs,
|
|
1723
|
+
filters: [
|
|
1724
|
+
...column.record.options.basicArgs.filters.filter(
|
|
1725
|
+
filter => filter.name !== 'batch_product' && filter.name !== 'batch_bundle'
|
|
1726
|
+
)
|
|
1727
|
+
]
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1730
|
+
if (_selectedInv.length) {
|
|
1731
|
+
const _selectedSingleInv = _selectedInv.filter(inv => inv.groupType === GROUP_TYPES.SINGLE.value)
|
|
1732
|
+
const _selectedBundleInv = _selectedInv.filter(inv => inv.groupType === GROUP_TYPES.BUNDLE.value)
|
|
1733
|
+
|
|
1734
|
+
if (_selectedSingleInv.length)
|
|
1735
|
+
column.record.options.basicArgs.filters.push({
|
|
1736
|
+
name: 'batch_product',
|
|
1737
|
+
value: _selectedSingleInv,
|
|
1738
|
+
operator: 'notin'
|
|
1739
|
+
})
|
|
1740
|
+
|
|
1741
|
+
if (_selectedBundleInv.length)
|
|
1742
|
+
column.record.options.basicArgs.filters.push({
|
|
1743
|
+
name: 'batch_bundle',
|
|
1744
|
+
value: _selectedBundleInv,
|
|
1745
|
+
operator: 'notin'
|
|
1746
|
+
})
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
return column
|
|
1751
|
+
})
|
|
1752
|
+
}
|
|
1753
|
+
} else {
|
|
1754
|
+
const _selectedInventories = (this.inventoryGrist.dirtyData.records || []).map(record => record.inventory.id)
|
|
1755
|
+
this.inventoryGristConfig = {
|
|
1756
|
+
...this.inventoryGristConfig,
|
|
1757
|
+
columns: this.inventoryGristConfig.columns.map(column => {
|
|
1758
|
+
if (column.name === 'inventory') {
|
|
1759
|
+
column.record.options.basicArgs = {
|
|
1760
|
+
...column.record.options.basicArgs,
|
|
1761
|
+
filters: [...column.record.options.basicArgs.filters.filter(filter => filter.name !== 'id')]
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1764
|
+
if (_selectedInventories.length)
|
|
1765
|
+
column.record.options.basicArgs.filters = [
|
|
1766
|
+
...column.record.options.basicArgs.filters,
|
|
1767
|
+
{
|
|
1768
|
+
name: 'id',
|
|
1769
|
+
value: _selectedInventories,
|
|
1770
|
+
operator: 'notin'
|
|
1771
|
+
}
|
|
1772
|
+
]
|
|
1773
|
+
}
|
|
1774
|
+
|
|
1775
|
+
return column
|
|
1776
|
+
})
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
|
|
1781
|
+
_clearGristConditions() {
|
|
1782
|
+
if (this.inventoryGristConfig?.columns?.length) {
|
|
1783
|
+
this.inventoryGristConfig = {
|
|
1784
|
+
...this.inventoryGristConfig,
|
|
1785
|
+
columns: this.inventoryGristConfig.columns.map(column => {
|
|
1786
|
+
if (column.name === 'inventory') {
|
|
1787
|
+
column.record.options.basicArgs = {
|
|
1788
|
+
filters: column.record.options.basicArgs.filters.filter(
|
|
1789
|
+
filter => filter.name !== 'batch_product' && filter.name !== 'id'
|
|
1790
|
+
)
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1793
|
+
|
|
1794
|
+
return column
|
|
1795
|
+
})
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
}
|
|
1799
|
+
|
|
1800
|
+
async _getOrderInventories() {
|
|
1801
|
+
const bundleOrderInventories = []
|
|
1802
|
+
|
|
1803
|
+
//// Note: need to relook into the logic. Might get performance issue when theres many order, client server round trip too many.
|
|
1804
|
+
await Promise.all(
|
|
1805
|
+
this.inventoryGrist.data.records
|
|
1806
|
+
.filter(
|
|
1807
|
+
record =>
|
|
1808
|
+
this._pickingStd === PICKING_STANDARD.SELECT_BY_PRODUCT.value &&
|
|
1809
|
+
record.inventory.groupType === GROUP_TYPES.BUNDLE.value
|
|
1810
|
+
)
|
|
1811
|
+
.map(async record => {
|
|
1812
|
+
let bundleReleaseDetail = await this.fetchInventoriesByBundle(record.inventory.productId, record.releaseQty)
|
|
1813
|
+
bundleReleaseDetail = bundleReleaseDetail.records.map(item => {
|
|
1814
|
+
return {
|
|
1815
|
+
product: { id: item.productId, name: item.productName },
|
|
1816
|
+
productDetail: { id: item.productDetailId },
|
|
1817
|
+
batchId: item.batchId,
|
|
1818
|
+
packingType: item.packingType,
|
|
1819
|
+
packingSize: item.packingSize,
|
|
1820
|
+
type: ORDER_TYPES.RELEASE_OF_GOODS.value,
|
|
1821
|
+
status: ORDER_INVENTORY_STATUS.PENDING.value,
|
|
1822
|
+
releaseQty: item.releaseQty,
|
|
1823
|
+
releaseUomValue: item.releaseUomValue,
|
|
1824
|
+
uom: item.uom
|
|
1825
|
+
}
|
|
1826
|
+
})
|
|
1827
|
+
bundleOrderInventories.push(...bundleReleaseDetail)
|
|
1828
|
+
})
|
|
1829
|
+
)
|
|
1830
|
+
|
|
1831
|
+
const singleOrderInventories = this.inventoryGrist.data.records
|
|
1832
|
+
.filter(record => record.inventory.groupType !== GROUP_TYPES.BUNDLE.value)
|
|
1833
|
+
.map(record => {
|
|
1834
|
+
let newRecord = {
|
|
1835
|
+
releaseQty: record.releaseQty,
|
|
1836
|
+
releaseUomValue: record.releaseUomValue,
|
|
1837
|
+
batchId: record.inventory.batchId,
|
|
1838
|
+
batchIdRef: record.inventory.batchIdRef,
|
|
1839
|
+
packingType: record.inventory.packingType,
|
|
1840
|
+
packingSize: record.inventory.packingSize,
|
|
1841
|
+
type: ORDER_TYPES.RELEASE_OF_GOODS.value,
|
|
1842
|
+
status: ORDER_INVENTORY_STATUS.PENDING.value,
|
|
1843
|
+
uom: record.inventory.uom
|
|
1844
|
+
}
|
|
1845
|
+
|
|
1846
|
+
if (record.isCrossDocking) newRecord.crossDocking = true
|
|
1847
|
+
|
|
1848
|
+
if (this._pickingStd === PICKING_STANDARD.SELECT_BY_PRODUCT.value) {
|
|
1849
|
+
newRecord.product = {
|
|
1850
|
+
id: record.inventory.productId,
|
|
1851
|
+
name: record.inventory.productName
|
|
1852
|
+
}
|
|
1853
|
+
newRecord.productDetail = {
|
|
1854
|
+
id: record.inventory.productDetailId
|
|
1855
|
+
}
|
|
1856
|
+
} else {
|
|
1857
|
+
newRecord.product = {
|
|
1858
|
+
id: record.inventory.productId || record.inventory.product.id,
|
|
1859
|
+
name: record.inventory.productName || record.inventory.product.name
|
|
1860
|
+
}
|
|
1861
|
+
newRecord.productDetail = {
|
|
1862
|
+
id: record.inventory.productDetailId || record.inventory.productDetail.id
|
|
1863
|
+
}
|
|
1864
|
+
newRecord.inventory = { id: record.id }
|
|
1865
|
+
}
|
|
1866
|
+
|
|
1867
|
+
return newRecord
|
|
1868
|
+
})
|
|
1869
|
+
|
|
1870
|
+
let orderInventories = [...bundleOrderInventories, ...singleOrderInventories]
|
|
1871
|
+
|
|
1872
|
+
if (this._pickingStd === PICKING_STANDARD.SELECT_BY_PRODUCT.value) {
|
|
1873
|
+
// return the merged bundle and single order inventories
|
|
1874
|
+
let data = orderInventories.reduce((acc, curr) => {
|
|
1875
|
+
let exsitingDataIndex = acc.findIndex(
|
|
1876
|
+
x => x.product.id === curr.product.id && x.batchId === curr.batchId && x.packingType === curr.packingType
|
|
1877
|
+
)
|
|
1878
|
+
|
|
1879
|
+
if (exsitingDataIndex >= 0) {
|
|
1880
|
+
acc[exsitingDataIndex].releaseQty += curr.releaseQty
|
|
1881
|
+
acc[exsitingDataIndex].releaseUomValue += curr.releaseUomValue
|
|
1882
|
+
} else {
|
|
1883
|
+
acc.push({ ...curr })
|
|
1884
|
+
}
|
|
1885
|
+
|
|
1886
|
+
return acc
|
|
1887
|
+
}, [])
|
|
1888
|
+
|
|
1889
|
+
return data
|
|
1890
|
+
} else {
|
|
1891
|
+
return orderInventories
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1895
|
+
_validateCountry(e) {
|
|
1896
|
+
if (e.target.value != 'MY') {
|
|
1897
|
+
this._switchDeliveryCountryInput = true
|
|
1898
|
+
} else {
|
|
1899
|
+
this._switchDeliveryCountryInput = false
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1903
|
+
_validateBillingCountry(e) {
|
|
1904
|
+
if (e.target.value != 'MY') {
|
|
1905
|
+
this._switchBillingCountryInput = true
|
|
1906
|
+
this._selectedBillingCountry = e.target.value
|
|
1907
|
+
} else {
|
|
1908
|
+
this._switchBillingCountryInput = false
|
|
1909
|
+
this._selectedBillingCountry = e.target.value
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
|
|
1913
|
+
async _getAllPostCode() {
|
|
1914
|
+
try {
|
|
1915
|
+
const response = await client.query({
|
|
1916
|
+
query: gql`
|
|
1917
|
+
query geoAreasAllPostCode {
|
|
1918
|
+
geoAreasAllPostCode {
|
|
1919
|
+
items {
|
|
1920
|
+
postalCode
|
|
1921
|
+
}
|
|
1922
|
+
total
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
`
|
|
1926
|
+
})
|
|
1927
|
+
|
|
1928
|
+
if (!response.errors) {
|
|
1929
|
+
const items = response.data.geoAreasAllPostCode.items
|
|
1930
|
+
this._deliveryPostCode = items
|
|
1931
|
+
this._billingPostCode = items
|
|
1932
|
+
}
|
|
1933
|
+
} catch (e) {
|
|
1934
|
+
this._showToast(e)
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
|
|
1938
|
+
async _getStateAndCityByPostCode(value, name) {
|
|
1939
|
+
const postCode = value
|
|
1940
|
+
|
|
1941
|
+
// If user select the first empty postal code, the city and state will change to empty
|
|
1942
|
+
if (postCode == '') {
|
|
1943
|
+
if (name == 'postalCode') {
|
|
1944
|
+
this._cityInput.value = ''
|
|
1945
|
+
this._stateInput.value = ''
|
|
1946
|
+
return
|
|
1947
|
+
} else if (name == 'billingPostalCode') {
|
|
1948
|
+
this._cityBillingInput.value = ''
|
|
1949
|
+
this._stateBillingInput.value = ''
|
|
1950
|
+
return
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1954
|
+
try {
|
|
1955
|
+
const response = await client.query({
|
|
1956
|
+
query: gql`
|
|
1957
|
+
query geoAreasGetStateAndCityByPosCode($postCode: String!) {
|
|
1958
|
+
geoAreasGetStateAndCityByPosCode(postCode: $postCode) {
|
|
1959
|
+
stateName
|
|
1960
|
+
cityName
|
|
1961
|
+
}
|
|
1962
|
+
}
|
|
1963
|
+
`,
|
|
1964
|
+
variables: {
|
|
1965
|
+
postCode
|
|
1966
|
+
}
|
|
1967
|
+
})
|
|
1968
|
+
|
|
1969
|
+
if (!response.errors) {
|
|
1970
|
+
const { stateName, cityName } = response.data.geoAreasGetStateAndCityByPosCode
|
|
1971
|
+
|
|
1972
|
+
switch (name) {
|
|
1973
|
+
case 'postalCode':
|
|
1974
|
+
this._deliveryCity = cityName.toUpperCase()
|
|
1975
|
+
this._deliveryState = stateName
|
|
1976
|
+
break
|
|
1977
|
+
|
|
1978
|
+
case 'billingPostalCode':
|
|
1979
|
+
this._billingCity = cityName.toUpperCase()
|
|
1980
|
+
this._billingState = stateName
|
|
1981
|
+
|
|
1982
|
+
default:
|
|
1983
|
+
break
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1986
|
+
} catch (error) {
|
|
1987
|
+
this._showToast(e)
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
|
|
1991
|
+
_serializeForm(form) {
|
|
1992
|
+
let obj = {}
|
|
1993
|
+
Array.from(form.querySelectorAll('input, select,textarea')).forEach(field => {
|
|
1994
|
+
if (!field.hasAttribute('hidden') && field.value) {
|
|
1995
|
+
obj[field.name] = field.type === 'checkbox' ? field.checked : field.value
|
|
1996
|
+
}
|
|
1997
|
+
})
|
|
1998
|
+
|
|
1999
|
+
return obj
|
|
2000
|
+
}
|
|
2001
|
+
|
|
2002
|
+
checkInventoryValidity() {
|
|
2003
|
+
const inventories = this.inventoryGrist?.dirtyData?.records
|
|
2004
|
+
if (!inventories?.length) throw new Error(i18next.t('text.there_is_no_inventory'))
|
|
2005
|
+
|
|
2006
|
+
if (this._pickingStd === PICKING_STANDARD.SELECT_BY_PALLET && inventories.some(record => !record?.inventory?.id))
|
|
2007
|
+
throw new Error(i18next.t('text.invalid_inventory'))
|
|
2008
|
+
|
|
2009
|
+
if (inventories.some(record => !record.releaseQty)) throw new Error(i18next.t('text.invalid_release_qty'))
|
|
2010
|
+
}
|
|
2011
|
+
|
|
2012
|
+
_openBizplacesSelector() {
|
|
2013
|
+
openPopup(
|
|
2014
|
+
html`
|
|
2015
|
+
<popup-partner-bizplaces-selector
|
|
2016
|
+
@selected="${e => {
|
|
2017
|
+
this._bizplaceId = e.detail.id
|
|
2018
|
+
this._bizplaceName = e.detail.name
|
|
2019
|
+
this.switchPickingType()
|
|
2020
|
+
this.inventoryGrist.reset()
|
|
2021
|
+
this._clearView()
|
|
2022
|
+
// this._resetShippingInfoForm()
|
|
2023
|
+
this.fetchCountry()
|
|
2024
|
+
}}"
|
|
2025
|
+
></popup-partner-bizplaces-selector>
|
|
2026
|
+
`,
|
|
2027
|
+
{
|
|
2028
|
+
backdrop: true,
|
|
2029
|
+
size: 'large',
|
|
2030
|
+
title: i18next.t('title.select_company')
|
|
2031
|
+
}
|
|
2032
|
+
)
|
|
2033
|
+
}
|
|
2034
|
+
|
|
2035
|
+
async bulkUploadValidateWarehousePartnersProductsQuantity(orderInventories) {
|
|
2036
|
+
const response = await client.query({
|
|
2037
|
+
query: gql`
|
|
2038
|
+
query bulkUploadValidateWarehousePartnersProductsQuantity(
|
|
2039
|
+
$orderInventories: [NewOrderInventory!]
|
|
2040
|
+
$partnerBizplaceId: String!
|
|
2041
|
+
) {
|
|
2042
|
+
bulkUploadValidateWarehousePartnersProductsQuantity(
|
|
2043
|
+
orderInventories: $orderInventories
|
|
2044
|
+
partnerBizplaceId: $partnerBizplaceId
|
|
2045
|
+
) {
|
|
2046
|
+
id
|
|
2047
|
+
name
|
|
2048
|
+
description
|
|
2049
|
+
batchId
|
|
2050
|
+
batchIdRef
|
|
2051
|
+
productId
|
|
2052
|
+
productDetailId
|
|
2053
|
+
productSKU
|
|
2054
|
+
productName
|
|
2055
|
+
remainQty
|
|
2056
|
+
remainUomValue
|
|
2057
|
+
remainUomValueWithUom
|
|
2058
|
+
packingType
|
|
2059
|
+
packingSize
|
|
2060
|
+
uom
|
|
2061
|
+
releaseQty
|
|
2062
|
+
releaseUomValue
|
|
2063
|
+
isError
|
|
2064
|
+
groupType
|
|
2065
|
+
inventory {
|
|
2066
|
+
batchId
|
|
2067
|
+
batchIdRef
|
|
2068
|
+
productId
|
|
2069
|
+
productDetailId
|
|
2070
|
+
productSKU
|
|
2071
|
+
productName
|
|
2072
|
+
remainQty
|
|
2073
|
+
remainUomValue
|
|
2074
|
+
remainUomValueWithUom
|
|
2075
|
+
packingType
|
|
2076
|
+
packingSize
|
|
2077
|
+
uom
|
|
2078
|
+
}
|
|
2079
|
+
product {
|
|
2080
|
+
id
|
|
2081
|
+
name
|
|
2082
|
+
sku
|
|
2083
|
+
}
|
|
2084
|
+
productDetail {
|
|
2085
|
+
id
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
`,
|
|
2090
|
+
variables: { orderInventories, partnerBizplaceId: this._bizplaceId }
|
|
2091
|
+
})
|
|
2092
|
+
|
|
2093
|
+
if (!response.errors) {
|
|
2094
|
+
const data = response.data.bulkUploadValidateWarehousePartnersProductsQuantity
|
|
2095
|
+
this.inventoryGrist.dirtyData.records = data.records
|
|
2096
|
+
this.inventoryData = {
|
|
2097
|
+
...this.inventoryData,
|
|
2098
|
+
...this.inventoryGrist.dirtyData,
|
|
2099
|
+
records: data.map((dt, idx) => {
|
|
2100
|
+
return {
|
|
2101
|
+
...dt,
|
|
2102
|
+
id: idx,
|
|
2103
|
+
name: idx,
|
|
2104
|
+
__dirty__: '+'
|
|
2105
|
+
}
|
|
2106
|
+
})
|
|
2107
|
+
}
|
|
2108
|
+
|
|
2109
|
+
this._updateInventoryGristConfig()
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2112
|
+
|
|
2113
|
+
getExcelColumns() {
|
|
2114
|
+
return [
|
|
2115
|
+
{
|
|
2116
|
+
type: 'string',
|
|
2117
|
+
name: 'productSKU',
|
|
2118
|
+
header: i18next.t('field.sku'),
|
|
2119
|
+
imex: { header: i18next.t('field.sku'), key: 'productSKU', width: 25, type: 'string' },
|
|
2120
|
+
width: 100
|
|
2121
|
+
},
|
|
2122
|
+
{
|
|
2123
|
+
type: 'string',
|
|
2124
|
+
name: 'packingType',
|
|
2125
|
+
header: i18next.t('field.packing_type'),
|
|
2126
|
+
imex: {
|
|
2127
|
+
header: i18next.t('field.packing_type'),
|
|
2128
|
+
key: 'packingType',
|
|
2129
|
+
width: 20,
|
|
2130
|
+
type: 'string'
|
|
2131
|
+
},
|
|
2132
|
+
width: 150
|
|
2133
|
+
},
|
|
2134
|
+
{
|
|
2135
|
+
type: 'integer',
|
|
2136
|
+
name: 'releaseQty',
|
|
2137
|
+
header: i18next.t('field.release_qty'),
|
|
2138
|
+
imex: { header: i18next.t('field.release_qty'), key: 'releaseQty', width: 25, type: 'float' },
|
|
2139
|
+
width: 140
|
|
2140
|
+
}
|
|
2141
|
+
]
|
|
2142
|
+
}
|
|
2143
|
+
|
|
2144
|
+
async _exportableData() {
|
|
2145
|
+
try {
|
|
2146
|
+
var headerSetting = [
|
|
2147
|
+
...this.getExcelColumns()
|
|
2148
|
+
.filter(column => column.type !== 'gutter' && column.imex !== undefined)
|
|
2149
|
+
.map(column => {
|
|
2150
|
+
return column.imex
|
|
2151
|
+
})
|
|
2152
|
+
]
|
|
2153
|
+
|
|
2154
|
+
return { header: headerSetting, data: [] }
|
|
2155
|
+
} catch (e) {
|
|
2156
|
+
this._showToast(e)
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
2159
|
+
|
|
2160
|
+
async importHandler(patches) {
|
|
2161
|
+
try {
|
|
2162
|
+
const orderInventories = patches.reduce((acc, patch) => {
|
|
2163
|
+
delete patch.cuFlag
|
|
2164
|
+
let idxExistingData = acc.findIndex(i => i.productSKU == patch.productSKU && i.packingType == patch.packingType)
|
|
2165
|
+
|
|
2166
|
+
if (idxExistingData >= 0) {
|
|
2167
|
+
acc[idxExistingData].releaseQty = acc[idxExistingData].releaseQty + patch.releaseQty
|
|
2168
|
+
} else {
|
|
2169
|
+
acc.push(patch)
|
|
2170
|
+
}
|
|
2171
|
+
return acc
|
|
2172
|
+
}, [])
|
|
2173
|
+
|
|
2174
|
+
// validate releaseQty
|
|
2175
|
+
// only positive integers permitted
|
|
2176
|
+
for (const orderInventory of orderInventories) {
|
|
2177
|
+
const rQty = orderInventory.releaseQty
|
|
2178
|
+
if (!Number.isInteger(rQty)) throw new Error(`${rQty} ${i18next.t('text.is_not_an_integer')}`)
|
|
2179
|
+
if (rQty <= 0) throw new Error(i18next.t('text.release_qty_must_be_at_least_1'))
|
|
2180
|
+
|
|
2181
|
+
delete orderInventory.id
|
|
2182
|
+
}
|
|
2183
|
+
|
|
2184
|
+
this.inventoryData = {
|
|
2185
|
+
records: [...patches]
|
|
2186
|
+
}
|
|
2187
|
+
|
|
2188
|
+
await this.bulkUploadValidateWarehousePartnersProductsQuantity(orderInventories)
|
|
2189
|
+
|
|
2190
|
+
history.back()
|
|
2191
|
+
} catch (e) {
|
|
2192
|
+
this._showToast(e)
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
|
|
2196
|
+
async _importableData(records) {
|
|
2197
|
+
try {
|
|
2198
|
+
if (this._pickingStd === PICKING_STANDARD.SELECT_BY_PRODUCT.value) {
|
|
2199
|
+
if (this._bizplaceId) {
|
|
2200
|
+
records = records
|
|
2201
|
+
.filter(record => record.productSKU)
|
|
2202
|
+
.map(record => {
|
|
2203
|
+
return {
|
|
2204
|
+
...record,
|
|
2205
|
+
releaseQty: parseFloat(record.releaseQty) || null
|
|
2206
|
+
}
|
|
2207
|
+
})
|
|
2208
|
+
|
|
2209
|
+
let inventoryGristConfigExcel = {
|
|
2210
|
+
pagination: { infinite: true },
|
|
2211
|
+
rows: {
|
|
2212
|
+
selectable: { multiple: true, appendable: false },
|
|
2213
|
+
classifier: (record, rowIndex) => {
|
|
2214
|
+
return {
|
|
2215
|
+
emphasized: record.isCrossDocking
|
|
2216
|
+
}
|
|
2217
|
+
}
|
|
2218
|
+
},
|
|
2219
|
+
list: { fields: ['productSKU', 'packingType', 'releaseQty'] },
|
|
2220
|
+
columns: this.getExcelColumns()
|
|
2221
|
+
}
|
|
2222
|
+
|
|
2223
|
+
openPopup(
|
|
2224
|
+
html`
|
|
2225
|
+
<import-pop-up
|
|
2226
|
+
.records=${records}
|
|
2227
|
+
.config=${{
|
|
2228
|
+
rows: inventoryGristConfigExcel.rows,
|
|
2229
|
+
columns: [...inventoryGristConfigExcel.columns.filter(column => column.imex !== undefined)]
|
|
2230
|
+
}}
|
|
2231
|
+
.importHandler="${await this.importHandler.bind(this)}"
|
|
2232
|
+
></import-pop-up>
|
|
2233
|
+
`,
|
|
2234
|
+
{
|
|
2235
|
+
backdrop: true,
|
|
2236
|
+
escapable: false,
|
|
2237
|
+
size: 'large',
|
|
2238
|
+
title: i18next.t('title.import')
|
|
2239
|
+
}
|
|
2240
|
+
)
|
|
2241
|
+
} else {
|
|
2242
|
+
throw new Error(i18next.t('text.please_select_a_company'))
|
|
2243
|
+
}
|
|
2244
|
+
} else {
|
|
2245
|
+
throw new Error(`Excel import only available for Select By Product`)
|
|
2246
|
+
}
|
|
2247
|
+
} catch (e) {
|
|
2248
|
+
this._showToast(e)
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2251
|
+
|
|
2252
|
+
async _tabChange(key) {
|
|
2253
|
+
if (key == 'order') {
|
|
2254
|
+
this._showReleasedOrderInfo = false
|
|
2255
|
+
this._showShippingInfo = true
|
|
2256
|
+
} else if (key == 'shipment') {
|
|
2257
|
+
this._showReleasedOrderInfo = true
|
|
2258
|
+
this._showShippingInfo = false
|
|
2259
|
+
}
|
|
2260
|
+
}
|
|
2261
|
+
|
|
2262
|
+
_fillUpDeliveryInfo(data) {
|
|
2263
|
+
// remapping according release good table
|
|
2264
|
+
const remapData = {
|
|
2265
|
+
attentionCompany: data.companyName || '',
|
|
2266
|
+
attentionTo: data.name || '',
|
|
2267
|
+
city: data.city || '',
|
|
2268
|
+
state: data.state || '',
|
|
2269
|
+
postalCode: data.postCode || '',
|
|
2270
|
+
country: 'MY',
|
|
2271
|
+
phone1: data.phone || '',
|
|
2272
|
+
deliveryAddress1: data.address ? data.address : '' + data.address2 ? data.address2 : '',
|
|
2273
|
+
billingAddress: data.billingAddress
|
|
2274
|
+
}
|
|
2275
|
+
|
|
2276
|
+
this._selectedPostCode = data.postCode
|
|
2277
|
+
|
|
2278
|
+
this._fillupForm(this.shippingInfoForm, remapData)
|
|
2279
|
+
}
|
|
2280
|
+
|
|
2281
|
+
_resetShippingInfoForm() {
|
|
2282
|
+
this.shippingInfoForm.reset()
|
|
2283
|
+
}
|
|
2284
|
+
|
|
2285
|
+
_resetExportInfoForm() {
|
|
2286
|
+
this._containerClosureDate = ''
|
|
2287
|
+
}
|
|
2288
|
+
|
|
2289
|
+
_fillupForm(form, data) {
|
|
2290
|
+
if (form) {
|
|
2291
|
+
form.reset()
|
|
2292
|
+
for (let key in data) {
|
|
2293
|
+
Array.from(form.querySelectorAll('input, textarea', 'select')).forEach(field => {
|
|
2294
|
+
if (field.name === key && field.type === 'checkbox') {
|
|
2295
|
+
field.checked = data[key]
|
|
2296
|
+
} else if (field.name === key && field.type === 'datetime-local') {
|
|
2297
|
+
const datetime = Number(data[key])
|
|
2298
|
+
const timezoneOffset = new Date(datetime).getTimezoneOffset() * 60000
|
|
2299
|
+
field.value = new Date(datetime - timezoneOffset).toISOString().slice(0, -1)
|
|
2300
|
+
} else if (field.name === key) {
|
|
2301
|
+
if (data[key] instanceof Object) {
|
|
2302
|
+
const objectData = data[key]
|
|
2303
|
+
field.value = `${objectData.name} ${objectData.description ? `(${objectData.description})` : ''}`
|
|
2304
|
+
} else {
|
|
2305
|
+
field.value = data[key]
|
|
2306
|
+
}
|
|
2307
|
+
}
|
|
2308
|
+
})
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
}
|
|
2312
|
+
|
|
2313
|
+
async checkActiveLmd() {
|
|
2314
|
+
const response = await client.query({
|
|
2315
|
+
query: gql`
|
|
2316
|
+
query checkActiveLastMileDelivery {
|
|
2317
|
+
checkActiveLastMileDelivery
|
|
2318
|
+
}
|
|
2319
|
+
`
|
|
2320
|
+
})
|
|
2321
|
+
|
|
2322
|
+
if (!response.error) {
|
|
2323
|
+
this._isLmdExists = response.data.checkActiveLastMileDelivery
|
|
2324
|
+
}
|
|
2325
|
+
}
|
|
2326
|
+
|
|
2327
|
+
sortByNameField(items, nameField, nameField2) {
|
|
2328
|
+
if (nameField2) {
|
|
2329
|
+
items?.sort((a, b) => {
|
|
2330
|
+
if (a[nameField] == b[nameField]) {
|
|
2331
|
+
return a[nameField2] > b[nameField2] ? 1 : a[nameField2] < b[nameField2] ? -1 : 0
|
|
2332
|
+
} else {
|
|
2333
|
+
return a[nameField] > b[nameField] ? 1 : a[nameField] < b[nameField] ? -1 : 0
|
|
2334
|
+
}
|
|
2335
|
+
})
|
|
2336
|
+
} else {
|
|
2337
|
+
items?.sort((a, b) => (a[nameField] > b[nameField] ? 1 : a[nameField] < b[nameField] ? -1 : 0))
|
|
2338
|
+
}
|
|
2339
|
+
|
|
2340
|
+
return items
|
|
2341
|
+
}
|
|
2342
|
+
|
|
2343
|
+
_showToast({ type, message }) {
|
|
2344
|
+
document.dispatchEvent(
|
|
2345
|
+
new CustomEvent('notify', {
|
|
2346
|
+
detail: {
|
|
2347
|
+
type,
|
|
2348
|
+
message
|
|
2349
|
+
}
|
|
2350
|
+
})
|
|
2351
|
+
)
|
|
2352
|
+
}
|
|
2353
|
+
}
|
|
2354
|
+
window.customElements.define('create-b2c-release-order', CreateB2CReleaseOrder)
|