@things-factory/operato-wms 4.1.32 → 4.1.35

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 (39) hide show
  1. package/client/pages/inbound/serial-number-list-popup.js +342 -0
  2. package/client/pages/inbound/unload-product.js +218 -39
  3. package/client/pages/inbound/unloaded-inventories-popup.js +7 -0
  4. package/client/pages/inventory/non-loaded-inventory.js +293 -0
  5. package/client/pages/outbound/picking-product.js +61 -36
  6. package/client/pages/outbound/serial-number-popup.js +150 -64
  7. package/client/pages/report/inbound-serial-number-report.js +452 -0
  8. package/client/pages/report/outbound-serial-number-report.js +460 -0
  9. package/client/route.js +11 -0
  10. package/dist-server/graphql/resolvers/reports/inbound-serial-number-report.js +111 -0
  11. package/dist-server/graphql/resolvers/reports/inbound-serial-number-report.js.map +1 -0
  12. package/dist-server/graphql/resolvers/reports/index.js +3 -1
  13. package/dist-server/graphql/resolvers/reports/index.js.map +1 -1
  14. package/dist-server/graphql/resolvers/reports/outbound-serial-number-report.js +116 -0
  15. package/dist-server/graphql/resolvers/reports/outbound-serial-number-report.js.map +1 -0
  16. package/dist-server/graphql/types/reports/inbound-serial-number-report-list.js +14 -0
  17. package/dist-server/graphql/types/reports/inbound-serial-number-report-list.js.map +1 -0
  18. package/dist-server/graphql/types/reports/inbound-serial-number-report.js +23 -0
  19. package/dist-server/graphql/types/reports/inbound-serial-number-report.js.map +1 -0
  20. package/dist-server/graphql/types/reports/index.js +10 -0
  21. package/dist-server/graphql/types/reports/index.js.map +1 -1
  22. package/dist-server/graphql/types/reports/outbound-serial-number-report-list.js +14 -0
  23. package/dist-server/graphql/types/reports/outbound-serial-number-report-list.js.map +1 -0
  24. package/dist-server/graphql/types/reports/outbound-serial-number-report.js +24 -0
  25. package/dist-server/graphql/types/reports/outbound-serial-number-report.js.map +1 -0
  26. package/package.json +6 -6
  27. package/server/graphql/resolvers/reports/inbound-serial-number-report.ts +128 -0
  28. package/server/graphql/resolvers/reports/index.ts +5 -0
  29. package/server/graphql/resolvers/reports/outbound-serial-number-report.ts +133 -0
  30. package/server/graphql/types/reports/inbound-serial-number-report-list.ts +8 -0
  31. package/server/graphql/types/reports/inbound-serial-number-report.ts +17 -0
  32. package/server/graphql/types/reports/index.ts +11 -0
  33. package/server/graphql/types/reports/outbound-serial-number-report-list.ts +8 -0
  34. package/server/graphql/types/reports/outbound-serial-number-report.ts +18 -0
  35. package/things-factory.config.js +12 -0
  36. package/translations/en.json +16 -2
  37. package/translations/ko.json +16 -3
  38. package/translations/ms.json +16 -3
  39. package/translations/zh.json +20 -7
