@things-factory/operato-wms 4.3.186 → 4.3.188

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.
Files changed (30) hide show
  1. package/client/pages/constants/index.js +3 -0
  2. package/client/pages/constants/location.js +4 -0
  3. package/client/pages/constants/order.js +3 -1
  4. package/client/pages/constants/replenishment-config.js +161 -0
  5. package/client/pages/constants/replenishment.js +22 -0
  6. package/client/pages/constants/worksheet-replenishment-config.js +119 -0
  7. package/client/pages/constants/worksheet.js +8 -0
  8. package/client/pages/inbound/putaway-product.js +185 -11
  9. package/client/pages/inbound/undo-putaway-popup.js +39 -2
  10. package/client/pages/inbound/unload-product.js +126 -14
  11. package/client/pages/inventory/inventory-by-product.js +23 -1
  12. package/client/pages/order/draft-release-good/draft-release-good-detail.js +7 -0
  13. package/client/pages/outbound/picking-product.js +104 -32
  14. package/client/pages/replenishment/replenishment-detail.js +429 -0
  15. package/client/pages/replenishment/replenishment-worksheet-list.js +470 -0
  16. package/client/pages/replenishment/replenishment.js +510 -0
  17. package/client/pages/replenishment/worksheet-replenishment.js +414 -0
  18. package/client/route.js +17 -0
  19. package/config.development.js +28 -21
  20. package/helps/release-note.ko.md +4 -4
  21. package/helps/release-note.md +4 -4
  22. package/helps/release-note.ms.md +4 -4
  23. package/helps/release-note.zh.md +4 -4
  24. package/package.json +6 -6
  25. package/things-factory.config.js +18 -0
  26. package/translations/en.json +35 -9
  27. package/translations/ko.json +26 -1
  28. package/translations/ms.json +26 -1
  29. package/translations/zh.json +26 -1
  30. package/config.production.js +0 -104
