@things-factory/operato-wms 4.3.186 → 4.3.187

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,470 @@
1
+ import '@things-factory/form-ui'
2
+ import '@things-factory/grist-ui'
3
+ import '../outbound/select-operator-popup'
4
+
5
+ import gql from 'graphql-tag'
6
+ import { css, html } from 'lit-element'
7
+
8
+ import { getCodeByName } from '@things-factory/code-base'
9
+ import { i18next, localize } from '@things-factory/i18n-base'
10
+ import { client, navigate, PageView } from '@things-factory/shell'
11
+ import { ScrollbarStyles, CommonButtonStyles } from '@things-factory/styles'
12
+ import { isMobileDevice } from '@things-factory/utils'
13
+ import { openPopup } from '@things-factory/layout-base'
14
+
15
+ import { WORKSHEET_TYPE } from '../constants'
16
+
17
+ class ReplenishmentWorksheet extends localize(i18next)(PageView) {
18
+ static get styles() {
19
+ return [
20
+ ScrollbarStyles,
21
+ css`
22
+ :host {
23
+ display: flex;
24
+ flex-direction: column;
25
+ overflow: hidden;
26
+ }
27
+
28
+ search-form {
29
+ overflow: visible;
30
+ }
31
+ data-grist {
32
+ overflow-y: auto;
33
+ flex: 1;
34
+ }
35
+ `
36
+ ]
37
+ }
38
+
39
+ static get properties() {
40
+ return {
41
+ _partnersList: Array,
42
+ _searchFields: Array,
43
+ _routeLabelSetting: Boolean,
44
+ assignee: String,
45
+ config: Object,
46
+ data: Object,
47
+ targetBizplace: Object,
48
+ assignee: String,
49
+ status: String
50
+ }
51
+ }
52
+
53
+ render() {
54
+ return html`
55
+ <search-form id="search-form" .fields=${this._searchFields} @submit=${e => this.dataGrist.fetch()}></search-form>
56
+
57
+ <data-grist
58
+ .mode=${isMobileDevice() ? 'LIST' : 'GRID'}
59
+ .config=${this.config}
60
+ .fetchHandler="${this.fetchHandler.bind(this)}"
61
+ ></data-grist>
62
+ `
63
+ }
64
+
65
+ get context() {
66
+ var actions = []
67
+
68
+ actions.push({
69
+ title: i18next.t('button.assign_picker'),
70
+ action: this._assignPicker.bind(this),
71
+ ...CommonButtonStyles.activate
72
+ })
73
+
74
+ return {
75
+ title: i18next.t('title.replenishment_worksheet'),
76
+ actions,
77
+ exportable: {
78
+ name: i18next.t('title.replenishment_worksheet'),
79
+ data: this._exportableData.bind(this)
80
+ }
81
+ }
82
+ }
83
+
84
+ get _fromDateInput() {
85
+ return this.searchForm.shadowRoot.querySelector('input[name=fromDate]')
86
+ }
87
+
88
+ get _toDateInput() {
89
+ return this.searchForm.shadowRoot.querySelector('input[name=toDate]')
90
+ }
91
+
92
+ pageUpdated(changes, lifecycle) {
93
+ if (this.active) {
94
+ this.assigneeId = lifecycle.params.assigneeId || null
95
+ this.status = lifecycle.params.status || null
96
+
97
+ this.dataGrist.fetch()
98
+ }
99
+ }
100
+
101
+ async pageInitialized() {
102
+ const _worksheetStatus = await getCodeByName('WORKSHEET_STATUS')
103
+
104
+ this._searchFields = [
105
+ {
106
+ name: 'replenishmentNo',
107
+ label: i18next.t('field.order_no'),
108
+ type: 'text',
109
+ props: { searchOper: 'i_like' }
110
+ },
111
+ {
112
+ name: 'assignee',
113
+ label: i18next.t('field.picker'),
114
+ type: 'text',
115
+ props: { searchOper: 'i_like' }
116
+ },
117
+ {
118
+ name: 'status',
119
+ label: i18next.t('label.status'),
120
+ type: 'select',
121
+ options: [
122
+ { value: '' },
123
+ ..._worksheetStatus.map(status => {
124
+ return { name: i18next.t(`label.${status.description}`), value: status.name }
125
+ })
126
+ ],
127
+ props: { searchOper: 'eq' }
128
+ }
129
+ // {
130
+ // label: i18next.t('field.from_date'),
131
+ // name: 'fromDate',
132
+ // type: 'date',
133
+ // props: {
134
+ // searchOper: 'eq'
135
+ // },
136
+ // value: (() => {
137
+ // let date = new Date()
138
+ // date.setMonth(date.getMonth() - 6)
139
+ // return date.toISOString().split('T')[0]
140
+ // })(),
141
+ // handlers: { change: this._modifyDateRange.bind(this) }
142
+ // },
143
+ // {
144
+ // label: i18next.t('field.to_date'),
145
+ // name: 'toDate',
146
+ // type: 'date',
147
+ // props: {
148
+ // searchOper: 'eq',
149
+ // min: (() => {
150
+ // let date = new Date()
151
+ // date.setMonth(date.getMonth() - 6)
152
+ // return date.toISOString().split('T')[0]
153
+ // })()
154
+ // },
155
+ // value: new Date().toISOString().split('T')[0]
156
+ // },
157
+ ]
158
+
159
+ this.config = {
160
+ list: {
161
+ fields: ['replenishment', 'type', 'status', 'assignee', 'createdAt', 'startedAt', 'endedAt']
162
+ },
163
+ rows: { selectable: { multiple: true }, appendable: false },
164
+ pagination: { limit: 100, pages: [20, 50, 100, 200, 500] },
165
+ columns: [
166
+ { type: 'gutter', gutterName: 'sequence' },
167
+ { type: 'gutter', gutterName: 'row-selector', multiple: true },
168
+ {
169
+ type: 'gutter',
170
+ gutterName: 'button',
171
+ icon: 'reorder',
172
+ handlers: {
173
+ click: (columns, data, column, record, rowIndex) => {
174
+ if (!record.id) return
175
+ const type = record.type
176
+
177
+ if (type === WORKSHEET_TYPE.PICKING_REPLENISHMENT.value) {
178
+ navigate(`worksheet_replenishment/${record.name}`)
179
+ } else if (type === WORKSHEET_TYPE.PUTAWAY_REPLENISHMENT.value) {
180
+ navigate(`worksheet_replenishment/${record.name}`)
181
+ }
182
+ }
183
+ }
184
+ },
185
+ {
186
+ type: 'object',
187
+ name: 'replenishment',
188
+ header: i18next.t('field.order_no'),
189
+ imex: {
190
+ header: i18next.t('field.order_no'),
191
+ key: 'replenishment.name',
192
+ width: 30,
193
+ type: 'string'
194
+ },
195
+ sortable: true,
196
+ width: 200
197
+ },
198
+ {
199
+ type: 'string',
200
+ name: 'type',
201
+ header: i18next.t('field.type'),
202
+ imex: { header: i18next.t('field.type'), key: 'type', width: 20, type: 'string' },
203
+ sortable: true,
204
+ width: 200
205
+ },
206
+ {
207
+ type: 'string',
208
+ name: 'status',
209
+ header: i18next.t('field.status'),
210
+ imex: { header: i18next.t('field.status'), key: 'status', width: 20, type: 'string' },
211
+ sortable: true,
212
+ width: 100
213
+ },
214
+ {
215
+ type: 'object',
216
+ name: 'assignee',
217
+ header: i18next.t('field.assigned_picker'),
218
+ imex: { header: i18next.t('field.assigned_picker'), key: 'assignee.name', width: 20, type: 'string' },
219
+ sortable: true,
220
+ width: 150
221
+ },
222
+ {
223
+ type: 'datetime',
224
+ name: 'createdAt',
225
+ header: i18next.t('field.created_at'),
226
+ imex: { header: i18next.t('field.created_at'), key: 'createdAt', width: 20, type: 'string' },
227
+ sortable: true,
228
+ width: 200
229
+ },
230
+ {
231
+ type: 'datetime',
232
+ name: 'startedAt',
233
+ header: i18next.t('field.started_at'),
234
+ imex: { header: i18next.t('field.started_at'), key: 'startedAt', width: 30, type: 'string' },
235
+ sortable: true,
236
+ width: 160
237
+ },
238
+ {
239
+ type: 'datetime',
240
+ name: 'endedAt',
241
+ header: i18next.t('field.ended_at'),
242
+ imex: { header: i18next.t('field.ended_at'), key: 'endedAt', width: 30, type: 'string' },
243
+ sortable: true,
244
+ width: 160
245
+ },
246
+ {
247
+ type: 'object',
248
+ name: 'updater',
249
+ header: i18next.t('field.updater'),
250
+ imex: { header: i18next.t('field.updater'), key: 'updater.name', width: 30, type: 'string' },
251
+ sortable: true,
252
+ width: 150
253
+ }
254
+ ]
255
+ }
256
+ }
257
+
258
+ get searchForm() {
259
+ return this.shadowRoot.querySelector('search-form')
260
+ }
261
+
262
+ get dataGrist() {
263
+ return this.shadowRoot.querySelector('data-grist')
264
+ }
265
+
266
+ async fetchHandler({ page, limit, sorters = [{ name: 'createdAt', desc: true }] }) {
267
+ const filters = this.searchForm.queryFilters
268
+ filters.push({
269
+ name: 'type',
270
+ operator: 'in',
271
+ value: [WORKSHEET_TYPE.PICKING_REPLENISHMENT.value, WORKSHEET_TYPE.PUTAWAY_REPLENISHMENT.value]
272
+ })
273
+
274
+ // Add extra condition if path variable has assigneeId
275
+ // It's for navigate from picking UI to list up assigned tasks of user
276
+ if (this.assigneeId) {
277
+ filters.push({
278
+ name: 'assigneeId',
279
+ operator: 'in',
280
+ value: [this.assigneeId]
281
+ })
282
+ }
283
+
284
+ // Add extra condition if path variable has status
285
+ // It's for navigate from picking UI to list up assigned tasks of user
286
+ if (this.status) {
287
+ filters.push({ name: 'status', operator: 'eq', value: this.status })
288
+ }
289
+
290
+ const response = await client.query({
291
+ query: gql`
292
+ query worksheets($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
293
+ worksheets(filters: $filters, pagination: $pagination, sortings: $sortings) {
294
+ items {
295
+ id
296
+ name
297
+ assignee {
298
+ id
299
+ name
300
+ }
301
+ replenishment {
302
+ id
303
+ name
304
+ }
305
+ bizplace {
306
+ id
307
+ name
308
+ description
309
+ }
310
+ name
311
+ type
312
+ status
313
+ startedAt
314
+ createdAt
315
+ endedAt
316
+ updater {
317
+ name
318
+ description
319
+ }
320
+ }
321
+ total
322
+ }
323
+ }
324
+ `,
325
+ variables: {
326
+ filters,
327
+ pagination: { page, limit },
328
+ sortings: sorters
329
+ }
330
+ })
331
+
332
+ if (!response.errors) {
333
+ this.updateContext()
334
+ return {
335
+ total: response.data.worksheets.total || 0,
336
+ records: response.data.worksheets.items || {}
337
+ }
338
+ }
339
+ }
340
+
341
+ get _columns() {
342
+ return this.config.columns
343
+ }
344
+
345
+ _assignPicker() {
346
+ try {
347
+ let selectedData = this.dataGrist.selected.filter(item => {
348
+ return item.status == 'DEACTIVATED'
349
+ })
350
+
351
+ if (selectedData.length <= 0) throw new Error(i18next.t('text.no_available_worksheet_selected'))
352
+
353
+ openPopup(
354
+ html`
355
+ <select-operator-popup
356
+ @updateOperator="${async e => {
357
+ let assignee = e.detail
358
+
359
+ const response = await client.mutate({
360
+ mutation: gql`
361
+ mutation assignPickingWorker($worksheetId: [String]!, $userId: String!) {
362
+ assignPickingWorker(worksheetId: $worksheetId, userId: $userId)
363
+ }
364
+ `,
365
+ variables: { worksheetId: selectedData.map(itm => itm.id), userId: assignee.id }
366
+ })
367
+
368
+ if (!response.errors) {
369
+ this.dataGrist.fetch()
370
+ return this._showToast({ message: i18next.t('text.updated_successfully') })
371
+ }
372
+
373
+ if (this.activatable) {
374
+ if (this.orderNo) {
375
+ history.back()
376
+ }
377
+ }
378
+ }}"
379
+ ></select-operator-popup>
380
+ `,
381
+ {
382
+ backdrop: true,
383
+ size: 'medium',
384
+ title: 'select operator'
385
+ }
386
+ )
387
+ } catch (error) {
388
+ return this._showToast(error)
389
+ }
390
+ }
391
+
392
+ _modifyDateRange(e) {
393
+ const fromDate = e.currentTarget.value
394
+
395
+ if (this._toDateInput.value < fromDate) this._toDateInput.value = fromDate
396
+
397
+ let min = new Date(fromDate)
398
+ let today = new Date()
399
+ today.setHours(0, 0, 0, 0)
400
+
401
+ min = min.toISOString().split('T')[0]
402
+
403
+ this._toDateInput.min = min
404
+ }
405
+
406
+ _compareValues(key, order = 'asc') {
407
+ return function innerSort(a, b) {
408
+ if (!a.hasOwnProperty(key) || !b.hasOwnProperty(key)) {
409
+ return 0
410
+ }
411
+
412
+ const varA = typeof a[key] === 'string' ? a[key].toUpperCase() : a[key]
413
+ const varB = typeof b[key] === 'string' ? b[key].toUpperCase() : b[key]
414
+
415
+ let comparison = 0
416
+ if (varA > varB) {
417
+ comparison = 1
418
+ } else if (varA < varB) {
419
+ comparison = -1
420
+ }
421
+ return order === 'desc' ? comparison * -1 : comparison
422
+ }
423
+ }
424
+
425
+ _exportableData() {
426
+ let records = []
427
+ if (this.dataGrist.selected && this.dataGrist.selected.length > 0) {
428
+ records = this.dataGrist.selected
429
+ } else {
430
+ records = this.dataGrist.data.records
431
+ }
432
+
433
+ var headerSetting = this.dataGrist._config.columns
434
+ .filter(column => column.type !== 'gutter' /* && column.record !== undefined */ && column.imex !== undefined)
435
+ .map(column => {
436
+ return column.imex
437
+ })
438
+
439
+ var data = records.map(item => {
440
+ return {
441
+ id: item.id,
442
+ ...this._columns
443
+ .filter(column => column.type !== 'gutter' /* && column.record !== undefined */ && column.imex !== undefined)
444
+ .reduce((record, column) => {
445
+ record[column.imex.key] = column.imex.key
446
+ .split('.')
447
+ .reduce((obj, key) => (obj && obj[key] !== 'undefined' ? obj[key] : undefined), item)
448
+ if (record[column.imex.key] === 'Invalid Date') {
449
+ record[column.imex.key] = ''
450
+ }
451
+ return record
452
+ }, {})
453
+ }
454
+ })
455
+ return { header: headerSetting, data: data }
456
+ }
457
+
458
+ _showToast({ type, message }) {
459
+ document.dispatchEvent(
460
+ new CustomEvent('notify', {
461
+ detail: {
462
+ type,
463
+ message
464
+ }
465
+ })
466
+ )
467
+ }
468
+ }
469
+
470
+ window.customElements.define('replenishment-worksheet-list', ReplenishmentWorksheet)