Procházet zdrojové kódy

修改选择工位和用户的代码

hh před 1 měsícem
rodič
revize
e9a4ebf6f3

+ 2 - 2
entry/src/main/ets/common/constants/CommonConstants.ets

@@ -11,13 +11,13 @@ export default class CommonConstants {
   static PICTURE_URL_PREFIX: string = 'http://192.168.1.3:20001'
 
   // 当前登录用户相关信息
-  static USER_ID?: number = 1
+  static USER_ID?: number
   static USER_NAME: string = ''
   static USER_AVATAR: string = ''
   static STATION_NANE: string = ''
   static DEPARTMENT_NANE: string = ''
   static PRODUCT_NANE: string = ''
-  static STATION_ID: number = 1
+  static STATION_ID: number
   static STATION_CODE: string = ''
   static STATION_IP: string = ''
   static stationDictValue: string = ''

+ 3 - 4
entry/src/main/ets/common/util/request/ProcessRequest.ets

@@ -14,7 +14,8 @@ import { printError, printRequest, printResponse, handleRes } from './Helps';
 //const baseUrl = "http://192.168.1.3:11010/" //chuangke
 //const baseUrl = "http://192.168.1.174:8079"//huajing
 const baseUrl = "http://192.168.1.3:20010"//huajing
-// const baseUrl = "http://192.168.1.4:8079/" //chuangke
+// huhao本地
+// const baseUrl = "http://192.168.1.246:8079"
 const DEBUG = true //
 
 // 创建实例
@@ -33,9 +34,7 @@ const ProcessRequest = axios.create(
 ProcessRequest.interceptors.request.use((config: InternalAxiosRequestConfig) => {
 
   // 以后登录之后可以在这里传
-  config.headers.Authorization = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJsb2dpblR5cGUiOiJsb2dpbiIsImxvZ2luSWQiOnsiZGVwdElkIjoxNywiaWQiOjEwMDAwLCJhdmF0YXIiOiIvamdmaWxlLy8yMDI0LzUvMjcvMjc0MzI5Mzk1ODM4ODUyLmpwZyIsInVzZXJOYW1lIjoiYWRtaW4iLCJvcmdJZCI6MTd9LCJkZXZpY2UiOiJiYWNrIiwiZWZmIjoxNzQ4NDIyMDk5MTk3LCJyblN0ciI6InduUktQS25iQmpVQ2hYTEJBbk5YbXdSZU0yOG5PQ1hzIn0.2be90J5J2sjxPgn1GJqNuXTH5XD9GF4t4jM6qmxrdVg"
-   //config.headers.Authorization ="eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJsb2dpblR5cGUiOiJsb2dpbiIsImxvZ2luSWQiOnsic3RhdGlvbkNvZGUiOiJ6aHVhbmd0aWFvMSIsInN0YXRpb25UeXBlIjoiMTgiLCJkZXB0SWQiOjE3LCJpZCI6MTAwMDAsInN0YXRpb25JcCI6IjE5Mi4xNjguMS4xMSIsInVzZXJOYW1lIjoiYWRtaW4iLCJvcmdJZCI6MTcsInN0YXRpb25JZCI6Njh9LCJkZXZpY2UiOiJhaW8iLCJlZmYiOjE3NDgwNTQ4ODg5MzUsInJuU3RyIjoiMmJ5NnJlOVpMa2JZOE1CcjBHSlBENjlXZTNwSjgyREIifQ.nY0PPEjgjW2-PX1TqI_SGxa5Mu4dGOCwbGDitvN_oqA"
-  //config.headers.Authorization ="eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJsb2dpblR5cGUiOiJsb2dpbiIsImxvZ2luSWQiOnsiaWQiOjM3LCJsb2dpblR5cGUiOiJhaW8ifSwiZGV2aWNlIjoiYWlvIiwiZWZmIjoxNzE3NTExMjYwODI4LCJyblN0ciI6InRSenNBTGdlZ3lqS0FHeDZTSkdYZTNLbFY3eWh1OG1PIn0.FVAeESiz_PH1NtBFDmGZr0IwtXzubV2d8JTQdGdJnxc"
+  config.headers.Authorization = CommonConstants.AUTH_TOKEN
   printRequest(config)
   return config;
 }, (error: AxiosError) => {

+ 54 - 98
entry/src/main/ets/pages/ProcessIndex.ets

@@ -5,7 +5,7 @@ import CommonConstants from '../common/constants/CommonConstants';
 import ProcessRequest from '../common/util/request/ProcessRequest';
 import RequestParamModel from '../viewmodel/RequestParamModel';
 import OperationInfo from '../viewmodel/process/OperationInfo';
-import { SelectOrderDialog } from '../view/SelectOrderDialog';
+import { SelectWorkOrderDialog } from '../view/SelectWorkOrderDialog';
 import { SwitchingProductDialog, taskSeqItem } from '../view/SwitchingProductDialog';
 import TaskSeqVO from '../viewmodel/process/TaskSeqInfo';
 import promptAction from '@ohos.promptAction';
@@ -22,72 +22,21 @@ struct ProcessIndex {
   // 工单列表
   @State workOrders: WorkOrderInfo[] = []
   // 选中工单
-  @State selectWorkOder: WorkOrderInfo = {workOrderCode:'32'}
+  @State selectWorkOder: WorkOrderInfo = {}
   // 工位通知数量
   @State noticeNum: number = 100
   // 扫描或手动输入的流水/序列/铭牌号
   @State scanCode: string = ''
   // 当前流转卡号
-  @State seqNo: string = '1'
+  @State seqNo: string = ''
   // 选中工序id
-  @State selectOperationId: string = '1'
+  @State selectOperationId: string = ''
   //选择的按钮索引(默认加载全部)
   @State selectedButtonIndex: number = 0
   // 流转卡号信息集合
   @State taskSeqArray: TaskSeqVO[] = []
   // 工序组件(工步)
-  @State opComponents: OperationComponent[] = [
-    {
-      compentName:'物料采集',
-      compentType: '1',
-      deleted:0,
-      id:2415,
-      operationId:'679',
-      processRouteId:'0',
-      remark:'',
-      sortNum:0
-    },
-    {
-      compentName:'ESOP',
-      compentType:'4',
-      deleted:0,
-      id:2416,
-      operationId:'679',
-      processRouteId:'0',
-      remark:'',
-      sortNum:1
-    },
-    {
-      compentName:'多媒体采集',
-      compentType:'3',
-      deleted:0,
-      id:2417,
-      operationId:'679',
-      processRouteId:'0',
-      remark:'',
-      sortNum:2,
-    },
-    {
-      compentName:'记录项',
-      compentType:'2',
-      deleted:0,
-      id:2418,
-      operationId:'679',
-      processRouteId:'0',
-      remark:'',
-      sortNum:3,
-    },
-    {
-      compentName:'设备记录',
-      compentType:'6',
-      deleted:0,
-      id:2420,
-      operationId:'679',
-      processRouteId:'0',
-      remark:'',
-      sortNum:5
-    },
-  ]
+  @State opComponents: OperationComponent[] = []
   // 选中的工序组件类型
   @State selectComponentType: string = ''
   // 工序组件状态数组(0:未完成)
@@ -110,28 +59,27 @@ struct ProcessIndex {
 
   private scrollerList: Scroller = new Scroller()
 
-  @State currentDept:string = ''
-  @State currentProductLine:string = ''
-  @State currentStation:string = ''
-  @State currentPLCode:string = ''
-  @State currentOrgId:number = 0
-  @State currentStationId:string =''
-  @State currentUserName :string =''
+  @Provide('currentDept') currentDept:string = ''
+  @Provide('currentProductLine') currentProductLine:string = ''
+  @Provide('currentStation') currentStation:string = ''
+  @Provide('currentPLCode') currentPLCode:string = ''
+  @Provide('currentOrgId') currentOrgId:number = 0
+  @Provide('currentStationId') currentStationId:string =''
+  @Provide('currentUserName') currentUserName :string =''
 
+  // 选择工单弹窗控制器
   selectOrderController: CustomDialogController = new CustomDialogController({
-    builder: SelectOrderDialog({}),
+    builder: SelectWorkOrderDialog({
+      selectWorkOder: this.selectWorkOder
+    }),
     autoCancel: true, // 点击遮罩关闭
     customStyle: true,
+    // alignment:DialogAlignment.Center,
     maskColor: 'rgba(0,0,0,0.8)',  // 黑色遮罩
   })
-
+  // 选择工位和用户弹窗控制器
   StationInfoController: CustomDialogController = new CustomDialogController({
     builder: StationInfoDialog({
-      currentDept:this.currentDept,
-      currentProductLine:this.currentProductLine,
-      currentStation:this.currentStation,
-      currentPLCode:this.currentPLCode,
-      currentUserName:this.currentUserName,
       searchDept:()=>{this.SwitchingDeptController.open()},
       searchStation:()=>{this.SwitchingStationController.open()},
       searchProductLine:()=>{this.SwitchingProductLineController.open()},
@@ -141,48 +89,35 @@ struct ProcessIndex {
     customStyle: true,
     maskColor: 'rgba(0,0,0,0.8)',  // 黑色遮罩
   })
-
+  //切换部门弹窗控制器
   SwitchingDeptController: CustomDialogController = new CustomDialogController({
-    builder: SwitchingDeptDialog({
-      currentDept:this.currentDept,
-      currentOrgId:this.currentOrgId
-    }),
+    builder: SwitchingDeptDialog({}),
     autoCancel: true, // 点击遮罩关闭
     customStyle: true,
     maskColor: 'rgba(0,0,0,0.8)',  // 黑色遮罩
   })
+  // 切换产线弹窗控制器
   SwitchingProductLineController: CustomDialogController = new CustomDialogController({
-    builder: SwitchingProductLineDialog({
-      currentProductLine:this.currentProductLine,
-      currentPLCode:this.currentPLCode
-    }),
+    builder: SwitchingProductLineDialog({}),
     autoCancel: true, // 点击遮罩关闭
     customStyle: true,
     maskColor: 'rgba(0,0,0,0.8)',  // 黑色遮罩
   })
+  // 切换工位弹窗控制器
   SwitchingStationController: CustomDialogController = new CustomDialogController({
-    builder: SwitchingStationDialog({
-      currentStation:this.currentStation,
-      currentPLCode:this.currentPLCode,
-      currentStationId:this.currentStationId
-    }),
+    builder: SwitchingStationDialog({}),
     autoCancel: true, // 点击遮罩关闭
     customStyle: true,
     maskColor: 'rgba(0,0,0,0.8)',  // 黑色遮罩
   })
-
+  //切换用户弹窗控制器
   switchingUserController: CustomDialogController = new CustomDialogController({
-    builder: SwitchingUserDialog({
-      currentOrgId:this.currentOrgId,
-      currentPLCode:this.currentPLCode,
-      currentStationId:this.currentStationId,
-      currentUserName:this.currentUserName
-    }),
+    builder: SwitchingUserDialog({}),
     autoCancel: true, // 点击遮罩关闭
     customStyle: true,
     maskColor: 'rgba(0,0,0,0.8)',  // 黑色遮罩
   })
-
+  // 切换产品弹窗控制器
   switchingProductDialogController: CustomDialogController = new CustomDialogController({
     builder: SwitchingProductDialog({
       scanSeqValue: this.scanCode
@@ -194,14 +129,23 @@ struct ProcessIndex {
 
 
   handleAllClick():void {
+    if (!this.selectWorkOder.workOrderCode || !this.currentUserName || !this.currentStationId) {
+      return
+    }
     this.onQueryTask([])
   }
 
   handleReportedClick():void{
+    if (!this.selectWorkOder.workOrderCode || !this.currentUserName || !this.currentStationId) {
+      return
+    }
     this.onQueryTask([2])
   }
 
   handleUnreportedClick():void{
+    if (!this.selectWorkOder.workOrderCode || !this.currentUserName || !this.currentStationId) {
+      return
+    }
     this.onQueryTask([-1,0,1])
   }
 
@@ -307,11 +251,11 @@ struct ProcessIndex {
           Row() {
             Row().width('5.6%')
             Column() {
-              Text(CommonConstants.STATION_NANE)
+              Text(this.currentStation)
                 .fontSize($r('app.float.fontSize_16'))
                 .fontWeight(FontWeight.Regular)
                 .fontColor($r('app.color.FFFFFF'))
-              Text(CommonConstants.USER_NAME)
+              Text(this.currentUserName)
                 .fontSize($r('app.float.fontSize_12'))
                 .fontWeight(FontWeight.Lighter)
                 .fontColor($r('app.color.FFFFFF'))
@@ -341,6 +285,9 @@ struct ProcessIndex {
           .height('8.1%')
           .backgroundColor($r('app.color.20FFFFFF'))
           .borderRadius($r('app.float.fontSize_16'))
+          .onClick(()=>{
+            this.StationInfoController.open()
+          })
           // 工序
           Column({space: 4}) {
             Row() {
@@ -394,6 +341,9 @@ struct ProcessIndex {
                     .backgroundImage(this.selectOperationId === item.operationId ? $r('app.media.process_select_operation') : $r('app.media.process_no_select_operation'))
                     .backgroundImageSize(ImageSize.Cover)
                     .onClick(() => {
+                      if (!this.selectWorkOder.workOrderCode || !this.currentUserName || !this.currentStationId) {
+                        return
+                      }
                       this.selectOperationId = item.operationId!
                       if (!item.exists) {
                         promptAction.showToast({
@@ -433,7 +383,7 @@ struct ProcessIndex {
           .height('77.2%')
           .backgroundColor($r('app.color.20FFFFFF'))
           .borderRadius($r('app.float.fontSize_16'))
-          .opacity(!this.seqNo || !CommonConstants.USER_ID || !CommonConstants.STATION_ID ? 0.3 : 1)
+          .opacity(!this.selectWorkOder.workOrderCode || !this.currentUserName || !this.currentStationId ? 0.3 : 1)
         }
         .height('100%')
         .width('19.8%')
@@ -509,9 +459,15 @@ struct ProcessIndex {
                     .fontColor($r('app.color.FFFFFF'))
                     .enableKeyboardOnFocus(false)
                     .onChange((value: string) => {
+                      if (!this.selectWorkOder.workOrderCode || !this.currentUserName || !this.currentStationId) {
+                        return
+                      }
                       this.scanCode = value
                     })
                     .onSubmit(async () => {
+                      if (!this.selectWorkOder.workOrderCode || !this.currentUserName || !this.currentStationId) {
+                        return
+                      }
                       this.opComponents = await ProcessRequest.get('/api/v1/op/compent/get/' + this.selectOperationId)
                     })
                 }
@@ -533,7 +489,7 @@ struct ProcessIndex {
           .justifyContent(FlexAlign.Center)
           .backgroundColor($r('app.color.20FFFFFF'))
           .borderRadius($r('app.float.fontSize_16'))
-          .opacity(!this.seqNo || !CommonConstants.USER_ID || !CommonConstants.STATION_ID ? 0.3 : 1)
+          .opacity(!this.selectWorkOder.workOrderCode || !this.currentUserName || !this.currentStationId ? 0.3 : 1)
         } else {
           Column() {
             List ({space: 4}) {
@@ -699,7 +655,7 @@ struct ProcessIndex {
           .backgroundColor($r('app.color.20FFFFFF'))
           .borderRadius($r('app.float.fontSize_16'))
           .onClick(()=>{
-            if (!this.seqNo || !CommonConstants.USER_ID || !CommonConstants.STATION_ID) {
+            if (!this.selectWorkOder.workOrderCode || !this.currentUserName || !this.currentStationId) {
               return
             }
             this.switchingProductDialogController.open()
@@ -759,7 +715,7 @@ struct ProcessIndex {
         .height('90.6%')
         .width('100%')
         .padding({left: '2.6%', right: '2.6%'})
-        .opacity(!this.seqNo || !CommonConstants.USER_ID || !CommonConstants.STATION_ID ? 0.3 : 1)
+        .opacity(!this.selectWorkOder.workOrderCode || !this.currentUserName || !this.currentStationId ? 0.3 : 1)
       }
       .width('100%')
       .height('9.8%')

+ 8 - 3
entry/src/main/ets/view/SelectOrderDialog.ets

@@ -4,7 +4,7 @@ import WorkOrderInfo from '../viewmodel/WorkOrderInfo'
 import { WorkOrderPage } from '../viewmodel/WorkOrderPage'
 
 @CustomDialog
-export struct SelectOrderDialog {
+export struct SelectWorkOrderDialog {
   private scrollerMaterial: Scroller = new Scroller()
   //工单列表
   @State workOrderList: WorkOrderInfo[] = []
@@ -12,6 +12,7 @@ export struct SelectOrderDialog {
   @State selectedOrderIndex: number = -1
   //扫描的工单号
   @State scanOrderValue:string = ''
+  @Link selectWorkOder: WorkOrderInfo
   controller: CustomDialogController
   onConfirm: () => void = () => {
   }
@@ -58,8 +59,11 @@ export struct SelectOrderDialog {
           .fontSize($r('app.float.fontSize_30'))
           .fontColor($r('app.color.FFFFFF'))
           .enableKeyboardOnFocus(false)
-          .onSubmit(() => {
-
+          .onSubmit(async () => {
+            let queryRes = await ProcessRequest.post('/api/v1/plan/workOrder/taskPage', {
+              queryCode:this.scanOrderValue
+            } as RequestParamModel) as WorkOrderPage;
+            this.workOrderList = queryRes?.records??[]
           })
           .onChange((value: string) => {
             this.scanOrderValue = value;
@@ -195,6 +199,7 @@ export struct SelectOrderDialog {
           .onClick(() => {
             if(this.selectedOrderIndex==-1) return
             this.onConfirm();
+            this.selectWorkOder = this.workOrderList[this.selectedOrderIndex]
             this.controller.close();
           })
         }

+ 8 - 6
entry/src/main/ets/view/StationInfoDialog.ets

@@ -8,15 +8,15 @@ import { SwitchingStationDialog } from './SwitchingStationViews'
 export struct StationInfoDialog{
   private scrollerList: Scroller = new Scroller()
   //当前工位
-  @Link currentStation:string
+  @Consume('currentStation') currentStation:string
   //当前部门
-  @Link currentDept:string
+  @Consume('currentDept') currentDept:string
   //当前产线
-  @Link currentProductLine:string
+  @Consume('currentProductLine') currentProductLine:string
   //当前产线code
-  @Link currentPLCode:string
+  @Consume('currentPLCode') currentPLCode:string
   //当前用户
-  @Link currentUserName:string
+  @Consume('currentUserName') currentUserName:string
   //全部已读按钮缩放
   @State allReadClick:number = 1
   //消息列表
@@ -89,7 +89,9 @@ export struct StationInfoDialog{
   }
 
   aboutToAppear(): void {
-    this.loadStationMessage()
+    if (this.currentUserName) {
+      this.loadStationMessage()
+    }
   }
 
   build() {

+ 14 - 7
entry/src/main/ets/view/SwitchingStationViews.ets

@@ -8,9 +8,14 @@ import RequestParamModel from '../viewmodel/RequestParamModel'
 export struct SwitchingStationDialog{
   private scrollerList: Scroller = new Scroller()
   //当前工位
-  @Link currentStation:string
-  @Link currentPLCode:string
-  @Link currentStationId:string
+  @Consume('currentStation') currentStation:string
+  //当前部门
+  @Consume('currentDept') currentDept:string
+  //当前产线code
+  @Consume('currentPLCode') currentPLCode:string
+  // 当前工位id
+  @Consume('currentStationId') currentStationId:string
+
   @State selectStationIndex: number = -1
   //工位列表
   @State stationsList : WorkstationInfo[]=[]
@@ -121,8 +126,9 @@ export struct SwitchingStationDialog{
 export struct SwitchingProductLineDialog{
   private scrollerList: Scroller = new Scroller()
   //当前产线
-  @Link currentProductLine:string
-  @Link currentPLCode:string
+  @Consume('currentProductLine') currentProductLine:string
+  //当前产线code
+  @Consume('currentPLCode') currentPLCode:string
 
   @State selectProductLineIndex: number = -1
   //产线列表
@@ -234,8 +240,9 @@ export struct SwitchingProductLineDialog{
 export struct SwitchingDeptDialog{
   private scrollerList: Scroller = new Scroller()
   //当前部门
-  @Link currentDept:string
-  @Link currentOrgId:number
+  @Consume('currentDept') currentDept:string
+  // 当前组织id
+  @Consume('currentOrgId') currentOrgId:number
 
   @State selectDeptIndex: number = -1
   //部门列表

+ 12 - 11
entry/src/main/ets/view/SwitchingUserDialog.ets

@@ -5,12 +5,16 @@ import RequestParamModel from '../viewmodel/RequestParamModel'
 
 @CustomDialog
 export struct SwitchingUserDialog {
-  @Link currentUserName : string
+  //当前用户
+  @Consume('currentUserName') currentUserName: string
+  @State userName: string = ''
   @State password : string = ''
-  @Prop currentOrgId:number = 0
-  @Prop currentPLCode:string = ''
-  @Prop currentStationId:string = ""
-
+  // 当前组织id
+  @Consume('currentOrgId') currentOrgId:number
+  //当前产线code
+  @Consume('currentPLCode') currentPLCode:string
+  // 当前工位id
+  @Consume('currentStationId') currentStationId:string
 
   controller: CustomDialogController
 
@@ -18,18 +22,18 @@ export struct SwitchingUserDialog {
     let token:string = await ProcessRequest.post('api/auth/aioLogin', {
       orgId:this.currentOrgId,
       password: this.password,
-      userName: this.currentUserName,
+      userName: this.userName,
       proCode: this.currentPLCode,
       stationId: this.currentStationId
       } as RequestParamModel) ;
     if (!token || token.length == 0)  return
     CommonConstants.AUTH_TOKEN = token
+    this.currentUserName = this.userName
     // let res:object= await ProcessRequest.post('api/auth', {
     // } as RequestParamModel) ;
     this.controller.close()
 }
 
-
   build() {
     Column() {
       Column(){
@@ -62,8 +66,7 @@ export struct SwitchingUserDialog {
             .placeholderColor($r('app.color.30FFFFFF'))
             .fontColor($r('app.color.FFFFFF'))
             .onChange((value: string) => {
-              this.currentUserName = value;
-
+              this.userName = value;
             })
         }
         .backgroundColor($r('app.color.000000'))
@@ -93,7 +96,6 @@ export struct SwitchingUserDialog {
             .type(InputType.Password)
             .onChange((value: string) => {
               this.password = value;
-
             })
         }
         .width('70%')
@@ -121,7 +123,6 @@ export struct SwitchingUserDialog {
           .width('50%')
           .onClick(() => {
             this.controller.close()
-            this.currentUserName=''
           })
           Divider()
             .vertical(true)

+ 62 - 51
entry/src/main/ets/view/process/MaterialCollectView.ets

@@ -1,55 +1,16 @@
 import ProcessRequest from '../../common/util/request/ProcessRequest'
 import OperationItem from '../../viewmodel/OperationItem'
 import ProcessInfo from '../../viewmodel/process/ProcessInfo'
+import ProcessMaterial from '../../viewmodel/process/ProcessMaterial'
 import RequestParamModel from '../../viewmodel/RequestParamModel'
 import WorkOrderInfo from '../../viewmodel/WorkOrderInfo'
+import promptAction from '@ohos.promptAction'
 
 @Component
 export struct MaterialCollectView {
   @State scanCode: string = ''
   // 需要采集的工序物料
-  @State itemArray: OperationItem[] = [
-    {
-      batchNo:'',
-      itemCode:'Y11P-1210ZJ10',
-      itemModel:'Y11P-1210ZJ10',
-      itemName:'控制连接器插座',
-      needNum:6.0,
-      operationId:'679',
-      processId:'',
-      realNum:1.0,
-      workOrderCode:'10.25.0022'
-    },{
-      batchNo:'',
-      itemCode:'Y11P-0804ZJ10-2',
-      itemModel:'Y11P-0804ZJ10-2',
-      itemName:'电源连接器插座',
-      needNum:5.0,
-      operationId:'679',
-      processId:'',
-      workOrderCode:'10.25.0022'
-    },
-    {
-      batchNo:'',
-      itemCode:'Y11P-1210ZJ10',
-      itemModel:'Y11P-1210ZJ10',
-      itemName:'控制连接器插座',
-      needNum:6.0,
-      operationId:'679',
-      processId:'',
-      realNum:1.0,
-      workOrderCode:'10.25.0022'
-    },{
-    batchNo:'',
-    itemCode:'Y11P-0804ZJ10-2',
-    itemModel:'Y11P-0804ZJ10-2',
-    itemName:'电源连接器插座',
-    needNum:5.0,
-    operationId:'679',
-    processId:'',
-    workOrderCode:'10.25.0022'
-  },
-  ]
+  @State itemArray: OperationItem[] = []
   // 总需求数
   @State needNum: number = 100
   // 实际数量(已采集数)
@@ -65,6 +26,15 @@ export struct MaterialCollectView {
   // 扫码开工后的生产过程信息
   @Link process: ProcessInfo
 
+  // modifyMaterialNumDialogController: CustomDialogController = new CustomDialogController({
+  //   builder: ModifyMaterialNumDialog({
+  //
+  //   }),
+  //   autoCancel: true, // 点击遮罩关闭
+  //   customStyle: true,
+  //   maskColor: 'rgba(0,0,0,0.8)',  // 黑色遮罩
+  // })
+
   async aboutToAppear() {
     if (this.scanState === 1) {
       this.itemArray = await ProcessRequest.post('/api/v1/process/itemRecord/list', {
@@ -105,11 +75,38 @@ export struct MaterialCollectView {
             .fontSize($r('app.float.fontSize_30'))
             .fontColor($r('app.color.FFFFFF'))
             .enableKeyboardOnFocus(false)
-            .onSubmit(() => {
+            .onSubmit(async () => {
+              let result: ProcessMaterial[] = await ProcessRequest.post('/api/v1/process/itemRecord/searchMaterial', {
+              operationId: this.selectOperationId,
+              processId: this.process.id!,
+              seqNo: this.seqNo,
+              scanCode: this.scanCode,
+              workOrderCode: this.selectWorkOder.workOrderCode!} as RequestParamModel)
+              if (result && result.length > 0) {
+                if (result[0].num! <= 0) {
+                  promptAction.showToast({
+                    message: `${result[0].batchNo!}批次物料已用完`,
+                    duration: 1500,
+                    bottom: 100
+                  })
+                }
+                for (const element of result) {
+                  element.operationId = this.selectOperationId
+                  element.processId = this.process.id!
+                  element.seqNo = this.seqNo
+                  element.workOrderCode = this.selectWorkOder.workOrderCode!
+                  element.trackBy = 'S'
+                  element.itemSeq = this.scanCode
+                }
+                if ('BATCH' === result[0].codeType!) {
 
+                } else {
+                  await ProcessRequest.post('/api/v1/process/itemRecord/add', result)
+                }
+              }
             })
             .onChange((value: string) => {
-
+              this.scanCode = value
             })
         }
         .height('52.8%')
@@ -122,11 +119,6 @@ export struct MaterialCollectView {
             .fontColor($r('app.color.FFFFFF'))
             .fontSize($r('app.float.fontSize_16'))
             .fontWeight(FontWeight.Regular)
-          // Progress({ value: this.realNum, total: this.needNum, type: ProgressType.Linear })
-          //   .width('100%')
-          //   .color($r('app.color.0A84FF'))
-          //   .backgroundColor($r('app.color.15FFFFFF'))
-          //   .borderRadius($r('app.float.virtualSize_32'))
           Row() {
             Row()
               .width(((this.realNum * 100)/ this.needNum).toFixed(2) + '%')
@@ -188,8 +180,27 @@ export struct MaterialCollectView {
               .height('45.8%')
               .width('100%')
               .justifyContent(FlexAlign.End)
-
-
+              Row() {
+                Text(item.codeTypeStr ? item.codeTypeStr : '')
+                  .fontSize($r('app.float.fontSize_16'))
+                  .fontWeight(FontWeight.Regular)
+                  .fontColor($r('app.color.FFFFFF'))
+                Row() {
+                  Text((item.realNum ? item.realNum : 0) + '/')
+                    .fontSize($r('app.float.fontSize_38'))
+                    .fontWeight(FontWeight.Lighter)
+                    .fontColor($r('app.color.FFFFFF'))
+                  Text((item.needNum ? item.needNum : 0) + item.unit!)
+                    .fontSize($r('app.float.fontSize_38'))
+                    .fontWeight(FontWeight.Lighter)
+                    .fontColor($r('app.color.FFFFFF'))
+                    .opacity(0.6)
+                }
+              }
+              .height('42.2%')
+              .width('91%')
+              .justifyContent(FlexAlign.SpaceBetween)
+              .alignItems(VerticalAlign.Bottom)
             }
             .width('32.8%')
             .height('25.2%')

+ 2 - 0
entry/src/main/ets/viewmodel/OperationItem.ets

@@ -26,4 +26,6 @@ export default class OperationItem {
   processId?: string;
   // 工单编码(生产过程)
   workOrderCode?: string;
+  //序列号/批次号
+  codeTypeStr?: string;
 }

+ 2 - 0
entry/src/main/ets/viewmodel/RequestParamModel.ets

@@ -78,4 +78,6 @@ export default class RequestParamModel {
   ids?:string[]
   //载具绑定工序id
   vehicleOperationId?:string
+  //扫描码
+  scanCode?:string
 }

+ 83 - 0
entry/src/main/ets/viewmodel/process/ProcessMaterial.ets

@@ -0,0 +1,83 @@
+// 生产过程物料信息
+export default class ProcessMaterial {
+  // 主键
+  id?: string;
+  // 物料编码
+  materialCode?: string;
+  // 物料名称
+  materialName?: string;
+  // 物料属性字典code
+  attributeDictCode?: string;
+  // 物料属性字典value
+  attributeDictValue?: string;
+  // 物料规格
+  spec?: string;
+  // 物料单位字典code
+  unitDictCode?: string;
+  // 物料单位字典value
+  unitDictValue?: string;
+  // 物料级别字典code
+  levelDictCode?: string;
+  // 物料级别字典value
+  levelDictValue?: string;
+  // 生产厂家
+  manufacturer?: string;
+  // 质检方案字典code
+  inspectDictCode?: string;
+  // 质检方案字典value
+  inspectDictValue?: string;
+  // 适用平台字典code
+  applicablePlatformsDictCode?: string;
+  // 适用平台字典value
+  applicablePlatformsDictValue?: string;
+  // 质量等级字典code
+  qualityLevelDictCode?: string;
+  // 质量等级字典value
+  qualityLevelDictValue?: string;
+  // 选用类型字典code
+  selectionDictCode?: string;
+  // 选用类型字典value
+  selectionDictValue?: string;
+  // 阶段字典code
+  stageDictCode?: string;
+  // 阶段字典value
+  stageDictValue?: string;
+  // 客户型号
+  customerModel?: string;
+  // 保质期
+  qualityGuaranteePeriod?: number;
+  // 封装方法字典code
+  packageDictCode?: string;
+  // 封装方法字典value
+  packageDictValue?: string;
+  // 是否工装
+  frock?: number;
+  // 筛选规范
+  selectionSpec?: string;
+  // 备注
+  remark?: string;
+  // 还需要多少数量
+  needNum?: number;
+  // 总数量
+  totalNum?: number;
+  // 扫码数量
+  num?: number;
+  // SEQ/BATCH(流水号/批次号)
+  codeType?: string;
+  // 批次号
+  batchNo?: string;
+  // 物料序列号
+  itemSeq?: string;
+  // 追溯类型
+  trackType?: string;
+  // 采集人
+  trackBy?: string;
+  // 工单编码
+  workOrderCode?: string;
+  // 工序id
+  operationId?: string;
+  // 生产过程id
+  processId?: string;
+  // 流转卡号
+  seqNo?: string;
+}