Browse Source

齐套绑定相关逻辑

hh 2 months ago
parent
commit
a35aeab2a3

+ 1 - 1
entry/src/main/ets/component/OrderMaterialsStorageView.ets

@@ -31,7 +31,7 @@ export struct ProcessFlow {
       {
         FlowStep({
           stepNumber: 3,
-          title: '绑定入库',
+          title: this.thirdStepTitle,
           showConnector: false,
           isChoose:this.currentStep === 3
         })

+ 83 - 70
entry/src/main/ets/pages/OperationMaterialKit.ets

@@ -9,6 +9,9 @@ import WorkOrderInfo from '../viewmodel/wms/WorkOrderInfo'
 import { OperationMaterialKitTwoStep } from '../view/wms/OperationMaterialKitTwoStep'
 import OperationInfo from '../viewmodel/wms/OperationInfo'
 import OperationItem from '../viewmodel/wms/OperationItem'
+import {
+  ProcessFlow,
+} from "../component/OrderMaterialsStorageView"
 
 @Entry
 @Component
@@ -53,80 +56,90 @@ struct OperationMaterialKit {
       .alignItems(VerticalAlign.Center)
       .justifyContent(FlexAlign.Start)
 
-      // 齐套步骤和操作栏
+      // 当前齐套步骤和操作栏
       Row() {
-        Row().width('41%')
-        Row() {
-          Column({space: 5}) {
-            Stack() {
-              Circle()
-                .width($r('app.float.virtualSize_19_2'))
-                .height($r('app.float.virtualSize_19_2'))
-                .fill(this.step === 1 ? $r('app.color.0A84FF') : $r('app.color.10FFFFFF'))
-              Text('1')
-                .fontSize($r('app.float.fontSize_12'))
-                .fontColor(this.step === 1 ? $r('app.color.FFFFFF') : $r('app.color.60FFFFFF'))
-                .fontWeight(FontWeight.Medium)
-            }
-            .width($r('app.float.virtualSize_19_2'))
-            .height($r('app.float.virtualSize_19_2'))
-            Text('选择工序')
-              .fontSize($r('app.float.fontSize_6_4'))
-              .fontColor(this.step === 1 ? $r('app.color.FFFFFF') : $r('app.color.60FFFFFF'))
-              .fontWeight(FontWeight.Regular)
-          }
-          Column({space: 5}) {
-            Stack() {
-              Circle()
-                .width($r('app.float.virtualSize_19_2'))
-                .height($r('app.float.virtualSize_19_2'))
-                .fill(this.step === 2 ? $r('app.color.0A84FF') : $r('app.color.10FFFFFF'))
-              Text('2')
-                .fontSize($r('app.float.fontSize_12'))
-                .fontColor(this.step === 2 ? $r('app.color.FFFFFF') : $r('app.color.60FFFFFF'))
-                .fontWeight(FontWeight.Medium)
-            }
-            .width($r('app.float.virtualSize_19_2'))
-            .height($r('app.float.virtualSize_19_2'))
-            Text('齐套装箱')
-              .fontSize($r('app.float.fontSize_6_4'))
-              .fontColor(this.step === 2 ? $r('app.color.FFFFFF') : $r('app.color.60FFFFFF'))
-              .fontWeight(FontWeight.Regular)
-          }
-          Column({space: 5}) {
-            Stack() {
-              Circle()
-                .width($r('app.float.virtualSize_19_2'))
-                .height($r('app.float.virtualSize_19_2'))
-                .fill(this.step === 3 ? $r('app.color.0A84FF') : $r('app.color.10FFFFFF'))
-              Text('3')
-                .fontSize($r('app.float.fontSize_12'))
-                .fontColor(this.step === 3 ? $r('app.color.FFFFFF') : $r('app.color.60FFFFFF'))
-                .fontWeight(FontWeight.Medium)
-            }
-            .width($r('app.float.virtualSize_19_2'))
-            .height($r('app.float.virtualSize_19_2'))
-            Text('齐套入库')
-              .fontSize($r('app.float.fontSize_6_4'))
-              .fontColor(this.step === 3 ? $r('app.color.FFFFFF') : $r('app.color.60FFFFFF'))
-              .fontWeight(FontWeight.Regular)
-          }
-        }
-        .height('80%')
-        .width('18%')
-        .justifyContent(FlexAlign.SpaceBetween)
-        .alignItems(VerticalAlign.Top)
-
-        Blank()
-        Row() {
-          NavigationBar()
-        }
-        .height('80%')
-        .width('30%')
+        ProcessFlow({
+          currentStep: this.step,
+          firstStepTitle: "选择工单",
+          secondStepTitle: "齐套装箱",
+          thirdStepTitle: "齐套入库",
+        }).width('20%')
+          .margin({right:'20%'})
+        NavigationBar().width('20%')
+        // Row().width('41%')
+        // Row() {
+        //   Column({space: 5}) {
+        //     Stack() {
+        //       Circle()
+        //         .width($r('app.float.virtualSize_19_2'))
+        //         .height($r('app.float.virtualSize_19_2'))
+        //         .fill(this.step === 1 ? $r('app.color.0A84FF') : $r('app.color.10FFFFFF'))
+        //       Text('1')
+        //         .fontSize($r('app.float.fontSize_12'))
+        //         .fontColor(this.step === 1 ? $r('app.color.FFFFFF') : $r('app.color.60FFFFFF'))
+        //         .fontWeight(FontWeight.Medium)
+        //     }
+        //     .width($r('app.float.virtualSize_19_2'))
+        //     .height($r('app.float.virtualSize_19_2'))
+        //     Text('选择工序')
+        //       .fontSize($r('app.float.fontSize_6_4'))
+        //       .fontColor(this.step === 1 ? $r('app.color.FFFFFF') : $r('app.color.60FFFFFF'))
+        //       .fontWeight(FontWeight.Regular)
+        //   }
+        //   Column({space: 5}) {
+        //     Stack() {
+        //       Circle()
+        //         .width($r('app.float.virtualSize_19_2'))
+        //         .height($r('app.float.virtualSize_19_2'))
+        //         .fill(this.step === 2 ? $r('app.color.0A84FF') : $r('app.color.10FFFFFF'))
+        //       Text('2')
+        //         .fontSize($r('app.float.fontSize_12'))
+        //         .fontColor(this.step === 2 ? $r('app.color.FFFFFF') : $r('app.color.60FFFFFF'))
+        //         .fontWeight(FontWeight.Medium)
+        //     }
+        //     .width($r('app.float.virtualSize_19_2'))
+        //     .height($r('app.float.virtualSize_19_2'))
+        //     Text('齐套装箱')
+        //       .fontSize($r('app.float.fontSize_6_4'))
+        //       .fontColor(this.step === 2 ? $r('app.color.FFFFFF') : $r('app.color.60FFFFFF'))
+        //       .fontWeight(FontWeight.Regular)
+        //   }
+        //   Column({space: 5}) {
+        //     Stack() {
+        //       Circle()
+        //         .width($r('app.float.virtualSize_19_2'))
+        //         .height($r('app.float.virtualSize_19_2'))
+        //         .fill(this.step === 3 ? $r('app.color.0A84FF') : $r('app.color.10FFFFFF'))
+        //       Text('3')
+        //         .fontSize($r('app.float.fontSize_12'))
+        //         .fontColor(this.step === 3 ? $r('app.color.FFFFFF') : $r('app.color.60FFFFFF'))
+        //         .fontWeight(FontWeight.Medium)
+        //     }
+        //     .width($r('app.float.virtualSize_19_2'))
+        //     .height($r('app.float.virtualSize_19_2'))
+        //     Text('齐套入库')
+        //       .fontSize($r('app.float.fontSize_6_4'))
+        //       .fontColor(this.step === 3 ? $r('app.color.FFFFFF') : $r('app.color.60FFFFFF'))
+        //       .fontWeight(FontWeight.Regular)
+        //   }
+        // }
+        // .height('80%')
+        // .width('18%')
+        // .justifyContent(FlexAlign.SpaceBetween)
+        // .alignItems(VerticalAlign.Top)
+        //
+        // Blank()
+        // Row() {
+        //   NavigationBar()
+        // }
+        // .height('80%')
+        // .width('30%')
       }
       .height('14.2%')
       .width('100%')
+      .justifyContent(FlexAlign.End)
 
+      // 步骤详情
       Column() {
         if (this.step === 1) {
           OperationMaterialKitOneStep({
@@ -144,7 +157,7 @@ struct OperationMaterialKit {
       }
       .height('71%')
       .width('94.8%')
-
+      // 步骤切换按钮
       Row() {
         if (this.step > 2) {
           Row () {

+ 65 - 79
entry/src/main/ets/view/wms/OperationMaterialKitTwoStep.ets

@@ -11,6 +11,7 @@ import VehicleInfo from '../../viewmodel/wms/VehicleInfo'
 import { InBoundView } from '../../component/InBoundView'
 import HouseStockMaterial from '../../viewmodel/wms/HouseStockMaterial'
 import promptAction from '@ohos.promptAction'
+import OperationMaterial from '../../viewmodel/wms/OperationMaterial'
 
 @Component
 export struct OperationMaterialKitTwoStep {
@@ -18,7 +19,9 @@ export struct OperationMaterialKitTwoStep {
   @Link workOrder: WorkOrderInfo
   @Link selectOperations: OperationInfo[]
   @Link operationItems: OperationItem[]
-
+  selectOperationIds: string[] = []
+  // 每个工序需要的物料编码分组
+  operationItemCodes: HashMap<string, string[]> = new HashMap<string, string[]>()
   @State operationNames: string = ''
   // 选择已有料箱,出库料箱
   @State selectVehicleCode: string = ''
@@ -30,85 +33,9 @@ export struct OperationMaterialKitTwoStep {
   // 扫描或手动输入的物料编码
   @State scanCode: string = ''
   // 物料全数组(本次扫描物料弹窗中展示)
-  @State materialArray: HouseStockMaterial[] =[
-    { materialName: "磷酸蚀刻液",
-      materialCode: "WET-H3PO4",
-      num: 10,
-      spec: "-",
-      unit: "克"},
-    { materialName: "磷酸dsf",
-      materialCode: "WET-H3PO5",
-      num: 10,
-      spec: "-",
-      unit: "克"},
-    { materialName: "ssdg",
-      materialCode: "WET-H3PO6",
-      num: 10,
-      spec: "-",
-      unit: "克"},
-    { materialName: "磷酸蚀刻液",
-      materialCode: "WET-H3PO4",
-      num: 10,
-      spec: "-",
-      unit: "克"},
-    { materialName: "fhgfh",
-      materialCode: "WET-H3PO7",
-      num: 10,
-      spec: "-",
-      unit: "克"},
-    { materialName: "sdfdg",
-      materialCode: "WET-H3PO8",
-      num: 10,
-      spec: "-",
-      unit: "克"},
-    { materialName: "磷酸蚀刻液",
-      materialCode: "WET-H3PO4",
-      num: 10,
-      spec: "-",
-      unit: "克"},
-    { materialName: "磷酸蚀刻液we",
-      materialCode: "WET-H3PO9",
-      num: 10,
-      spec: "-",
-      unit: "克"},
-    { materialName: "磷酸蚀刻液",
-      materialCode: "WET-H3PO4",
-      num: 10,
-      spec: "-",
-      unit: "克"},
-  ]
-
+  @State materialArray: HouseStockMaterial[] = []
   // 数量合并的物料数组(在拣选工作台展示)
-  @State materialMergeArray: HouseStockMaterial[] =  [ { materialName: "磷酸蚀刻液",
-    materialCode: "WET-H3PO4",
-    num: 40,
-    spec: "-",
-    unit: "克"},
-    { materialName: "磷酸dsf",
-      materialCode: "WET-H3PO5",
-      num: 10,
-      spec: "-",
-      unit: "克"},
-    { materialName: "ssdg",
-      materialCode: "WET-H3PO6",
-      num: 10,
-      spec: "-",
-      unit: "克"},
-    { materialName: "fhgfh",
-      materialCode: "WET-H3PO7",
-      num: 10,
-      spec: "-",
-      unit: "克"},
-    { materialName: "sdfdg",
-      materialCode: "WET-H3PO8",
-      num: 10,
-      spec: "-",
-      unit: "克"},
-    { materialName: "磷酸蚀刻液we",
-      materialCode: "WET-H3PO9",
-      num: 10,
-      spec: "-",
-      unit: "克"}]
+  @State materialMergeArray: HouseStockMaterial[] = []
   //齐套料箱扫码后如果物料存在则自动滚动所在列
   @State scanCodeIndex: number = -1
   materialScrollerController: Scroller = new Scroller()
@@ -153,6 +80,7 @@ export struct OperationMaterialKitTwoStep {
     customStyle: true,
   })
 
+  // 齐套操作-扫描物料
   scanMaterialCode = async (itemCode: string) => {
     this.scanCode = ""
     let res: HouseStockMaterial = await WmsRequest.post("/api/v1/process/circulation/material", {
@@ -194,6 +122,47 @@ export struct OperationMaterialKitTwoStep {
     this.materialScrollerController.scrollToIndex(this.scanCodeIndex)
   }
 
+  // 齐套绑定
+  toCompleteKitting = async () => {
+    // 接口只支持根据工序去绑定,需要先遍历
+    let paramArray: RequestParamModel[] = []
+    this.operationItemCodes.forEach((value: string[], key: string) => {
+      let itemArray: HouseStockMaterial[] = []
+      for (const material of this.materialMergeArray) {
+        if (value.includes(material.materialCode)) {
+          itemArray.push(material)
+        }
+      }
+      // 当前工序有齐套物料绑定
+      if (itemArray.length > 0) {
+        let param: RequestParamModel = {
+          operationId: key,
+          workOrderCode: this.workOrder.workOrderCode!,
+          vehicleCode: this.vehicleCode,
+          processVehicleMaterialList: itemArray
+        }
+        paramArray.push(param)
+      }
+    })
+    if (paramArray.length <= 0) {
+      return
+    }
+    for (const param of paramArray) {
+      await WmsRequest.post("api/v1/process/vehicleOperation/add", param)
+    }
+    // 重新刷新调取料箱下方物料已齐套数量
+    let result: OperationMaterial[] = await WmsRequest.post('/api/v1/wms/operationMaterial/list', {
+      //查询工序需求的物料
+      operationIds: this.selectOperationIds,
+    } as RequestParamModel) as OperationMaterial[]
+    this.operationItems = []
+    if (result && result.length > 0) {
+      for (const element of result) {
+        this.operationItems = this.operationItems.concat(element.itemList!);
+      }
+    }
+  }
+
   async aboutToAppear() {
     if (this.selectOperations) {
       this.selectOperations.sort((a: OperationInfo, b: OperationInfo) => {
@@ -208,6 +177,20 @@ export struct OperationMaterialKitTwoStep {
         }
       }
     }
+    for (const operation of this.selectOperations) {
+      this.selectOperationIds.push(operation.id!)
+      for (const item of this.operationItems) {
+        if (operation.id != item.operationId) {
+          continue
+        }
+        let itemCodes: string[] = []
+        if (this.operationItemCodes.hasKey(operation.id)) {
+          itemCodes = this.operationItemCodes.get(operation.id)
+        }
+        itemCodes.push(item.itemCode!)
+        this.operationItemCodes.set(operation.id, itemCodes)
+      }
+    }
   }
 
   build() {
@@ -483,6 +466,9 @@ export struct OperationMaterialKitTwoStep {
           .height('7.3%')
           .borderRadius($r('app.float.virtualSize_6_4'))
           .backgroundColor($r('app.color.20FFFFFF'))
+          .onClick(async ()=>{
+            this.toCompleteKitting()
+          })
       }
       .height('100%')
       .width('29.6%')

+ 6 - 0
entry/src/main/ets/viewmodel/wms/RequestParamModel.ets

@@ -1,4 +1,6 @@
 import {detailsListClass} from '../wms/InBoundOrderInfo'
+import HouseStockMaterial from './HouseStockMaterial';
+
 //通用请求后台参数
 export default class RequestParamModel {
   // 工单状态 0 未完成 1已完成
@@ -37,4 +39,8 @@ export default class RequestParamModel {
   stationId?:string
   //工单编号
   workOrderCode?:string
+  // 工序id
+  operationId?: number | string
+  // 工序绑定载具物料参数
+  processVehicleMaterialList?: HouseStockMaterial[]
 }