소스 검색

齐套绑定相关逻辑

hh 3 주 전
부모
커밋
7c4dfe211f
2개의 변경된 파일438개의 추가작업 그리고 62개의 파일을 삭제
  1. 436 62
      entry/src/main/ets/view/wms/OperationMaterialKitTwoStep.ets
  2. 2 0
      entry/src/main/ets/viewmodel/wms/HouseStockMaterial.ets

+ 436 - 62
entry/src/main/ets/view/wms/OperationMaterialKitTwoStep.ets

@@ -7,10 +7,10 @@ import HouseStock from '../../viewmodel/wms/HouseStock'
 import CommonConstants from '../../common/constants/CommonConstants'
 import DictInfo from '../../viewmodel/DictInfo'
 import HashMap from '@ohos.util.HashMap'
-import { isAxiosError } from '@ohos/axios'
 import VehicleInfo from '../../viewmodel/wms/VehicleInfo'
 import { InBoundView } from '../../component/InBoundView'
 import HouseStockMaterial from '../../viewmodel/wms/HouseStockMaterial'
+import promptAction from '@ohos.promptAction'
 
 @Component
 export struct OperationMaterialKitTwoStep {
@@ -27,8 +27,93 @@ export struct OperationMaterialKitTwoStep {
   // 空箱编码
   @State vehicleCode: string = ''
   @State materialTotal: number = 0
-  @State materialArray: HouseStockMaterial[] = []
-  stationType: string = 'station_type'
+  // 扫描或手动输入的物料编码
+  @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 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 scanCodeIndex: number = -1
+  materialScrollerController: Scroller = new Scroller()
+  // 出库料箱中的库存物料信息(暂时用不上)
+  outHouseStocks: HouseStock[] = []
 
   houseStockDialogController: CustomDialogController = new CustomDialogController({
     builder: houseStockDialog({
@@ -47,13 +132,68 @@ export struct OperationMaterialKitTwoStep {
         let res: VehicleInfo = await WmsRequest.post("/api/v1/wmsOrder/outBox", {
           houseNo: houseNo,
           vehicleNo:this.selectVehicleCode,
-        }as RequestParamModel)
+        } as RequestParamModel)
+        if (res && res.list) {
+          this.outHouseStocks = res.list
+        }
       }
+
+    }),
+    autoCancel: true, // 点击遮罩关闭
+    customStyle: true,
+  })
+
+  thisScanDialogController: CustomDialogController = new CustomDialogController({
+    builder: thisScanDialog({
+      materialMergeArray: this.materialMergeArray,
+      materialArray: this.materialArray,
+      confirm: async () => {}
     }),
     autoCancel: true, // 点击遮罩关闭
     customStyle: true,
   })
 
