OperationMaterialKitOneStep.ets 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. import CommonConstants from '../../common/constants/CommonConstants'
  2. import WmsRequest from '../../common/util/request/WmsRequest'
  3. import StationOperationInfo from '../../viewmodel/wms/StationOperationInfo'
  4. import OperationInfo from '../../viewmodel/wms/OperationInfo'
  5. import RequestParamModel from '../../viewmodel/wms/RequestParamModel'
  6. import WorkOrderInfo from '../../viewmodel/wms/WorkOrderInfo'
  7. import OperationMaterial from '../../viewmodel/wms/OperationMaterial'
  8. import OperationItem from '../../viewmodel/wms/OperationItem'
  9. import HashMap from '@ohos.util.HashMap'
  10. import DictInfo from '../../viewmodel/DictInfo'
  11. @Component
  12. export struct OperationMaterialKitOneStep {
  13. @Link workOrder: WorkOrderInfo
  14. @Link selectOperations: OperationInfo[]
  15. @Link operationItems: OperationItem[]
  16. @State workOrderArray: WorkOrderInfo[] = []
  17. @State operationArray: StationOperationInfo[] = []
  18. @State operationMaterialArray: OperationMaterial[] = []
  19. @State selectWorkOrder: number = 0
  20. @State selectOperationIds: string[] = []
  21. fixed38px: number = 22.8
  22. fixed52px: number = 31.2
  23. fixed100px: number = 60
  24. stationTypeDictType: string = 'station_type'
  25. stationTypeDictMap: HashMap<string, string> = new HashMap<string, string>()
  26. async aboutToAppear() {
  27. this.workOrderArray = await WmsRequest.post('/api/v1/wms/workOrder/list', {
  28. //查询未完成的工单
  29. queryComplete: 0,
  30. } as RequestParamModel) as WorkOrderInfo[]
  31. if (this.workOrderArray && this.workOrderArray.length > 0) {
  32. this.workOrder = this.workOrderArray[0]
  33. this.selectWorkOrder = 0
  34. this.operationArray = await WmsRequest.post('/api/v1/wms/operation/list', {
  35. //查询未完成的工单
  36. processRouteId: this.workOrderArray[0]?.processRouteId,
  37. } as RequestParamModel) as StationOperationInfo[]
  38. }
  39. if (!CommonConstants.DICT_DATA || CommonConstants.DICT_DATA.length <= 0) {
  40. let res: DictInfo[] = await WmsRequest.post('/api/v1/sys/dictData/all',)
  41. if (res && res.length > 0) {
  42. for (const dict of res) {
  43. CommonConstants.DICT_DATA.set(dict.dictCode, dict.list)
  44. if (this.stationTypeDictType === dict.dictCode) {
  45. for (const element of dict?.list!) {
  46. this.stationTypeDictMap.set(element.dictValue, element.dictLabel);
  47. }
  48. }
  49. }
  50. }
  51. } else {
  52. let dictList = CommonConstants.DICT_DATA.get(this.stationTypeDictType);
  53. for (const element of dictList) {
  54. this.stationTypeDictMap.set(element.dictValue, element.dictLabel);
  55. }
  56. }
  57. }
  58. build() {
  59. Row() {
  60. // 选择工单
  61. Column() {
  62. Row() {
  63. Text('选择工单')
  64. .fontSize($r('app.float.fontSize_30'))
  65. .fontColor($r('app.color.FFFFFF'))
  66. .fontWeight(FontWeight.Medium)
  67. }
  68. .height('10%')
  69. .width('100%')
  70. .justifyContent(FlexAlign.Center)
  71. List({space: 5}) {
  72. ForEach(this.workOrderArray, (item: WorkOrderInfo, index: number) => {
  73. ListItem() {
  74. Column() {
  75. Row() {
  76. Text((item.orderName ? item.orderName : '') + (item.orderCode ? item.orderCode : ''))
  77. .fontSize($r('app.float.fontSize_24'))
  78. .fontWeight(FontWeight.Medium)
  79. .fontColor($r('app.color.FFFFFF'))
  80. .maxLines(1)
  81. }
  82. .height('38%')
  83. .width('91%')
  84. .alignItems(VerticalAlign.Bottom)
  85. Column() {
  86. Text('工单编号:' + (item.workOrderCode ? item.workOrderCode : ''))
  87. .fontSize($r('app.float.fontSize_16'))
  88. .fontWeight(FontWeight.Lighter)
  89. .fontColor($r('app.color.FFFFFF'))
  90. .maxLines(1)
  91. Text('下发时间:' + item.updated)
  92. .fontSize($r('app.float.fontSize_16'))
  93. .fontWeight(FontWeight.Lighter)
  94. .fontColor($r('app.color.FFFFFF'))
  95. .maxLines(1)
  96. Text('齐套进度:' + (item.kitCompleteProgress ? item.kitCompleteProgress : 0) + '%')
  97. .fontSize($r('app.float.fontSize_16'))
  98. .fontWeight(FontWeight.Lighter)
  99. .fontColor($r('app.color.FFFFFF'))
  100. .maxLines(1)
  101. }
  102. .height('48.3%')
  103. .width('91%')
  104. .alignItems(HorizontalAlign.Start)
  105. .justifyContent(FlexAlign.SpaceAround)
  106. }
  107. .height('15.4%')
  108. .width('92.6%')
  109. .borderRadius($r('app.float.virtualSize_6_4'))
  110. .justifyContent(FlexAlign.Start)
  111. .backgroundColor(this.selectWorkOrder === index ? $r('app.color.2030D158') : $r('app.color.20FFFFFF'))
  112. .borderWidth(1)
  113. .borderColor(this.selectWorkOrder === index ? $r('app.color.30D158') : $r('app.color.20FFFFFF'))
  114. .onClick(async ()=>{
  115. if (this.selectWorkOrder === index) {
  116. return
  117. }
  118. this.operationArray = await WmsRequest.post('/api/v1/wms/operation/list', {
  119. //查询未完成的工单
  120. processRouteId: this.workOrderArray[index]?.processRouteId,
  121. } as RequestParamModel) as StationOperationInfo[]
  122. this.selectWorkOrder = index
  123. this.workOrder = this.workOrderArray[this.selectWorkOrder]
  124. })
  125. }
  126. })
  127. }
  128. .width('100%')
  129. .height('90%')
  130. .alignListItem(ListItemAlign.Center)
  131. }
  132. .height('100%')
  133. .width('29.6%')
  134. .borderRadius($r('app.float.virtualSize_6_4'))
  135. .justifyContent(FlexAlign.Center)
  136. .backgroundColor($r('app.color.10FFFFFF'))
  137. Image($r("app.media.wms_arrow_right"))
  138. .height($r('app.float.virtualSize_38'))
  139. .width($r('app.float.virtualSize_38'))
  140. // 选择工序
  141. Column() {
  142. Row() {
  143. Text('选择工序')
  144. .fontSize($r('app.float.fontSize_30'))
  145. .fontColor($r('app.color.FFFFFF'))
  146. .fontWeight(FontWeight.Medium)
  147. }
  148. .height('10%')
  149. .width('100%')
  150. .justifyContent(FlexAlign.Center)
  151. List() {
  152. ForEach(this.operationArray, (item: StationOperationInfo, index: number) => {
  153. ListItem() {
  154. Column() {
  155. Row() {
  156. Row() {
  157. Text(this.stationTypeDictMap.get(item.stanType!) ? this.stationTypeDictMap.get(item.stanType!) : item.stanType!)
  158. .fontSize($r('app.float.fontSize_16'))
  159. .fontWeight(FontWeight.Lighter)
  160. .fontColor($r('app.color.FFFFFF'))
  161. }
  162. .height('100%')
  163. .width('40%')
  164. .alignItems(VerticalAlign.Center)
  165. .justifyContent(FlexAlign.Start)
  166. Column() {
  167. ForEach(item.operationVO, (operation: OperationInfo, index: number) => {
  168. Column() {
  169. Row().height(6)
  170. Row({space: 5}) {
  171. Checkbox()
  172. .select(this.selectOperationIds.indexOf(operation.id) > -1 ? true : false)
  173. .selectedColor($r('app.color.30D158'))
  174. .width($r('app.float.virtualSize_8'))
  175. .height($r('app.float.virtualSize_8'))
  176. .onChange(async (value: boolean) => {
  177. if (value) {
  178. if (!this.selectOperationIds.includes(operation.id)) {
  179. this.selectOperationIds.push(operation.id)
  180. this.selectOperations.push(operation)
  181. }
  182. } else {
  183. if (this.selectOperationIds.includes(operation.id)) {
  184. this.selectOperationIds.splice(this.selectOperationIds.indexOf(operation.id), 1)
  185. this.selectOperations.splice(this.selectOperations.indexOf(operation), 1)
  186. }
  187. }
  188. this.operationMaterialArray = await WmsRequest.post('/api/v1/wms/operationMaterial/list', {
  189. //查询工序需求的物料
  190. operationIds: this.selectOperationIds,
  191. } as RequestParamModel) as OperationMaterial[]
  192. this.operationItems = []
  193. if (this.operationMaterialArray) {
  194. for (const element of this.operationMaterialArray) {
  195. this.operationItems = this.operationItems.concat(element.itemList);
  196. }
  197. }
  198. })
  199. Text(operation.operationName ? operation.operationName : '')
  200. .fontSize($r('app.float.fontSize_24'))
  201. .fontWeight(FontWeight.Medium)
  202. .fontColor($r('app.color.FFFFFF'))
  203. }
  204. .width('100%')
  205. .height(48)
  206. .padding({left: '6%'})
  207. .backgroundColor(this.selectOperationIds.indexOf(operation.id) > -1 ? $r('app.color.2030D158') : $r('app.color.20FFFFFF'))
  208. .borderWidth(1)
  209. .borderColor(this.selectOperationIds.indexOf(operation.id) > -1 ? $r('app.color.30D158') : $r('app.color.20FFFFFF'))
  210. .borderRadius($r('app.float.virtualSize_6_4'))
  211. .onClick(async ()=>{
  212. if (this.selectOperationIds.includes(operation.id)) {
  213. this.selectOperationIds.splice(this.selectOperationIds.indexOf(operation.id), 1)
  214. this.selectOperations.splice(this.selectOperations.indexOf(operation), 1)
  215. } else {
  216. this.selectOperationIds.push(operation.id)
  217. this.selectOperations.push(operation)
  218. }
  219. this.operationMaterialArray = await WmsRequest.post('/api/v1/wms/operationMaterial/list', {
  220. //查询工序需求的物料
  221. operationIds: this.selectOperationIds,
  222. } as RequestParamModel) as OperationMaterial[]
  223. this.operationItems = []
  224. if (this.operationMaterialArray) {
  225. for (const element of this.operationMaterialArray) {
  226. this.operationItems = this.operationItems.concat(element.itemList);
  227. }
  228. }
  229. })
  230. Row().height(6)
  231. }
  232. .justifyContent(FlexAlign.Center)
  233. })
  234. }
  235. .width('60%')
  236. .height('100%')
  237. .justifyContent(FlexAlign.Center)
  238. }
  239. Divider().vertical(false)
  240. .color($r('app.color.15FFFFFF'))
  241. .width('100%')
  242. }
  243. .width('92.6%')
  244. .height(item.operationVO?.length! * this.fixed100px)
  245. }
  246. })
  247. }
  248. .width('100%')
  249. .height('90%')
  250. .alignListItem(ListItemAlign.Center)
  251. }
  252. .height('100%')
  253. .width('29.6%')
  254. .borderRadius($r('app.float.virtualSize_6_4'))
  255. .justifyContent(FlexAlign.Center)
  256. .backgroundColor($r('app.color.10FFFFFF'))
  257. Image($r("app.media.wms_arrow_right"))
  258. .height($r('app.float.virtualSize_38'))
  259. .width($r('app.float.virtualSize_38'))
  260. // 工序所需物料
  261. Column() {
  262. Row() {
  263. Text('需求物料')
  264. .fontSize($r('app.float.fontSize_30'))
  265. .fontColor($r('app.color.FFFFFF'))
  266. .fontWeight(FontWeight.Medium)
  267. }
  268. .height('10%')
  269. .width('100%')
  270. .justifyContent(FlexAlign.Center)
  271. List() {
  272. ForEach(this.operationMaterialArray, (item: OperationMaterial, index: number) => {
  273. ListItem() {
  274. Column() {
  275. Row({space: 5}) {
  276. Circle()
  277. .width($r('app.float.virtualSize_2')) // 设置圆点直径
  278. .height($r('app.float.virtualSize_2'))
  279. .fill($r('app.color.FFFFFF'))
  280. Text(item.operationName ? item.operationName : '')
  281. .fontSize($r('app.float.fontSize_24'))
  282. .fontWeight(FontWeight.Medium)
  283. .fontColor($r('app.color.FFFFFF'))
  284. .maxLines(1)
  285. }
  286. .height(this.fixed52px)
  287. .width('100%')
  288. .alignItems(VerticalAlign.Center)
  289. ForEach(item.itemList, (material: OperationItem)=>{
  290. Column({space: 5}) {
  291. Row() {
  292. Text(material.itemName! + '-' + material.itemCode!)
  293. .fontSize($r('app.float.fontSize_16'))
  294. .fontWeight(FontWeight.Bold)
  295. .fontColor($r('app.color.FFFFFF'))
  296. .maxLines(1)
  297. Text((material.kitNum? material.kitNum : 0) + '/' + (material.storageNum? material.storageNum : 0))
  298. .fontSize($r('app.float.fontSize_16'))
  299. .fontWeight(FontWeight.Bold)
  300. .fontColor($r('app.color.FFFFFF'))
  301. .maxLines(1)
  302. }
  303. .width('100%')
  304. .justifyContent(FlexAlign.SpaceBetween)
  305. Row() {
  306. Text('型号:' + (material.itemModel ? material.itemModel : ''))
  307. .fontSize($r('app.float.fontSize_12'))
  308. .fontWeight(FontWeight.Lighter)
  309. .fontColor($r('app.color.FFFFFF'))
  310. .maxLines(1)
  311. Text('齐套/入库数量')
  312. .fontSize($r('app.float.fontSize_12'))
  313. .fontWeight(FontWeight.Lighter)
  314. .fontColor($r('app.color.60FFFFFF'))
  315. }
  316. .width('100%')
  317. .justifyContent(FlexAlign.SpaceBetween)
  318. Divider().vertical(false)
  319. .color($r('app.color.15FFFFFF'))
  320. .width('100%')
  321. }
  322. .width('100%')
  323. .height(this.fixed52px)
  324. .justifyContent(FlexAlign.End)
  325. })
  326. Row().height(this.fixed38px)
  327. }
  328. .height((item.itemList?.length! + 1) * this.fixed52px + this.fixed38px)
  329. .width('92.6%')
  330. .justifyContent(FlexAlign.Start)
  331. }
  332. })
  333. }
  334. .width('100%')
  335. .height('90%')
  336. .alignListItem(ListItemAlign.Center)
  337. }
  338. .height('100%')
  339. .width('29.6%')
  340. .borderRadius($r('app.float.virtualSize_6_4'))
  341. .justifyContent(FlexAlign.Center)
  342. .backgroundColor($r('app.color.10FFFFFF'))
  343. }
  344. .width('100%')
  345. .height('100%')
  346. .justifyContent(FlexAlign.SpaceBetween)
  347. }
  348. }