@things-factory/operato-wms 4.3.607 → 4.3.609
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.
- package/client/pages/outbound/packing-product.js +164 -73
- package/client/pages/outbound/packing-serial-number-popup.js +30 -2
- package/client/pages/outbound/picking-product.js +118 -43
- package/client/pages/outbound/serial-number-popup.js +25 -1
- package/client/pages/outbound/sorting-product.js +69 -6
- package/client/util/index.js +2 -0
- package/client/util/page-settings.js +8 -5
- package/client/util/qr-decoder.js +119 -0
- package/client/util/url-validator.js +11 -0
- package/dist-server/graphql/resolvers/other/page-settings.js +51 -3
- package/dist-server/graphql/resolvers/other/page-settings.js.map +1 -1
- package/dist-server/graphql/resolvers/zone-worksheet/zone-picking.js +2 -1
- package/dist-server/graphql/resolvers/zone-worksheet/zone-picking.js.map +1 -1
- package/dist-server/graphql/types/other/index.js +2 -0
- package/dist-server/graphql/types/other/index.js.map +1 -1
- package/dist-server/graphql/types/other/page-setting.js +1 -0
- package/dist-server/graphql/types/other/page-setting.js.map +1 -1
- package/package.json +8 -8
- package/server/graphql/resolvers/other/page-settings.ts +90 -27
- package/server/graphql/resolvers/zone-worksheet/zone-picking.ts +3 -1
- package/server/graphql/types/other/index.ts +2 -0
- package/server/graphql/types/other/page-setting.ts +1 -0
|
@@ -9,32 +9,20 @@ import './tote-popup'
|
|
|
9
9
|
import './vas-list-popup'
|
|
10
10
|
|
|
11
11
|
import gql from 'graphql-tag'
|
|
12
|
-
import {
|
|
13
|
-
css,
|
|
14
|
-
html
|
|
15
|
-
} from 'lit-element'
|
|
12
|
+
import { css, html } from 'lit-element'
|
|
16
13
|
import { connect } from 'pwa-helpers/connect-mixin.js'
|
|
17
14
|
|
|
18
15
|
import { sleep } from '@operato/utils'
|
|
19
16
|
import { MultiColumnFormStyles } from '@things-factory/form-ui'
|
|
20
|
-
import {
|
|
21
|
-
i18next,
|
|
22
|
-
localize
|
|
23
|
-
} from '@things-factory/i18n-base'
|
|
17
|
+
import { i18next, localize } from '@things-factory/i18n-base'
|
|
24
18
|
import { openPopup } from '@things-factory/layout-base'
|
|
25
|
-
import {
|
|
26
|
-
client,
|
|
27
|
-
CustomAlert,
|
|
28
|
-
gqlContext,
|
|
29
|
-
PageView,
|
|
30
|
-
store
|
|
31
|
-
} from '@things-factory/shell'
|
|
19
|
+
import { client, CustomAlert, gqlContext, PageView, store } from '@things-factory/shell'
|
|
32
20
|
import { CommonButtonStyles } from '@things-factory/styles'
|
|
33
21
|
import { isMobileDevice } from '@things-factory/utils'
|
|
34
22
|
|
|
35
23
|
import { fetchLocationSortingRule } from '../../fetch-location-sorting-rule'
|
|
36
24
|
import { fetchSettingRule } from '../../fetch-setting-value'
|
|
37
|
-
import { showToast } from '../../util/index'
|
|
25
|
+
import { decodeQR, showToast, fetchPageSettings, isValidHttpUrl } from '../../util/index'
|
|
38
26
|
import {
|
|
39
27
|
BATCH_PICKING,
|
|
40
28
|
LOCATION_SORTING_RULE,
|
|
@@ -53,6 +41,7 @@ class PickingProduct extends connect(store)(localize(i18next)(PageView)) {
|
|
|
53
41
|
_crossDocking: Boolean,
|
|
54
42
|
_currentBinLocation: String,
|
|
55
43
|
_enableProductScanning: Boolean,
|
|
44
|
+
_qrProcessing: Number,
|
|
56
45
|
_hasBinPicking: Boolean,
|
|
57
46
|
_incompleteLocationName: Boolean,
|
|
58
47
|
_isCartonLabel: Boolean,
|
|
@@ -331,6 +320,7 @@ class PickingProduct extends connect(store)(localize(i18next)(PageView)) {
|
|
|
331
320
|
this._isRequireSerialNumberScanningOutbound = false
|
|
332
321
|
this._crossDocking = false
|
|
333
322
|
this._enableProductScanning = false
|
|
323
|
+
this._qrProcessing = 0
|
|
334
324
|
this._hasBinPicking = false
|
|
335
325
|
this._reusablePalletList = { records: [] }
|
|
336
326
|
this._selectedOrderInventory = null
|
|
@@ -570,13 +560,23 @@ class PickingProduct extends connect(store)(localize(i18next)(PageView)) {
|
|
|
570
560
|
}
|
|
571
561
|
|
|
572
562
|
async pageInitialized() {
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
563
|
+
//fetch domain page settings
|
|
564
|
+
let pageSettings = await fetchPageSettings({
|
|
565
|
+
settings: {
|
|
566
|
+
name: 'name',
|
|
567
|
+
operator: 'in',
|
|
568
|
+
value: ['enable-bin-picking', 'camera-scan-only', 'enable-picking-random-seq', 'disable-missing-button']
|
|
569
|
+
}
|
|
570
|
+
})
|
|
571
|
+
|
|
572
|
+
const settingsMap = new Map(pageSettings.settings.map(setting => [setting.name, setting.value]))
|
|
573
|
+
|
|
574
|
+
let enableBinPickingTask = settingsMap.get('enable-bin-picking') === 'true'
|
|
575
|
+
let cameraScanOnly = settingsMap.get('camera-scan-only') === 'true'
|
|
576
|
+
let enablePickingRandomSeq = settingsMap.get('enable-picking-random-seq') === 'true'
|
|
577
|
+
let disableMissingButton = settingsMap.get('disable-missing-button') === 'true'
|
|
578
|
+
|
|
579
|
+
const locationSortingTask = fetchLocationSortingRule(LOCATION_SORTING_RULE.PICKING_PRODUCT.value)
|
|
580
580
|
|
|
581
581
|
this.config = {
|
|
582
582
|
rows: {
|
|
@@ -729,7 +729,7 @@ class PickingProduct extends connect(store)(localize(i18next)(PageView)) {
|
|
|
729
729
|
|
|
730
730
|
this.locationSortingRules = await locationSortingTask
|
|
731
731
|
this._hasBinPicking = await enableBinPickingTask
|
|
732
|
-
this._disableMissingButton = await disableMissingButton || false
|
|
732
|
+
this._disableMissingButton = (await disableMissingButton) || false
|
|
733
733
|
|
|
734
734
|
this._pageSettings = {
|
|
735
735
|
...this._pageSettings,
|
|
@@ -790,11 +790,11 @@ class PickingProduct extends connect(store)(localize(i18next)(PageView)) {
|
|
|
790
790
|
this._worksheetLoaded = false
|
|
791
791
|
}
|
|
792
792
|
|
|
793
|
-
fillUpForm(form, data) {
|
|
793
|
+
fillUpForm(form, data, fieldType) {
|
|
794
794
|
this._incompleteLocationName = false
|
|
795
795
|
form.reset()
|
|
796
796
|
for (let key in data) {
|
|
797
|
-
Array.from(form.querySelectorAll(
|
|
797
|
+
Array.from(form.querySelectorAll(fieldType)).forEach(field => {
|
|
798
798
|
if (field.name === key && field.type === 'checkbox') {
|
|
799
799
|
field.checked = data[key]
|
|
800
800
|
} else if (field.name === key && field.type === 'datetime-local') {
|
|
@@ -817,6 +817,40 @@ class PickingProduct extends connect(store)(localize(i18next)(PageView)) {
|
|
|
817
817
|
if (e.keyCode !== 13) return
|
|
818
818
|
e.preventDefault()
|
|
819
819
|
try {
|
|
820
|
+
//qr scanning and input is a url
|
|
821
|
+
let isBarcode = isValidHttpUrl(this.productBarcodeInput?.value)
|
|
822
|
+
if (
|
|
823
|
+
this._enableProductScanning &&
|
|
824
|
+
this._qrProcessing > 0 &&
|
|
825
|
+
(isBarcode || isValidHttpUrl(this.serialInput?.value))
|
|
826
|
+
) {
|
|
827
|
+
//assign url to input
|
|
828
|
+
let input = ''
|
|
829
|
+
//need to update this logic if using qr scanning without serial number
|
|
830
|
+
if (this.refPickingType === PICKING_TYPES.PICKING.value && this._isRequireSerialNumberScanningOutbound) {
|
|
831
|
+
input = isBarcode ? this.productBarcodeInput.value : this.serialInput.value
|
|
832
|
+
} else if (this.refPickingType === PICKING_TYPES.BATCH_PICKING.value) {
|
|
833
|
+
input = this.productBarcodeInput?.value.trim()
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
//get gtin and serial number from qr
|
|
837
|
+
let config = JSON.parse(
|
|
838
|
+
await fetchSettingRule('qr-data-parsing-configuration', this._worksheetInfo.partnerDomainId)
|
|
839
|
+
)
|
|
840
|
+
|
|
841
|
+
let data = await decodeQR(input, config)
|
|
842
|
+
|
|
843
|
+
// Fill up form
|
|
844
|
+
if (this.productBarcodeInput && data.productBarcode) {
|
|
845
|
+
this.productBarcodeInput.value = data.productBarcode
|
|
846
|
+
}
|
|
847
|
+
if (this.serialInput && data.serialNumber) {
|
|
848
|
+
this.serialInput.value = data.serialNumber
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
await sleep(1010)
|
|
852
|
+
}
|
|
853
|
+
|
|
820
854
|
let answer = await this.validatePicking()
|
|
821
855
|
if (answer) {
|
|
822
856
|
if (!answer?.value) return
|
|
@@ -905,6 +939,12 @@ class PickingProduct extends connect(store)(localize(i18next)(PageView)) {
|
|
|
905
939
|
|
|
906
940
|
async openSerialNumberPopup() {
|
|
907
941
|
await sleep(1010)
|
|
942
|
+
let qrConfig = null
|
|
943
|
+
if (this._qrProcessing > 0) {
|
|
944
|
+
qrConfig = JSON.parse(
|
|
945
|
+
await fetchSettingRule('qr-data-parsing-configuration', this._worksheetInfo.partnerDomainId)
|
|
946
|
+
)
|
|
947
|
+
}
|
|
908
948
|
openPopup(
|
|
909
949
|
html`
|
|
910
950
|
<serial-number-popup
|
|
@@ -913,6 +953,8 @@ class PickingProduct extends connect(store)(localize(i18next)(PageView)) {
|
|
|
913
953
|
.orderSource="${ORDER_SOURCES.PICKING.value}"
|
|
914
954
|
.orderId="${this.pickingOrderId}"
|
|
915
955
|
.data="${this?._selectedOrderInventory}"
|
|
956
|
+
.qrProcessing="${this._qrProcessing}"
|
|
957
|
+
.qrConfig="${qrConfig}"
|
|
916
958
|
@close-serial-number-popup="${async e => {
|
|
917
959
|
await this.fetchAll(this.releaseGoodNo)
|
|
918
960
|
}}"
|
|
@@ -1271,6 +1313,12 @@ class PickingProduct extends connect(store)(localize(i18next)(PageView)) {
|
|
|
1271
1313
|
|
|
1272
1314
|
if (!foundRecord) {
|
|
1273
1315
|
//carton replacement?
|
|
1316
|
+
if (this.productBarcodeInput?.value) {
|
|
1317
|
+
this.productBarcodeInput.value = ''
|
|
1318
|
+
}
|
|
1319
|
+
if (this.serialInput?.value) {
|
|
1320
|
+
this.serialInput.value = ''
|
|
1321
|
+
}
|
|
1274
1322
|
throw new Error(i18next.t('text.invalid_carton_id'))
|
|
1275
1323
|
}
|
|
1276
1324
|
}
|
|
@@ -1630,10 +1678,14 @@ class PickingProduct extends connect(store)(localize(i18next)(PageView)) {
|
|
|
1630
1678
|
this.updateSelectedItemProp(record)
|
|
1631
1679
|
await this.updateComplete
|
|
1632
1680
|
await this.grist.reset()
|
|
1633
|
-
this.fillUpForm(
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1681
|
+
this.fillUpForm(
|
|
1682
|
+
this.inputForm,
|
|
1683
|
+
{
|
|
1684
|
+
...record,
|
|
1685
|
+
binLocation: record?.binLocation ? record.binLocation : ''
|
|
1686
|
+
},
|
|
1687
|
+
'input'
|
|
1688
|
+
)
|
|
1637
1689
|
|
|
1638
1690
|
if (record.pickedQty == record.releaseQty) {
|
|
1639
1691
|
if (this.cartonInput) this.cartonInput.value = ''
|
|
@@ -1804,9 +1856,9 @@ class PickingProduct extends connect(store)(localize(i18next)(PageView)) {
|
|
|
1804
1856
|
if (this.cartonInput) this.cartonInput.value = ''
|
|
1805
1857
|
if (this.productBarcodeInput) this.productBarcodeInput.value = ''
|
|
1806
1858
|
}
|
|
1807
|
-
this.fillUpForm(this.inputForm, record)
|
|
1859
|
+
this.fillUpForm(this.inputForm, record, 'input')
|
|
1808
1860
|
} else {
|
|
1809
|
-
this.fillUpForm(this.inputForm, record)
|
|
1861
|
+
this.fillUpForm(this.inputForm, record, 'input')
|
|
1810
1862
|
}
|
|
1811
1863
|
|
|
1812
1864
|
if (
|
|
@@ -2145,8 +2197,21 @@ class PickingProduct extends connect(store)(localize(i18next)(PageView)) {
|
|
|
2145
2197
|
this._worksheetInfo = worksheetInfo
|
|
2146
2198
|
this.data = { records: this.formatWorksheetDetailInfos(worksheetDetailInfos) }
|
|
2147
2199
|
|
|
2148
|
-
|
|
2149
|
-
|
|
2200
|
+
//fetch partner page settings
|
|
2201
|
+
let pageSettings = await fetchPageSettings({
|
|
2202
|
+
settings: {
|
|
2203
|
+
name: 'name',
|
|
2204
|
+
operator: 'in',
|
|
2205
|
+
value: ['enable-product-scanning', 'qr-code-scanning', 'enable-tote-scanning']
|
|
2206
|
+
},
|
|
2207
|
+
settingsDomain: this._worksheetInfo.partnerDomainId
|
|
2208
|
+
})
|
|
2209
|
+
|
|
2210
|
+
const settingsMap = new Map(pageSettings.settings.map(setting => [setting.name, setting.value]))
|
|
2211
|
+
|
|
2212
|
+
this._enableProductScanning = settingsMap.get('enable-product-scanning') === 'true'
|
|
2213
|
+
this._enableToteScanning = settingsMap.get('enable-tote-scanning') === 'true'
|
|
2214
|
+
this._qrProcessing = settingsMap.get('qr-code-scanning')
|
|
2150
2215
|
|
|
2151
2216
|
this._selectedOrderInventory = this.data?.records[0] || undefined
|
|
2152
2217
|
|
|
@@ -2162,7 +2227,7 @@ class PickingProduct extends connect(store)(localize(i18next)(PageView)) {
|
|
|
2162
2227
|
this.inputForm.reset()
|
|
2163
2228
|
} else {
|
|
2164
2229
|
this._focusOnProductBarcodeInput()
|
|
2165
|
-
this.fillUpForm(this.inputForm, this._selectedOrderInventory)
|
|
2230
|
+
this.fillUpForm(this.inputForm, this._selectedOrderInventory, 'input')
|
|
2166
2231
|
}
|
|
2167
2232
|
}
|
|
2168
2233
|
this.scannableField()
|
|
@@ -2176,14 +2241,23 @@ class PickingProduct extends connect(store)(localize(i18next)(PageView)) {
|
|
|
2176
2241
|
await this.fetchInventories(orderNo)
|
|
2177
2242
|
await this.fetchPalletsHandler(orderNo)
|
|
2178
2243
|
await this.fetchOrderVas(this.pickingOrderId)
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2244
|
+
//fetch partner page settings
|
|
2245
|
+
let pageSettings = await fetchPageSettings({
|
|
2246
|
+
settings: {
|
|
2247
|
+
name: 'name',
|
|
2248
|
+
operator: 'in',
|
|
2249
|
+
value: ['enable-product-scanning', 'enable-tote-scanning', 'enable-input-qty', 'qr-code-scanning']
|
|
2250
|
+
},
|
|
2251
|
+
settingsDomain: this._worksheetInfo.partnerDomainId
|
|
2252
|
+
})
|
|
2253
|
+
|
|
2254
|
+
const settingsMap = new Map(pageSettings.settings.map(setting => [setting.name, setting.value]))
|
|
2255
|
+
|
|
2256
|
+
this._enableProductScanning = settingsMap.get('enable-product-scanning') === 'true'
|
|
2257
|
+
this._enableToteScanning = settingsMap.get('enable-tote-scanning') === 'true'
|
|
2258
|
+
this._enableInputQty = settingsMap.get('enable-input-qty')
|
|
2259
|
+
this._qrProcessing = settingsMap.get('qr-code-scanning')
|
|
2260
|
+
|
|
2187
2261
|
this.focusOnInput()
|
|
2188
2262
|
}
|
|
2189
2263
|
|
|
@@ -2263,6 +2337,7 @@ class PickingProduct extends connect(store)(localize(i18next)(PageView)) {
|
|
|
2263
2337
|
this.scannable = false
|
|
2264
2338
|
}
|
|
2265
2339
|
}
|
|
2340
|
+
|
|
2266
2341
|
massageReleaseGood(response) {}
|
|
2267
2342
|
}
|
|
2268
2343
|
|
|
@@ -8,6 +8,7 @@ import { MultiColumnFormStyles, SingleColumnFormStyles } from '@things-factory/f
|
|
|
8
8
|
import { i18next, localize } from '@things-factory/i18n-base'
|
|
9
9
|
import { client } from '@things-factory/shell'
|
|
10
10
|
import { isMobileDevice } from '@things-factory/utils'
|
|
11
|
+
import { decodeQR , isValidHttpUrl } from '../../util/index'
|
|
11
12
|
|
|
12
13
|
import { ORDER_SOURCES } from '../constants'
|
|
13
14
|
|
|
@@ -65,7 +66,9 @@ class SerialNumberPopup extends localize(i18next)(LitElement) {
|
|
|
65
66
|
_inventoryItems: Object,
|
|
66
67
|
_selectedSerialNumber: Object,
|
|
67
68
|
enableRemove: Boolean,
|
|
68
|
-
enableUpdateBtn: Boolean
|
|
69
|
+
enableUpdateBtn: Boolean,
|
|
70
|
+
qrProcessing: Number,
|
|
71
|
+
qrConfig: Object
|
|
69
72
|
}
|
|
70
73
|
}
|
|
71
74
|
|
|
@@ -136,6 +139,12 @@ class SerialNumberPopup extends localize(i18next)(LitElement) {
|
|
|
136
139
|
name="serialNumber"
|
|
137
140
|
class="mobile-full-width"
|
|
138
141
|
custom-input
|
|
142
|
+
@keypress="${async e => {
|
|
143
|
+
if (e.keyCode === 13) {
|
|
144
|
+
e.preventDefault()
|
|
145
|
+
await this._extractSerialNumber(e)
|
|
146
|
+
}
|
|
147
|
+
}}"
|
|
139
148
|
></barcode-scanable-input>
|
|
140
149
|
<mwc-button
|
|
141
150
|
name="setSerialNumber"
|
|
@@ -161,6 +170,21 @@ class SerialNumberPopup extends localize(i18next)(LitElement) {
|
|
|
161
170
|
`
|
|
162
171
|
}
|
|
163
172
|
|
|
173
|
+
async _extractSerialNumber() {
|
|
174
|
+
// QR scanning
|
|
175
|
+
if (this.qrProcessing > 0 && isValidHttpUrl(this.serialInput.value)) {
|
|
176
|
+
let input = this.serialInput.value.trim()
|
|
177
|
+
|
|
178
|
+
// Get GTIN and serial number from QR code
|
|
179
|
+
let data = await decodeQR(input, this.qrConfig)
|
|
180
|
+
|
|
181
|
+
// Fill up form
|
|
182
|
+
if (this.serialInput && data.serialNumber) {
|
|
183
|
+
this.serialInput.value = data.serialNumber
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
164
188
|
async firstUpdated() {
|
|
165
189
|
this.clearView()
|
|
166
190
|
|
|
@@ -19,11 +19,13 @@ import { isMobileDevice } from '@things-factory/utils'
|
|
|
19
19
|
|
|
20
20
|
import { fetchSettingRule } from '../../fetch-setting-value'
|
|
21
21
|
import { WORKSHEET_STATUS } from '../constants'
|
|
22
|
+
import { decodeQR, fetchPageSettings, isValidHttpUrl } from '../../util'
|
|
22
23
|
|
|
23
24
|
class SortingProduct extends connect(store)(localize(i18next)(PageView)) {
|
|
24
25
|
static get properties() {
|
|
25
26
|
return {
|
|
26
27
|
_enableProductScanning: Boolean,
|
|
28
|
+
_qrProcessing: Number,
|
|
27
29
|
_selectedOrderInventory: Object,
|
|
28
30
|
_selectedTaskStatus: String,
|
|
29
31
|
_worksheetInfo: Object,
|
|
@@ -194,7 +196,16 @@ class SortingProduct extends connect(store)(localize(i18next)(PageView)) {
|
|
|
194
196
|
${this._enableProductScanning
|
|
195
197
|
? html`
|
|
196
198
|
<label>${i18next.t('label.scan_product_barcode')}</label>
|
|
197
|
-
<barcode-scanable-input
|
|
199
|
+
<barcode-scanable-input
|
|
200
|
+
name="productBarcode"
|
|
201
|
+
custom-input
|
|
202
|
+
@keypress="${async e => {
|
|
203
|
+
if (this._qrProcessing > 0 && e.keyCode === 13) {
|
|
204
|
+
e.preventDefault()
|
|
205
|
+
await this._processQRAndFillForm(e)
|
|
206
|
+
}
|
|
207
|
+
}}"
|
|
208
|
+
></barcode-scanable-input>
|
|
198
209
|
`
|
|
199
210
|
: ''}
|
|
200
211
|
${(this._enableSortingQty && !this._isRequireSerialNumberScanningOutbound) || !this._enableProductScanning
|
|
@@ -206,7 +217,16 @@ class SortingProduct extends connect(store)(localize(i18next)(PageView)) {
|
|
|
206
217
|
${this._isRequireSerialNumberScanningOutbound
|
|
207
218
|
? html`
|
|
208
219
|
<label>${i18next.t('label.serial_number')}</label>
|
|
209
|
-
<barcode-scanable-input
|
|
220
|
+
<barcode-scanable-input
|
|
221
|
+
name="serialNumber"
|
|
222
|
+
custom-input
|
|
223
|
+
@keypress="${async e => {
|
|
224
|
+
if (this._qrProcessing > 0 && e.keyCode === 13) {
|
|
225
|
+
e.preventDefault()
|
|
226
|
+
await this._processQRAndFillForm(e)
|
|
227
|
+
}
|
|
228
|
+
}}"
|
|
229
|
+
></barcode-scanable-input>
|
|
210
230
|
`
|
|
211
231
|
: ``}
|
|
212
232
|
</fieldset>
|
|
@@ -238,6 +258,7 @@ class SortingProduct extends connect(store)(localize(i18next)(PageView)) {
|
|
|
238
258
|
this._selectedOrderInventory = null
|
|
239
259
|
this._selectedTaskStatus = null
|
|
240
260
|
this._enableSortingQty = false
|
|
261
|
+
this._qrProcessing = 0
|
|
241
262
|
}
|
|
242
263
|
|
|
243
264
|
updated(changedProps) {
|
|
@@ -519,11 +540,22 @@ class SortingProduct extends connect(store)(localize(i18next)(PageView)) {
|
|
|
519
540
|
this._isRequireSerialNumberScanningOutbound = worksheetDetailInfos[0].isRequireSerialNumberScanningOutbound
|
|
520
541
|
}
|
|
521
542
|
|
|
522
|
-
|
|
523
|
-
|
|
543
|
+
//fetch partner page settings
|
|
544
|
+
let pageSettings = await fetchPageSettings({
|
|
545
|
+
settings: {
|
|
546
|
+
name: 'name',
|
|
547
|
+
operator: 'in',
|
|
548
|
+
value: ['enable-product-scanning', 'enable-tote-scanning', 'enable-sorting-qty', 'qr-code-scanning']
|
|
549
|
+
},
|
|
550
|
+
settingsDomain: worksheetInfo.partnerDomainId
|
|
551
|
+
})
|
|
552
|
+
|
|
553
|
+
const settingsMap = new Map(pageSettings.settings.map(setting => [setting.name, setting.value]))
|
|
524
554
|
|
|
525
|
-
|
|
526
|
-
|
|
555
|
+
this._enableProductScanning = settingsMap.get('enable-product-scanning') === 'true'
|
|
556
|
+
this._enableToteScanning = settingsMap.get('enable-tote-scanning') === 'true'
|
|
557
|
+
this._enableSortingQty = settingsMap.get('enable-sorting-qty') === 'true'
|
|
558
|
+
this._qrProcessing = settingsMap.get('qr-code-scanning')
|
|
527
559
|
|
|
528
560
|
this.updateContext()
|
|
529
561
|
this._completeHandler()
|
|
@@ -577,6 +609,37 @@ class SortingProduct extends connect(store)(localize(i18next)(PageView)) {
|
|
|
577
609
|
)
|
|
578
610
|
}
|
|
579
611
|
|
|
612
|
+
async _processQRAndFillForm(e) {
|
|
613
|
+
// QR scanning
|
|
614
|
+
let isBarcode = isValidHttpUrl(this.productBarcodeInput.value)
|
|
615
|
+
if (
|
|
616
|
+
this._enableProductScanning &&
|
|
617
|
+
this._qrProcessing > 0 &&
|
|
618
|
+
(isBarcode|| isValidHttpUrl(this.serialInput?.value))
|
|
619
|
+
) {
|
|
620
|
+
input = isBarcode
|
|
621
|
+
? this.productBarcodeInput.value
|
|
622
|
+
: this.serialInput.value
|
|
623
|
+
let config = JSON.parse(
|
|
624
|
+
await fetchSettingRule('qr-data-parsing-configuration', this._worksheetInfo.partnerDomainId)
|
|
625
|
+
)
|
|
626
|
+
// Get GTIN and serial number from QR code
|
|
627
|
+
let data = await decodeQR(input, config)
|
|
628
|
+
|
|
629
|
+
// Fill up form
|
|
630
|
+
if (this.productBarcodeInput && data.productBarcode) {
|
|
631
|
+
this.productBarcodeInput.value = data.productBarcode
|
|
632
|
+
}
|
|
633
|
+
if (this.serialInput && data.serialNumber) {
|
|
634
|
+
this.serialInput.value = data.serialNumber
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
await sleep(1010)
|
|
638
|
+
|
|
639
|
+
this._sorting(e)
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
|
|
580
643
|
async _sorting(e) {
|
|
581
644
|
if (e.keyCode !== 13) return
|
|
582
645
|
e.preventDefault()
|
package/client/util/index.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { client, gqlContext } from '@things-factory/shell'
|
|
2
2
|
import gql from 'graphql-tag'
|
|
3
3
|
|
|
4
|
-
export const fetchPageSettings = async function (variables = { codes, partners }) {
|
|
4
|
+
export const fetchPageSettings = async function (variables = { codes, partners, settings, settingsDomain }) {
|
|
5
5
|
try {
|
|
6
6
|
const response = await client.query({
|
|
7
7
|
query: gql`
|
|
8
|
-
query pageSettings($codes: [Filter!], $partners: [Filter!]) {
|
|
9
|
-
pageSettings(codes: $codes, partners: $partners) {
|
|
8
|
+
query pageSettings($codes: [Filter!], $partners: [Filter!], $settings: [Filter!], $settingsDomain: String) {
|
|
9
|
+
pageSettings(codes: $codes, partners: $partners, settings: $settings, settingsDomain: $settingsDomain) {
|
|
10
10
|
type
|
|
11
11
|
details {
|
|
12
12
|
id
|
|
13
13
|
name
|
|
14
14
|
description
|
|
15
|
+
value
|
|
15
16
|
settingDetails {
|
|
16
17
|
id
|
|
17
18
|
name
|
|
@@ -29,12 +30,14 @@ export const fetchPageSettings = async function (variables = { codes, partners }
|
|
|
29
30
|
if (!response.errors && response.data.pageSettings) {
|
|
30
31
|
return {
|
|
31
32
|
codes: response.data.pageSettings.find(x => x.type == 'code')?.details || [],
|
|
32
|
-
partners: response.data.pageSettings.find(x => x.type == 'partner')?.details || []
|
|
33
|
+
partners: response.data.pageSettings.find(x => x.type == 'partner')?.details || [],
|
|
34
|
+
settings: response.data.pageSettings.find(x => x.type == 'setting')?.details || []
|
|
33
35
|
}
|
|
34
36
|
} else {
|
|
35
37
|
return {
|
|
36
38
|
code: [],
|
|
37
|
-
partners: []
|
|
39
|
+
partners: [],
|
|
40
|
+
settings: []
|
|
38
41
|
}
|
|
39
42
|
}
|
|
40
43
|
} catch (error) {
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts GTIN and Serial Number from a given data based on provided configurations.
|
|
3
|
+
* @param {string} data - The data to decode.
|
|
4
|
+
* @param {Object} config - Configuration object defining parsing rules.
|
|
5
|
+
* @returns {Object|string} - Extracted data object or an error message.
|
|
6
|
+
*/
|
|
7
|
+
export const decodeQR = function (data, config) {
|
|
8
|
+
// Iterate through each pattern to find a match
|
|
9
|
+
let extractedData = {}
|
|
10
|
+
|
|
11
|
+
const urlObject = new URL(data)
|
|
12
|
+
if (config.type === 'path-query') {
|
|
13
|
+
const pathSegments = urlObject.pathname.split('/').filter(segment => segment) // Remove empty segments
|
|
14
|
+
/**
|
|
15
|
+
* Example Pattern Configuration:
|
|
16
|
+
* {
|
|
17
|
+
* type: 'path-query',
|
|
18
|
+
* pathIndex: -1, // Last segment in the path
|
|
19
|
+
* queryParams: {
|
|
20
|
+
* SerialNumber: 'sn',
|
|
21
|
+
* GTIN: 'gtin' // Optional if GTIN is in path
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
// Extract GTIN from path if specified
|
|
27
|
+
if (config.pathIndex !== undefined) {
|
|
28
|
+
let gtin = ''
|
|
29
|
+
if (config.pathIndex >= 0) {
|
|
30
|
+
gtin = pathSegments[config.pathIndex]
|
|
31
|
+
} else {
|
|
32
|
+
// Negative index for counting from the end
|
|
33
|
+
gtin = pathSegments[pathSegments.length + config.pathIndex]
|
|
34
|
+
}
|
|
35
|
+
extractedData.GTIN = gtin || null
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Extract Serial Number from query parameters
|
|
39
|
+
for (const [key, param] of Object.entries(config.queryParams)) {
|
|
40
|
+
const value = urlObject.searchParams.get(param)
|
|
41
|
+
extractedData[key] = value || null
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Check if required fields are present
|
|
45
|
+
const requiredFields = Object.keys(config.queryParams)
|
|
46
|
+
let allFieldsPresent = requiredFields.every(field => extractedData[field])
|
|
47
|
+
|
|
48
|
+
// If GTIN is also required, ensure it's present
|
|
49
|
+
if (config.requireGTINInPath && !extractedData.GTIN) {
|
|
50
|
+
allFieldsPresent = false
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (allFieldsPresent) {
|
|
54
|
+
return extractedData
|
|
55
|
+
}
|
|
56
|
+
} else if (config.type === 'query-delimited') {
|
|
57
|
+
const queryString = urlObject.search.substring(1) // Remove the '?' at the beginning
|
|
58
|
+
/**
|
|
59
|
+
* Example Pattern Configuration:
|
|
60
|
+
* {
|
|
61
|
+
* type: 'query-delimited',
|
|
62
|
+
* delimiter: '!',
|
|
63
|
+
* sequence: ['SerialNumber', 'GTIN']
|
|
64
|
+
* }
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
const delimiter = config.delimiter || '!'
|
|
68
|
+
const dataSegments = queryString.split(delimiter)
|
|
69
|
+
|
|
70
|
+
if (dataSegments.length >= config.sequence.length) {
|
|
71
|
+
config.sequence.forEach((field, index) => {
|
|
72
|
+
extractedData[field] = dataSegments[index] || null
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
// Check if all required fields are present
|
|
76
|
+
const allFieldsPresent = config.sequence.every(field => extractedData[field])
|
|
77
|
+
if (allFieldsPresent) {
|
|
78
|
+
return extractedData
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return 'No matching config found or required data is missing.'
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// // Example configuration for both URL formats
|
|
87
|
+
// const config = {
|
|
88
|
+
// patterns: [
|
|
89
|
+
// {
|
|
90
|
+
// type: 'path-query',
|
|
91
|
+
// pathIndex: -1, // Last segment in the path
|
|
92
|
+
// requireGTINInPath: true,
|
|
93
|
+
// queryParams: {
|
|
94
|
+
// SerialNumber: 'sn'
|
|
95
|
+
// // GTIN can also be included here if it appears in query params
|
|
96
|
+
// }
|
|
97
|
+
// },
|
|
98
|
+
// {
|
|
99
|
+
// type: 'query-delimited',
|
|
100
|
+
// delimiter: '!',
|
|
101
|
+
// sequence: ['SerialNumber', 'GTIN']
|
|
102
|
+
// }
|
|
103
|
+
// ]
|
|
104
|
+
// }
|
|
105
|
+
|
|
106
|
+
// // Example Usage:
|
|
107
|
+
// // Case 1: URL with GTIN in path and Serial Number in query param
|
|
108
|
+
// const url1 = 'https://example.com/product/01234567890512?sn=ABC123456789'
|
|
109
|
+
// const result1 = extractDataFromURL(url1, config)
|
|
110
|
+
// console.log('Result for URL 1:', result1)
|
|
111
|
+
// // Expected Output:
|
|
112
|
+
// // Result for URL 1: { GTIN: '01234567890512', SerialNumber: 'ABC123456789' }
|
|
113
|
+
|
|
114
|
+
// // Case 2: URL with Serial Number and GTIN in query string separated by '!'
|
|
115
|
+
// const url2 = 'https://kr.riman.com/?IDC00000718!8800267650480'
|
|
116
|
+
// const result2 = extractDataFromURL(url2, config)
|
|
117
|
+
// console.log('Result for URL 2:', result2)
|
|
118
|
+
// // Expected Output:
|
|
119
|
+
// // Result for URL 2: { SerialNumber: 'IDC00000718', GTIN: '8800267650480' }
|