OperationMaterialKitTwoStep.ets 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864
  1. import OperationInfo from '../../viewmodel/wms/OperationInfo'
  2. import WorkOrderInfo from '../../viewmodel/wms/WorkOrderInfo'
  3. import OperationItem from '../../viewmodel/wms/OperationItem'
  4. import WmsRequest from '../../common/util/request/WmsRequest'
  5. import RequestParamModel from '../../viewmodel/wms/RequestParamModel'
  6. import MaterialBoxInfo from '../../viewmodel/wms/MaterialBoxInfo'
  7. import CommonConstants from '../../common/constants/CommonConstants'
  8. import DictInfo from '../../viewmodel/DictInfo'
  9. import HashMap from '@ohos.util.HashMap'
  10. import VehicleInfo from '../../viewmodel/wms/VehicleInfo'
  11. import { InBoundView } from '../../component/InBoundView'
  12. import MaterialInfo from '../../viewmodel/wms/MaterialInfo'
  13. import promptAction from '@ohos.promptAction'
  14. import OperationMaterial from '../../viewmodel/wms/OperationMaterial'
  15. @Component
  16. export struct OperationMaterialKitTwoStep {
  17. @Link workOrder: WorkOrderInfo
  18. @Link selectOperations: OperationInfo[]
  19. @Link operationItems: OperationItem[]
  20. @Link scanMaterialArray: MaterialInfo[]
  21. // 选择已有料箱,出库料箱
  22. @Consume('currentVehicleCode') currentVehicleCode: string
  23. // 出库料箱中的库存物料信息
  24. @State outMaterialBoxInfos: MaterialInfo[] = []
  25. // 出库料箱中物料数量(出入口料口使用)
  26. @Link materialNum: number
  27. @Link scanMaterialList: MaterialInfo[]
  28. // 物料全数组(本次扫描物料弹窗中展示)
  29. @Link materialArray: MaterialInfo[]
  30. // 数量合并的物料数组(在拣选工作台展示)
  31. @Link materialMergeArray: MaterialInfo[]
  32. selectOperationIds: string[] = []
  33. // 每个工序需要的物料编码分组
  34. operationItemCodes: HashMap<string, string[]> = new HashMap<string, string[]>()
  35. @State operationNames: string = ''
  36. @State materialBoxInfos: MaterialBoxInfo[] = []
  37. // 空箱编码
  38. @State vehicleCode: string = ''
  39. // 扫描或手动输入的物料编码
  40. @State scanCode: string = ''
  41. //齐套料箱扫码后如果物料存在则自动滚动所在行
  42. @State scanCodeIndex: number = -1
  43. // 绑定物料数量
  44. @State bindMaterialNum: number = 0
  45. materialScrollerController: Scroller = new Scroller()
  46. // 选择料箱弹窗控制器
  47. selectMaterialBoxDialogController: CustomDialogController = new CustomDialogController({
  48. builder: SelectMaterialBoxDialog({
  49. MaterialBoxInfos: this.materialBoxInfos,
  50. confirm: async () => {
  51. if (!this.currentVehicleCode || !this.materialBoxInfos || this.materialBoxInfos.length <= 0) {
  52. return
  53. }
  54. let houseNo = ''
  55. for (const element of this.materialBoxInfos) {
  56. if (this.currentVehicleCode === element.vehicleCode) {
  57. houseNo = element.houseNo!
  58. }
  59. }
  60. let res: VehicleInfo = await WmsRequest.post('/api/v1/wmsOrder/outBox', {
  61. houseNo: houseNo,
  62. vehicleNo:this.currentVehicleCode,
  63. } as RequestParamModel)
  64. if (res && res.list) {
  65. this.outMaterialBoxInfos = res.list
  66. }
  67. }
  68. }),
  69. autoCancel: true, // 点击遮罩关闭
  70. customStyle: true,
  71. })
  72. // 本次扫描物料弹窗控制器
  73. thisScanDialogController: CustomDialogController = new CustomDialogController({
  74. builder: ThisScanDialog({
  75. materialMergeArray: this.materialMergeArray,
  76. materialArray: this.materialArray,
  77. outMaterialBoxInfos: this.outMaterialBoxInfos,
  78. materialNum: this.materialNum,
  79. confirm: async () => {}
  80. }),
  81. autoCancel: true, // 点击遮罩关闭
  82. customStyle: true,
  83. })
  84. // 齐套操作-扫描物料
  85. scanMaterialCode = async (itemCode: string) => {
  86. this.scanCode = ''
  87. let res: MaterialInfo = await WmsRequest.post('/api/v1/process/circulation/material', {
  88. label: itemCode //'#gys022#sc022#100#20220929#31'
  89. } as RequestParamModel)
  90. // 判断扫描完成后返回的物料码是否是当前需要齐套的物料
  91. let hasFlag: boolean = false
  92. for (const item of this.operationItems) {
  93. if (res.materialCode === item.itemCode) {
  94. hasFlag = true
  95. break
  96. }
  97. }
  98. if (!hasFlag) {
  99. promptAction.showToast({
  100. message: '不是当前工序中的物料',
  101. bottom: '50%',
  102. duration: 2000
  103. })
  104. return
  105. }
  106. // 判断数量合并的物料数组是否有,有则合并数量并滚动到当前位置,没有则数组头部新增
  107. hasFlag = false
  108. for (let i = 0; i < this.materialMergeArray.length; i++) {
  109. if (res.materialCode === this.materialMergeArray[i].materialCode) {
  110. hasFlag = true
  111. this.scanCodeIndex = i
  112. this.materialMergeArray[i].num = this.materialMergeArray[i].num! + res.num!
  113. this.materialMergeArray[i] = JSON.parse(JSON.stringify(this.materialMergeArray[i]))
  114. break;
  115. }
  116. }
  117. if (!hasFlag) {
  118. this.materialMergeArray.unshift(res)
  119. this.scanCodeIndex = 0
  120. }
  121. // 物料全数组默认都新增在数组头部
  122. this.materialArray.unshift(res)
  123. this.materialScrollerController.scrollToIndex(this.scanCodeIndex)
  124. // 出库料箱中的库存物料 需要做出库操作
  125. let toChangeArray: MaterialInfo[] = [...this.outMaterialBoxInfos]
  126. for (let i = 0; i < toChangeArray.length; i++) {
  127. let box = toChangeArray[i]
  128. if (res.materialCode == box.materialCode) {
  129. let value = box.num! - res.num!
  130. box.num = value >= 0 ? value : 0
  131. continue
  132. }
  133. }
  134. this.outMaterialBoxInfos = toChangeArray.filter((m) => {
  135. return m.num! > 0
  136. })
  137. this.materialNum = this.outMaterialBoxInfos.length
  138. }
  139. // 齐套绑定
  140. toCompleteKitting = async () => {
  141. // 接口只支持根据工序去绑定,需要先遍历
  142. let paramArray: RequestParamModel[] = []
  143. this.operationItemCodes.forEach((value: string[], key: string) => {
  144. let itemArray: MaterialInfo[] = []
  145. for (const material of this.materialMergeArray) {
  146. if (value.includes(material.materialCode)) {
  147. itemArray.push(material)
  148. }
  149. }
  150. // 当前工序有齐套物料绑定
  151. if (itemArray.length > 0) {
  152. let param: RequestParamModel = {
  153. operationId: key,
  154. workOrderCode: this.workOrder.workOrderCode!,
  155. vehicleCode: this.vehicleCode,
  156. processVehicleMaterialList: itemArray
  157. }
  158. paramArray.push(param)
  159. }
  160. })
  161. if (paramArray.length <= 0) {
  162. return
  163. }
  164. for (const param of paramArray) {
  165. await WmsRequest.post('api/v1/process/vehicleOperation/add', param)
  166. }
  167. // 重新刷新调取料箱下方物料已齐套数量
  168. let result: OperationMaterial[] = await WmsRequest.post('/api/v1/wms/operationMaterial/list', {
  169. //查询工序需求的物料
  170. operationIds: this.selectOperationIds,
  171. } as RequestParamModel) as OperationMaterial[]
  172. this.operationItems = []
  173. if (result && result.length > 0) {
  174. for (const element of result) {
  175. this.operationItems = this.operationItems.concat(element.itemList!);
  176. }
  177. }
  178. this.bindMaterialNum += this.materialMergeArray.length
  179. this.scanMaterialArray.concat(this.materialMergeArray)
  180. this.materialArray = []
  181. this.materialMergeArray = []
  182. }
  183. async aboutToAppear() {
  184. if (this.selectOperations) {
  185. this.selectOperations.sort((a: OperationInfo, b: OperationInfo) => {
  186. if (a.operationSort === null) return 1;
  187. if (b.operationSort === null) return -1;
  188. return a.operationSort! - b.operationSort!;
  189. })
  190. // 拼接工序名称
  191. for (let i = 0; i < this.selectOperations.length; i++) {
  192. this.operationNames += this.selectOperations[i].operationName
  193. if (i < this.selectOperations.length - 1) {
  194. this.operationNames += '、'
  195. }
  196. }
  197. }
  198. for (const operation of this.selectOperations) {
  199. this.selectOperationIds.push(operation.id!)
  200. for (const item of this.operationItems) {
  201. if (operation.id != item.operationId) {
  202. continue
  203. }
  204. let itemCodes: string[] = []
  205. if (this.operationItemCodes.hasKey(operation.id)) {
  206. itemCodes = this.operationItemCodes.get(operation.id)
  207. }
  208. itemCodes.push(item.itemCode!)
  209. this.operationItemCodes.set(operation.id, itemCodes)
  210. }
  211. }
  212. }
  213. build() {
  214. Row() {
  215. // 调取料箱
  216. Column() {
  217. Row() {
  218. Text('调取料箱')
  219. .fontSize($r('app.float.fontSize_30'))
  220. .fontColor($r('app.color.FFFFFF'))
  221. .fontWeight(FontWeight.Medium)
  222. }
  223. .height('10%')
  224. .width('100%')
  225. .justifyContent(FlexAlign.Center)
  226. // 订单名称和选择的工序名称
  227. Column() {
  228. Text(this.workOrder?.orderName!)
  229. .fontSize($r('app.float.fontSize_12'))
  230. .fontColor($r('app.color.FFFFFF'))
  231. .fontWeight(FontWeight.Lighter)
  232. Text(this.operationNames)
  233. .fontSize($r('app.float.fontSize_12'))
  234. .fontColor($r('app.color.FFFFFF'))
  235. .fontWeight(FontWeight.Lighter)
  236. }
  237. .height('6.5%')
  238. // 工序需要采集的物料列表
  239. List({space: 5}) {
  240. ForEach(this.operationItems, (item: OperationItem, index: number) => {
  241. ListItem() {
  242. Column() {
  243. Row() {
  244. Text(item.itemName! + '-' + item.itemCode)
  245. .fontSize($r('app.float.fontSize_24'))
  246. .fontWeight(FontWeight.Medium)
  247. .fontColor($r('app.color.FFFFFF'))
  248. .maxLines(1)
  249. }
  250. .height('38%')
  251. .width('91%')
  252. .alignItems(VerticalAlign.Bottom)
  253. Column({space: 5}) {
  254. Text('型号:' +item.itemModel!)
  255. .fontSize($r('app.float.fontSize_16'))
  256. .fontWeight(FontWeight.Lighter)
  257. .fontColor($r('app.color.FFFFFF'))
  258. .maxLines(1)
  259. Text('已齐套/需求:' + item.kitNum! + '/' + item.num! + item.unit!)
  260. .fontSize($r('app.float.fontSize_16'))
  261. .fontWeight(FontWeight.Lighter)
  262. .fontColor($r('app.color.FFFFFF'))
  263. .maxLines(1)
  264. }
  265. .height('48.3%')
  266. .width('91%')
  267. .justifyContent(FlexAlign.Center)
  268. .alignItems(HorizontalAlign.Start)
  269. }
  270. .height('15.4%')
  271. .width('92.6%')
  272. .borderRadius($r('app.float.virtualSize_16'))
  273. .justifyContent(FlexAlign.Start)
  274. .backgroundColor($r('app.color.20FFFFFF'))
  275. .opacity(item.storageNum! > 0 ? 1 : 0.3)
  276. .onClick(async ()=>{
  277. if (!item.storageNum || item.storageNum! <= 0) {
  278. return
  279. }
  280. this.materialBoxInfos = await WmsRequest.post('/api/v1/process/vehicleOperation/processVehicle', {
  281. label: item.itemCode
  282. } as RequestParamModel) as MaterialBoxInfo[]
  283. if (this.materialBoxInfos) {
  284. for (const element of this.materialBoxInfos) {
  285. if (element.coordinate && element.coordinate.length > 0 && element.coordinate.indexOf('-') > 0) {
  286. let coors = element.coordinate.split('-');
  287. element.x = parseInt(coors[0])
  288. element.y = parseInt(coors[1])
  289. }
  290. }
  291. }
  292. this.selectMaterialBoxDialogController.open()
  293. })
  294. }
  295. })
  296. }
  297. .width('100%')
  298. .height('83%')
  299. .alignListItem(ListItemAlign.Center)
  300. }
  301. .height('100%')
  302. .width('29.6%')
  303. .borderRadius($r('app.float.virtualSize_16'))
  304. .justifyContent(FlexAlign.Center)
  305. .backgroundColor($r('app.color.10FFFFFF'))
  306. Image($r('app.media.wms_arrow_right'))
  307. .height($r('app.float.virtualSize_48'))
  308. .width($r('app.float.virtualSize_48'))
  309. // 出入库料口操作
  310. Column() {
  311. InBoundView({
  312. materialNum:this.materialNum,
  313. boxMaterials:this.scanMaterialList
  314. })
  315. }
  316. .height('100%')
  317. .width('29.6%')
  318. .borderRadius($r('app.float.virtualSize_16'))
  319. .justifyContent(FlexAlign.Center)
  320. .backgroundColor($r('app.color.10FFFFFF'))
  321. Image($r('app.media.wms_arrow_right'))
  322. .height($r('app.float.virtualSize_48'))
  323. .width($r('app.float.virtualSize_48'))
  324. // 拣选工作台
  325. Column() {
  326. Row() {
  327. Text('拣选工作台')
  328. .fontSize($r('app.float.fontSize_30'))
  329. .fontColor($r('app.color.FFFFFF'))
  330. .fontWeight(FontWeight.Medium)
  331. }
  332. .height('10%')
  333. .width('100%')
  334. .justifyContent(FlexAlign.Center)
  335. Stack() {
  336. Image(this.vehicleCode && this.vehicleCode.length > 0 ? $r('app.media.wms_read_vehicle') : $r('app.media.wms_not_read_vehicle'))
  337. .width('100%')
  338. .height('100%')
  339. .borderRadius($r('app.float.virtualSize_16'))
  340. .objectFit(ImageFit.Fill)
  341. Column() {
  342. Row() {
  343. Text('物料:' + this.bindMaterialNum)
  344. .fontSize($r('app.float.fontSize_24'))
  345. .fontColor($r('app.color.0A84FF'))
  346. .fontWeight(FontWeight.Medium)
  347. }
  348. .width('29.2%')
  349. .height('30.8%')
  350. .alignItems(VerticalAlign.Center)
  351. .justifyContent(FlexAlign.Center)
  352. .borderRadius($r('app.float.virtualSize_16'))
  353. .backgroundColor($r('app.color.60000000'))
  354. .margin({top: $r('app.float.virtualSize_12'), right: $r('app.float.virtualSize_12')})
  355. Blank()
  356. Row({space: 3}) {
  357. Image($r('app.media.wms_card_reader'))
  358. .height($r('app.float.virtualSize_24'))
  359. .width($r('app.float.virtualSize_24'))
  360. .fillColor(this.vehicleCode && this.vehicleCode.length > 0 ? $r('app.color.30D158') : $r('app.color.FF453A'))
  361. Text(this.vehicleCode)
  362. .fontSize($r('app.float.fontSize_30'))
  363. .fontColor($r('app.color.30D158'))
  364. .fontWeight(FontWeight.Medium)
  365. }
  366. .height('24%')
  367. .width('96.8%')
  368. .justifyContent(FlexAlign.Start)
  369. .padding({bottom: 3})
  370. }
  371. .width('100%')
  372. .height('100%')
  373. .alignItems(HorizontalAlign.End)
  374. }
  375. .height('23.8%')
  376. .width('92.6%')
  377. // 扫码框
  378. Row() {
  379. Row() {
  380. Row().width('3.4%')
  381. // 左侧二维码图标
  382. Image($r('app.media.general_qr_code')) // 请替换为您的二维码图片资源
  383. .width($r('app.float.virtualSize_24'))
  384. .height($r('app.float.virtualSize_24'))
  385. .fillColor($r('app.color.FFFFFF'))
  386. // 扫码输入框
  387. TextInput({ placeholder: '请扫描物料编码', text: this.scanCode })
  388. .type(InputType.Normal)
  389. .placeholderFont({ size: $r('app.float.fontSize_16')})
  390. .placeholderColor($r('app.color.30FFFFFF'))
  391. .fontSize($r('app.float.fontSize_16'))
  392. .fontColor($r('app.color.FFFFFF'))
  393. .enableKeyboardOnFocus(false)
  394. .onChange((value: string) => {
  395. this.scanCode = value
  396. })
  397. .onSubmit(async () => {
  398. this.scanMaterialCode(this.scanCode)
  399. })
  400. }
  401. .width('82%')
  402. .height('100%')
  403. .borderRadius($r('app.float.virtualSize_16'))
  404. .backgroundColor($r('app.color.000000'))
  405. .justifyContent(FlexAlign.Start)
  406. }
  407. .height('7.3%')
  408. .width('92.6%')
  409. .margin({top: $r('app.float.virtualSize_20'), bottom: $r('app.float.fontSize_12')})
  410. // 扫码得到的物料列表
  411. List({ scroller: this.materialScrollerController }) {
  412. ForEach(this.materialMergeArray, (item: MaterialInfo)=>{
  413. ListItem() {
  414. Column() {
  415. Row() {
  416. Text(item.materialName! + '-' + item.materialCode!)
  417. .fontSize($r('app.float.fontSize_16'))
  418. .fontWeight(FontWeight.Bold)
  419. .fontColor($r('app.color.FFFFFF'))
  420. .maxLines(1)
  421. Text((item.num ? item.num.toString() : '0') + item.unit!)
  422. .fontSize($r('app.float.fontSize_16'))
  423. .fontWeight(FontWeight.Bold)
  424. .fontColor($r('app.color.FFFFFF'))
  425. .maxLines(1)
  426. }
  427. .width('100%')
  428. .justifyContent(FlexAlign.SpaceBetween)
  429. Row() {
  430. Text('型号:' + (item.spec ? item.spec : ''))
  431. .fontSize($r('app.float.fontSize_12'))
  432. .fontWeight(FontWeight.Lighter)
  433. .fontColor($r('app.color.FFFFFF'))
  434. .maxLines(1)
  435. Text('本次添加')
  436. .fontSize($r('app.float.fontSize_12'))
  437. .fontWeight(FontWeight.Lighter)
  438. .fontColor($r('app.color.60FFFFFF'))
  439. }
  440. .width('100%')
  441. .justifyContent(FlexAlign.SpaceBetween)
  442. Divider().vertical(false)
  443. .color($r('app.color.15FFFFFF'))
  444. .width('100%')
  445. }
  446. .height('25%')
  447. .width('92.6%')
  448. .justifyContent(FlexAlign.SpaceBetween)
  449. }
  450. })
  451. }
  452. .height('21.9%')
  453. .width('92.6%')
  454. .alignListItem(ListItemAlign.Center)
  455. Row() {
  456. Text('本次扫描物料')
  457. .fontSize($r('app.float.fontSize_24'))
  458. .fontColor($r('app.color.0A84FF'))
  459. .fontWeight(FontWeight.Medium)
  460. .textAlign(TextAlign.Center)
  461. .width('100%')
  462. .height('37.3%')
  463. .borderRadius($r('app.float.virtualSize_16'))
  464. .backgroundColor($r('app.color.20FFFFFF'))
  465. }
  466. .height('19.6%')
  467. .width('44.4%')
  468. .justifyContent(FlexAlign.Center)
  469. .onClick(()=>{
  470. this.thisScanDialogController.open()
  471. })
  472. Text('齐套绑定')
  473. .fontSize($r('app.float.fontSize_24'))
  474. .fontColor($r('app.color.0A84FF'))
  475. .fontWeight(FontWeight.Medium)
  476. .textAlign(TextAlign.Center)
  477. .width('92.6%')
  478. .height('7.3%')
  479. .borderRadius($r('app.float.virtualSize_16'))
  480. .backgroundColor($r('app.color.20FFFFFF'))
  481. .onClick(async ()=>{
  482. this.toCompleteKitting()
  483. })
  484. }
  485. .height('100%')
  486. .width('29.6%')
  487. .borderRadius($r('app.float.virtualSize_16'))
  488. .justifyContent(FlexAlign.Center)
  489. .backgroundColor($r('app.color.10FFFFFF'))
  490. }
  491. .width('100%')
  492. .height('100%')
  493. .justifyContent(FlexAlign.SpaceBetween)
  494. }
  495. }
  496. // 库存信息弹窗(选择料箱)
  497. @CustomDialog
  498. struct SelectMaterialBoxDialog {
  499. // 若尝试在CustomDialog中传入多个其他的Controller,以实现在CustomDialog中打开另一个或另一些CustomDialog,那么此处需要将指向自己的controller放在最后
  500. controller?: CustomDialogController
  501. cancel?: () => void = () => {
  502. }
  503. confirm: () => void = () => {
  504. }
  505. vehicleTypeDictType: string = 'vehicle_type'
  506. vehicleTypeDictMap: HashMap<string, string> = new HashMap<string, string>()
  507. MaterialBoxInfos: MaterialBoxInfo[] = []
  508. scroller: Scroller = new Scroller()
  509. @Consume('currentVehicleCode') currentVehicleCode: string
  510. async aboutToAppear() {
  511. if (!CommonConstants.DICT_DATA || CommonConstants.DICT_DATA.length <= 0) {
  512. let res: DictInfo[] = await WmsRequest.post('/api/v1/sys/dictData/all',)
  513. if (res && res.length > 0) {
  514. for (const dict of res) {
  515. CommonConstants.DICT_DATA.set(dict.dictCode, dict.list)
  516. if (this.vehicleTypeDictType === dict.dictCode) {
  517. for (const element of dict?.list!) {
  518. this.vehicleTypeDictMap.set(element.dictValue, element.dictLabel);
  519. }
  520. }
  521. }
  522. }
  523. } else {
  524. let dictList = CommonConstants.DICT_DATA.get(this.vehicleTypeDictType);
  525. for (const element of dictList) {
  526. this.vehicleTypeDictMap.set(element.dictValue, element.dictLabel);
  527. }
  528. }
  529. }
  530. build() {
  531. Column() {
  532. Row() {
  533. Text('选择料箱')
  534. .fontWeight(FontWeight.Medium)
  535. .fontSize($r('app.float.fontSize_30'))
  536. .fontColor($r('app.color.FFFFFF'))
  537. .fontWeight(FontWeight.Medium)
  538. }
  539. .height('10%')
  540. .width('100%')
  541. .justifyContent(FlexAlign.Center)
  542. // 动态排列容器
  543. Scroll() {
  544. Flex({ wrap: FlexWrap.Wrap, direction: FlexDirection.Column, justifyContent: FlexAlign.Start, alignItems: ItemAlign.Start}) {
  545. ForEach(this.MaterialBoxInfos, (item: MaterialBoxInfo, index: number) => {
  546. Column({ space: 5 }) {
  547. Row() {
  548. Text(item.materials?.[0]?.materialName! + '-' + item.materials?.[0]?.materialNo!)
  549. .fontSize($r('app.float.fontSize_24'))
  550. .fontWeight(FontWeight.Medium)
  551. .fontColor($r('app.color.FFFFFF'))
  552. .maxLines(1)
  553. }
  554. .height('28.5%')
  555. .width('87.4%')
  556. .alignItems(VerticalAlign.Bottom)
  557. Column() {
  558. Text('料箱编号:' + item.vehicleCode!)
  559. .fontSize($r('app.float.fontSize_16'))
  560. .fontWeight(FontWeight.Lighter)
  561. .fontColor($r('app.color.FFFFFF'))
  562. .maxLines(1)
  563. Text('料箱类型:' + (this.vehicleTypeDictMap.get(item.vehicleCategory!) ? this.vehicleTypeDictMap.get(item.vehicleCategory!) : item.vehicleCategory!))
  564. .fontSize($r('app.float.fontSize_16'))
  565. .fontWeight(FontWeight.Lighter)
  566. .fontColor($r('app.color.FFFFFF'))
  567. .maxLines(1)
  568. Text('所属订单:')
  569. .fontSize($r('app.float.fontSize_16'))
  570. .fontWeight(FontWeight.Lighter)
  571. .fontColor($r('app.color.FFFFFF'))
  572. .maxLines(1)
  573. Text('数量:' + item.materials?.[0]?.num! + item.unit!)
  574. .fontSize($r('app.float.fontSize_16'))
  575. .fontWeight(FontWeight.Lighter)
  576. .fontColor($r('app.color.FFFFFF'))
  577. .maxLines(1)
  578. Text('位置:X-' + item.x! + ' Y-' + item.y!)
  579. .fontSize($r('app.float.fontSize_16'))
  580. .fontWeight(FontWeight.Lighter)
  581. .fontColor($r('app.color.FFFFFF'))
  582. .maxLines(1)
  583. }
  584. .height('48.3%')
  585. .width('87.4%')
  586. .justifyContent(FlexAlign.Center)
  587. .alignItems(HorizontalAlign.Start)
  588. }
  589. .width('32.8%')
  590. .height('25%')
  591. .borderRadius($r('app.float.virtualSize_16'))
  592. .backgroundColor(this.currentVehicleCode === item.vehicleCode ? $r('app.color.2030D158') : $r('app.color.20FFFFFF'))
  593. .borderWidth(1)
  594. .borderColor(this.currentVehicleCode === item.vehicleCode ? $r('app.color.30D158') : $r('app.color.20FFFFFF'))
  595. .margin({ top: index > 2 ? '1%' : '0%', left: (index % 3) === 0 ? '0%' : '0.8%' })
  596. .onClick(()=>{
  597. this.currentVehicleCode = item.vehicleCode!
  598. })
  599. })
  600. }
  601. .width('100%')
  602. }
  603. .scrollable(ScrollDirection.Vertical) // 垂直滚动
  604. .scrollBar(BarState.Auto)
  605. .width('96.6%')
  606. .height('82.7%')
  607. Divider().vertical(false).color($r('app.color.15FFFFFF'))
  608. .width('100%')
  609. Row() {
  610. Row() {
  611. Text('关闭')
  612. .fontColor($r('app.color.60FFFFFF'))
  613. .fontSize($r('app.float.fontSize_16'))
  614. .fontWeight(FontWeight.Medium)
  615. }
  616. .width('50%')
  617. .justifyContent(FlexAlign.Center)
  618. .onClick(()=>{
  619. if (this.controller != undefined) {
  620. this.controller.close()
  621. }
  622. })
  623. Divider().vertical(true).color($r('app.color.15FFFFFF'))
  624. .height('100%')
  625. Row() {
  626. Text('料箱出库')
  627. .fontColor($r('app.color.007AFF'))
  628. .fontSize($r('app.float.fontSize_16'))
  629. .fontWeight(FontWeight.Medium)
  630. }
  631. .width('50%')
  632. .justifyContent(FlexAlign.Center)
  633. .onClick(()=>{
  634. this.confirm()
  635. if (this.controller != undefined) {
  636. this.controller.close()
  637. }
  638. })
  639. }
  640. .width('100%')
  641. .height('7.3%')
  642. .justifyContent(FlexAlign.Center)
  643. }
  644. .width('61.5%')
  645. .height('71%')
  646. .justifyContent(FlexAlign.Start)
  647. .backgroundColor($r('app.color.2A2A2A'))
  648. .borderRadius($r('app.float.virtualSize_16'))
  649. }
  650. }
  651. // 本次扫描物料弹窗
  652. @CustomDialog
  653. struct ThisScanDialog {
  654. // 若尝试在CustomDialog中传入多个其他的Controller,以实现在CustomDialog中打开另一个或另一些CustomDialog,那么此处需要将指向自己的controller放在最后
  655. controller?: CustomDialogController
  656. cancel?: () => void = () => {
  657. }
  658. confirm: () => void = () => {
  659. }
  660. MaterialBoxInfos: MaterialBoxInfo[] = []
  661. scroller: Scroller = new Scroller()
  662. @Link materialArray: MaterialInfo[]
  663. @Link materialMergeArray: MaterialInfo[]
  664. // 出库料箱的物料信息
  665. @Link outMaterialBoxInfos: MaterialInfo[]
  666. @Link materialNum: number
  667. @State tempArray: MaterialInfo[] = []
  668. tempMergeArray: MaterialInfo[] = []
  669. deleteArray: MaterialInfo[] = []
  670. aboutToAppear(): void {
  671. if (this.materialArray && this.materialArray.length > 0) {
  672. this.tempArray = JSON.parse(JSON.stringify(this.materialArray));
  673. }
  674. if (this.materialMergeArray && this.materialMergeArray.length > 0) {
  675. this.tempMergeArray = JSON.parse(JSON.stringify(this.materialMergeArray));
  676. }
  677. }
  678. build() {
  679. Column() {
  680. Row() {
  681. Text('本次扫描物料')
  682. .fontWeight(FontWeight.Medium)
  683. .fontSize($r('app.float.fontSize_30'))
  684. .fontColor($r('app.color.FFFFFF'))
  685. .fontWeight(FontWeight.Medium)
  686. }
  687. .height('10%')
  688. .width('100%')
  689. .justifyContent(FlexAlign.Center)
  690. List({space: 4, scroller: this.scroller}) {
  691. ForEach(this.tempArray, (item: MaterialInfo, index: number) => {
  692. ListItem() {
  693. Row() {
  694. Column({space: 1}) {
  695. Text(item.materialName! + '-' + item.materialCode!)
  696. .fontSize($r('app.float.fontSize_24'))
  697. .fontWeight(FontWeight.Medium)
  698. .fontColor($r('app.color.FFFFFF'))
  699. .maxLines(1)
  700. Column() {
  701. Text('型号:' + item.spec!)
  702. .fontSize($r('app.float.fontSize_16'))
  703. .fontWeight(FontWeight.Lighter)
  704. .fontColor($r('app.color.FFFFFF'))
  705. .maxLines(1)
  706. Text('序列号:' + item.batchCode!)
  707. .fontSize($r('app.float.fontSize_16'))
  708. .fontWeight(FontWeight.Lighter)
  709. .fontColor($r('app.color.FFFFFF'))
  710. .maxLines(1)
  711. Text('所属订单:-')
  712. .fontSize($r('app.float.fontSize_16'))
  713. .fontWeight(FontWeight.Lighter)
  714. .fontColor($r('app.color.FFFFFF'))
  715. .maxLines(1)
  716. Text('数量:' + item.num! + item.unit!)
  717. .fontSize($r('app.float.fontSize_16'))
  718. .fontWeight(FontWeight.Lighter)
  719. .fontColor($r('app.color.FFFFFF'))
  720. .maxLines(1)
  721. }
  722. .height('52.8%')
  723. .width('100%')
  724. .justifyContent(FlexAlign.SpaceBetween)
  725. .alignItems(HorizontalAlign.Start)
  726. }
  727. .height('100%')
  728. .width('48%')
  729. .alignItems(HorizontalAlign.Start)
  730. .justifyContent(FlexAlign.Center)
  731. Row() {
  732. Image($r('app.media.material_delete'))
  733. .height($r('app.float.virtualSize_48'))
  734. .width($r('app.float.virtualSize_48'))
  735. .fillColor($r('app.color.FF453A'))
  736. .onClick(()=>{
  737. this.deleteArray.push(item)
  738. for (let i = 0; i < this.tempMergeArray.length; i++) {
  739. if (this.tempMergeArray[i].materialCode! === this.tempArray[index].materialCode!) {
  740. if (this.tempMergeArray[i].num! === this.tempArray[index].num!) {
  741. this.tempMergeArray.splice(i, 1)
  742. break;
  743. } else {
  744. this.tempMergeArray[i].num = this.tempMergeArray[i].num! - this.tempArray[index].num!;
  745. break;
  746. }
  747. }
  748. }
  749. this.tempArray.splice(index, 1)
  750. })
  751. Row().width('2%')
  752. }
  753. .height('100%')
  754. .width('50%')
  755. .alignItems(VerticalAlign.Center)
  756. .justifyContent(FlexAlign.End)
  757. }
  758. .height('22.7%')
  759. .width('100%')
  760. .justifyContent(FlexAlign.Center)
  761. .borderRadius($r('app.float.virtualSize_16'))
  762. .backgroundColor($r('app.color.10FFFFFF'))
  763. }
  764. })
  765. }
  766. .alignListItem(ListItemAlign.Center)
  767. .width('96.6%')
  768. .height('82.7%')
  769. Divider().vertical(false).color($r('app.color.15FFFFFF'))
  770. .width('100%')
  771. Row() {
  772. Row() {
  773. Text('关闭')
  774. .fontColor($r('app.color.60FFFFFF'))
  775. .fontSize($r('app.float.fontSize_16'))
  776. .fontWeight(FontWeight.Medium)
  777. }
  778. .width('50%')
  779. .justifyContent(FlexAlign.Center)
  780. .onClick(()=>{
  781. if (this.controller != undefined) {
  782. this.controller.close()
  783. }
  784. })
  785. Divider().vertical(true).color($r('app.color.15FFFFFF'))
  786. .height('100%')
  787. Row() {
  788. Text('确认')
  789. .fontColor($r('app.color.007AFF'))
  790. .fontSize($r('app.float.fontSize_16'))
  791. .fontWeight(FontWeight.Medium)
  792. }
  793. .width('50%')
  794. .justifyContent(FlexAlign.Center)
  795. .onClick(()=>{
  796. this.materialArray = []
  797. this.materialMergeArray = []
  798. this.materialArray = this.tempArray
  799. this.materialMergeArray = this.tempMergeArray
  800. let toChangeArray: MaterialInfo[] = [...this.outMaterialBoxInfos]
  801. // 出库料箱把物料加回去
  802. this.deleteArray.forEach((item) => {
  803. // 中间列表遍历,将同一个数据的num进行运算
  804. for (let i = 0; i < toChangeArray.length; i++) {
  805. let box = toChangeArray[i]
  806. if (item.materialCode == box.materialCode) {
  807. let value = box.num! - item.num!
  808. box.num = value >= 0 ? value : 0
  809. continue
  810. }
  811. }
  812. })
  813. this.outMaterialBoxInfos = toChangeArray.filter((m) => {
  814. return m.num! > 0
  815. })
  816. this.materialNum = this.outMaterialBoxInfos.length
  817. if (this.controller != undefined) {
  818. this.controller.close()
  819. }
  820. })
  821. }
  822. .width('100%')
  823. .height('7.3%')
  824. .justifyContent(FlexAlign.Center)
  825. }
  826. .width('61.5%')
  827. .height('71%')
  828. .justifyContent(FlexAlign.Start)
  829. .backgroundColor($r('app.color.2A2A2A'))
  830. .borderRadius($r('app.float.virtualSize_16'))
  831. }
  832. }