OperationMaterialKitTwoStep.ets 30 KB

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