@things-factory/operato-wms 4.3.81 → 4.3.86

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.
@@ -21,6 +21,7 @@ import { isMobileDevice } from '@things-factory/utils'
21
21
 
22
22
  import { fetchLocationSortingRule } from '../../fetch-location-sorting-rule'
23
23
  import { fetchSettingRule } from '../../fetch-setting-value'
24
+ import { showToast } from '../../util/index'
24
25
  import { BATCH_PICKING, LOCATION_SORTING_RULE, LOCATION_TYPE, ORDER_SOURCES, PICKING, RO_TYPES } from '../constants'
25
26
 
26
27
  const PICKING_TYPES = { PICKING, BATCH_PICKING }
@@ -345,6 +346,15 @@ class PickingProduct extends connect(store)(localize(i18next)(PageView)) {
345
346
  this.completeHandler()
346
347
  }
347
348
  }
349
+ let [enableProductScanning, enableToteScanning, enableInputQty] = await Promise.all([
350
+ fetchSettingRule('enable-product-scanning', this._worksheetInfo.partnerDomainId),
351
+ fetchSettingRule('enable-tote-scanning', this._worksheetInfo.partnerDomainId),
352
+ fetchSettingRule('enable-input-qty', this._worksheetInfo.partnerDomainId)
353
+ ])
354
+ this._enableProductScanning = enableProductScanning
355
+ this._enableToteScanning = enableToteScanning
356
+ this._enableInputQty = enableInputQty
357
+
348
358
  this.focusOnInput()
349
359
  }
350
360
  }}"
@@ -615,1054 +625,1042 @@ class PickingProduct extends connect(store)(localize(i18next)(PageView)) {
615
625
  this._hasBinPicking = await enableBinPickingTask
616
626
  }
617
627
 
