Index.ets 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. import { TimeAndTitle } from '../component/TimeAndTitle';
  2. import router from '@ohos.router';
  3. import WorkOrderInfo from '../viewmodel/WorkOrderInfo';
  4. import CommonConstants from '../common/constants/CommonConstants';
  5. import ProcessRequest from '../common/util/request/ProcessRequest';
  6. import RequestParamModel from '../viewmodel/RequestParamModel';
  7. import OperationInfo from '../viewmodel/process/OperationInfo';
  8. import { SelectOrderDialog } from '../view/SelectOrderDialog';
  9. import image from '@ohos.multimedia.image';
  10. import { SwitchingProductDialog, taskSeqItem } from '../view/SwitchingProductDialog';
  11. import TaskSeqVO from '../viewmodel/process/TaskSeqInfo';
  12. import promptAction from '@ohos.promptAction';
  13. @Entry
  14. @Component
  15. struct Index {
  16. // 工单列表
  17. @State workOrders: WorkOrderInfo[] = []
  18. // 选中工单
  19. @State selectWorkOder: WorkOrderInfo = {}
  20. // 工位通知数量
  21. @State noticeNum: number = 100
  22. // 扫描或手动输入的流水/序列/铭牌号
  23. @State scanCode: string = ''
  24. // 当前流转卡号
  25. @State seqNo: string = ''
  26. // 选中工序id
  27. @State selectOperationId: string = ''
  28. //选择的按钮索引(默认加载全部)
  29. @State selectedButtonIndex: number = 0
  30. // 流转卡号信息集合
  31. @State taskSeqArray: TaskSeqVO[] = []
  32. private scrollerList: Scroller = new Scroller()
  33. pageNo: number = 1
  34. pageSize: number = 9
  35. selectOrderController: CustomDialogController = new CustomDialogController({
  36. builder: SelectOrderDialog({}),
  37. autoCancel: true, // 点击遮罩关闭
  38. customStyle: true,
  39. maskColor: 'rgba(0,0,0,0.8)', // 黑色遮罩
  40. })
  41. switchingProductDialogController: CustomDialogController = new CustomDialogController({
  42. builder: SwitchingProductDialog({
  43. scanSeqValue: this.scanCode
  44. }),
  45. autoCancel: true, // 点击遮罩关闭
  46. customStyle: true,
  47. maskColor: 'rgba(0,0,0,0.8)', // 黑色遮罩
  48. })
  49. handleAllClick():void {
  50. this.onQueryTask([])
  51. }
  52. handleReportedClick():void{
  53. this.onQueryTask([2])
  54. }
  55. handleUnreportedClick():void{
  56. this.onQueryTask([-1,0,1])
  57. }
  58. onQueryTask = async (currentStateList: Array<number>)=>{
  59. this.taskSeqArray = await ProcessRequest.post('/api/v1/plan/task/list', {
  60. stationId: CommonConstants.STATION_ID.toString(),
  61. workOrderCode: this.selectWorkOder.workOrderCode!,
  62. operationId: this.selectOperationId,
  63. stateList: currentStateList
  64. } as RequestParamModel) as TaskSeqVO[];
  65. }
  66. async aboutToAppear() {
  67. if (!this.selectWorkOder || !this.selectWorkOder.workOrderCode) {
  68. this.selectOrderController.open()
  69. // this.workOrders = await ProcessRequest.post('/api/v1/plan/workOrder/taskPage', {
  70. // //查询未完成的工单
  71. // queryComplete: 0,
  72. // pageNo: this.pageNo,
  73. // pageSize: this.pageSize
  74. // } as RequestParamModel) as WorkOrderInfo[]
  75. }
  76. }
  77. build() {
  78. Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center }) {
  79. //时间和导航标
  80. Row(){
  81. TimeAndTitle()
  82. }.width('100%')
  83. .height('3.4%')
  84. .alignItems(VerticalAlign.Bottom)
  85. .justifyContent(FlexAlign.End)
  86. Row(){
  87. Image($r('app.media.general_return'))
  88. .height($r('app.float.virtualSize_56'))
  89. .width($r('app.float.virtualSize_56'))
  90. .fillColor($r('app.color.FFFFFF'))
  91. Text('生产执行')
  92. .fontColor($r('app.color.FFFFFF'))
  93. .fontSize($r('app.float.fontSize_30'))
  94. .fontWeight(FontWeight.Medium)
  95. }
  96. .height('4%')
  97. .width('94.8%')
  98. .justifyContent(FlexAlign.Start)
  99. .onClick(()=> {
  100. router.back()
  101. })
  102. Row().height('2.8%')
  103. // 主要操作栏
  104. Row() {
  105. // 左侧选择工单、工位、人员;工序查看
  106. Column() {
  107. if (this.selectWorkOder && this.selectWorkOder.workOrderCode) {
  108. Column() {
  109. Text(this.selectWorkOder.materialName!)
  110. .fontWeight(FontWeight.Medium)
  111. .fontColor($r('app.color.FFFFFF'))
  112. .fontSize($r('app.float.fontSize_24'))
  113. .width('88.9%')
  114. Text(this.selectWorkOder.materialCode!)
  115. .fontWeight(FontWeight.Lighter)
  116. .fontColor($r('app.color.FFFFFF'))
  117. .fontSize($r('app.float.fontSize_12'))
  118. .width('88.9%')
  119. Row() {
  120. Text('工单:')
  121. .fontWeight(FontWeight.Lighter)
  122. .fontColor($r('app.color.FFFFFF'))
  123. .fontSize($r('app.float.fontSize_12'))
  124. Text(this.selectWorkOder.orderCode!)
  125. .fontWeight(FontWeight.Bold)
  126. .fontColor($r('app.color.FFFFFF'))
  127. .fontSize($r('app.float.fontSize_16'))
  128. }
  129. .width('88.9%')
  130. }
  131. .width('100%')
  132. .height('12.4%')
  133. .justifyContent(FlexAlign.Center)
  134. .backgroundColor($r('app.color.20FFFFFF'))
  135. .borderRadius($r('app.float.fontSize_16'))
  136. .onClick(()=>{
  137. this.selectOrderController.open()
  138. })
  139. } else {
  140. Button('请选择工单', { type: ButtonType.Normal })
  141. .width('100%')
  142. .height('12.4%')
  143. .fontWeight(FontWeight.Medium)
  144. .fontColor($r('app.color.FFFFFF'))
  145. .fontSize($r('app.float.fontSize_24'))
  146. .backgroundColor($r('app.color.20FFFFFF'))
  147. .borderRadius($r('app.float.fontSize_16'))
  148. .onClick(()=>{
  149. this.selectOrderController.open()
  150. })
  151. }
  152. // 工位、人员信息
  153. Row() {
  154. Row().width('5.6%')
  155. Column() {
  156. Text(CommonConstants.STATION_NANE)
  157. .fontSize($r('app.float.fontSize_16'))
  158. .fontWeight(FontWeight.Regular)
  159. .fontColor($r('app.color.FFFFFF'))
  160. Text(CommonConstants.USER_NAME)
  161. .fontSize($r('app.float.fontSize_12'))
  162. .fontWeight(FontWeight.Lighter)
  163. .fontColor($r('app.color.FFFFFF'))
  164. }
  165. .width('48.8%')
  166. .height('100%')
  167. .justifyContent(FlexAlign.Center)
  168. .alignItems(HorizontalAlign.Start)
  169. Row() {
  170. Text(this.noticeNum > 99 ? '99+' : this.noticeNum.toString())
  171. .fontSize($r('app.float.fontSize_16'))
  172. .fontWeight(FontWeight.Bold)
  173. .fontColor($r('app.color.FFFFFF'))
  174. .textAlign(TextAlign.Center)
  175. .height('42.3%')
  176. .width('42%')
  177. .backgroundColor($r('app.color.20FFFFFF'))
  178. .borderRadius($r('app.float.fontSize_16'))
  179. }
  180. .width('40%')
  181. .height('100%')
  182. .justifyContent(FlexAlign.End)
  183. Row().width('5.6%')
  184. }
  185. .width('100%')
  186. .height('8.1%')
  187. .backgroundColor($r('app.color.20FFFFFF'))
  188. .borderRadius($r('app.float.fontSize_16'))
  189. // 工序
  190. Column({space: 4}) {
  191. Row() {
  192. Text('工序')
  193. .fontWeight(FontWeight.Medium)
  194. .fontColor($r('app.color.FFFFFF'))
  195. .fontSize($r('app.float.fontSize_24'))
  196. }
  197. .width('83.4%')
  198. .height('8.4%')
  199. .alignItems(VerticalAlign.Bottom)
  200. List() {
  201. ForEach(this.selectWorkOder.ops!, (item: OperationInfo, index: number) => {
  202. ListItem() {
  203. Column() {
  204. Row() {
  205. Row() {
  206. Text((index + 1).toString())
  207. .fontSize($r('app.float.fontSize_16'))
  208. .fontColor(this.selectOperationId === item.operationId ? $r('app.color.90000000') : $r('app.color.FFFFFF'))
  209. .fontWeight(FontWeight.Bold)
  210. }
  211. .width('14.6%')
  212. .height('80%')
  213. .justifyContent(FlexAlign.Center)
  214. Row() {
  215. Text(item.operationName)
  216. .fontSize($r('app.float.fontSize_16'))
  217. .fontColor(this.selectOperationId === item.operationId ? $r('app.color.90000000') : $r('app.color.FFFFFF'))
  218. .fontWeight(FontWeight.Regular)
  219. .padding({left: 5})
  220. }
  221. .width('70.8%')
  222. .height('100%')
  223. .alignItems(VerticalAlign.Center)
  224. .justifyContent(FlexAlign.Start)
  225. Row() {
  226. Image(this.selectOperationId === item.operationId ? $r('app.media.process_current_operation') : (item.isEnd! ? $r('app.media.process_complete') : ''))
  227. .width($r('app.float.virtualSize_24'))
  228. .height($r('app.float.virtualSize_24'))
  229. .fillColor(this.selectOperationId === item.operationId ? $r('app.color.90000000') : $r('app.color.FFFFFF'))
  230. .opacity(this.selectOperationId != item.operationId && !item.isEnd ? 0 : 1)
  231. }
  232. .width('14.6%')
  233. .height('100%')
  234. .justifyContent(FlexAlign.Center)
  235. }
  236. .width('100%')
  237. .height('70%')
  238. .borderRadius($r('app.float.virtualSize_40'))
  239. .backgroundImage(this.selectOperationId === item.operationId ? $r('app.media.process_select_operation') : $r('app.media.process_no_select_operation'))
  240. .backgroundImageSize(ImageSize.Cover)
  241. .onClick(() => {
  242. this.selectOperationId = item.operationId!
  243. if (!item.exists) {
  244. promptAction.showToast({
  245. message: `${item.operationName}需要在${item.stationName}工位上生产`,
  246. duration: 1500,
  247. bottom: 100
  248. })
  249. }
  250. if (!this.seqNo || this.seqNo.length <= 0) {
  251. this.handleAllClick()
  252. }
  253. })
  254. if (index < this.selectWorkOder.ops!.length - 1) {
  255. Row() {
  256. Divider()
  257. .vertical(true)
  258. .color($r('app.color.60FFFFFF'))
  259. .padding({ right: '15%' })
  260. }
  261. .justifyContent(FlexAlign.Center)
  262. .width('20%')
  263. .layoutWeight(1)
  264. }
  265. }
  266. .width('100%')
  267. .height('10.6%')
  268. .alignItems(HorizontalAlign.Start)
  269. }
  270. })
  271. }
  272. .width('83.4%')
  273. .height('88.6%')
  274. .alignListItem(ListItemAlign.Center)
  275. }
  276. .width('100%')
  277. .height('77.2%')
  278. .backgroundColor($r('app.color.20FFFFFF'))
  279. .borderRadius($r('app.float.fontSize_16'))
  280. }
  281. .height('100%')
  282. .width('19.8%')
  283. .justifyContent(FlexAlign.SpaceBetween)
  284. // 右侧生产操作栏
  285. Column() {
  286. Row() {
  287. Text('录入流水号')
  288. .fontSize($r('app.float.fontSize_30'))
  289. .fontWeight(FontWeight.Medium)
  290. .fontColor($r('app.color.FFFFFF'))
  291. }
  292. .height('10%')
  293. .width('97.2%')
  294. .justifyContent(FlexAlign.Start)
  295. Row() {
  296. Column({space: 8}) {
  297. Row() {
  298. this.buildButton(0, '全部', () => this.handleAllClick())
  299. this.buildButton(1, '已报工', () => this.handleReportedClick())
  300. this.buildButton(2, '未报工', () => this.handleUnreportedClick())
  301. }
  302. .width('72%')
  303. .height('5.3%')
  304. .justifyContent(FlexAlign.Start)
  305. List({space: 4, scroller: this.scrollerList}) {
  306. ForEach(this.taskSeqArray, (item:TaskSeqVO) => {
  307. ListItem() {
  308. taskSeqItem({
  309. item:item,
  310. scanSeqValue: this.scanCode,
  311. selectedButtonIndex: this.selectedButtonIndex
  312. })
  313. }
  314. })
  315. }
  316. .width('72%')
  317. .height('94.7%')
  318. }
  319. .width('52.9%')
  320. .height('100%')
  321. .alignItems(HorizontalAlign.End)
  322. .padding({right: '2.6%'})
  323. Divider()
  324. .vertical(true)
  325. .color($r('app.color.15FFFFFF'))
  326. .height('100%')
  327. Column({space: 5}) {
  328. Row().height('37%')
  329. Row() {
  330. Text('扫描流水/序列/铭牌号')
  331. .fontSize($r('app.float.fontSize_16'))
  332. .fontWeight(FontWeight.Regular)
  333. .fontColor($r('app.color.FFFFFF'))
  334. }
  335. .width('62%')
  336. Row() {
  337. Row().width('3.4%')
  338. // 左侧二维码图标
  339. Image($r('app.media.material_qr_code')) // 请替换为您的二维码图片资源
  340. .width($r('app.float.virtualSize_24'))
  341. .height($r('app.float.virtualSize_24'))
  342. .fillColor($r('app.color.FFFFFF'))
  343. // 扫码输入框
  344. TextInput({ placeholder: '请扫描物料编码', text: this.scanCode })
  345. .type(InputType.Normal)
  346. .placeholderFont({ size: $r('app.float.fontSize_16')})
  347. .placeholderColor($r('app.color.30FFFFFF'))
  348. .fontSize($r('app.float.fontSize_16'))
  349. .fontColor($r('app.color.FFFFFF'))
  350. .enableKeyboardOnFocus(false)
  351. .onChange((value: string) => {
  352. this.scanCode = value
  353. })
  354. .onSubmit(async () => {
  355. })
  356. }
  357. .width('65%')
  358. .height('6.5%')
  359. .borderRadius($r('app.float.virtualSize_16'))
  360. .backgroundColor($r('app.color.000000'))
  361. .justifyContent(FlexAlign.Start)
  362. }
  363. .width('52.9%')
  364. .height('100%')
  365. }
  366. .width('100%')
  367. .height('87.7%')
  368. .justifyContent(FlexAlign.Center)
  369. }
  370. .width('79.1%')
  371. .height('100%')
  372. .justifyContent(FlexAlign.Center)
  373. .backgroundColor($r('app.color.20FFFFFF'))
  374. .borderRadius($r('app.float.fontSize_16'))
  375. }
  376. .height('80%')
  377. .width('94.8%')
  378. .justifyContent(FlexAlign.SpaceBetween)
  379. // 底部按钮和抽屉
  380. Stack() {
  381. Column() {
  382. Blank()
  383. Stack() {
  384. Image($r('app.media.process_drawer_thumbnail'))
  385. .width('100%')
  386. .height('100%')
  387. Image($r('app.media.process_drawer_switch'))
  388. .width($r('app.float.virtualSize_48'))
  389. .height($r('app.float.virtualSize_48'))
  390. .fillColor($r('app.color.60FFFFFF'))
  391. }
  392. .width('100%')
  393. .height('47%')
  394. }
  395. .width('100%')
  396. .height('100%')
  397. Row() {
  398. Row({space: 4}) {
  399. Image($r('app.media.process_work_instruction'))
  400. .width($r('app.float.virtualSize_24'))
  401. .height($r('app.float.virtualSize_24'))
  402. .fillColor($r('app.color.0A84FF'))
  403. Text('作业指导')
  404. .fontColor($r('app.color.0A84FF'))
  405. .fontSize($r('app.float.fontSize_24'))
  406. .fontWeight(FontWeight.Medium)
  407. }
  408. .width('10%')
  409. .height('58.3%')
  410. .justifyContent(FlexAlign.Center)
  411. .backgroundColor($r('app.color.20FFFFFF'))
  412. .borderRadius($r('app.float.fontSize_16'))
  413. Row().width('1.5%')
  414. Row({space: 4}) {
  415. Image($r('app.media.process_complete_reception'))
  416. .width($r('app.float.virtualSize_24'))
  417. .height($r('app.float.virtualSize_24'))
  418. .fillColor($r('app.color.0A84FF'))
  419. Text('齐套接收')
  420. .fontColor($r('app.color.0A84FF'))
  421. .fontSize($r('app.float.fontSize_24'))
  422. .fontWeight(FontWeight.Medium)
  423. }
  424. .width('10%')
  425. .height('58.3%')
  426. .justifyContent(FlexAlign.Center)
  427. .backgroundColor($r('app.color.20FFFFFF'))
  428. .borderRadius($r('app.float.fontSize_16'))
  429. Blank()
  430. Column({space: 2}) {
  431. Row() {
  432. Text((this.selectWorkOder && this.selectWorkOder.workOrderCode) ? parseInt(this.selectWorkOder.completeNum!) + '/' + parseInt(this.selectWorkOder.planNum) : '')
  433. .fontColor($r('app.color.FFFFFF'))
  434. .fontSize($r('app.float.fontSize_16'))
  435. .fontWeight(FontWeight.Lighter)
  436. }
  437. .width('100%')
  438. .height('50%')
  439. .justifyContent(FlexAlign.End)
  440. .alignItems(VerticalAlign.Bottom)
  441. Row() {
  442. if (this.seqNo.length > 0 ) {
  443. Text('S/N ')
  444. .fontColor($r('app.color.FFFFFF'))
  445. .fontSize($r('app.float.fontSize_16'))
  446. .fontWeight(FontWeight.Lighter)
  447. Text(this.seqNo)
  448. .fontColor($r('app.color.FFFFFF'))
  449. .fontSize($r('app.float.fontSize_16'))
  450. .fontWeight(FontWeight.Bold)
  451. }
  452. }
  453. .width('100%')
  454. .height('50%')
  455. .justifyContent(FlexAlign.End)
  456. .alignItems(VerticalAlign.Top)
  457. }
  458. .width('10.8%')
  459. .height('100%')
  460. Row().width('1%')
  461. Row({space: 4}) {
  462. Image($r('app.media.process_switch'))
  463. .width($r('app.float.virtualSize_24'))
  464. .height($r('app.float.virtualSize_24'))
  465. .fillColor($r('app.color.0A84FF'))
  466. Text('切换产品')
  467. .fontColor($r('app.color.0A84FF'))
  468. .fontSize($r('app.float.fontSize_24'))
  469. .fontWeight(FontWeight.Medium)
  470. }
  471. .width('10%')
  472. .height('58.3%')
  473. .justifyContent(FlexAlign.Center)
  474. .backgroundColor($r('app.color.20FFFFFF'))
  475. .borderRadius($r('app.float.fontSize_16'))
  476. .onClick(()=>{
  477. this.switchingProductDialogController.open()
  478. })
  479. Row().width('1.5%')
  480. Row({space: 4}) {
  481. Image($r('app.media.process_start_work'))
  482. .width($r('app.float.virtualSize_24'))
  483. .height($r('app.float.virtualSize_24'))
  484. .fillColor($r('app.color.FFFFFF'))
  485. Text('工序开工')
  486. .fontColor($r('app.color.FFFFFF'))
  487. .fontSize($r('app.float.fontSize_24'))
  488. .fontWeight(FontWeight.Medium)
  489. }
  490. .width('10%')
  491. .height('58.3%')
  492. .justifyContent(FlexAlign.Center)
  493. .backgroundColor($r('app.color.0A84FF'))
  494. .borderRadius($r('app.float.fontSize_16'))
  495. }
  496. .height('90.6%')
  497. .width('100%')
  498. .padding({left: '2.6%', right: '2.6%'})
  499. }
  500. .width('100%')
  501. .height('9.8%')
  502. .alignContent(Alignment.Top)
  503. }
  504. .width('100%')
  505. .height('100%')
  506. .backgroundColor($r('app.color.000000'))
  507. }
  508. @Builder
  509. buildButton(index: number, text: string, onClick: () => void) {
  510. Row({space: 5}){
  511. if(this.selectedButtonIndex === index) {
  512. Image($r('app.media.process_radio_check'))
  513. .width($r('app.float.virtualSize_24'))
  514. .height($r('app.float.virtualSize_24'))
  515. .fillColor($r('app.color.0A84FF'))
  516. } else {
  517. Image($r('app.media.process_radio_no_check'))
  518. .width($r('app.float.virtualSize_24'))
  519. .height($r('app.float.virtualSize_24'))
  520. .fillColor($r('app.color.FFFFFF'))
  521. }
  522. Text(text)
  523. .fontSize($r('app.float.fontSize_16'))
  524. .fontColor($r('app.color.FFFFFF'))
  525. }
  526. .justifyContent(FlexAlign.Center)
  527. .width('24.3%')
  528. .height('100%')
  529. .backgroundColor(this.selectedButtonIndex === index ? $r('app.color.200A84FF') : $r('app.color.20FFFFFF')) // 选中蓝/未选中灰
  530. .borderRadius($r('app.float.virtualSize_16'))
  531. .margin({ right:'3%'})
  532. .onClick(() => {
  533. this.selectedButtonIndex = index
  534. onClick();
  535. })
  536. }
  537. }