+  scanMaterialCode = async (itemCode: string) => {
+    this.scanCode = ""
+    let res: HouseStockMaterial = await WmsRequest.post("/api/v1/process/circulation/material", {
+      label: itemCode //"#gys022#sc022#100#20220929#31"
+    } as RequestParamModel)
+    // 判断扫描完成后返回的物料码是否是当前需要齐套的物料
+    let hasFlag: boolean = false
+    for (const item of this.operationItems) {
+      if (res.materialCode === item.itemCode) {
+        hasFlag = true
+        break
+      }
+    }
+    if (!hasFlag) {
+      promptAction.showToast({
+        message: "不是当前工序中的物料",
+        bottom: "50%",
+        duration: 2000
+      })
+      return
+    }
+    // 判断数量合并的物料数组是否有,有则合并数量并滚动到当前位置,没有则数组头部新增
+    hasFlag = false
+    for (let i = 0; i < this.materialMergeArray.length; i++) {
+      if (res.materialCode === this.materialMergeArray[i].materialCode) {
+        hasFlag = true
+        this.scanCodeIndex = i
+        this.materialMergeArray[i].num = this.materialMergeArray[i].num! + res.num!
+        this.materialMergeArray[i] = JSON.parse(JSON.stringify(this.materialMergeArray[i]))
+        break;
+      }
+    }
+    if (!hasFlag) {
+      this.materialMergeArray.unshift(res)
+      this.scanCodeIndex = 0
+    }
+    // 物料全数组默认都新增在数组头部
+    this.materialArray.unshift(res)
+    this.materialScrollerController.scrollToIndex(this.scanCodeIndex)
+  }
+
   async aboutToAppear() {
     if (this.selectOperations) {
       this.selectOperations.sort((a: OperationInfo, b: OperationInfo) => {
@@ -67,8 +207,6 @@ export struct OperationMaterialKitTwoStep {
           this.operationNames += '、'
         }
       }
-      console.log('hhtest', JSON.stringify(this.selectOperations));
-      console.log('hhtest', '--------------' + JSON.stringify(this.operationItems));
     }
   }
 
@@ -85,7 +223,7 @@ export struct OperationMaterialKitTwoStep {
         .height('10%')
         .width('100%')
         .justifyContent(FlexAlign.Center)
-
+        // 订单名称和选择的工序名称
         Column() {
           Text(this.workOrder?.orderName!)
             .fontSize($r('app.float.fontSize_4_8'))
@@ -97,7 +235,7 @@ export struct OperationMaterialKitTwoStep {
             .fontWeight(FontWeight.Lighter)
         }
         .height('6.5%')
-
+        // 工序需要采集的物料列表
         List({space: 5}) {
           ForEach(this.operationItems, (item: OperationItem, index: number) => {
             ListItem() {
@@ -138,6 +276,9 @@ export struct OperationMaterialKitTwoStep {
               .backgroundColor($r('app.color.20FFFFFF'))
               .opacity(item.storageNum! > 0 ? 1 : 0.3)
               .onClick(async ()=>{
+                if (!item.storageNum || item.storageNum! <= 0) {
+                  return
+                }
                 this.houseStocks = await WmsRequest.post('/api/v1/process/vehicleOperation/processVehicle', {
                   label: item.itemCode
                 } as RequestParamModel) as HouseStock[]
@@ -164,18 +305,7 @@ export struct OperationMaterialKitTwoStep {
       .borderRadius($r('app.float.virtualSize_6_4'))
       .justifyContent(FlexAlign.Center)
       .backgroundColor($r('app.color.10FFFFFF'))
-      .onClick(async ()=>{
-        if (this.houseStocks) {
-          for (const element of this.houseStocks) {
-            if (element.coordinate && element.coordinate.length > 0 && element.coordinate.indexOf('-') > 0) {
-              let coors = element.coordinate.split('-');
-              element.x = parseInt(coors[0])
-              element.y = parseInt(coors[1])
-            }
-          }
-        }
-        this.houseStockDialogController.open()
-      })
+
       Image($r("app.media.wms_arrow_right"))
         .height($r('app.float.virtualSize_19_2'))
         .width($r('app.float.virtualSize_19_2'))
@@ -202,8 +332,8 @@ export struct OperationMaterialKitTwoStep {
         .height('10%')
         .width('100%')
         .justifyContent(FlexAlign.Center)
-        Column() {
-          Stack() {
+
+        Stack() {
             Image(this.vehicleCode && this.vehicleCode.length > 0 ? $r("app.media.wms_read_vehicle") : $r("app.media.wms_not_read_vehicle"))
               .width('100%')
               .height('100%')
@@ -243,46 +373,116 @@ export struct OperationMaterialKitTwoStep {
             .height('100%')
             .alignItems(HorizontalAlign.End)
           }
-          .height('26.4%')
-          .width('92.6%')
-
+        .height('23.8%')
+        .width('92.6%')
+        // 扫码框
+        Row() {
           Row() {
-            Row() {
-              Row().width('3.4%')
-              // 左侧二维码图标
-              Image($r('app.media.material_qr_code')) // 请替换为您的二维码图片资源
-                .width($r('app.float.virtualSize_9_6'))
-                .height($r('app.float.virtualSize_9_6'))
-                .fillColor($r('app.color.FFFFFF'))
-              // 扫码输入框
-              TextInput({ placeholder: '请扫描物料编码' })
-                .type(InputType.Normal)
-                .placeholderFont({ size: $r('app.float.fontSize_6_4')})
-                .placeholderColor($r('app.color.30FFFFFF'))
-                .fontSize($r('app.float.fontSize_6_4'))
-                .fontColor($r('app.color.FFFFFF'))
-                .enableKeyboardOnFocus(false)
-            }
-            .width('82%')
-            .height('100%')
-            .borderRadius($r('app.float.virtualSize_6_4'))
-            .backgroundColor($r('app.color.000000'))
-            .justifyContent(FlexAlign.Start)
-
+            Row().width('3.4%')
+            // 左侧二维码图标
+            Image($r('app.media.material_qr_code')) // 请替换为您的二维码图片资源
+              .width($r('app.float.virtualSize_9_6'))
+              .height($r('app.float.virtualSize_9_6'))
+              .fillColor($r('app.color.FFFFFF'))
+            // 扫码输入框
+            TextInput({ placeholder: '请扫描物料编码', text: this.scanCode })
+              .type(InputType.Normal)
+              .placeholderFont({ size: $r('app.float.fontSize_6_4')})
+              .placeholderColor($r('app.color.30FFFFFF'))
+              .fontSize($r('app.float.fontSize_6_4'))
+              .fontColor($r('app.color.FFFFFF'))
+              .enableKeyboardOnFocus(false)
+              .onChange((value: string) => {
+                this.scanCode = value
+              })
+              .onSubmit(async () => {
+                this.scanMaterialCode(this.scanCode)
+              })
           }
-          .height('8.1%')
-          .width('92.6%')
-          .margin({top: $r('app.float.virtualSize_8'), bottom: $r('app.float.fontSize_4_8')})
+          .width('82%')
+          .height('100%')
+          .borderRadius($r('app.float.virtualSize_6_4'))
+          .backgroundColor($r('app.color.000000'))
+          .justifyContent(FlexAlign.Start)
+        }
+        .height('7.3%')
+        .width('92.6%')
+        .margin({top: $r('app.float.virtualSize_8'), bottom: $r('app.float.fontSize_4_8')})
+        // 扫码得到的物料列表
+        List({ scroller: this.materialScrollerController }) {
+          ForEach(this.materialMergeArray, (item: HouseStockMaterial)=>{
+            ListItem() {
+              Column() {
+                Row() {
+                  Text(item.materialName! + '-' + item.materialCode!)
+                    .fontSize($r('app.float.fontSize_6_4'))
+                    .fontWeight(FontWeight.Bold)
+                    .fontColor($r('app.color.FFFFFF'))
+                    .maxLines(1)
 
-          List() {
+                  Text(item.num ? item.num.toString() : '0')
+                    .fontSize($r('app.float.fontSize_6_4'))
+                    .fontWeight(FontWeight.Bold)
+                    .fontColor($r('app.color.FFFFFF'))
+                    .maxLines(1)
+                }
+                .width('100%')
+                .justifyContent(FlexAlign.SpaceBetween)
+                Row() {
+                  Text('型号:' + (item.spec ? item.spec : ''))
+                    .fontSize($r('app.float.fontSize_4_8'))
+                    .fontWeight(FontWeight.Lighter)
+                    .fontColor($r('app.color.FFFFFF'))
+                    .maxLines(1)
+                  Text('本次添加')
+                    .fontSize($r('app.float.fontSize_4_8'))
+                    .fontWeight(FontWeight.Lighter)
+                    .fontColor($r('app.color.60FFFFFF'))
+                }
+                .width('100%')
+                .justifyContent(FlexAlign.SpaceBetween)
 
-          }
-          .height('24.4%')
-          .width('92.6%')
-          .alignListItem(ListItemAlign.Center)
+                Divider().vertical(false)
+                  .color($r('app.color.10FFFFFF'))
+                  .width('100%')
+              }
+              .height('25%')
+              .width('92.6%')
+              .justifyContent(FlexAlign.SpaceBetween)
+            }
+          })
         }
-        .height('90%')
-        .width('100%')
+        .height('21.9%')
+        .width('92.6%')
+        .alignListItem(ListItemAlign.Center)
+
+        Row() {
+          Text('本次扫描物料')
+            .fontSize($r('app.float.fontSize_9_6'))
+            .fontColor($r('app.color.0A84FF'))
+            .fontWeight(FontWeight.Medium)
+            .textAlign(TextAlign.Center)
+            .width('100%')
+            .height('37.3%')
+            .borderRadius($r('app.float.virtualSize_6_4'))
+            .backgroundColor($r('app.color.20FFFFFF'))
+        }
+        .height('19.6%')
+        .width('44.4%')
+        .justifyContent(FlexAlign.Center)
+        .onClick(()=>{
+          this.thisScanDialogController.open()
+        })
+
+        Text('齐套绑定')
+          .fontSize($r('app.float.fontSize_9_6'))
+          .fontColor($r('app.color.0A84FF'))
+          .fontWeight(FontWeight.Medium)
+          .textAlign(TextAlign.Center)
+          .width('92.6%')
+          .height('7.3%')
+          .borderRadius($r('app.float.virtualSize_6_4'))
+          .backgroundColor($r('app.color.20FFFFFF'))
       }
       .height('100%')
       .width('29.6%')
@@ -296,7 +496,6 @@ export struct OperationMaterialKitTwoStep {
   }
 }
 
-
 // 库存信息弹窗(选择料箱)
 @CustomDialog
 struct houseStockDialog {
@@ -426,6 +625,11 @@ struct houseStockDialog {
         }
         .width('50%')
         .justifyContent(FlexAlign.Center)
+        .onClick(()=>{
+          if (this.controller != undefined) {
+            this.controller.close()
+          }
+        })
         Divider().vertical(true).color($r('app.color.FFFFFF'))
           .height('100%')
           .opacity(0.15)
@@ -437,15 +641,185 @@ struct houseStockDialog {
         }
         .width('50%')
         .justifyContent(FlexAlign.Center)
+        .onClick(()=>{
+          this.confirm()
+          if (this.controller != undefined) {
+            this.controller.close()
+          }
+        })
       }
       .width('100%')
       .height('7.3%')
       .justifyContent(FlexAlign.Center)
-      .onClick(()=>{
-        if (this.controller != undefined) {
-          this.controller.close()
+    }
+    .width('61.5%')
+    .height('71%')
+    .justifyContent(FlexAlign.Start)
+    .backgroundColor($r('app.color.2A2A2A'))
+    .borderRadius($r('app.float.virtualSize_6_4'))
+  }
+}
+
+// 本次扫描物料弹窗
+@CustomDialog
+struct thisScanDialog {
+
+  // 若尝试在CustomDialog中传入多个其他的Controller,以实现在CustomDialog中打开另一个或另一些CustomDialog,那么此处需要将指向自己的controller放在最后
+  controller?: CustomDialogController
+  cancel?: () => void = () => {
+  }
+  confirm: () => void = () => {
+  }
+  houseStocks: HouseStock[] = []
+  scroller: Scroller = new Scroller()
+  @Link materialArray: HouseStockMaterial[]
+  @Link materialMergeArray: HouseStockMaterial[]
+  @State tempArray: HouseStockMaterial[] = []
+  tempMergeArray: HouseStockMaterial[] = []
+
+  onPageShow(): void {
+    if (this.materialArray && this.materialArray.length > 0) {
+      this.tempArray = this.materialArray
+    }
+    if (this.materialMergeArray && this.materialMergeArray.length > 0) {
+      this.tempMergeArray = this.materialMergeArray
+    }
+  }
+
+  build() {
+    Column() {
+      Row() {
+        Text('本次扫描物料')
+          .fontWeight(FontWeight.Medium)
+          .fontSize($r('app.float.fontSize_12'))
+          .fontColor($r('app.color.FFFFFF'))
+          .fontWeight(FontWeight.Medium)
+      }
+      .height('10%')
+      .width('100%')
+      .justifyContent(FlexAlign.Center)
+
+      List({space: 4, scroller: this.scroller}) {
+        ForEach(this.materialArray, (item: HouseStockMaterial, index: number) => {
+          ListItem() {
+            Row() {
+              Column({space: 1}) {
+                Text(item.materialName! + '-' + item.materialCode!)
+                  .fontSize($r('app.float.fontSize_9_6'))
+                  .fontWeight(FontWeight.Medium)
+                  .fontColor($r('app.color.FFFFFF'))
+                  .maxLines(1)
+                Column() {
+                  Text('型号:' + item.spec!)
+                    .fontSize($r('app.float.fontSize_6_4'))
+                    .fontWeight(FontWeight.Lighter)
+                    .fontColor($r('app.color.FFFFFF'))
+                    .maxLines(1)
+                  Text('序列号:' + item.batchCode!)
+                    .fontSize($r('app.float.fontSize_6_4'))
+                    .fontWeight(FontWeight.Lighter)
+                    .fontColor($r('app.color.FFFFFF'))
+                    .maxLines(1)
+                  Text('所属订单:-')
+                    .fontSize($r('app.float.fontSize_6_4'))
+                    .fontWeight(FontWeight.Lighter)
+                    .fontColor($r('app.color.FFFFFF'))
+                    .maxLines(1)
+                  Text('数量:' + item.num!)
+                    .fontSize($r('app.float.fontSize_6_4'))
+                    .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_19_2'))
+                  .width($r('app.float.virtualSize_19_2'))
+                  .fillColor($r('app.color.FF453A'))
+                  .onClick(()=>{
+                    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!) {
+                          this.tempMergeArray.splice(i, 1)
+                          break;
+                        } else {
+                          this.tempMergeArray[i].num = this.tempMergeArray[i].num! - this.tempArray[index].num!;
+                          break;
+                        }
+                      }
+                    }
+                    this.tempArray.splice(index, 1)
+                  })
+                Row().width('2%')
+              }
+              .height('100%')
+              .width('50%')
+              .alignItems(VerticalAlign.Center)
+              .justifyContent(FlexAlign.End)
+            }
+            .height('22.7%')
+            .width('100%')
+            .justifyContent(FlexAlign.Center)
+            .borderRadius($r('app.float.virtualSize_6_4'))
+            .backgroundColor($r('app.color.10FFFFFF'))
+          }
+        })
+      }
+      .alignListItem(ListItemAlign.Center)
+      .width('96.6%')
+      .height('82.7%')
+
+      Divider().vertical(false).color($r('app.color.FFFFFF'))
+        .width('100%')
+        .opacity(0.15)
+
+      Row() {
+        Row() {
+          Text('关闭')
+            .fontColor($r('app.color.60FFFFFF'))
+            .fontSize($r('app.float.fontSize_6_4'))
+            .fontWeight(FontWeight.Medium)
         }
-      })
+        .width('50%')
+        .justifyContent(FlexAlign.Center)
+        .onClick(()=>{
+          if (this.controller != undefined) {
+            this.controller.close()
+          }
+        })
+        Divider().vertical(true).color($r('app.color.FFFFFF'))
+          .height('100%')
+          .opacity(0.15)
+        Row() {
+          Text('确认')
+            .fontColor($r('app.color.007AFF'))
+            .fontSize($r('app.float.fontSize_6_4'))
+            .fontWeight(FontWeight.Medium)
+        }
+        .width('50%')
+        .justifyContent(FlexAlign.Center)
+        .onClick(()=>{
+          this.materialArray = this.tempArray
+          this.materialMergeArray = this.tempMergeArray
+          console.log('hhtest', JSON.stringify(this.materialMergeArray));
+          if (this.controller != undefined) {
+            this.controller.close()
+          }
+        })
+      }
+      .width('100%')
+      .height('7.3%')
+      .justifyContent(FlexAlign.Center)
     }
     .width('61.5%')
     .height('71%')

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

@@ -12,4 +12,6 @@ export default class HouseStockMaterial {
   num?: number;
   // 单位
   unit?: string;
+  // 流转卡号/序列号
+  batchCode?: string;
 }