OperationMaterialKitOneStep.ets 15 KB

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