|
@@ -1,26 +1,43 @@
|
|
|
/*
|
|
|
* 零星物料入库
|
|
|
* */
|
|
|
-import {ProcessFlow,BoxGrid,MaterialListComponent} from "../component/OrderMaterialsStorageView"
|
|
|
+import {ProcessFlow,BoxGrid,MaterialListComponent,RemindDialog} from "../component/OrderMaterialsStorageView"
|
|
|
import {OrderParams,MaterialBox, EmptyBox} from "../params/OrderMaterialsStorageParams"
|
|
|
import router from '@ohos.router';
|
|
|
+import RobotErrorHandleRequest from '../common/util/request/RobotErrorHandleRequest'
|
|
|
+import RequestParamModel from '../viewmodel/wms/RequestParamModel'
|
|
|
+import {CommonConfirmDialog}from "../component/OrderMaterialsStorageView"
|
|
|
+import {ConfirmDialogParams} from "../params/OrderMaterialsStorageParams"
|
|
|
+import WorkOrderInfo from '../viewmodel/wms/WorkOrderInfo'
|
|
|
+import CommonConstants from '../common/constants/CommonConstants'
|
|
|
+import WmsRequest from '../common/util/request/WmsRequest'
|
|
|
+import {RgvInfo} from "../params/RobotsParam"
|
|
|
import {NavigationBar} from '../component/NavigationBar'
|
|
|
import {TimeAndTitle} from "../component/TimeAndTitle"
|
|
|
import {InBoundView} from '../component/InBoundView'
|
|
|
-import {MaterialListInformation,MaterialBoxInfo} from '../params/MaterialInformationParam'
|
|
|
+import {outBoxClass,materialsInfo,MaterialBoxInfo} from '../params/MaterialInformationParam'
|
|
|
+const TAG = 'LittleMaterialInbound';
|
|
|
@Entry
|
|
|
@Component
|
|
|
struct LittleMaterialsStorage{
|
|
|
@State materialNum:number=0
|
|
|
@State currentStep: number = 1;
|
|
|
@State emptyBoxes: MaterialBoxInfo[] = []
|
|
|
+ @State scanBoxValue:string = ''
|
|
|
+ @State scanMaterialValue:string = ''
|
|
|
@State selectedMaterialBox: MaterialBoxInfo = {};
|
|
|
@State isQueryMaterial : boolean = false
|
|
|
@State nextStepButtonClick :number = 1
|
|
|
@State preStepButtonClick :number = 1
|
|
|
@State outBoundButtonClick :number = 1
|
|
|
@State materialBoxes: MaterialBoxInfo[] = [];
|
|
|
- @State orders:OrderParams[]= [
|
|
|
+ @State queryMaterialBoxNum:number = 0
|
|
|
+ @State ScanMaterialList:WorkOrderInfo[] = []
|
|
|
+ @State reminds:string=''
|
|
|
+ @State queryTargetMaterial:materialsInfo={}
|
|
|
+ @StorageLink('materialBoxWeight') materialBoxWeight: number =0;
|
|
|
+ @StorageLink('drawerPositionStatus') drawerPositionStatus: number=1 ;
|
|
|
+ @State orders: OrderParams[] = [
|
|
|
{ orderName: '订单名称XXXXX', orderNo: '123123213', date: '2025/11/11', progress: '50%' },
|
|
|
{ orderName: '订单名称XXXX', orderNo: '123123213', date: '2025/11/11', progress: '75%' },
|
|
|
{ orderName: '特殊订单', orderNo: 'SH2024001', date: '2024/03/01', progress: '100%' },
|
|
@@ -28,6 +45,131 @@ struct LittleMaterialsStorage{
|
|
|
{ orderName: '订单名称XXXX', orderNo: '123123213', date: '2025/11/11', progress: '75%' },
|
|
|
{ orderName: '特殊订单', orderNo: 'SH2024001', date: '2024/03/01', progress: '100%' }
|
|
|
]
|
|
|
+ remindController: CustomDialogController = new CustomDialogController({
|
|
|
+ builder: RemindDialog({
|
|
|
+ remind: this.reminds,}
|
|
|
+ ),
|
|
|
+ customStyle: true,
|
|
|
+ maskColor: 'rgba(0,0,0,0.6)',
|
|
|
+ //autoCancel:false
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //扫描物料编码
|
|
|
+ ScanMaterialCode = async (itemCode: string) => {
|
|
|
+ try{
|
|
|
+ this.scanMaterialValue = ""
|
|
|
+ let res: WorkOrderInfo = await WmsRequest.post("/api/v1/process/circulation/material", {
|
|
|
+ label: `BM${itemCode};18*18*1-6;SL50;20240111` //"#gys022#sc022#100#20220929#31"
|
|
|
+ } as RequestParamModel)
|
|
|
+
|
|
|
+ // 验证1:检查是否已在扫描列表中
|
|
|
+ const isDuplicate = this.ScanMaterialList.some(
|
|
|
+ item => item.materialCode === res.materialCode
|
|
|
+ );
|
|
|
+ if (isDuplicate) {
|
|
|
+ console.warn(`物料 ${res.materialCode} 已存在,无法重复添加`);
|
|
|
+ this.reminds="物料已存在!"
|
|
|
+ this.remindController.open()
|
|
|
+ setTimeout(() => {
|
|
|
+ this.remindController.close();
|
|
|
+ }, 2000);
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.ScanMaterialList = [...this.ScanMaterialList, res];
|
|
|
+ this.materialNum = this.ScanMaterialList.length; // 更新物料数量统计
|
|
|
+ }catch (err) {
|
|
|
+ console.error(TAG, `http ScanMaterialCode failed: ${JSON.stringify(err)}`);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ async queryRgvInfo(): Promise<boolean> {
|
|
|
+ let res: RgvInfo = await RobotErrorHandleRequest.get('/api/v1/wcs/rgv/rgv1', {}) as RgvInfo;
|
|
|
+ if (res) {
|
|
|
+ if (res.status != '0' || res.x != res.rx || res.y != res.ry) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true; // 如果条件不满足,返回 true
|
|
|
+ }
|
|
|
+ return false; // 如果 res 为 null 或 undefined,返回 false
|
|
|
+ }
|
|
|
+
|
|
|
+ getMaterialBoxList = async (currentMaterialNo: string) => {
|
|
|
+ this.queryTargetMaterial = {}
|
|
|
+ this.queryMaterialBoxNum = 0
|
|
|
+ this.scanBoxValue = ''
|
|
|
+ this.materialBoxes = await WmsRequest.post("/api/v1/stock/groupList", {
|
|
|
+ materialNo: currentMaterialNo,
|
|
|
+ } as RequestParamModel);
|
|
|
+ if (this.materialBoxes.length == 0) {
|
|
|
+ this.reminds = "无当前物料料箱!"
|
|
|
+ this.remindController.open()
|
|
|
+ setTimeout(() => {
|
|
|
+ this.remindController.close();
|
|
|
+ }, 2000); // 2000毫秒 = 2秒
|
|
|
+ } else {
|
|
|
+ this.isQueryMaterial = true;
|
|
|
+ this.queryMaterialBoxNum = this.materialBoxes.length
|
|
|
+ if (this.materialBoxes[0]?.materials) {
|
|
|
+ this.queryTargetMaterial = this.materialBoxes[0].materials.find(
|
|
|
+ (material) => material.materialNo === currentMaterialNo
|
|
|
+ ) || {} as materialsInfo; // 如果找不到就使用空对象
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ commonDialogController: CustomDialogController | null = null;
|
|
|
+ private showConfirmDialog(params: ConfirmDialogParams) {
|
|
|
+ if (this.commonDialogController) {
|
|
|
+ this.commonDialogController.close()
|
|
|
+ }
|
|
|
+
|
|
|
+ this.commonDialogController = new CustomDialogController({
|
|
|
+ builder: CommonConfirmDialog({
|
|
|
+ title: params.title || '提示',
|
|
|
+ message: params.message,
|
|
|
+ confirmText: params.confirmText || '确定',
|
|
|
+ cancelText: params.cancelText || '取消',
|
|
|
+ onConfirm: params.onConfirm
|
|
|
+ }),
|
|
|
+ cancel: () => console.log('用户取消操作'),
|
|
|
+ customStyle: true,
|
|
|
+ autoCancel:false,
|
|
|
+ maskColor: 'rgba(0,0,0,0.6)'
|
|
|
+ });
|
|
|
+
|
|
|
+ this.commonDialogController.open();
|
|
|
+ }
|
|
|
+
|
|
|
+ boxOutBound = async () => {
|
|
|
+ try {
|
|
|
+ const res: outBoxClass = await WmsRequest.post("/api/v1/wmsOrder/outBox", {
|
|
|
+ houseNo: this.selectedMaterialBox?.houseNo,
|
|
|
+ vehicleNo: this.selectedMaterialBox?.vehicleCode,
|
|
|
+ stanCode: CommonConstants.STATION_CODE
|
|
|
+ } as RequestParamModel);
|
|
|
+ this.reminds="正在出库中,请稍等..."
|
|
|
+ this.remindController.open()
|
|
|
+ const checkInterval = setInterval(() => {
|
|
|
+ if (this.materialBoxWeight > 0) {
|
|
|
+ clearInterval(checkInterval); // 停止轮询
|
|
|
+ // this.getEmptyBox();
|
|
|
+ this.remindController.close(); // 关闭弹窗
|
|
|
+ }
|
|
|
+ }, 500); // 每500毫秒检查一次
|
|
|
+ setTimeout(() => {
|
|
|
+ clearInterval(checkInterval);
|
|
|
+ }, 300000);
|
|
|
+ } catch (error) {
|
|
|
+ this.reminds="出库失败..."
|
|
|
+ this.remindController.open()
|
|
|
+ setTimeout(() => {
|
|
|
+ this.remindController.close();
|
|
|
+ }, 2000);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
build() {
|
|
|
Row() {
|
|
|
Column() {
|
|
@@ -98,13 +240,19 @@ struct LittleMaterialsStorage{
|
|
|
.fillColor($r('app.color.FFFFFF'))
|
|
|
.margin({left:'2%'})
|
|
|
// 扫码输入框
|
|
|
- TextInput({ placeholder: '请扫描物料编码' })
|
|
|
+ TextInput({ text:this.scanBoxValue,placeholder: '请扫描物料编码' })
|
|
|
.type(InputType.Normal)
|
|
|
.placeholderFont({ size: $r('app.float.fontSize_12')})
|
|
|
.placeholderColor($r('app.color.30FFFFFF'))
|
|
|
.fontSize($r('app.float.fontSize_12'))
|
|
|
.fontColor($r('app.color.FFFFFF'))
|
|
|
.enableKeyboardOnFocus(false)
|
|
|
+ .onSubmit(() => {
|
|
|
+ this.getMaterialBoxList(this.scanBoxValue)
|
|
|
+ })
|
|
|
+ .onChange((value: string) => {
|
|
|
+ this.scanBoxValue = value
|
|
|
+ })
|
|
|
}
|
|
|
.margin({top:'3%'})
|
|
|
.height('8%')
|
|
@@ -125,26 +273,29 @@ struct LittleMaterialsStorage{
|
|
|
.height($r('app.float.virtualSize_23'))
|
|
|
.fillColor($r('app.color.FFFFFF'))
|
|
|
Column({space:5}){
|
|
|
- Text('DIANLUBANPCBAADD123124114232423ASD')
|
|
|
- .fontSize($r('app.float.fontSize_12'))
|
|
|
- .fontColor($r('app.color.0A84FF'))
|
|
|
- .textAlign(TextAlign.Start)
|
|
|
- .width('100%')
|
|
|
- Text('产品型号:12322221232321222332211233')
|
|
|
- .fontSize($r('app.float.fontSize_8'))
|
|
|
- .fontColor($r('app.color.0A84FF'))
|
|
|
- .textAlign(TextAlign.Start)
|
|
|
- .width('100%')
|
|
|
- Text('序列号:123254213452465346346456')
|
|
|
- .fontSize($r('app.float.fontSize_8'))
|
|
|
- .fontColor($r('app.color.0A84FF'))
|
|
|
- .textAlign(TextAlign.Start)
|
|
|
- .width('100%')
|
|
|
- Text('数量:10个')
|
|
|
- .fontSize($r('app.float.fontSize_8'))
|
|
|
- .fontColor($r('app.color.0A84FF'))
|
|
|
- .textAlign(TextAlign.Start)
|
|
|
- .width('100%')
|
|
|
+ if(this.isQueryMaterial)
|
|
|
+ {
|
|
|
+ Text(this.queryTargetMaterial.materialName)
|
|
|
+ .fontSize($r('app.float.fontSize_12'))
|
|
|
+ .fontColor($r('app.color.0A84FF'))
|
|
|
+ .textAlign(TextAlign.Start)
|
|
|
+ .width('100%')
|
|
|
+ Text(`型号:${this.queryTargetMaterial.materialNo}`)
|
|
|
+ .fontSize($r('app.float.fontSize_8'))
|
|
|
+ .fontColor($r('app.color.0A84FF'))
|
|
|
+ .textAlign(TextAlign.Start)
|
|
|
+ .width('100%')
|
|
|
+ Text(`序列号:${this.queryTargetMaterial.spec}`)
|
|
|
+ .fontSize($r('app.float.fontSize_8'))
|
|
|
+ .fontColor($r('app.color.0A84FF'))
|
|
|
+ .textAlign(TextAlign.Start)
|
|
|
+ .width('100%')
|
|
|
+ Text(`数量:${this.queryTargetMaterial.num}${this.queryTargetMaterial.unit}`)
|
|
|
+ .fontSize($r('app.float.fontSize_8'))
|
|
|
+ .fontColor($r('app.color.0A84FF'))
|
|
|
+ .textAlign(TextAlign.Start)
|
|
|
+ .width('100%')
|
|
|
+ }
|
|
|
}.backgroundColor($r('app.color.000000'))
|
|
|
.borderRadius($r('app.float.virtualSize_7_2'))
|
|
|
.padding(16)
|
|
@@ -155,7 +306,7 @@ struct LittleMaterialsStorage{
|
|
|
Text('当前有 ')
|
|
|
.fontSize($r('app.float.fontSize_8'))
|
|
|
.fontColor($r('app.color.60FFFFFF'))
|
|
|
- Text('6')
|
|
|
+ Text(`${this.queryMaterialBoxNum}`)
|
|
|
.fontSize($r('app.float.fontSize_12'))
|
|
|
.fontColor($r('app.color.0A84FF'))
|
|
|
Text(' 个料箱装有同型号物料')
|
|
@@ -179,6 +330,7 @@ struct LittleMaterialsStorage{
|
|
|
}.height('10%')
|
|
|
Row() {
|
|
|
BoxGrid({
|
|
|
+ isQueryEmpty:false,
|
|
|
materialBoxes:this.materialBoxes,
|
|
|
emptyBoxes:this.emptyBoxes,
|
|
|
isQueryMaterial:this.isQueryMaterial,
|
|
@@ -200,20 +352,59 @@ struct LittleMaterialsStorage{
|
|
|
}
|
|
|
.width('22%')
|
|
|
.height('100%')
|
|
|
- .backgroundColor($r('app.color.20FFFFFF'))
|
|
|
+ .backgroundColor(this.selectedMaterialBox.vehicleCode ?$r('app.color.20FFFFFF'):$r('app.color.10FFFFFF'))
|
|
|
.borderRadius($r('app.float.virtualSize_6_4'))
|
|
|
+ .enabled(!!this.selectedMaterialBox.vehicleCode) // 只有选中订单时才启用按钮
|
|
|
.scale({ x: this.outBoundButtonClick, y: this.outBoundButtonClick })
|
|
|
.animation({
|
|
|
duration: 200,
|
|
|
curve: Curve.Linear // 弹性曲线更生动
|
|
|
})
|
|
|
- //.enabled(!!this.selectedOrderNo) // 只有选中订单时才启用按钮
|
|
|
- .onClick(() => {
|
|
|
- this.outBoundButtonClick = 0.9; // 点击时缩小
|
|
|
+ .onClick(async() => {
|
|
|
+ this.outBoundButtonClick = 0.9;
|
|
|
setTimeout(() => {
|
|
|
- this.outBoundButtonClick = 1; // 0.2秒后恢复
|
|
|
+ this.outBoundButtonClick = 1;
|
|
|
}, 200);
|
|
|
- this.currentStep = 1;
|
|
|
+
|
|
|
+ //查询小车的状态
|
|
|
+ const rgvStatusNormal = await this.queryRgvInfo()
|
|
|
+ if(!rgvStatusNormal){
|
|
|
+ this.reminds = "小车状态异常或位置错误,请检查后重试"
|
|
|
+ this.remindController.open()
|
|
|
+ setTimeout(() => {
|
|
|
+ this.remindController.close()
|
|
|
+ }, 2000);
|
|
|
+ return
|
|
|
+ }
|
|
|
+ console.info("ssss"+this.drawerPositionStatus+"as")
|
|
|
+ if(this.drawerPositionStatus == 0)
|
|
|
+ {
|
|
|
+ this.reminds = "抽屉未缩回,请检查后重试"
|
|
|
+ this.remindController.open()
|
|
|
+ setTimeout(() => {
|
|
|
+ this.remindController.close()
|
|
|
+ }, 2000);
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if(this.materialBoxWeight > 0)
|
|
|
+ {
|
|
|
+ this.reminds = "抽屉已有料箱,请检查后重试"
|
|
|
+ this.remindController.open()
|
|
|
+ setTimeout(() => {
|
|
|
+ this.remindController.close()
|
|
|
+ }, 2000);
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询抽屉的状态
|
|
|
+ this.showConfirmDialog({
|
|
|
+ title: '料箱出库',
|
|
|
+ message: `确定要${this.selectedMaterialBox.vehicleCode}料箱出库吗?`,
|
|
|
+ onConfirm: ()=> {
|
|
|
+ this.boxOutBound();
|
|
|
+ }
|
|
|
+ });
|
|
|
})
|
|
|
Button({type:ButtonType.Normal}) {
|
|
|
Text("下一步")
|
|
@@ -234,8 +425,8 @@ struct LittleMaterialsStorage{
|
|
|
this.nextStepButtonClick = 0.9; // 点击时缩小
|
|
|
setTimeout(() => {
|
|
|
this.nextStepButtonClick = 1; // 0.2秒后恢复
|
|
|
+ this.currentStep = 2
|
|
|
}, 200);
|
|
|
- this.currentStep = 2
|
|
|
})
|
|
|
|
|
|
}.width('100%').height('6%').justifyContent(FlexAlign.End).margin({bottom:'3%',right:'5%'})
|
|
@@ -261,13 +452,19 @@ struct LittleMaterialsStorage{
|
|
|
.fillColor($r('app.color.FFFFFF'))
|
|
|
.margin({left:'2%'})
|
|
|
// 扫码输入框
|
|
|
- TextInput({ placeholder: '请扫描物料编码' })
|
|
|
+ TextInput({ text:this.scanMaterialValue,placeholder: '请扫描物料编码' })
|
|
|
.type(InputType.Normal)
|
|
|
.placeholderFont({ size: $r('app.float.fontSize_12')})
|
|
|
.placeholderColor($r('app.color.30FFFFFF'))
|
|
|
.fontSize($r('app.float.fontSize_12'))
|
|
|
.fontColor($r('app.color.FFFFFF'))
|
|
|
.enableKeyboardOnFocus(false)
|
|
|
+ .onSubmit(()=>{
|
|
|
+ this.ScanMaterialCode(this.scanMaterialValue)
|
|
|
+ })
|
|
|
+ .onChange((value: string) => {
|
|
|
+ this.scanMaterialValue = value
|
|
|
+ })
|
|
|
}.width('35%')
|
|
|
.borderRadius($r('app.float.virtualSize_7_2'))
|
|
|
.backgroundColor($r('app.color.000000'))
|
|
@@ -278,7 +475,7 @@ struct LittleMaterialsStorage{
|
|
|
|
|
|
Row() {
|
|
|
MaterialListComponent({
|
|
|
- ScanMaterialList:this.orders,
|
|
|
+ ScanMaterialList:this.ScanMaterialList,
|
|
|
materialNum:this.materialNum
|
|
|
}).width('95%')
|
|
|
}.width('100%').height('90%').justifyContent(FlexAlign.Center)
|
|
@@ -290,7 +487,10 @@ struct LittleMaterialsStorage{
|
|
|
.margin({left:'-2%',right:'-2%'})
|
|
|
|
|
|
Column(){
|
|
|
- InBoundView({materialNum:this.materialNum})
|
|
|
+ InBoundView({
|
|
|
+ materialNum:this.materialNum,
|
|
|
+ boxMaterials:this.ScanMaterialList
|
|
|
+ })
|
|
|
}.width('29%').backgroundColor($r('app.color.10FFFFFF'))
|
|
|
}
|
|
|
.height('85%')
|
|
@@ -318,8 +518,8 @@ struct LittleMaterialsStorage{
|
|
|
this.preStepButtonClick = 0.9; // 点击时缩小
|
|
|
setTimeout(() => {
|
|
|
this.preStepButtonClick = 1; // 0.2秒后恢复
|
|
|
+ this.currentStep = 1;
|
|
|
}, 200);
|
|
|
- this.currentStep = 1;
|
|
|
})
|
|
|
}.width('100%').height('6%').justifyContent(FlexAlign.Start).margin({bottom:'3%',left:'5%'})
|
|
|
}.height('83.6%').margin({top:'3%'}).width('100%')
|