@things-factory/operato-wms 4.0.44 → 4.0.45

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.
@@ -0,0 +1,191 @@
1
+ import '@things-factory/grist-ui'
2
+
3
+ import { css, html, LitElement } from 'lit-element'
4
+ import { connect } from 'pwa-helpers/connect-mixin'
5
+
6
+ import { SingleColumnFormStyles } from '@things-factory/form-ui'
7
+ import { i18next, localize } from '@things-factory/i18n-base'
8
+ import { store, CustomAlert } from '@things-factory/shell'
9
+ import { isMobileDevice } from '@things-factory/utils'
10
+
11
+ class PutawaySameCartonPopup extends connect(store)(localize(i18next)(LitElement)) {
12
+ static get properties() {
13
+ return {
14
+ config: Object,
15
+ data: Object,
16
+ putawayInventories: Array
17
+ }
18
+ }
19
+
20
+ constructor() {
21
+ super()
22
+ this._selectedInventoryIds = []
23
+ }
24
+
25
+ static get styles() {
26
+ return [
27
+ SingleColumnFormStyles,
28
+ css`
29
+ .button-container {
30
+ padding: var(--button-container-padding);
31
+ margin: var(--button-container-margin);
32
+ text-align: var(--button-container-align);
33
+ background-color: var(--button-container-background);
34
+ height: var(--button-container-height);
35
+ }
36
+ .button-container button {
37
+ background-color: var(--button-container-button-background-color);
38
+ border-radius: var(--button-container-button-border-radius);
39
+ height: var(--button-container-button-height);
40
+ border: var(--button-container-button-border);
41
+ margin: var(--button-container-button-margin);
42
+
43
+ padding: var(--button-padding);
44
+ color: var(--theme-white-color);
45
+ font: var(--button-font);
46
+ text-transform: var(--button-text-transform);
47
+ }
48
+ .button-container button:hover,
49
+ .button-container button:active {
50
+ background-color: var(--button-background-focus-color);
51
+ }
52
+ data-grist {
53
+ overflow-y: hidden;
54
+ flex: 1;
55
+ }
56
+ .grist {
57
+ display: flex;
58
+ flex-direction: column;
59
+ flex: 1;
60
+ overflow-y: auto;
61
+ }
62
+ :host {
63
+ padding: 10px;
64
+ display: flex;
65
+ flex-direction: column;
66
+ overflow: hidden;
67
+ background-color: white;
68
+ }
69
+ `
70
+ ]
71
+ }
72
+
73
+ get dataGrist() {
74
+ return this.shadowRoot.querySelector('data-grist')
75
+ }
76
+
77
+ updated(changeProps) {
78
+ if (changeProps.has('putawayInventories')) {
79
+ if (this.putawayInventories && this.putawayInventories.length) {
80
+ this.data = { records: this.putawayInventories }
81
+ }
82
+ }
83
+ }
84
+
85
+ render() {
86
+ return html`
87
+ <div class="grist">
88
+ <data-grist
89
+ id="grist"
90
+ .mode=${isMobileDevice() ? 'LIST' : 'GRID'}
91
+ .config=${this.config}
92
+ .data="${this.data}"
93
+ ></data-grist>
94
+ </div>
95
+
96
+ <div class="button-container">
97
+ <mwc-button
98
+ raised
99
+ @click="${this._selectPutawayInventories.bind(this)}"
100
+ label="${i18next.t('button.select')}"
101
+ ></mwc-button>
102
+ </div>
103
+ `
104
+ }
105
+
106
+ firstUpdated() {
107
+ this.config = {
108
+ pagination: { infinite: true },
109
+ rows: { selectable: { multiple: true }, appendable: false },
110
+ list: { fields: ['palletId', 'cartonId', 'batchId', 'product', 'packingType', 'packingSize', 'qty', 'status'] },
111
+ columns: [
112
+ { type: 'gutter', gutterName: 'sequence' },
113
+ { type: 'gutter', gutterName: 'row-selector', multiple: true },
114
+ { name: 'id', hidden: true },
115
+ {
116
+ type: 'string',
117
+ name: 'cartonId',
118
+ label: true,
119
+ header: i18next.t('field.carton_id'),
120
+ width: 150
121
+ },
122
+ {
123
+ type: 'object',
124
+ name: 'product',
125
+ label: true,
126
+ header: i18next.t('field.product'),
127
+ width: 250
128
+ },
129
+ {
130
+ type: 'string',
131
+ name: 'batchId',
132
+ label: true,
133
+ header: i18next.t('field.batch_id'),
134
+ width: 150
135
+ },
136
+ {
137
+ type: 'string',
138
+ name: 'packingType',
139
+ label: true,
140
+ header: i18next.t('field.packing_type'),
141
+ width: 120
142
+ },
143
+ {
144
+ type: 'integer',
145
+ name: 'packingSize',
146
+ label: true,
147
+ header: i18next.t('field.packing_size'),
148
+ width: 100
149
+ },
150
+ {
151
+ type: 'integer',
152
+ name: 'qty',
153
+ label: true,
154
+ header: i18next.t('field.qty'),
155
+ width: 100
156
+ }
157
+ ]
158
+ }
159
+ }
160
+
161
+ async _selectPutawayInventories() {
162
+ try {
163
+ let selectedInventories = []
164
+ selectedInventories = this.dataGrist.selected.map(({ name, expirationDate, expirationPeriod, palletId }) => ({
165
+ name,
166
+ expirationDate,
167
+ expirationPeriod,
168
+ palletId
169
+ }))
170
+ if (!selectedInventories?.length) throw new Error(i18next.t('text.select_at_least_one_inventory_to_putaway'))
171
+
172
+ this.dispatchEvent(new CustomEvent('selections', { detail: selectedInventories }))
173
+ history.back()
174
+ } catch (e) {
175
+ this._showToast(e)
176
+ }
177
+ }
178
+
179
+ _showToast({ type, message }) {
180
+ document.dispatchEvent(
181
+ new CustomEvent('notify', {
182
+ detail: {
183
+ type,
184
+ message
185
+ }
186
+ })
187
+ )
188
+ }
189
+ }
190
+
191
+ window.customElements.define('putaway-same-carton-popup', PutawaySameCartonPopup)
@@ -0,0 +1,365 @@
1
+ import '@things-factory/grist-ui'
2
+
3
+ import gql from 'graphql-tag'
4
+ import { css, html, LitElement } from 'lit-element'
5
+ import { connect } from 'pwa-helpers/connect-mixin'
6
+
7
+ import { SingleColumnFormStyles } from '@things-factory/form-ui'
8
+ import { i18next, localize } from '@things-factory/i18n-base'
9
+ import { client, store, CustomAlert } from '@things-factory/shell'
10
+ import { isMobileDevice } from '@things-factory/utils'
11
+
12
+ import { ARRIVAL_NOTICE, CUSTOMER_RETURN, WAREHOUSE_RETURN } from '../constants'
13
+
14
+ const AVAIL_ORDER_TYPES = { ARRIVAL_NOTICE, CUSTOMER_RETURN, WAREHOUSE_RETURN }
15
+
16
+ class UndoPutawayPopup extends connect(store)(localize(i18next)(LitElement)) {
17
+ static get properties() {
18
+ return {
19
+ _autoSelectInventory: Array,
20
+ _selectedInventories: Array,
21
+ config: Object,
22
+ data: Object,
23
+ enableCartonLabel: Boolean,
24
+ orderType: String,
25
+ orderNo: String,
26
+ putawayInventories: Array
27
+ }
28
+ }
29
+
30
+ constructor() {
31
+ super()
32
+ this._selectedInventories = []
33
+ this._autoSelectInventory = []
34
+ }
35
+
36
+ static get styles() {
37
+ return [
38
+ SingleColumnFormStyles,
39
+ css`
40
+ .button-container {
41
+ padding: var(--button-container-padding);
42
+ margin: var(--button-container-margin);
43
+ text-align: var(--button-container-align);
44
+ background-color: var(--button-container-background);
45
+ height: var(--button-container-height);
46
+ }
47
+ .button-container button {
48
+ background-color: var(--button-container-button-background-color);
49
+ border-radius: var(--button-container-button-border-radius);
50
+ height: var(--button-container-button-height);
51
+ border: var(--button-container-button-border);
52
+ margin: var(--button-container-button-margin);
53
+
54
+ padding: var(--button-padding);
55
+ color: var(--theme-white-color);
56
+ font: var(--button-font);
57
+ text-transform: var(--button-text-transform);
58
+ }
59
+ .button-container button:hover,
60
+ .button-container button:active {
61
+ background-color: var(--button-background-focus-color);
62
+ }
63
+ data-grist {
64
+ overflow-y: hidden;
65
+ flex: 1;
66
+ }
67
+ .grist {
68
+ display: flex;
69
+ flex-direction: column;
70
+ flex: 1;
71
+ overflow-y: auto;
72
+ }
73
+ :host {
74
+ padding: 10px;
75
+ display: flex;
76
+ flex-direction: column;
77
+ overflow: hidden;
78
+ background-color: white;
79
+ }
80
+ `
81
+ ]
82
+ }
83
+
84
+ get cartonInput() {
85
+ return this.shadowRoot.querySelector('barcode-scanable-input[name=cartonId]').shadowRoot.querySelector('input')
86
+ }
87
+
88
+ get dataGrist() {
89
+ return this.shadowRoot.querySelector('data-grist')
90
+ }
91
+
92
+ get inputForm() {
93
+ return this.shadowRoot.querySelector('form#input-form')
94
+ }
95
+
96
+ get lotInput() {
97
+ return this.shadowRoot.querySelector('barcode-scanable-input[name=lotId]').shadowRoot.querySelector('input')
98
+ }
99
+
100
+ render() {
101
+ return html`
102
+ <form id="input-form" class="single-column-form" @keypress="${this._populateTargetedInventory.bind(this)}">
103
+ <fieldset>
104
+ ${this.enableCartonLabel
105
+ ? html`<label>${i18next.t('label.carton_id')}</label>
106
+ <barcode-scanable-input name="cartonId" without-enter custom-input></barcode-scanable-input>`
107
+ : html`<label>${i18next.t('label.lot_id')}</label>
108
+ <barcode-scanable-input name="lotId" without-enter custom-input></barcode-scanable-input>`}
109
+ </fieldset>
110
+ </form>
111
+
112
+ <div class="grist">
113
+ <data-grist
114
+ id="grist"
115
+ .mode=${isMobileDevice() ? 'LIST' : 'GRID'}
116
+ .config=${this.config}
117
+ .data="${this.data}"
118
+ ></data-grist>
119
+ </div>
120
+
121
+ <div class="button-container">
122
+ <mwc-button raised @click="${this._undoPutaway.bind(this)}" label="${i18next.t('button.undo')}"></mwc-button>
123
+ </div>
124
+ `
125
+ }
126
+
127
+ firstUpdated() {
128
+ this.config = {
129
+ pagination: { infinite: true },
130
+ rows: { selectable: { multiple: true }, appendable: false },
131
+ list: { fields: ['palletId', 'cartonId', 'batchId', 'product', 'packingType', 'packingSize', 'qty', 'status'] },
132
+ columns: [
133
+ { type: 'gutter', gutterName: 'sequence' },
134
+ { type: 'gutter', gutterName: 'row-selector', multiple: true },
135
+ { name: 'id', hidden: true },
136
+ {
137
+ type: 'string',
138
+ name: 'palletId',
139
+ label: true,
140
+ header: i18next.t('field.lot_id'),
141
+ width: 150
142
+ },
143
+ {
144
+ type: 'string',
145
+ name: 'cartonId',
146
+ label: true,
147
+ header: i18next.t('field.carton_id'),
148
+ width: 150
149
+ },
150
+ {
151
+ type: 'string',
152
+ name: 'batchId',
153
+ label: true,
154
+ header: i18next.t('field.batch_id'),
155
+ width: 150
156
+ },
157
+ {
158
+ type: 'object',
159
+ name: 'product',
160
+ label: true,
161
+ header: i18next.t('field.product'),
162
+ width: 250
163
+ },
164
+ {
165
+ type: 'string',
166
+ name: 'packingType',
167
+ label: true,
168
+ header: i18next.t('field.packing_type'),
169
+ width: 120
170
+ },
171
+ {
172
+ type: 'integer',
173
+ name: 'packingSize',
174
+ label: true,
175
+ header: i18next.t('field.packing_size'),
176
+ width: 100
177
+ },
178
+ {
179
+ type: 'integer',
180
+ name: 'qty',
181
+ label: true,
182
+ header: i18next.t('field.qty'),
183
+ width: 100
184
+ },
185
+ {
186
+ type: 'string',
187
+ name: 'status',
188
+ label: true,
189
+ header: i18next.t('field.status'),
190
+ width: 120
191
+ }
192
+ ]
193
+ }
194
+
195
+ if (this.enableCartonLabel) {
196
+ this._focusOnCartonInput()
197
+ } else {
198
+ this._focusOnLotInput()
199
+ }
200
+ }
201
+
202
+ async _undoPutaway() {
203
+ try {
204
+ let selectedInventories = []
205
+ if (this._autoSelectInventory?.length) {
206
+ selectedInventories = this._autoSelectInventory
207
+ } else {
208
+ selectedInventories = this.dataGrist.selected
209
+ }
210
+ if (!selectedInventories?.length) throw new Error(i18next.t('text.select_at_least_one_inventory_to_undo'))
211
+
212
+ this._validateScanInventory()
213
+
214
+ let response = {}
215
+
216
+ if (this.orderType === AVAIL_ORDER_TYPES.ARRIVAL_NOTICE.value) {
217
+ response = await this._undoArrivalNoticePutaway(selectedInventories)
218
+ } else if (this.orderType === AVAIL_ORDER_TYPES.CUSTOMER_RETURN.value) {
219
+ response = await this._undoCustomerReturnPutaway(selectedInventories)
220
+ }
221
+
222
+ if (!response.errors) {
223
+ this.dispatchEvent(new CustomEvent('undo-inventory'))
224
+ }
225
+ } catch (e) {
226
+ this._showToast(e)
227
+ }
228
+ }
229
+
230
+ _populateTargetedInventory(e) {
231
+ if (e.keyCode === 13) {
232
+ e.preventDefault()
233
+
234
+ let targetedUndoInventories = []
235
+
236
+ if (this.enableCartonLabel) {
237
+ targetedUndoInventories = this.putawayInventories.filter(
238
+ inventory => inventory.cartonId === this.cartonInput?.value
239
+ )
240
+ } else {
241
+ targetedUndoInventories = this.putawayInventories.filter(
242
+ inventory => inventory.palletId === this.lotInput?.value
243
+ )
244
+ }
245
+
246
+ if (!targetedUndoInventories?.length) {
247
+ if (this.enableCartonLabel) {
248
+ this.cartonInput.value = ''
249
+ } else {
250
+ this.lotInput.value = ''
251
+ }
252
+ this._showToast({ message: i18next.t('text.no_matching_putaway_inventory_found') })
253
+ } else if (targetedUndoInventories?.length == 1) {
254
+ this.data = { records: targetedUndoInventories }
255
+ this._autoSelectInventory = targetedUndoInventories
256
+ this._undoPutaway()
257
+ } else {
258
+ this.data = { records: targetedUndoInventories }
259
+ }
260
+ }
261
+ }
262
+
263
+ async _undoArrivalNoticePutaway(selectedInventories) {
264
+ try {
265
+ const result = await CustomAlert({
266
+ title: i18next.t('title.are_you_sure'),
267
+ text: i18next.t('text.undo_putaway'),
268
+ confirmButton: { text: i18next.t('button.confirm') },
269
+ cancelButton: { text: i18next.t('button.cancel') }
270
+ })
271
+
272
+ if (!result.value) {
273
+ return
274
+ }
275
+
276
+ const response = await client.mutate({
277
+ mutation: gql`
278
+ mutation undoPutaway($worksheetDetailName: [String]!, $palletId: String, $cartonId: String) {
279
+ undoPutaway(worksheetDetailName: $worksheetDetailName, palletId: $palletId, cartonId: $cartonId)
280
+ }
281
+ `,
282
+ variables: {
283
+ worksheetDetailName: selectedInventories.map(inventory => inventory.name),
284
+ palletId: this.enableCartonLabel ? null : selectedInventories[0].palletId,
285
+ cartonId: this.enableCartonLabel ? selectedInventories[0].cartonId : null
286
+ }
287
+ })
288
+
289
+ if (!response.errors) {
290
+ return response
291
+ }
292
+ } catch (e) {
293
+ this._showToast(e)
294
+ }
295
+ }
296
+
297
+ async _undoCustomerReturnPutaway(selectedInventories) {
298
+ try {
299
+ const result = await CustomAlert({
300
+ title: i18next.t('title.are_you_sure'),
301
+ text: i18next.t('text.undo_putaway'),
302
+ confirmButton: { text: i18next.t('button.confirm') },
303
+ cancelButton: { text: i18next.t('button.cancel') }
304
+ })
305
+
306
+ if (!result.value) {
307
+ return
308
+ }
309
+
310
+ const response = await client.mutate({
311
+ mutation: gql`
312
+ mutation undoPutawayReturn($worksheetDetailName: [String]!, $palletId: String, $cartonId: String) {
313
+ undoPutawayReturn(worksheetDetailName: $worksheetDetailName, palletId: $palletId, cartonId: $cartonId)
314
+ }
315
+ `,
316
+ variables: {
317
+ worksheetDetailName: selectedInventories.map(inventory => inventory.name),
318
+ palletId: this.enableCartonLabel ? null : selectedInventories[0].palletId,
319
+ cartonId: this.enableCartonLabel ? selectedInventories[0].cartonId : null
320
+ }
321
+ })
322
+
323
+ if (!response.errors) {
324
+ return response
325
+ }
326
+ } catch (e) {
327
+ this._showToast(e)
328
+ }
329
+ }
330
+
331
+ _focusOnLotInput() {
332
+ setTimeout(() => this.lotInput.focus(), 100)
333
+ }
334
+
335
+ _focusOnCartonInput() {
336
+ setTimeout(() => this.cartonInput.focus(), 100)
337
+ }
338
+
339
+ _validateScanInventory() {
340
+ if (this.enableCartonLabel) {
341
+ if (!this.cartonInput?.value) {
342
+ this._focusOnCartonInput()
343
+ throw new Error(i18next.t('text.carton_id_is_empty'))
344
+ }
345
+ } else {
346
+ if (!this.lotInput?.value) {
347
+ this._focusOnLotInput()
348
+ throw new Error(i18next.t('text.lot_id_is_empty'))
349
+ }
350
+ }
351
+ }
352
+
353
+ _showToast({ type, message }) {
354
+ document.dispatchEvent(
355
+ new CustomEvent('notify', {
356
+ detail: {
357
+ type,
358
+ message
359
+ }
360
+ })
361
+ )
362
+ }
363
+ }
364
+
365
+ window.customElements.define('undo-putaway-popup', UndoPutawayPopup)
@@ -187,14 +187,14 @@ export class EditProductPopup extends localize(i18next)(LitElement) {
187
187
  type: 'float',
188
188
  name: 'uomValue',
189
189
  header: i18next.t('field.uom_value'),
190
- record: { editable: true, options: { min: 0 } },
190
+ record: { options: { min: 0 } },
191
191
  width: 80
192
192
  },
