OperationMaterialKit.ets 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. /*
  2. * 工序齐套
  3. * */
  4. import { TimeAndTitle } from '../component/TimeAndTitle'
  5. import router from '@ohos.router'
  6. import { NavigationBar } from '../component/NavigationBar'
  7. import { OperationMaterialKitOneStep } from '../view/wms/OperationMaterialKitOneStep'
  8. import WorkOrderInfo from '../viewmodel/wms/WorkOrderInfo'
  9. import { OperationMaterialKitTwoStep } from '../view/wms/OperationMaterialKitTwoStep'
  10. import { OperationMaterialKitThreeStep } from '../view/wms/OperationMaterialKitThreeStep'
  11. import OperationInfo from '../viewmodel/wms/OperationInfo'
  12. import OperationItem from '../viewmodel/wms/OperationItem'
  13. import VehicleInfo from '../viewmodel/wms/VehicleInfo'
  14. import WmsRequest from '../common/util/request/WmsRequest'
  15. import promptAction from '@ohos.promptAction'
  16. import RequestParamModel from '../viewmodel/wms/RequestParamModel'
  17. import CommonConstants from '../common/constants/CommonConstants'
  18. import RobotErrorHandleRequest from '../common/util/request/RobotErrorHandleRequest'
  19. import { ConfirmDialogParams, RgvInfo } from '../params/RobotsParam'
  20. import { CommonConfirmDialog, ProcessFlow, RemindDialog } from '../component/OrderMaterialsStorageView'
  21. @Entry
  22. @Component
  23. struct OperationMaterialKit {
  24. @State step: number = 1
  25. // 选中的工单
  26. @State workOrder: WorkOrderInfo = {}
  27. // 选中的工序
  28. @State selectOperations: OperationInfo[] = []
  29. // 选中工序需求的物料
  30. @State operationItems: OperationItem[] = []
  31. // 抽屉称重(根据重量判断抽屉是否有料箱)
  32. @StorageLink('materialBoxWeight') materialBoxWeight: number = 0
  33. // 抽屉状态
  34. @StorageLink('drawerPositionStatus') drawerPositionStatus: number = 1
  35. @State reminds: string = '1'
  36. commonDialogController: CustomDialogController | null = null;
  37. remindController: CustomDialogController = new CustomDialogController({
  38. builder: RemindDialog({
  39. remind: this.reminds,}
  40. ),
  41. customStyle: true,
  42. maskColor: 'rgba(0,0,0,0.6)',
  43. //autoCancel:false
  44. })
  45. private showConfirmDialog(params: ConfirmDialogParams) {
  46. if (this.commonDialogController) {
  47. this.commonDialogController.close()
  48. }
  49. this.commonDialogController = new CustomDialogController({
  50. builder: CommonConfirmDialog({
  51. title: params.title || '提示',
  52. message: params.message,
  53. confirmText: params.confirmText || '确定',
  54. cancelText: params.cancelText || '取消',
  55. onConfirm: params.onConfirm
  56. }),
  57. cancel: () => console.log('用户取消操作'),
  58. customStyle: true,
  59. autoCancel:false,
  60. maskColor: 'rgba(0,0,0,0.6)'
  61. });
  62. this.commonDialogController.open();
  63. }
  64. // 判断小车状态
  65. async queryRgvInfo(): Promise<boolean> {
  66. let res: RgvInfo = await RobotErrorHandleRequest.get('/api/v1/wcs/rgv/rgv1', {}) as RgvInfo;
  67. if (res) {
  68. if (res.status != '0' || res.x != res.rx || res.y != res.ry) {
  69. return false;
  70. }
  71. return true; // 如果条件不满足,返回 true
  72. }
  73. return false; // 如果 res 为 null 或 undefined,返回 false
  74. }
  75. // 空箱出库的方法
  76. callEmptyBoxFun = async () => {
  77. //查询小车的状态
  78. const rgvStatusNormal = await this.queryRgvInfo()
  79. if(!rgvStatusNormal){
  80. this.reminds = "小车状态异常或位置错误,请检查后重试"
  81. this.remindController.open()
  82. setTimeout(() => {
  83. this.remindController.close()
  84. }, 2000);
  85. return
  86. }
  87. console.info("ssss"+this.drawerPositionStatus+"as")
  88. if(this.drawerPositionStatus == 0)
  89. {
  90. this.reminds = "抽屉未缩回,请检查后重试"
  91. this.remindController.open()
  92. setTimeout(() => {
  93. this.remindController.close()
  94. }, 2000);
  95. return
  96. }
  97. if(this.materialBoxWeight > 0)
  98. {
  99. this.reminds = "抽屉已有料箱,请检查后重试"
  100. this.remindController.open()
  101. setTimeout(() => {
  102. this.remindController.close()
  103. }, 2000);
  104. return
  105. }
  106. //查询抽屉的状态
  107. // this.showConfirmDialog({
  108. // title: '料箱出库',
  109. // message: `确定要空箱出库吗?`,
  110. // onConfirm: ()=> {
  111. //
  112. // }
  113. // });
  114. let res: VehicleInfo = await WmsRequest.post('/api/v1/stock/queryEmptyBox')
  115. console.log("hhtest", JSON.stringify(res), res?.vehicleNo)
  116. await WmsRequest.post('/api/v1/wmsOrder/outBox', {
  117. stanCode: CommonConstants.STATION_CODE,
  118. vehicleNo: res!.vehicleNo,
  119. houseNo: res!.houseNo
  120. } as RequestParamModel)
  121. promptAction.showToast({
  122. message: "箱子正在运行中....",
  123. duration: 1800,
  124. bottom: '50%'
  125. })
  126. }
  127. build() {
  128. Column() {
  129. // 顶部时间和菜单栏
  130. Row(){
  131. TimeAndTitle()
  132. }
  133. .width('100%')
  134. .height('3.4%')
  135. .alignItems(VerticalAlign.Bottom)
  136. .justifyContent(FlexAlign.End)
  137. // 工序齐套
  138. Row() {
  139. Image($r('app.media.general_return'))
  140. .height($r('app.float.virtualSize_22_4'))
  141. .width($r('app.float.virtualSize_22_4'))
  142. .fillColor($r('app.color.FFFFFF'))
  143. Text('工序齐套')
  144. .fontSize($r('app.float.fontSize_12'))
  145. .fontColor($r('app.color.FFFFFF'))
  146. .fontWeight(FontWeight.Medium)
  147. }
  148. .width('94.8%')
  149. .height('5.2%')
  150. .alignItems(VerticalAlign.Center)
  151. .justifyContent(FlexAlign.Start)
  152. .onClick(()=> {
  153. router.back()
  154. })
  155. // 当前齐套步骤和操作栏
  156. Row() {
  157. Row().width('41%')
  158. Row() {
  159. ProcessFlow({
  160. currentStep: this.step,
  161. firstStepTitle: "选择工单",
  162. secondStepTitle: "齐套装箱",
  163. thirdStepTitle: "齐套入库",
  164. })
  165. }
  166. .height('80%')
  167. .width('18%')
  168. // .justifyContent(FlexAlign.SpaceBetween)
  169. .alignItems(VerticalAlign.Top)
  170. Blank()
  171. NavigationBar()
  172. .height('80%')
  173. .width('23%')
  174. }
  175. .height('13%')
  176. .width('100%')
  177. // 步骤详情
  178. Column() {
  179. if (this.step === 1) {
  180. OperationMaterialKitOneStep({
  181. workOrder: this.workOrder,
  182. selectOperations: this.selectOperations,
  183. operationItems: this.operationItems,
  184. })
  185. } else if (this.step === 2) {
  186. OperationMaterialKitTwoStep({
  187. workOrder: this.workOrder,
  188. selectOperations: this.selectOperations,
  189. operationItems: this.operationItems,
  190. })
  191. } else {
  192. OperationMaterialKitThreeStep({
  193. workOrder: this.workOrder,
  194. selectOperations: this.selectOperations,
  195. operationItems: this.operationItems,
  196. })
  197. }
  198. }
  199. .height('71%')
  200. .width('94.8%')
  201. // 步骤切换按钮
  202. Row() {
  203. Row () {
  204. Text('第一步')
  205. .fontSize($r('app.float.fontSize_9_6'))
  206. .fontColor($r('app.color.0A84FF'))
  207. .fontWeight(FontWeight.Medium)
  208. }
  209. .height('67%')
  210. .width('24.1%')
  211. .justifyContent(FlexAlign.Center)
  212. .backgroundColor($r('app.color.20FFFFFF'))
  213. .borderRadius($r('app.float.fontSize_6_4'))
  214. .opacity(this.step > 2 ? 1 : 0.3)
  215. .onClick(()=>{
  216. this.step = 1
  217. })
  218. Row().width('1.2%')
  219. Row () {
  220. Text('上一步')
  221. .fontSize($r('app.float.fontSize_9_6'))
  222. .fontColor($r('app.color.0A84FF'))
  223. .fontWeight(FontWeight.Medium)
  224. }
  225. .height('67%')
  226. .width('24.1%')
  227. .justifyContent(FlexAlign.Center)
  228. .backgroundColor($r('app.color.20FFFFFF'))
  229. .borderRadius($r('app.float.fontSize_6_4'))
  230. .opacity(this.step > 1 ? 1 : 0.3)
  231. .onClick(()=>{
  232. if (this.step > 1) {
  233. this.step -= 1
  234. }
  235. })
  236. Row().width('1.2%')
  237. Row () {
  238. Text('空箱出库')
  239. .fontSize($r('app.float.fontSize_9_6'))
  240. .fontColor($r('app.color.0A84FF'))
  241. .fontWeight(FontWeight.Medium)
  242. }
  243. .height('67%')
  244. .width('24.1%')
  245. .justifyContent(FlexAlign.Center)
  246. .backgroundColor($r('app.color.20FFFFFF'))
  247. .borderRadius($r('app.float.fontSize_6_4'))
  248. .opacity(this.step === 2 ? 1 : 0.3)
  249. .onClick(()=>{
  250. this.callEmptyBoxFun()
  251. })
  252. Row().width('1.2%')
  253. Row () {
  254. Text('下一步')
  255. .fontSize($r('app.float.fontSize_9_6'))
  256. .fontColor($r('app.color.0A84FF'))
  257. .fontWeight(FontWeight.Medium)
  258. }
  259. .height('67%')
  260. .width('24.1%')
  261. .justifyContent(FlexAlign.Center)
  262. .backgroundColor($r('app.color.20FFFFFF'))
  263. .borderRadius($r('app.float.fontSize_6_4'))
  264. .opacity(this.step < 3 ? 1 : 0.3)
  265. .onClick(()=>{
  266. if (this.step < 3) {
  267. this.step += 1
  268. }
  269. })
  270. }
  271. .width('94.8%')
  272. .height('7.4%')
  273. .alignItems(VerticalAlign.Center)
  274. }
  275. .width('100%')
  276. .height('100%')
  277. .backgroundColor($r('app.color.000000'))
  278. }
  279. }