ManualWarehousing.ets 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067
  1. import EquipmentRequest from '../common/util/request/EquipmentRequest'
  2. import StorageRequest from '../common/util/request/StorageRequest'
  3. import { MaterialInformationModel } from '../model/MaterialInformation'
  4. import RequestParamModel from '../viewmodel/RequestParamModel'
  5. import { Materialpositionclass, ScanStorageclass } from './IntelligentWarehousingOutbound'
  6. import CommonConstants from '../common/constants/CommonConstants'
  7. import promptAction from '@ohos.promptAction'
  8. import { EmptyBoxInfoModel, StationInfoModel } from '../model/StorageSpace'
  9. import { outBoxClass } from './CompleteSet'
  10. export interface stat2 {
  11. statNo?: string
  12. //料箱编号
  13. rfid?: string
  14. //料箱检测的io位,1:有,0:没有
  15. io?: string
  16. //0:无锁定,1:锁定,即机器人正在动作,不能进出库动作
  17. lock?: string
  18. ts?: string
  19. RFID?: string
  20. UID?: string
  21. kg?: number
  22. }
  23. @Entry
  24. @Component
  25. export struct ManualWarehousing {
  26. //料箱等级(类型)
  27. @State vehicleLevel: string = ''
  28. // 叫空料箱数量
  29. @State callBoxNum: number = 1
  30. //取空箱子
  31. @State emptyBox: number = 0
  32. //更改的数量
  33. @State exchangeNumber: number = 0
  34. //料箱中的物料信息
  35. @State private boxMaterials: Array<MaterialInformationModel> = []
  36. //定义物料信息
  37. @State private MaterialInformation: Array<MaterialInformationModel> = []
  38. ///料箱状态
  39. @State materialBox: number = 0
  40. // 中间输入框绑定的值
  41. @State scanCodeValue: string = ""
  42. @State materialNo: string = ''
  43. @State materialModel: string =''
  44. //1:抽屉在料格内 0:抽屉在料格外
  45. @State drawerPositionStatus: number = 1
  46. //入库口料格状态(1:有料箱 0:无料箱)
  47. @State materialGridStatus: number = 0
  48. //选中取出的物料位置
  49. @State materialPosition: Materialpositionclass = {}
  50. //需要展示和更改的物料信息
  51. @State index: number = 0
  52. @State batchCode: string = ''
  53. @State materialName: string = ''
  54. @State imgSrc:Resource = $r('app.media.drawer_inside')
  55. //齐套料箱状态不可以点击:0,可以点击:1
  56. @State completeSetMaterialState: number = 0
  57. @State num: number = 0
  58. //点击颜色
  59. @State onclick: number = -1
  60. @State seqNo: string = ''
  61. //物料编码
  62. @State materialCode: string = ''
  63. @State spec: string = ''
  64. //扫码控制器
  65. textController: TextInputController = new TextInputController()
  66. //齐套料箱重量
  67. @State BoxWeight: number = 20
  68. @State private recentlyRecordObject: StationInfoModel = {}
  69. currentTimer: number = -1;
  70. //设置img图片路径
  71. setImgSrc = ()=>{
  72. if(this.drawerPositionStatus == 1 && this.materialGridStatus == 0){
  73. this.imgSrc = $r('app.media.drawer_inside')
  74. }else if(this.drawerPositionStatus == 0 && this.materialGridStatus == 0){
  75. this.imgSrc = $r('app.media.drawer_outside')
  76. }
  77. else if(this.drawerPositionStatus === 1 && this.materialGridStatus === 1){
  78. this.imgSrc = $r('app.media.D_W_inside')
  79. }
  80. else if(this.drawerPositionStatus === 0 && this.materialGridStatus === 1) {
  81. this.imgSrc = $r('app.media.D_W_outside')
  82. }
  83. }
  84. //扫码请求
  85. ScanStorageCode = async (itemCode: string) => {
  86. this.scanCodeValue = ""
  87. let res: MaterialInformationModel = await StorageRequest.post("/api/v1/process/circulation/material", {
  88. label: itemCode //"#gys022#sc022#100#20220929#31"
  89. } as MaterialInformationModel)
  90. //let res = await StorageRequest.get("/api/v3/stock/selectSafeList/1")
  91. // {"batchCode":"BM47111400130447;SL5","codeType":"BATCH","materialCode":"47111400130447","materialName":"穿心电容","num":5,"spec":"G CT52-4-1-2C1-63V-103-M","unitDictLabel":"个","unitDictValue":"个"}
  92. let obj: MaterialInformationModel = JSON.parse(JSON.stringify(res))
  93. // 扫码完成之后,如果数组中有对应的值,就添加数量否则就push
  94. let toPushArray: MaterialInformationModel[] = [...this.MaterialInformation]
  95. let has = false
  96. for (let i = 0; i < toPushArray.length; i++) {
  97. let box = toPushArray[i]
  98. if (obj.materialCode == box.materialCode) {
  99. let number = obj.num! + box.num!
  100. box.num = number
  101. has = true
  102. }
  103. }
  104. if (!has) {
  105. toPushArray.push(JSON.parse(JSON.stringify(obj)))
  106. }
  107. this.MaterialInformation = [...toPushArray]
  108. }
  109. //RFID卡读取失败弹窗
  110. RfidCarController: CustomDialogController = new CustomDialogController({
  111. builder: RfidCar({}),
  112. alignment: DialogAlignment.Center,
  113. gridCount: 4,
  114. customStyle: true,
  115. })
  116. //物料详情弹窗
  117. materialDetailsController: CustomDialogController = new CustomDialogController({
  118. builder: materialDetails({
  119. exchangeNumber: this.exchangeNumber,
  120. MaterialInformation: this.MaterialInformation,
  121. index: this.index,
  122. batchCode: this.batchCode,
  123. materialName: this.materialName,
  124. num: this.num,
  125. seqNo: this.seqNo,
  126. spec: this.spec,
  127. materialNo: this.materialNo,
  128. materialModel:this.materialModel
  129. }),
  130. alignment: DialogAlignment.Bottom,
  131. gridCount: 4,
  132. customStyle: true,
  133. })
  134. //获取RFID信息
  135. locationRequest = async (): Promise<StationInfoModel> => {
  136. let res: StationInfoModel = await StorageRequest.post("api/v1/wms/common/queryStationInfo", {
  137. stanCode: CommonConstants.STATION_CODE
  138. } as RequestParamModel)
  139. this.recentlyRecordObject = res
  140. if(!this.recentlyRecordObject.rfid){
  141. this.boxMaterials = []
  142. }
  143. this.materialGridStatus = 0
  144. if (this.recentlyRecordObject && this.recentlyRecordObject.rfid) {
  145. this.materialGridStatus = 1
  146. this.BoxWeight = Number(this.recentlyRecordObject.weight)
  147. this.recentlyRecordObject.weight = this.recentlyRecordObject.weight + 'Kg'
  148. }
  149. this.drawerPositionStatus = res.lock==null? 1: Number(res.lock)
  150. this.setImgSrc()
  151. // 有数据 {"code":200,"message":"ok","data":{"RFID":"2024080613602207","UID":"992fa202530104e0","errCode":"0","ts":"1722568500"}}
  152. // 无数据 {"code":200,"message":"ok","data":{"RFID":"","UID":"0000000000000000","errCode":"0","ts":"1722568502"}}
  153. return this.recentlyRecordObject
  154. }
  155. //后端入库操作
  156. Warehousing = async (): Promise<MaterialInformationModel[]> => {
  157. let res: MaterialInformationModel[] = await StorageRequest.post("/api/v1/wmsOrder/inBox", {
  158. houseNo: '1',
  159. stanCode: CommonConstants.STATION_CODE,
  160. vehicleCode: this.recentlyRecordObject.rfid,
  161. detailsList: this.boxMaterials
  162. } as RequestParamModel)
  163. console.log('testTag', 'aaaaaaaa1' + JSON.stringify(res));
  164. promptAction.showToast({
  165. message: '请求成功,业务处理中。。。',
  166. duration: 2000,
  167. bottom: 150
  168. });
  169. this.boxMaterials = []
  170. return res
  171. }
  172. //硬件请求入库操作
  173. warehousingHttp = async (): Promise<MaterialInformationModel> => {
  174. let res: MaterialInformationModel = await StorageRequest.post("/api/v1/wcs/stockin", {
  175. boxNo: this.recentlyRecordObject.rfid,
  176. position: CommonConstants.STATION_CODE,
  177. mtype: this.vehicleLevel
  178. } as RequestParamModel)
  179. console.log('testTag1', '----------' + JSON.stringify(res));
  180. return res
  181. }
  182. //查询取出料箱里面的物料信息
  183. boxMaterialHttp = async (): Promise<MaterialInformationModel[]> => {
  184. let res: MaterialInformationModel[] = await StorageRequest.post("/api/v1/stock/list", {
  185. //读取RFId的料箱编码,要根据硬件读到的改
  186. vehicleCode: this.materialNo
  187. } as RequestParamModel)
  188. console.log('testTag', 'aaaaaaaa2' + JSON.stringify(res));
  189. this.MaterialInformation = res
  190. return res
  191. }
  192. callEmptyBoxFun = async () => {
  193. this.emptyBox = 1 //表明正在取的进度
  194. let res: EmptyBoxInfoModel = await StorageRequest.post("/api/v1/stock/queryEmptyBox")
  195. console.log("QQQ", JSON.stringify(res), res?.vehicleNo)
  196. let outRes: outBoxClass = await StorageRequest.post("/api/v1/wmsOrder/outBox", {
  197. stanCode: CommonConstants.STATION_CODE,
  198. vehicleNo: res!.vehicleNo,
  199. houseNo: res!.houseNo
  200. } as RequestParamModel)
  201. promptAction.showToast({
  202. message: "箱子正在运行中....",
  203. duration: 1800,
  204. bottom: '50%'
  205. })
  206. console.log("QQQ", JSON.stringify(outRes), outRes?.orderId)
  207. }
  208. // 获取二楼绑定料箱信息
  209. getUpstairsData = async () => {
  210. // 如果没有rfid就不调用
  211. if (!this.recentlyRecordObject.rfid) {
  212. return
  213. }
  214. let res: MaterialInformationModel[] = await StorageRequest.get(`/web/wcs/bindInfo/${this.recentlyRecordObject.rfid}`) as MaterialInformationModel[]
  215. if (res && res.length && res.length > 0) {
  216. this.MaterialInformation = res
  217. console.log('dyy',JSON.stringify(res))
  218. }
  219. }
  220. // 清空的按钮调用这个方法
  221. clearData = () => {
  222. this.MaterialInformation = []
  223. }
  224. //打开页面0.5s请求一次硬件,当io(有无料箱)和weight(重量)发送变化时执行改变数据,同时通过RFID请求读取料箱里面物料信息
  225. async aboutToAppear() {
  226. this.currentTimer = setInterval(async () => {
  227. this.locationRequest()
  228. }, 1000);
  229. }
  230. aboutToDisappear(): void {
  231. clearInterval(this.currentTimer)
  232. }
  233. //删除操作
  234. @Builder
  235. itemEnd(index: number) {
  236. Row() {
  237. Button("删除").margin("4vp")
  238. .onClick(() => {
  239. this.MaterialInformation.splice(index, 1)
  240. })
  241. }.padding("4vp").justifyContent(FlexAlign.SpaceEvenly)
  242. }
  243. build() {
  244. Row() {
  245. Column() {
  246. Row() {
  247. Column() {
  248. Stack() {
  249. 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'))
  250. .width(px2vp(608))
  251. .height(px2vp(220))
  252. .borderRadius(px2vp(16))
  253. // RFID的信息
  254. Column() {
  255. // Text('料箱重量')
  256. // .textAlign(TextAlign.End)
  257. // .width('48%')
  258. // .height('20%')
  259. // .fontWeight(FontWeight.Regular)
  260. // .fontSize($r('app.float.fontSize_20'))
  261. // .fontColor($r('app.color.process_nameplate_grey_color'))
  262. // .focusable(true)
  263. // .defaultFocus(true)
  264. // Text(this.BoxWeight.toString() + 'Kg')
  265. // Text(this.recentlyRecordObject.weight)
  266. // .textAlign(TextAlign.End)
  267. // .width('48%')
  268. // .height('25%')
  269. // .fontWeight(FontWeight.Regular)
  270. // .fontSize($r('app.float.fontSize_24'))
  271. // .fontColor(this.BoxWeight <= 15 ? $r('app.color.black_90') : $r('app.color.brown_100'))
  272. //
  273. // Blank()
  274. Text('料箱ID')
  275. .textAlign(TextAlign.End)
  276. .width('48%')
  277. .height('20%')
  278. .fontWeight(FontWeight.Regular)
  279. .fontSize($r('app.float.fontSize_20'))
  280. .fontColor($r('app.color.process_nameplate_grey_color'))
  281. .focusable(true)
  282. .defaultFocus(false)
  283. Text(this.recentlyRecordObject.rfid)
  284. .textAlign(TextAlign.End)
  285. .width('100%')
  286. .height('25%')
  287. .fontWeight(FontWeight.Regular)
  288. .fontSize($r('app.float.fontSize_24'))
  289. .fontColor($r('app.color.black_90'))
  290. }
  291. .width(px2vp(608))
  292. .height(px2vp(220))
  293. .borderRadius(px2vp(16))
  294. .padding({ right: $r('app.float.borderRadius_16') })
  295. .alignItems(HorizontalAlign.End)
  296. }
  297. .width(px2vp(608))
  298. .height(px2vp(220))
  299. // 扫码之后在左边rfid下面的列表
  300. Column() {
  301. List() {
  302. ForEach(this.boxMaterials, (item: MaterialInformationModel, index: number) => {
  303. ListItem() {
  304. Row() {
  305. Column() {
  306. Column() {
  307. Row().height('23%')
  308. Text(item.materialName)
  309. .fontSize($r('app.float.fontSize_24'))
  310. .fontColor($r('app.color.general_font_color'))
  311. .fontWeight(FontWeight.Medium)
  312. .opacity($r('app.float.general_font_opacity'))
  313. Text(item.spec)
  314. .fontSize($r('app.float.fontSize_20'))
  315. .fontColor($r('app.color.process_nameplate_grey_color'))
  316. .fontWeight(FontWeight.Medium)
  317. }
  318. .height('50%')
  319. .width('90%')
  320. .alignItems(HorizontalAlign.Start)
  321. Column() {
  322. Row() {
  323. Text(item.num?.toString())
  324. .fontSize($r('app.float.fontSize_38'))
  325. .fontColor($r('app.color.general_font_color'))
  326. .fontWeight(FontWeight.Bold)
  327. Text(item.unitDictLabel)
  328. .fontSize($r('app.float.fontSize_20'))
  329. .fontColor($r('app.color.process_nameplate_grey_color'))
  330. .fontWeight(FontWeight.Medium)
  331. .lineHeight(25)
  332. .margin({ left: 2 })
  333. }
  334. .width('90%')
  335. .margin({ top: 5 })
  336. Blank()
  337. Row() {
  338. Image($r('app.media.subscript_space'))
  339. .height($r('app.float.card_subscript_new_size'))
  340. .width($r('app.float.card_subscript_new_size'))
  341. }
  342. .alignItems(VerticalAlign.Bottom)
  343. .justifyContent(FlexAlign.End)
  344. .width('100%')
  345. }
  346. .height('50%')
  347. .width('100%')
  348. }
  349. .width('100%')
  350. .borderRadius($r('app.float.general_border_radius'))
  351. .alignItems(HorizontalAlign.Center)
  352. .justifyContent(FlexAlign.Center)
  353. .height('100%')
  354. }
  355. .borderRadius(10)
  356. .height('30%')
  357. .onClick(() => {
  358. })
  359. .margin({ top: 3 })
  360. .backgroundColor(this.onclick === index ? $r('app.color.robot_set_card_blue') : $r('app.color.robot_set_card_white'))
  361. }
  362. })
  363. }
  364. .width(px2vp(608))
  365. .height(px2vp(540))
  366. .margin({ bottom: px2vp(20), top: px2vp(20) })
  367. }
  368. .width(px2vp(608))
  369. .height(px2vp(450))
  370. .borderRadius($r('app.float.borderRadius_16'))
  371. }
  372. .width(px2vp(608))
  373. .height(px2vp(800))
  374. .borderRadius($r('app.float.borderRadius_16'))
  375. // ================= 中间一列扫码
  376. Column() {
  377. // Blank()
  378. Row() {
  379. Image($r('app.media.shaoma'))
  380. .width(px2vp(32))
  381. .height(px2vp(32))
  382. Row() {
  383. TextInput({ text: this.scanCodeValue,
  384. placeholder: '请点击扫码或者输入物料编码',
  385. controller: this.textController })
  386. .width('92%')
  387. .placeholderFont({ size: $r('app.float.fontSize_24') })
  388. .height('100%')
  389. .defaultFocus(false)
  390. .fontWeight(FontWeight.Medium)
  391. .fontSize($r('app.float.fontSize_24'))
  392. .backgroundColor("#ffff")
  393. .borderRadius(21)
  394. .defaultFocus(false)
  395. .onSubmit(() => {
  396. this.materialBox = 1
  397. this.ScanStorageCode(this.scanCodeValue)
  398. })
  399. .onChange((value: string) => {
  400. this.scanCodeValue = value
  401. })
  402. }.width('80%')
  403. .padding({ left: 10 })
  404. Image($r('app.media.search'))
  405. .width(px2vp(32))
  406. .height(px2vp(32))
  407. .onClick(async () => {
  408. this.materialBox = 1
  409. this.ScanStorageCode(this.scanCodeValue)
  410. })
  411. }
  412. .border({ width: 0.1 })
  413. .borderRadius(40)
  414. .width(px2vp(608))
  415. .height(px2vp(80))
  416. .backgroundColor('#fff')
  417. .justifyContent(FlexAlign.Center)
  418. Column() {
  419. List() {
  420. ForEach(this.MaterialInformation, (item: MaterialInformationModel, index: number) => {
  421. // ForEach(this.exchange,(exchangeItem:exchangeClass,exchangeIndex:number)=>{
  422. ListItem() {
  423. Row() {
  424. Column() {
  425. Text(item.materialName)
  426. .fontWeight(FontWeight.Medium)// Text(item.materialCode)
  427. .fontSize($r('app.float.fontSize_24'))
  428. Text(item.materialCode)
  429. .fontWeight(FontWeight.Medium)
  430. .fontSize($r('app.float.fontSize_24'))
  431. Text(item.spec)
  432. .fontColor("#666666")
  433. .fontWeight(FontWeight.Regular)
  434. .fontSize($r('app.float.fontSize_20'))
  435. // Text(item.type)
  436. // .fontColor("#666666")
  437. // .fontWeight(FontWeight.Regular)
  438. // .fontSize($r('app.float.fontSize_20'))
  439. Row() {
  440. Text(item.num?.toString())
  441. .fontWeight(FontWeight.Bold)
  442. .fontSize($r('app.float.fontSize_38'))
  443. Text(item.unitDictLabel)
  444. .fontColor("#666666")
  445. .fontWeight(FontWeight.Medium)
  446. .fontSize($r('app.float.fontSize_24'))
  447. }
  448. }
  449. .width('70%')
  450. .padding({ left: px2vp(30) })
  451. .borderRadius(10)
  452. .alignItems(HorizontalAlign.Start)
  453. .justifyContent(FlexAlign.Center)
  454. .height('100%')
  455. .backgroundColor('#fff')
  456. if (item.exchangeNumber !== undefined) {
  457. Row() {
  458. Image((item.exchangeNumber!) >= 0 ? $r('app.media.plus') : $r('app.media.reduce'))
  459. .width(px2vp(30))
  460. .height((item.exchangeNumber!) >= 0 ? px2vp(30) : px2vp(8))
  461. 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'))
  462. .fontSize($r('app.float.fontSize_38'))
  463. .fontWeight(FontWeight.Bold)
  464. .fontColor((item.exchangeNumber!) >= 0 ? $r('app.color.green_100') : $r('app.color.brown_100'))
  465. }.width('20%')
  466. .justifyContent(FlexAlign.Center)
  467. .alignItems(VerticalAlign.Center)
  468. .height('100%')
  469. } else {
  470. Column() {
  471. }.width('20%')
  472. .justifyContent(FlexAlign.Center)
  473. .alignItems(HorizontalAlign.Center)
  474. .height('100%')
  475. }
  476. Column() {
  477. Image($r('app.media.subscript_space'))
  478. .width($r('app.float.storage_set_image_effect_height'))
  479. .height($r('app.float.storage_set_image_effect_height'))
  480. }.width('10%')
  481. .justifyContent(FlexAlign.End)
  482. .alignItems(HorizontalAlign.End)
  483. .height('100%')
  484. }
  485. .width(px2vp(608))
  486. .height(px2vp(210))
  487. .borderRadius($r('app.float.borderRadius_16'))
  488. .backgroundColor('#fff')
  489. .onClick(() => {
  490. // this.exchangeIndex=exchangeIndex!
  491. this.index = index
  492. this.batchCode = item.batchCode!
  493. this.materialName = item.materialName!
  494. this.materialNo = item.materialCode!
  495. this.materialModel = item.materialModel!
  496. this.num = item.num!
  497. this.seqNo = item.seqNo!
  498. this.spec = item.spec!
  499. //if (item.exchangeNumber===null){
  500. // this.MaterialInformation[index].exchangeNumber=0
  501. // if (this.exchangeNumber!==0) {
  502. // this.MaterialInformation[index]= {
  503. // taskId: this.MaterialInformation[index].taskId,
  504. // materialName: this.MaterialInformation[index].materialName,
  505. // exchangeNumber:0,
  506. // num:this.MaterialInformation[index].num,
  507. // materialNo: this.MaterialInformation[index].materialNo,
  508. // batchCode: this.MaterialInformation[index].batchCode,
  509. // seqNo: this.MaterialInformation[index].seqNo,
  510. // spec: this.MaterialInformation[index].spec,
  511. // }
  512. // }
  513. // }else if (item.exchangeNumber!==0){
  514. // item.exchangeNumber=0
  515. // }
  516. // this.exchangeNumber=item.exchangeNumber!
  517. // this.scanStorageList[index]= {
  518. // taskId: item.taskId!,
  519. // materialName: item.materialName!,
  520. // num: item.num!,
  521. // exchangeNumber:this.exchangeNumber!,
  522. // materialNo: item.materialNo!,
  523. // batchCode: item.batchCode!,
  524. // seqNo: item.seqNo!,
  525. // spec: item.spec!,
  526. // }
  527. this.materialDetailsController.open()
  528. })
  529. }
  530. .swipeAction({ end: this.itemEnd(index) })
  531. .margin({ right: px2vp(12), top: px2vp(10) })
  532. // })
  533. })
  534. }
  535. // .lanes(2)
  536. .onScrollIndex((first: number) => {
  537. console.info(first.toString())
  538. })
  539. .width('100%')
  540. .height('100%')
  541. }.width(px2vp(610))
  542. .height(px2vp(640))
  543. .margin({ right: px2vp(24), bottom: px2vp(8), top: px2vp(8) })
  544. }.width(px2vp(610))
  545. .height(px2vp(800))
  546. .alignItems(HorizontalAlign.Start)
  547. .margin({ left: $r('app.float.Margins_24') })
  548. }.width(px2vp(1260))
  549. .height(px2vp(800))
  550. Row({ space: 20 }) {
  551. Button('获取二楼信息')
  552. .fontSize($r('app.float.fontSize_24'))
  553. .fontColor($r('app.color.general_font_white_color'))
  554. .width(px2vp(200))
  555. .height(px2vp(80))
  556. .backgroundColor($r('app.color.brown_100'))
  557. .onClick(() => {
  558. this.getUpstairsData()
  559. })
  560. Button('清空物料')
  561. .fontSize($r('app.float.fontSize_24'))
  562. .fontColor($r('app.color.general_font_white_color'))
  563. .width(px2vp(150))
  564. .height(px2vp(80))
  565. .backgroundColor($r('app.color.blue_100'))
  566. .onClick(() => {
  567. this.clearData()
  568. })
  569. if (this.MaterialInformation.length === 0) {
  570. Button('绑定料箱')
  571. .fontSize($r('app.float.fontSize_24'))
  572. .fontColor($r('app.color.general_font_white_color'))
  573. .width(px2vp(608))
  574. .height(px2vp(80))
  575. .backgroundColor($r('app.color.blue_20'))
  576. }
  577. else {
  578. Button('绑定料箱')
  579. .fontSize($r('app.float.fontSize_24'))
  580. .fontColor($r('app.color.general_font_white_color'))
  581. .width(px2vp(608))
  582. .height(px2vp(80))
  583. .backgroundColor($r('app.color.blue_100'))
  584. .onClick(() => {
  585. // 把中间的数据push到左边的数组,如果xx一样就数量相加
  586. let toPushArray: MaterialInformationModel[] = [...this.boxMaterials]
  587. this.MaterialInformation.forEach((middleBox) => {
  588. let has = false
  589. for (let i = 0; i < toPushArray.length; i++) {
  590. let box = toPushArray[i]
  591. if (middleBox.materialCode == box.materialCode) {
  592. let number = middleBox.num! + box.num!
  593. box.num = number
  594. has = true
  595. }
  596. }
  597. if (!has) {
  598. toPushArray.push(JSON.parse(JSON.stringify(middleBox)))
  599. }
  600. })
  601. this.boxMaterials = [...toPushArray]
  602. this.MaterialInformation = []
  603. })
  604. }
  605. }
  606. .width(px2vp(1260))
  607. .height(px2vp(100))
  608. .justifyContent(FlexAlign.Center)
  609. }.width(px2vp(1260))
  610. .height(px2vp(900))
  611. Column() {
  612. Stack() {
  613. Image(this.imgSrc)
  614. .width(px2vp(608))
  615. .height('100%')
  616. .borderRadius($r('app.float.borderRadius_16'))
  617. Column() {
  618. Text('抽屉状态')
  619. .textAlign(TextAlign.End)
  620. .width('48%')
  621. .height('20%')
  622. .fontWeight(FontWeight.Regular)
  623. .fontSize($r('app.float.fontSize_20'))
  624. .fontColor($r('app.color.process_nameplate_grey_color'))
  625. Text(this.recentlyRecordObject.lockStr)
  626. .textAlign(TextAlign.End)
  627. .width('48%')
  628. .height('25%')
  629. .fontWeight(FontWeight.Regular)
  630. .fontSize($r('app.float.fontSize_24'))
  631. .fontColor($r('app.color.black_90'))
  632. Blank()
  633. Text('料箱ID')
  634. .textAlign(TextAlign.End)
  635. .width('48%')
  636. .height('20%')
  637. .fontWeight(FontWeight.Regular)
  638. .fontSize($r('app.float.fontSize_20'))
  639. .fontColor($r('app.color.process_nameplate_grey_color'))
  640. Text(this.recentlyRecordObject.rfid)
  641. .textAlign(TextAlign.End)
  642. .width('100%')
  643. .height('25%')
  644. .fontWeight(FontWeight.Regular)
  645. .fontSize($r('app.float.fontSize_24'))
  646. .fontColor($r('app.color.black_90'))
  647. }
  648. .width('100%')
  649. .height('100%')
  650. .padding({ right: $r('app.float.borderRadius_16') })
  651. .alignItems(HorizontalAlign.End)
  652. .borderRadius($r('app.float.borderRadius_16'))
  653. }.width(px2vp(608))
  654. .height('30%')
  655. .borderRadius($r('app.float.borderRadius_16'))
  656. Button(this.materialGridStatus === 1 ? '入库' : '取空箱')
  657. .fontSize($r('app.float.fontSize_24'))
  658. .fontColor($r('app.color.general_font_white_color'))
  659. .width('100%')
  660. .height('10%')
  661. .margin({ top: $r('app.float.topMargins_20') })
  662. .backgroundColor(this.drawerPositionStatus === 1 && this.materialGridStatus === 1 ? $r('app.color.green_100') : (this.drawerPositionStatus === 2 && this.materialGridStatus === 1 ? $r('app.color.Green_20') :
  663. (this.drawerPositionStatus === 1 && this.materialGridStatus === 0 ? $r('app.color.blue_100') : $r('app.color.blue_20'))))
  664. .onClick(() => {
  665. if (this.materialGridStatus === 0) {
  666. this.callEmptyBoxFun()
  667. }
  668. if (this.materialGridStatus === 1) {
  669. this.Warehousing()
  670. }
  671. })
  672. // if (this.emptyBox === 1) {
  673. //
  674. // Column() {
  675. // Text('正在取空箱,当前进度1/' + this.callBoxNum + '...')
  676. // .textAlign(TextAlign.Center)
  677. // .borderRadius(px2vp(16))
  678. // .width('100%')
  679. // .height('25%')
  680. // .fontWeight(FontWeight.Bold)
  681. // .fontSize($r('app.float.fontSize_24'))
  682. // .fontColor($r('app.color.black_90'))
  683. // Text(this.materialGridStatus === 1 ? '请取出料箱' : this.drawerPositionStatus === 2 && this.materialGridStatus === 0 ? '请将料格推入' : '')
  684. // .textAlign(TextAlign.Center)
  685. // .borderRadius(px2vp(16))
  686. // .width('100%')
  687. // .height('25%')
  688. // .fontWeight(FontWeight.Bold)
  689. // .fontSize($r('app.float.fontSize_24'))
  690. // .fontColor($r('app.color.black_90'))
  691. //
  692. // }
  693. // .width('100%')
  694. // .height('60%')
  695. // .justifyContent(FlexAlign.Center)
  696. //
  697. // }
  698. }.width(px2vp(608))
  699. .height('100%')
  700. .focusable(true)
  701. .defaultFocus(false)
  702. }
  703. .width('100%')
  704. .height('92%')
  705. .padding({
  706. left: px2vp(24),
  707. right: px2vp(24),
  708. top: $r('app.float.fontSize_20'),
  709. bottom: $r('app.float.fontSize_20')
  710. })
  711. .focusable(true)
  712. .defaultFocus(false)
  713. }
  714. }
  715. @Component
  716. struct TextInputExample {
  717. @Link exchangeNumber: number
  718. @Link index: number
  719. @Link num: number
  720. @Link private MaterialInformation: Array<MaterialInformationModel>
  721. controller: TextInputController = new TextInputController()
  722. build() {
  723. TextInput({ text:this.num.toString(), controller: this.controller })
  724. .fontSize($r('app.float.title_font_size'))
  725. .fontWeight(FontWeight.Bold)
  726. .fontColor($r('app.color.general_font_color'))// .opacity($r('app.float.general_font_opacity'))
  727. .height('85%')
  728. .width('60%')
  729. .textAlign(TextAlign.Center)
  730. .backgroundColor($r('app.color.general_card_background_color'))
  731. .borderRadius(0)
  732. .border({ width: 0.8 })
  733. .onChange((newValue: string) => {
  734. this.num = Number(newValue)
  735. this.MaterialInformation[this.index] = {
  736. taskId: this.MaterialInformation[this.index].taskId!,
  737. materialName: this.MaterialInformation[this.index].materialName!,
  738. // exchangeNumber:this.MaterialInformation[this.index].exchangeNumber!,
  739. exchangeNumber: this.exchangeNumber,
  740. num: this.num,
  741. materialCode: this.MaterialInformation[this.index].materialCode!,
  742. batchCode: this.MaterialInformation[this.index].batchCode!,
  743. seqNo: this.MaterialInformation[this.index].seqNo!,
  744. spec: this.MaterialInformation[this.index].spec!,
  745. }
  746. console.log('dyy',this.num)
  747. })
  748. }
  749. }
  750. @CustomDialog
  751. ///无批次号物料详情弹窗
  752. struct materialDetails {
  753. @Link exchangeNumber: number
  754. @Link index: number
  755. @Link batchCode: string
  756. @Link materialName: string
  757. @Link num: number
  758. @Link seqNo: string
  759. @Link spec: string
  760. @Link materialNo: string
  761. @Link materialModel: string
  762. @Link private MaterialInformation: Array<MaterialInformationModel>
  763. scroller: Scroller = new Scroller()
  764. @State navigation: number = 0
  765. controller: CustomDialogController
  766. // 若尝试在CustomDialog中传入多个其他的Controller,以实现在CustomDialog中打开另一个或另一些CustomDialog,那么此处需要将指向自己的controller放在最后
  767. build() {
  768. Column() {
  769. Column() {
  770. }.width('100%')
  771. .height('20%')
  772. .onClick(() => {
  773. this.exchangeNumber = 0
  774. this.controller.close()
  775. })
  776. Row() {
  777. Row() {
  778. }.width('25%')
  779. .height('100%')
  780. .onClick(() => {
  781. this.exchangeNumber = 0
  782. this.controller.close()
  783. })
  784. Column({ space: 20 }) {
  785. Text('物料详情')
  786. .textAlign(TextAlign.Center)
  787. .width('100%')
  788. .height('20%')
  789. .fontSize('51px')
  790. .focusable(true)
  791. .defaultFocus(true)
  792. Column({ space: 10 }) {
  793. Text(this.materialName)
  794. .fontSize('32px')
  795. .width('100%')
  796. Text('物料编码:' + this.materialNo)
  797. .fontSize($r('app.float.robot_state_font_size'))
  798. .textAlign(TextAlign.Start)
  799. .fontColor('#99000000')
  800. .width('100%')
  801. Text('规格型号:' + this.materialModel)
  802. .fontSize($r('app.float.robot_state_font_size'))
  803. .textAlign(TextAlign.Start)
  804. .fontColor('#99000000')
  805. .width('100%')
  806. Row(){
  807. Text('批次号:')
  808. .fontSize($r('app.float.robot_state_font_size'))
  809. .textAlign(TextAlign.Start)
  810. .fontColor('#99000000')
  811. .maxLines(1)
  812. .textOverflow({ overflow: TextOverflow.Ellipsis })
  813. Text(this.batchCode)
  814. .fontSize($r('app.float.robot_state_font_size'))
  815. .textAlign(TextAlign.Start)
  816. .fontColor('#99000000')
  817. .maxLines(1)
  818. .textOverflow({ overflow: TextOverflow.Ellipsis })
  819. }
  820. .padding({right:px2vp(40)})
  821. }.width('80%')
  822. .height('30%')
  823. Divider().vertical(false)
  824. .width('60%')
  825. Column() {
  826. // Text('录入数量')
  827. // .fontSize($r('app.float.robot_state_font_size'))
  828. // .textAlign(TextAlign.Start)
  829. // .fontColor('#99000000')
  830. // .width('40%')
  831. Row() {
  832. Image($r('app.media.subtract_disabled'))
  833. .width(px2vp(120))
  834. .height(px2vp(120))
  835. .border({ width: 0.8 })
  836. .borderRadius({ topLeft: px2vp(16), bottomLeft: px2vp(16) })
  837. .onClick(() => {
  838. this.num--
  839. this.exchangeNumber--
  840. this.MaterialInformation[this.index] = {
  841. taskId: this.MaterialInformation[this.index].taskId,
  842. materialName: this.MaterialInformation[this.index].materialName,
  843. // exchangeNumber:this.MaterialInformation[this.index].exchangeNumber,
  844. exchangeNumber: this.exchangeNumber,
  845. num: this.num,
  846. materialCode: this.MaterialInformation[this.index].materialCode,
  847. batchCode: this.MaterialInformation[this.index].batchCode,
  848. seqNo: this.MaterialInformation[this.index].seqNo,
  849. spec: this.MaterialInformation[this.index].spec,
  850. }
  851. })
  852. TextInputExample({
  853. MaterialInformation:this.MaterialInformation,
  854. num:this.num,
  855. exchangeNumber:this.exchangeNumber,
  856. index:this.index
  857. })
  858. // TextInput({ text:this.num.toString() })
  859. // .fontSize($r('app.float.title_font_size'))
  860. // .fontWeight(FontWeight.Bold)
  861. // .fontColor($r('app.color.general_font_color'))// .opacity($r('app.float.general_font_opacity'))
  862. // .height('85%')
  863. // .width('60%')
  864. // .textAlign(TextAlign.Center)
  865. // .backgroundColor($r('app.color.general_card_background_color'))
  866. // .borderRadius(0)
  867. // .border({ width: 0.8 })
  868. // .onChange(() => {
  869. // this.MaterialInformation[this.index] = {
  870. // taskId: this.MaterialInformation[this.index].taskId!,
  871. // materialName: this.MaterialInformation[this.index].materialName!,
  872. // // exchangeNumber:this.MaterialInformation[this.index].exchangeNumber!,
  873. // exchangeNumber: this.exchangeNumber,
  874. // num: this.num,
  875. // materialCode: this.MaterialInformation[this.index].materialCode!,
  876. // batchCode: this.MaterialInformation[this.index].batchCode!,
  877. // seqNo: this.MaterialInformation[this.index].seqNo!,
  878. // spec: this.MaterialInformation[this.index].spec!,
  879. // }
  880. // })
  881. Image($r('app.media.add_disabled'))
  882. .width(px2vp(120))
  883. .height(px2vp(120))
  884. .border({ width: 0.8 })
  885. .borderRadius({ topRight: px2vp(16), bottomRight: px2vp(16) })
  886. .onClick(() => {
  887. this.exchangeNumber++
  888. this.num++
  889. this.MaterialInformation[this.index] = {
  890. taskId: this.MaterialInformation[this.index].taskId,
  891. materialName: this.MaterialInformation[this.index].materialName,
  892. //exchangeNumber:this.MaterialInformation[this.index].exchangeNumber,
  893. exchangeNumber: this.exchangeNumber,
  894. num: this.num,
  895. materialCode: this.MaterialInformation[this.index].materialCode,
  896. batchCode: this.MaterialInformation[this.index].batchCode,
  897. seqNo: this.MaterialInformation[this.index].seqNo,
  898. spec: this.MaterialInformation[this.index].spec,
  899. }
  900. // this.exchange[this.exchangeIndex]={
  901. // exchangeNumber:this.exchange[this.exchangeIndex].exchangeNumber
  902. // }
  903. })
  904. }
  905. .width('60%')
  906. .height('20%')
  907. }
  908. }.width('50%')
  909. .height('100%')
  910. .backgroundColor('#F1F3F5')
  911. .borderRadius(20)
  912. Row() {
  913. }.width('25%')
  914. .height('100%')
  915. .onClick(() => {
  916. this.exchangeNumber = 0
  917. this.controller.close()
  918. })
  919. }.width('100%')
  920. .height('60%')
  921. Column() {
  922. }.width('100%')
  923. .height('20%')
  924. .onClick(() => {
  925. this.controller.close()
  926. })
  927. }
  928. .width('100%')
  929. .backgroundColor('#4d000000')
  930. .height('100%')
  931. .justifyContent(FlexAlign.Center)
  932. .focusable(true)
  933. .defaultFocus(false)
  934. // dialog默认的borderRadius为24vp,如果需要使用border属性,请和borderRadius属性一起使用。
  935. }
  936. }
  937. //RFID读取失败弹窗
  938. @CustomDialog
  939. struct RfidCar {
  940. controller: CustomDialogController
  941. build() {
  942. Column() {
  943. Text('RFID读取失败')
  944. .fontWeight(FontWeight.Medium)
  945. .fontSize($r('app.float.fontSize_50'))
  946. Blank()
  947. Text('请检查RFID读卡器或料箱底部识别卡片是否正常!')
  948. .fontWeight(FontWeight.Medium)
  949. .fontSize($r('app.float.fontSize_38'))
  950. Blank()
  951. Button('取消', { type: ButtonType.Normal, stateEffect: true })
  952. .width(px2vp(252))
  953. .height(px2vp(70))
  954. .borderRadius(px2vp(75))
  955. .fontSize($r('app.float.fontSize_20'))
  956. .onClick(() => {
  957. this.controller.close()
  958. })
  959. }
  960. .width(px2vp(924))
  961. .height(px2vp(536))
  962. .padding({ top: px2vp(60), bottom: px2vp(60) })
  963. .borderRadius($r('app.float.borderRadius_16'))
  964. .backgroundColor($r('app.color.white_100'))
  965. }
  966. }
  967. // 自定义键盘
  968. @Builder
  969. function CustomKeyboardBuilderEmpty() {
  970. Column() {
  971. }
  972. .width(0)
  973. .height(0)
  974. }