@things-factory/operato-wms 4.3.491 → 4.3.493

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.
@@ -3,6 +3,7 @@ import '@things-factory/grist-ui'
3
3
  import '../components/worksheet-information-popup'
4
4
  import './serial-number-popup'
5
5
  import './order-remark-popup'
6
+ import './packing-serial-number-popup'
6
7
 
7
8
  import gql from 'graphql-tag'
8
9
  import { css, html } from 'lit-element'
@@ -171,7 +172,7 @@ class PackingProduct extends connect(store)(localize(i18next)(PageView)) {
171
172
  })
172
173
  }
173
174
 
174
- if (this._selectedOrderInventory && this._isRequireSerialNumberScanningOutbound && this._isBatchPicking) {
175
+ if (this._isRequireSerialNumberScanningOutbound && this._isBatchPicking) {
175
176
  actions.push({
176
177
  title: i18next.t('button.serial_number'),
177
178
  action: this.openSerialNumberPopup.bind(this),
@@ -504,6 +505,7 @@ class PackingProduct extends connect(store)(localize(i18next)(PageView)) {
504
505
  }
505
506
  }
506
507
  platform
508
+ isBatchPicking
507
509
  }
508
510
  worksheetDetailInfos {
509
511
  id
@@ -515,6 +517,7 @@ class PackingProduct extends connect(store)(localize(i18next)(PageView)) {
515
517
  sku
516
518
  product {
517
519
  id
520
+ sku
518
521
  name
519
522
  description
520
523
  gtin
@@ -545,6 +548,10 @@ class PackingProduct extends connect(store)(localize(i18next)(PageView)) {
545
548
  batchIdRef
546
549
  packingType
547
550
  refWorksheetId
551
+ binLocation {
552
+ id
553
+ name
554
+ }
548
555
  product {
549
556
  id
550
557
  sku
@@ -552,6 +559,9 @@ class PackingProduct extends connect(store)(localize(i18next)(PageView)) {
552
559
  description
553
560
  isRequireSerialNumberScanningOutbound
554
561
  }
562
+ productDetail {
563
+ id
564
+ }
555
565
  }
556
566
  }
557
567
  }
@@ -1427,18 +1437,15 @@ class PackingProduct extends connect(store)(localize(i18next)(PageView)) {
1427
1437
  await sleep(1010)
1428
1438
  openPopup(
1429
1439
  html`
1430
- <serial-number-popup
1431
- .enableRemove=${false}
1432
- .enableUpdateBtn=${false}
1433
- .orderInventory="${this?._selectedOrderInventory?.relatedOrderInv}"
1440
+ <packing-serial-number-popup
1434
1441
  .orderType="${i18next.t('text.outbound')}"
1435
1442
  .orderSource="${ORDER_SOURCES.PACKING.value}"
1436
1443
  .orderId="${this.releaseGoodId}"
1437
- .data="${this?._selectedOrderInventory}"
1444
+ .orderPackageId="${this._orderPackageInformation?.orderPackage?.id}"
1438
1445
  @close-serial-number-popup="${async e => {
1439
1446
  await this.fetchInventories(this.releaseGoodNo)
1440
1447
  }}"
1441
- ></serial-number-popup>
1448
+ ></packing-serial-number-popup>
1442
1449
  `,
1443
1450
  {
1444
1451
  closable: false,
@@ -0,0 +1,378 @@
1
+ import '@things-factory/barcode-ui'
2
+ import '@things-factory/grist-ui'
3
+
4
+ import gql from 'graphql-tag'
5
+ import { css, html, LitElement } from 'lit-element'
6
+
7
+ import { MultiColumnFormStyles, SingleColumnFormStyles } from '@things-factory/form-ui'
8
+ import { i18next, localize } from '@things-factory/i18n-base'
9
+ import { client } from '@things-factory/shell'
10
+ import { isMobileDevice } from '@things-factory/utils'
11
+
12
+ import { ORDER_SOURCES } from '../constants'
13
+
14
+ class PackingSerialNumberPopup extends localize(i18next)(LitElement) {
15
+ static get styles() {
16
+ return [
17
+ MultiColumnFormStyles,
18
+ SingleColumnFormStyles,
19
+ css`
20
+ :host {
21
+ padding: 10px;
22
+ display: flex;
23
+ flex-direction: column;
24
+ overflow-x: overlay;
25
+ background-color: var(--main-section-background-color);
26
+ }
27
+ .grist {
28
+ background-color: var(--main-section-background-color);
29
+ display: flex;
30
+ flex-direction: column;
31
+ flex: 1;
32
+ overflow-y: auto;
33
+ }
34
+ data-grist {
35
+ overflow-y: hidden;
36
+ flex: 1;
37
+ }
38
+ .button-container {
39
+ padding: 10px 0 12px 0;
40
+ text-align: center;
41
+ display: flex;
42
+ flex-direction: column;
43
+ }
44
+
45
+ @media (max-width: 460px) {
46
+ .single-column-form {
47
+ max-width: 100%;
48
+ }
49
+ .mobile-full-width {
50
+ grid-column: span 12 / auto;
51
+ }
52
+ }
53
+ `
54
+ ]
55
+ }
56
+
57
+ static get properties() {
58
+ return {
59
+ orderInventory: Object,
60
+ config: Object,
61
+ data: Object,
62
+ orderId: String,
63
+ orderType: String,
64
+ orderSource: String,
65
+ orderPackageId: String,
66
+ _inventoryItems: Object,
67
+ _selectedSerialNumber: Object
68
+ // enableRemove: Boolean,
69
+ // enableUpdateBtn: Boolean
70
+ }
71
+ }
72
+
73
+ get serialInput() {
74
+ return this.shadowRoot
75
+ ?.querySelector('barcode-scanable-input[name=serialNumber]')
76
+ ?.shadowRoot.querySelector('input')
77
+ }
78
+
79
+ get dataGrist() {
80
+ return this.shadowRoot.querySelector('data-grist')
81
+ }
82
+
83
+ _focusOnSerialInput() {
84
+ if (this.serialInput) {
85
+ setTimeout(() => this.serialInput.focus(), 50)
86
+ }
87
+ }
88
+
89
+ constructor() {
90
+ super()
91
+ this.clearView()
92
+ // this.enableRemove = true
93
+ // this.enableUpdateBtn = true
94
+ }
95
+
96
+ render() {
97
+ return html`
98
+ <div class="grist">
99
+ <data-grist
100
+ .mode=${isMobileDevice() ? 'LIST' : 'GRID'}
101
+ .config=${this.config}
102
+ .data=${this._inventoryItems}
103
+ ></data-grist>
104
+ </div>
105
+
106
+ <form id="input-form" class="single-column-form" @keypress="${this.updateSerialNumber.bind(this)}">
107
+ <input
108
+ name="selectedSerialNumber"
109
+ placeholder="-- Selected Serial Number --"
110
+ disabled
111
+ readonly
112
+ class="mobile-full-width"
113
+ value="${this._selectedSerialNumber.serialNumber}"
114
+ />
115
+ <barcode-scanable-input name="serialNumber" class="mobile-full-width" custom-input></barcode-scanable-input>
116
+ <mwc-button
117
+ name="setSerialNumber"
118
+ class="mobile-full-width"
119
+ raised
120
+ @click=${this.updateSerialNumber.bind(this)}
121
+ label="${i18next.t('button.update')}"
122
+ ></mwc-button>
123
+ </form>
124
+
125
+ <div class="button-container">
126
+ <mwc-button
127
+ danger
128
+ @click=${() => {
129
+ this.dispatchEvent(new CustomEvent('close-serial-number-popup', {}))
130
+ history.back()
131
+ }}
132
+ raised
133
+ label="${i18next.t('button.back')}"
134
+ ></mwc-button>
135
+ </div>
136
+ `
137
+ }
138
+
139
+ async firstUpdated() {
140
+ this.clearView()
141
+
142
+ this.config = {
143
+ rows: {
144
+ appendable: false,
145
+ classifier: (record, rowIndex) => {
146
+ return {
147
+ emphasized: record.completed == true
148
+ }
149
+ },
150
+ handlers: {
151
+ click: async (columns, data, column, record, rowIndex) => {
152
+ try {
153
+ this.dataGrist.showSpinner()
154
+ if (data.records.length && record) {
155
+ this._selectedSerialNumber = {
156
+ ...record,
157
+ product: { id: record.product.id, name: record.product.name }
158
+ }
159
+ delete this._selectedSerialNumber.__seq__
160
+ delete this._selectedSerialNumber.__origin__
161
+ }
162
+ } catch (ex) {
163
+ console.log(ex)
164
+ } finally {
165
+ this.dataGrist.hideSpinner()
166
+ }
167
+ }
168
+ }
169
+ },
170
+ pagination: { infinite: true },
171
+ list: {
172
+ fields: ['serialNumber']
173
+ },
174
+ columns: [
175
+ { type: 'gutter', gutterName: 'sequence' },
176
+ {
177
+ type: 'gutter',
178
+ gutterName: 'button',
179
+ icon: 'close',
180
+ handlers: {
181
+ click: (columns, data, column, record, rowIndex) => {
182
+ try {
183
+ const newData = data.records.filter((_, idx) => idx !== rowIndex)
184
+ this._inventoryItems = { ...this._inventoryItems, records: newData }
185
+ this.undoSerialNumberPacking(record.id)
186
+ } catch (e) {}
187
+ }
188
+ }
189
+ },
190
+ {
191
+ type: 'string',
192
+ name: 'serialNumber',
193
+ header: i18next.t('field.serial_number'),
194
+ width: 150
195
+ },
196
+ {
197
+ type: 'string',
198
+ name: 'sku',
199
+ header: i18next.t('field.sku'),
200
+ width: 150
201
+ },
202
+ {
203
+ type: 'string',
204
+ name: 'productName',
205
+ header: i18next.t('field.product'),
206
+ width: 300
207
+ }
208
+ ]
209
+ }
210
+ await this.fetchInventoryItems()
211
+ this._focusOnSerialInput()
212
+ }
213
+
214
+ clearView() {
215
+ this._selectedSerialNumber = {}
216
+ if (this.serialInput) this.serialInput.value = ''
217
+ }
218
+
219
+ async fetchInventoryItems() {
220
+ let filters = [
221
+ { name: 'orderType', operator: 'eq', value: this.orderType },
222
+ { name: 'orderId', operator: 'eq', value: this.orderId },
223
+ { name: 'orderPackageId', operator: 'eq', value: this.orderPackageId }
224
+ ]
225
+
226
+ const sortings = []
227
+
228
+ const response = await client.query({
229
+ query: gql`
230
+ query inventoryItemsByOrder($filters: [Filter!]!, $sortings: [Sorting!]!) {
231
+ inventoryItemsByOrder(filters: $filters, sortings: $sortings) {
232
+ items {
233
+ id
234
+ name
235
+ status
236
+ serialNumber
237
+ outboundOrderId
238
+ orderPackageId
239
+ inventory {
240
+ id
241
+ name
242
+ }
243
+ product {
244
+ id
245
+ sku
246
+ name
247
+ }
248
+ productDetail {
249
+ id
250
+ name
251
+ }
252
+ }
253
+ total
254
+ }
255
+ }
256
+ `,
257
+ variables: { filters, sortings }
258
+ })
259
+
260
+ if (!response.errors) {
261
+ this._inventoryItems = {
262
+ records: response.data.inventoryItemsByOrder.items.map(item => ({
263
+ ...item,
264
+ sku: item.product.sku,
265
+ productName: item.product.name
266
+ }))
267
+ }
268
+ }
269
+ }
270
+
271
+ async updateSerialNumber(e) {
272
+ if (e.keyCode === 13 || e.type == 'click') {
273
+ e.preventDefault()
274
+ try {
275
+ this.validate()
276
+
277
+ const { id, name, status, serialNumber, outboundOrderId, orderPackageId, inventory, product, productDetail } =
278
+ this._selectedSerialNumber
279
+
280
+ const selectedSerialNumber = {
281
+ id,
282
+ name,
283
+ status,
284
+ serialNumber,
285
+ outboundOrderId,
286
+ orderPackageId,
287
+ inventory: { id: inventory.id, name: inventory.name },
288
+ product: { id: product.id, name: product.name },
289
+ productDetail: { id: productDetail.id, name: productDetail.name }
290
+ }
291
+
292
+ const response = await client.mutate({
293
+ mutation: gql`
294
+ mutation replacePackedInventoryItem($selectedSerialNumber: InventoryItemPatch!, $newSerialNumber: String!) {
295
+ replacePackedInventoryItem(
296
+ selectedSerialNumber: $selectedSerialNumber
297
+ newSerialNumber: $newSerialNumber
298
+ ) {
299
+ id
300
+ name
301
+ serialNumber
302
+ }
303
+ }
304
+ `,
305
+ variables: {
306
+ selectedSerialNumber,
307
+ newSerialNumber: this.serialInput.value.trim()
308
+ }
309
+ })
310
+
311
+ if (!response.errors) {
312
+ this.clearView()
313
+ await this.fetchInventoryItems()
314
+ this._focusOnSerialInput()
315
+ }
316
+ } catch (e) {
317
+ this._showToast(e)
318
+ }
319
+ }
320
+ }
321
+
322
+ async undoSerialNumberPacking(id) {
323
+ try {
324
+ let response = await client.mutate({
325
+ mutation: gql`
326
+ mutation undoSerialNumberPacking(
327
+ $releaseGoodId: String!
328
+ $orderPackageId: String!
329
+ $inventoryItemId: String!
330
+ ) {
331
+ undoSerialNumberPacking(
332
+ releaseGoodId: $releaseGoodId
333
+ orderPackageId: $orderPackageId
334
+ inventoryItemId: $inventoryItemId
335
+ )
336
+ }
337
+ `,
338
+ variables: {
339
+ releaseGoodId: this.orderId,
340
+ orderPackageId: this.orderPackageId,
341
+ inventoryItemId: id
342
+ }
343
+ })
344
+
345
+ if (!response.errors) {
346
+ this._selectedSerialNumber = {}
347
+ this.dataGrist.fetch()
348
+ }
349
+ } catch (e) {
350
+ this._showToast(e)
351
+ }
352
+ }
353
+
354
+ validate() {
355
+ // validate for previous picking execution (multiple picking scanning)
356
+ let foundSerialNumber = this.dataGrist.data.records.filter(itm => itm.serialNumber == this.serialInput.value.trim())
357
+ if (foundSerialNumber.length > 0) {
358
+ throw new Error(i18next.t('text.serial_number_has_been_scanned'))
359
+ }
360
+
361
+ if (!this._selectedSerialNumber.id) throw new Error(i18next.t('text.no_serial_number_selected'))
362
+
363
+ if (this.serialInput.value == '') throw new Error(i18next.t('text.please_key_in_new_serial_number'))
364
+ }
365
+
366
+ _showToast({ type, message }) {
367
+ document.dispatchEvent(
368
+ new CustomEvent('notify', {
369
+ detail: {
370
+ type,
371
+ message
372
+ }
373
+ })
374
+ )
375
+ }
376
+ }
377
+
378
+ window.customElements.define('packing-serial-number-popup', PackingSerialNumberPopup)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/operato-wms",
3
- "version": "4.3.491",
3
+ "version": "4.3.493",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -91,7 +91,7 @@
91
91
  "@things-factory/print-ui": "^4.3.434",
92
92
  "@things-factory/product-base": "^4.3.452",
93
93
  "@things-factory/resource-ui": "^4.3.452",
94
- "@things-factory/sales-ui": "^4.3.491",
94
+ "@things-factory/sales-ui": "^4.3.493",
95
95
  "@things-factory/scene-data-transform": "^4.3.381",
96
96
  "@things-factory/scene-excel": "^4.3.381",
97
97
  "@things-factory/scene-firebase": "^4.3.381",
@@ -107,8 +107,8 @@
107
107
  "@things-factory/system-ui": "^4.3.434",
108
108
  "@things-factory/transport-base": "^4.3.452",
109
109
  "@things-factory/tutorial-ui": "^4.3.452",
110
- "@things-factory/warehouse-base": "^4.3.479",
111
- "@things-factory/worksheet-base": "^4.3.491"
110
+ "@things-factory/warehouse-base": "^4.3.493",
111
+ "@things-factory/worksheet-base": "^4.3.493"
112
112
  },
113
113
  "devDependencies": {
114
114
  "@things-factory/builder": "^4.3.381",
@@ -117,5 +117,5 @@
117
117
  "cypress-localstorage-commands": "^1.6.1",
118
118
  "eslint-plugin-cypress": "^2.12.1"
119
119
  },
120
- "gitHead": "d8e60884f674e4fed6443a115c3979b6287c241a"
120
+ "gitHead": "ed124795915f8de6fbb16c284445c774188565b9"
121
121
  }