@things-factory/operato-wms 4.3.82 → 4.3.87

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