@@ -0,0 +1,510 @@
1
+ import '@things-factory/grist-ui'
2
+ import '@things-factory/barcode-ui'
3
+
4
+ import gql from 'graphql-tag'
5
+ import { css, html } from 'lit-element'
6
+
7
+ import { MultiColumnFormStyles } from '@things-factory/form-ui'
8
+ import { i18next, localize } from '@things-factory/i18n-base'
9
+ import { client, CustomAlert, navigate, PageView } from '@things-factory/shell'
10
+ import { CommonButtonStyles } from '@things-factory/styles'
11
+ import { isMobileDevice } from '@things-factory/utils'
12
+ import { REPLENISHMENT_CONFIG, ORDER_TYPES, ORDER_STATUS } from '../constants'
13
+ import { showToast } from '../../util/index'
14
+ import { getCodeByName } from '@things-factory/code-base'
15
+
16
+ class Replenishment extends localize(i18next)(PageView) {
17
+ static get styles() {
18
+ return [
19
+ MultiColumnFormStyles,
20
+ css`
21
+ :host {
22
+ display: flex;
23
+ flex-direction: column;
24
+ overflow-x: auto;
25
+ }
26
+ .form-container {
27
+ display: flex;
28
+ }
29
+ .form-container > form {
30
+ flex: 1;
31
+ }
32
+ .container {
33
+ flex: 1;
34
+ display: flex;
35
+ overflow-y: auto;
36
+ min-height: 50vh;
37
+ }
38
+ .grist {
39
+ background-color: var(--main-section-background-color);
40
+ display: flex;
41
+ flex-direction: column;
42
+ flex: 1;
43
+ overflow-y: auto;
44
+ }
45
+ data-grist {
46
+ overflow-y: hidden;
47
+ flex: 1;
48
+ }
49
+ barcode-tag {
50
+ width: 100px;
51
+ height: 100px;
52
+ margin: 10px;
53
+ }
54
+ h2 {
55
+ padding: var(--subtitle-padding);
56
+ font: var(--subtitle-font);
57
+ color: var(--subtitle-text-color);
58
+ border-bottom: var(--subtitle-border-bottom);
59
+ }
60
+ .grist h2 {
61
+ margin: var(--grist-title-margin);
62
+ border: var(--grist-title-border);
63
+ font: var(--grist-title-font);
64
+ color: var(--secondary-color);
65
+ }
66
+
67
+ .grist h2 mwc-icon {
68
+ vertical-align: middle;
69
+ margin: var(--grist-title-icon-margin);
70
+ font-size: var(--grist-title-icon-size);
71
+ color: var(--grist-title-icon-color);
72
+ }
73
+
74
+ h2 + data-grist {
75
+ padding-top: var(--grist-title-with-grid-padding);
76
+ }
77
+
78
+ search-form {
79
+ overflow: visible;
80
+ }
81
+ `
82
+ ]
83
+ }
84
+
85
+ static get properties() {
86
+ return {
87
+ searchFields: Array,
88
+ config: Object,
89
+ _pageType: String,
90
+ _status: String,
91
+ _orderNo: String
92
+ }
93
+ }
94
+
95
+ get context() {
96
+ switch (this._pageType) {
97
+ case 'create':
98
+ return {
99
+ title: i18next.t('title.create_replenishment'),
100
+ actions: [
101
+ {
102
+ title: i18next.t('button.create_replenishment'),
103
+ action: this._createReplenishment.bind(this),
104
+ ...CommonButtonStyles.activate
105
+ }
106
+ ]
107
+ }
108
+ case 'list':
109
+ return {
110
+ title: i18next.t('title.replenishment_list'),
111
+ actions: [
112
+ {
113
+ title: i18next.t('button.generate_worksheet'),
114
+ action: this._generateWorksheets.bind(this),
115
+ ...CommonButtonStyles.submit
116
+ }
117
+ ]
118
+ }
119
+ }
120
+ }
121
+
122
+ get replenishmentForm() {
123
+ return this.shadowRoot.querySelector('form[name=replenishment]')
124
+ }
125
+
126
+ render() {
127
+ return html`
128
+ ${html`
129
+ <search-form id="search-form" .fields=${this.searchFields} @submit=${e => this.dataGrist.fetch()}></search-form>
130
+ `}
131
+
132
+ <data-grist
133
+ .mode=${isMobileDevice() ? 'LIST' : 'GRID'}
134
+ .config=${this.config}
135
+ .fetchHandler="${this.fetchHandler.bind(this)}"
136
+ @field-change="${this._onInventoryFieldChanged.bind(this)}"
137
+ ></data-grist>
138
+ </div>
139
+ `
140
+ }
141
+
142
+ constructor() {
143
+ super()
144
+ }
145
+
146
+ get searchForm() {
147
+ return this.shadowRoot.querySelector('search-form')
148
+ }
149
+
150
+ get dataGrist() {
151
+ return this.shadowRoot.querySelector('data-grist')
152
+ }
153
+
154
+ async pageUpdated(changes, lifecycle, before) {
155
+ const replenishmentStatus = await getCodeByName('REPLENISHMENT_STATUS')
156
+
157
+ if (this.active) {
158
+ this._pageType = lifecycle.resourceId
159
+ }
160
+
161
+ switch (this._pageType) {
162
+ case 'create':
163
+ this.config = REPLENISHMENT_CONFIG.CREATE
164
+ break
165
+ case 'list':
166
+ this.config = REPLENISHMENT_CONFIG.LIST
167
+ break
168
+ }
169
+
170
+ const partners = [...(await this._fetchPartners())]
171
+
172
+ this.searchFields =
173
+ this._pageType == 'create'
174
+ ? [
175
+ {
176
+ label: i18next.t('field.company'),
177
+ name: 'bizplace',
178
+ type: 'select',
179
+ options: [
180
+ { value: '' },
181
+ ...partners
182
+ .map(partner => {
183
+ return {
184
+ name: `${partner.name} ${partner.description ? `(${partner.description})` : ''}`,
185
+ value: partner.id
186
+ }
187
+ })
188
+ .sort(this._compareValues('name', 'asc'))
189
+ ],
190
+ props: { searchOper: 'eq' }
191
+ },
192
+ {
193
+ label: i18next.t('field.product_info'),
194
+ name: 'product',
195
+ props: { searchOper: 'eq' }
196
+ }
197
+ ]
198
+ : [
199
+ {
200
+ label: i18next.t('field.order_no'),
201
+ name: 'name',
202
+ props: { searchOper: 'i_like' }
203
+ },
204
+ {
205
+ label: i18next.t('field.status'),
206
+ name: 'status',
207
+ type: 'select',
208
+ options: [
209
+ { value: '' },
210
+ ...replenishmentStatus.map(status => {
211
+ return { name: status.description, value: status.name }
212
+ })
213
+ ],
214
+ props: { searchOper: 'eq' }
215
+ }
216
+ ]
217
+
218
+ this.dataGrist.fetch()
219
+ }
220
+
221
+ async pageInitialized() {}
222
+
223
+ fetchHandler({ page, limit, sorters = [] }) {
224
+ this._clearView()
225
+ switch (this._pageType) {
226
+ case 'create':
227
+ return this._fetchStorageInventories({ page, limit, sorters })
228
+ case 'list':
229
+ return this._fetchReplenishments({ page, limit, sorters })
230
+ }
231
+ }
232
+
233
+ async _fetchStorageInventories({ page, limit, sorters }) {
234
+ const response = await client.query({
235
+ query: gql`
236
+ query replenishmentInventories($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
237
+ replenishmentInventories(filters: $filters, pagination: $pagination, sortings: $sortings) {
238
+ items {
239
+ productDetailId
240
+ productSKU
241
+ packingType
242
+ packingSize
243
+ minQty
244
+ pickingShelfQty
245
+ storageQty
246
+ bizplace {
247
+ id
248
+ name
249
+ }
250
+ }
251
+ total
252
+ }
253
+ }
254
+ `,
255
+ variables: {
256
+ filters: this.searchForm.queryFilters,
257
+ pagination: { page, limit },
258
+ sortings: sorters
259
+ }
260
+ })
261
+
262
+ if (!response.errors) {
263
+ this.searchForm.form.reset()
264
+ return {
265
+ total: response.data.replenishmentInventories.total || 0,
266
+ records: response.data.replenishmentInventories.items || []
267
+ }
268
+ }
269
+ }
270
+
271
+ async _fetchReplenishments({ page, limit, sorters }) {
272
+ const response = await client.query({
273
+ query: gql`
274
+ query replenishments($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
275
+ replenishments(filters: $filters, pagination: $pagination, sortings: $sortings) {
276
+ items {
277
+ id
278
+ name
279
+ status
280
+ createdAt
281
+ creator {
282
+ id
283
+ name
284
+ }
285
+ }
286
+ total
287
+ }
288
+ }
289
+ `,
290
+ variables: {
291
+ filters: await this.searchForm.getQueryFilters(),
292
+ pagination: { page, limit },
293
+ sortings: sorters
294
+ }
295
+ })
296
+
297
+ if (!response.errors) {
298
+ this.searchForm.form.reset()
299
+ return {
300
+ total: response.data.replenishments.total || 0,
301
+ records: response.data.replenishments.items || []
302
+ }
303
+ }
304
+ }
305
+
306
+ _validateForm() {
307
+ //check if transfer qty is less than storage qty
308
+ let invalidRow = this.dataGrist.selected.find(itm => itm.transferQty > itm.storageQty)
309
+
310
+ if (invalidRow) {
311
+ throw new Error(i18next.t('text.insufficient_storage_qty'))
312
+ }
313
+
314
+ invalidRow = this.dataGrist.selected.find(itm => !itm.transferQty || itm.transferQty <= 0 || isNaN(itm.transferQty))
315
+
316
+ if (invalidRow) {
317
+ throw new Error(i18next.t('text.invalid_transfer_qty'))
318
+ }
319
+ }
320
+
321
+ async _createReplenishment() {
322
+ try {
323
+ this._validateForm()
324
+
325
+ let orderInventories = await this._getOrderInventories()
326
+
327
+ if (orderInventories.length < 1) {
328
+ throw new Error(i18next.t('text.please_select_product_to_replenish'))
329
+ }
330
+
331
+ let result = await CustomAlert({
332
+ title: i18next.t('title.are_you_sure'),
333
+ text: i18next.t('text.create_replenishment'),
334
+ confirmButton: { text: i18next.t('button.submit') },
335
+ cancelButton: { text: i18next.t('button.cancel') }
336
+ })
337
+
338
+ if (!result.value) return
339
+
340
+ const response = await client.mutate({
341
+ mutation: gql`
342
+ mutation ($replenishInventories: [ReplenishmentInventoryPatch!]!) {
343
+ createReplenishment(replenishInventories: $replenishInventories) {
344
+ id
345
+ name
346
+ }
347
+ }
348
+ `,
349
+ variables: {
350
+ replenishInventories: orderInventories
351
+ }
352
+ })
353
+
354
+ if (!response.errors) {
355
+ navigate(`replenishment_detail/${response.data.createReplenishment.name}`)
356
+ showToast({ message: i18next.t('text.replenishment_created') })
357
+ }
358
+ } catch (e) {
359
+ showToast(e)
360
+ }
361
+ }
362
+
363
+ async _generateWorksheets() {
364
+ try {
365
+ let replenishmentNos = []
366
+ if (this.dataGrist.selected.length <= 0 && this._pageType == 'list')
367
+ throw new Error(i18next.t('text.please_select_one_or_more_order_to_generate_worksheet'))
368
+
369
+ let availableReplenishments = this.dataGrist.selected.filter(
370
+ itm => itm.status === ORDER_STATUS.PENDING_WORKSHEET.value
371
+ )
372
+
373
+ if (availableReplenishments.length > 0) {
374
+ replenishmentNos = availableReplenishments.map(record => record.name)
375
+ } else {
376
+ if (this._status == ORDER_STATUS.PENDING_WORKSHEET.value) {
377
+ replenishmentNos.push(this._orderNo)
378
+ }
379
+ }
380
+
381
+ if (replenishmentNos.length <= 0)
382
+ throw new Error(i18next.t('text.selected_replenishment(s)_is_not_in_pending_worksheet_status'))
383
+
384
+ const response = await client.mutate({
385
+ mutation: gql`
386
+ mutation ($replenishmentNos: [String!]) {
387
+ generateReplenishmentWorksheets(replenishmentNos: $replenishmentNos)
388
+ }
389
+ `,
390
+ variables: {
391
+ replenishmentNos
392
+ }
393
+ })
394
+
395
+ if (!response.errors) {
396
+ navigate(`replenishment_worksheet_list`)
397
+ showToast({ message: i18next.t('text.worksheet(s)_has_been_generated') })
398
+ }
399
+ this._processing = false
400
+ } catch (e) {
401
+ showToast(e)
402
+ }
403
+ }
404
+
405
+ async _fetchPartners() {
406
+ const filters = []
407
+ const response = await client.query({
408
+ query: gql`
409
+ query partnersBizplaces($filters: [Filter!]) {
410
+ partnersBizplaces(filters: $filters) {
411
+ items {
412
+ id
413
+ name
414
+ description
415
+ domain {
416
+ id
417
+ name
418
+ }
419
+ }
420
+ }
421
+ }
422
+ `,
423
+ variables: { filters }
424
+ })
425
+ if (!response.errors) {
426
+ return response.data.partnersBizplaces.items
427
+ }
428
+ }
429
+
430
+ async _getOrderInventories() {
431
+ const orderInventories = this.dataGrist.selected.map(record => {
432
+ let newRecord = {
433
+ bizplaceId: record.bizplace.id,
434
+ releaseQty: record.transferQty,
435
+ packingType: record.packingType,
436
+ packingSize: record.packingSize,
437
+ type: ORDER_TYPES.REPLENISHMENT.value,
438
+ productDetailId: record.productDetailId
439
+ }
440
+
441
+ return newRecord
442
+ })
443
+
444
+ return orderInventories
445
+ }
446
+
447
+ _fillupForm(form, data) {
448
+ if (form) {
449
+ form.reset()
450
+ for (let key in data) {
451
+ Array.from(form.querySelectorAll('input, textarea')).forEach(field => {
452
+ if (field.name === key && field.type === 'checkbox') {
453
+ field.checked = data[key]
454
+ } else if (field.name === key && field.type === 'datetime-local') {
455
+ const datetime = Number(data[key])
456
+ const timezoneOffset = new Date(datetime).getTimezoneOffset() * 60000
457
+ field.value = new Date(datetime - timezoneOffset).toISOString().slice(0, -1)
458
+ } else if (field.name === key) {
459
+ if (data[key] instanceof Object) {
460
+ const objectData = data[key]
461
+ field.value = `${objectData.name} ${objectData.description ? `(${objectData.description})` : ''}`
462
+ } else {
463
+ field.value = data[key]
464
+ }
465
+ }
466
+ })
467
+ }
468
+ }
469
+ }
470
+
471
+ _compareValues(key, order = 'asc') {
472
+ return function innerSort(a, b) {
473
+ if (!a.hasOwnProperty(key) || !b.hasOwnProperty(key)) {
474
+ return 0
475
+ }
476
+
477
+ const varA = typeof a[key] === 'string' ? a[key].toUpperCase() : a[key]
478
+ const varB = typeof b[key] === 'string' ? b[key].toUpperCase() : b[key]
479
+
480
+ let comparison = 0
481
+ if (varA > varB) {
482
+ comparison = 1
483
+ } else if (varA < varB) {
484
+ comparison = -1
485
+ }
486
+ return order === 'desc' ? comparison * -1 : comparison
487
+ }
488
+ }
489
+
490
+ _onInventoryFieldChanged(e) {
491
+ let transferQty = e.detail.after
492
+ if (isNaN(transferQty) || transferQty < 0) {
493
+ let beforeValue = e.detail.before
494
+ if (!beforeValue) {
495
+ beforeValue = 0
496
+ }
497
+ e.detail.after = beforeValue
498
+ this.dataGrist.dirtyData.records[e.detail.row].transferQty = beforeValue
499
+
500
+ showToast({ message: i18next.t('text.invalid_transfer_qty') })
501
+ }
502
+ }
503
+
504
+ _clearView() {
505
+ this._orderNo = ''
506
+ this._status = ''
507
+ }
508
+ }
509
+
510
+ window.customElements.define('replenishment-page', Replenishment)