Index.ets 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  1. import {componentLocation} from '../model/ComponentLocation'
  2. import { TitleStateComp } from '../common/component/TitleStateComp';
  3. import { BottomOperateComp } from '../common/component/BottomOperateComp';
  4. import router from '@ohos.router'
  5. import { TaskComp } from '../common/component/TaskComp'
  6. import { Warehousing}from '../common/component/Warehousing'
  7. import { SmartFactoryCard }from '../common/component/SmartFactoryCard'
  8. import CommonConstants from '../common/constants/CommonConstants'
  9. import UniversalCard from '../model/UniversalCard'
  10. @CustomDialog
  11. struct login {
  12. @Link textValue: string
  13. @Link inputValue: string
  14. controller: CustomDialogController
  15. cancel: () => void
  16. confirm: () => void
  17. build() {
  18. Column() {
  19. Text('退出登录')
  20. .textAlign(TextAlign.Center)
  21. .fontColor('#e6000000')
  22. .fontSize(px2vp(53))
  23. .fontWeight(FontWeight.Medium)
  24. .width('100%')
  25. .height('30%')
  26. Text('是否返回登录页?')
  27. .textAlign(TextAlign.Center)
  28. .width('100%')
  29. .height('30%')
  30. Row({space:10}){
  31. Text('取消')
  32. .width('40%')
  33. .borderRadius(21)
  34. .height('70%')
  35. .textAlign(TextAlign.Center)
  36. .backgroundColor('#0f000000')
  37. .fontColor('#0A59F7')
  38. .onClick(()=>{
  39. this.controller.close()
  40. })
  41. Text('确认')
  42. .width('40%')
  43. .height('70%')
  44. .borderRadius(21)
  45. .backgroundColor('#0A59F7')
  46. .textAlign(TextAlign.Center)
  47. .fontColor('#ffff')
  48. .onClick(()=>{
  49. this.controller.close()
  50. })
  51. }
  52. .width('100%')
  53. .justifyContent(FlexAlign.Center)
  54. .height('30%')
  55. }.width('25%')
  56. .height('20%')
  57. .borderRadius(15)
  58. .backgroundColor('#ffff')
  59. }
  60. }
  61. @CustomDialog
  62. struct confirmPopup {
  63. @Link cardServices:UniversalCard[]
  64. controller: CustomDialogController
  65. cancel: () => void
  66. confirm: () => void
  67. @Link x: number
  68. @Link y: number
  69. @Link index:number
  70. build(){
  71. Column(){
  72. Column(){
  73. Row(){
  74. Image($r('app.media.card'))
  75. .width(px2vp(50))
  76. .height(px2vp(50))
  77. Text('卡片服务')
  78. .padding({left:10})
  79. .margin(px2vp(5))
  80. .width('100%')
  81. .fontWeight(FontWeight.Medium)
  82. .fontSize(px2vp(38))
  83. .textAlign(TextAlign.Start)
  84. .onClick(()=>{
  85. this.controller.close()
  86. this.cardServices[this.index]= {
  87. id:this.cardServices[this.index].id,
  88. userId:this.cardServices[this.index].userId,
  89. cardType:this.cardServices[this.index].cardType,
  90. cardStatus:1,
  91. cardSort:this.cardServices[this.index].cardSort,
  92. }
  93. })
  94. }.width('100%')
  95. .height('80%')
  96. .padding({left:10})
  97. .borderRadius(px2vp(15))
  98. .backgroundColor($r('app.color.general_font_white_color'))
  99. Divider()
  100. .width('80%')
  101. }
  102. .margin({bottom:5})
  103. .borderRadius(px2vp(15))
  104. .height('20%')
  105. .width('120%')
  106. .backgroundColor($r('app.color.general_font_white_color'))
  107. Image(this.index===1?$r("app.media.processImages"):$r('app.media.storage'))
  108. .width(px2vp(220))
  109. .height(px2vp(220))
  110. .borderRadius(15)
  111. }
  112. .alignItems(HorizontalAlign.Start)
  113. .width('350px')
  114. .height('600px')
  115. .offset({x:this.x+20+'px', y:this.y-340+'px'})
  116. }
  117. }
  118. @CustomDialog
  119. struct shutdown {
  120. @Link shutdownTransparency:number
  121. @Link textValue: string
  122. @Link inputValue: string
  123. controller: CustomDialogController
  124. cancel: () => void
  125. confirm: () => void
  126. build() {
  127. Column() {
  128. Row(){
  129. Image($r('app.media.restart'))
  130. .width(px2vp(107))
  131. .height(px2vp(107))
  132. .onClick(()=>{
  133. this.shutdownTransparency=0
  134. this.controller.close()
  135. })
  136. Blank()
  137. Image($r('app.media.shutdown'))
  138. .width(px2vp(107))
  139. .height(px2vp(107))
  140. .onClick(()=>{
  141. this.shutdownTransparency=0
  142. this.controller.close()
  143. })
  144. }.width('100%')
  145. .height('50%')
  146. Row(){
  147. Text('重启')
  148. .fontWeight(FontWeight.Medium)
  149. .fontSize(px2vp(27))
  150. .width(px2vp(107))
  151. .height(px2vp(107))
  152. .textAlign(TextAlign.Center)
  153. .fontColor('#FFFFFF')
  154. Blank()
  155. Text('关机')
  156. .fontWeight(FontWeight.Medium)
  157. .fontSize(px2vp(27))
  158. .width(px2vp(107))
  159. .textAlign(TextAlign.Center)
  160. .height(px2vp(107))
  161. .fontColor('#FFFFFF')
  162. }.width('100%')
  163. .height('30%')
  164. }.width('20%')
  165. .height('20%')
  166. .borderRadius(15)
  167. }
  168. }
  169. @Entry
  170. @Component
  171. struct Index {
  172. @State index:number=0
  173. @State x:number=0
  174. @State y:number=0
  175. @State cardServices:UniversalCard[] = CommonConstants.Card_DATA
  176. @State SmartFactoryCardDelete:number=0
  177. @State SmartFactoryDelete:number=0
  178. @State SmartFactoryCarLongPressDelete:number=0
  179. @State storageCardDelete:number=0
  180. @State smartWarehouseCard:number=0
  181. @State avatarFrame:boolean=false
  182. @State deleteConfirmation:number=0
  183. @State longPressDelete:number=0
  184. scroller: Scroller = new Scroller()
  185. @State shutdownTransparency:number=0
  186. @State YanSe: number = 0
  187. @State carswitch:number=0
  188. private isHomePage: boolean = true
  189. @State textValue: string = ''
  190. @State inputValue: string = ''
  191. loginDialogController: CustomDialogController = new CustomDialogController({
  192. builder:login({
  193. textValue: $textValue,
  194. inputValue: $inputValue,
  195. }),
  196. alignment: DialogAlignment.Center,
  197. autoCancel:false,
  198. customStyle:true
  199. })
  200. shutdownDialogController: CustomDialogController = new CustomDialogController({
  201. builder:shutdown({
  202. textValue: $textValue,
  203. inputValue: $inputValue,
  204. shutdownTransparency:this.shutdownTransparency
  205. }),
  206. alignment: DialogAlignment.Center,
  207. autoCancel:false,
  208. customStyle:true
  209. })
  210. confirmPopupDialogController: CustomDialogController = new CustomDialogController({
  211. builder: confirmPopup({
  212. x:this.x,
  213. y:this.y,
  214. index:this.index,
  215. cardServices:this.cardServices
  216. }
  217. ),
  218. alignment: DialogAlignment.TopStart,
  219. autoCancel:true,
  220. customStyle:true,
  221. })
  222. build() {
  223. Stack(){
  224. Row() {
  225. Column() {
  226. TitleStateComp({ isHomePage: this.isHomePage })
  227. .onClick(()=>{
  228. this.avatarFrame=!this.avatarFrame
  229. })
  230. Row() {
  231. Flex({ wrap: FlexWrap.Wrap }) {
  232. if (this.cardServices[1].cardStatus===1){
  233. Stack(){
  234. Column(){
  235. TaskComp({isHomePage: this.isHomePage})
  236. Text('生产操作')
  237. .fontSize(px2vp(27))
  238. .margin({top:5})
  239. .fontWeight(FontWeight.Medium)
  240. .fontColor($r('app.color.robot_set_card_white'))
  241. }
  242. .height('40%')
  243. .width('32%')
  244. .gesture(
  245. LongPressGesture({ repeat: false })
  246. .onActionEnd(() => {
  247. this.deleteConfirmation=1
  248. })
  249. )
  250. if (this.deleteConfirmation===1){
  251. Row(){
  252. Text('取消')
  253. .fontWeight(FontWeight.Medium)
  254. .fontSize(px2vp(27))
  255. .textAlign(TextAlign.Center)
  256. .width('20%')
  257. .height('20%')
  258. .margin(10)
  259. .borderRadius(px2vp(21))
  260. .fontColor($r('app.color.robot_set_card_blue'))
  261. .backgroundColor($r('app.color.general_font_white_color'))
  262. .onClick(()=>{
  263. this.deleteConfirmation=0
  264. })
  265. Text('删除')
  266. .fontWeight(FontWeight.Medium)
  267. .fontSize(px2vp(27))
  268. .width('20%')
  269. .margin(10)
  270. .fontColor($r('app.color.general_font_white_color'))
  271. .borderRadius(px2vp(21))
  272. .height('20%')
  273. .textAlign(TextAlign.Center)
  274. .backgroundColor( $r('app.color.robot_set_card_blue'))
  275. .onClick(()=>{
  276. this.deleteConfirmation=0
  277. this.cardServices[1]= {
  278. id:this.cardServices[1].id,
  279. userId:this.cardServices[1].userId,
  280. cardType:this.cardServices[1].cardType,
  281. cardStatus:2,
  282. cardSort:this.cardServices[1].cardSort,
  283. }
  284. })
  285. }
  286. .justifyContent(FlexAlign.Center)
  287. .height('40%')
  288. .width('32%')
  289. }
  290. }
  291. }
  292. if (this.cardServices[0].cardStatus===1){
  293. Stack(){
  294. Column(){
  295. Warehousing()
  296. Text('智能仓储')
  297. .margin({top:5})
  298. .fontSize(px2vp(27))
  299. .fontWeight(FontWeight.Medium)
  300. .fontColor($r('app.color.robot_set_card_white'))
  301. }
  302. .height('40%')
  303. .width('32%')
  304. .margin({left:10})
  305. .onClick(()=>{
  306. router.pushUrl({
  307. url:'pages/Storage'
  308. })
  309. })
  310. .gesture(
  311. LongPressGesture({ repeat: false })
  312. .onActionEnd(() => {
  313. this.smartWarehouseCard=1
  314. })
  315. )
  316. if (this.smartWarehouseCard===1){
  317. Row(){
  318. Text('取消')
  319. .fontWeight(FontWeight.Medium)
  320. .fontSize(px2vp(27))
  321. .textAlign(TextAlign.Center)
  322. .width('20%')
  323. .height('20%')
  324. .margin(10)
  325. .borderRadius(px2vp(21))
  326. .fontColor($r('app.color.robot_set_card_blue'))
  327. .backgroundColor($r('app.color.general_font_white_color'))
  328. .onClick(()=>{
  329. this.smartWarehouseCard=0
  330. })
  331. Text('删除')
  332. .fontWeight(FontWeight.Medium)
  333. .fontSize(px2vp(27))
  334. .width('20%')
  335. .margin(10)
  336. .fontColor($r('app.color.general_font_white_color'))
  337. .borderRadius(px2vp(21))
  338. .height('20%')
  339. .textAlign(TextAlign.Center)
  340. .backgroundColor( $r('app.color.robot_set_card_blue'))
  341. .onClick(()=>{
  342. this.smartWarehouseCard=0
  343. this.cardServices[0]= {
  344. id:this.cardServices[0].id,
  345. userId:this.cardServices[0].userId,
  346. cardType:this.cardServices[0].cardType,
  347. cardStatus:2,
  348. cardSort:this.cardServices[0].cardSort,
  349. }
  350. })
  351. }
  352. .justifyContent(FlexAlign.Center)
  353. .height('40%')
  354. .width('32%')
  355. }
  356. }
  357. }
  358. if (this.SmartFactoryCardDelete===0){
  359. Stack(){
  360. Column(){
  361. SmartFactoryCard()
  362. Text('智汇工厂')
  363. .margin({top:5})
  364. .fontSize(px2vp(27))
  365. .fontWeight(FontWeight.Medium)
  366. .fontColor($r('app.color.robot_set_card_white'))
  367. }
  368. .height('40%')
  369. .width('32%')
  370. .margin({left:10})
  371. .onClick(()=>{
  372. router.pushUrl({
  373. url:'pages/SmartFactory'
  374. })
  375. })
  376. .gesture(
  377. LongPressGesture({ repeat: false })
  378. .onActionEnd(() => {
  379. this.SmartFactoryCarLongPressDelete=1
  380. })
  381. )
  382. if (this.SmartFactoryCarLongPressDelete===1){
  383. Row(){
  384. Text('取消')
  385. .fontWeight(FontWeight.Medium)
  386. .fontSize(px2vp(27))
  387. .textAlign(TextAlign.Center)
  388. .width('20%')
  389. .height('20%')
  390. .margin(10)
  391. .borderRadius(px2vp(21))
  392. .fontColor($r('app.color.robot_set_card_blue'))
  393. .backgroundColor($r('app.color.general_font_white_color'))
  394. .onClick(()=>{
  395. this.SmartFactoryCarLongPressDelete=0
  396. })
  397. Text('删除')
  398. .fontWeight(FontWeight.Medium)
  399. .fontSize(px2vp(27))
  400. .width('20%')
  401. .margin(10)
  402. .fontColor($r('app.color.general_font_white_color'))
  403. .borderRadius(px2vp(21))
  404. .height('20%')
  405. .textAlign(TextAlign.Center)
  406. .backgroundColor( $r('app.color.robot_set_card_blue'))
  407. .onClick(()=>{
  408. this.SmartFactoryCarLongPressDelete=0
  409. this.SmartFactoryCardDelete=1
  410. })
  411. }
  412. .justifyContent(FlexAlign.Center)
  413. .height('40%')
  414. .width('32%')
  415. }
  416. }
  417. }
  418. }
  419. .width('100%')
  420. .height('100%')
  421. }
  422. .justifyContent(FlexAlign.Center)
  423. .width('100%')
  424. .height('68%')
  425. Row({ space: 10 }) {
  426. Text().width('1%')
  427. Column({ space: 10 }) {
  428. Image($r("app.media.shezhi"))
  429. .width('60%')
  430. .height('60%')
  431. .margin({top:5})
  432. Text('设置')
  433. .width('100%')
  434. .textAlign(TextAlign.Center)
  435. .fontSize(16)
  436. .fontColor('#ffff')
  437. }
  438. .width('10%')
  439. .justifyContent(FlexAlign.Center)
  440. .backdropBlur(13)
  441. .height('90%')
  442. .borderRadius(15)
  443. .backgroundColor('#4d000000')
  444. .onClick(() => {
  445. router.pushUrl({
  446. url: 'pages/SetPage'
  447. })
  448. })
  449. Column({ space: 10 }) {
  450. Image($r("app.media.storage"))
  451. .width('60%')
  452. .height('60%')
  453. .margin({top:5})
  454. Text('智能仓储')
  455. .width('100%')
  456. .textAlign(TextAlign.Center)
  457. .fontSize(16)
  458. .fontColor('#ffff')
  459. }
  460. .width('10%')
  461. .justifyContent(FlexAlign.Center)
  462. .height('90%')
  463. .borderRadius(15)
  464. .backgroundColor('#4d000000')
  465. .id('smartWarehousing')
  466. .onClick(() => {
  467. router.pushUrl({
  468. url: 'pages/Storage'
  469. })
  470. })
  471. .gesture(
  472. LongPressGesture({ repeat: false })
  473. .onActionEnd(() => {
  474. let rect = componentLocation.getComponentRect('smartWarehousing')
  475. let touchPoint: TouchObject = {
  476. id: 1,
  477. x: rect.left, // 组件中心点x坐标
  478. y:rect.bottom, // 组件中心点y坐标
  479. type: TouchType.Down,
  480. screenX: rect.left + (rect.right - rect.left) / 2, // 组件中心点x坐标
  481. screenY: rect.left + (rect.right - rect.left) / 2, // 组件中心点y坐标
  482. }
  483. this.x=touchPoint.x
  484. this.y=touchPoint.y
  485. this.index=0
  486. this.confirmPopupDialogController.open()
  487. })
  488. )
  489. Column({ space: 10 }) {
  490. Image($r('app.media.jiqiren'))
  491. .width('60%')
  492. .height('60%')
  493. .margin({top:5})
  494. Text('机器人调试')
  495. .width('100%')
  496. .textAlign(TextAlign.Center)
  497. .fontSize(16)
  498. .fontColor('#ffff')
  499. }
  500. .width('10%')
  501. .justifyContent(FlexAlign.Center)
  502. .height('90%')
  503. .borderRadius(15)
  504. .backgroundColor('#4d000000')
  505. .onClick(() => {
  506. router.pushUrl({
  507. url: 'pages/RobotDebug'
  508. })
  509. })
  510. Column({ space: 10 }) {
  511. Image($r("app.media.processImages"))
  512. .width('60%')
  513. .height('60%')
  514. .margin({top:5})
  515. Text('工序操作')
  516. .width('100%')
  517. .textAlign(TextAlign.Center)
  518. .fontSize(16)
  519. .fontColor('#ffff')
  520. }
  521. .width('10%')
  522. .justifyContent(FlexAlign.Center)
  523. .height('90%')
  524. .borderRadius(15)
  525. .id('workingProcedure')
  526. .backgroundColor('#4d000000')
  527. .onClick(() => {
  528. router.pushUrl({
  529. url: 'pages/process/ProcessHome'
  530. })
  531. })
  532. .gesture(
  533. LongPressGesture({ repeat: false })
  534. .onActionEnd(() => {
  535. let rect = componentLocation.getComponentRect('workingProcedure')
  536. let touchPoint: TouchObject = {
  537. id: 1,
  538. x: rect.left, // 组件中心点x坐标
  539. y:rect.bottom, // 组件中心点y坐标
  540. type: TouchType.Down,
  541. screenX: rect.left + (rect.right - rect.left) / 2, // 组件中心点x坐标
  542. screenY: rect.left + (rect.right - rect.left) / 2, // 组件中心点y坐标
  543. }
  544. this.x=touchPoint.x
  545. this.y=touchPoint.y
  546. this.index=1
  547. this.confirmPopupDialogController.open()
  548. })
  549. )
  550. Column({ space: 10 }) {
  551. Image($r('app.media.baobiao'))
  552. .width('60%')
  553. .height('60%')
  554. .margin({top:5})
  555. Text('统计报表')
  556. .width('100%')
  557. .textAlign(TextAlign.Center)
  558. .fontSize(16)
  559. .fontColor('#ffff')
  560. }
  561. .width('10%')
  562. .justifyContent(FlexAlign.Center)
  563. .height('90%')
  564. .borderRadius(15)
  565. .backgroundColor('#4d000000')
  566. }
  567. .width('100%')
  568. .height('16%')
  569. BottomOperateComp({ isHomePage: this.isHomePage,
  570. }
  571. )
  572. }
  573. .backgroundImage($r('app.media.BG'))
  574. .backgroundImageSize({ width: '100%', height: '100%' })
  575. .width('100%')
  576. .height('100%')
  577. }
  578. .height('100%')
  579. .width('100%')
  580. if (this.avatarFrame){
  581. Column(){
  582. Text('个人设置')
  583. .height('33%')
  584. .fontSize(px2vp(32))
  585. .fontWeight(FontWeight.Medium)
  586. .fontColor('#e6000000')
  587. Divider()
  588. Text('退出登录')
  589. .height('33%')
  590. .fontSize(px2vp(32))
  591. .fontWeight(FontWeight.Medium)
  592. .fontColor('#e6000000')
  593. .onClick(()=>{
  594. this.loginDialogController.open()
  595. })
  596. Divider()
  597. Text('开关/重启')
  598. .height('33%')
  599. .fontSize(px2vp(32))
  600. .fontWeight(FontWeight.Medium)
  601. .fontColor('#e6000000')
  602. .onClick(()=>{
  603. this.shutdownTransparency=1
  604. this.shutdownDialogController.open()
  605. this.avatarFrame=!this.avatarFrame
  606. })
  607. }.width('15%')
  608. .height('25%')
  609. .backgroundColor('#ffff')
  610. .margin({top:'4%',right:'1%'})
  611. .borderRadius(21)
  612. }
  613. if (this.shutdownTransparency===1){
  614. Column(){
  615. }.width('100%')
  616. .backgroundColor('#cc000000')
  617. .height('100%')
  618. //.opacity(0.8)
  619. .blur(30)
  620. }
  621. }
  622. .alignContent(Alignment.TopEnd)
  623. .height('100%')
  624. .width('100%')
  625. }
  626. // 动画效果
  627. pageTransition() {
  628. // 设置1ms是为了使延时生效
  629. PageTransitionEnter({ duration: 1, curve: Curve.Linear, delay: 400 })
  630. .scale({
  631. x: 0,
  632. y: 0,
  633. z: 0,
  634. centerX: '50%',
  635. centerY: '50%'
  636. })
  637. PageTransitionExit({ duration: 0, curve: Curve.Linear })
  638. }
  639. }