@things-factory/operato-wms 4.3.512 → 4.3.514

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,549 @@
1
+ import '@things-factory/grist-ui'
2
+
3
+ import gql from 'graphql-tag'
4
+ import { css, html, LitElement } from 'lit-element'
5
+
6
+ import { i18next, localize } from '@things-factory/i18n-base'
7
+ import { client, CustomAlert } from '@things-factory/shell'
8
+ import { ScrollbarStyles } from '@things-factory/styles'
9
+ import { isMobileDevice } from '@things-factory/utils'
10
+
11
+ export class ProceedEditVasPopup extends localize(i18next)(LitElement) {
12
+ static get styles() {
13
+ return [
14
+ ScrollbarStyles,
15
+ css`
16
+ :host {
17
+ display: flex;
18
+ flex-direction: column;
19
+ overflow: hidden;
20
+ background-color: white;
21
+ }
22
+ .grist-container {
23
+ overflow-y: auto;
24
+ display: flex;
25
+ flex: 1;
26
+ margin: 10px;
27
+ }
28
+ .grist {
29
+ display: flex;
30
+ flex-direction: column;
31
+ flex: 1;
32
+ overflow-y: auto;
33
+ }
34
+ .grist h2 mwc-icon {
35
+ vertical-align: middle;
36
+ margin: var(--grist-title-icon-margin);
37
+ font-size: var(--grist-title-icon-size);
38
+ color: var(--grist-title-icon-color);
39
+ }
40
+ data-grist {
41
+ overflow-y: hidden;
42
+ flex: 1;
43
+ }
44
+ h2 {
45
+ padding: var(--subtitle-padding);
46
+ font: var(--subtitle-font);
47
+ color: var(--subtitle-text-color);
48
+ border-bottom: var(--subtitle-border-bottom);
49
+ }
50
+ .grist h2 {
51
+ font: var(--grist-title-font);
52
+ }
53
+ .button-container {
54
+ padding: var(--button-container-padding);
55
+ margin: var(--button-container-margin);
56
+ text-align: var(--button-container-align);
57
+ background-color: var(--button-container-background);
58
+ height: var(--button-container-height);
59
+ }
60
+ [danger] {
61
+ --mdc-theme-primary: var(--mdc-danger-button-primary-color);
62
+ }
63
+ `
64
+ ]
65
+ }
66
+
67
+ static get properties() {
68
+ return {
69
+ config: Object,
70
+ data: Object,
71
+ bizplace: String,
72
+ releaseGoodNo: String
73
+ }
74
+ }
75
+
76
+ render() {
77
+ return html`
78
+ <div class="grist-container">
79
+ <div class="grist">
80
+ <h2><mwc-icon>list-alt</mwc-icon>${i18next.t('title.approve')}</h2>
81
+ <data-grist
82
+ id="approve-grist"
83
+ .mode="${isMobileDevice() ? 'LIST' : 'GRID' }"
84
+ .config="${this.config}"
85
+ .data="${this.approvedData}"
86
+ ></data-grist>
87
+ </div>
88
+
89
+ <div class="grist">
90
+ <h2><mwc-icon>list-alt</mwc-icon>${i18next.t('title.reject')}</h2>
91
+ <data-grist
92
+ id="reject-grist"
93
+ .mode="${isMobileDevice() ? 'LIST' : 'GRID' }"
94
+ .config="${this.config}"
95
+ .data="${this.rejectedData}"
96
+ ></data-grist>
97
+ </div>
98
+ </div>
99
+
100
+ <div class="button-container">
101
+ <mwc-button
102
+ raised
103
+ @click="${this._approveVasChanges.bind(this)}"
104
+ label="${i18next.t('button.approve')}"
105
+ ></mwc-button>
106
+ <mwc-button
107
+ raised
108
+ danger
109
+ @click="${this._rejectVasChanges.bind(this)}"
110
+ label="${i18next.t('button.reject')}"
111
+ ></mwc-button>
112
+ <mwc-button
113
+ raised
114
+ @click="${this._proceedEditedVas.bind(this)}"
115
+ label="${i18next.t('button.confirm')}"
116
+ ></mwc-button>
117
+ </div>
118
+ `
119
+ }
120
+
121
+ constructor() {
122
+ super()
123
+ this.approvedData = { records: [] }
124
+ this.rejectedData = { records: [] }
125
+ }
126
+
127
+ get approveGrist() {
128
+ return this.shadowRoot.querySelector('data-grist#approve-grist')
129
+ }
130
+
131
+ get rejectGrist() {
132
+ return this.shadowRoot.querySelector('data-grist#reject-grist')
133
+ }
134
+
135
+ updated(changedProps) {
136
+ if (changedProps.has('data')) {
137
+ this.approvedData = {
138
+ ...this.data,
139
+ records: this.data.records.filter(
140
+ item => item.editType || item.itemEditType
141
+ )
142
+ }
143
+ }
144
+ }
145
+
146
+ firstUpdated() {
147
+ this.config = {
148
+ list: {
149
+ fields: [
150
+ 'itemEditType',
151
+ 'batchId',
152
+ 'productSKU',
153
+ 'adjustedBatchId',
154
+ 'adjustedSku',
155
+ 'qty',
156
+ 'adjustedQty',
157
+ 'packingType',
158
+ 'adjustedPackingType',
159
+ 'uom',
160
+ 'adjustedUom',
161
+ 'uomValue',
162
+ 'adjustedUomValue',
163
+ 'vas',
164
+ 'vasQty',
165
+ 'adjustedVasQty',
166
+ 'newBatchId',
167
+ 'adjustedNewBatchId',
168
+ 'newSKU',
169
+ 'adjustedNewSku',
170
+ 'newPackingType',
171
+ 'adjustedNewPackingType',
172
+ 'newUom',
173
+ 'adjustedNewUom',
174
+ 'newUnitUomValue',
175
+ 'adjustedNewUnitUomValue',
176
+ 'newUomValue',
177
+ 'adjustedNewUomValue',
178
+ 'outputQty',
179
+ 'adjustedOutputQty',
180
+ 'vasRemark',
181
+ 'adjustedVasRemark',
182
+ ]
183
+ },
184
+ pagination: { infinite: true },
185
+ rows: {
186
+ selectable: {multiple: true },
187
+ groups: { column: 'productSKU' },
188
+ appendable: false,
189
+ },
190
+ columns: [
191
+ { type: 'gutter', gutterName: 'sequence' },
192
+ {
193
+ type: 'gutter',
194
+ gutterName: 'row-selector',
195
+ multiple: true
196
+ },
197
+ {
198
+ type: 'string',
199
+ name: 'itemEditType',
200
+ header: i18next.t('field.type'),
201
+ width: 100
202
+ },
203
+ {
204
+ type: 'string',
205
+ name: 'batchId',
206
+ header: i18next.t('field.batch_no'),
207
+ width: 150
208
+ },
209
+ {
210
+ type: 'string',
211
+ name: 'productSKU',
212
+ header: i18next.t('field.sku'),
213
+ width: 150
214
+ },
215
+ {
216
+ type: 'string',
217
+ name: 'adjustedBatchId',
218
+ header: i18next.t('field.adjusted_batch_id'),
219
+ width: 150
220
+ },
221
+ {
222
+ type: 'string',
223
+ name: 'adjustedSku',
224
+ header: i18next.t('field.adjusted_sku'),
225
+ width: 150
226
+ },
227
+ {
228
+ type: 'integer',
229
+ name: 'qty',
230
+ header: i18next.t('field.qty'),
231
+ width: 100
232
+ },
233
+ {
234
+ type: 'string',
235
+ name: 'adjustedQty',
236
+ header: i18next.t('field.adjusted_qty'),
237
+ width: 100
238
+ },
239
+ {
240
+ type: 'string',
241
+ name: 'packingType',
242
+ header: i18next.t('field.packing_type_sku', { sku: 'SKU' }),
243
+ width: 150
244
+ },
245
+ {
246
+ type: 'string',
247
+ name: 'adjustedPackingType',
248
+ header: i18next.t('field.adjusted_packing_type_sku', { sku: 'SKU' }),
249
+ width: 150
250
+ },
251
+ {
252
+ type: 'string',
253
+ name: 'uom',
254
+ header: i18next.t('field.uom_sku', { sku: 'SKU' }),
255
+ width: 100
256
+ },
257
+ {
258
+ type: 'string',
259
+ name: 'adjustedUom',
260
+ header: i18next.t('field.adjusted_uom', { sku: 'SKU'}),
261
+ width: 100
262
+ },
263
+ {
264
+ type: 'integer',
265
+ name: 'uomValue',
266
+ header: i18next.t('field.uom_value_sku', { sku: 'SKU' }),
267
+ width: 100
268
+ },
269
+ {
270
+ type: 'integer',
271
+ name: 'adjustedUomValue',
272
+ header: i18next.t('field.adjusted_uom_value_sku', { sku: 'SKU' }),
273
+ width: 100
274
+ },
275
+ {
276
+ type: 'string',
277
+ name: 'group',
278
+ hidden: true
279
+ },
280
+ {
281
+ type: 'string',
282
+ name: 'orderVasItemId',
283
+ hidden: true,
284
+ },
285
+ {
286
+ type: 'object',
287
+ name: 'vas',
288
+ header: i18next.t('field.vas'),
289
+ width: 250
290
+ },
291
+ {
292
+ type: 'integer',
293
+ name: 'vasQty',
294
+ header: i18next.t('field.vas_qty'),
295
+ width: 80
296
+ },
297
+ {
298
+ type: 'integer',
299
+ name: 'adjustedVasQty',
300
+ header: i18next.t('field.adjusted_vas_qty'),
301
+ width: 80
302
+ },
303
+ {
304
+ type: 'string',
305
+ name: 'newBatchId',
306
+ header: i18next.t('field.batch_no_(new_sku)'),
307
+ width: 150
308
+ },
309
+ {
310
+ type: 'string',
311
+ name: 'adjustedNewBatchId',
312
+ header: i18next.t('field.adjusted_batch_id_new_sku'),
313
+ width: 150
314
+ },
315
+ {
316
+ type: 'string',
317
+ name: 'newSku',
318
+ header: i18next.t('field.new_sku'),
319
+ width: 200
320
+ },
321
+ {
322
+ type: 'string',
323
+ name: 'adjustedSku',
324
+ header: i18next.t('field.adjusted_new_sku'),
325
+ width: 200
326
+ },
327
+ {
328
+ type: 'string',
329
+ name: 'newPackingType',
330
+ header: i18next.t('field.packing_type_sku', { sku: 'N. SKU' }),
331
+ width: 150
332
+ },
333
+ {
334
+ type: 'string',
335
+ name: 'adjustedNewPackingType',
336
+ header: i18next.t('field.adjusted_packing_type_sku', { sku: 'N. SKU' }),
337
+
338
+ width: 150
339
+ },
340
+ {
341
+ type: 'string',
342
+ name: 'newUom',
343
+ header: i18next.t('field.uom_sku', { sku: 'N.SKU' }),
344
+ width: 80
345
+ },
346
+ {
347
+ type: 'string',
348
+ name: 'adjustedNewUom',
349
+ header: i18next.t('field.adjusted_uom_sku', { sku: 'N.SKU' }),
350
+ width: 80
351
+ },
352
+ {
353
+ type: 'float',
354
+ name: 'newUnitUomValue',
355
+ header: i18next.t('field.uom_value_sku', { sku: 'NEW SKU' }),
356
+ width: 150
357
+ },
358
+ {
359
+ type: 'float',
360
+ name: 'adjustedNewUnitUomValue',
361
+ header: i18next.t('field.adjusted_uom_value_sku', { sku: 'NEW SKU' }),
362
+ width: 150
363
+ },
364
+ {
365
+ type: 'float',
366
+ name: 'newUomValue',
367
+ header: i18next.t('field.total_uom_value_sku', { sku: 'N.SKU' }),
368
+ width: 150
369
+ },
370
+ {
371
+ type: 'float',
372
+ name: 'adjustedNewUomValue',
373
+ header: i18next.t('field.adjusted_total_uom_value_sku', { sku:'N.SKU' }),
374
+ width: 150
375
+ },
376
+ {
377
+ type: 'integer',
378
+ name: 'outputQty',
379
+ header: i18next.t('field.output_qty'),
380
+ width: 100
381
+ },
382
+ {
383
+ type: 'integer',
384
+ name: 'adjustedOutputQty',
385
+ header: i18next.t('field.adjusted_output_qty'),
386
+ width: 100
387
+ },
388
+ {
389
+ type: 'string',
390
+ name: 'vasRemark',
391
+ header: i18next.t('field.remark'),
392
+ width: 400
393
+ },
394
+ {
395
+ type: 'string',
396
+ name: 'adjustedVasRemark',
397
+ header: i18next.t('field.adjusted_vas_remark'),
398
+ width: 400
399
+ }
400
+ ]
401
+ }
402
+ }
403
+
404
+ async _approveVasChanges() {
405
+ if (!this.rejectGrist.selected || !this.rejectGrist.selected.length) return
406
+
407
+ const selectedGroups = this.rejectGrist.selected.map(record => record.group)
408
+
409
+ const approvedData = [
410
+ ...this.approveGrist.data.records,
411
+ ...this.rejectGrist.data.records.filter(record =>
412
+ selectedGroups.some(group => group === record.group)
413
+ )
414
+ ]
415
+
416
+ const rejectedData = this.rejectGrist.data.records.filter(record =>
417
+ !selectedGroups.some(group => group === record.group)
418
+ )
419
+
420
+ this.approveGrist.data = { records: [] }
421
+ this.rejectGrist.data = { records: [] }
422
+
423
+ await this.approveGrist.updateComplete
424
+ await this.rejectGrist.updateComplete
425
+
426
+ this.approveGrist.data = { records: approvedData }
427
+ this.rejectGrist.data = { records: rejectedData }
428
+ }
429
+
430
+ async _rejectVasChanges() {
431
+ if (!this.approveGrist.selected || !this.approveGrist.selected.length) return
432
+
433
+ const selectedGroups = this.approveGrist.selected.map(record => record.group)
434
+
435
+ const rejectedData = [
436
+ ...this.rejectGrist.data.records,
437
+ ...this.approveGrist.data.records.filter(record =>
438
+ selectedGroups.some(group => group === record.group)
439
+ )
440
+ ]
441
+
442
+ const approvedData = this.approveGrist.data.records.filter(record =>
443
+ !selectedGroups.some(group => group === record.group)
444
+ )
445
+
446
+ this.approveGrist.data = { records: [] }
447
+ this.rejectGrist.data = { records: [] }
448
+
449
+ await this.approveGrist.updateComplete
450
+ await this.rejectGrist.updateComplete
451
+
452
+ this.approveGrist.data = { records: approvedData }
453
+ this.rejectGrist.data = { records: rejectedData }
454
+ }
455
+
456
+ async _proceedEditedVas() {
457
+ try {
458
+ const result = await CustomAlert({
459
+ title: i18next.t('title.are_you_sure'),
460
+ text: i18next.t('text.you_wont_be_able_to_revert_this'),
461
+ confirmButton: { text: i18next.t('button.confirm') },
462
+ cancelButton: { text: i18next.t('button.cancel') }
463
+ })
464
+
465
+ if (!result.value) return
466
+
467
+ const response = await client.mutate({
468
+ mutation: gql`
469
+ mutation proceedVasChanges(
470
+ $releaseOrderNo: String!
471
+ $bizplaceId: String!
472
+ $approvedVas: [OrderVasPatch!]
473
+ $rejectedVas: [OrderVasPatch!]
474
+ ) {
475
+ proceedVasChanges(
476
+ releaseOrderNo: $releaseOrderNo
477
+ bizplaceId: $bizplaceId
478
+ approvedVas: $approvedVas
479
+ rejectedVas: $rejectedVas
480
+ )
481
+ }
482
+ `,
483
+ variables: {
484
+ releaseOrderNo: this.releaseGoodNo,
485
+ bizplaceId: this.bizplace,
486
+ approvedVas: await this._getApprovedVas(),
487
+ rejectedVas: await this._getRejectedVas()
488
+ }
489
+ })
490
+
491
+ if (!response.errors) {
492
+ this._showToast({ message: i18next.t('text.vas_changes_has_been_processed') })
493
+ this.dispatchEvent(new CustomEvent('completed'))
494
+ window.history.back()
495
+ }
496
+ } catch(e) {
497
+ this._showToast({ message: e.message })
498
+ }
499
+ }
500
+
501
+ _getApprovedVas() {
502
+ return this.approveGrist?.dirtyData.records
503
+ .map(ov => {
504
+ return {
505
+ id: ov?.id,
506
+ editType: ov.editType,
507
+ orderVasItemsPatch: this.approveGrist.dirtyData.records.reduce((acc, cur) => {
508
+ if (cur.group === ov.group) {
509
+ return [...acc, { id: cur?.orderVasItemId, itemEditType: cur?.itemEditType }]
510
+ } else {
511
+ return acc
512
+ }
513
+ }, [])
514
+ }
515
+ })
516
+ .filter(ov => ov.id)
517
+ }
518
+
519
+ _getRejectedVas() {
520
+ return this.rejectGrist.dirtyData.records
521
+ .map(ov => {
522
+ return {
523
+ id: ov?.id,
524
+ editType: ov.editType,
525
+ orderVasItemsPatch: this.rejectGrist.dirtyData.records.reduce((acc, cur) => {
526
+ if (cur.group === ov.group) {
527
+ return [...acc, { id: cur?.orderVasItemId, itemEditType: cur?.itemEditType }]
528
+ } else {
529
+ return acc
530
+ }
531
+ }, []),
532
+ }
533
+ })
534
+ .filter(ov => ov.id)
535
+ }
536
+
537
+ _showToast({ type, message }) {
538
+ document.dispatchEvent(
539
+ new CustomEvent('notify', {
540
+ detail: {
541
+ type,
542
+ message
543
+ }
544
+ })
545
+ )
546
+ }
547
+ }
548
+
549
+ window.customElements.define('proceed-edit-vas-popup', ProceedEditVasPopup)
@@ -17,7 +17,8 @@ class SelectVasPopup extends localize(i18next)(LitElement) {
17
17
  vasData: Object,
18
18
  type: String,
19
19
  partnerBizplaceIds: Array,
20
- selectedVasData: Object
20
+ selectedVasData: Object,
21
+ deletedVas: Array
21
22
  }
