ProcessStepPage.ets 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341
  1. /*
  2. * 工步页面
  3. * */
  4. import { BottomOperateComp } from '../../common/component/BottomOperateComp'
  5. import router from '@ohos.router';
  6. import ProcessData from '../../viewmodel/ProcessData';
  7. import CommonConstants from '../../common/constants/CommonConstants';
  8. import ProcessStep from '../../viewmodel/ProcessStep'
  9. import MaterialInfo from '../../model/MaterialInfo';
  10. import { MaterialCollectView } from '../../view/processview/MaterialCollectView';
  11. import { RecordItemView } from '../../view/processview/RecordItemView';
  12. import { MultimediaCollectView } from '../../view/processview/MultimediaCollectView';
  13. import { EsopView } from '../../view/processview/EsopView';
  14. import { SpotCheckView } from '../../view/processview/SpotCheckView';
  15. import { EquipRecordView } from '../../view/processview/EquipRecordView';
  16. import { DebugPairView } from '../../view/processview/DebugPairView';
  17. import { FixtureView } from '../../view/processview/FixtureView';
  18. import { NameplateBindView } from '../../view/processview/NameplateBindView';
  19. import { pinyin } from 'pinyin-pro';
  20. import HashMap from '@ohos.util.HashMap';
  21. import { ProcessTitleComp } from '../../common/component/ProcessTitleComp';
  22. import JGRequest from '../../common/util/request/Request';
  23. import StartWorkInfo from '../../viewmodel/StartWorkInfo';
  24. const params = router.getParams(); // 获取传递过来的参数对象
  25. const startWorkInfo = params['startWorkInfo']; // 获取开工信息
  26. const processInfo = params['processInfo']; // 获取当前工序信息
  27. @Entry
  28. @Component
  29. struct ProcessStepPage {
  30. startWorkInfo: StartWorkInfo = startWorkInfo
  31. @State process: ProcessData = processInfo
  32. @State processSteps: ProcessStep[] = []
  33. private stepImages: Resource[] = CommonConstants.STEP_IMAGES
  34. private stepSelectImages: Resource[] = CommonConstants.STEP_SELECT_IMAGES
  35. // 选中的工步索引
  36. @State selectStep: number = -1
  37. // 报故弹窗
  38. reportFaultController: CustomDialogController = new CustomDialogController({
  39. builder: ReportFaultDialog({
  40. }),
  41. autoCancel: true,
  42. alignment: DialogAlignment.TopEnd,
  43. // gridCount: 3,
  44. customStyle: true,
  45. })
  46. // 报工弹窗
  47. reportWorkController: CustomDialogController = new CustomDialogController({
  48. builder: ReportWorkDialog({
  49. }),
  50. autoCancel: true,
  51. alignment: DialogAlignment.Center,
  52. // gridCount: 3,
  53. customStyle: true,
  54. })
  55. async aboutToAppear() {
  56. let res: ProcessStep[] = await JGRequest.get("/api/v1/process/opCompent/get/" + 129, {})
  57. if (res && res.length > 0) {
  58. this.processSteps = res
  59. this.selectStep = 0
  60. }
  61. }
  62. build() {
  63. Column() {
  64. ProcessTitleComp()
  65. Row() {
  66. // 左侧信息和操作栏
  67. Column() {
  68. // 信息栏(产品、工序、主料)
  69. Column() {
  70. Column() {
  71. Text(this.startWorkInfo.materialName)
  72. .fontSize($r('app.float.card_title_font_size'))
  73. .fontWeight(FontWeight.Medium)
  74. .fontColor($r('app.color.general_font_color'))
  75. .opacity($r('app.float.general_font_opacity'))
  76. .maxLines(1)
  77. Text(this.startWorkInfo.materialCode)
  78. .fontSize($r('app.float.card_info_font_size'))
  79. .fontColor($r('app.color.general_font_color'))
  80. .fontWeight(FontWeight.Regular)
  81. .opacity($r('app.float.card_font_default_opacity'))
  82. .maxLines(1)
  83. }
  84. .height('27%')
  85. .width('90%')
  86. .alignItems(HorizontalAlign.Start)
  87. Column() {
  88. Text('序列号')
  89. .fontSize($r('app.float.card_info_font_size'))
  90. .fontWeight(FontWeight.Regular)
  91. .fontColor($r('app.color.general_font_color'))
  92. .opacity($r('app.float.card_font_default_opacity'))
  93. Text(this.startWorkInfo.seqNo)
  94. .fontSize($r('app.float.card_info_font_size'))
  95. .fontColor($r('app.color.general_font_color'))
  96. .fontWeight(FontWeight.Medium)
  97. .opacity($r('app.float.general_font_opacity'))
  98. .maxLines(1)
  99. }
  100. .height('27%')
  101. .width('90%')
  102. .alignItems(HorizontalAlign.Start)
  103. Column() {
  104. Text('当前工序')
  105. .fontSize($r('app.float.card_info_font_size'))
  106. .fontWeight(FontWeight.Regular)
  107. .fontColor($r('app.color.general_font_color'))
  108. .opacity($r('app.float.card_font_default_opacity'))
  109. Row() {
  110. Text(this.process.operationName)
  111. .fontSize($r('app.float.card_info_font_size'))
  112. .fontColor($r('app.color.general_font_color'))
  113. .fontWeight(FontWeight.Medium)
  114. .opacity($r('app.float.general_font_opacity'))
  115. Image($r('app.media.subscript'))
  116. .height($r('app.float.card_subscript_size'))
  117. .width($r('app.float.card_subscript_size'))
  118. }
  119. .alignItems(VerticalAlign.Center)
  120. .justifyContent(FlexAlign.SpaceBetween)
  121. .width('90%')
  122. }
  123. .height('27%')
  124. .width('90%')
  125. .alignItems(HorizontalAlign.Start)
  126. }
  127. .height('29%')
  128. .width('100%')
  129. .justifyContent(FlexAlign.SpaceEvenly)
  130. .backgroundColor($r('app.color.general_card_background_color'))
  131. .borderRadius($r('app.float.general_border_radius'))
  132. // 操作卡片
  133. OperateCard({operateName: '叫料', operateImage:$r('app.media.call_material'), clickEvent: ()=>{
  134. router.pushUrl({
  135. url: 'pages/process/CallMaterialPage',
  136. // params: {}
  137. })
  138. }})
  139. OperateCard({operateName: '工位上料', operateImage:$r('app.media.station_loading'), clickEvent: ()=>{
  140. router.pushUrl({
  141. url: 'pages/process/StationLoadingPage'
  142. })
  143. }})
  144. OperateCard({operateName: '物料流转', operateImage:$r("app.media.material_circulation"), clickEvent: ()=>{
  145. router.pushUrl({
  146. url: 'pages/process/MaterialCirculationPage',
  147. // params: {}
  148. })
  149. }})
  150. OperateCard({operateName: '图纸', operateImage:$r('app.media.drawing'), clickEvent: ()=>{
  151. router.pushUrl({
  152. url: 'pages/process/ProcessDrawingPage',
  153. params: {
  154. mainMaterial: this.startWorkInfo.materialCode
  155. }
  156. })
  157. }})
  158. OperateCard({operateName: '报故', operateImage:$r('app.media.report_fault'), clickEvent: ()=>{
  159. this.reportFaultController.open()
  160. }})
  161. OperateCard({operateName: '报工', operateImage:$r('app.media.report_work'), bgColor: $r('app.color.process_card_green_color'), clickEvent: ()=>{
  162. this.reportWorkController.open()
  163. }})
  164. }
  165. .height('83%')
  166. .width('15%')
  167. .justifyContent(FlexAlign.SpaceBetween)
  168. .alignItems(HorizontalAlign.Center)
  169. // 工步和当前工步的操作
  170. Column() {
  171. // 当前工序的工步列表
  172. List({space: 6}) {
  173. ForEach(this.processSteps, (item: ProcessStep, index: number)=> {
  174. ListItem() {
  175. Column() {
  176. Image(this.selectStep === index ? this.stepSelectImages[item.compentType - 1] : this.stepImages[item.compentType - 1])
  177. .width($r('app.float.card_image_size'))
  178. .height($r('app.float.card_image_size'))
  179. Text(item.compentName)
  180. .fontSize($r('app.float.card_info_font_size'))
  181. .fontWeight(FontWeight.Medium)
  182. .fontColor(this.selectStep === index ? $r('app.color.general_font_white_color') : $r('app.color.general_font_color'))
  183. .opacity(this.selectStep === index ? 1 : $r('app.float.general_font_opacity'))
  184. }
  185. .height('100%')
  186. .width('9.5%')
  187. .justifyContent(FlexAlign.Center)
  188. .borderRadius($r('app.float.general_border_radius'))
  189. .backgroundColor(this.selectStep === index ? $r('app.color.process_card_blue_color') : $r('app.color.page_general_background'))
  190. .onClick(()=>{
  191. this.selectStep = index
  192. })
  193. }
  194. })
  195. }
  196. .height('9%')
  197. .width('100%')
  198. .listDirection(Axis.Horizontal)
  199. .margin({left: '2%'})
  200. Column() {
  201. if (this.processSteps && this.processSteps.length > 0 && this.processSteps[this.selectStep].compentType.toString() === '1') {
  202. MaterialCollectView({
  203. startWorkInfo: this.startWorkInfo,
  204. })
  205. } else if (this.processSteps && this.processSteps.length > 0 && this.processSteps[this.selectStep].compentType.toString() === '2') {
  206. RecordItemView({
  207. operationId: this.process.operationId,
  208. processId: this.startWorkInfo.id
  209. })
  210. } else if (this.processSteps && this.processSteps.length > 0 && this.processSteps[this.selectStep].compentType.toString() === '3') {
  211. MultimediaCollectView({
  212. operationId: this.process.operationId,
  213. processId: this.startWorkInfo.id,
  214. })
  215. } else if (this.processSteps && this.processSteps.length > 0 && this.processSteps[this.selectStep].compentType.toString() === '4') {
  216. EsopView({operationId: this.process.operationId,})
  217. } else if (this.processSteps && this.processSteps.length > 0 && this.processSteps[this.selectStep].compentType.toString() === '5') {
  218. SpotCheckView({
  219. operationId: this.process.operationId,
  220. processId: this.startWorkInfo.id
  221. })
  222. } else if (this.processSteps && this.processSteps.length > 0 && this.processSteps[this.selectStep].compentType.toString() === '6') {
  223. EquipRecordView({
  224. operationId: this.process.operationId,
  225. processId: this.startWorkInfo.id
  226. })
  227. } else if (this.processSteps && this.processSteps.length > 0 && this.processSteps[this.selectStep].compentType.toString() === '7') {
  228. FixtureView()
  229. } else if (this.processSteps && this.processSteps.length > 0 && this.processSteps[this.selectStep].compentType.toString() === '8') {
  230. DebugPairView()
  231. } else if (this.processSteps && this.processSteps.length > 0 && this.processSteps[this.selectStep].compentType.toString() === '9') {
  232. NameplateBindView({mainMaterial: this.startWorkInfo.materialCode})
  233. }
  234. }
  235. .width('100%')
  236. .height('91%')
  237. }
  238. .height('100%')
  239. .width('85%')
  240. }
  241. .width('100%')
  242. .height('84%')
  243. .alignItems(VerticalAlign.Top)
  244. .margin({left: '1.25%'})
  245. BottomOperateComp()
  246. }
  247. .width('100%')
  248. .height('100%')
  249. .backgroundColor($r('app.color.page_general_background'))
  250. }
  251. }
  252. @Component
  253. struct OperateCard {
  254. operateName: string
  255. operateImage: Resource
  256. bgColor?: Resource = $r('app.color.general_card_background_color')
  257. clickEvent?: Function
  258. build() {
  259. Row() {
  260. Row() {
  261. Text(this.operateName)
  262. .fontSize($r('app.float.card_title_font_size'))
  263. .fontWeight(FontWeight.Medium)
  264. .fontColor($r('app.color.general_font_color'))
  265. .opacity($r('app.float.general_font_opacity'))
  266. Image(this.operateImage)
  267. .width($r('app.float.general_icon_size'))
  268. .height($r('app.float.general_icon_size'))
  269. }
  270. .width('90%')
  271. .justifyContent(FlexAlign.SpaceBetween)
  272. }
  273. .height('11.5%')
  274. .width('100%')
  275. .backgroundColor(this.bgColor)
  276. .borderRadius($r('app.float.general_border_radius'))
  277. .justifyContent(FlexAlign.Center)
  278. .onClick(()=>{
  279. if (this.clickEvent) {
  280. this.clickEvent()
  281. }
  282. })
  283. }
  284. }
  285. @CustomDialog
  286. struct ReportFaultDialog {
  287. @State historyArray: MaterialInfo[] = CommonConstants.MATERIAL_ARRAY
  288. // 所有的缺陷类型
  289. @State faultTypes: FaultType[] = [
  290. {id: 1, faultName: '外观缺陷'}, {id: 2, faultName: '尺寸和形状缺陷'}, {id: 3, faultName: '功能性缺陷'}, {id: 4, faultName: '电气连接缺陷'}, {id: 5, faultName: '密闭性缺陷'},
  291. ]
  292. // 所有的缺陷类型
  293. @State faultLevels: FaultLevel[] = [
  294. {id: 1, levelName: '1级缺陷'}, {id: 2, levelName: '2级缺陷'}, {id: 3, levelName: '3级缺陷'}, {id: 4, levelName: '4级缺陷'},
  295. ]
  296. @State selectTypes: number[] = []
  297. @State selectLevel: number = -1
  298. @State faultImage: Resource[] = [$r('app.media.return'), $r('app.media.pcb_demo'), $r('app.media.pcb_demo'), $r('app.media.pcb_demo')]
  299. // 故障缺陷选择弹窗
  300. faultTypeController: CustomDialogController = new CustomDialogController({
  301. builder: FaultTypeDialog({
  302. faultTypes: this.faultTypes,
  303. selectTypes: $selectTypes,
  304. }),
  305. autoCancel: true,
  306. alignment: DialogAlignment.Center,
  307. // gridCount: 3,
  308. customStyle: true,
  309. })
  310. // 故障等级选择弹窗
  311. faultLevelController: CustomDialogController = new CustomDialogController({
  312. builder: FaultLevelDialog({
  313. faultLevels: this.faultLevels,
  314. selectLevel: $selectLevel,
  315. }),
  316. autoCancel: true,
  317. alignment: DialogAlignment.Center,
  318. // gridCount: 3,
  319. customStyle: true,
  320. })
  321. controller?: CustomDialogController
  322. cancel: () => void = () => {}
  323. confirm: () => void = () => {}
  324. aboutToAppear(){
  325. // todo 查询故障类型 故障等级
  326. }
  327. build() {
  328. Column() {
  329. Row() {
  330. Text('报故')
  331. .fontSize($r('app.float.process_card_large_font_size'))
  332. .fontWeight(FontWeight.Medium)
  333. .fontColor($r('app.color.general_font_color'))
  334. .opacity($r('app.float.general_font_opacity'))
  335. }
  336. .height('7.5%')
  337. .alignItems(VerticalAlign.Bottom)
  338. Column() {
  339. Row() {
  340. Text('故障缺陷')
  341. .fontSize($r('app.float.process_card_middle_font_size'))
  342. .fontWeight(FontWeight.Medium)
  343. .fontColor($r('app.color.general_font_color'))
  344. .opacity($r('app.float.general_font_opacity'))
  345. }
  346. .width('96%')
  347. .height('6%')
  348. Scroll() {
  349. Flex({ wrap: FlexWrap.Wrap}) {
  350. ForEach(this.selectTypes, (item: number, index: number) => {
  351. Row().width('2%')
  352. Row() {
  353. Text(this.faultTypes[item].faultName)
  354. .fontSize($r('app.float.process_card_middle_font_size'))
  355. .fontWeight(FontWeight.Medium)
  356. .fontColor($r('app.color.general_font_color'))
  357. .opacity($r('app.float.general_font_opacity'))
  358. }
  359. .backgroundColor($r('app.color.general_card_background_color'))
  360. .width('47%')
  361. .height('10%')
  362. .borderRadius($r('app.float.general_border_radius'))
  363. .padding({left: 15})
  364. .margin({bottom: 5})
  365. })
  366. Row() {
  367. Row().width('2%')
  368. Image($r('app.media.fault_add'))
  369. .objectFit(ImageFit.Contain)
  370. .onClick(()=>{
  371. this.faultTypeController.open()
  372. })
  373. }
  374. .width('100%')
  375. .height('10%')
  376. Row() {
  377. Row().width('2%')
  378. Text('故障等级')
  379. .fontSize($r('app.float.process_card_middle_font_size'))
  380. .fontWeight(FontWeight.Medium)
  381. .fontColor($r('app.color.general_font_color'))
  382. .opacity($r('app.float.general_font_opacity'))
  383. }
  384. .width('100%')
  385. .height('6%')
  386. Row() {
  387. Row().width('2%')
  388. Row() {
  389. Text(this.faultLevels && this.faultLevels[this.selectLevel] ? this.faultLevels[this.selectLevel].levelName : '请选择')
  390. .fontSize($r('app.float.process_card_middle_font_size'))
  391. .fontWeight(FontWeight.Medium)
  392. .fontColor($r('app.color.general_font_color'))
  393. .opacity($r('app.float.material_collect_font_opacity'))
  394. Blank()
  395. Row() {
  396. Image($r('app.media.subscript_space'))
  397. .height($r('app.float.card_subscript_new_size'))
  398. .width($r('app.float.card_subscript_new_size'))
  399. }
  400. .alignItems(VerticalAlign.Bottom)
  401. .justifyContent(FlexAlign.End)
  402. .width('20%')
  403. .height('100%')
  404. }
  405. .backgroundColor($r('app.color.general_card_background_color'))
  406. .width('47%')
  407. .height('10%')
  408. .borderRadius($r('app.float.general_border_radius'))
  409. .padding({left: 15})
  410. .onClick(()=>{
  411. this.faultLevelController.open()
  412. })
  413. }
  414. .width('100%')
  415. Row() {
  416. Row().width('2%')
  417. Text('故障图片')
  418. .fontSize($r('app.float.process_card_middle_font_size'))
  419. .fontWeight(FontWeight.Medium)
  420. .fontColor($r('app.color.general_font_color'))
  421. .opacity($r('app.float.general_font_opacity'))
  422. }
  423. .width('100%')
  424. .height('6%')
  425. ForEach(this.faultImage, (item: Resource, index: number) => {
  426. Row().width('2%')
  427. if (index === 0) {
  428. Row() {
  429. Image($r('app.media.process_camera'))
  430. .width('30%')
  431. Image($r('app.media.local_upload'))
  432. .width('30%')
  433. }
  434. .width('30.67%')
  435. .height('33%')
  436. .layoutWeight(1)
  437. .justifyContent(FlexAlign.SpaceAround)
  438. .borderRadius($r('app.float.general_border_radius'))
  439. .borderStyle(BorderStyle.Dashed)
  440. .borderColor($r('app.color.material_collect_border_color'))
  441. .borderWidth(1)
  442. .margin({bottom: 5})
  443. } else {
  444. Row() {
  445. Image(item)
  446. .objectFit(ImageFit.Fill)
  447. .borderRadius($r('app.float.general_border_radius'))
  448. }
  449. .width('30.67%')
  450. .height('33%')
  451. .margin({bottom: 5})
  452. .onClick(()=> {
  453. // todo
  454. })
  455. }
  456. })
  457. Row().width('100%').height('10%')
  458. }
  459. }
  460. .scrollBar(BarState.Off)
  461. }
  462. .width('100%')
  463. .layoutWeight(1)
  464. .justifyContent(FlexAlign.Start)
  465. Row() {
  466. Button('取消')
  467. .fontSize($r('app.float.robot_set_font_size'))
  468. .fontWeight(FontWeight.Medium)
  469. .fontColor($r('app.color.robot_set_card_blue'))
  470. .width('45%')
  471. .height('66.5%')
  472. .borderRadius($r('app.float.robot_set_radius'))
  473. .backgroundColor($r('app.color.robot_set_coord_card_grey'))
  474. .onClick(() => {
  475. // todo
  476. })
  477. Button('报故')
  478. .fontSize($r('app.float.robot_set_font_size'))
  479. .fontWeight(FontWeight.Medium)
  480. .fontColor($r('app.color.general_font_white_color'))
  481. .width('45%')
  482. .height('66.5%')
  483. .borderRadius($r('app.float.robot_set_radius'))
  484. .backgroundColor($r('app.color.robot_set_card_blue'))
  485. .onClick(() => {
  486. // todo
  487. })
  488. }
  489. .justifyContent(FlexAlign.SpaceEvenly)
  490. .alignItems(VerticalAlign.Center)
  491. .height('11%')
  492. .width('100%')
  493. }
  494. .width('50.6%')
  495. .height('100%')
  496. .backgroundColor($r('app.color.page_general_background'))
  497. .justifyContent(FlexAlign.Start)
  498. .borderRadius({topLeft: $r('app.float.general_border_radius'), bottomLeft: $r('app.float.general_border_radius'),})
  499. }
  500. }
  501. @CustomDialog
  502. struct ReportWorkDialog {
  503. @State reportSwitch: number = 1
  504. // 上报的工人
  505. @State reportWorkers: UserInfo[] = [
  506. {userName: '王德发', workHoursRatio: 100}
  507. ]
  508. // 工时总比率(max:100) todo 提交需要校验是否等于 100
  509. @State radioTotal: number = 100
  510. // 弹窗可用比率 = radioTotal - 当前用户的workHoursRatio
  511. @State availableRatio: number = 0
  512. workerRatio: number = 0
  513. // 修改的人员索引
  514. workerIndex: number = -1
  515. @State addWorker: UserInfo = null
  516. // 报工人员选择弹窗
  517. workerAddController: CustomDialogController = new CustomDialogController({
  518. builder: WorkerAddDialog({
  519. reportWorkers: $reportWorkers,
  520. addWorker: $addWorker,
  521. confirm: ()=> {
  522. this.reportWorkers.splice(this.reportWorkers.length - 1, 0, this.addWorker)
  523. this.addWorker = null
  524. }
  525. }),
  526. autoCancel: true,
  527. alignment: DialogAlignment.TopEnd,
  528. // gridCount: 3,
  529. customStyle: true,
  530. })
  531. workHoursRatioController: CustomDialogController = new CustomDialogController({
  532. builder: WorkHoursRatioDialog({
  533. availableRatio: $availableRatio,
  534. workerRatio: this.workerRatio,
  535. confirm: ()=> {
  536. console.log('testTag', '----'+this.availableRatio)
  537. this.reportWorkers[this.workerIndex] = {
  538. userName: this.reportWorkers[this.workerIndex].userName,
  539. workHoursRatio: this.availableRatio
  540. }
  541. this.radioTotal = 0
  542. for (const worker of this.reportWorkers) {
  543. this.radioTotal += worker.workHoursRatio
  544. }
  545. }
  546. }),
  547. autoCancel: true,
  548. alignment: DialogAlignment.TopEnd,
  549. // gridCount: 3,
  550. customStyle: true,
  551. })
  552. controller?: CustomDialogController
  553. cancel: () => void = () => {}
  554. confirm: () => void = () => {}
  555. aboutToAppear() {
  556. this.reportWorkers.push({userName: 'admin', workHoursRatio: 0})
  557. }
  558. build(){
  559. Column() {
  560. Row() {
  561. Text('报工')
  562. .fontSize($r('app.float.title_font_size'))
  563. .fontWeight(FontWeight.Medium)
  564. .fontColor($r('app.color.general_font_color'))
  565. .opacity($r('app.float.general_font_opacity'))
  566. }
  567. .height('12.6%')
  568. .alignItems(VerticalAlign.Bottom)
  569. .padding({ bottom : 10})
  570. // 报工切换按钮
  571. Row() {
  572. Row() {
  573. Stack() {
  574. if (this.reportSwitch === 1) {
  575. Text()
  576. .backgroundColor($r('app.color.general_card_background_color'))
  577. .width('100%')
  578. .height('100%')
  579. .borderRadius($r('app.float.general_border_radius'))
  580. }
  581. Text('单人报工')
  582. .fontSize($r('app.float.set_card_font_size'))
  583. .fontColor($r('app.color.general_font_color'))
  584. .fontWeight(FontWeight.Medium)
  585. .opacity(this.reportSwitch === 1 ? $r('app.float.card_font_select_opacity') : $r('app.float.card_font_default_opacity'))
  586. }
  587. .width('100%')
  588. .height('100%')
  589. }
  590. .onClick(() => {
  591. this.reportSwitch = 1
  592. })
  593. .width('50%')
  594. Row() {
  595. Stack() {
  596. if (this.reportSwitch === 2) {
  597. Text()
  598. .backgroundColor($r('app.color.general_card_background_color'))
  599. .width('100%')
  600. .height('100%')
  601. .borderRadius($r('app.float.general_border_radius'))
  602. }
  603. Text('多人报工')
  604. .fontSize($r('app.float.set_card_font_size'))
  605. .fontColor($r('app.color.general_font_color'))
  606. .fontWeight(FontWeight.Medium)
  607. .opacity(this.reportSwitch === 2 ? $r('app.float.card_font_select_opacity') : $r('app.float.card_font_default_opacity'))
  608. }
  609. .width('100%')
  610. .height('100%')
  611. }
  612. .width('50%')
  613. .onClick(() => {
  614. this.reportSwitch = 2
  615. })
  616. }
  617. .width('66%')
  618. .height('10%')
  619. .borderRadius($r('app.float.general_border_radius'))
  620. .backgroundColor($r('app.color.robot_toward_set_card_background'))
  621. .margin({bottom: 22})
  622. // 报工人员
  623. Row() {
  624. if (this.reportSwitch === 1) {
  625. Column() {
  626. Row(){}.height('16.5%')
  627. Row(){
  628. Image($r('app.media.user'))
  629. .height('100%')
  630. .objectFit(ImageFit.Fill)
  631. }
  632. .height('28.5%')
  633. .width('100%')
  634. .justifyContent(FlexAlign.Center)
  635. Row(){
  636. Text(this.reportWorkers[0].userName)
  637. .fontSize($r('app.float.process_card_middle_font_size'))
  638. .fontWeight(FontWeight.Medium)
  639. .fontColor($r('app.color.general_font_color'))
  640. .opacity($r('app.float.card_font_select_opacity'))
  641. }
  642. .height('14.6%')
  643. Column() {
  644. Text('100%')
  645. .fontSize($r('app.float.process_card_middle_font_size'))
  646. .fontWeight(FontWeight.Medium)
  647. .fontColor($r('app.color.process_card_blue_color'))
  648. Text('用时占比')
  649. .fontSize($r('app.float.process_card_small_font_size'))
  650. .fontWeight(FontWeight.Medium)
  651. .fontColor($r('app.color.general_font_color'))
  652. .opacity($r('app.float.process_step_font_opacity'))
  653. }
  654. .height('27.5%')
  655. .width('75%')
  656. .justifyContent(FlexAlign.Center)
  657. .backgroundColor($r('app.color.robot_set_coord_card_grey'))
  658. .borderRadius($r('app.float.general_border_radius'))
  659. }
  660. .width('48%')
  661. .height('63%')
  662. .backgroundColor($r('app.color.general_card_background_color'))
  663. .borderRadius($r('app.float.general_border_radius'))
  664. } else {
  665. Scroll() {
  666. Flex({ wrap: FlexWrap.Wrap, justifyContent: FlexAlign.SpaceBetween}) {
  667. ForEach(this.reportWorkers, (item: UserInfo, index: number)=>{
  668. if (index === this.reportWorkers.length - 1) {
  669. Column() {
  670. Row() {
  671. Image($r('app.media.user_add'))
  672. .height('100%')
  673. .objectFit(ImageFit.Fill)
  674. }
  675. .height('39%')
  676. }
  677. .width('48%')
  678. .height('63%')
  679. .borderRadius($r('app.float.general_border_radius'))
  680. .justifyContent(FlexAlign.Center)
  681. .borderStyle(BorderStyle.Dashed)
  682. .borderColor($r('app.color.material_collect_border_color'))
  683. .borderWidth(1)
  684. .onClick(()=>{
  685. this.workerAddController.open()
  686. })
  687. } else {
  688. Column() {
  689. Row(){}.height('16.5%')
  690. Row(){
  691. Image($r('app.media.user'))
  692. .height('100%')
  693. .objectFit(ImageFit.Fill)
  694. }
  695. .height('28.5%')
  696. .width('100%')
  697. .justifyContent(FlexAlign.Center)
  698. Row(){
  699. Text(item.userName)
  700. .fontSize($r('app.float.process_card_middle_font_size'))
  701. .fontWeight(FontWeight.Medium)
  702. .fontColor($r('app.color.general_font_color'))
  703. .opacity($r('app.float.card_font_select_opacity'))
  704. }
  705. .height('14.6%')
  706. Column() {
  707. Text(item.workHoursRatio + '%')
  708. .fontSize($r('app.float.process_card_middle_font_size'))
  709. .fontWeight(FontWeight.Medium)
  710. .fontColor($r('app.color.process_card_blue_color'))
  711. Text('用时占比')
  712. .fontSize($r('app.float.process_card_small_font_size'))
  713. .fontWeight(FontWeight.Medium)
  714. .fontColor($r('app.color.general_font_color'))
  715. .opacity($r('app.float.process_step_font_opacity'))
  716. }
  717. .height('27.5%')
  718. .width('75%')
  719. .justifyContent(FlexAlign.Center)
  720. .backgroundColor($r('app.color.robot_set_coord_card_grey'))
  721. .borderRadius($r('app.float.general_border_radius'))
  722. Row() {
  723. Image($r('app.media.subscript_space'))
  724. .height($r('app.float.card_subscript_new_size'))
  725. .width($r('app.float.card_subscript_new_size'))
  726. }
  727. .alignItems(VerticalAlign.Bottom)
  728. .justifyContent(FlexAlign.End)
  729. .width('100%')
  730. .layoutWeight(1)
  731. }
  732. .width('48%')
  733. .height('63%')
  734. .backgroundColor($r('app.color.general_card_background_color'))
  735. .borderRadius($r('app.float.general_border_radius'))
  736. .onClick(()=>{
  737. this.workerIndex = index
  738. this.workerRatio = this.reportWorkers[index].workHoursRatio
  739. this.availableRatio = (100 - this.radioTotal) + this.reportWorkers[index].workHoursRatio
  740. console.log('testTag', '========='+ this.availableRatio)
  741. this.workHoursRatioController.open()
  742. })
  743. }
  744. })
  745. }
  746. }
  747. }
  748. }
  749. .width('66%')
  750. .justifyContent(FlexAlign.Start)
  751. .alignItems(VerticalAlign.Top)
  752. .layoutWeight(1)
  753. // 确认/取消按钮
  754. Row() {
  755. Button('取消')
  756. .fontSize($r('app.float.robot_set_font_size'))
  757. .fontWeight(FontWeight.Medium)
  758. .fontColor($r('app.color.robot_set_card_blue'))
  759. .width('32%')
  760. .height('50%')
  761. .borderRadius($r('app.float.robot_set_radius'))
  762. .backgroundColor($r('app.color.robot_set_coord_card_grey'))
  763. .onClick(() => {
  764. this.controller.close()
  765. this.cancel()
  766. })
  767. Row()
  768. .width('2.5%')
  769. Button('确认报工')
  770. .fontSize($r('app.float.robot_set_font_size'))
  771. .fontWeight(FontWeight.Medium)
  772. .fontColor($r('app.color.general_font_white_color'))
  773. .width('32%')
  774. .height('50%')
  775. .borderRadius($r('app.float.robot_set_radius'))
  776. .backgroundColor($r('app.color.robot_set_card_blue'))
  777. .onClick(() => {
  778. if (this.controller != undefined) {
  779. this.controller.close()
  780. }
  781. })
  782. }
  783. .justifyContent(FlexAlign.Center)
  784. .alignItems(VerticalAlign.Center)
  785. .height('20%')
  786. .width('100%')
  787. }
  788. .width('48%')
  789. .height('74%')
  790. .backgroundColor($r('app.color.page_general_background'))
  791. .borderRadius($r('app.float.general_border_radius'))
  792. }
  793. }
  794. @CustomDialog
  795. struct FaultTypeDialog {
  796. faultTypes: FaultType[]
  797. @Link selectTypes: number[]
  798. selectTemps: number[] = []
  799. aboutToAppear() {
  800. if (this.selectTypes && this.selectTypes.length > 0) {
  801. for (const select of this.selectTypes) {
  802. this.selectTemps.push(select)
  803. }
  804. }
  805. }
  806. controller?: CustomDialogController
  807. cancel: () => void = () => {}
  808. confirm: () => void = () => {}
  809. build(){
  810. Column() {
  811. Row() {
  812. Text('选择缺陷')
  813. .fontSize($r('app.float.title_font_size'))
  814. .fontWeight(FontWeight.Medium)
  815. .fontColor($r('app.color.general_font_color'))
  816. .opacity($r('app.float.general_font_opacity'))
  817. }
  818. .height('15%')
  819. .alignItems(VerticalAlign.Center)
  820. List({ space: 10}) {
  821. ForEach(this.faultTypes, (item: FaultType, index: number)=>{
  822. ListItem() {
  823. Row() {
  824. Text(item.faultName)
  825. .fontSize($r('app.float.process_card_middle_font_size'))
  826. .fontWeight(FontWeight.Medium)
  827. .fontColor($r('app.color.general_font_color'))
  828. .opacity($r('app.float.general_font_opacity'))
  829. Checkbox()
  830. .select(this.selectTemps.includes(index) ? true : false)
  831. .onChange((value: boolean)=>{
  832. if (value) {
  833. this.selectTemps.push(index)
  834. } else {
  835. this.selectTemps = this.selectTemps.filter(function(item) {
  836. return item !== index
  837. });
  838. }
  839. })
  840. }
  841. .backgroundColor($r('app.color.general_card_background_color'))
  842. .width('71%')
  843. .height('14%')
  844. .borderRadius($r('app.float.general_border_radius'))
  845. .justifyContent(FlexAlign.SpaceBetween)
  846. .padding({left: 15, right: 15})
  847. }
  848. })
  849. }
  850. .width('100%')
  851. .layoutWeight(1)
  852. .alignListItem(ListItemAlign.Center)
  853. Row() {
  854. Button('取消')
  855. .fontSize($r('app.float.robot_set_font_size'))
  856. .fontWeight(FontWeight.Medium)
  857. .fontColor($r('app.color.robot_set_card_blue'))
  858. .width('32%')
  859. .height('50%')
  860. .borderRadius($r('app.float.robot_set_radius'))
  861. .backgroundColor($r('app.color.robot_set_coord_card_grey'))
  862. .onClick(() => {
  863. this.controller.close()
  864. this.cancel()
  865. })
  866. Row()
  867. .width('2.5%')
  868. Button('确认')
  869. .fontSize($r('app.float.robot_set_font_size'))
  870. .fontWeight(FontWeight.Medium)
  871. .fontColor($r('app.color.general_font_white_color'))
  872. .width('32%')
  873. .height('50%')
  874. .borderRadius($r('app.float.robot_set_radius'))
  875. .backgroundColor($r('app.color.robot_set_card_blue'))
  876. .onClick(() => {
  877. if (this.controller != undefined) {
  878. this.controller.close()
  879. this.selectTypes = this.selectTemps
  880. this.selectTypes.sort(function(a, b){
  881. return a as number - (b as number);
  882. })
  883. }
  884. })
  885. }
  886. .justifyContent(FlexAlign.Center)
  887. .alignItems(VerticalAlign.Center)
  888. .height('15%')
  889. .width('100%')
  890. }
  891. .width('48%')
  892. .height('74%')
  893. .backgroundColor($r('app.color.page_general_background'))
  894. .borderRadius($r('app.float.general_border_radius'))
  895. }
  896. }
  897. @CustomDialog
  898. struct FaultLevelDialog {
  899. faultLevels: FaultLevel[]
  900. @Link selectLevel: number
  901. @State selectTemp: number = -1
  902. aboutToAppear() {
  903. this.selectTemp = this.selectLevel
  904. }
  905. controller?: CustomDialogController
  906. cancel: () => void = () => {}
  907. confirm: () => void = () => {}
  908. build(){
  909. Column() {
  910. Row() {
  911. Text('选择故障等级')
  912. .fontSize($r('app.float.title_font_size'))
  913. .fontWeight(FontWeight.Medium)
  914. .fontColor($r('app.color.general_font_color'))
  915. .opacity($r('app.float.general_font_opacity'))
  916. }
  917. .height('15%')
  918. .alignItems(VerticalAlign.Center)
  919. List({ space: 10 }) {
  920. ForEach(this.faultLevels, (item: FaultLevel, index: number)=>{
  921. ListItem() {
  922. Row() {
  923. Text(item.levelName)
  924. .fontSize($r('app.float.process_card_middle_font_size'))
  925. .fontWeight(FontWeight.Medium)
  926. .fontColor(this.selectTemp === index ? $r('app.color.general_font_white_color') : $r('app.color.general_font_color'))
  927. .opacity(this.selectTemp === index ? 1 : $r('app.float.general_font_opacity'))
  928. }
  929. .backgroundColor(this.selectTemp === index ? $r('app.color.process_card_blue_color') : $r('app.color.general_card_background_color'))
  930. .width('71%')
  931. .height('20%')
  932. .borderRadius($r('app.float.general_border_radius'))
  933. .justifyContent(FlexAlign.Center)
  934. .padding({left: 15, right: 15})
  935. .onClick(()=>{
  936. this.selectTemp = index
  937. })
  938. }
  939. })
  940. }
  941. .width('100%')
  942. .layoutWeight(1)
  943. .alignListItem(ListItemAlign.Center)
  944. Row() {
  945. Button('取消')
  946. .fontSize($r('app.float.robot_set_font_size'))
  947. .fontWeight(FontWeight.Medium)
  948. .fontColor($r('app.color.robot_set_card_blue'))
  949. .width('32%')
  950. .height('50%')
  951. .borderRadius($r('app.float.robot_set_radius'))
  952. .backgroundColor($r('app.color.robot_set_coord_card_grey'))
  953. .onClick(() => {
  954. this.controller.close()
  955. this.cancel()
  956. })
  957. Row()
  958. .width('2.5%')
  959. Button('确认')
  960. .fontSize($r('app.float.robot_set_font_size'))
  961. .fontWeight(FontWeight.Medium)
  962. .fontColor($r('app.color.general_font_white_color'))
  963. .width('32%')
  964. .height('50%')
  965. .borderRadius($r('app.float.robot_set_radius'))
  966. .backgroundColor($r('app.color.robot_set_card_blue'))
  967. .onClick(() => {
  968. if (this.controller != undefined) {
  969. this.controller.close()
  970. this.selectLevel = this.selectTemp
  971. }
  972. })
  973. }
  974. .justifyContent(FlexAlign.Center)
  975. .alignItems(VerticalAlign.Center)
  976. .height('15%')
  977. .width('100%')
  978. }
  979. .width('48%')
  980. .height('54%')
  981. .backgroundColor($r('app.color.page_general_background'))
  982. .borderRadius($r('app.float.general_border_radius'))
  983. }
  984. }
  985. @CustomDialog
  986. struct WorkerAddDialog {
  987. @Link reportWorkers: UserInfo[]
  988. @Link addWorker: UserInfo
  989. // 所有工人
  990. @State workerArray: UserInfo[] = [
  991. {userName: '王德发'}, {userName: '阿强'}, {userName: '包天'}, {userName: '毕想'}, {userName: '安海兵'},
  992. {userName: '王德发'}, {userName: '阿强'}, {userName: '包天'}, {userName: '毕想'}, {userName: '安海兵'},
  993. {userName: '王德发'}, {userName: '阿强'}, {userName: '包天'}, {userName: '毕想'}, {userName: '安海兵'},
  994. {userName: '王德发'}, {userName: '阿强'}, {userName: '包天'}, {userName: '毕想'}, {userName: '安海兵'},
  995. {userName: '王德发'}, {userName: '阿强'}, {userName: '包天'}, {userName: '毕想'}, {userName: '安海兵'},
  996. {userName: '王德发'}, {userName: '阿强'}, {userName: '包天'}, {userName: '毕想'}, {userName: '安海兵'},
  997. {userName: '王德发'}, {userName: '阿强'}, {userName: '包天'}, {userName: '毕想'}, {userName: '安海兵'},
  998. {userName: '王德发'}, {userName: '阿强'}, {userName: '包天'}, {userName: '毕想'}, {userName: '安海兵'},
  999. ]
  1000. // 字母对应的索引
  1001. @State alphabetMap: HashMap<string, number> = new HashMap();
  1002. @State alphabetArray: string[] = []
  1003. scroller: Scroller = new Scroller()
  1004. controller?: CustomDialogController
  1005. cancel: () => void = () => {}
  1006. confirm: () => void = () => {}
  1007. aboutToAppear() {
  1008. // todo 查询所有工人(过滤掉已选择的)
  1009. for (const worker of this.workerArray) {
  1010. let str = pinyin(worker.userName, { mode: 'surname', toneType: 'none', pattern: 'first'})
  1011. worker.pinyinInitial = str.charAt(0).toUpperCase()
  1012. }
  1013. // 将工人按照姓名字母排序
  1014. this.workerArray = this.workerSort(this.workerArray)
  1015. // 把第一个工人姓名的字母保存到对应的数组中
  1016. this.workerArray.unshift({userName: 'A', pinyinInitial: 'A'})
  1017. this.alphabetMap.set(this.workerArray[0].pinyinInitial, 0)
  1018. this.alphabetArray.push(this.workerArray[0].pinyinInitial)
  1019. let lastInitial: string = this.workerArray[0].pinyinInitial
  1020. for (let index = 0; index < this.workerArray.length; index++) {
  1021. if (this.workerArray[index].pinyinInitial !== lastInitial) {
  1022. lastInitial = this.workerArray[index].pinyinInitial
  1023. // 工人姓名字母发生变化,则在数组中插入 字母 保证渲染
  1024. this.workerArray.splice(index, 0, {userName: lastInitial, pinyinInitial: lastInitial});
  1025. this.alphabetMap.set(lastInitial, index)
  1026. this.alphabetArray.push(lastInitial)
  1027. } else {
  1028. if (index === 0) {
  1029. continue
  1030. }
  1031. this.workerArray[index].pinyinInitial = '@'
  1032. }
  1033. }
  1034. }
  1035. workerSort (arr: UserInfo[]) {
  1036. if (arr.length <= 1) {
  1037. return arr;
  1038. }
  1039. var medianIndex = Math.floor(arr.length / 2); // 找分界值索引
  1040. var medianValue: UserInfo[] = arr.splice(medianIndex, 1); // 把分界值从原数组中取出并删除
  1041. var left: UserInfo[] = []; // 比分界值小的,放左边
  1042. var right: UserInfo[] = []; // 比分界值大的,放右边
  1043. for (let i = 0; i < arr.length; i++) {
  1044. if (arr[i].pinyinInitial < medianValue[0].pinyinInitial) {
  1045. left.push(arr[i])
  1046. } else {
  1047. right.push(arr[i])
  1048. }
  1049. }
  1050. return this.workerSort(left).concat(medianValue, this.workerSort(right)); // 最后进行拼接
  1051. };
  1052. build() {
  1053. Column() {
  1054. Row() {
  1055. Text('参与人员')
  1056. .fontSize($r('app.float.process_card_large_font_size'))
  1057. .fontWeight(FontWeight.Medium)
  1058. .fontColor($r('app.color.general_font_color'))
  1059. .opacity($r('app.float.general_font_opacity'))
  1060. }
  1061. .height('7.5%')
  1062. .alignItems(VerticalAlign.Bottom)
  1063. Row() {
  1064. Row() {
  1065. Row() {
  1066. Image($r('app.media.user'))
  1067. .height('31%')
  1068. }
  1069. .width('8%')
  1070. .justifyContent(FlexAlign.End)
  1071. TextInput({ placeholder: '员工名单搜索' })
  1072. .placeholderColor($r('app.color.text_input_placeholder_font_color'))
  1073. .placeholderFont({size: $r('app.float.robot_set_font_size'), weight: FontWeight.Medium})
  1074. .fontSize($r('app.float.robot_set_font_size'))
  1075. .fontWeight(FontWeight.Medium)
  1076. .fontColor($r('app.color.general_font_color'))
  1077. .textAlign(TextAlign.Start)
  1078. .height('100%')
  1079. .layoutWeight(1)
  1080. .maxLength(100)
  1081. .borderRadius($r('app.float.robot_set_radius'))
  1082. .backgroundColor($r('app.color.general_font_white_color'))
  1083. .onChange((value: string) => {
  1084. })
  1085. .onSubmit(() => {
  1086. })
  1087. }
  1088. .height('66.5%')
  1089. .width('92%')
  1090. .borderRadius($r('app.float.robot_set_radius'))
  1091. .backgroundColor($r('app.color.general_font_white_color'))
  1092. }
  1093. .height('11%')
  1094. Row() {
  1095. List({space:14, scroller: this.scroller}) {
  1096. ForEach(this.workerArray, (item: UserInfo, index: number) => {
  1097. ListItem() {
  1098. if (this.alphabetMap.hasKey(item.pinyinInitial)) {
  1099. Column() {
  1100. Text(item.pinyinInitial)
  1101. .fontSize($r('app.float.process_worker_font_size'))
  1102. .fontWeight(FontWeight.Medium)
  1103. .fontColor($r('app.color.general_font_white_color'))
  1104. .opacity($r('app.float.general_font_opacity'))
  1105. }
  1106. .height('9%')
  1107. .width('26.5%')
  1108. .justifyContent(FlexAlign.Center)
  1109. .backgroundColor($r('app.color.process_card_blue_color'))
  1110. } else {
  1111. Column() {
  1112. Text(item.userName)
  1113. .fontSize($r('app.float.process_card_middle_font_size'))
  1114. .fontWeight(FontWeight.Medium)
  1115. .fontColor($r('app.color.general_font_color'))
  1116. .textAlign(TextAlign.Center)
  1117. }
  1118. .height('9%')
  1119. .onClick(()=>{
  1120. this.addWorker = {
  1121. userName: item.userName,
  1122. workHoursRatio: 0
  1123. }
  1124. this.controller.close()
  1125. this.confirm()
  1126. })
  1127. }
  1128. }
  1129. })
  1130. }
  1131. .width('50%')
  1132. AlphabetIndexer({ arrayValue: this.alphabetArray, selected: 0 })
  1133. .color($r('app.color.process_worker_font_color'))
  1134. .selectedColor($r('app.color.process_worker_font_color')) // 选中项文本颜色
  1135. .selectedBackgroundColor($r('app.color.general_font_white_color')) // 选中项背景颜色
  1136. .usingPopup(false) // 是否显示弹出框
  1137. .onSelect((index: number) => {
  1138. if (this.alphabetMap.hasKey(this.alphabetArray[index])) {
  1139. this.scroller.scrollToIndex(this.alphabetMap.get(this.alphabetArray[index]))
  1140. }
  1141. })
  1142. }
  1143. .width('92%')
  1144. .justifyContent(FlexAlign.SpaceBetween)
  1145. .layoutWeight(1)
  1146. }
  1147. .width('48%')
  1148. .height('100%')
  1149. .backgroundColor($r('app.color.page_general_background'))
  1150. .borderRadius($r('app.float.general_border_radius'))
  1151. }
  1152. }
  1153. @CustomDialog
  1154. struct WorkHoursRatioDialog {
  1155. @Link availableRatio: number
  1156. workerRatio: number
  1157. // 选择项(10%为一个间隔)
  1158. selectItems: string[] = []
  1159. private select: number = 1
  1160. controller?: CustomDialogController
  1161. cancel: () => void = () => {}
  1162. confirm: () => void = () => {}
  1163. aboutToAppear() {
  1164. console.log('testTag', JSON.stringify(this.availableRatio))
  1165. let radio = 10
  1166. while (radio <= this.availableRatio) {
  1167. this.selectItems.push(radio + '%')
  1168. if (this.workerRatio && this.workerRatio === radio) {
  1169. this.select = this.selectItems.length - 1
  1170. }
  1171. radio += 10
  1172. }
  1173. console.log('testTag', JSON.stringify(this.workerRatio))
  1174. }
  1175. build() {
  1176. Column() {
  1177. Row() {
  1178. Text('用时占比')
  1179. .fontSize($r('app.float.process_card_large_font_size'))
  1180. .fontWeight(FontWeight.Medium)
  1181. .fontColor($r('app.color.general_font_color'))
  1182. .opacity($r('app.float.general_font_opacity'))
  1183. }
  1184. .height('16%')
  1185. Row() {
  1186. TextPicker({ range: this.selectItems, selected: this.select})
  1187. .onChange((value: string, index: number) => {
  1188. this.availableRatio = Number.parseInt(value)
  1189. })
  1190. .width('40%')
  1191. .height('100%')
  1192. .backgroundColor($r('app.color.bottom_bar_background'))
  1193. .borderImage({source:$r('app.media.text_picker_frame'), fill: true})
  1194. }
  1195. .width('100%')
  1196. .layoutWeight(1)
  1197. .justifyContent(FlexAlign.Center)
  1198. Row() {
  1199. Button('取消')
  1200. .fontSize($r('app.float.robot_set_font_size'))
  1201. .fontWeight(FontWeight.Medium)
  1202. .fontColor($r('app.color.robot_set_card_blue'))
  1203. .width('32%')
  1204. .height('50%')
  1205. .borderRadius($r('app.float.robot_set_radius'))
  1206. .backgroundColor($r('app.color.robot_set_coord_card_grey'))
  1207. .onClick(() => {
  1208. this.controller.close()
  1209. this.cancel()
  1210. })
  1211. Row()
  1212. .width('2.5%')
  1213. Button('确认')
  1214. .fontSize($r('app.float.robot_set_font_size'))
  1215. .fontWeight(FontWeight.Medium)
  1216. .fontColor($r('app.color.general_font_white_color'))
  1217. .width('32%')
  1218. .height('50%')
  1219. .borderRadius($r('app.float.robot_set_radius'))
  1220. .backgroundColor($r('app.color.robot_set_card_blue'))
  1221. .onClick(() => {
  1222. if (this.controller != undefined) {
  1223. this.controller.close()
  1224. this.confirm()
  1225. }
  1226. })
  1227. }
  1228. .justifyContent(FlexAlign.Center)
  1229. .height('24%')
  1230. .width('100%')
  1231. }
  1232. .width('48%')
  1233. .height('62%')
  1234. .backgroundColor($r('app.color.page_general_background'))
  1235. .borderRadius($r('app.float.general_border_radius'))
  1236. }
  1237. }
  1238. class FaultType {
  1239. id?: number
  1240. faultName?: string
  1241. }
  1242. class FaultLevel {
  1243. id?: number
  1244. levelName?: string
  1245. }
  1246. class UserInfo {
  1247. id?: number
  1248. userName?: string
  1249. // 工时占比
  1250. workHoursRatio?: number
  1251. // 姓氏的拼音首字母
  1252. pinyinInitial?: string
  1253. }