SwitchingProductDialog.ets 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. //切换产品
  2. import CommonConstants from '../common/constants/CommonConstants'
  3. import ProcessRequest from '../common/util/request/ProcessRequest'
  4. import OperationComponent from '../viewmodel/process/OperationComponent'
  5. import ProcessInfo from '../viewmodel/process/ProcessInfo'
  6. import TaskSeqVO from '../viewmodel/process/TaskSeqInfo'
  7. import RequestParamModel from '../viewmodel/RequestParamModel'
  8. import WorkOrderInfo from '../viewmodel/WorkOrderInfo'
  9. @CustomDialog
  10. export struct SwitchingProductDialog{
  11. private scrollerList: Scroller = new Scroller()
  12. //查询报工
  13. @State queryTaskSeq: TaskSeqVO[] = []
  14. //选中的工单
  15. @State selectWorkOder: WorkOrderInfo = {}
  16. //当前工序号
  17. @Prop currentOperationId:string = ''
  18. //当前工位
  19. @Prop currentStationId:string = ''
  20. //当前工序已报工数量
  21. @State reportedNum:number = 0
  22. //计划报工数量
  23. @State planReportNum:number = 0
  24. //选择的按钮索引(默认加载全部)
  25. @State selectedButtonIndex: number = 0
  26. //工步
  27. @Link opComponents: OperationComponent[]
  28. //扫描的流水号/序列/铭牌号
  29. @Link scanSeqValue: string
  30. // 扫码开工后的生产过程信息
  31. @Link process: ProcessInfo
  32. // 扫码开工状态(0:未开工 1:已开工)
  33. @Link scanState: number
  34. controller: CustomDialogController
  35. onQueryTask = async (currentStateList: Array<number>): Promise<number> => {
  36. let res = await ProcessRequest.post('/api/v1/plan/seq/list', {
  37. stationId:this.currentStationId,
  38. workOrderCode:this.selectWorkOder.workOrderCode,
  39. operationId:this.currentOperationId,
  40. stateList:currentStateList
  41. } as RequestParamModel) as TaskSeqVO[];
  42. this.queryTaskSeq = res
  43. return res.length
  44. }
  45. onSwitchProduct=async ()=> {
  46. if (!this.selectWorkOder.workOrderCode || !this.currentStationId) {
  47. return
  48. }
  49. this.opComponents = await ProcessRequest.get('/api/v1/op/compent/get/' + this.currentOperationId)
  50. if (this.opComponents) {
  51. for (const element of this.opComponents) {
  52. if (CommonConstants.OPERATION_COMPONENT_TYPE.has(element.compentType??'')) {
  53. element.compentType = CommonConstants.OPERATION_COMPONENT_TYPE.get(element.compentType??'')
  54. }
  55. }
  56. }
  57. }
  58. handleAllClick():void {
  59. this.onQueryTask([])
  60. }
  61. handleReportedClick():void{
  62. this.onQueryTask([2])
  63. }
  64. handleUnreportedClick():void{
  65. this.onQueryTask([-1,0,1])
  66. }
  67. async aboutToAppear() {
  68. this.reportedNum = await this.onQueryTask([2]);
  69. this.planReportNum = await this.onQueryTask([]);
  70. }
  71. @Builder
  72. buildButton(index: number, text: string,onClick: () => void) {
  73. Row(){
  74. if(this.selectedButtonIndex === index)
  75. {
  76. Image($r('app.media.process_radio_check'))
  77. .width($r('app.float.virtualSize_24'))
  78. .height($r('app.float.virtualSize_24'))
  79. .fillColor($r('app.color.0A84FF'))
  80. }else{
  81. Image($r('app.media.process_radio_no_check'))
  82. .width($r('app.float.virtualSize_24'))
  83. .height($r('app.float.virtualSize_24'))
  84. .fillColor($r('app.color.FFFFFF'))
  85. }
  86. Row(){}.width('10%')
  87. Text(text)
  88. .fontSize($r('app.float.fontSize_16'))
  89. .fontColor($r('app.color.FFFFFF'))
  90. }
  91. .justifyContent(FlexAlign.Center)
  92. .width('31%')
  93. .height('100%')
  94. .backgroundColor(this.selectedButtonIndex === index ? $r('app.color.200A84FF') : $r('app.color.20FFFFFF')) // 选中蓝/未选中灰
  95. .borderRadius($r('app.float.virtualSize_16'))
  96. .margin({ right:'3%'})
  97. .onClick(() => {
  98. this.selectedButtonIndex = index
  99. onClick();
  100. })
  101. }
  102. build() {
  103. Column() {
  104. Column() {
  105. Text("切换产品")
  106. .fontColor($r('app.color.FFFFFF'))
  107. .fontSize($r('app.float.fontSize_30'))
  108. }
  109. .height('8%')
  110. .width('100%')
  111. .justifyContent(FlexAlign.Center)
  112. Row(){
  113. Column(){
  114. Row(){
  115. Column({space:3}){
  116. Text(this.selectWorkOder.materialName)
  117. .fontSize($r('app.float.fontSize_24'))
  118. .fontColor($r('app.color.FFFFFF'))
  119. Text(this.selectWorkOder.materialCode)
  120. .fontSize($r('app.float.fontSize_12'))
  121. .fontColor($r('app.color.FFFFFF'))
  122. .fontWeight(FontWeight.Lighter)
  123. Row(){
  124. Text("工单 ")
  125. .fontSize($r('app.float.fontSize_16'))
  126. .fontColor($r('app.color.FFFFFF'))
  127. .fontWeight(FontWeight.Lighter)
  128. Text(this.selectWorkOder.workOrderCode)
  129. .fontSize($r('app.float.fontSize_16'))
  130. .fontColor($r('app.color.FFFFFF'))
  131. }
  132. }
  133. .height('100%')
  134. .width('70%')
  135. .justifyContent(FlexAlign.End)
  136. .alignItems(HorizontalAlign.Start)
  137. Column(){
  138. Row(){
  139. Text(`${this.reportedNum}/`)
  140. .fontSize($r('app.float.fontSize_38'))
  141. .fontColor($r('app.color.FFFFFF'))
  142. Text(`${this.planReportNum}`)
  143. .fontSize($r('app.float.fontSize_38'))
  144. .fontColor($r('app.color.60FFFFFF'))
  145. }
  146. Text('当前工序已报工/计划')
  147. .fontSize($r('app.float.fontSize_12'))
  148. .fontColor($r('app.color.FFFFFF'))
  149. .fontWeight(FontWeight.Lighter)
  150. }
  151. .height('100%')
  152. .width('30%')
  153. .justifyContent(FlexAlign.End)
  154. .alignItems(HorizontalAlign.End)
  155. }
  156. .height('10%')
  157. .width('100%')
  158. Row(){
  159. Row() {
  160. this.buildButton(0, '全部', () => this.handleAllClick())
  161. this.buildButton(1, '已报工', () => this.handleReportedClick())
  162. this.buildButton(2, '未报工', () => this.handleUnreportedClick())
  163. }.width('100%')
  164. .height('55%')
  165. }
  166. .height('10%')
  167. .width('80%')
  168. .margin({right:'20%'})
  169. .justifyContent(FlexAlign.Start)
  170. Column(){
  171. List({space: 8, scroller:this.scrollerList}) {
  172. ForEach(this.queryTaskSeq, (item:TaskSeqVO) => {
  173. ListItem() {
  174. taskSeqItem({
  175. item:item,
  176. scanSeqValue:this.scanSeqValue,
  177. selectedButtonIndex:this.selectedButtonIndex
  178. })
  179. .onClick(()=>{
  180. this.scanSeqValue = item.seqNo!
  181. })
  182. }
  183. })
  184. }
  185. .width('100%')
  186. .height('100%')
  187. }
  188. .height('80%')
  189. .width('100%')
  190. }
  191. .height('100%')
  192. .width('46%')
  193. Divider()
  194. .vertical(true)
  195. .strokeWidth(1)
  196. .color($r('app.color.15FFFFFF'))
  197. .margin({ bottom: '2%'})
  198. Column(){
  199. Text("扫描流水/序列/铭牌号")
  200. .fontSize($r('app.float.fontSize_16'))
  201. .fontColor($r('app.color.FFFFFF'))
  202. .margin({left:'22%'})
  203. Row() {
  204. // 左侧二维码图标
  205. Image($r('app.media.material_qr_code'))
  206. .width($r('app.float.virtualSize_24'))
  207. .height($r('app.float.virtualSize_24'))
  208. .fillColor($r('app.color.FFFFFF'))
  209. .objectFit(ImageFit.Contain)
  210. .margin({left:'5%'})
  211. // 扫码输入框
  212. TextInput({text:this.scanSeqValue, placeholder: '请扫描或录入流水、序列或铭牌号' })
  213. .type(InputType.Normal)
  214. .placeholderFont({ size: $r('app.float.fontSize_16') })
  215. .placeholderColor($r('app.color.30FFFFFF'))
  216. .fontSize($r('app.float.fontSize_16'))
  217. .fontColor($r('app.color.FFFFFF'))
  218. .enableKeyboardOnFocus(false)
  219. .onSubmit(() => {
  220. })
  221. .onChange((value: string) => {
  222. this.scanSeqValue = value;
  223. })
  224. }
  225. .height('8%')
  226. .width('65%')
  227. .borderRadius($r('app.float.virtualSize_16'))
  228. .backgroundColor($r('app.color.000000'))
  229. .margin({top:'2%',bottom:'5%',left:'20%'})
  230. }
  231. .justifyContent(FlexAlign.Center)
  232. .alignItems(HorizontalAlign.Start)
  233. .width('46%')
  234. .height('100%')
  235. }
  236. .justifyContent(FlexAlign.SpaceEvenly)
  237. .width('100%')
  238. .height('81%')
  239. .margin({ top: '2%'})
  240. Column() {
  241. Divider()
  242. .vertical(false)
  243. .strokeWidth(1)
  244. .color($r('app.color.15FFFFFF'))
  245. Row() {
  246. Row() {
  247. Text('取消')
  248. .fontColor($r('app.color.60FFFFFF'))
  249. .fontSize($r('app.float.fontSize_30'))
  250. }
  251. .justifyContent(FlexAlign.Center)
  252. .width('50%')
  253. .onClick(() => this.controller.close())
  254. Divider()
  255. .vertical(true)
  256. .strokeWidth(1)
  257. .color($r('app.color.15FFFFFF'))
  258. Row() {
  259. Text('确定')
  260. .fontColor($r('app.color.007AFF'))
  261. .fontSize($r('app.float.fontSize_30'))
  262. }
  263. .justifyContent(FlexAlign.Center)
  264. .width('50%')
  265. .onClick(() => {
  266. this.scanState = 0
  267. this.process = {}
  268. this.onSwitchProduct();
  269. this.controller.close();
  270. })
  271. }
  272. }
  273. .width('100%')
  274. .height('8%')
  275. }
  276. .height('71%')
  277. .width('62%')
  278. .backgroundColor($r('app.color.2A2A2A'))
  279. .justifyContent(FlexAlign.End)
  280. .alignItems(HorizontalAlign.Start)
  281. .borderColor($r('app.color.000000'))
  282. .borderWidth(1)
  283. .borderRadius($r('app.float.virtualSize_16'))
  284. }
  285. }
  286. @Component
  287. export struct taskSeqItem{
  288. @Prop item: TaskSeqVO
  289. @Link scanSeqValue:string
  290. @State scaleValue : number = 1
  291. @Link selectedButtonIndex:number
  292. build() {
  293. Row() {
  294. Text('S/N ')
  295. .fontSize($r('app.float.fontSize_16'))
  296. .fontColor($r('app.color.FFFFFF'))
  297. .fontWeight(FontWeight.Lighter)
  298. .margin({ left:'2%'})
  299. Text(this.item.seqNo)
  300. .fontSize($r('app.float.fontSize_16'))
  301. .fontColor($r('app.color.FFFFFF'))
  302. .textAlign(TextAlign.Start)
  303. Blank()
  304. if(this.selectedButtonIndex != 2) {
  305. Text(this.item.state! === '2' ? `报工时间:${this.item.updated}` : '')
  306. .fontSize($r('app.float.fontSize_16'))
  307. .fontColor($r('app.color.60FFFFFF'))
  308. .fontWeight(FontWeight.Lighter)
  309. .margin({ right:'2%'})
  310. }
  311. }.width('100%')
  312. .justifyContent(FlexAlign.Start)
  313. .backgroundColor($r('app.color.20FFFFFF'))
  314. .padding(10)
  315. .borderRadius($r('app.float.virtualSize_16'))
  316. .scale({ x: this.scaleValue, y: this.scaleValue })
  317. .animation({
  318. duration: 200,
  319. curve: Curve.Linear // 弹性曲线更生动
  320. })
  321. .onClick(() => {
  322. this.scaleValue = 0.9; // 点击时缩小
  323. setTimeout(() => {
  324. this.scanSeqValue = this.item?.seqNo??''
  325. this.scaleValue = 1;
  326. }, 200);
  327. })
  328. }
  329. }