22
23
  }
23
24
 
@@ -83,6 +84,7 @@ class SelectVasPopup extends localize(i18next)(LitElement) {
83
84
  this.partnerBizplaceIds = []
84
85
  this.vasData = { records: [], total: 0 }
85
86
  this.selectedVasData = { records: [] }
87
+ this.deletedVas = []
86
88
  }
87
89
 
88
90
  render() {
@@ -209,6 +211,7 @@ class SelectVasPopup extends localize(i18next)(LitElement) {
209
211
  click: (columns, data, column, record, rowIndex) => {
210
212
  this.selectedVasGrist.dirtyData?.records.splice(rowIndex, 1)
211
213
  this.selectedVasData = { records: this.selectedVasGrist.dirtyData?.records }
214
+ this.deletedVas.push({ ...record })
212
215
  this.firstUpdated()
213
216
  }
214
217
  }
@@ -338,6 +341,7 @@ class SelectVasPopup extends localize(i18next)(LitElement) {
338
341
  _selectVas() {
339
342
  if (this.selectedVasGrist.dirtyData.records.length > 0) {
340
343
  this.dispatchEvent(new CustomEvent('selected', { detail: this.selectedVasGrist.dirtyData.records }))
344
+ this.dispatchEvent(new CustomEvent('deleted', { detail: this.deletedVas }))
341
345
  history.back()
342
346
  } else {
343
347
  document.dispatchEvent(new CustomEvent('notify', { detail: { message: i18next.t('text.nothing_selected') } }))