@@ -0,0 +1,452 @@
1
+ import '@things-factory/form-ui'
2
+ import '@things-factory/grist-ui'
3
+ import '../inventory/inventory-by-product-detail'
4
+
5
+ import gql from 'graphql-tag'
6
+ import { css, html } from 'lit-element'
7
+ import { connect } from 'pwa-helpers/connect-mixin'
8
+
9
+ import { i18next, localize } from '@things-factory/i18n-base'
10
+ import { client, gqlContext, PageView, store } from '@things-factory/shell'
11
+ import { flattenObject, isMobileDevice } from '@things-factory/utils'
12
+
13
+ class InboundSerialNumberReport extends connect(store)(localize(i18next)(PageView)) {
14
+ static get styles() {
15
+ return css`
16
+ :host {
17
+ display: flex;
18
+ flex-direction: column;
19
+ width: 100%;
20
+ }
21
+
22
+ data-grist {
23
+ overflow-y: auto;
24
+ flex: 1;
25
+ }
26
+
27
+ .summary {
28
+ background-color: var(--main-section-background-color);
29
+ display: flex;
30
+ flex-direction: column;
31
+ overflow-y: auto;
32
+ align-items: flex-end;
33
+ padding: var(--data-list-item-padding);
34
+ display: grid;
35
+ font-size: 14px;
36
+ color: #394e64;
37
+ grid-template-columns: repeat(2, 1fr);
38
+ grid-auto-rows: minmax(24px, auto);
39
+ }
40
+ `
41
+ }
42
+
43
+ static get properties() {
44
+ return {
45
+ _searchFields: Object,
46
+ _config: Object,
47
+ _partners: Object,
48
+ _gristData: Object,
49
+ data: Object
50
+ }
51
+ }
52
+
53
+ get context() {
54
+ return {
55
+ title: i18next.t('title.inbound_serial_number_report'),
56
+ printable: {
57
+ accept: ['preview'],
58
+ content: this
59
+ },
60
+ help: 'operato-wms/report/inbound-serial-number-report'
61
+ }
62
+ }
63
+
64
+ get dataGrist() {
65
+ return this.shadowRoot.querySelector('data-grist')
66
+ }
67
+
68
+ get searchForm() {
69
+ return this.shadowRoot.querySelector('search-form')
70
+ }
71
+
72
+ get _bizplaceSelector() {
73
+ return this.searchForm.shadowRoot.querySelector('select[name=bizplace]')
74
+ }
75
+
76
+ get _fromDateInput() {
77
+ return this.searchForm.shadowRoot.querySelector('input[name=fromDate]')
78
+ }
79
+
80
+ get _toDateInput() {
81
+ return this.searchForm.shadowRoot.querySelector('input[name=toDate]')
82
+ }
83
+
84
+ render() {
85
+ return html`
86
+ <search-form id="search-form" .fields=${this._searchFields} @submit=${e => this.dataGrist.fetch()}></search-form>
87
+
88
+ <data-grist
89
+ .mode=${isMobileDevice() ? 'LIST' : 'GRID'}
90
+ .config=${this._config}
91
+ .fetchHandler="${this.fetchHandler.bind(this)}"
92
+ ></data-grist>
93
+ `
94
+ }
95
+
96
+ get searchFields() {
97
+ return [
98
+ {
99
+ label: i18next.t('field.company'),
100
+ name: 'bizplace',
101
+ type: 'select',
102
+ options: [
103
+ { value: '' },
104
+ ...this._partners
105
+ .map(partner => {
106
+ return {
107
+ name: `${partner.name} ${partner.description ? `(${partner.description})` : ''}`,
108
+ value: partner.id
109
+ }
110
+ })
111
+ .sort(this._compareValues('name', 'asc'))
112
+ ],
113
+ props: { searchOper: 'eq' }
114
+ },
115
+ {
116
+ label: i18next.t('field.from_date'),
117
+ name: 'fromDate',
118
+ type: 'date',
119
+ props: {
120
+ searchOper: 'eq',
121
+ max: new Date().toISOString().split('T')[0]
122
+ },
123
+ value: (() => {
124
+ let date = new Date()
125
+ date.setMonth(date.getMonth() - 1)
126
+ return date.toISOString().split('T')[0]
127
+ })(),
128
+ handlers: { change: this._modifyDateRange.bind(this) }
129
+ },
130
+ {
131
+ label: i18next.t('field.to_date'),
132
+ name: 'toDate',
133
+ type: 'date',
134
+ props: {
135
+ searchOper: 'eq',
136
+ min: (() => {
137
+ let date = new Date()
138
+ date.setMonth(date.getMonth() - 1)
139
+ return date.toISOString().split('T')[0]
140
+ })()
141
+ },
142
+ value: new Date().toISOString().split('T')[0],
143
+ handlers: { change: this._submit.bind(this) }
144
+ }
145
+ ]
146
+ }
147
+
148
+ get reportConfig() {
149
+ let columns = [
150
+ {
151
+ type: 'number',
152
+ name: 'no',
153
+ header: i18next.t('field.no'),
154
+ width: 50
155
+ },
156
+ {
157
+ type: 'string',
158
+ name: 'bizplace|name',
159
+ header: i18next.t('field.company'),
160
+ width: 200
161
+ },
162
+ {
163
+ type: 'string',
164
+ name: 'orderNo',
165
+ header: i18next.t('field.order_no'),
166
+ width: 200
167
+ },
168
+ {
169
+ type: 'string',
170
+ name: 'refNo1',
171
+ header: i18next.t('field.ref_no'),
172
+ width: 150
173
+ },
174
+ {
175
+ type: 'string',
176
+ name: 'refNo2',
177
+ header: i18next.t('field.ref_no_2'),
178
+ width: 150
179
+ },
180
+ {
181
+ type: 'string',
182
+ name: 'refNo3',
183
+ header: i18next.t('field.ref_no_3'),
184
+ width: 150
185
+ },
186
+ {
187
+ type: 'string',
188
+ name: 'palletId',
189
+ header: i18next.t('field.lot_id'),
190
+ width: 200
191
+ },
192
+ {
193
+ type: 'string',
194
+ name: 'cartonId',
195
+ header: i18next.t('field.carton_id'),
196
+ width: 200
197
+ },
198
+ {
199
+ type: 'string',
200
+ name: 'product|sku',
201
+ header: i18next.t('field.sku'),
202
+ width: 150
203
+ },
204
+ {
205
+ type: 'string',
206
+ name: 'product|brandSku',
207
+ header: i18next.t('field.brand_sku'),
208
+ width: 150
209
+ },
210
+ {
211
+ type: 'string',
212
+ name: 'product|name',
213
+ header: i18next.t('field.product_name'),
214
+ width: 200
215
+ },
216
+ {
217
+ type: 'string',
218
+ name: 'product|description',
219
+ header: i18next.t('field.product_description'),
220
+ width: 300
221
+ },
222
+ {
223
+ type: 'string',
224
+ name: 'product|type',
225
+ header: i18next.t('field.product_type'),
226
+ width: 150
227
+ },
228
+ {
229
+ type: 'number',
230
+ name: 'product|volume',
231
+ header: i18next.t('field.volume'),
232
+ width: 150
233
+ },
234
+ {
235
+ type: 'string',
236
+ name: 'serialNumber',
237
+ header: i18next.t('field.serial_number'),
238
+ width: 150
239
+ },
240
+ {
241
+ type: 'datetime',
242
+ name: 'etd',
243
+ header: i18next.t('field.etd'),
244
+ width: 170
245
+ }
246
+ ]
247
+ let list = {
248
+ fields: [
249
+ 'no',
250
+ 'bizplace|name',
251
+ 'orderNo',
252
+ 'refNo1',
253
+ 'refNo2',
254
+ 'refNo3',
255
+ 'palletId',
256
+ 'cartonId',
257
+ 'product|sku',
258
+ 'product|brandSku',
259
+ 'product|name',
260
+ 'product|description',
261
+ 'product|type',
262
+ 'product|volume',
263
+ 'serialNumber',
264
+ 'etd'
265
+ ]
266
+ }
267
+
268
+ return {
269
+ columns: columns,
270
+ list,
271
+ pagination: { limit: 100, pages: [50, 100, 200, 500, 1000] },
272
+ rows: {
273
+ selectable: false,
274
+ insertable: false,
275
+ appendable: false
276
+ }
277
+ }
278
+ }
279
+
280
+ async pageInitialized() {
281
+ this._gristData = { total: 0, records: [] }
282
+ this._partners = [...(await this._fetchPartners())]
283
+
284
+ this._searchFields = this.searchFields
285
+ this._config = this.reportConfig
286
+ }
287
+
288
+ async pageUpdated(changes, lifecycle) {
289
+ if (this.active) {
290
+ this.dataGrist.fetch()
291
+ }
292
+ }
293
+
294
+ async fetchHandler({ page, limit, sorters = [] }) {
295
+ try {
296
+ this._validate()
297
+ let filters = this.searchForm.queryFilters.map(filter => {
298
+ switch (filter.name) {
299
+ case 'fromDate':
300
+ let fromDt = new Date(filter.value)
301
+ fromDt.setHours(0)
302
+ filter.value = fromDt.toISOString()
303
+ break
304
+ case 'toDate':
305
+ let toDt = new Date(filter.value)
306
+ toDt.setHours(23, 59, 59)
307
+ filter.value = toDt.toISOString()
308
+ break
309
+ default:
310
+ break
311
+ }
312
+ return filter
313
+ })
314
+
315
+ const pagination = { page, limit }
316
+ const sortings = sorters
317
+
318
+ const response = await client.query({
319
+ query: gql`
320
+ query inboundSerialNumberReport($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
321
+ inboundSerialNumberReport(filters: $filters, pagination: $pagination, sortings: $sortings) {
322
+ items {
323
+ no
324
+ bizplace {
325
+ name
326
+ description
327
+ }
328
+ orderNo
329
+ refNo1
330
+ refNo2
331
+ refNo3
332
+ palletId
333
+ cartonId
334
+ product {
335
+ id
336
+ sku
337
+ brandSku
338
+ name
339
+ description
340
+ type
341
+ volume
342
+ }
343
+ serialNumber
344
+ etd
345
+ }
346
+ total
347
+ }
348
+ }
349
+ `,
350
+ variables: { filters, pagination, sortings },
351
+ context: gqlContext()
352
+ })
353
+
354
+ const data = {
355
+ total: response.data.inboundSerialNumberReport.total,
356
+ records:
357
+ response.data.inboundSerialNumberReport.items.map(itm => {
358
+ return flattenObject({ ...itm, bizplace: { name: `${itm.bizplace.name} ${itm.bizplace.description}` } })
359
+ }) || []
360
+ }
361
+
362
+ this._gristData = {
363
+ ...data
364
+ }
365
+
366
+ return data
367
+ } catch (e) {
368
+ this._showToast(e)
369
+ }
370
+ }
371
+
372
+ async _fetchPartners() {
373
+ const filters = []
374
+ const response = await client.query({
375
+ query: gql`
376
+ query partnersBizplaces($filters: [Filter!]) {
377
+ partnersBizplaces(filters: $filters) {
378
+ items {
379
+ id
380
+ name
381
+ description
382
+ }
383
+ }
384
+ }
385
+ `,
386
+ variables: { filters }
387
+ })
388
+
389
+ if (!response.errors) {
390
+ return response.data.partnersBizplaces.items
391
+ }
392
+ }
393
+ _validate() {
394
+ if (!this.searchForm.shadowRoot.querySelector('form').checkValidity())
395
+ throw new Error(i18next.t('text.invalid_form_value'))
396
+ if (!this._bizplaceSelector.value) throw new Error(i18next.t('text.no_company_selected'))
397
+ if (!this._fromDateInput.value) throw new Error(i18next.t('text.from_date_is_empty'))
398
+ if (!this._toDateInput.value) throw new Error(i18next.t('text.to_date_is_empty'))
399
+ }
400
+
401
+ _compareValues(key, order = 'asc') {
402
+ return function innerSort(a, b) {
403
+ if (!a.hasOwnProperty(key) || !b.hasOwnProperty(key)) {
404
+ return 0
405
+ }
406
+
407
+ const varA = typeof a[key] === 'string' ? a[key].toUpperCase() : a[key]
408
+ const varB = typeof b[key] === 'string' ? b[key].toUpperCase() : b[key]
409
+
410
+ let comparison = 0
411
+ if (varA > varB) {
412
+ comparison = 1
413
+ } else if (varA < varB) {
414
+ comparison = -1
415
+ }
416
+ return order === 'desc' ? comparison * -1 : comparison
417
+ }
418
+ }
419
+
420
+ _modifyDateRange(e) {
421
+ const fromDate = e.currentTarget.value
422
+
423
+ if (this._toDateInput.value < fromDate) this._toDateInput.value = fromDate
424
+
425
+ let min = new Date(fromDate)
426
+ let today = new Date()
427
+ today.setHours(0, 0, 0, 0)
428
+
429
+ min = min.toISOString().split('T')[0]
430
+
431
+ this._toDateInput.min = min
432
+ this._submit()
433
+ }
434
+
435
+ _submit(e) {
436
+ this._config = { ...this.reportConfig }
437
+ this.searchForm.submit()
438
+ }
439
+
440
+ _showToast({ type, message }) {
441
+ document.dispatchEvent(
442
+ new CustomEvent('notify', {
443
+ detail: {
444
+ type,
445
+ message
446
+ }
447
+ })
448
+ )
449
+ }
450
+ }
451
+
452
+ window.customElements.define('inbound-serial-number-report', InboundSerialNumberReport)