12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067 |
- import EquipmentRequest from '../common/util/request/EquipmentRequest'
- import StorageRequest from '../common/util/request/StorageRequest'
- import { MaterialInformationModel } from '../model/MaterialInformation'
- import RequestParamModel from '../viewmodel/RequestParamModel'
- import { Materialpositionclass, ScanStorageclass } from './IntelligentWarehousingOutbound'
- import CommonConstants from '../common/constants/CommonConstants'
- import promptAction from '@ohos.promptAction'
- import { EmptyBoxInfoModel, StationInfoModel } from '../model/StorageSpace'
- import { outBoxClass } from './CompleteSet'
- export interface stat2 {
- statNo?: string
- //料箱编号
- rfid?: string
- //料箱检测的io位,1:有,0:没有
- io?: string
- //0:无锁定,1:锁定,即机器人正在动作,不能进出库动作
- lock?: string
- ts?: string
- RFID?: string
- UID?: string
- kg?: number
- }
- @Entry
- @Component
- export struct ManualWarehousing {
- //料箱等级(类型)
- @State vehicleLevel: string = ''
- // 叫空料箱数量
- @State callBoxNum: number = 1
- //取空箱子
- @State emptyBox: number = 0
- //更改的数量
- @State exchangeNumber: number = 0
- //料箱中的物料信息
- @State private boxMaterials: Array<MaterialInformationModel> = []
- //定义物料信息
- @State private MaterialInformation: Array<MaterialInformationModel> = []
- ///料箱状态
- @State materialBox: number = 0
- // 中间输入框绑定的值
- @State scanCodeValue: string = ""
- @State materialNo: string = ''
- @State materialModel: string =''
- //1:抽屉在料格内 0:抽屉在料格外
- @State drawerPositionStatus: number = 1
- //入库口料格状态(1:有料箱 0:无料箱)
- @State materialGridStatus: number = 0
- //选中取出的物料位置
- @State materialPosition: Materialpositionclass = {}
- //需要展示和更改的物料信息
- @State index: number = 0
- @State batchCode: string = ''
- @State materialName: string = ''
- @State imgSrc:Resource = $r('app.media.drawer_inside')
- //齐套料箱状态不可以点击:0,可以点击:1
- @State completeSetMaterialState: number = 0
- @State num: number = 0
- //点击颜色
- @State onclick: number = -1
- @State seqNo: string = ''
- //物料编码
- @State materialCode: string = ''
- @State spec: string = ''
- //扫码控制器
- textController: TextInputController = new TextInputController()
- //齐套料箱重量
- @State BoxWeight: number = 20
- @State private recentlyRecordObject: StationInfoModel = {}
- currentTimer: number = -1;
- //设置img图片路径
- setImgSrc = ()=>{
- if(this.drawerPositionStatus == 1 && this.materialGridStatus == 0){
- this.imgSrc = $r('app.media.drawer_inside')
- }else if(this.drawerPositionStatus == 0 && this.materialGridStatus == 0){
- this.imgSrc = $r('app.media.drawer_outside')
- }
- else if(this.drawerPositionStatus === 1 && this.materialGridStatus === 1){
- this.imgSrc = $r('app.media.D_W_inside')
- }
- else if(this.drawerPositionStatus === 0 && this.materialGridStatus === 1) {
- this.imgSrc = $r('app.media.D_W_outside')
- }
- }
- //扫码请求
- ScanStorageCode = async (itemCode: string) => {
- this.scanCodeValue = ""
- let res: MaterialInformationModel = await StorageRequest.post("/api/v1/process/circulation/material", {
- label: itemCode //"#gys022#sc022#100#20220929#31"
- } as MaterialInformationModel)
- //let res = await StorageRequest.get("/api/v3/stock/selectSafeList/1")
- // {"batchCode":"BM47111400130447;SL5","codeType":"BATCH","materialCode":"47111400130447","materialName":"穿心电容","num":5,"spec":"G CT52-4-1-2C1-63V-103-M","unitDictLabel":"个","unitDictValue":"个"}
- let obj: MaterialInformationModel = JSON.parse(JSON.stringify(res))
- // 扫码完成之后,如果数组中有对应的值,就添加数量否则就push
- let toPushArray: MaterialInformationModel[] = [...this.MaterialInformation]
- let has = false
- for (let i = 0; i < toPushArray.length; i++) {
- let box = toPushArray[i]
- if (obj.materialCode == box.materialCode) {
- let number = obj.num! + box.num!
- box.num = number
- has = true
- }
- }
- if (!has) {
- toPushArray.push(JSON.parse(JSON.stringify(obj)))
- }
- this.MaterialInformation = [...toPushArray]
- }
- //RFID卡读取失败弹窗
- RfidCarController: CustomDialogController = new CustomDialogController({
- builder: RfidCar({}),
- alignment: DialogAlignment.Center,
- gridCount: 4,
- customStyle: true,
- })
- //物料详情弹窗
- materialDetailsController: CustomDialogController = new CustomDialogController({
- builder: materialDetails({
- exchangeNumber: this.exchangeNumber,
- MaterialInformation: this.MaterialInformation,
- index: this.index,
- batchCode: this.batchCode,
- materialName: this.materialName,
- num: this.num,
- seqNo: this.seqNo,
- spec: this.spec,
- materialNo: this.materialNo,
- materialModel:this.materialModel
- }),
- alignment: DialogAlignment.Bottom,
- gridCount: 4,
- customStyle: true,
- })
- //获取RFID信息
- locationRequest = async (): Promise<StationInfoModel> => {
- let res: StationInfoModel = await StorageRequest.post("api/v1/wms/common/queryStationInfo", {
- stanCode: CommonConstants.STATION_CODE
- } as RequestParamModel)
- this.recentlyRecordObject = res
- if(!this.recentlyRecordObject.rfid){
- this.boxMaterials = []
- }
- this.materialGridStatus = 0
- if (this.recentlyRecordObject && this.recentlyRecordObject.rfid) {
- this.materialGridStatus = 1
- this.BoxWeight = Number(this.recentlyRecordObject.weight)
- this.recentlyRecordObject.weight = this.recentlyRecordObject.weight + 'Kg'
- }
- this.drawerPositionStatus = res.lock==null? 1: Number(res.lock)
- this.setImgSrc()
- // 有数据 {"code":200,"message":"ok","data":{"RFID":"2024080613602207","UID":"992fa202530104e0","errCode":"0","ts":"1722568500"}}
- // 无数据 {"code":200,"message":"ok","data":{"RFID":"","UID":"0000000000000000","errCode":"0","ts":"1722568502"}}
- return this.recentlyRecordObject
- }
- //后端入库操作
- Warehousing = async (): Promise<MaterialInformationModel[]> => {
- let res: MaterialInformationModel[] = await StorageRequest.post("/api/v1/wmsOrder/inBox", {
- houseNo: '1',
- stanCode: CommonConstants.STATION_CODE,
- vehicleCode: this.recentlyRecordObject.rfid,
- detailsList: this.boxMaterials
- } as RequestParamModel)
- console.log('testTag', 'aaaaaaaa1' + JSON.stringify(res));
- promptAction.showToast({
- message: '请求成功,业务处理中。。。',
- duration: 2000,
- bottom: 150
- });
- this.boxMaterials = []
- return res
- }
- //硬件请求入库操作
- warehousingHttp = async (): Promise<MaterialInformationModel> => {
- let res: MaterialInformationModel = await StorageRequest.post("/api/v1/wcs/stockin", {
- boxNo: this.recentlyRecordObject.rfid,
- position: CommonConstants.STATION_CODE,
- mtype: this.vehicleLevel
- } as RequestParamModel)
- console.log('testTag1', '----------' + JSON.stringify(res));
- return res
- }
- //查询取出料箱里面的物料信息
- boxMaterialHttp = async (): Promise<MaterialInformationModel[]> => {
- let res: MaterialInformationModel[] = await StorageRequest.post("/api/v1/stock/list", {
- //读取RFId的料箱编码,要根据硬件读到的改
- vehicleCode: this.materialNo
- } as RequestParamModel)
- console.log('testTag', 'aaaaaaaa2' + JSON.stringify(res));
- this.MaterialInformation = res
- return res
- }
- callEmptyBoxFun = async () => {
- this.emptyBox = 1 //表明正在取的进度
- let res: EmptyBoxInfoModel = await StorageRequest.post("/api/v1/stock/queryEmptyBox")
- console.log("QQQ", JSON.stringify(res), res?.vehicleNo)
- let outRes: outBoxClass = await StorageRequest.post("/api/v1/wmsOrder/outBox", {
- stanCode: CommonConstants.STATION_CODE,
- vehicleNo: res!.vehicleNo,
- houseNo: res!.houseNo
- } as RequestParamModel)
- promptAction.showToast({
- message: "箱子正在运行中....",
- duration: 1800,
- bottom: '50%'
- })
- console.log("QQQ", JSON.stringify(outRes), outRes?.orderId)
- }
- // 获取二楼绑定料箱信息
- getUpstairsData = async () => {
- // 如果没有rfid就不调用
- if (!this.recentlyRecordObject.rfid) {
- return
- }
- let res: MaterialInformationModel[] = await StorageRequest.get(`/web/wcs/bindInfo/${this.recentlyRecordObject.rfid}`) as MaterialInformationModel[]
- if (res && res.length && res.length > 0) {
- this.MaterialInformation = res
- console.log('dyy',JSON.stringify(res))
- }
- }
- // 清空的按钮调用这个方法
- clearData = () => {
- this.MaterialInformation = []
- }
- //打开页面0.5s请求一次硬件,当io(有无料箱)和weight(重量)发送变化时执行改变数据,同时通过RFID请求读取料箱里面物料信息
- async aboutToAppear() {
- this.currentTimer = setInterval(async () => {
- this.locationRequest()
- }, 1000);
- }
- aboutToDisappear(): void {
- clearInterval(this.currentTimer)
- }
- //删除操作
- @Builder
- itemEnd(index: number) {
- Row() {
- Button("删除").margin("4vp")
- .onClick(() => {
- this.MaterialInformation.splice(index, 1)
- })
- }.padding("4vp").justifyContent(FlexAlign.SpaceEvenly)
- }
- build() {
- Row() {
- Column() {
- Row() {
- Column() {
- Stack() {
- Image(this.BoxWeight === 0 ? $r('app.media.no_material_box') : this.BoxWeight <= 15 && this.BoxWeight !== 0 ? $r('app.media.normal_box') : $r('app.media.overweight_box'))
- .width(px2vp(608))
- .height(px2vp(220))
- .borderRadius(px2vp(16))
- // RFID的信息
- Column() {
- // Text('料箱重量')
- // .textAlign(TextAlign.End)
- // .width('48%')
- // .height('20%')
- // .fontWeight(FontWeight.Regular)
- // .fontSize($r('app.float.fontSize_20'))
- // .fontColor($r('app.color.process_nameplate_grey_color'))
- // .focusable(true)
- // .defaultFocus(true)
- // Text(this.BoxWeight.toString() + 'Kg')
- // Text(this.recentlyRecordObject.weight)
- // .textAlign(TextAlign.End)
- // .width('48%')
- // .height('25%')
- // .fontWeight(FontWeight.Regular)
- // .fontSize($r('app.float.fontSize_24'))
- // .fontColor(this.BoxWeight <= 15 ? $r('app.color.black_90') : $r('app.color.brown_100'))
- //
- // Blank()
- Text('料箱ID')
- .textAlign(TextAlign.End)
- .width('48%')
- .height('20%')
- .fontWeight(FontWeight.Regular)
- .fontSize($r('app.float.fontSize_20'))
- .fontColor($r('app.color.process_nameplate_grey_color'))
- .focusable(true)
- .defaultFocus(false)
- Text(this.recentlyRecordObject.rfid)
- .textAlign(TextAlign.End)
- .width('100%')
- .height('25%')
- .fontWeight(FontWeight.Regular)
- .fontSize($r('app.float.fontSize_24'))
- .fontColor($r('app.color.black_90'))
- }
- .width(px2vp(608))
- .height(px2vp(220))
- .borderRadius(px2vp(16))
- .padding({ right: $r('app.float.borderRadius_16') })
- .alignItems(HorizontalAlign.End)
- }
- .width(px2vp(608))
- .height(px2vp(220))
- // 扫码之后在左边rfid下面的列表
- Column() {
- List() {
- ForEach(this.boxMaterials, (item: MaterialInformationModel, index: number) => {
- ListItem() {
- Row() {
- Column() {
- Column() {
- Row().height('23%')
- Text(item.materialName)
- .fontSize($r('app.float.fontSize_24'))
- .fontColor($r('app.color.general_font_color'))
- .fontWeight(FontWeight.Medium)
- .opacity($r('app.float.general_font_opacity'))
- Text(item.spec)
- .fontSize($r('app.float.fontSize_20'))
- .fontColor($r('app.color.process_nameplate_grey_color'))
- .fontWeight(FontWeight.Medium)
- }
- .height('50%')
- .width('90%')
- .alignItems(HorizontalAlign.Start)
- Column() {
- Row() {
- Text(item.num?.toString())
- .fontSize($r('app.float.fontSize_38'))
- .fontColor($r('app.color.general_font_color'))
- .fontWeight(FontWeight.Bold)
- Text(item.unitDictLabel)
- .fontSize($r('app.float.fontSize_20'))
- .fontColor($r('app.color.process_nameplate_grey_color'))
- .fontWeight(FontWeight.Medium)
- .lineHeight(25)
- .margin({ left: 2 })
- }
- .width('90%')
- .margin({ top: 5 })
- Blank()
- Row() {
- Image($r('app.media.subscript_space'))
- .height($r('app.float.card_subscript_new_size'))
- .width($r('app.float.card_subscript_new_size'))
- }
- .alignItems(VerticalAlign.Bottom)
- .justifyContent(FlexAlign.End)
- .width('100%')
- }
- .height('50%')
- .width('100%')
- }
- .width('100%')
- .borderRadius($r('app.float.general_border_radius'))
- .alignItems(HorizontalAlign.Center)
- .justifyContent(FlexAlign.Center)
- .height('100%')
- }
- .borderRadius(10)
- .height('30%')
- .onClick(() => {
- })
- .margin({ top: 3 })
- .backgroundColor(this.onclick === index ? $r('app.color.robot_set_card_blue') : $r('app.color.robot_set_card_white'))
- }
- })
- }
- .width(px2vp(608))
- .height(px2vp(540))
- .margin({ bottom: px2vp(20), top: px2vp(20) })
- }
- .width(px2vp(608))
- .height(px2vp(450))
- .borderRadius($r('app.float.borderRadius_16'))
- }
- .width(px2vp(608))
- .height(px2vp(800))
- .borderRadius($r('app.float.borderRadius_16'))
- // ================= 中间一列扫码
- Column() {
- // Blank()
- Row() {
- Image($r('app.media.shaoma'))
- .width(px2vp(32))
- .height(px2vp(32))
- Row() {
- TextInput({ text: this.scanCodeValue,
- placeholder: '请点击扫码或者输入物料编码',
- controller: this.textController })
- .width('92%')
- .placeholderFont({ size: $r('app.float.fontSize_24') })
- .height('100%')
- .defaultFocus(false)
- .fontWeight(FontWeight.Medium)
- .fontSize($r('app.float.fontSize_24'))
- .backgroundColor("#ffff")
- .borderRadius(21)
- .defaultFocus(false)
- .onSubmit(() => {
- this.materialBox = 1
- this.ScanStorageCode(this.scanCodeValue)
- })
- .onChange((value: string) => {
- this.scanCodeValue = value
- })
- }.width('80%')
- .padding({ left: 10 })
- Image($r('app.media.search'))
- .width(px2vp(32))
- .height(px2vp(32))
- .onClick(async () => {
- this.materialBox = 1
- this.ScanStorageCode(this.scanCodeValue)
- })
- }
- .border({ width: 0.1 })
- .borderRadius(40)
- .width(px2vp(608))
- .height(px2vp(80))
- .backgroundColor('#fff')
- .justifyContent(FlexAlign.Center)
- Column() {
- List() {
- ForEach(this.MaterialInformation, (item: MaterialInformationModel, index: number) => {
- // ForEach(this.exchange,(exchangeItem:exchangeClass,exchangeIndex:number)=>{
- ListItem() {
- Row() {
- Column() {
- Text(item.materialName)
- .fontWeight(FontWeight.Medium)// Text(item.materialCode)
- .fontSize($r('app.float.fontSize_24'))
- Text(item.materialCode)
- .fontWeight(FontWeight.Medium)
- .fontSize($r('app.float.fontSize_24'))
- Text(item.spec)
- .fontColor("#666666")
- .fontWeight(FontWeight.Regular)
- .fontSize($r('app.float.fontSize_20'))
- // Text(item.type)
- // .fontColor("#666666")
- // .fontWeight(FontWeight.Regular)
- // .fontSize($r('app.float.fontSize_20'))
- Row() {
- Text(item.num?.toString())
- .fontWeight(FontWeight.Bold)
- .fontSize($r('app.float.fontSize_38'))
- Text(item.unitDictLabel)
- .fontColor("#666666")
- .fontWeight(FontWeight.Medium)
- .fontSize($r('app.float.fontSize_24'))
- }
- }
- .width('70%')
- .padding({ left: px2vp(30) })
- .borderRadius(10)
- .alignItems(HorizontalAlign.Start)
- .justifyContent(FlexAlign.Center)
- .height('100%')
- .backgroundColor('#fff')
- if (item.exchangeNumber !== undefined) {
- Row() {
- Image((item.exchangeNumber!) >= 0 ? $r('app.media.plus') : $r('app.media.reduce'))
- .width(px2vp(30))
- .height((item.exchangeNumber!) >= 0 ? px2vp(30) : px2vp(8))
- Text((item.exchangeNumber!) >= 0 ? item.exchangeNumber?.toString() : (-(item.exchangeNumber!))?.toString())// .backgroundColor(item.exchangeNumber>0?$r('app.color.green_100'):item?.exchangeNumber===0?'':$r('app.color.brown_100'))
- .fontSize($r('app.float.fontSize_38'))
- .fontWeight(FontWeight.Bold)
- .fontColor((item.exchangeNumber!) >= 0 ? $r('app.color.green_100') : $r('app.color.brown_100'))
- }.width('20%')
- .justifyContent(FlexAlign.Center)
- .alignItems(VerticalAlign.Center)
- .height('100%')
- } else {
- Column() {
- }.width('20%')
- .justifyContent(FlexAlign.Center)
- .alignItems(HorizontalAlign.Center)
- .height('100%')
- }
- Column() {
- Image($r('app.media.subscript_space'))
- .width($r('app.float.storage_set_image_effect_height'))
- .height($r('app.float.storage_set_image_effect_height'))
- }.width('10%')
- .justifyContent(FlexAlign.End)
- .alignItems(HorizontalAlign.End)
- .height('100%')
- }
- .width(px2vp(608))
- .height(px2vp(210))
- .borderRadius($r('app.float.borderRadius_16'))
- .backgroundColor('#fff')
- .onClick(() => {
- // this.exchangeIndex=exchangeIndex!
- this.index = index
- this.batchCode = item.batchCode!
- this.materialName = item.materialName!
- this.materialNo = item.materialCode!
- this.materialModel = item.materialModel!
- this.num = item.num!
- this.seqNo = item.seqNo!
- this.spec = item.spec!
- //if (item.exchangeNumber===null){
- // this.MaterialInformation[index].exchangeNumber=0
- // if (this.exchangeNumber!==0) {
- // this.MaterialInformation[index]= {
- // taskId: this.MaterialInformation[index].taskId,
- // materialName: this.MaterialInformation[index].materialName,
- // exchangeNumber:0,
- // num:this.MaterialInformation[index].num,
- // materialNo: this.MaterialInformation[index].materialNo,
- // batchCode: this.MaterialInformation[index].batchCode,
- // seqNo: this.MaterialInformation[index].seqNo,
- // spec: this.MaterialInformation[index].spec,
- // }
- // }
- // }else if (item.exchangeNumber!==0){
- // item.exchangeNumber=0
- // }
- // this.exchangeNumber=item.exchangeNumber!
- // this.scanStorageList[index]= {
- // taskId: item.taskId!,
- // materialName: item.materialName!,
- // num: item.num!,
- // exchangeNumber:this.exchangeNumber!,
- // materialNo: item.materialNo!,
- // batchCode: item.batchCode!,
- // seqNo: item.seqNo!,
- // spec: item.spec!,
- // }
- this.materialDetailsController.open()
- })
- }
- .swipeAction({ end: this.itemEnd(index) })
- .margin({ right: px2vp(12), top: px2vp(10) })
- // })
- })
- }
- // .lanes(2)
- .onScrollIndex((first: number) => {
- console.info(first.toString())
- })
- .width('100%')
- .height('100%')
- }.width(px2vp(610))
- .height(px2vp(640))
- .margin({ right: px2vp(24), bottom: px2vp(8), top: px2vp(8) })
- }.width(px2vp(610))
- .height(px2vp(800))
- .alignItems(HorizontalAlign.Start)
- .margin({ left: $r('app.float.Margins_24') })
- }.width(px2vp(1260))
- .height(px2vp(800))
- Row({ space: 20 }) {
- Button('获取二楼信息')
- .fontSize($r('app.float.fontSize_24'))
- .fontColor($r('app.color.general_font_white_color'))
- .width(px2vp(200))
- .height(px2vp(80))
- .backgroundColor($r('app.color.brown_100'))
- .onClick(() => {
- this.getUpstairsData()
- })
- Button('清空物料')
- .fontSize($r('app.float.fontSize_24'))
- .fontColor($r('app.color.general_font_white_color'))
- .width(px2vp(150))
- .height(px2vp(80))
- .backgroundColor($r('app.color.blue_100'))
- .onClick(() => {
- this.clearData()
- })
- if (this.MaterialInformation.length === 0) {
- Button('绑定料箱')
- .fontSize($r('app.float.fontSize_24'))
- .fontColor($r('app.color.general_font_white_color'))
- .width(px2vp(608))
- .height(px2vp(80))
- .backgroundColor($r('app.color.blue_20'))
- }
- else {
- Button('绑定料箱')
- .fontSize($r('app.float.fontSize_24'))
- .fontColor($r('app.color.general_font_white_color'))
- .width(px2vp(608))
- .height(px2vp(80))
- .backgroundColor($r('app.color.blue_100'))
- .onClick(() => {
- // 把中间的数据push到左边的数组,如果xx一样就数量相加
- let toPushArray: MaterialInformationModel[] = [...this.boxMaterials]
- this.MaterialInformation.forEach((middleBox) => {
- let has = false
- for (let i = 0; i < toPushArray.length; i++) {
- let box = toPushArray[i]
- if (middleBox.materialCode == box.materialCode) {
- let number = middleBox.num! + box.num!
- box.num = number
- has = true
- }
- }
- if (!has) {
- toPushArray.push(JSON.parse(JSON.stringify(middleBox)))
- }
- })
- this.boxMaterials = [...toPushArray]
- this.MaterialInformation = []
- })
- }
- }
- .width(px2vp(1260))
- .height(px2vp(100))
- .justifyContent(FlexAlign.Center)
- }.width(px2vp(1260))
- .height(px2vp(900))
- Column() {
- Stack() {
- Image(this.imgSrc)
- .width(px2vp(608))
- .height('100%')
- .borderRadius($r('app.float.borderRadius_16'))
- Column() {
- Text('抽屉状态')
- .textAlign(TextAlign.End)
- .width('48%')
- .height('20%')
- .fontWeight(FontWeight.Regular)
- .fontSize($r('app.float.fontSize_20'))
- .fontColor($r('app.color.process_nameplate_grey_color'))
- Text(this.recentlyRecordObject.lockStr)
- .textAlign(TextAlign.End)
- .width('48%')
- .height('25%')
- .fontWeight(FontWeight.Regular)
- .fontSize($r('app.float.fontSize_24'))
- .fontColor($r('app.color.black_90'))
- Blank()
- Text('料箱ID')
- .textAlign(TextAlign.End)
- .width('48%')
- .height('20%')
- .fontWeight(FontWeight.Regular)
- .fontSize($r('app.float.fontSize_20'))
- .fontColor($r('app.color.process_nameplate_grey_color'))
- Text(this.recentlyRecordObject.rfid)
- .textAlign(TextAlign.End)
- .width('100%')
- .height('25%')
- .fontWeight(FontWeight.Regular)
- .fontSize($r('app.float.fontSize_24'))
- .fontColor($r('app.color.black_90'))
- }
- .width('100%')
- .height('100%')
- .padding({ right: $r('app.float.borderRadius_16') })
- .alignItems(HorizontalAlign.End)
- .borderRadius($r('app.float.borderRadius_16'))
- }.width(px2vp(608))
- .height('30%')
- .borderRadius($r('app.float.borderRadius_16'))
- Button(this.materialGridStatus === 1 ? '入库' : '取空箱')
- .fontSize($r('app.float.fontSize_24'))
- .fontColor($r('app.color.general_font_white_color'))
- .width('100%')
- .height('10%')
- .margin({ top: $r('app.float.topMargins_20') })
- .backgroundColor(this.drawerPositionStatus === 1 && this.materialGridStatus === 1 ? $r('app.color.green_100') : (this.drawerPositionStatus === 2 && this.materialGridStatus === 1 ? $r('app.color.Green_20') :
- (this.drawerPositionStatus === 1 && this.materialGridStatus === 0 ? $r('app.color.blue_100') : $r('app.color.blue_20'))))
- .onClick(() => {
- if (this.materialGridStatus === 0) {
- this.callEmptyBoxFun()
- }
- if (this.materialGridStatus === 1) {
- this.Warehousing()
- }
- })
- // if (this.emptyBox === 1) {
- //
- // Column() {
- // Text('正在取空箱,当前进度1/' + this.callBoxNum + '...')
- // .textAlign(TextAlign.Center)
- // .borderRadius(px2vp(16))
- // .width('100%')
- // .height('25%')
- // .fontWeight(FontWeight.Bold)
- // .fontSize($r('app.float.fontSize_24'))
- // .fontColor($r('app.color.black_90'))
- // Text(this.materialGridStatus === 1 ? '请取出料箱' : this.drawerPositionStatus === 2 && this.materialGridStatus === 0 ? '请将料格推入' : '')
- // .textAlign(TextAlign.Center)
- // .borderRadius(px2vp(16))
- // .width('100%')
- // .height('25%')
- // .fontWeight(FontWeight.Bold)
- // .fontSize($r('app.float.fontSize_24'))
- // .fontColor($r('app.color.black_90'))
- //
- // }
- // .width('100%')
- // .height('60%')
- // .justifyContent(FlexAlign.Center)
- //
- // }
- }.width(px2vp(608))
- .height('100%')
- .focusable(true)
- .defaultFocus(false)
- }
- .width('100%')
- .height('92%')
- .padding({
- left: px2vp(24),
- right: px2vp(24),
- top: $r('app.float.fontSize_20'),
- bottom: $r('app.float.fontSize_20')
- })
- .focusable(true)
- .defaultFocus(false)
- }
- }
- @Component
- struct TextInputExample {
- @Link exchangeNumber: number
- @Link index: number
- @Link num: number
- @Link private MaterialInformation: Array<MaterialInformationModel>
- controller: TextInputController = new TextInputController()
- build() {
- TextInput({ text:this.num.toString(), controller: this.controller })
- .fontSize($r('app.float.title_font_size'))
- .fontWeight(FontWeight.Bold)
- .fontColor($r('app.color.general_font_color'))// .opacity($r('app.float.general_font_opacity'))
- .height('85%')
- .width('60%')
- .textAlign(TextAlign.Center)
- .backgroundColor($r('app.color.general_card_background_color'))
- .borderRadius(0)
- .border({ width: 0.8 })
- .onChange((newValue: string) => {
- this.num = Number(newValue)
- this.MaterialInformation[this.index] = {
- taskId: this.MaterialInformation[this.index].taskId!,
- materialName: this.MaterialInformation[this.index].materialName!,
- // exchangeNumber:this.MaterialInformation[this.index].exchangeNumber!,
- exchangeNumber: this.exchangeNumber,
- num: this.num,
- materialCode: this.MaterialInformation[this.index].materialCode!,
- batchCode: this.MaterialInformation[this.index].batchCode!,
- seqNo: this.MaterialInformation[this.index].seqNo!,
- spec: this.MaterialInformation[this.index].spec!,
- }
- console.log('dyy',this.num)
- })
- }
- }
- @CustomDialog
- ///无批次号物料详情弹窗
- struct materialDetails {
- @Link exchangeNumber: number
- @Link index: number
- @Link batchCode: string
- @Link materialName: string
- @Link num: number
- @Link seqNo: string
- @Link spec: string
- @Link materialNo: string
- @Link materialModel: string
- @Link private MaterialInformation: Array<MaterialInformationModel>
- scroller: Scroller = new Scroller()
- @State navigation: number = 0
- controller: CustomDialogController
- // 若尝试在CustomDialog中传入多个其他的Controller,以实现在CustomDialog中打开另一个或另一些CustomDialog,那么此处需要将指向自己的controller放在最后
- build() {
- Column() {
- Column() {
- }.width('100%')
- .height('20%')
- .onClick(() => {
- this.exchangeNumber = 0
- this.controller.close()
- })
- Row() {
- Row() {
- }.width('25%')
- .height('100%')
- .onClick(() => {
- this.exchangeNumber = 0
- this.controller.close()
- })
- Column({ space: 20 }) {
- Text('物料详情')
- .textAlign(TextAlign.Center)
- .width('100%')
- .height('20%')
- .fontSize('51px')
- .focusable(true)
- .defaultFocus(true)
- Column({ space: 10 }) {
- Text(this.materialName)
- .fontSize('32px')
- .width('100%')
- Text('物料编码:' + this.materialNo)
- .fontSize($r('app.float.robot_state_font_size'))
- .textAlign(TextAlign.Start)
- .fontColor('#99000000')
- .width('100%')
- Text('规格型号:' + this.materialModel)
- .fontSize($r('app.float.robot_state_font_size'))
- .textAlign(TextAlign.Start)
- .fontColor('#99000000')
- .width('100%')
- Row(){
- Text('批次号:')
- .fontSize($r('app.float.robot_state_font_size'))
- .textAlign(TextAlign.Start)
- .fontColor('#99000000')
- .maxLines(1)
- .textOverflow({ overflow: TextOverflow.Ellipsis })
- Text(this.batchCode)
- .fontSize($r('app.float.robot_state_font_size'))
- .textAlign(TextAlign.Start)
- .fontColor('#99000000')
- .maxLines(1)
- .textOverflow({ overflow: TextOverflow.Ellipsis })
- }
- .padding({right:px2vp(40)})
- }.width('80%')
- .height('30%')
- Divider().vertical(false)
- .width('60%')
- Column() {
- // Text('录入数量')
- // .fontSize($r('app.float.robot_state_font_size'))
- // .textAlign(TextAlign.Start)
- // .fontColor('#99000000')
- // .width('40%')
- Row() {
- Image($r('app.media.subtract_disabled'))
- .width(px2vp(120))
- .height(px2vp(120))
- .border({ width: 0.8 })
- .borderRadius({ topLeft: px2vp(16), bottomLeft: px2vp(16) })
- .onClick(() => {
- this.num--
- this.exchangeNumber--
- this.MaterialInformation[this.index] = {
- taskId: this.MaterialInformation[this.index].taskId,
- materialName: this.MaterialInformation[this.index].materialName,
- // exchangeNumber:this.MaterialInformation[this.index].exchangeNumber,
- exchangeNumber: this.exchangeNumber,
- num: this.num,
- materialCode: this.MaterialInformation[this.index].materialCode,
- batchCode: this.MaterialInformation[this.index].batchCode,
- seqNo: this.MaterialInformation[this.index].seqNo,
- spec: this.MaterialInformation[this.index].spec,
- }
- })
- TextInputExample({
- MaterialInformation:this.MaterialInformation,
- num:this.num,
- exchangeNumber:this.exchangeNumber,
- index:this.index
- })
- // TextInput({ text:this.num.toString() })
- // .fontSize($r('app.float.title_font_size'))
- // .fontWeight(FontWeight.Bold)
- // .fontColor($r('app.color.general_font_color'))// .opacity($r('app.float.general_font_opacity'))
- // .height('85%')
- // .width('60%')
- // .textAlign(TextAlign.Center)
- // .backgroundColor($r('app.color.general_card_background_color'))
- // .borderRadius(0)
- // .border({ width: 0.8 })
- // .onChange(() => {
- // this.MaterialInformation[this.index] = {
- // taskId: this.MaterialInformation[this.index].taskId!,
- // materialName: this.MaterialInformation[this.index].materialName!,
- // // exchangeNumber:this.MaterialInformation[this.index].exchangeNumber!,
- // exchangeNumber: this.exchangeNumber,
- // num: this.num,
- // materialCode: this.MaterialInformation[this.index].materialCode!,
- // batchCode: this.MaterialInformation[this.index].batchCode!,
- // seqNo: this.MaterialInformation[this.index].seqNo!,
- // spec: this.MaterialInformation[this.index].spec!,
- // }
- // })
- Image($r('app.media.add_disabled'))
- .width(px2vp(120))
- .height(px2vp(120))
- .border({ width: 0.8 })
- .borderRadius({ topRight: px2vp(16), bottomRight: px2vp(16) })
- .onClick(() => {
- this.exchangeNumber++
- this.num++
- this.MaterialInformation[this.index] = {
- taskId: this.MaterialInformation[this.index].taskId,
- materialName: this.MaterialInformation[this.index].materialName,
- //exchangeNumber:this.MaterialInformation[this.index].exchangeNumber,
- exchangeNumber: this.exchangeNumber,
- num: this.num,
- materialCode: this.MaterialInformation[this.index].materialCode,
- batchCode: this.MaterialInformation[this.index].batchCode,
- seqNo: this.MaterialInformation[this.index].seqNo,
- spec: this.MaterialInformation[this.index].spec,
- }
- // this.exchange[this.exchangeIndex]={
- // exchangeNumber:this.exchange[this.exchangeIndex].exchangeNumber
- // }
- })
- }
- .width('60%')
- .height('20%')
- }
- }.width('50%')
- .height('100%')
- .backgroundColor('#F1F3F5')
- .borderRadius(20)
- Row() {
- }.width('25%')
- .height('100%')
- .onClick(() => {
- this.exchangeNumber = 0
- this.controller.close()
- })
- }.width('100%')
- .height('60%')
- Column() {
- }.width('100%')
- .height('20%')
- .onClick(() => {
- this.controller.close()
- })
- }
- .width('100%')
- .backgroundColor('#4d000000')
- .height('100%')
- .justifyContent(FlexAlign.Center)
- .focusable(true)
- .defaultFocus(false)
- // dialog默认的borderRadius为24vp,如果需要使用border属性,请和borderRadius属性一起使用。
- }
- }
- //RFID读取失败弹窗
- @CustomDialog
- struct RfidCar {
- controller: CustomDialogController
- build() {
- Column() {
- Text('RFID读取失败')
- .fontWeight(FontWeight.Medium)
- .fontSize($r('app.float.fontSize_50'))
- Blank()
- Text('请检查RFID读卡器或料箱底部识别卡片是否正常!')
- .fontWeight(FontWeight.Medium)
- .fontSize($r('app.float.fontSize_38'))
- Blank()
- Button('取消', { type: ButtonType.Normal, stateEffect: true })
- .width(px2vp(252))
- .height(px2vp(70))
- .borderRadius(px2vp(75))
- .fontSize($r('app.float.fontSize_20'))
- .onClick(() => {
- this.controller.close()
- })
- }
- .width(px2vp(924))
- .height(px2vp(536))
- .padding({ top: px2vp(60), bottom: px2vp(60) })
- .borderRadius($r('app.float.borderRadius_16'))
- .backgroundColor($r('app.color.white_100'))
- }
- }
- // 自定义键盘
- @Builder
- function CustomKeyboardBuilderEmpty() {
- Column() {
- }
- .width(0)
- .height(0)
- }
|