Procházet zdrojové kódy

工序齐套修改;零星出库修改

hh před 2 měsíci
rodič
revize
42114f8e61

+ 176 - 18
entry/src/main/ets/pages/LittleMaterialOutBound.ets

@@ -25,12 +25,13 @@ import { ConfirmDialogParams, RgvInfo } from '../params/RobotsParam';
 import promptAction from '@ohos.promptAction';
 import VehicleInfo from '../viewmodel/wms/VehicleInfo';
 import MaterialInfo from '../viewmodel/wms/MaterialInfo';
+import { InfoRow } from '../component/RgvControlView';
 
 @Entry
 @Component
 struct LittleMaterialsOutBound {
-  // 输入的物料编码
-  @State inputCode: string = ''
+  // 输入的物料名称
+  @State inputValue: string = ''
   // 查询到的物料库存列表
   @State materialArray: MaterialBoxInfo[] = []
   // 选中的库存的物料编码
@@ -51,31 +52,73 @@ struct LittleMaterialsOutBound {
   outMaterialBoxInfos: MaterialInfo[] = []
   // 扫码待出库的物料
   @State scanMaterialList: MaterialInfo[] = []
+  //扫码后自动滚动第一行
+  @State scanCodeIndex: number = -1
+  materialScrollerController: Scroller = new Scroller()
 
   @State currentStep: number = 1;
   @State nextStepButtonClick: number = 1
   @State preStepButtonClick: number = 1
   @State outBoundButtonClick :number = 1
+  @State confirmOutboundButtonClick :number = 1
 
   // 根据物料编码【模糊】查询库存
-  getStoreList = async () => {
-    let res: MaterialBoxInfo[] = await WmsRequest.post('/api/v1/stock/mergeList', {
+  getStoreListFunc = async () => {
+    let res: MaterialBoxInfo[] = await WmsRequest.post('/api/v1/stock/list', {
       houseType: '1',
-      materialNo: this.inputCode
+      materialNo: this.inputValue
     } as RequestParamModel)
-    this.inputCode = ''
+    this.inputValue = ''
     if (res && res.length > 0) {
       this.materialArray = res
     }
   }
-
   //请求物料位置
-  queryMaterialPosition = async () => {
+  queryMaterialPositionFunc = async () => {
     this.materialBoxInfos = await WmsRequest.post('/api/v1/stock/groupList', {
       materialNo: this.selectMaterialCode
     } as RequestParamModel)
   }
+  // 扫码物料编码方法
+  scanMaterialCodeFunc = async (itemCode: string) => {
+    this.scanCode = ''
+    let res: MaterialInfo = await WmsRequest.post('/api/v1/process/circulation/material', {
+      label: itemCode //'#gys022#sc022#100#20220929#31'
+    } as RequestParamModel)
 
+    // 物料默认都新增在数组头部
+    this.scanMaterialList.unshift(res)
+    this.scanCodeIndex = 0
+    this.materialScrollerController.scrollToIndex(this.scanCodeIndex)
+    // 出库料箱中的库存物料 需要做出库操作
+    let toChangeArray: MaterialInfo[] = [...this.outMaterialBoxInfos]
+    for (let i = 0; i < toChangeArray.length; i++) {
+      let box = toChangeArray[i]
+      if (res.materialCode == box.materialCode) {
+        let value = box.num! - res.num!
+        box.num = value >= 0 ? value : 0
+        continue
+      }
+    }
+    this.outMaterialBoxInfos = toChangeArray.filter((m) => {
+      return m.num! > 0
+    })
+    // for (let i = this.outMaterialBoxInfos.length - 1; i >= 0; i--) {
+    //   if (this.outMaterialBoxInfos[i].materialCode! === res.materialCode!) {
+    //     if (this.outMaterialBoxInfos[i].num! > res.num!) {
+    //       this.outMaterialBoxInfos[i].num = this.outMaterialBoxInfos[i].num! - res.num!
+    //       break
+    //     } else if (this.outMaterialBoxInfos[i].num! === res.num!) {
+    //       this.outMaterialBoxInfos.splice(i, 1)
+    //       break
+    //     } else {
+    //       res.num = res.num! - this.outMaterialBoxInfos[i].num!
+    //       this.outMaterialBoxInfos.splice(i, 1);
+    //     }
+    //   }
+    // }
+    this.materialNum = this.outMaterialBoxInfos.length
+  }
   // 抽屉称重(根据重量判断抽屉是否有料箱)
   @StorageLink('materialBoxWeight') materialBoxWeight: number = 0
   // 抽屉状态
@@ -106,7 +149,7 @@ struct LittleMaterialsOutBound {
       }),
       cancel: () => console.log('用户取消操作'),
       customStyle: true,
-      autoCancel:false,
+      autoCancel: false,
       maskColor: 'rgba(0,0,0,0.6)'
     });
     this.commonDialogController.open();
@@ -125,9 +168,9 @@ struct LittleMaterialsOutBound {
   }
 
   // 料箱出库的方法
-  callBoxOutboundFun = async () => {
+  callBoxOutboundFunc = async () => {
     if (this.selectVehicleIndex < 0) {
-      this.reminds = "请选择料箱"
+      this.reminds = "请选择料箱"
       this.remindController.open()
       setTimeout(() => {
         this.remindController.close()
@@ -272,10 +315,10 @@ struct LittleMaterialsOutBound {
               .width('100%')
               .justifyContent(FlexAlign.Center)
               .onClick(()=>{
-                this.getStoreList()
+                this.getStoreListFunc()
               })
               Row() {
-                TextInput({ text: this.inputCode, placeholder: '录入物料名称' })
+                TextInput({ text: this.inputValue, placeholder: '录入物料名称' })
                   .type(InputType.Normal)
                   .width('84%')
                   .placeholderFont({ size: $r('app.float.fontSize_16') })
@@ -283,10 +326,10 @@ struct LittleMaterialsOutBound {
                   .fontSize($r('app.float.fontSize_24'))
                   .fontColor($r('app.color.FFFFFF'))
                   .onSubmit(() => {
-                    this.getStoreList()
+                    this.getStoreListFunc()
                   })
                   .onChange((value: string) => {
-                    this.inputCode = value
+                    this.inputValue = value
                   })
                 Row() {
                   Image($r('app.media.wms_search'))
@@ -347,7 +390,7 @@ struct LittleMaterialsOutBound {
                     .onClick(()=>{
                       this.selectMaterialCode = item.materialNo!
                       if (this.selectMaterialCode && this.selectMaterialCode.length > 0) {
-                        this.queryMaterialPosition()
+                        this.queryMaterialPositionFunc()
                       }
                     })
                   }
@@ -504,7 +547,7 @@ struct LittleMaterialsOutBound {
                         this.scanCode = value
                       })
                       .onSubmit(async () => {
-
+                        this.scanMaterialCodeFunc(this.scanCode)
                       })
                   }
                   .height('48.7%')
@@ -521,6 +564,121 @@ struct LittleMaterialsOutBound {
               .width('100%')
               .justifyContent(FlexAlign.Center)
               .alignItems(VerticalAlign.Top)
+              // 扫码物料列表
+              List({ scroller: this.materialScrollerController }) {
+                ForEach(this.scanMaterialList, (item: MaterialInfo, index: number) => {
+                  ListItem() {
+                    Row() {
+                      Column({space: 1}) {
+                        Text(item.materialName! + '-' + item.materialCode!)
+                          .fontSize($r('app.float.fontSize_24'))
+                          .fontWeight(FontWeight.Medium)
+                          .fontColor($r('app.color.FFFFFF'))
+                          .maxLines(1)
+                        Column() {
+                          Text('型号:' + item.spec!)
+                            .fontSize($r('app.float.fontSize_16'))
+                            .fontWeight(FontWeight.Lighter)
+                            .fontColor($r('app.color.FFFFFF'))
+                            .maxLines(1)
+                          Text('序列号:' + item.batchCode!)
+                            .fontSize($r('app.float.fontSize_16'))
+                            .fontWeight(FontWeight.Lighter)
+                            .fontColor($r('app.color.FFFFFF'))
+                            .maxLines(1)
+                          Text('所属订单:-')
+                            .fontSize($r('app.float.fontSize_16'))
+                            .fontWeight(FontWeight.Lighter)
+                            .fontColor($r('app.color.FFFFFF'))
+                            .maxLines(1)
+                          Text('数量:' + item.num!)
+                            .fontSize($r('app.float.fontSize_16'))
+                            .fontWeight(FontWeight.Lighter)
+                            .fontColor($r('app.color.FFFFFF'))
+                            .maxLines(1)
+                        }
+                        .height('52.8%')
+                        .width('100%')
+                        .justifyContent(FlexAlign.SpaceBetween)
+                        .alignItems(HorizontalAlign.Start)
+                      }
+                      .height('100%')
+                      .width('48%')
+                      .alignItems(HorizontalAlign.Start)
+                      .justifyContent(FlexAlign.Center)
+
+                      Row() {
+                        Image($r('app.media.material_delete'))
+                          .height($r('app.float.virtualSize_48'))
+                          .width($r('app.float.virtualSize_48'))
+                          .fillColor($r('app.color.FF453A'))
+                          .onClick(()=>{
+                            // 出库料箱中的物料需要加回去
+                            let toChangeArray: MaterialInfo[] = [...this.outMaterialBoxInfos]
+                            let hasFlag: boolean = false
+                            // 出库料箱中还有,则把数量加回去
+                            for (let i = 0; i < toChangeArray.length; i++) {
+                              let box = toChangeArray[i]
+                              if (item.materialCode == box.materialCode) {
+                                let value = box.num! + item.num!
+                                box.num = value >= 0 ? value : 0
+                                hasFlag = true
+                                continue
+                              }
+                            }
+                            // 出库料箱中没有,则把这一项加进去
+                            if (!hasFlag) {
+                              this.outMaterialBoxInfos.push(item)
+                            }
+                            // 扫码待出库的物料删除这一项
+                            this.scanMaterialList.splice(index, 1)
+                          })
+                        Row().width('2%')
+                      }
+                      .height('100%')
+                      .width('50%')
+                      .alignItems(VerticalAlign.Center)
+                      .justifyContent(FlexAlign.End)
+                    }
+                    .height('26%')
+                    .width('100%')
+                    .justifyContent(FlexAlign.Center)
+                    .borderRadius($r('app.float.virtualSize_16'))
+                    .backgroundColor($r('app.color.10FFFFFF'))
+                  }
+                })
+              }
+              .width('96.6%')
+              .height('72.5%')
+              .alignListItem(ListItemAlign.Center)
+              // 确认出库按钮
+              Row() {
+                Button('确认出库')
+                  .fontSize($r('app.float.fontSize_24'))
+                  .fontColor($r('app.color.0A84FF'))
+                  .width('42.4%')
+                  .height('56.3%')
+                  .backgroundColor($r('app.color.20FFFFFF'))
+                  .opacity(this.scanMaterialList.length > 0 ? 1 : 0.3)
+                  .scale({ x: this.confirmOutboundButtonClick, y: this.confirmOutboundButtonClick })
+                  .animation({
+                    duration: 200,
+                    curve: Curve.Linear  // 弹性曲线更生动
+                  })
+                  .onClick(() => {
+                    if (this.scanMaterialList.length <= 0) {
+                      return
+                    }
+                    this.confirmOutboundButtonClick = 0.9; // 点击时缩小
+                    setTimeout(() => {
+                      this.confirmOutboundButtonClick = 1; // 0.2秒后恢复
+                    }, 200);
+                    this.scanMaterialList = []
+                  })
+              }
+              .width('100%')
+              .height('12.5%')
+              .justifyContent(FlexAlign.Center)
             }
             .height('100%')
             .width('64.8%')
@@ -602,7 +760,7 @@ struct LittleMaterialsOutBound {
             setTimeout(() => {
               this.outBoundButtonClick = 1; // 0.2秒后恢复
             }, 200);
-            this.callBoxOutboundFun()
+            this.callBoxOutboundFunc()
           })
 
           Row().width('1.2%')

+ 29 - 16
entry/src/main/ets/pages/OperationMaterialKit.ets

@@ -24,7 +24,6 @@ import MaterialInfo from '../viewmodel/wms/MaterialInfo'
 @Entry
 @Component
 struct OperationMaterialKit {
-
   @State step: number = 1
   // 选中的工单
   @State workOrder: WorkOrderInfo = {}
@@ -32,12 +31,16 @@ struct OperationMaterialKit {
   @State selectOperations: OperationInfo[] = []
   // 选中工序需求的物料
   @State operationItems: OperationItem[] = []
-  // 出库料箱中的库存物料信息
-  @State outMaterialBoxInfos: MaterialInfo[] = []
+  // 当前的料箱编码
+  @Provide('currentVehicleCode') currentVehicleCode: string = ''
+  // 扫码添加的物料数组(齐套料箱)
+  @State scanMaterialArray: MaterialInfo[] = []
   // 抽屉称重(根据重量判断抽屉是否有料箱)
   @StorageLink('materialBoxWeight') materialBoxWeight: number = 0
   // 抽屉状态
   @StorageLink('drawerPositionStatus') drawerPositionStatus: number = 1
+  // RFID读到的物料编码
+  @StorageLink('materialBoxID') rfidVehicleCode: string = ''
   @State reminds: string = '1'
   commonDialogController: CustomDialogController | null = null;
 
@@ -84,20 +87,21 @@ struct OperationMaterialKit {
 
   // 空箱出库的方法
   callEmptyBoxFun = async () => {
+    // todo 拣选工作台上没有料箱才能叫空箱
     //查询小车的状态
     const rgvStatusNormal = await this.queryRgvInfo()
     if(!rgvStatusNormal){
-      this.reminds = "小车状态异常或位置错误,请检查后重试"
+      this.reminds = '小车状态异常或位置错误,请检查后重试'
       this.remindController.open()
       setTimeout(() => {
         this.remindController.close()
       }, 2000);
       return
     }
-    console.info("ssss"+this.drawerPositionStatus+"as")
+    console.info('ssss'+this.drawerPositionStatus+'as')
     if(this.drawerPositionStatus == 0)
     {
-      this.reminds = "抽屉未缩回,请检查后重试"
+      this.reminds = '抽屉未缩回,请检查后重试'
       this.remindController.open()
       setTimeout(() => {
         this.remindController.close()
@@ -105,9 +109,8 @@ struct OperationMaterialKit {
       return
     }
 
-    if(this.materialBoxWeight > 0)
-    {
-      this.reminds = "抽屉已有料箱,请检查后重试"
+    if(this.materialBoxWeight > 0) {
+      this.reminds = '抽屉已有料箱,请检查后重试'
       this.remindController.open()
       setTimeout(() => {
         this.remindController.close()
@@ -125,14 +128,14 @@ struct OperationMaterialKit {
     // });
 
     let res: VehicleInfo = await WmsRequest.post('/api/v1/stock/queryEmptyBox')
-    console.log("hhtest", JSON.stringify(res), res?.vehicleNo)
+    console.log('hhtest', JSON.stringify(res), res?.vehicleNo)
     await WmsRequest.post('/api/v1/wmsOrder/outBox', {
       stanCode: CommonConstants.STATION_CODE,
       vehicleNo: res!.vehicleNo,
       houseNo: res!.houseNo
     } as RequestParamModel)
     promptAction.showToast({
-      message: "箱子正在运行中....",
+      message: '箱子正在运行中....',
       duration: 1800,
       bottom: '50%'
     })
@@ -174,9 +177,9 @@ struct OperationMaterialKit {
         Row() {
           ProcessFlow({
             currentStep: this.step,
-            firstStepTitle: "选择工单",
-            secondStepTitle: "齐套装箱",
-            thirdStepTitle: "齐套入库",
+            firstStepTitle: '选择工单',
+            secondStepTitle: '齐套装箱',
+            thirdStepTitle: '齐套入库',
           })
         }
         .height('80%')
@@ -204,14 +207,14 @@ struct OperationMaterialKit {
             workOrder: this.workOrder,
             selectOperations: this.selectOperations,
             operationItems: this.operationItems,
-            outMaterialBoxInfos: this.outMaterialBoxInfos,
+            scanMaterialArray: this.scanMaterialArray,
           })
         } else {
           OperationMaterialKitThreeStep({
             workOrder: this.workOrder,
             selectOperations: this.selectOperations,
             operationItems: this.operationItems,
-            outMaterialBoxInfos: this.outMaterialBoxInfos,
+            scanMaterialArray: this.scanMaterialArray,
           })
         }
       }
@@ -282,6 +285,16 @@ struct OperationMaterialKit {
         .borderRadius($r('app.float.fontSize_16'))
         .opacity(this.step < 3 ? 1 : 0.3)
         .onClick(()=>{
+          if (this.step === 2) {
+            if (this.currentVehicleCode.length > 0 && this.currentVehicleCode === this.rfidVehicleCode) {
+              this.reminds = '请先对出库料箱做回库操作'
+              this.remindController.open()
+              setTimeout(() => {
+                this.remindController.close()
+              }, 2000);
+              return
+            }
+          }
           if (this.step < 3) {
             this.step += 1
           }

+ 47 - 37
entry/src/main/ets/view/wms/OperationMaterialKitOneStep.ets

@@ -11,17 +11,20 @@ import DictInfo from '../../viewmodel/DictInfo'
 
 @Component
 export struct OperationMaterialKitOneStep {
-
+  // 选择的工单
   @Link workOrder: WorkOrderInfo
+  // 选中的工序数组
   @Link selectOperations: OperationInfo[]
+  // 选中工序需要的物料
   @Link operationItems: OperationItem[]
   
   @State workOrderArray: WorkOrderInfo[] = []
-  @State operationArray: StationOperationInfo[] = []
+  @State stationOperations: StationOperationInfo[] = []
   @State operationMaterialArray: OperationMaterial[] = []
 
   @State selectWorkOrder: number = 0
   @State selectOperationIds: string[] = []
+  selectStationSortId: number = 0
 
   fixed38px: number = 22.8
   fixed52px: number = 31.2
@@ -29,6 +32,31 @@ export struct OperationMaterialKitOneStep {
 
   stationTypeDictType: string = 'station_type'
   stationTypeDictMap: HashMap<string, string> = new HashMap<string, string>()
+  // 选中工序方法
+  selectOperationFunc = async (operation: OperationInfo)=>{
+    if (this.selectOperationIds.length > 0 && this.selectStationSortId != operation.stationSortId) {
+      this.selectOperationIds = []
+      this.selectOperations = []
+      this.selectStationSortId = operation.stationSortId!
+    }
+    if (this.selectOperationIds.includes(operation.id!)) {
+      this.selectOperationIds.splice(this.selectOperationIds.indexOf(operation.id!), 1)
+      this.selectOperations.splice(this.selectOperations.indexOf(operation), 1)
+    } else {
+      this.selectOperationIds.push(operation.id!)
+      this.selectOperations.push(operation)
+    }
+    this.operationMaterialArray = await WmsRequest.post('/api/v1/wms/operationMaterial/list', {
+      //查询工序需求的物料
+      operationIds: this.selectOperationIds,
+    } as RequestParamModel) as OperationMaterial[]
+    this.operationItems = []
+    if (this.operationMaterialArray) {
+      for (const element of this.operationMaterialArray) {
+        this.operationItems = this.operationItems.concat(element.itemList!);
+      }
+    }
+  }
 
   async aboutToAppear() {
     this.workOrderArray = await WmsRequest.post('/api/v1/wms/workOrder/list', {
@@ -38,7 +66,7 @@ export struct OperationMaterialKitOneStep {
     if (this.workOrderArray && this.workOrderArray.length > 0) {
       this.workOrder = this.workOrderArray[0]
       this.selectWorkOrder = 0
-      this.operationArray = await WmsRequest.post('/api/v1/wms/operation/list', {
+      this.stationOperations = await WmsRequest.post('/api/v1/wms/operation/list', {
         //查询未完成的工单
         processRouteId: this.workOrderArray[0]?.processRouteId,
       } as RequestParamModel) as StationOperationInfo[]
@@ -127,10 +155,19 @@ export struct OperationMaterialKitOneStep {
                 if (this.selectWorkOrder === index) {
                   return
                 }
-                this.operationArray = await WmsRequest.post('/api/v1/wms/operation/list', {
+                this.stationOperations = await WmsRequest.post('/api/v1/wms/operation/list', {
                   //查询未完成的工单
                   processRouteId: this.workOrderArray[index]?.processRouteId,
                 } as RequestParamModel) as StationOperationInfo[]
+                if (this.stationOperations) {
+                  for (const station of this.stationOperations) {
+                    if (station.operationList) {
+                      for (const operation of station.operationList) {
+                        operation.stationSortId = station.sortId!
+                      }
+                    }
+                  }
+                }
                 this.selectWorkOrder = index
                 this.workOrder = this.workOrderArray[this.selectWorkOrder]
               })
@@ -160,9 +197,9 @@ export struct OperationMaterialKitOneStep {
         .height('10%')
         .width('100%')
         .justifyContent(FlexAlign.Center)
-
+        // 工序列表
         List() {
-          ForEach(this.operationArray, (item: StationOperationInfo, index: number) => {
+          ForEach(this.stationOperations, (item: StationOperationInfo, index: number) => {
             ListItem() {
               Column() {
                 Row() {
@@ -178,7 +215,7 @@ export struct OperationMaterialKitOneStep {
                   .justifyContent(FlexAlign.Start)
 
                   Column() {
-                    ForEach(item.operationVO, (operation: OperationInfo, index: number) => {
+                    ForEach(item.operationList, (operation: OperationInfo, index: number) => {
                       Column() {
                         Row().height(6)
                         Row({space: 5}) {
@@ -190,8 +227,7 @@ export struct OperationMaterialKitOneStep {
                             .onChange(async (value: boolean) => {
                               if (value) {
                                 if (!this.selectOperationIds.includes(operation.id)) {
-                                  this.selectOperationIds.push(operation.id)
-                                  this.selectOperations.push(operation)
+                                  this.selectOperationFunc(operation)
                                 }
                               } else {
                                 if (this.selectOperationIds.includes(operation.id)) {
@@ -199,16 +235,6 @@ export struct OperationMaterialKitOneStep {
                                   this.selectOperations.splice(this.selectOperations.indexOf(operation), 1)
                                 }
                               }
-                              this.operationMaterialArray = await WmsRequest.post('/api/v1/wms/operationMaterial/list', {
-                                //查询工序需求的物料
-                                operationIds: this.selectOperationIds,
-                              } as RequestParamModel) as OperationMaterial[]
-                              this.operationItems = []
-                              if (this.operationMaterialArray) {
-                                for (const element of this.operationMaterialArray) {
-                                  this.operationItems = this.operationItems.concat(element.itemList);
-                                }
-                              }
                             })
                           Text(operation.operationName ? operation.operationName : '')
                             .fontSize($r('app.float.fontSize_24'))
@@ -223,23 +249,7 @@ export struct OperationMaterialKitOneStep {
                         .borderColor(this.selectOperationIds.indexOf(operation.id) > -1 ? $r('app.color.30D158') : $r('app.color.20FFFFFF'))
                         .borderRadius($r('app.float.virtualSize_16'))
                         .onClick(async ()=>{
-                          if (this.selectOperationIds.includes(operation.id)) {
-                            this.selectOperationIds.splice(this.selectOperationIds.indexOf(operation.id), 1)
-                            this.selectOperations.splice(this.selectOperations.indexOf(operation), 1)
-                          } else {
-                            this.selectOperationIds.push(operation.id)
-                            this.selectOperations.push(operation)
-                          }
-                          this.operationMaterialArray = await WmsRequest.post('/api/v1/wms/operationMaterial/list', {
-                            //查询工序需求的物料
-                            operationIds: this.selectOperationIds,
-                          } as RequestParamModel) as OperationMaterial[]
-                          this.operationItems = []
-                          if (this.operationMaterialArray) {
-                            for (const element of this.operationMaterialArray) {
-                              this.operationItems = this.operationItems.concat(element.itemList);
-                            }
-                          }
+                          this.selectOperationFunc(operation)
                         })
                         Row().height(6)
                       }
@@ -255,7 +265,7 @@ export struct OperationMaterialKitOneStep {
                   .width('100%')
               }
               .width('92.6%')
-              .height(item.operationVO?.length! * this.fixed100px)
+              .height(item.operationList?.length! * this.fixed100px)
             }
           })
         }

+ 6 - 6
entry/src/main/ets/view/wms/OperationMaterialKitThreeStep.ets

@@ -7,17 +7,17 @@ import MaterialInfo from '../../viewmodel/wms/MaterialInfo'
 
 @Component
 export struct OperationMaterialKitThreeStep {
-
   @Link workOrder: WorkOrderInfo
   @Link selectOperations: OperationInfo[]
   @Link operationItems: OperationItem[]
-  // 出库料箱中的库存物料信息
-  @Link outMaterialBoxInfos: MaterialInfo[]
+  @Link scanMaterialArray: MaterialInfo[]
+
   @State materialNum: number = 0
-  @State scanMaterialList: MaterialBoxInfo[] = []
+  @State materialList: MaterialInfo[] = []
 
   aboutToAppear(): void {
-    this.materialNum = this.outMaterialBoxInfos.length
+    this.materialNum = this.scanMaterialArray.length
+    this.materialList = this.scanMaterialArray
   }
 
   build() {
@@ -26,7 +26,7 @@ export struct OperationMaterialKitThreeStep {
       Column() {
         InBoundView({
           materialNum: this.materialNum,
-          boxMaterials: this.scanMaterialList
+          boxMaterials: this.materialList
         });
       }
       .height('100%')

+ 60 - 18
entry/src/main/ets/view/wms/OperationMaterialKitTwoStep.ets

@@ -19,48 +19,51 @@ export struct OperationMaterialKitTwoStep {
   @Link workOrder: WorkOrderInfo
   @Link selectOperations: OperationInfo[]
   @Link operationItems: OperationItem[]
+  @Link scanMaterialArray: MaterialInfo[]
+  // 选择已有料箱,出库料箱
+  @Consume('currentVehicleCode') currentVehicleCode: string
+
   // 出库料箱中的库存物料信息
-  @Link outMaterialBoxInfos: MaterialInfo[]
+  @State outMaterialBoxInfos: MaterialInfo[] = []
+  // 出库料箱中物料数量(出入口料口使用)
+  @State materialNum: number = 0
   @State scanMaterialList: MaterialInfo[] = []
   selectOperationIds: string[] = []
   // 每个工序需要的物料编码分组
   operationItemCodes: HashMap<string, string[]> = new HashMap<string, string[]>()
   @State operationNames: string = ''
-  // 选择已有料箱,出库料箱
-  @State selectVehicleCode: string = ''
   @State materialBoxInfos: MaterialBoxInfo[] = []
-  @State materialNum: number = 0
   // 空箱编码
   @State vehicleCode: string = ''
-  @State materialTotal: number = 0
   // 扫描或手动输入的物料编码
   @State scanCode: string = ''
   // 物料全数组(本次扫描物料弹窗中展示)
   @State materialArray: MaterialInfo[] = []
   // 数量合并的物料数组(在拣选工作台展示)
   @State materialMergeArray: MaterialInfo[] = []
-  //齐套料箱扫码后如果物料存在则自动滚动所在
+  //齐套料箱扫码后如果物料存在则自动滚动所在
   @State scanCodeIndex: number = -1
+  // 绑定物料数量
+  @State bindMaterialNum: number = 0
   materialScrollerController: Scroller = new Scroller()
 
   // 选择料箱弹窗控制器
   selectMaterialBoxDialogController: CustomDialogController = new CustomDialogController({
     builder: SelectMaterialBoxDialog({
       MaterialBoxInfos: this.materialBoxInfos,
-      selectVehicleCode: this.selectVehicleCode,
       confirm: async () => {
-        if (!this.selectVehicleCode || !this.materialBoxInfos || this.materialBoxInfos.length <= 0) {
+        if (!this.currentVehicleCode || !this.materialBoxInfos || this.materialBoxInfos.length <= 0) {
           return
         }
         let houseNo = ''
         for (const element of this.materialBoxInfos) {
-          if (this.selectVehicleCode === element.vehicleCode) {
+          if (this.currentVehicleCode === element.vehicleCode) {
             houseNo = element.houseNo!
           }
         }
         let res: VehicleInfo = await WmsRequest.post('/api/v1/wmsOrder/outBox', {
           houseNo: houseNo,
-          vehicleNo:this.selectVehicleCode,
+          vehicleNo:this.currentVehicleCode,
         } as RequestParamModel)
         if (res && res.list) {
           this.outMaterialBoxInfos = res.list
@@ -76,6 +79,8 @@ export struct OperationMaterialKitTwoStep {
     builder: ThisScanDialog({
       materialMergeArray: this.materialMergeArray,
       materialArray: this.materialArray,
+      outMaterialBoxInfos: this.outMaterialBoxInfos,
+      materialNum: this.materialNum,
       confirm: async () => {}
     }),
     autoCancel: true, // 点击遮罩关闭
@@ -122,9 +127,20 @@ export struct OperationMaterialKitTwoStep {
     // 物料全数组默认都新增在数组头部
     this.materialArray.unshift(res)
     this.materialScrollerController.scrollToIndex(this.scanCodeIndex)
-    for (const element of this.outMaterialBoxInfos) {
-
+    // 出库料箱中的库存物料 需要做出库操作
+    let toChangeArray: MaterialInfo[] = [...this.outMaterialBoxInfos]
+    for (let i = 0; i < toChangeArray.length; i++) {
+      let box = toChangeArray[i]
+      if (res.materialCode == box.materialCode) {
+        let value = box.num! - res.num!
+        box.num = value >= 0 ? value : 0
+        continue
+      }
     }
+    this.outMaterialBoxInfos = toChangeArray.filter((m) => {
+      return m.num! > 0
+    })
+    this.materialNum = this.outMaterialBoxInfos.length
   }
 
   // 齐套绑定
@@ -166,6 +182,10 @@ export struct OperationMaterialKitTwoStep {
         this.operationItems = this.operationItems.concat(element.itemList!);
       }
     }
+    this.bindMaterialNum += this.materialMergeArray.length
+    this.scanMaterialArray.concat(this.materialMergeArray)
+    this.materialArray = []
+    this.materialMergeArray = []
   }
 
   async aboutToAppear() {
@@ -175,6 +195,7 @@ export struct OperationMaterialKitTwoStep {
         if (b.operationSort === null) return -1;
         return a.operationSort! - b.operationSort!;
       })
+      // 拼接工序名称
       for (let i = 0; i < this.selectOperations.length; i++) {
         this.operationNames += this.selectOperations[i].operationName
         if (i < this.selectOperations.length - 1) {
@@ -332,7 +353,7 @@ export struct OperationMaterialKitTwoStep {
               .objectFit(ImageFit.Fill)
             Column() {
               Row() {
-                Text('物料:' + this.materialTotal)
+                Text('物料:' + this.bindMaterialNum)
                   .fontSize($r('app.float.fontSize_24'))
                   .fontColor($r('app.color.0A84FF'))
                   .fontWeight(FontWeight.Medium)
@@ -504,7 +525,7 @@ struct SelectMaterialBoxDialog {
   vehicleTypeDictMap: HashMap<string, string> = new HashMap<string, string>()
   MaterialBoxInfos: MaterialBoxInfo[] = []
   scroller: Scroller = new Scroller()
-  @Link selectVehicleCode: string
+  @Consume('currentVehicleCode') currentVehicleCode: string
 
   async aboutToAppear() {
     if (!CommonConstants.DICT_DATA || CommonConstants.DICT_DATA.length <= 0) {
@@ -591,12 +612,12 @@ struct SelectMaterialBoxDialog {
             .width('32.8%')
             .height('25%')
             .borderRadius($r('app.float.virtualSize_16'))
-            .backgroundColor(this.selectVehicleCode === item.vehicleCode ? $r('app.color.2030D158') : $r('app.color.20FFFFFF'))
+            .backgroundColor(this.currentVehicleCode === item.vehicleCode ? $r('app.color.2030D158') : $r('app.color.20FFFFFF'))
             .borderWidth(1)
-            .borderColor(this.selectVehicleCode === item.vehicleCode ? $r('app.color.30D158') : $r('app.color.20FFFFFF'))
+            .borderColor(this.currentVehicleCode === item.vehicleCode ? $r('app.color.30D158') : $r('app.color.20FFFFFF'))
             .margin({ top: index > 2 ? '1%' : '0%', left: (index % 3) === 0 ? '0%' : '0.8%' })
             .onClick(()=>{
-              this.selectVehicleCode = item.vehicleCode!
+              this.currentVehicleCode = item.vehicleCode!
             })
           })
         }
@@ -655,7 +676,6 @@ struct SelectMaterialBoxDialog {
 // 本次扫描物料弹窗
 @CustomDialog
 struct ThisScanDialog {
-
   // 若尝试在CustomDialog中传入多个其他的Controller,以实现在CustomDialog中打开另一个或另一些CustomDialog,那么此处需要将指向自己的controller放在最后
   controller?: CustomDialogController
   cancel?: () => void = () => {
@@ -666,8 +686,12 @@ struct ThisScanDialog {
   scroller: Scroller = new Scroller()
   @Link materialArray: MaterialInfo[]
   @Link materialMergeArray: MaterialInfo[]
+  // 出库料箱的物料信息
+  @Link outMaterialBoxInfos: MaterialInfo[]
+  @Link materialNum: number
   @State tempArray: MaterialInfo[] = []
   tempMergeArray: MaterialInfo[] = []
+  deleteArray: MaterialInfo[] = []
 
   aboutToAppear(): void {
     if (this.materialArray && this.materialArray.length > 0) {
@@ -739,6 +763,7 @@ struct ThisScanDialog {
                   .width($r('app.float.virtualSize_48'))
                   .fillColor($r('app.color.FF453A'))
                   .onClick(()=>{
+                    this.deleteArray.push(item)
                     for (let i = 0; i < this.tempMergeArray.length; i++) {
                       if (this.tempMergeArray[i].materialCode! === this.tempArray[index].materialCode!) {
                         if (this.tempMergeArray[i].num! === this.tempArray[index].num!) {
@@ -803,6 +828,23 @@ struct ThisScanDialog {
           this.materialMergeArray = []
           this.materialArray = this.tempArray
           this.materialMergeArray = this.tempMergeArray
+          let toChangeArray: MaterialInfo[] = [...this.outMaterialBoxInfos]
+          // 出库料箱把物料加回去
+          this.deleteArray.forEach((item) => {
+            // 中间列表遍历,将同一个数据的num进行运算
+            for (let i = 0; i < toChangeArray.length; i++) {
+              let box = toChangeArray[i]
+              if (item.materialCode == box.materialCode) {
+                let value = box.num! - item.num!
+                box.num = value >= 0 ? value : 0
+                continue
+              }
+            }
+          })
+          this.outMaterialBoxInfos = toChangeArray.filter((m) => {
+            return m.num! > 0
+          })
+          this.materialNum = this.outMaterialBoxInfos.length
           if (this.controller != undefined) {
             this.controller.close()
           }

+ 2 - 0
entry/src/main/ets/viewmodel/wms/OperationInfo.ets

@@ -11,4 +11,6 @@ export default class OperationInfo {
   stanType?: string
   // 当前工序排序号
   operationSort?: number
+  // 工位虚拟序号id
+  stationSortId?: number
 }

+ 3 - 1
entry/src/main/ets/viewmodel/wms/StationOperationInfo.ets

@@ -2,11 +2,13 @@
 import OperationInfo from './OperationInfo'
 
 export default class StationOperationInfo {
+    // 序号id
+    sortId?: number
     // 工位类型
     stanType?: string
     // 工位类型名称
     stanTypeName?: string
     // 工序明细
-    operationVO?: OperationInfo[]
+    operationList?: OperationInfo[]
 }