193
193
  {
194
194
  type: 'code',
195
195
  name: 'uom',
196
196
  header: i18next.t('field.uom'),
197
- record: { editable: true, codeName: 'WEIGHT_UNITS' },
197
+ record: { codeName: 'WEIGHT_UNITS' },
198
198
  width: 80
199
199
  },
200
200
  {
@@ -214,7 +214,17 @@ class ReverseKittingOrderList extends localize(i18next)(PageView) {
214
214
  }
215
215
 
216
216
  _exportableData() {
217
- return this.dataGrist.exportRecords()
217
+ return {
218
+ header: [
219
+ { header: i18next.t('field.order_no'), key: 'name', width: 25, type: 'string' },
220
+ { header: i18next.t('field.status'), key: 'status', width: 25, type: 'string' },
221
+ { header: i18next.t('field.updated_at'), key: 'updatedAt', width: 30, type: 'date' },
222
+ { header: i18next.t('field.updater'), key: 'updater', width: 25, type: 'string' }
223
+ ],
224
+ data: this.dataGrist?.data?.records?.map(record => {
225
+ return { ...record, updater: record.updater.name }
226
+ })
227
+ }
218
228
  }
219
229
  }
220
230
 
@@ -229,8 +229,8 @@ class ElcclDeliveryOrderSummary extends connect(store)(localize(i18next)(PageVie
229
229
 
230
230
  const response = await client.query({
231
231
  query: gql`
232
- query deliveryOrderSummaryReport($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
233
- deliveryOrders(filters: $filters, pagination: $pagination, sortings: $sortings) {
232
+ query deliveryOrderReport($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
233
+ deliveryOrderReport(filters: $filters, pagination: $pagination, sortings: $sortings) {
234
234
  items {
235
235
  id
236
236
  name
@@ -272,9 +272,9 @@ class ElcclDeliveryOrderSummary extends connect(store)(localize(i18next)(PageVie
272
272
 
273
273
  if (!response.errors) {
274
274
  return {
275
- total: response.data.deliveryOrders.total || 0,
275
+ total: response.data.deliveryOrderReport.total || 0,
276
276
  records:
277
- response.data.deliveryOrders.items.map(itm => {
277
+ response.data.deliveryOrderReport.items.map(itm => {
278
278
  let remarks = (itm.orderInventories || []).reduce((acc, itm) => {
279
279
  let dt = {
280
280
  product_name: `${itm.inventory.product.name} (${itm.inventory.product.description})`,
@@ -402,7 +402,7 @@ class PopupReverseKittingTemplate extends localize(i18next)(LitElement) {
402
402
  this._focusOnQtyInput()
403
403
  throw new Error(i18next.t('text.qty_is_empty'))
404
404
  } else {
405
- if (!this.qtyInput.checkValidity()) throw new Error(i18next.t('text.qty_invalid'))
405
+ if (!this.qtyInput.checkValidity()) throw new Error(i18next.t('text.invalid_qty'))
406
406
  }
407
407
 
408
408
  // 4. location code existing