123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543 |
- import { TitleStateComp } from '../common/component/TitleStateComp';
- import { ScanStorageclass } from './Storage';
- import StorageRequest from '../common/util/request/StorageRequest';
- import router from '@ohos.router';
- import { WorkstationInfo } from './LoginPage';
- import CommonConstants from '../common/constants/CommonConstants';
- import EquipmentRequest from '../common/util/request/EquipmentRequest';
- import RequestParamModel from '../viewmodel/RequestParamModel';
- import { StationInfoModel } from '../model/StorageSpace';
- @Entry
- @CustomDialog
- export struct RfidAllocation {
- //todo 读写器编号
- @State ReadingWriting: string = 'SGHRI3LR48500'
- //写入rfid
- @State InRfid: string = ''
- @State workstation: WorkstationInfo = {}
- //新建料箱最后两位
- @State newBox: number = 0
- //点击选择
- @State onclick: number = -1
- //打印机在线状态
- @State onlineStatus: number = 0
- //RFID在线状态
- @State RfidOnlineStatus: number = 0
- //箱子编码
- @State boxCode: string = ''
- //扫码控制器
- textcontroller: TextInputController = new TextInputController()
- //新建料箱list
- @State private scanStorageList: Array<ScanStorageclass> = []
- @State isHomePage: boolean = false
- RfidController?: CustomDialogController;
- //料箱容量
- @State capacity: string = '9999'
- //料箱类别
- @State category: string = '0'
- //载具编号
- @State code: string = ''
- //载具名称
- @State name: string = ''
- //资产编号
- @State propertyCode: string = 'YXJ-4610'
- //时间
- @State coding: string = ''
- //料箱创建日期
- @State MaterialBoxData: string = ''
- //料箱创建时间
- @State MaterialBoxTime: string = ''
- //新建料箱表
- @State private newMaterial: Array<newMaterialBoxList> = []
- @State private newMaterialBin: Array<newMaterialBin> = []
- //读取到的rfid信息
- @State private httpRfid: RfidClass = {}
- //获取rfid
- @State private recentlyRecordObject: StationInfoModel = {}
- RfidHttp = async (): Promise<RfidClass> => {
- //todo SGHRI3LR48500设备编号,从后端数据获取,暂时写死
- let res: RfidClass = await EquipmentRequest.get("/api/v1/device/data/recentlyRecord/SGHRI3LR48500", {})
- // let result: StationInfoModel = await StorageRequest.post("api/v1/wms/common/queryStationInfo", {
- // stanCode: CommonConstants.STATION_CODE
- // } as RequestParamModel)
- // this.recentlyRecordObject = result
- this.httpRfid = res
- this.RfidOnlineStatus = 1
- console.log('textTag', 'rfid请求结果' + JSON.stringify(res)
- );
- return res
- }
- //写入rfid
- InRfidHttp = async (): Promise<InRfidClass> => {
- //todo SGHRI3LR48500设备编号,从后端数据获取,暂时写死
- let res: InRfidClass = await EquipmentRequest.post("/api/v1/device/setup", {
- deviceNo: this.ReadingWriting,
- data: {
- rfid0: this.InRfid
- }
- } as RequestParamModel)
- console.log('textTag', 'rfid写入结果' + JSON.stringify(res)
- );
- return res
- }
- currentTimer: number = -1
- aboutToAppear(): void {
- this.currentTimer = setInterval(async () => {
- this.RfidHttp().then((res: RfidClass) => {
- console.log('textTag', '-------rfid获取信息' + JSON.stringify(res))
- })
- }, 5000);
- }
- aboutToDisappear(): void {
- clearInterval(this.currentTimer)
- }
- //后端料箱绑定
- newMaterialBox = async (): Promise<newMaterialBoxList> => {
- let obj: newMaterialBoxList = {}
- let res: newMaterialBoxList = await StorageRequest.post("/api/v1/wms/vehicle/add", {
- capacity: '9999',
- category: '0',
- code: this.coding,
- name: this.coding,
- propertyCode: this.coding,
- universal: '0'
- } as newMaterialBoxList)
- console.log('testTag', 'Tasklist成功' + JSON.stringify(res))
- obj = JSON.parse(JSON.stringify(res))
- console.log('testTag', 'aaaaaaaa' + JSON.stringify(obj));
- return obj
- }
- build() {
- Column() {
- Stack({ alignContent: Alignment.Start }) {
- TitleStateComp({ isHomePage: this.isHomePage, })
- Row() {
- Image($r('app.media.return'))
- .width(px2vp(56))
- .height(px2vp(56))
- .onClick(() => {
- if (CommonConstants.stationDictValue === '5') {
- router.pushUrl({
- url: 'pages/Warehousing'
- })
- } else if (CommonConstants.stationDictValue === '6') {
- router.pushUrl({
- url: 'pages/OutboundStation',
- })
- }
- else {
- router.pushUrl({
- url: 'pages/process/ProcessHome',
- })
- }
- })
- }.width('20%')
- .height('8%')
- .padding({ left: px2vp(24) })
- .backgroundColor($r('app.color.title_bar_background'))
- }
- Row() {
- Column() {
- Column() {
- Column() {
- Text('已有料盒' + "[" + this.newMaterialBin.length.toString() + ']')
- .fontSize($r('app.float.fontSize_30'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.black_90'))
- .width('40%')
- .height(px2vp(80))
- }
- .width('100%')
- .height(px2vp(80))
- .alignItems(HorizontalAlign.Start)
- Row() {
- Button('新建料箱')
- .width(px2vp(292))
- .height(px2vp(80))
- .fontSize($r('app.float.fontSize_24'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.process_divider_white_color'))
- .backgroundColor($r('app.color.blue_100'))
- .onClick(() => {
- this.newBox++
- //日期时间
- let dateTime = new Date()
- let coding = dateTime.getFullYear() + (dateTime.getMonth() + 1).toString().padStart(2, '0')
- + (dateTime.getDate().toString().padStart(2, '0')) +
- (dateTime.getHours()).toString().padStart(2, '0') + (dateTime.getMinutes() + 1).toString()
- .padStart(2, '0')
- + (dateTime.getSeconds()).toString().padStart(2, '0') + (this.newBox < 10 ? 0 : '') + this.newBox
- this.coding = coding
- let data = dateTime.getFullYear() + '-' + (dateTime.getMonth() + 1).toString().padStart(2, '0')
- + '-' + (dateTime.getDate().toString().padStart(2, '0'))
- this.MaterialBoxData = data
- let time = dateTime.getHours() + ':' + (dateTime.getMinutes() + 1).toString().padStart(2, '0')
- + ':' + (dateTime.getSeconds().toString().padStart(2, '0'))
- this.MaterialBoxTime = time
- //todo 后台接口完善后要放开注释
- // this.newMaterialBox().then((res:newMaterialBoxList)=>{
- // this.newMaterial.push(res)
- // })
- let obj: newMaterialBin = {
- MaterialBoxData: this.MaterialBoxData,
- MaterialBoxTime: this.MaterialBoxTime,
- coding: this.coding
- }
- this.newMaterialBin.unshift(obj)
- })
- Blank()
- Row() {
- Image($r('app.media.shaoma'))
- .width(px2vp(32))
- .height(px2vp(32))
- .margin({ left: $r('app.float.fontSize_30') })
- TextInput({ text: this.boxCode,
- placeholder: '请点击扫码或者输入物料编码',
- controller: this.textcontroller })
- .width('92%')
- .height('100%')
- .width(px2vp(450))
- .fontWeight(FontWeight.Medium)
- .fontSize($r('app.float.fontSize_24'))
- .backgroundColor("#ffff")
- .borderRadius(21)
- .onSubmit(() => {
- })
- Image($r('app.media.search'))
- .width(px2vp(32))
- .height(px2vp(32))
- .margin({ right: $r('app.float.fontSize_30') })
- }
- .width(px2vp(608))
- .height(px2vp(80))
- .borderRadius(px2vp(100))
- .alignItems(VerticalAlign.Center)
- .backgroundColor($r('app.color.process_divider_white_color'))
- }
- .margin({ right: $r('app.float.Margins_24') })
- .width('100%')
- .height(px2vp(80))
- }
- .width('100%')
- .height(px2vp(160))
- .margin({ right: $r('app.float.Margins_24'), bottom: px2vp(20) })
- Column() {
- List() {
- ForEach(this.newMaterialBin, (item: newMaterialBin, index: number) => {
- ListItem() {
- Column() {
- Text(item.coding)
- .fontSize($r('app.float.fontSize_24'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.black_90'))
- .width('100%')
- .height('40%')
- Row() {
- Text(item.MaterialBoxData + ' ' + item.MaterialBoxTime)
- .fontSize($r('app.float.fontSize_20'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.black_60'))
- .width('100%')
- .height('100%')
- .textAlign(TextAlign.Start)
- }
- .width('100%')
- .height('40%')
- }
- .justifyContent(FlexAlign.Center)
- .width(px2vp(608))
- .height(px2vp(88))
- .margin({ right: $r('app.float.Margins_24'), bottom: $r('app.float.topMargins_20') })
- .padding({ left: $r('app.float.leftMargins_30') })
- .backgroundColor(this.onclick === index ? $r('app.color.blue_100') : $r('app.color.process_divider_white_color'))
- .borderRadius(px2vp(16))
- .onClick(() => {
- this.onclick = index
- this.InRfid = item.coding!
- })
- }
- .margin({ right: $r('app.float.Margins_24') })
- })
- }
- .lanes(2)
- }.width('100%')
- .height('80%')
- }.width('66%')
- .height('100%')
- .borderRadius($r('app.float.borderRadius_16'))
- .alignItems(HorizontalAlign.Start)
- //.margin({right:$r('app.float.Margins_24')})
- Column() {
- Column() {
- Text('条码打印')
- .fontSize($r('app.float.fontSize_30'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.black_90'))
- .textAlign(TextAlign.Start)
- .width('100%')
- .height('15%')
- .margin({ left: $r('app.float.leftMargins_30') })
- Column() {
- Row({ space: 10 }) {
- Text('打印机状态')
- .fontSize($r('app.float.fontSize_20'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.black_60'))
- .textAlign(TextAlign.End)
- .width('40%')
- .height('100%')
- if (this.onlineStatus === 0) {
- Text().width(px2vp(12))
- .height(px2vp(12))
- .borderRadius(px2vp(50))
- .backgroundColor($r('app.color.green_100'))
- Text('在线')
- .fontSize($r('app.float.fontSize_20'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.black_90'))
- .textAlign(TextAlign.Start)
- .width('35%')
- .height('100%')
- } else if (this.onlineStatus === 1) {
- Text().width('5%')
- .height('30%')
- .borderRadius(px2vp(50))
- .backgroundColor($r('app.color.grey_100'))
- Text('不在线')
- .fontSize($r('app.float.fontSize_20'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.black_90'))
- .textAlign(TextAlign.Start)
- .width('35%')
- .height('100%')
- }
- }
- .width('100%')
- .height('30%')
- Row({ space: 10 }) {
- Text('打印机RFID编号')
- .fontSize($r('app.float.fontSize_20'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.black_60'))
- .textAlign(TextAlign.End)
- .width('40%')
- .height('100%')
- Text('6537289495783').width('40%')
- .height('30%')
- .borderRadius(px2vp(50))
- .fontColor($r('app.color.blue_100'))
- }
- .width('100%')
- .height('30%')
- }.width('100%')
- .height('60%')
- .justifyContent(FlexAlign.Center)
- .alignItems(HorizontalAlign.Center)
- Blank()
- Button('打印条码')
- .fontColor($r('app.color.process_divider_white_color'))
- .fontSize($r('app.float.fontSize_20'))
- .fontWeight(FontWeight.Medium)
- .backgroundColor($r('app.color.blue_100'))
- .width(px2vp(292))
- .height(px2vp(80))
- .margin({ bottom: $r('app.float.topMargins_20') })
- }
- .width('100%')
- .height('49%')
- .borderRadius(px2vp(16))
- .backgroundColor($r('app.color.white_E3E5E7'))
- .margin({ bottom: $r('app.float.topMargins_20') })
- Column() {
- Text('写入RFID')
- .fontSize($r('app.float.fontSize_30'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.black_90'))
- .textAlign(TextAlign.Start)
- .width('100%')
- .height('15%')
- .margin({ left: $r('app.float.leftMargins_30') })
- Column() {
- Row({ space: 10 }) {
- Text('RFID状态')
- .fontSize($r('app.float.fontSize_20'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.black_60'))
- .textAlign(TextAlign.End)
- .width('40%')
- .height('100%')
- if (this.RfidOnlineStatus === 1) {
- Text().width(px2vp(12))
- .height(px2vp(12))
- .borderRadius(px2vp(50))
- .backgroundColor($r('app.color.green_100'))
- Text('在线')
- .fontSize($r('app.float.fontSize_20'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.black_90'))
- .textAlign(TextAlign.Start)
- .width('35%')
- .height('100%')
- } else if (this.RfidOnlineStatus === 0) {
- Text().width('5%')
- .height('30%')
- .borderRadius(px2vp(50))
- .backgroundColor($r('app.color.grey_100'))
- Text('不在线')
- .fontSize($r('app.float.fontSize_20'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.black_90'))
- .textAlign(TextAlign.Start)
- .width('35%')
- .height('100%')
- }
- }
- .width('100%')
- .height('30%')
- Row({ space: 10 }) {
- Text('当前RFID编号')
- .fontSize($r('app.float.fontSize_20'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.black_60'))
- .textAlign(TextAlign.End)
- .width('40%')
- .height('100%')
- Text(this.httpRfid.data?.RFID!).width('40%')
- .height('30%')
- .borderRadius(px2vp(50))
- .fontColor($r('app.color.blue_100'))
- }
- .width('100%')
- .height('30%')
- Row({ space: 10 }) {
- Text('写入RFID编号')
- .fontSize($r('app.float.fontSize_20'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.black_60'))
- .textAlign(TextAlign.End)
- .width('40%')
- .height('100%')
- Text(this.InRfid.toString()).width('40%')
- .height('30%')
- .borderRadius(px2vp(50))
- .fontColor($r('app.color.blue_100'))
- }
- .width('100%')
- .height('30%')
- }.width('100%')
- .height('60%')
- .justifyContent(FlexAlign.Center)
- .alignItems(HorizontalAlign.Center)
- Blank()
- Button('写入RFID')
- .fontColor($r('app.color.process_divider_white_color'))
- .fontSize($r('app.float.fontSize_20'))
- .fontWeight(FontWeight.Medium)
- .backgroundColor($r('app.color.blue_100'))
- .width(px2vp(292))
- .height(px2vp(80))
- .margin({ bottom: $r('app.float.topMargins_20') })
- .onClick(() => {
- this.InRfidHttp().then((res: InRfidClass) => {
- console.log('textTag', '-------rfid写入信息' + JSON.stringify(res))
- })
- })
- }.width('100%')
- .height('49%')
- .borderRadius(px2vp(16))
- .backgroundColor($r('app.color.white_E3E5E7'))
- }.width('33%')
- .height('100%')
- }.width('100%')
- .height('92%')
- .justifyContent(FlexAlign.Center)
- .padding({
- left: $r('app.float.Margins_24'),
- right: $r('app.float.Margins_24'),
- top: $r('app.float.topMargins_20'),
- bottom: $r('app.float.topMargins_20')
- })
- }.width('100%')
- .height('100%')
- .backgroundColor($r('app.color.white_f1f3f5'))
- }
- }
- export interface newMaterialBoxList {
- capacity?: string
- category?: string
- code?: string
- name?: string
- propertyCode?: string
- universal?: string
- }
- export interface newMaterialBin {
- MaterialBoxData?: string
- MaterialBoxTime?: string
- coding?: string
- }
- export interface RfidClass {
- data?: datalass
- }
- export interface datalass {
- RFID?: string
- UID?: string
- errCode?: string
- }
- export interface InRfidClass {
- deviceNo?: string
- data?: InDataClass
- }
- export interface InDataClass {
- rfid0?: string
- }
|