OrderMaterialsStorageView.ets 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. import {DemandMaterial,OrderParams,MaterialItem,MaterialBox,EmptyBox} from "../params/OrderMaterialsStorageParams"
  2. import { ON } from '@ohos.UiTest'
  3. @Component
  4. export struct ProcessFlow {
  5. @Prop currentStep:number =0
  6. @Prop firstStepTitle:string = ''
  7. @Prop secondStepTitle:string = ''
  8. @Prop thirdStepTitle:string = ''
  9. build() {
  10. Row() {
  11. // 步骤1
  12. FlowStep({
  13. stepNumber: 1,
  14. title: this.firstStepTitle,
  15. showConnector: true,
  16. isChoose:this.currentStep === 1
  17. })
  18. // 步骤2
  19. FlowStep({
  20. stepNumber: 2,
  21. title: this.secondStepTitle,
  22. showConnector: this.thirdStepTitle!='',
  23. isChoose:this.currentStep === 2
  24. })
  25. // 步骤3
  26. if(this.thirdStepTitle!='')
  27. {
  28. FlowStep({
  29. stepNumber: 3,
  30. title: '绑定入库',
  31. showConnector: false,
  32. isChoose:this.currentStep === 3
  33. })
  34. }
  35. }
  36. .justifyContent(FlexAlign.Center)
  37. .width('100%')
  38. }
  39. }
  40. @Component
  41. struct FlowStep {
  42. @Prop stepNumber: number
  43. @Prop title: string
  44. @Prop showConnector: boolean
  45. @Prop isChoose : boolean
  46. build() {
  47. Row() {
  48. Column() {
  49. // 步骤圆圈
  50. Column() {
  51. Text(this.stepNumber.toString())
  52. .fontColor(this.isChoose? $r('app.color.FFFFFF'):$r('app.color.60FFFFFF'))
  53. .fontSize($r('app.float.fontSize_15_2'))
  54. }
  55. .width($r('app.float.virtualSize_23'))
  56. .height($r('app.float.virtualSize_23'))
  57. .borderRadius(20) // 圆形
  58. .backgroundColor(this.isChoose? $r('app.color.0A84FF'):$r('app.color.20FFFFFF'))
  59. .justifyContent(FlexAlign.Center)
  60. .alignItems(HorizontalAlign.Center)
  61. // 步骤文字
  62. Text(this.title)
  63. .fontColor(this.isChoose? $r('app.color.FFFFFF'):$r('app.color.60FFFFFF'))
  64. .fontSize($r('app.float.fontSize_9_6'))
  65. .margin({ top: 8 })
  66. }
  67. .justifyContent(FlexAlign.Center)
  68. .alignItems(HorizontalAlign.Center)
  69. if (this.showConnector) {
  70. Divider()
  71. .vertical(false)
  72. .strokeWidth(1)
  73. .color($r('app.color.20FFFFFF'))
  74. .margin({
  75. left: '-3%',
  76. right: '-3%',// 向左延伸至圆心
  77. //
  78. })
  79. .width('30%') // 自适
  80. }
  81. }
  82. }
  83. }
  84. @Component
  85. export struct OrderListComponent {
  86. private scrollerForList: Scroller = new Scroller()
  87. @Prop orders: OrderParams[] = []
  88. @State selectedIndex: number = -1 // 添加选中索引状态
  89. @Link selectedOrderNo: string
  90. @Link selectedOrderDate: string
  91. @Link selectedOrderName: string
  92. @Link selectedOrderInRatio:string
  93. // 选中回调函数
  94. private onSelect(index: number): void {
  95. this.selectedIndex = index
  96. this.selectedOrderNo = this.orders[index].orderNo
  97. this.selectedOrderDate = this.orders[index].date
  98. this.selectedOrderName = this.orders[index].orderName
  99. this.selectedOrderInRatio = this.orders[index].progress
  100. }
  101. build() {
  102. Column() { // 订单列表
  103. List({ space: 8,scroller:this.scrollerForList }) {
  104. ForEach(this.orders, (item: OrderParams, index) => {
  105. ListItem() {
  106. Column() {
  107. // 订单标题(带订单号)
  108. Text(`${item.orderName}`)
  109. .fontSize($r('app.float.fontSize_12'))
  110. .fontColor($r('app.color.FFFFFF'))
  111. .width('100%')
  112. .textAlign(TextAlign.Start)
  113. // 订单详情
  114. Column({ space: 3 }) {
  115. Text(`工单编号: ${item.orderNo}`)
  116. .fontColor($r('app.color.FFFFFF'))
  117. .fontSize($r('app.float.fontSize_8'))
  118. Text(`下发时间: ${item.date}`)
  119. .fontColor($r('app.color.FFFFFF'))
  120. .fontSize($r('app.float.fontSize_8'))
  121. Row() {
  122. Text('入库比例:')
  123. .fontColor($r('app.color.FFFFFF'))
  124. .fontSize($r('app.float.fontSize_8'))
  125. Text(item.progress)
  126. .fontColor($r('app.color.FFFFFF'))
  127. .fontSize($r('app.float.fontSize_8'))
  128. .margin({ left: 4 })
  129. }
  130. .width('100%')
  131. .justifyContent(FlexAlign.Start)
  132. }
  133. .margin({ top: 6 })
  134. .alignItems(HorizontalAlign.Start)
  135. }.backgroundColor(index === this.selectedIndex ? $r('app.color.2030D158') : $r('app.color.20FFFFFF')) // 选中状态加深
  136. .borderRadius($r('app.float.virtualSize_9_6'))
  137. .padding(13)
  138. .border({width:2,color:index === this.selectedIndex ? $r('app.color.2030D158'):$r('app.color.20FFFFFF')})
  139. .onClick(() => {
  140. this.onSelect(index)
  141. })
  142. }
  143. })
  144. }
  145. .width('100%')
  146. .flexGrow(1)
  147. }
  148. .width('100%')
  149. .height('100%')
  150. }
  151. }
  152. @Component
  153. export struct MaterialGrid {
  154. @Prop materials: MaterialItem[] = [];
  155. build() {
  156. Grid() {
  157. ForEach(this.materials, (item:MaterialItem) => {
  158. GridItem() {
  159. Column() {
  160. // 物料名称
  161. Text(item.name)
  162. .fontSize(16)
  163. .fontWeight(FontWeight.Bold)
  164. .margin({ bottom: 8 })
  165. .width('100%')
  166. .textAlign(TextAlign.Start)
  167. // 产品型号
  168. Text(item.model)
  169. .fontSize(14)
  170. .fontColor('#666666')
  171. .margin({ bottom: 12 })
  172. .width('100%')
  173. .textAlign(TextAlign.Start)
  174. // 数量进度
  175. Row() {
  176. Text(`已入库: ${item.completed}`)
  177. .fontSize(14)
  178. Text('/')
  179. .margin({ left: 4, right: 4 })
  180. Text(`计划: ${item.planned}`)
  181. .fontSize(14)
  182. .fontColor('#1890FF')
  183. }
  184. .width('100%')
  185. .justifyContent(FlexAlign.SpaceBetween)
  186. }
  187. .padding(12)
  188. .backgroundColor('#FFFFFF')
  189. .borderRadius(4)
  190. .border({
  191. width: 1,
  192. color: '#F0F0F0'
  193. })
  194. }
  195. })
  196. }
  197. .columnsTemplate('1fr 1fr 1fr')
  198. .columnsGap(10) // 移除网格内部列间距
  199. .rowsGap(0) // 移除网格内部行间距
  200. .width('100%') // 确保填满父容器
  201. .height('100%')
  202. .padding(10)
  203. .backgroundColor('#F5F5F5') // 背景色与图片一致
  204. }
  205. }
  206. @Component
  207. export struct SingleOrder {
  208. @Prop selectedOrderNo: string
  209. @Prop selectedOrderDate: string
  210. @Prop selectedOrderName: string
  211. @Prop selectedOrderInRatio: string
  212. build() {
  213. Column() {
  214. // 订单标题(带订单号)
  215. Text(this.selectedOrderName)
  216. .fontSize($r('app.float.fontSize_12'))
  217. .fontColor($r('app.color.FFFFFF'))
  218. .width('100%')
  219. .textAlign(TextAlign.Start)
  220. // 订单详情
  221. Column({ space: 3 }) {
  222. Text(`工单编号: ${this.selectedOrderNo}`)
  223. .fontColor($r('app.color.FFFFFF'))
  224. .fontSize($r('app.float.fontSize_8'))
  225. Text(`下发时间: ${this.selectedOrderDate}`)
  226. .fontColor($r('app.color.FFFFFF'))
  227. .fontSize($r('app.float.fontSize_8'))
  228. Row() {
  229. Text('入库比例:')
  230. .fontColor($r('app.color.FFFFFF'))
  231. .fontSize($r('app.float.fontSize_8'))
  232. Text(this.selectedOrderInRatio)
  233. .fontColor($r('app.color.FFFFFF'))
  234. .fontSize($r('app.float.fontSize_8'))
  235. .margin({ left: 4 })
  236. }
  237. .width('100%')
  238. .justifyContent(FlexAlign.Start)
  239. }
  240. .margin({ top: 6 })
  241. .alignItems(HorizontalAlign.Start)
  242. Divider()
  243. .strokeWidth(1)
  244. .color($r('app.color.20FFFFFF'))
  245. .margin({top:'2%'})
  246. }//.backgroundColor(index === this.selectedIndex ? $r('app.color.30D158') : $r('app.color.20FFFFFF')) // 选中状态加深
  247. .borderRadius($r('app.float.virtualSize_9_6'))
  248. .padding(13)
  249. }
  250. }
  251. @Component
  252. export struct BoxGrid {
  253. private scrollerMaterial: Scroller = new Scroller()
  254. private scrollerEmpty: Scroller = new Scroller()
  255. // 拆分两个独立的状态变量
  256. @State selectedMaterialIndex: number = -1 // 物料箱选中索引
  257. @State selectedEmptyIndex: number = -1 // 空箱选中索引
  258. // 独立的选择回调
  259. private onSelectMaterial(index: number) {
  260. this.selectedMaterialIndex =
  261. (this.selectedMaterialIndex === index) ? -1 : index
  262. this.selectedEmptyIndex = -1
  263. }
  264. private onSelectEmpty(index: number) {
  265. this.selectedEmptyIndex =
  266. (this.selectedEmptyIndex === index) ? -1 : index
  267. this.selectedMaterialIndex = -1
  268. }
  269. @Prop materialBoxes: MaterialBox[] = [];
  270. @Prop emptyBoxes: EmptyBox[] = [];
  271. build() {
  272. Column() {
  273. Grid(this.scrollerMaterial) {
  274. ForEach(this.materialBoxes, (box: MaterialBox, index) => {
  275. GridItem() {
  276. Column() {
  277. // 订单标题(带订单号)
  278. Text(`${box.name}`)
  279. .fontSize($r('app.float.fontSize_12'))
  280. .fontColor($r('app.color.FFFFFF'))
  281. .width('100%')
  282. .textAlign(TextAlign.Start)
  283. .margin({ bottom: '2%',left:'2%' })
  284. // 订单详情
  285. Column({ space: 3 }) {
  286. Text(`料箱编号: ${box.id}`)
  287. .fontColor($r('app.color.FFFFFF'))
  288. .fontSize($r('app.float.fontSize_8'))
  289. .textAlign(TextAlign.Start)
  290. Text(`料箱类型: ${box.boxType}`)
  291. .fontColor($r('app.color.FFFFFF'))
  292. .fontSize($r('app.float.fontSize_8'))
  293. .textAlign(TextAlign.Start)
  294. Text(`所属订单: ${box.order}`)
  295. .fontColor($r('app.color.FFFFFF'))
  296. .fontSize($r('app.float.fontSize_8'))
  297. .textAlign(TextAlign.Start)
  298. Text(`数量: ${box.boxNumber}`)
  299. .fontColor($r('app.color.FFFFFF'))
  300. .fontSize($r('app.float.fontSize_8'))
  301. .textAlign(TextAlign.Start)
  302. Text(`位置: ${box.position}`)
  303. .fontColor($r('app.color.FFFFFF'))
  304. .fontSize($r('app.float.fontSize_8'))
  305. .textAlign(TextAlign.Start)
  306. }
  307. .width('100%')
  308. .margin({left:'2%'})
  309. .justifyContent(FlexAlign.Start)
  310. .alignItems(HorizontalAlign.Start)
  311. }
  312. //.margin({ top: 6 })
  313. .alignItems(HorizontalAlign.Start)
  314. }
  315. .backgroundColor(index === this.selectedMaterialIndex ? $r('app.color.2030D158') : $r('app.color.20FFFFFF')) // 选中状态加深
  316. .borderRadius($r('app.float.virtualSize_9_6'))
  317. .padding(8)
  318. .border({
  319. width: 2,
  320. color: index === this.selectedMaterialIndex ? $r('app.color.2030D158') : $r('app.color.20FFFFFF')
  321. })
  322. .onClick(() => {
  323. this.onSelectMaterial(index)
  324. })
  325. })
  326. }
  327. .columnsTemplate('1fr 1fr 1fr')
  328. // .rowsTemplate('1fr 1fr')
  329. .columnsGap(10) // 移除网格内部列间距
  330. .rowsGap(10) // 移除网格内部行间距
  331. .width('100%') // 确保填满父容器
  332. .height('48%')
  333. .padding(10)
  334. Divider()
  335. .strokeWidth(1)
  336. .color($r('app.color.20FFFFFF'))
  337. .margin({top:'1%'})
  338. //.margin({top:'2%'})
  339. Grid(this.scrollerEmpty) {
  340. ForEach(this.emptyBoxes, (box: EmptyBox, index) => {
  341. GridItem() {
  342. Row() {
  343. Column(){
  344. // 订单标题(带订单号)
  345. Text(`空箱`)
  346. .fontSize($r('app.float.fontSize_12'))
  347. .fontColor($r('app.color.FFFFFF'))
  348. .width('100%')
  349. .textAlign(TextAlign.Start)
  350. .margin({ top: '2%',left:'2%' })
  351. Text(`位置: ${box.position}`)
  352. .fontColor($r('app.color.FFFFFF'))
  353. .fontSize($r('app.float.fontSize_8'))
  354. .textAlign(TextAlign.Start)
  355. .margin({ top: '60%',left:'2%' })
  356. }.width('40%').alignItems(HorizontalAlign.Start).justifyContent(FlexAlign.Start)
  357. Row(){
  358. Image($r('app.media.empty_box'))
  359. .width('100%')
  360. .height('100%')
  361. .objectFit(ImageFit.Contain)
  362. }.width('60%')
  363. }
  364. //.margin({ top: 6 })
  365. }
  366. .backgroundColor(index === this.selectedEmptyIndex ? $r('app.color.2030D158') : $r('app.color.20FFFFFF')) // 选中状态加深
  367. .borderRadius($r('app.float.virtualSize_9_6'))
  368. .padding(8)
  369. .height('50%')
  370. .border({
  371. width: 2,
  372. color: index === this.selectedEmptyIndex ? $r('app.color.2030D158') : $r('app.color.20FFFFFF')
  373. })
  374. .onClick(() => {
  375. this.onSelectEmpty(index)
  376. })
  377. })
  378. }
  379. .columnsTemplate('1fr 1fr 1fr')
  380. .columnsGap(10) // 移除网格内部列间距
  381. .rowsGap(10) // 移除网格内部行间距
  382. .width('100%') // 确保填满父容器
  383. .height('48%')
  384. .padding(10)
  385. .margin({top:'1%'})
  386. }
  387. // 背景色与图片一致
  388. }
  389. }
  390. // 辅助组件:料箱信息行
  391. @Component
  392. struct BoxInfoRow {
  393. @Prop label: string = ''
  394. @Prop value: string = ''
  395. build() {
  396. Row() {
  397. Text(`${this.label}:`)
  398. .fontSize(14)
  399. .fontColor('#666666')
  400. Text(this.value)
  401. .fontSize(14)
  402. .fontColor('#000000')
  403. }
  404. .width('100%')
  405. .margin({ bottom: 6 })
  406. .justifyContent(FlexAlign.Start)
  407. }
  408. }
  409. @Component
  410. export struct MaterialList {
  411. private scrollerForList: Scroller = new Scroller()
  412. @Prop MaterialData: DemandMaterial[] = []
  413. build() {
  414. Column() {
  415. List({scroller:this.scrollerForList}) {
  416. ForEach(this.MaterialData, (item:DemandMaterial) => {
  417. ListItem() {
  418. Column() {
  419. Row(){
  420. Text(item.materialName)
  421. .fontSize($r('app.float.fontSize_12'))
  422. .fontColor($r('app.color.FFFFFF'))
  423. .width('90%')
  424. .textAlign(TextAlign.Start)
  425. Text(`${item.inBoundNum}/${item.planNum}`)
  426. .fontSize($r('app.float.fontSize_12'))
  427. .fontColor($r('app.color.FFFFFF'))
  428. .width('10%')
  429. .textAlign(TextAlign.End)
  430. }.margin({top:'1%'})
  431. Row(){
  432. Text(`型号: ${item.materialType}`)
  433. .fontSize($r('app.float.fontSize_8'))
  434. .fontColor($r('app.color.FFFFFF'))
  435. .width('90%')
  436. .textAlign(TextAlign.Start)
  437. Text('入库/计划数量')
  438. .fontSize($r('app.float.fontSize_7'))
  439. .fontColor($r('app.color.60FFFFFF'))
  440. .width('10%')
  441. .textAlign(TextAlign.End)
  442. }.margin({bottom:'1%'})
  443. }.width('100%').alignItems(HorizontalAlign.Start).justifyContent(FlexAlign.SpaceEvenly).height('12%')
  444. }
  445. })
  446. }
  447. .width('100%')
  448. .height('100%')
  449. .divider({
  450. strokeWidth: 1,
  451. color: $r('app.color.20FFFFFF')
  452. })
  453. }
  454. .height('100%')
  455. .justifyContent(FlexAlign.Start)
  456. }
  457. }
  458. @Component
  459. export struct MaterialListComponent {
  460. private scrollerForList: Scroller = new Scroller()
  461. @Link orders: OrderParams[]
  462. @State selectedIndex: number = -1 // 添加选中索引状
  463. // 选中回调函数
  464. private onSelect(index: number): void {
  465. this.selectedIndex = index
  466. }
  467. build() {
  468. Column() { // 订单列表
  469. List({ space: 8,scroller:this.scrollerForList }) {
  470. ForEach(this.orders, (item: OrderParams, index) => {
  471. ListItem() {
  472. Row() {
  473. Column(){
  474. // 订单标题(带订单号)
  475. Text(`${item.orderName}`)
  476. .fontSize($r('app.float.fontSize_12'))
  477. .fontColor($r('app.color.FFFFFF'))
  478. .width('100%')
  479. .textAlign(TextAlign.Start)
  480. // 订单详情
  481. Column({ space: 3 }) {
  482. Text(`型号: ${item.orderNo}`)
  483. .fontColor($r('app.color.FFFFFF'))
  484. .fontSize($r('app.float.fontSize_8'))
  485. .width('100%')
  486. .textAlign(TextAlign.Start)
  487. Text(`序列号: ${item.date}`)
  488. .fontColor($r('app.color.FFFFFF'))
  489. .fontSize($r('app.float.fontSize_8'))
  490. .width('100%')
  491. .textAlign(TextAlign.Start)
  492. Text(`所属订单: ${item.date}`)
  493. .fontColor($r('app.color.FFFFFF'))
  494. .fontSize($r('app.float.fontSize_8'))
  495. .width('100%')
  496. .textAlign(TextAlign.Start)
  497. Text(`数量: ${item.date}`)
  498. .fontColor($r('app.color.FFFFFF'))
  499. .fontSize($r('app.float.fontSize_8'))
  500. .width('100%')
  501. .textAlign(TextAlign.Start)
  502. }
  503. .margin({ top: 4 })
  504. .alignItems(HorizontalAlign.Start)
  505. }.width('90%')
  506. Row(){
  507. Image($r('app.media.material_delete'))
  508. .width($r('app.float.virtualSize_23'))
  509. .height($r('app.float.virtualSize_23'))
  510. .fillColor($r('app.color.FF453A'))
  511. .onClick(()=>{
  512. this.orders.splice(index, 1);
  513. })
  514. }.width('10%')
  515. }
  516. .backgroundColor($r('app.color.20FFFFFF')) // 选中状态加深
  517. .borderRadius($r('app.float.virtualSize_9_6'))
  518. .padding(13)
  519. //.border({width:2,color:index === this.selectedIndex ? $r('app.color.2030D158'):$r('app.color.20FFFFFF')})
  520. }
  521. })
  522. }
  523. .width('100%')
  524. .flexGrow(1)
  525. }
  526. .width('100%')
  527. .height('100%')
  528. }
  529. }