618
- autoFetchPickingTasks(orderNo) {
619
- this.releaseGoodNoInput.value = orderNo
620
- this.fetchAll(this.releaseGoodNoInput.value)
621
- }
628
+ formatWorksheetDetailInfos(wsdInfos) {
629
+ return wsdInfos
630
+ .map(record => {
631
+ if (record.pickedQty == record.releaseQty || record.status == 'MISSING') {
632
+ record.completed = true
633
+ } else {
634
+ record.completed = false
635
+ }
636
+ record.locationName = record?.location?.name
637
+ record.product = record?.relatedOrderInv && record?.relatedOrderInv?.product
622
638
 
623
- async fetchInventories(pickingRefNo) {
624
- if (!pickingRefNo) return
639
+ if (this._crossDocking) {
640
+ record.batchId = record.relatedOrderInv.batchId
641
+ record.packingType = record.relatedOrderInv.packingType
642
+ }
625
643
 
626
- //this.releaseGoodNo will be incorrect if worksheet list is used, therefore it's assigned here
627
- //this._selectedOrderInventory still has the value of previous order, therefore it's cleared here
628
- if (this.releaseGoodNo !== pickingRefNo) {
629
- this.releaseGoodNo = pickingRefNo
630
- this._selectedOrderInventory = null
631
- }
644
+ if (this._hasBinPicking) {
645
+ record.binLocation = record.binLocation?.name
646
+ }
632
647
 
633
- const data = this._selectedOrderInventory
634
- let response
635
- switch (this.refPickingType) {
636
- case PICKING_TYPES.PICKING.value:
637
- response = await client.query({
638
- query: gql`
639
- query pickingWorksheet($releaseGoodNo: String!, $locationSortingRules: [Sorting!]) {
640
- pickingWorksheet(releaseGoodNo: $releaseGoodNo, locationSortingRules: $locationSortingRules) {
641
- worksheetInfo {
642
- releaseGood {
643
- id
644
- name
645
- recall
646
- crossDocking
647
- type
648
- }
649
- bizplaceName
650
- partnerDomainId
651
- refNo
652
- refNo2
653
- refNo3
654
- startedAt
655
- containerNo
656
- marketplaceStatus
657
- shippingProvider
658
- trackingNo
659
- }
660
- worksheetDetailInfos {
661
- hasMissingInventoryChanges
662
- name
663
- palletId
664
- cartonId
665
- batchId
666
- batchIdRef
667
- product {
668
- id
669
- sku
670
- name
671
- description
672
- isRequireSerialNumberScanningOutbound
673
- }
674
- qty
675
- releaseQty
676
- pickedQty
677
- expirationDate
678
- status
679
- description
680
- targetName
681
- packingType
682
- packingSize
683
- location {
684
- name
685
- description
686
- }
687
- binLocation {
688
- name
689
- description
690
- }
691
- relatedOrderInv {
692
- id
693
- batchId
694
- batchIdRef
695
- packingType
696
- binLocation {
697
- id
698
- name
699
- }
700
- product {
701
- id
702
- sku
703
- name
704
- description
705
- isRequireSerialNumberScanningOutbound
706
- }
707
- }
708
- }
709
- }
710
- }
711
- `,
712
- variables: { releaseGoodNo: pickingRefNo, locationSortingRules: this.locationSortingRules }
713
- })
648
+ if (record?.cartonId) {
649
+ record.hasCartonLabel = true
650
+ }
714
651
 
715
- if (!response.errors) {
716
- this._isReleaseGoodRecall = response.data.pickingWorksheet.worksheetInfo.releaseGood.recall
717
- let releaseGood = response.data.pickingWorksheet.worksheetInfo.releaseGood
718
- this.releaseGoodId = releaseGood.id
719
- this._releaseGoodType = releaseGood.type
652
+ record.releaseProgress = `${record.pickedQty} / ${record.releaseQty}`
653
+ record.sku = record?.relatedOrderInv.product?.sku
720
654
 
721
- if (!response.data?.pickingWorksheet) return
722
- const { worksheetInfo, worksheetDetailInfos } = response.data.pickingWorksheet
723
- this._crossDocking = worksheetInfo.releaseGood?._crossDocking
724
- this._bizplaceName = worksheetInfo.bizplaceName
725
- this._orderNo = this.releaseGoodNo
726
- this._worksheetInfo = worksheetInfo
727
- this.data = { records: await this.formatWorksheetDetailInfos(worksheetDetailInfos) }
728
- let a = this.data
655
+ return record
656
+ })
657
+ .sort((a, b) => a.hasMissingInventoryChanges - b.hasMissingInventoryChanges)
658
+ .sort((a, b) => a.completed - b.completed)
659
+ }
729
660
 
730
- if (!this._selectedOrderInventory) {
731
- this._selectedOrderInventory = this.data.records[0]
732
- }
661
+ clearView() {
662
+ this.data = { records: [] }
663
+ this.infoForm.reset()
664
+ this.inputForm.reset()
665
+ this._isRequireSerialNumberScanningOutbound = false
666
+ this.releaseGoodNo = null
667
+ this.releaseGoodId = null
668
+ this.taskNo = null
669
+ this._crossDocking = false
670
+ this._selectedOrderInventory = null
671
+ this._incompleteLocationName = false
672
+ this._isExecuting = false
673
+ this._locationName = null
674
+ this.toteNo = ''
675
+ }
733
676
 
734
- if (
735
- this._selectedOrderInventory &&
736
- this._selectedOrderInventory.pickedQty != this._selectedOrderInventory.releaseQty &&
737
- !this._selectedOrderInventory.hasMissingInventoryChanges &&
738
- this._selectedOrderInventory.status !== 'MISSING'
739
- ) {
740
- this.scannable = true
677
+ fillUpForm(form, data) {
678
+ this._incompleteLocationName = false
679
+ form.reset()
680
+ for (let key in data) {
681
+ Array.from(form.querySelectorAll('input')).forEach(field => {
682
+ if (field.name === key && field.type === 'checkbox') {
683
+ field.checked = data[key]
684
+ } else if (field.name === key && field.type === 'datetime-local') {
685
+ const datetime = Number(data[key])
686
+ const timezoneOffset = new Date(datetime).getTimezoneOffset() * 60000
687
+ field.value = new Date(datetime - timezoneOffset).toISOString().slice(0, -1)
688
+ } else if (field.name === key) {
689
+ if (data[key] instanceof Object) {
690
+ const objectData = data[key]
691
+ field.value = `${objectData.name} ${objectData.description ? `(${objectData.description})` : ''}`
741
692
  } else {
742
- this.scannable = false
693
+ field.value = data[key]
743
694
  }
695
+ }
696
+ })
697
+ }
698
+ }
744
699
 
745
- if (!this._isCartonLabel && data) {
746
- const findPalletId = worksheetDetailInfos.find(res => res.palletId == data.palletId)
700
+ async picking(e) {
701
+ if (e.keyCode !== 13) return
702
+ e.preventDefault()
703
+ try {
704
+ let answer = await this.validatePicking()
705
+ if (answer) {
706
+ if (!answer?.value) return
707
+ }
708
+ let orderNo = this.refPickingType === PICKING_TYPES.PICKING.value ? this.releaseGoodNo : this.taskNo
747
709
 
748
- if (data && findPalletId.hasMissingInventoryChanges) {
749
- this.scannable = false
750
- }
710
+ let response = {}
711
+ if (this.crossDocking) {
712
+ response = await this.pickCrossDocking()
713
+ } else if (this._enableProductScanning && this._isCartonLabel) {
714
+ response = await this.productBarcodePicking()
715
+ } else {
716
+ if (this._isReplacement && !this._isCartonLabel) {
717
+ if (this._isReleaseGoodRecall) {
718
+ throw new Error(i18next.t('text.lot_replacement_is_not_applicable_on_recall_release_order'))
719
+ } else {
720
+ this.openPalletReplacementPopup()
751
721
  }
722
+ return
723
+ } else {
724
+ response = await this.pickCommonPicking()
725
+ }
726
+ }
752
727
 
753
- if (this._isCartonLabel && data) {
754
- const findCartonId = worksheetDetailInfos.find(res => res.cartonId == data.cartonId)
728
+ if (!response.errors) {
729
+ if (this._hasBinPicking && (!this.toteNo || this.tote == '')) {
730
+ this._currentBinLocation = this.binLocationInput.value
731
+ }
732
+ if (this._isRequireSerialNumberScanningOutbound) this.serialInput.value = ''
733
+ else if (this._enableProductScanning) this.productBarcodeInput.value = ''
734
+ else this.releaseQtyInput.value = ''
755
735
 
756
- if (data && findCartonId?.hasMissingInventoryChanges) {
757
- this.scannable = false
758
- }
759
- }
736
+ if (!this._isCartonLabel && !this._isRequireSerialNumberScanningOutbound) {
737
+ this.palletInput.value = ''
738
+ }
760
739
 
761
- if (this._selectedOrderInventory) {
762
- const record = this.data.records.find(record => record.name === this._selectedOrderInventory.name)
763
- this._selectedOrderInventory = record
764
- this.updateSelectedItemProp(record)
765
- await this.updateComplete
766
- await this.grist.reset()
767
- this.fillUpForm(this.inputForm, {
768
- ...record,
769
- binLocation: record?.binLocation ? record.binLocation : ''
770
- })
740
+ if (!this.isWholePicking && !this._crossDocking && !this._isCartonLabel && this.locationInput)
741
+ this.locationInput.value = ''
742
+ }
771
743
 
772
- if (record.pickedQty == record.releaseQty) {
773
- if (this.cartonInput) this.cartonInput.value = ''
774
- if (this.palletInput) this.palletInput.value = ''
775
- } else {
776
- // pre-set bin location from last scan if none was set
777
- if (
778
- this._hasBinPicking &&
779
- this.binLocationInput &&
780
- (!this._currentBinLocation || this._currentBinLocation == '')
781
- ) {
782
- this._currentBinLocation = record?.binLocation ? record.binLocation : ''
783
- }
784
- }
744
+ await this.fetchInventories(orderNo)
785
745
 
786
- if (
787
- record.releaseQty - record.pickedQty == 1 &&
788
- !this._isCartonLabel &&
789
- this._isRequireSerialNumberScanningOutbound
790
- ) {
791
- this._isLastUnit = true
792
- } else {
793
- this._isLastUnit = false
794
- }
795
- }
796
-
797
- this._enableProductScanning = await fetchSettingRule('enable-product-scanning', worksheetInfo.partnerDomainId)
798
- this._enableToteScanning = await fetchSettingRule('enable-tote-scanning', worksheetInfo.partnerDomainId)
799
- this._enableInputQty = await fetchSettingRule('enable-input-qty', worksheetInfo.partnerDomainId)
800
- }
801
- break
802
-
803
- case PICKING_TYPES.BATCH_PICKING.value:
804
- response = await client.query({
805
- query: gql`
806
- query batchPickingWorksheet($taskNo: String!, $locationSortingRules: [Sorting!]) {
807
- batchPickingWorksheet(taskNo: $taskNo, locationSortingRules: $locationSortingRules) {
808
- worksheetInfo {
809
- bizplaceName
810
- partnerDomainId
811
- startedAt
812
- }
813
- worksheetDetailInfos {
814
- hasMissingInventoryChanges
815
- palletId
816
- cartonId
817
- batchId
818
- product {
819
- id
820
- name
821
- description
822
- sku
823
- isRequireSerialNumberScanning
824
- }
825
- qty
826
- releaseQty
827
- pickedQty
828
- expirationDate
829
- status
830
- packingType
831
- packingSize
832
- location {
833
- name
834
- }
835
- binLocation {
836
- name
837
- }
838
- relatedOrderInv {
839
- batchId
840
- packingType
841
- product {
842
- id
843
- name
844
- description
845
- sku
846
- }
847
- }
848
- }
849
- }
850
- }
851
- `,
852
- variables: { taskNo: pickingRefNo, locationSortingRules: this.locationSortingRules }
853
- })
854
-
855
- if (!response.errors) {
856
- if (!this._selectedOrderInventory) this.clearView()
857
- this.taskNo = pickingRefNo
858
- if (!response.data?.batchPickingWorksheet) return
859
-
860
- const { worksheetInfo, worksheetDetailInfos } = response.data.batchPickingWorksheet
861
- await this.updateComplete
862
- this._bizplaceName = worksheetInfo.bizplaceName
863
- this._orderNo = this.taskNo
864
- this._worksheetInfo = worksheetInfo
865
- this.data = { records: this.formatWorksheetDetailInfos(worksheetDetailInfos) }
866
-
867
- if (!this._selectedOrderInventory) {
868
- this._selectedOrderInventory = this.data.records[0]
869
- }
870
-
871
- if (
872
- this._selectedOrderInventory &&
873
- this._selectedOrderInventory.pickedQty != this._selectedOrderInventory.releaseQty &&
874
- !this._selectedOrderInventory.hasMissingInventoryChanges &&
875
- this._selectedOrderInventory.status !== 'MISSING'
876
- ) {
877
- this.scannable = true
878
- } else {
879
- this.scannable = false
880
- }
746
+ this.focusOnInput()
881
747
 
882
- if (!this._isCartonLabel && data) {
883
- const findPalletId = worksheetDetailInfos.find(res => res.palletId == data.palletId)
748
+ this.isReplacement = false
749
+ } catch (e) {
750
+ showToast(e)
751
+ }
752
+ }
884
753
 
885
- if (data && findPalletId.hasMissingInventoryChanges) {
886
- this.scannable = false
754
+ openPalletReplacementPopup() {
755
+ openPopup(
756
+ html`
757
+ <picking-replacement-popup
758
+ .orderInventory="${this._selectedOrderInventory}"
759
+ .refPickingType="${this.refPickingType}"
760
+ .replacePalletId="${this.palletInput.value}"
761
+ @completed="${() => {
762
+ this._selectedOrderInventory = null
763
+ let a = this._selectedOrderInventory
764
+ if (this.refPickingType === PICKING_TYPES.PICKING.value) {
765
+ this.fetchInventories(this.releaseGoodNoInput.value)
766
+ this.fetchPalletsHandler(this.releaseGoodNoInput.value)
767
+ } else {
768
+ this.fetchInventories(this.taskNoInput.value)
769
+ this.fetchPalletsHandler(this.taskNoInput.value)
887
770
  }
888
- }
771
+ // this._selectedTaskStatus = null
772
+ this._isReplacement = false
773
+ this._isExecuting = false
774
+ }}"
775
+ ></picking-replacement-popup>
776
+ `,
777
+ {
778
+ backdrop: true,
779
+ size: 'large',
780
+ title: i18next.t('title.pallet_replacement')
781
+ }
782
+ )
783
+ }
889
784
 
890
- if (this._isCartonLabel && data) {
891
- const findCartonId = worksheetDetailInfos.find(res => res.cartonId == data.cartonId)
785
+ async openSerialNumberPopup() {
786
+ await sleep(1010)
787
+ openPopup(
788
+ html`
789
+ <serial-number-popup
790
+ .orderInventory="${this?._selectedOrderInventory?.relatedOrderInv}"
791
+ .orderType="${i18next.t('text.outbound')}"
792
+ .orderSource="${ORDER_SOURCES.PICKING.value}"
793
+ .orderId="${this.releaseGoodId}"
794
+ .data="${this?._selectedOrderInventory}"
795
+ @close-serial-number-popup="${async e => {
796
+ await this.fetchAll(this.releaseGoodNo)
797
+ }}"
798
+ ></serial-number-popup>
799
+ `,
800
+ {
801
+ closable: false,
802
+ backdrop: false,
803
+ escapable: false,
804
+ size: 'large',
805
+ title: i18next.t('title.serial_number_list')
806
+ }
807
+ )
808
+ }
892
809
 
893
- if (data && findCartonId.hasMissingInventoryChanges) {
894
- this.scannable = false
895
- }
896
- }
810
+ async openTotePopup() {
811
+ await sleep(1010)
812
+ openPopup(
813
+ html`
814
+ <tote-popup
815
+ .orderNo="${this.releaseGoodNo}"
816
+ .toteNo="${this.toteNo}"
817
+ .bizplace="${this._bizplaceName}"
818
+ @completed="${async e => {
819
+ this.toteNo = e.detail
820
+ }}"
821
+ ></tote-popup>
822
+ `,
823
+ {
824
+ closable: false,
825
+ backdrop: false,
826
+ escapable: false,
827
+ size: 'large',
828
+ title: i18next.t('title.tote_scanning')
829
+ }
830
+ )
831
+ }
897
832
 
898
- this._enableProductScanning = await fetchSettingRule('enable-product-scanning', worksheetInfo.partnerDomainId)
899
- this._enableInputQty = await fetchSettingRule('enable-input-qty', worksheetInfo.partnerDomainId)
833
+ _openWorksheetInformation() {
834
+ openPopup(
835
+ html`
836
+ <worksheet-information-popup .worksheetInformation="${this._worksheetInfo}"></worksheet-information-popup>
837
+ `,
838
+ {
839
+ backdrop: true,
840
+ size: 'large',
841
+ title: i18next.t('title.order_information')
842
+ }
843
+ )
844
+ }
900
845
 
901
- if (this._selectedOrderInventory) {
902
- const record = this.data.records.find(
903
- record =>
904
- record.product.sku === this._selectedOrderInventory.product.sku &&
905
- record.palletId === this._selectedOrderInventory.palletId
906
- )
846
+ async pick_crossDocking() {
847
+ return await client.mutate({
848
+ mutation: gql`
849
+ mutation crossDockPicking(
850
+ $worksheetDetailName: String!
851
+ $worksheetType: String!
852
+ $palletId: String!
853
+ $releaseQty: Int!
854
+ ) {
855
+ crossDockPicking(
856
+ worksheetDetailName: $worksheetDetailName
857
+ worksheetType: $worksheetType
858
+ palletId: $palletId
859
+ releaseQty: $releaseQty
860
+ )
861
+ }
862
+ `,
863
+ variables: {
864
+ worksheetDetailName: this._selectedOrderInventory.name,
865
+ worksheetType: this.refPickingType,
866
+ palletId: this.palletInput.value,
867
+ releaseQty: parseInt(this.releaseQtyInput.value)
868
+ }
869
+ })
870
+ }
907
871
 
908
- this._selectedOrderInventory = record
909
- await this.updateSelectedItemProp(record)
872
+ async pickCommonPicking() {
873
+ if (this._isExecuting) throw new Error(i18next.t('text.previous_picking_is_still_executing_please_wait'))
874
+ this._isExecuting = true
910
875
 
911
- if (record.pickedQty == record.releaseQty) {
912
- if (this._isCartonLabel) {
913
- //need to relook into clearview logic
914
- if (this.cartonInput) this.cartonInput.value = ''
915
- if (this.productBarcodeInput) this.productBarcodeInput.value = ''
876
+ try {
877
+ switch (this.refPickingType) {
878
+ case PICKING_TYPES.PICKING.value:
879
+ return await client.mutate({
880
+ mutation: gql`
881
+ mutation picking(
882
+ $worksheetDetailName: String!
883
+ $worksheetType: String!
884
+ $palletId: String
885
+ $locationName: String!
886
+ $releaseQty: Int!
887
+ $binLocation: String
888
+ $serialNumber: String
889
+ $toteNo: String
890
+ ) {
891
+ picking(
892
+ worksheetDetailName: $worksheetDetailName
893
+ worksheetType: $worksheetType
894
+ palletId: $palletId
895
+ locationName: $locationName
896
+ releaseQty: $releaseQty
897
+ binLocation: $binLocation
898
+ serialNumber: $serialNumber
899
+ toteNo: $toteNo
900
+ )
916
901
  }
917
- this.fillUpForm(this.inputForm, record)
918
- } else {
919
- this.fillUpForm(this.inputForm, record)
902
+ `,
903
+ variables: {
904
+ worksheetDetailName: this._selectedOrderInventory.name,
905
+ worksheetType: this.refPickingType,
906
+ palletId: this.palletInput.value.trim(),
907
+ locationName: this._locationName ? this._locationName : this._selectedOrderInventory?.location.name,
908
+ releaseQty: this._isRequireSerialNumberScanningOutbound ? 1 : parseInt(this.releaseQtyInput.value),
909
+ binLocation:
910
+ this._hasBinPicking && (!this.toteNo || this.tote == '') ? this.binLocationInput.value : null,
911
+ serialNumber: this._isRequireSerialNumberScanningOutbound ? this.serialInput.value : null,
912
+ toteNo: this._enableToteScanning && this.toteNo !== '' ? this.toteNo : null
920
913
  }
914
+ })
921
915
 
922
- if (
923
- record.releaseQty - record.pickedQty == 1 &&
924
- !this._isCartonLabel &&
925
- this._isRequireSerialNumberScanningOutbound
926
- ) {
927
- this._isLastUnit = true
928
- } else {
929
- this._isLastUnit = false
916
+ case PICKING_TYPES.BATCH_PICKING.value:
917
+ return await client.mutate({
918
+ mutation: gql`
919
+ mutation batchPicking(
920
+ $taskNo: String!
921
+ $worksheetType: String!
922
+ $palletId: String!
923
+ $locationName: String
924
+ $binLocationName: String
925
+ $releaseQty: Int!
926
+ ) {
927
+ batchPicking(
928
+ taskNo: $taskNo
929
+ worksheetType: $worksheetType
930
+ palletId: $palletId
931
+ locationName: $locationName
932
+ binLocationName: $binLocationName
933
+ releaseQty: $releaseQty
934
+ )
935
+ }
936
+ `,
937
+ variables: {
938
+ taskNo: this.taskNo,
939
+ worksheetType: this.refPickingType,
940
+ palletId: this.palletInput.value.trim(),
941
+ locationName: this._locationName ? this._locationName : this._selectedOrderInventory?.location.name,
942
+ binLocationName:
943
+ this._hasBinPicking && (!this.toteNo || this.tote == '') ? this.binLocationInput.value : null,
944
+ releaseQty: parseInt(this.releaseQtyInput.value)
930
945
  }
931
- }
932
- }
933
- break
946
+ })
947
+ }
948
+ } catch (e) {
949
+ showToast(e)
950
+ } finally {
951
+ this._isExecuting = false
934
952
  }
935
-
936
- this.updateContext()
937
953
  }
938
954
 
939
- formatWorksheetDetailInfos(wsdInfos) {
940
- return wsdInfos
941
- .map(record => {
942
- if (record.pickedQty == record.releaseQty || record.status == 'MISSING') {
943
- record.completed = true
944
- } else {
945
- record.completed = false
946
- }
947
- record.locationName = record?.location?.name
948
- record.product = record?.relatedOrderInv && record?.relatedOrderInv?.product
949
-
950
- if (this._crossDocking) {
951
- record.batchId = record.relatedOrderInv.batchId
952
- record.packingType = record.relatedOrderInv.packingType
953
- }
954
-
955
- if (this._hasBinPicking) {
956
- record.binLocation = record.binLocation?.name
957
- }
958
-
959
- if (record?.cartonId) {
960
- record.hasCartonLabel = true
961
- }
962
-
963
- record.releaseProgress = `${record.pickedQty} / ${record.releaseQty}`
964
- record.sku = record?.relatedOrderInv.product?.sku
965
-
966
- return record
967
- })
968
- .sort((a, b) => a.hasMissingInventoryChanges - b.hasMissingInventoryChanges)
969
- .sort((a, b) => a.completed - b.completed)
970
- }
955
+ async productBarcodePicking() {
956
+ if (this._isExecuting) throw new Error(i18next.t('text.previous_picking_is_still_executing_please_wait'))
957
+ this._isExecuting = true
971
958
 
972
- async fetchPalletsHandler(releaseGoodNo) {
973
- const response = await client.query({
974
- query: gql`
975
- query pallets($filters: [Filter!]!, $pagination: Pagination) {
976
- pallets(filters: $filters, pagination: $pagination) {
977
- items {
978
- id
979
- name
980
- owner {
981
- id
982
- name
983
- description
959
+ try {
960
+ switch (this.refPickingType) {
961
+ case PICKING_TYPES.PICKING.value:
962
+ return await client.mutate({
963
+ mutation: gql`
964
+ mutation scanProductPicking(
965
+ $worksheetDetailName: String!
966
+ $worksheetType: String!
967
+ $productBarcode: String!
968
+ $cartonId: String!
969
+ $binLocation: String
970
+ $serialNumber: String
971
+ $toteNo: String
972
+ $pickingQty: Int
973
+ ) {
974
+ scanProductPicking(
975
+ worksheetDetailName: $worksheetDetailName
976
+ worksheetType: $worksheetType
977
+ productBarcode: $productBarcode
978
+ cartonId: $cartonId
979
+ binLocation: $binLocation
980
+ serialNumber: $serialNumber
981
+ toteNo: $toteNo
982
+ pickingQty: $pickingQty
983
+ )
984
984
  }
985
- holder {
986
- id
987
- name
988
- description
985
+ `,
986
+ variables: {
987
+ worksheetDetailName: this._selectedOrderInventory.name,
988
+ worksheetType: this.refPickingType,
989
+ productBarcode: this.productBarcodeInput.value.trim(),
990
+ cartonId: this.cartonInput.value.trim(),
991
+ serialNumber: this._isRequireSerialNumberScanningOutbound ? this.serialInput.value : null,
992
+ binLocation:
993
+ this._hasBinPicking && (!this.toteNo || this.tote == '') ? this.binLocationInput.value : null,
994
+ toteNo: this._enableToteScanning && this.toteNo !== '' ? this.toteNo : null,
995
+ pickingQty: this.releaseQtyInput?.value ? parseInt(this.releaseQtyInput.value) : 1
996
+ }
997
+ })
998
+
999
+ case PICKING_TYPES.BATCH_PICKING.value:
1000
+ return await client.mutate({
1001
+ mutation: gql`
1002
+ mutation scanProductBatchPicking(
1003
+ $taskNo: String!
1004
+ $worksheetType: String!
1005
+ $cartonId: String!
1006
+ $inventory: InventoryPatch!
1007
+ $productBarcode: String!
1008
+ $binLocationName: String
1009
+ $pickingQty: Int
1010
+ ) {
1011
+ scanProductBatchPicking(
1012
+ taskNo: $taskNo
1013
+ worksheetType: $worksheetType
1014
+ cartonId: $cartonId
1015
+ inventory: $inventory
1016
+ productBarcode: $productBarcode
1017
+ binLocationName: $binLocationName
1018
+ pickingQty: $pickingQty
1019
+ )
989
1020
  }
990
- status
1021
+ `,
1022
+ variables: {
1023
+ taskNo: this.taskNo,
1024
+ worksheetType: this.refPickingType,
1025
+ cartonId: this.cartonInput.value.trim(),
1026
+ productBarcode: this.productBarcodeInput.value.trim(),
1027
+ inventory: {
1028
+ batchId: this._selectedOrderInventory.batchId,
1029
+ packingType: this._selectedOrderInventory.packingType,
1030
+ packingSize: this._selectedOrderInventory.packingSize,
1031
+ product: { id: this._selectedOrderInventory.product.id }
1032
+ },
1033
+ binLocationName:
1034
+ this._hasBinPicking && (!this.toteNo || this.tote == '') ? this.binLocationInput.value : null,
1035
+ pickingQty: this.releaseQtyInput?.value ? parseInt(this.releaseQtyInput.value) : 1
991
1036
  }
992
- }
993
- }
994
- `,
995
- variables: {
996
- filters: [{ name: 'refOrderNo', value: releaseGoodNo, operator: 'eq' }],
997
- pagination: { page: 1, limit: 9999999 }
1037
+ })
998
1038
  }
999
- })
1000
-
1001
- if (!response.errors) {
1002
- this._reusablePalletList = { records: response.data.pallets.items }
1003
- }
1004
- }
1005
-
1006
- clearView() {
1007
- this.data = { records: [] }
1008
- this.infoForm.reset()
1009
- this.inputForm.reset()
1010
- this._isRequireSerialNumberScanningOutbound = false
1011
- this.releaseGoodNo = null
1012
- this.releaseGoodId = null
1013
- this.taskNo = null
1014
- this._crossDocking = false
1015
- this._selectedOrderInventory = null
1016
- this._incompleteLocationName = false
1017
- this._isExecuting = false
1018
- this._locationName = null
1019
- this.toteNo = ''
1020
- }
1021
-
1022
- fillUpForm(form, data) {
1023
- this._incompleteLocationName = false
1024
- form.reset()
1025
- for (let key in data) {
1026
- Array.from(form.querySelectorAll('input')).forEach(field => {
1027
- if (field.name === key && field.type === 'checkbox') {
1028
- field.checked = data[key]
1029
- } else if (field.name === key && field.type === 'datetime-local') {
1030
- const datetime = Number(data[key])
1031
- const timezoneOffset = new Date(datetime).getTimezoneOffset() * 60000
1032
- field.value = new Date(datetime - timezoneOffset).toISOString().slice(0, -1)
1033
- } else if (field.name === key) {
1034
- if (data[key] instanceof Object) {
1035
- const objectData = data[key]
1036
- field.value = `${objectData.name} ${objectData.description ? `(${objectData.description})` : ''}`
1037
- } else {
1038
- field.value = data[key]
1039
- }
1040
- }
1041
- })
1039
+ } catch (e) {
1040
+ throw e
1041
+ } finally {
1042
+ this._isExecuting = false
1042
1043
  }
1043
1044
  }
1044
1045
 
1045
- async picking(e) {
1046
- if (e.keyCode !== 13) return
1047
- e.preventDefault()
1048
- try {
1049
- let answer = await this.validatePicking()
1046
+ async validatePicking() {
1047
+ // validate for order selection
1048
+ // pallet id existing
1050
1049
 
1051
- if (answer) {
1052
- if (!answer?.value) return
1050
+ if ((!this.palletInput?.value || !this.cartonInput?.value) && this._isRequireSerialNumberScanningOutbound) {
1051
+ if (!this.serialInput?.value) {
1052
+ this._focusOnSerialInput()
1053
+ throw new Error(i18next.t('text.empty_serial_number'))
1053
1054
  }
1055
+ }
1054
1056
 
1055
- let response = {}
1056
- if (this.crossDocking) {
1057
- response = await this.pickCrossDocking()
1058
- } else if (this._enableProductScanning && this._isCartonLabel) {
1059
- response = await this.productBarcodePicking()
1057
+ if (!this._isCartonLabel) {
1058
+ if (!this.palletInput.value) {
1059
+ this._focusOnLotNoInput()
1060
+ throw new Error(i18next.t('text.lot_id_is_empty'))
1060
1061
  } else {
1061
- if (this._isReplacement && !this._isCartonLabel) {
1062
- if (this._isReleaseGoodRecall) {
1063
- throw new Error(i18next.t('text.lot_replacement_is_not_applicable_on_recall_release_order'))
1064
- } else {
1065
- this.openPalletReplacementPopup()
1062
+ if (
1063
+ this._selectedOrderInventory.palletId !== this.palletInput.value &&
1064
+ !this._isRequireSerialNumberScanningOutbound
1065
+ ) {
1066
+ const isInProgressing = await this.checkProgressingPallet(this.palletInput.value)
1067
+ if (isInProgressing) throw new Error(i18next.t('text.pallet_is_in_progressing'))
1068
+
1069
+ this._isReplacement = await this.checkProductIdenticality(
1070
+ this._selectedOrderInventory.palletId,
1071
+ this.palletInput.value
1072
+ )
1073
+
1074
+ if (!this._isReplacement) {
1075
+ this._focusOnLotNoInput()
1076
+ throw new Error(i18next.t('text.wrong_lot_id'))
1066
1077
  }
1067
- return
1068
- } else {
1069
- response = await this.pickCommonPicking()
1070
1078
  }
1071
1079
  }
1080
+ } else {
1081
+ if (!this.cartonInput?.value) {
1082
+ this._focusOnCartonNoInput()
1083
+ throw new Error(i18next.t('text.carton_id_is_empty'))
1084
+ }
1072
1085
 
1073
- if (!response.errors) {
1074
- if (this._hasBinPicking && (!this.toteNo || this.tote == '')) {
1075
- this._currentBinLocation = this.binLocationInput.value
1076
- }
1077
- if (this._isRequireSerialNumberScanningOutbound) this.serialInput.value = ''
1078
- else if (this._enableProductScanning) this.productBarcodeInput.value = ''
1079
- else this.releaseQtyInput.value = ''
1086
+ if (this._selectedOrderInventory.cartonId) {
1087
+ if (this._selectedOrderInventory.cartonId !== this.cartonInput.value) {
1088
+ //carton replacement?
1089
+ throw new Error(i18next.t('text.invalid_carton_id'))
1090
+ this._isReplacement = await this.checkCartonIdenticality(
1091
+ this._selectedOrderInventory.cartonId,
1092
+ this._selectedOrderInventory.palletId,
1093
+ this.cartonInput.value
1094
+ )
1080
1095
 
1081
- if (!this._isCartonLabel && !this._isRequireSerialNumberScanningOutbound) {
1082
- this.palletInput.value = ''
1096
+ if (!this._isReplacement) {
1097
+ this.cartonInput.value = ''
1098
+ this._focusOnCartonNoInput()
1099
+ throw new Error(i18next.t('text.wrong_carton_id'))
1100
+ }
1083
1101
  }
1084
1102
 
1085
- if (!this.isWholePicking && !this._crossDocking && !this._isCartonLabel && this.locationInput)
1086
- this.locationInput.value = ''
1087
- if (this.refPickingType === PICKING_TYPES.PICKING.value) {
1088
- await this.fetchInventories(this.releaseGoodNo)
1089
- } else {
1090
- await this.fetchInventories(this.taskNo)
1103
+ if (this._enableProductScanning) {
1104
+ if (!this.productBarcodeInput?.value) {
1105
+ this._focusOnProductBarcodeInput()
1106
+ throw new Error(i18next.t('text.empty_product_barcode'))
1107
+ }
1091
1108
  }
1109
+ }
1110
+ }
1092
1111
 
1093
- if (
1094
- this._selectedOrderInventory &&
1095
- this._selectedOrderInventory.pickedQty == this._selectedOrderInventory.releaseQty
1096
- ) {
1097
- this._selectedOrderInventory = null
1098
- if (this.refPickingType === PICKING_TYPES.PICKING.value) {
1099
- await this.fetchInventories(this.releaseGoodNo)
1100
- } else {
1101
- await this.fetchInventories(this.taskNo)
1112
+ if (!this._isReplacement) {
1113
+ if (!this._isRequireSerialNumberScanningOutbound) {
1114
+ if (this.releaseQtyInput) {
1115
+ if (!parseInt(this.releaseQtyInput?.value)) {
1116
+ this._focusOnReleaseQtyInput()
1117
+ throw new Error(i18next.t('text.release_qty_is_empty'))
1118
+ }
1119
+
1120
+ if (!this.releaseQtyInput?.checkValidity()) throw new Error(i18next.t('text.release_qty_invalid'))
1121
+
1122
+ // typed qty should be matched with release qty.
1123
+ if (
1124
+ parseInt(this.releaseQtyInput.value) !==
1125
+ this._selectedOrderInventory.releaseQty -
1126
+ (this._selectedOrderInventory.pickedQty ? this._selectedOrderInventory.pickedQty : 0) &&
1127
+ !this._isCartonLabel
1128
+ ) {
1129
+ this._focusOnReleaseQtyInput()
1130
+ throw new Error(i18next.t('text.wrong_release_qty'))
1102
1131
  }
1103
- }
1104
- } else {
1105
- if (this.refPickingType === PICKING_TYPES.PICKING.value) {
1106
- await this.fetchInventories(this.releaseGoodNo)
1107
- } else {
1108
- await this.fetchInventories(this.taskNo)
1109
1132
  }
1110
1133
  }
1111
1134
 
1112
- this.focusOnInput()
1135
+ if (!this._isCartonLabel) {
1136
+ // location id existing
1137
+ if (!this.isWholePicking && this.locationInput) {
1138
+ if (!this.locationInput.value) {
1139
+ this._focusOnLocationNameInput()
1140
+ throw new Error(i18next.t('text.location_id_is_empty'))
1141
+ }
1142
+ // check if actual return location
1143
+ this._locationName =
1144
+ this.isWholePicking || !this.locationInput
1145
+ ? this._selectedOrderInventory.location.name
1146
+ : this.locationInput.value
1147
+ // 1. Check whether location is changed
1148
+ if (this._selectedOrderInventory.location.name !== this._locationName) {
1149
+ this.locationNameSplit = this.locationInput.value.split('-')
1150
+ if (this.locationNameSplit.length < 3) {
1151
+ this._focusOnLocationNameInput()
1152
+ throw new Error(i18next.t('text.invalid_return_location'))
1153
+ }
1154
+ const zonePortions = this.locationNameSplit[0].match(/[a-zA-Z0-9]+/g)
1155
+ const rowPortions = this.locationNameSplit[1].match(/[a-zA-Z0-9]+/g)
1156
+ const columnPortions = this.locationNameSplit[2].match(/[a-zA-Z0-9]+/g)
1157
+ const shelfPortions = this.locationNameSplit[3].match(/[a-zA-Z0-9]+/g)
1158
+ if (this.locationNameSplit.length === 3) {
1159
+ this.locations = await this.fetchLocations(zonePortions[0], rowPortions[0], columnPortions[0])
1160
+ this._focusOnNewLocationInput()
1113
1161
 
1114
- this.isReplacement = false
1115
- } catch (e) {
1116
- this._showToast(e)
1117
- }
1118
- }
1162
+ const selectedLocations = this.locations.find(res => {
1163
+ return res.name === this._locationName
1164
+ })
1119
1165
 
1120
- openPalletReplacementPopup() {
1121
- openPopup(
1122
- html`
1123
- <picking-replacement-popup
1124
- .orderInventory="${this._selectedOrderInventory}"
1125
- .refPickingType="${this.refPickingType}"
1126
- .replacePalletId="${this.palletInput.value}"
1127
- @completed="${() => {
1128
- this._selectedOrderInventory = null
1129
- let a = this._selectedOrderInventory
1130
- if (this.refPickingType === PICKING_TYPES.PICKING.value) {
1131
- this.fetchInventories(this.releaseGoodNoInput.value)
1132
- this.fetchPalletsHandler(this.releaseGoodNoInput.value)
1133
- } else {
1134
- this.fetchInventories(this.taskNoInput.value)
1135
- this.fetchPalletsHandler(this.taskNoInput.value)
1166
+ if (this._isReleaseGoodRecall) {
1167
+ if (![selectedLocations.type].includes(LOCATION_TYPE.QUARANTINE.value, LOCATION_TYPE.RESERVE.value)) {
1168
+ throw new Error(i18next.t('text.location_scanned_is_not_a_quarantine_zone_or_reserved_zone'))
1169
+ }
1170
+ }
1171
+
1172
+ if (this.locations.length > 0) {
1173
+ this._incompleteLocationName = true
1174
+ throw new Error(i18next.t('text.please_select_the_location_again'))
1175
+ } else {
1176
+ throw new Error(i18next.t('text.invalid_return_location'))
1177
+ }
1178
+ } else if (this.locationNameSplit.length === 4) {
1179
+ this.locations = await this.fetchLocations(
1180
+ zonePortions[0],
1181
+ rowPortions[0],
1182
+ columnPortions[0],
1183
+ shelfPortions[0]
1184
+ )
1185
+
1186
+ const selectedLocations = this.locations.find(res => {
1187
+ return res.name === this._locationName
1188
+ })
1189
+
1190
+ if (this._isReleaseGoodRecall) {
1191
+ if (![selectedLocations.type].includes(LOCATION_TYPE.QUARANTINE.value, LOCATION_TYPE.RESERVE.value)) {
1192
+ throw new Error(i18next.t('text.location_scanned_is_not_a_quarantine_zone_or_reserved_zone'))
1193
+ }
1194
+ }
1195
+
1196
+ let relocateConfirmation = await CustomAlert({
1197
+ title: i18next.t('title.relocate'),
1198
+ text: i18next.t('text.are_you_sure'),
1199
+ confirmButton: { text: i18next.t('button.relocate') },
1200
+ cancelButton: { text: i18next.t('button.cancel') }
1201
+ })
1202
+
1203
+ if (!relocateConfirmation.isConfirmed) {
1204
+ this._incompleteLocationName = false
1205
+ this.locationNameSplit = []
1206
+ return relocateConfirmation
1207
+ }
1136
1208
  }
1137
- // this._selectedTaskStatus = null
1138
- this._isReplacement = false
1139
- this._isExecuting = false
1140
- }}"
1141
- ></picking-replacement-popup>
1142
- `,
1143
- {
1144
- backdrop: true,
1145
- size: 'large',
1146
- title: i18next.t('title.pallet_replacement')
1209
+ }
1210
+ }
1147
1211
  }
1148
- )
1149
- }
1212
+ }
1150
1213
 
1151
- async openSerialNumberPopup() {
1152
- await sleep(1010)
1153
- openPopup(
1154
- html`
1155
- <serial-number-popup
1156
- .orderInventory="${this?._selectedOrderInventory?.relatedOrderInv}"
1157
- .orderType="${i18next.t('text.outbound')}"
1158
- .orderSource="${ORDER_SOURCES.PICKING.value}"
1159
- .orderId="${this.releaseGoodId}"
1160
- .data="${this?._selectedOrderInventory}"
1161
- @close-serial-number-popup="${async e => {
1162
- await this.fetchAll(this.releaseGoodNo)
1163
- }}"
1164
- ></serial-number-popup>
1165
- `,
1166
- {
1167
- closable: false,
1168
- backdrop: false,
1169
- escapable: false,
1170
- size: 'large',
1171
- title: i18next.t('title.serial_number_list')
1214
+ if (this._crossDocking) {
1215
+ // typed qty should be smaller than release qty.
1216
+ if (parseInt(this.releaseQtyInput.value) > this._selectedOrderInventory.releaseQty) {
1217
+ this._focusOnReleaseQtyInput()
1218
+ throw new Error(i18next.t('text.wrong_release_qty'))
1172
1219
  }
1173
- )
1220
+ }
1174
1221
  }
1175
1222
 
1176
- async openTotePopup() {
1177
- await sleep(1010)
1178
- openPopup(
1179
- html`
1180
- <tote-popup
1181
- .orderNo="${this.releaseGoodNo}"
1182
- .toteNo="${this.toteNo}"
1183
- .bizplace="${this._bizplaceName}"
1184
- @completed="${async e => {
1185
- this.toteNo = e.detail
1186
- }}"
1187
- ></tote-popup>
1188
- `,
1189
- {
1190
- closable: false,
1191
- backdrop: false,
1192
- escapable: false,
1193
- size: 'large',
1194
- title: i18next.t('title.tote_scanning')
1195
- }
1196
- )
1223
+ async checkProgressingPallet(palletId) {
1224
+ const response = await client.query({
1225
+ query: gql`
1226
+ query checkProgressingPallet($palletId: String!) {
1227
+ checkProgressingPallet(palletId: $palletId)
1228
+ }
1229
+ `,
1230
+ variables: { palletId }
1231
+ })
1232
+
1233
+ if (!response.errors) {
1234
+ return response.data.checkProgressingPallet
1235
+ }
1197
1236
  }
1198
1237
 
1199
- _openWorksheetInformation() {
1200
- openPopup(
1201
- html`
1202
- <worksheet-information-popup .worksheetInformation="${this._worksheetInfo}"></worksheet-information-popup>
1238
+ async checkProductIdenticality(palletA, palletB) {
1239
+ const response = await client.query({
1240
+ query: gql`
1241
+ query checkProductIdenticality($palletA: String!, $palletB: String!) {
1242
+ checkProductIdenticality(palletA: $palletA, palletB: $palletB)
1243
+ }
1203
1244
  `,
1204
- {
1205
- backdrop: true,
1206
- size: 'large',
1207
- title: i18next.t('title.order_information')
1208
- }
1209
- )
1245
+ variables: { palletA, palletB }
1246
+ })
1247
+
1248
+ if (!response.errors) {
1249
+ return response.data.checkProductIdenticality
1250
+ }
1210
1251
  }
1211
1252
 
1212
- async pick_crossDocking() {
1213
- return await client.mutate({
1214
- mutation: gql`
1215
- mutation crossDockPicking(
1216
- $worksheetDetailName: String!
1217
- $worksheetType: String!
1218
- $palletId: String!
1219
- $releaseQty: Int!
1220
- ) {
1221
- crossDockPicking(
1222
- worksheetDetailName: $worksheetDetailName
1223
- worksheetType: $worksheetType
1224
- palletId: $palletId
1225
- releaseQty: $releaseQty
1226
- )
1253
+ async checkCartonIdenticality(cartonA, palletA, cartonB) {
1254
+ const response = await client.query({
1255
+ query: gql`
1256
+ query checkCartonIdenticality($cartonA: String!, $palletA: String!, $cartonB: String!) {
1257
+ checkCartonIdenticality(cartonA: $cartonA, palletA: $palletA, cartonB: $cartonB)
1227
1258
  }
1228
1259
  `,
1229
- variables: {
1230
- worksheetDetailName: this._selectedOrderInventory.name,
1231
- worksheetType: this.refPickingType,
1232
- palletId: this.palletInput.value,
1233
- releaseQty: parseInt(this.releaseQtyInput.value)
1234
- }
1260
+ variables: { cartonA, palletA, cartonB }
1235
1261
  })
1262
+
1263
+ if (!response.errors) {
1264
+ return response.data.checkCartonIdenticality
1265
+ }
1236
1266
  }
1237
1267
 
1238
- async pickCommonPicking() {
1239
- if (this._isExecuting) throw new Error(i18next.t('text.previous_picking_is_still_executing_please_wait'))
1240
- this._isExecuting = true
1268
+ async fetchLocations(zone, row, column) {
1269
+ const sortings = [{ name: 'name', desc: false }]
1270
+ const filters = [
1271
+ { name: 'zone', operator: 'eq', value: zone },
1272
+ { name: 'row', operator: 'eq', value: row },
1273
+ { name: 'column', operator: 'eq', value: column }
1274
+ ]
1241
1275
 
1242
- try {
1243
- switch (this.refPickingType) {
1244
- case PICKING_TYPES.PICKING.value:
1245
- return await client.mutate({
1246
- mutation: gql`
1247
- mutation picking(
1248
- $worksheetDetailName: String!
1249
- $worksheetType: String!
1250
- $palletId: String
1251
- $locationName: String!
1252
- $releaseQty: Int!
1253
- $binLocation: String
1254
- $serialNumber: String
1255
- $toteNo: String
1256
- ) {
1257
- picking(
1258
- worksheetDetailName: $worksheetDetailName
1259
- worksheetType: $worksheetType
1260
- palletId: $palletId
1261
- locationName: $locationName
1262
- releaseQty: $releaseQty
1263
- binLocation: $binLocation
1264
- serialNumber: $serialNumber
1265
- toteNo: $toteNo
1266
- )
1276
+ if (filters) {
1277
+ const response = await client.query({
1278
+ query: gql`
1279
+ query locations($filters: [Filter!], $sortings: [Sorting!]) {
1280
+ locations(filters: $filters, sortings: $sortings) {
1281
+ items {
1282
+ id
1283
+ name
1284
+ zone
1285
+ row
1286
+ column
1287
+ shelf
1288
+ status
1289
+ type
1267
1290
  }
1268
- `,
1269
- variables: {
1270
- worksheetDetailName: this._selectedOrderInventory.name,
1271
- worksheetType: this.refPickingType,
1272
- palletId: this.palletInput.value.trim(),
1273
- locationName: this._locationName ? this._locationName : this._selectedOrderInventory?.location.name,
1274
- releaseQty: this._isRequireSerialNumberScanningOutbound ? 1 : parseInt(this.releaseQtyInput.value),
1275
- binLocation:
1276
- this._hasBinPicking && (!this.toteNo || this.tote == '') ? this.binLocationInput.value : null,
1277
- serialNumber: this._isRequireSerialNumberScanningOutbound ? this.serialInput.value : null,
1278
- toteNo: this._enableToteScanning && this.toteNo !== '' ? this.toteNo : null
1279
1291
  }
1280
- })
1292
+ }
1293
+ `,
1294
+ variables: { filters, sortings }
1295
+ })
1281
1296
 
1282
- case PICKING_TYPES.BATCH_PICKING.value:
1283
- return await client.mutate({
1284
- mutation: gql`
1285
- mutation batchPicking(
1286
- $taskNo: String!
1287
- $worksheetType: String!
1288
- $palletId: String!
1289
- $locationName: String
1290
- $binLocationName: String
1291
- $releaseQty: Int!
1292
- ) {
1293
- batchPicking(
1294
- taskNo: $taskNo
1295
- worksheetType: $worksheetType
1296
- palletId: $palletId
1297
- locationName: $locationName
1298
- binLocationName: $binLocationName
1299
- releaseQty: $releaseQty
1300
- )
1301
- }
1302
- `,
1303
- variables: {
1304
- taskNo: this.taskNo,
1305
- worksheetType: this.refPickingType,
1306
- palletId: this.palletInput.value.trim(),
1307
- locationName: this._locationName ? this._locationName : this._selectedOrderInventory?.location.name,
1308
- binLocationName:
1309
- this._hasBinPicking && (!this.toteNo || this.tote == '') ? this.binLocationInput.value : null,
1310
- releaseQty: parseInt(this.releaseQtyInput.value)
1297
+ if (!response.errors) {
1298
+ return response.data.locations.items || []
1299
+ }
1300
+ }
1301
+ }
1302
+
1303
+ autoFetchPickingTasks(orderNo) {
1304
+ this.releaseGoodNoInput.value = orderNo
1305
+ this.fetchAll(this.releaseGoodNoInput.value)
1306
+ }
1307
+
1308
+ async fetchInventories(pickingRefNo) {
1309
+ if (!pickingRefNo) return
1310
+
1311
+ //this.releaseGoodNo will be incorrect if worksheet list is used, therefore it's assigned here
1312
+ //this._selectedOrderInventory still has the value of previous order, therefore it's cleared here
1313
+ if (this.releaseGoodNo !== pickingRefNo) {
1314
+ this.releaseGoodNo = pickingRefNo
1315
+ this._selectedOrderInventory = null
1316
+ }
1317
+
1318
+ const data = this._selectedOrderInventory
1319
+ let response
1320
+ switch (this.refPickingType) {
1321
+ case PICKING_TYPES.PICKING.value:
1322
+ response = await client.query({
1323
+ query: gql`
1324
+ query pickingWorksheet($releaseGoodNo: String!, $locationSortingRules: [Sorting!]) {
1325
+ pickingWorksheet(releaseGoodNo: $releaseGoodNo, locationSortingRules: $locationSortingRules) {
1326
+ worksheetInfo {
1327
+ releaseGood {
1328
+ id
1329
+ name
1330
+ recall
1331
+ crossDocking
1332
+ type
1333
+ }
1334
+ bizplaceName
1335
+ partnerDomainId
1336
+ refNo
1337
+ refNo2
1338
+ refNo3
1339
+ startedAt
1340
+ containerNo
1341
+ marketplaceStatus
1342
+ shippingProvider
1343
+ trackingNo
1344
+ }
1345
+ worksheetDetailInfos {
1346
+ hasMissingInventoryChanges
1347
+ name
1348
+ palletId
1349
+ cartonId
1350
+ batchId
1351
+ batchIdRef
1352
+ product {
1353
+ id
1354
+ sku
1355
+ name
1356
+ description
1357
+ isRequireSerialNumberScanningOutbound
1358
+ }
1359
+ qty
1360
+ releaseQty
1361
+ pickedQty
1362
+ expirationDate
1363
+ status
1364
+ description
1365
+ targetName
1366
+ packingType
1367
+ packingSize
1368
+ location {
1369
+ name
1370
+ description
1371
+ }
1372
+ binLocation {
1373
+ name
1374
+ description
1375
+ }
1376
+ relatedOrderInv {
1377
+ id
1378
+ batchId
1379
+ batchIdRef
1380
+ packingType
1381
+ binLocation {
1382
+ id
1383
+ name
1384
+ }
1385
+ product {
1386
+ id
1387
+ sku
1388
+ name
1389
+ description
1390
+ isRequireSerialNumberScanningOutbound
1391
+ }
1392
+ }
1393
+ }
1394
+ }
1311
1395
  }
1312
- })
1313
- }
1314
- } catch (e) {
1315
- this._showToast(e)
1316
- } finally {
1317
- this._isExecuting = false
1318
- }
1319
- }
1396
+ `,
1397
+ variables: { releaseGoodNo: pickingRefNo, locationSortingRules: this.locationSortingRules }
1398
+ })
1320
1399
 
1321
- async productBarcodePicking() {
1322
- if (this._isExecuting) throw new Error(i18next.t('text.previous_picking_is_still_executing_please_wait'))
1323
- this._isExecuting = true
1400
+ if (!response.errors) {
1401
+ this._isReleaseGoodRecall = response.data.pickingWorksheet.worksheetInfo.releaseGood.recall
1402
+ let releaseGood = response.data.pickingWorksheet.worksheetInfo.releaseGood
1403
+ this.releaseGoodId = releaseGood.id
1404
+ this._releaseGoodType = releaseGood.type
1324
1405
 
1325
- try {
1326
- switch (this.refPickingType) {
1327
- case PICKING_TYPES.PICKING.value:
1328
- return await client.mutate({
1329
- mutation: gql`
1330
- mutation scanProductPicking(
1331
- $worksheetDetailName: String!
1332
- $worksheetType: String!
1333
- $productBarcode: String!
1334
- $cartonId: String!
1335
- $binLocation: String
1336
- $serialNumber: String
1337
- $toteNo: String
1338
- $pickingQty: Int
1339
- ) {
1340
- scanProductPicking(
1341
- worksheetDetailName: $worksheetDetailName
1342
- worksheetType: $worksheetType
1343
- productBarcode: $productBarcode
1344
- cartonId: $cartonId
1345
- binLocation: $binLocation
1346
- serialNumber: $serialNumber
1347
- toteNo: $toteNo
1348
- pickingQty: $pickingQty
1349
- )
1406
+ if (!response.data?.pickingWorksheet) return
1407
+ const { worksheetInfo, worksheetDetailInfos } = response.data.pickingWorksheet
1408
+ this._crossDocking = worksheetInfo.releaseGood?._crossDocking
1409
+ this._bizplaceName = worksheetInfo.bizplaceName
1410
+ this._orderNo = this.releaseGoodNo
1411
+ this._worksheetInfo = worksheetInfo
1412
+ let data = { records: this.formatWorksheetDetailInfos(worksheetDetailInfos) }
1413
+ this.data = { ...data }
1414
+
1415
+ if (!this._selectedOrderInventory) {
1416
+ this._selectedOrderInventory = data.records[0]
1417
+ } else {
1418
+ let currentData = data.records.find(record => record.name === this._selectedOrderInventory.name)
1419
+
1420
+ if (currentData.completed) {
1421
+ if (this.cartonInput) this.cartonInput.value = ''
1422
+ if (this.palletInput) this.palletInput.value = ''
1423
+ let nextData = data.records.filter(rec => !rec.completed)
1424
+ if (nextData.length > 0) {
1425
+ this._selectedOrderInventory = nextData[0]
1426
+ } else {
1427
+ this._selectedOrderInventory = null
1350
1428
  }
1351
- `,
1352
- variables: {
1353
- worksheetDetailName: this._selectedOrderInventory.name,
1354
- worksheetType: this.refPickingType,
1355
- productBarcode: this.productBarcodeInput.value.trim(),
1356
- cartonId: this.cartonInput.value.trim(),
1357
- serialNumber: this._isRequireSerialNumberScanningOutbound ? this.serialInput.value : null,
1358
- binLocation:
1359
- this._hasBinPicking && (!this.toteNo || this.tote == '') ? this.binLocationInput.value : null,
1360
- toteNo: this._enableToteScanning && this.toteNo !== '' ? this.toteNo : null,
1361
- pickingQty: this.releaseQtyInput?.value ? parseInt(this.releaseQtyInput.value) : 1
1362
1429
  }
1363
- })
1430
+ }
1364
1431
 
1365
- case PICKING_TYPES.BATCH_PICKING.value:
1366
- return await client.mutate({
1367
- mutation: gql`
1368
- mutation scanProductBatchPicking(
1369
- $taskNo: String!
1370
- $worksheetType: String!
1371
- $cartonId: String!
1372
- $inventory: InventoryPatch!
1373
- $productBarcode: String!
1374
- $binLocationName: String
1375
- $pickingQty: Int
1432
+ if (this._selectedOrderInventory) {
1433
+ const record = data.records.find(record => record.name === this._selectedOrderInventory.name)
1434
+ this._selectedOrderInventory = record
1435
+ this.updateSelectedItemProp(record)
1436
+ await this.updateComplete
1437
+ await this.grist.reset()
1438
+ this.fillUpForm(this.inputForm, {
1439
+ ...record,
1440
+ binLocation: record?.binLocation ? record.binLocation : ''
1441
+ })
1442
+
1443
+ if (record.pickedQty == record.releaseQty) {
1444
+ if (this.cartonInput) this.cartonInput.value = ''
1445
+ if (this.palletInput) this.palletInput.value = ''
1446
+ } else {
1447
+ // pre-set bin location from last scan if none was set
1448
+ if (
1449
+ this._hasBinPicking &&
1450
+ this.binLocationInput &&
1451
+ (!this._currentBinLocation || this._currentBinLocation == '')
1376
1452
  ) {
1377
- scanProductBatchPicking(
1378
- taskNo: $taskNo
1379
- worksheetType: $worksheetType
1380
- cartonId: $cartonId
1381
- inventory: $inventory
1382
- productBarcode: $productBarcode
1383
- binLocationName: $binLocationName
1384
- pickingQty: $pickingQty
1385
- )
1453
+ this._currentBinLocation = record?.binLocation ? record.binLocation : ''
1386
1454
  }
1387
- `,
1388
- variables: {
1389
- taskNo: this.taskNo,
1390
- worksheetType: this.refPickingType,
1391
- cartonId: this.cartonInput.value.trim(),
1392
- productBarcode: this.productBarcodeInput.value.trim(),
1393
- inventory: {
1394
- batchId: this._selectedOrderInventory.batchId,
1395
- packingType: this._selectedOrderInventory.packingType,
1396
- packingSize: this._selectedOrderInventory.packingSize,
1397
- product: { id: this._selectedOrderInventory.product.id }
1398
- },
1399
- binLocationName:
1400
- this._hasBinPicking && (!this.toteNo || this.tote == '') ? this.binLocationInput.value : null,
1401
- pickingQty: this.releaseQtyInput?.value ? parseInt(this.releaseQtyInput.value) : 1
1402
1455
  }
1403
- })
1404
- }
1405
- } catch (e) {
1406
- this._showToast(e)
1407
- } finally {
1408
- this._isExecuting = false
1409
- }
1410
- }
1411
1456
 
1412
- async validatePicking() {
1413
- // validate for order selection
1414
- // pallet id existing
1457
+ if (
1458
+ record.releaseQty - record.pickedQty == 1 &&
1459
+ !this._isCartonLabel &&
1460
+ this._isRequireSerialNumberScanningOutbound
1461
+ ) {
1462
+ this._isLastUnit = true
1463
+ } else {
1464
+ this._isLastUnit = false
1465
+ }
1466
+ }
1415
1467
 
1416
- if ((!this.palletInput?.value || !this.cartonInput?.value) && this._isRequireSerialNumberScanningOutbound) {
1417
- if (!this.serialInput?.value) {
1418
- this._focusOnSerialInput()
1419
- throw new Error(i18next.t('text.empty_serial_number'))
1420
- }
1421
- }
1468
+ if (
1469
+ this._selectedOrderInventory &&
1470
+ this._selectedOrderInventory.pickedQty != this._selectedOrderInventory.releaseQty &&
1471
+ !this._selectedOrderInventory?.hasMissingInventoryChanges &&
1472
+ this._selectedOrderInventory.status !== 'MISSING'
1473
+ ) {
1474
+ this.scannable = true
1475
+ } else {
1476
+ this.scannable = false
1477
+ }
1422
1478
 
1423
- if (!this._isCartonLabel) {
1424
- if (!this.palletInput.value) {
1425
- this._focusOnLotNoInput()
1426
- throw new Error(i18next.t('text.lot_id_is_empty'))
1427
- } else {
1428
- if (
1429
- this._selectedOrderInventory.palletId !== this.palletInput.value &&
1430
- !this._isRequireSerialNumberScanningOutbound
1431
- ) {
1432
- const isInProgressing = await this.checkProgressingPallet(this.palletInput.value)
1433
- if (isInProgressing) throw new Error(i18next.t('text.pallet_is_in_progressing'))
1479
+ if (data) {
1480
+ if (!this._isCartonLabel) {
1481
+ const findPalletId = worksheetDetailInfos.find(res => res.palletId == data.palletId)
1434
1482
 
1435
- this._isReplacement = await this.checkProductIdenticality(
1436
- this._selectedOrderInventory.palletId,
1437
- this.palletInput.value
1438
- )
1483
+ if (data && findPalletId?.hasMissingInventoryChanges) {
1484
+ this.scannable = false
1485
+ }
1486
+ } else {
1487
+ const findCartonId = worksheetDetailInfos.find(res => res.cartonId == data.cartonId)
1439
1488
 
1440
- if (!this._isReplacement) {
1441
- this._focusOnLotNoInput()
1442
- throw new Error(i18next.t('text.wrong_lot_id'))
1489
+ if (data && findCartonId?.hasMissingInventoryChanges) {
1490
+ this.scannable = false
1491
+ }
1492
+ }
1443
1493
  }
1444
1494
  }
1445
- }
1446
- } else {
1447
- if (!this.cartonInput?.value) {
1448
- this._focusOnCartonNoInput()
1449
- throw new Error(i18next.t('text.carton_id_is_empty'))
1450
- }
1451
-
1452
- if (this._selectedOrderInventory.cartonId) {
1453
- if (this._selectedOrderInventory.cartonId !== this.cartonInput.value) {
1454
- //carton replacement?
1455
- throw new Error(i18next.t('text.invalid_carton_id'))
1456
- this._isReplacement = await this.checkCartonIdenticality(
1457
- this._selectedOrderInventory.cartonId,
1458
- this._selectedOrderInventory.palletId,
1459
- this.cartonInput.value
1460
- )
1495
+ break
1461
1496
 
1462
- if (!this._isReplacement) {
1463
- this.cartonInput.value = ''
1464
- this._focusOnCartonNoInput()
1465
- throw new Error(i18next.t('text.wrong_carton_id'))
1466
- }
1467
- }
1497
+ case PICKING_TYPES.BATCH_PICKING.value:
1498
+ response = await client.query({
1499
+ query: gql`
1500
+ query batchPickingWorksheet($taskNo: String!, $locationSortingRules: [Sorting!]) {
1501
+ batchPickingWorksheet(taskNo: $taskNo, locationSortingRules: $locationSortingRules) {
1502
+ worksheetInfo {
1503
+ bizplaceName
1504
+ partnerDomainId
1505
+ startedAt
1506
+ }
1507
+ worksheetDetailInfos {
1508
+ hasMissingInventoryChanges
1509
+ palletId
1510
+ cartonId
1511
+ batchId
1512
+ product {
1513
+ id
1514
+ name
1515
+ description
1516
+ sku
1517
+ isRequireSerialNumberScanning
1518
+ }
1519
+ qty
1520
+ releaseQty
1521
+ pickedQty
1522
+ expirationDate
1523
+ status
1524
+ packingType
1525
+ packingSize
1526
+ location {
1527
+ name
1528
+ }
1529
+ binLocation {
1530
+ name
1531
+ }
1532
+ relatedOrderInv {
1533
+ batchId
1534
+ packingType
1535
+ product {
1536
+ id
1537
+ name
1538
+ description
1539
+ sku
1540
+ }
1541
+ }
1542
+ }
1543
+ }
1544
+ }
1545
+ `,
1546
+ variables: { taskNo: pickingRefNo, locationSortingRules: this.locationSortingRules }
1547
+ })
1468
1548
 
1469
- if (this._enableProductScanning) {
1470
- if (!this.productBarcodeInput?.value) {
1471
- this._focusOnProductBarcodeInput()
1472
- throw new Error(i18next.t('text.empty_product_barcode'))
1473
- }
1474
- }
1475
- }
1476
- }
1549
+ if (!response.errors) {
1550
+ if (!this._selectedOrderInventory) this.clearView()
1551
+ this.taskNo = pickingRefNo
1552
+ if (!response.data?.batchPickingWorksheet) return
1477
1553
 
1478
- if (!this._isReplacement) {
1479
- if (!this._isRequireSerialNumberScanningOutbound) {
1480
- if (this.releaseQtyInput) {
1481
- if (!parseInt(this.releaseQtyInput?.value)) {
1482
- this._focusOnReleaseQtyInput()
1483
- throw new Error(i18next.t('text.release_qty_is_empty'))
1484
- }
1554
+ const { worksheetInfo, worksheetDetailInfos } = response.data.batchPickingWorksheet
1555
+ await this.updateComplete
1556
+ this._bizplaceName = worksheetInfo.bizplaceName
1557
+ this._orderNo = this.taskNo
1558
+ this._worksheetInfo = worksheetInfo
1559
+ this.data = { records: this.formatWorksheetDetailInfos(worksheetDetailInfos) }
1485
1560
 
1486
- if (!this.releaseQtyInput?.checkValidity()) throw new Error(i18next.t('text.release_qty_invalid'))
1561
+ if (!this._selectedOrderInventory) {
1562
+ this._selectedOrderInventory = this.data.records[0]
1563
+ }
1487
1564
 
1488
- // typed qty should be matched with release qty.
1489
1565
  if (
1490
- parseInt(this.releaseQtyInput.value) !==
1491
- this._selectedOrderInventory.releaseQty -
1492
- (this._selectedOrderInventory.pickedQty ? this._selectedOrderInventory.pickedQty : 0) &&
1493
- !this._isCartonLabel
1566
+ this._selectedOrderInventory &&
1567
+ this._selectedOrderInventory.pickedQty != this._selectedOrderInventory.releaseQty &&
1568
+ !this._selectedOrderInventory?.hasMissingInventoryChanges &&
1569
+ this._selectedOrderInventory.status !== 'MISSING'
1494
1570
  ) {
1495
- this._focusOnReleaseQtyInput()
1496
- throw new Error(i18next.t('text.wrong_release_qty'))
1571
+ this.scannable = true
1572
+ } else {
1573
+ this.scannable = false
1497
1574
  }
1498
- }
1499
- }
1500
1575
 
1501
- if (!this._isCartonLabel) {
1502
- // location id existing
1503
- if (!this.isWholePicking && this.locationInput) {
1504
- if (!this.locationInput.value) {
1505
- this._focusOnLocationNameInput()
1506
- throw new Error(i18next.t('text.location_id_is_empty'))
1507
- }
1508
- // check if actual return location
1509
- this._locationName =
1510
- this.isWholePicking || !this.locationInput
1511
- ? this._selectedOrderInventory.location.name
1512
- : this.locationInput.value
1513
- // 1. Check whether location is changed
1514
- if (this._selectedOrderInventory.location.name !== this._locationName) {
1515
- this.locationNameSplit = this.locationInput.value.split('-')
1516
- if (this.locationNameSplit.length < 3) {
1517
- this._focusOnLocationNameInput()
1518
- throw new Error(i18next.t('text.invalid_return_location'))
1519
- }
1520
- const zonePortions = this.locationNameSplit[0].match(/[a-zA-Z0-9]+/g)
1521
- const rowPortions = this.locationNameSplit[1].match(/[a-zA-Z0-9]+/g)
1522
- const columnPortions = this.locationNameSplit[2].match(/[a-zA-Z0-9]+/g)
1523
- const shelfPortions = this.locationNameSplit[3].match(/[a-zA-Z0-9]+/g)
1524
- if (this.locationNameSplit.length === 3) {
1525
- this.locations = await this.fetchLocations(zonePortions[0], rowPortions[0], columnPortions[0])
1526
- this._focusOnNewLocationInput()
1576
+ if (!this._isCartonLabel && data) {
1577
+ const findPalletId = worksheetDetailInfos.find(res => res.palletId == data.palletId)
1527
1578
 
1528
- const selectedLocations = this.locations.find(res => {
1529
- return res.name === this._locationName
1530
- })
1579
+ if (data && findPalletId?.hasMissingInventoryChanges) {
1580
+ this.scannable = false
1581
+ }
1582
+ }
1531
1583
 
1532
- if (this._isReleaseGoodRecall) {
1533
- if (![selectedLocations.type].includes(LOCATION_TYPE.QUARANTINE.value, LOCATION_TYPE.RESERVE.value)) {
1534
- throw new Error(i18next.t('text.location_scanned_is_not_a_quarantine_zone_or_reserved_zone'))
1535
- }
1536
- }
1584
+ if (this._isCartonLabel && data) {
1585
+ const findCartonId = worksheetDetailInfos.find(res => res.cartonId == data.cartonId)
1537
1586
 
1538
- if (this.locations.length > 0) {
1539
- this._incompleteLocationName = true
1540
- throw new Error(i18next.t('text.please_select_the_location_again'))
1541
- } else {
1542
- throw new Error(i18next.t('text.invalid_return_location'))
1543
- }
1544
- } else if (this.locationNameSplit.length === 4) {
1545
- this.locations = await this.fetchLocations(
1546
- zonePortions[0],
1547
- rowPortions[0],
1548
- columnPortions[0],
1549
- shelfPortions[0]
1550
- )
1587
+ if (data && findCartonId?.hasMissingInventoryChanges) {
1588
+ this.scannable = false
1589
+ }
1590
+ }
1551
1591
 
1552
- const selectedLocations = this.locations.find(res => {
1553
- return res.name === this._locationName
1554
- })
1592
+ this._enableProductScanning = await fetchSettingRule('enable-product-scanning', worksheetInfo.partnerDomainId)
1593
+ this._enableInputQty = await fetchSettingRule('enable-input-qty', worksheetInfo.partnerDomainId)
1555
1594
 
1556
- if (this._isReleaseGoodRecall) {
1557
- if (![selectedLocations.type].includes(LOCATION_TYPE.QUARANTINE.value, LOCATION_TYPE.RESERVE.value)) {
1558
- throw new Error(i18next.t('text.location_scanned_is_not_a_quarantine_zone_or_reserved_zone'))
1559
- }
1560
- }
1595
+ if (this._selectedOrderInventory) {
1596
+ const record = this.data.records.find(
1597
+ record =>
1598
+ record.product.sku === this._selectedOrderInventory.product.sku &&
1599
+ record.palletId === this._selectedOrderInventory.palletId
1600
+ )
1561
1601
 
1562
- let relocateConfirmation = await CustomAlert({
1563
- title: i18next.t('title.relocate'),
1564
- text: i18next.t('text.are_you_sure'),
1565
- confirmButton: { text: i18next.t('button.relocate') },
1566
- cancelButton: { text: i18next.t('button.cancel') }
1567
- })
1602
+ this._selectedOrderInventory = record
1603
+ await this.updateSelectedItemProp(record)
1568
1604
 
1569
- if (!relocateConfirmation.isConfirmed) {
1570
- this._incompleteLocationName = false
1571
- this.locationNameSplit = []
1572
- return relocateConfirmation
1605
+ if (record.pickedQty == record.releaseQty) {
1606
+ if (this._isCartonLabel) {
1607
+ //need to relook into clearview logic
1608
+ if (this.cartonInput) this.cartonInput.value = ''
1609
+ if (this.productBarcodeInput) this.productBarcodeInput.value = ''
1573
1610
  }
1611
+ this.fillUpForm(this.inputForm, record)
1612
+ } else {
1613
+ this.fillUpForm(this.inputForm, record)
1574
1614
  }
1575
- }
1576
- }
1577
- }
1578
- }
1579
-
1580
- if (this._crossDocking) {
1581
- // typed qty should be smaller than release qty.
1582
- if (parseInt(this.releaseQtyInput.value) > this._selectedOrderInventory.releaseQty) {
1583
- this._focusOnReleaseQtyInput()
1584
- throw new Error(i18next.t('text.wrong_release_qty'))
1585
- }
1586
- }
1587
- }
1588
1615
 
1589
- async checkProgressingPallet(palletId) {
1590
- const response = await client.query({
1591
- query: gql`
1592
- query checkProgressingPallet($palletId: String!) {
1593
- checkProgressingPallet(palletId: $palletId)
1616
+ if (
1617
+ record.releaseQty - record.pickedQty == 1 &&
1618
+ !this._isCartonLabel &&
1619
+ this._isRequireSerialNumberScanningOutbound
1620
+ ) {
1621
+ this._isLastUnit = true
1622
+ } else {
1623
+ this._isLastUnit = false
1624
+ }
1625
+ }
1594
1626
  }
1595
- `,
1596
- variables: { palletId }
1597
- })
1598
-
1599
- if (!response.errors) {
1600
- return response.data.checkProgressingPallet
1627
+ break
1601
1628
  }
1602
- }
1603
-
1604
- async checkProductIdenticality(palletA, palletB) {
1605
- const response = await client.query({
1606
- query: gql`
1607
- query checkProductIdenticality($palletA: String!, $palletB: String!) {
1608
- checkProductIdenticality(palletA: $palletA, palletB: $palletB)
1609
- }
1610
- `,
1611
- variables: { palletA, palletB }
1612
- })
1613
1629
 
1614
- if (!response.errors) {
1615
- return response.data.checkProductIdenticality
1616
- }
1630
+ this.updateContext()
1617
1631
  }
1618
1632
 
1619
- async checkCartonIdenticality(cartonA, palletA, cartonB) {
1633
+ async fetchPalletsHandler(releaseGoodNo) {
1620
1634
  const response = await client.query({
1621
1635
  query: gql`
1622
- query checkCartonIdenticality($cartonA: String!, $palletA: String!, $cartonB: String!) {
1623
- checkCartonIdenticality(cartonA: $cartonA, palletA: $palletA, cartonB: $cartonB)
1624
- }
1625
- `,
1626
- variables: { cartonA, palletA, cartonB }
1627
- })
1628
-
1629
- if (!response.errors) {
1630
- return response.data.checkCartonIdenticality
1631
- }
1632
- }
1633
-
1634
- async fetchLocations(zone, row, column) {
1635
- const sortings = [{ name: 'name', desc: false }]
1636
- const filters = [
1637
- { name: 'zone', operator: 'eq', value: zone },
1638
- { name: 'row', operator: 'eq', value: row },
1639
- { name: 'column', operator: 'eq', value: column }
1640
- ]
1641
-
1642
- if (filters) {
1643
- const response = await client.query({
1644
- query: gql`
1645
- query locations($filters: [Filter!], $sortings: [Sorting!]) {
1646
- locations(filters: $filters, sortings: $sortings) {
1647
- items {
1636
+ query pallets($filters: [Filter!]!, $pagination: Pagination) {
1637
+ pallets(filters: $filters, pagination: $pagination) {
1638
+ items {
1639
+ id
1640
+ name
1641
+ owner {
1648
1642
  id
1649
1643
  name
1650
- zone
1651
- row
1652
- column
1653
- shelf
1654
- status
1655
- type
1644
+ description
1645
+ }
1646
+ holder {
1647
+ id
1648
+ name
1649
+ description
1656
1650
  }
1651
+ status
1657
1652
  }
1658
1653
  }
1659
- `,
1660
- variables: { filters, sortings }
1661
- })
1662
-
1663
- if (!response.errors) {
1664
- return response.data.locations.items || []
1654
+ }
1655
+ `,
1656
+ variables: {
1657
+ filters: [{ name: 'refOrderNo', value: releaseGoodNo, operator: 'eq' }],
1658
+ pagination: { page: 1, limit: 9999999 }
1665
1659
  }
1660
+ })
1661
+
1662
+ if (!response.errors) {
1663
+ this._reusablePalletList = { records: response.data.pallets.items }
1666
1664
  }
1667
1665
  }
1668
1666
 
@@ -1897,7 +1895,7 @@ class PickingProduct extends connect(store)(localize(i18next)(PageView)) {
1897
1895
  }
1898
1896
  }
1899
1897
  } catch (e) {
1900
- this._showToast(e)
1898
+ showToast(e)
1901
1899
  }
1902
1900
  }
1903
1901
 
@@ -1969,17 +1967,6 @@ class PickingProduct extends connect(store)(localize(i18next)(PageView)) {
1969
1967
  this._isCartonLabel = selectedRecords.hasCartonLabel
1970
1968
  this._isRequireSerialNumberScanningOutbound = selectedRecords?.product?.isRequireSerialNumberScanningOutbound
1971
1969
  }
1972
-
1973
- _showToast({ type, message }) {
1974
- document.dispatchEvent(
1975
- new CustomEvent('notify', {
1976
- detail: {
1977
- type,
1978
- message
1979
- }
1980
- })
1981
- )
1982
- }
1983
1970
  }
1984
1971
 
1985
1972
  window.customElements.define('picking-product', PickingProduct)