SmartFactory.ets 56 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815
  1. import router from '@ohos.router'
  2. import { Staging } from '../view/Staging'
  3. import { ProcessArea } from '../view/ProcessArea'
  4. import CommonConstants from '../common/constants/CommonConstants'
  5. import UserAuthModel from '../model/database/UserAuthModel'
  6. import curves from '@ohos.curves';
  7. import process from '@ohos.process'
  8. import connection from '@ohos.net.connection'
  9. import data from '@ohos.telephony.data';
  10. import UserInfo from '../model/UserInfo'
  11. import { WorkstationInfo } from '../pages/LoginPage'
  12. //import formHost from '@ohos.app.form.formHost';
  13. import media from '@ohos.multimedia.media';
  14. import fs from '@ohos.file.fs';
  15. import common from '@ohos.app.ability.common';
  16. import { DeviceDialog } from '../common/DeviceDialog';
  17. import { RemoteDeviceModel, BUNDLE_NAME } from '../model/RemoteDeviceModel';
  18. import deviceManager from '@ohos.distributedDeviceManager';
  19. import { KvStoreModel } from '../model/KvStoreModel';
  20. import Want from '@ohos.app.ability.Want';
  21. import NoticeInfo from '../model/NoticeInfo';
  22. import { taskclass } from '../common/util/request/StorageRequestInstance'
  23. import StorageRequest from '../common/util/request/StorageRequest'
  24. import { TaskComp } from '../common/component/TaskComp'
  25. import UniversalCard from '../model/UniversalCard'
  26. const TAG: string = 'testTag'
  27. const DATA_CHANGE: string = 'dataChange'
  28. const DATA_CHANGE1: number = 0
  29. const EXIT: string = 'exit'
  30. export class hardwareList {
  31. name?: string
  32. state?: string
  33. text?: string
  34. type?: Resource
  35. open?: Resource
  36. colse?: Resource
  37. select?: boolean
  38. temp?: number
  39. }
  40. @Entry
  41. @Component
  42. struct SmartFactory {
  43. @State completeNum: number | undefined = 0
  44. @State planNum: number | undefined = 0
  45. //视图选择
  46. @State viewSelection: number = 0
  47. @State WorkstationInfo: WorkstationInfo = {}
  48. @State userInfo: UserInfo = {}
  49. @State listPosition: number = 0; // 0代表滚动到List顶部,1代表中间值,2代表滚动到List底部。
  50. private scrollerForScroll: Scroller = new Scroller()
  51. @State dragIndex: number = 0
  52. @State open: number = 0
  53. //注释掉的是假数据,实际更具请求硬件获取
  54. @State private items: Array<hardwareList> = [
  55. {
  56. name: '三色灯',
  57. state: '关',
  58. text: '装配工位001',
  59. type: $r('app.media.sansedeng'),
  60. open: $r('app.media.open'),
  61. colse: $r('app.media.colse'),
  62. select: true,
  63. temp: 1
  64. } as hardwareList,
  65. {
  66. name: '扫码枪',
  67. state: '开',
  68. text: '装配工位001',
  69. type: $r('app.media.saomaqiang'),
  70. open: $r('app.media.open'),
  71. colse: $r('app.media.colse'),
  72. select: true,
  73. temp: 2
  74. } as hardwareList,
  75. {
  76. name: '电能表',
  77. state: '关',
  78. text: '装配工位001',
  79. type: $r('app.media.diannengbiao'),
  80. open: $r('app.media.open'),
  81. colse: $r('app.media.colse'),
  82. select: true,
  83. temp: 3
  84. } as hardwareList,
  85. {
  86. name: '万用表',
  87. state: '开',
  88. text: '装配工位001',
  89. type: $r('app.media.multimeter'),
  90. open: $r('app.media.open'),
  91. colse: $r('app.media.colse'),
  92. select: true,
  93. temp: 6
  94. } as hardwareList,
  95. {
  96. name: 'RFID工位读卡器',
  97. state: '关',
  98. text: '装配工位001',
  99. type: $r('app.media.dukaqi'),
  100. open: $r('app.media.open'),
  101. colse: $r('app.media.colse'),
  102. select: true,
  103. temp: 7
  104. } as hardwareList,
  105. {
  106. name: '程控电源',
  107. state: '开',
  108. text: '装配工位001',
  109. type: $r('app.media.chengkongdianyuan'),
  110. open: $r('app.media.open'),
  111. colse: $r('app.media.colse'),
  112. select: true,
  113. temp: 8
  114. } as hardwareList,
  115. {
  116. name: '数控电烙铁',
  117. state: '开',
  118. text: '装配工位001',
  119. type: $r('app.media.shukongdian'),
  120. open: $r('app.media.open'),
  121. colse: $r('app.media.colse'),
  122. select: true,
  123. temp: 9
  124. } as hardwareList,
  125. {
  126. name: '电动螺丝刀',
  127. state: '开',
  128. text: '装配工位001',
  129. type: $r('app.media.diandongluosidao'),
  130. open: $r('app.media.open'),
  131. colse: $r('app.media.colse'),
  132. select: true,
  133. temp: 10
  134. } as hardwareList,
  135. {
  136. name: '照明灯',
  137. state: '开',
  138. text: '装配工位001',
  139. type: $r('app.media.zhaomingdeng'),
  140. open: $r('app.media.open'),
  141. colse: $r('app.media.colse'),
  142. select: true,
  143. temp: 11
  144. } as hardwareList,
  145. {
  146. name: '镊子',
  147. state: '开',
  148. text: '装配工位001',
  149. type: $r('app.media.tweezers'),
  150. open: $r('app.media.open'),
  151. colse: $r('app.media.colse'),
  152. select: true,
  153. temp: 12
  154. } as hardwareList,
  155. {
  156. name: '扳手',
  157. state: '开',
  158. text: '装配工位001',
  159. type: $r('app.media.wrench'),
  160. open: $r('app.media.open'),
  161. colse: $r('app.media.colse'),
  162. select: true,
  163. temp: 13
  164. } as hardwareList,
  165. {
  166. name: '放大镜',
  167. state: '开',
  168. text: '装配工位001',
  169. type: $r('app.media.magnifier'),
  170. open: $r('app.media.open'),
  171. colse: $r('app.media.colse'),
  172. select: true,
  173. temp: 14
  174. } as hardwareList,
  175. {
  176. name: '焊烟净化器',
  177. state: '开',
  178. text: '装配工位001',
  179. type: $r('app.media.Weldingfumepurifier'),
  180. open: $r('app.media.open'),
  181. colse: $r('app.media.colse'),
  182. select: true,
  183. temp: 15
  184. } as hardwareList,
  185. {
  186. name: '螺丝刀-十字',
  187. state: '开',
  188. text: '装配工位001',
  189. type: $r('app.media.screwdriver'),
  190. open: $r('app.media.open'),
  191. colse: $r('app.media.colse'),
  192. select: true,
  193. temp: 16
  194. } as hardwareList,
  195. ]
  196. private scrollerForList: Scroller = new Scroller()
  197. scroller: Scroller = new Scroller()
  198. @State colsetimeID: number = 0
  199. @State colsetimeID1: number = 0
  200. @State processvalue: number = 50
  201. @State text: number = 0
  202. @State success: boolean = true
  203. @State click: number = 0
  204. @State trigger: number = 0
  205. @State donghua1: number = 0
  206. @State index: number = 0
  207. @State state?: string = ''
  208. @State text1?: string = ''
  209. @State open1: Resource | undefined = undefined
  210. @State colse: Resource | undefined = undefined
  211. @State temp?: number = 0
  212. @State swtich: undefined | boolean = true
  213. @State DeviceName: undefined | string = ''
  214. @State DeviceImage: Resource | undefined = undefined
  215. @State isHomePage: boolean = true
  216. controller: TextClockController = new TextClockController()
  217. @State isClick: boolean = false
  218. @State textValue: string = ''
  219. @State inputValue: string = ''
  220. @State translateX: number = 0;
  221. private jumpWithSpeed(speed: number) {
  222. this.translateX = -1;
  223. animateTo({ duration: 2000, curve: curves.springCurve(speed, 1, 10, 1) }, () => {
  224. // 以指定初速度进行x方向的平移的弹簧动画
  225. this.translateX = 0;
  226. })
  227. }
  228. onCancel() {
  229. console.info('onCancel')
  230. }
  231. onAccept() {
  232. console.info(' onAccept')
  233. }
  234. existApp() {
  235. console.info(' existApp')
  236. }
  237. ////弹框控制器
  238. dialogController1: CustomDialogController = new CustomDialogController({
  239. builder: Device({
  240. index: this.index,
  241. items: this.items,
  242. temp: this.temp,
  243. open1: this.open1,
  244. colse: this.colse,
  245. state: this.state,
  246. text1: this.text1,
  247. swtich: this.swtich,
  248. DeviceImage: this.DeviceImage,
  249. DeviceName: this.DeviceName,
  250. textValue: $textValue,
  251. inputValue: $inputValue,
  252. }),
  253. // gridCount: 3,
  254. cancel: this.existApp,
  255. //autoCancel: true,
  256. alignment: DialogAlignment.CenterEnd,
  257. //justifyContent:
  258. //offset: { dx: 0, dy: -20 },
  259. customStyle: true,
  260. })
  261. Devicepop_up: CustomDialogController = new CustomDialogController({
  262. builder: Devicepop_up({
  263. timeoutID: this.colsetimeID,
  264. timeoutID1: this.colsetimeID1,
  265. success: this.success,
  266. inputValue: $inputValue,
  267. }),
  268. // gridCount: 3,
  269. cancel: this.existApp,
  270. //autoCancel: true,
  271. alignment: DialogAlignment.Bottom,
  272. //justifyContent:
  273. offset: { dx: 0, dy: -80 },
  274. autoCancel: false,
  275. customStyle: true,
  276. })
  277. Devicepop_up1: CustomDialogController = new CustomDialogController({
  278. builder: Devicepop_up1({
  279. inputValue: $inputValue,
  280. }),
  281. // gridCount: 3,
  282. cancel: this.existApp,
  283. //autoCancel: true,
  284. alignment: DialogAlignment.Bottom,
  285. //justifyContent:
  286. offset: { dx: 0, dy: -80 },
  287. customStyle: true,
  288. })
  289. @Builder
  290. pixelMapBuilder(index: number) { //拖拽过程样式
  291. Row() {
  292. Column() {
  293. Text(this.items[index].name)
  294. Row() {
  295. Text(this.items[index].state + '|' + this.items[index].text)
  296. }
  297. .height('30%')
  298. Row() {
  299. Image(this.items[index].type)
  300. .width('50%')
  301. .height('100%')
  302. Image($r('app.media.kaiguan'))
  303. .width('100px')
  304. .height('100px')
  305. }.height('50%')
  306. }
  307. .width('100%')
  308. .padding(10)
  309. .borderRadius(10)
  310. .alignItems(HorizontalAlign.Start)
  311. // .justifyContent(FlexAlign.Center)
  312. .height('100%')
  313. }
  314. .width('16%')
  315. .height('20%')
  316. .padding({ left: 10 })
  317. .borderRadius(10)
  318. .backgroundColor('#99ffffff')
  319. }
  320. changeIndex(index1: number, index2: number) {
  321. console.debug('347589', index1 + 'OK' + index2) //交换数组中的位置
  322. // [this.items[index1], this.items[index2]] = [this.items[index2], this.items[index1]];
  323. const temp = this.items[index1];
  324. // this.items[index1]=this.items[index2]
  325. this.items[index1] = {
  326. name: this.items[index2].name,
  327. type: this.items[index2].type,
  328. temp: this.items[index2].temp,
  329. state: this.items[index2].state,
  330. text: this.items[index2].text,
  331. open: this.items[index2].open,
  332. colse: this.items[index2].colse,
  333. select: this.items[index2].select,
  334. }
  335. this.items[index2] = {
  336. name: temp.name,
  337. type: temp.type,
  338. temp: temp.temp,
  339. state: temp.state,
  340. text: temp.text,
  341. select: temp.select,
  342. open: temp.open,
  343. colse: temp.colse,
  344. }
  345. }
  346. dialogController: CustomDialogController = new CustomDialogController({
  347. builder: NoticeDialog({}),
  348. alignment: DialogAlignment.Center,
  349. customStyle: true,
  350. cancel: () => {
  351. this.isClick = !this.isClick
  352. }
  353. })
  354. @State deviceDialogWidth: number = 0
  355. @State click1: number = 0;
  356. @State @Watch('dataChange') message: string = 'Hello World';
  357. @State inputMsg: string = '';
  358. @State isDistributed: boolean = false
  359. @StorageLink('deviceList') deviceList: Array<deviceManager.DeviceBasicInfo> = []
  360. @State selectedIndex: number | undefined = -1
  361. private remoteDeviceModel: RemoteDeviceModel = new RemoteDeviceModel()
  362. private kvStoreModel: KvStoreModel = new KvStoreModel()
  363. // private dialogController: CustomDialogController | null = null
  364. onSelectedIndexChange = async (index: number | undefined) => {
  365. console.info(TAG, `selectedIndexChange`)
  366. this.selectedIndex = index
  367. this.selectDevice()
  368. }
  369. // aboutToAppear(){
  370. // this.showDeviceDialog()
  371. // }
  372. //任务统计
  373. task = async (): Promise<taskclass> => {
  374. let obj: taskclass = {} //尽量用{}来定义空对象,如果用null在get属性的时候可能会出错
  375. let res: taskclass = await StorageRequest.get("/api/v1/statistics/todayInfo")
  376. obj = res as taskclass
  377. console.info("testTag", ' -----------------' + JSON.stringify(obj));
  378. console.debug('await StorageRequest.get 如果是Promise.reject 就不会执行await后面的代码', obj)
  379. return Promise.resolve(obj)
  380. }
  381. aboutToDisappear() {
  382. console.info(TAG, `index disappear`)
  383. this.kvStoreModel.deleteKvStore()
  384. }
  385. startAbilityCallBack = (key: string) => {
  386. console.info(TAG, `startAbilityCallBack ${key}`)
  387. if (DATA_CHANGE === key) {
  388. this.kvStoreModel.put(DATA_CHANGE, this.message)
  389. }
  390. if (EXIT === key) {
  391. this.kvStoreModel.put(DATA_CHANGE, EXIT)
  392. }
  393. }
  394. selectDevice() {
  395. console.info(TAG, `start ability ......`)
  396. this.isDistributed = true
  397. if (this.selectedIndex !== undefined && (this.remoteDeviceModel === null || this.remoteDeviceModel.discoverList.length <= 0)) {
  398. console.info(TAG, `continue unauthed device: ${JSON.stringify(this.deviceList)}`)
  399. this.startAbility(this.deviceList[this.selectedIndex].networkId as string)
  400. this.clearSelectState()
  401. return
  402. }
  403. console.info(TAG, `start ability1, needAuth:`)
  404. if (this.selectedIndex !== undefined) {
  405. console.log(TAG, '------------' + JSON.stringify(this.deviceList[this.selectedIndex]));
  406. this.remoteDeviceModel.authenticateDevice(this.deviceList[this.selectedIndex], () => {
  407. console.info(TAG, `auth and online finished`);
  408. if (this.remoteDeviceModel !== null && this.remoteDeviceModel.deviceList !== null && this.selectedIndex !== undefined) {
  409. for (let i = 0; i < this.remoteDeviceModel.deviceList!.length; i++) {
  410. if (this.remoteDeviceModel.deviceList![i].deviceName === this.deviceList[this.selectedIndex].deviceName) {
  411. this.startAbility(this.remoteDeviceModel.deviceList![i].networkId);
  412. }
  413. }
  414. }
  415. })
  416. }
  417. console.info(TAG, `start ability2 ......`)
  418. this.clearSelectState()
  419. }
  420. clearSelectState() {
  421. this.deviceList = []
  422. if (this.dialogController !== null) {
  423. this.dialogController.close()
  424. }
  425. console.info(TAG, `cancelDialog`)
  426. if (this.remoteDeviceModel === undefined) {
  427. return
  428. }
  429. this.remoteDeviceModel.unregisterDeviceListCallback()
  430. }
  431. async startAbility(deviceId: string | undefined) {
  432. console.debug(TAG, `startAbility deviceId: ${deviceId}`)
  433. let context = getContext(this) as common.UIAbilityContext
  434. // console.log("获取当前页面"+choicePages.choicePages?.toString())
  435. let want: Want = {
  436. bundleName: BUNDLE_NAME,
  437. abilityName: 'EntryAbility',
  438. // abilityName: choicePages.choicePages===2?'':'firstAbility',
  439. deviceId: deviceId,
  440. parameters: {
  441. isRemote: 'isRemote'
  442. }
  443. }
  444. context.startAbility(want).then((data) => {
  445. console.info(TAG, `start ability finished: ${JSON.stringify(data)}`)
  446. this.startAbilityCallBack(DATA_CHANGE)
  447. })
  448. }
  449. dataChange() {
  450. console.info(TAG, `dataChange, message = ${this.message},`)
  451. this.kvStoreModel.put(DATA_CHANGE1.toString(), this.click.toString())
  452. this.kvStoreModel.put(DATA_CHANGE, this.message,)
  453. }
  454. showDeviceDialog() {
  455. this.deviceList = []
  456. // 注册监听回调,发现设备或查找到已认证设备会弹窗显示
  457. this.remoteDeviceModel.registerDeviceListCallback(() => {
  458. this.deviceList = []
  459. let deviceTempList = this.remoteDeviceModel.discoverList.length > 0 ? this.remoteDeviceModel.discoverList : this.remoteDeviceModel.deviceList;
  460. if (deviceTempList !== null) {
  461. for (let i = 0; i < deviceTempList!.length; i++) {
  462. console.debug(TAG, `device ${i}/${deviceTempList!.length} deviceId= ${deviceTempList![i].deviceId},
  463. deviceName= ${deviceTempList![i].deviceName}, deviceType= ${deviceTempList![i].deviceType}`);
  464. if (deviceTempList !== null) {
  465. this.deviceList.push({
  466. deviceId: deviceTempList![i].deviceId,
  467. deviceName: deviceTempList![i].deviceName,
  468. deviceType: deviceTempList![i].deviceType,
  469. networkId: deviceTempList![i].networkId,
  470. })
  471. AppStorage.set('deviceList', this.deviceList)
  472. }
  473. }
  474. }
  475. })
  476. if (this.dialogController === null) {
  477. this.dialogController = new CustomDialogController({
  478. builder: DeviceDialog({
  479. selectedIndex: this.selectedIndex,
  480. onSelectedIndexChange: this.onSelectedIndexChange
  481. }),
  482. cancel: () => {
  483. this.clearSelectState()
  484. },
  485. autoCancel: true,
  486. alignment: DialogAlignment.Center,
  487. customStyle: false
  488. })
  489. }
  490. if (this.dialogController !== null) {
  491. this.dialogController.open()
  492. }
  493. }
  494. // 消息弹窗控制器
  495. noticeDialogController: CustomDialogController = new CustomDialogController({
  496. builder: NoticeDialog({}),
  497. alignment: DialogAlignment.Center,
  498. customStyle: true,
  499. cancel: () => {
  500. this.isClick = !this.isClick
  501. }
  502. })
  503. AvatarController: CustomDialogController = new CustomDialogController({
  504. builder: AvatarClick({}),
  505. alignment: DialogAlignment.TopEnd,
  506. customStyle: true,
  507. offset: { dx: 0, dy: -25 },
  508. cancel: () => {
  509. this.isClick = !this.isClick
  510. }
  511. })
  512. IconController: CustomDialogController = new CustomDialogController({
  513. builder: iconList({}),
  514. alignment: DialogAlignment.Center,
  515. customStyle: true,
  516. offset: { dx: 0, dy: 0 },
  517. cancel: () => {
  518. this.isClick = !this.isClick
  519. }
  520. })
  521. build() {
  522. Stack() {
  523. Column() {
  524. Column() {
  525. Stack() {
  526. Text()
  527. .width('100%')
  528. .height('100%')
  529. Row() {
  530. Row() {
  531. Image($r('app.media.back_white'))
  532. .height(px2vp(48))
  533. .width(px2vp(48))
  534. .onClick(async () => {
  535. // let userInfo = await UserAuthModel.getLast()
  536. // if (userInfo?.stationDictValue === '5') {
  537. // router.pushUrl({
  538. // url: 'pages/Warehousing'
  539. // })
  540. // } else if (userInfo?.stationDictValue === '6') {
  541. // router.pushUrl({
  542. // url: 'pages/OutboundStation'
  543. // })
  544. // } else {
  545. // router.pushUrl({
  546. // url: 'pages/process/ProcessHome'
  547. // })
  548. // }
  549. router.back()
  550. })
  551. }.width('40%')
  552. Blank()
  553. Row() {
  554. Text('场景视图')
  555. .width('10%')
  556. .fontSize($r('app.float.fontSize_24'))
  557. .fontColor('#FFFFFF')
  558. .fontWeight(FontWeight.Medium)
  559. .textAlign(TextAlign.Center)
  560. .height('100%')
  561. .backgroundColor(this.viewSelection === 0 ? $r('app.color.black_30') : '')
  562. .onClick(() => {
  563. this.viewSelection = 0
  564. })
  565. Text('列表视图')
  566. .width('10%')
  567. .fontSize($r('app.float.fontSize_24'))
  568. .fontColor('#FFFFFF')
  569. .fontWeight(FontWeight.Medium)
  570. .textAlign(TextAlign.Center)
  571. .backgroundColor(this.viewSelection === 1 ? $r('app.color.black_30') : '')
  572. .height('100%')
  573. .onClick(() => {
  574. this.viewSelection = 1
  575. })
  576. }
  577. Row() {
  578. }
  579. //
  580. // Blank()
  581. // Row() {
  582. // Row() {
  583. // Image($r("app.media.gongda_white"))
  584. // .height(px2vp(48))
  585. // .width(px2vp(48))
  586. // .onClick(() => {
  587. // router.pushUrl({
  588. // url: 'pages/SmartFactory'
  589. // })
  590. // })
  591. // }
  592. // .height('100%')
  593. // .width('7.2%')
  594. // .justifyContent(FlexAlign.Center)
  595. //
  596. // Row() {
  597. // Image($r('app.media.notice_white'))
  598. // .height(px2vp(48))
  599. // .width(px2vp(48))
  600. // }
  601. // .height('100%')
  602. // .width('7.2%')
  603. // .justifyContent(FlexAlign.Center)
  604. // .onClick(() => {
  605. // router.pushUrl({
  606. // url: "pages/OutboundStation"
  607. // })
  608. // this.noticeDialogController.open()
  609. // })
  610. //
  611. // Row() {
  612. // Image($r("app.media.box_edit_white"))
  613. // .height(px2vp(48))
  614. // .width(px2vp(48))
  615. // }
  616. // .height('100%')
  617. // .width('7.2%')
  618. // .justifyContent(FlexAlign.Center)
  619. // .onClick(() => {
  620. // router.pushUrl({
  621. // // url:'pages/Storage'
  622. // // url:'pages/yyyyy'
  623. // url: 'pages/RfidAllocation'
  624. // })
  625. // })
  626. //
  627. // Row({ space: 2 }) {
  628. // Column() {
  629. // Text(CommonConstants.USER_NAME)
  630. // .fontSize($r('app.float.fontSize_20'))
  631. // .fontColor($r('app.color.general_font_white_color'))
  632. // .opacity($r('app.float.general_font_opacity'))
  633. // .fontWeight(FontWeight.Medium)
  634. // .width('95%')
  635. // .maxLines(1)
  636. // Progress({ value: this.completeNum!, total: this.planNum!, type: ProgressType.Linear })
  637. // .width('95%')
  638. // .backgroundColor($r('app.color.grey_100'))
  639. // .style({ strokeWidth: 5 })
  640. // Text('任务进度:' + ((this.completeNum!) / (this.planNum!)) * 100 + '%')
  641. // .fontSize($r('app.float.fontSize_14'))
  642. // .fontColor($r('app.color.general_font_white_color'))
  643. // .opacity($r('app.float.card_font_default_opacity'))
  644. // .fontWeight(FontWeight.Medium)
  645. // .maxLines(1)
  646. // }
  647. // .justifyContent(FlexAlign.Center)
  648. // .height(px2vp(105))
  649. // .width('58%')
  650. //
  651. // Row() {
  652. // Image(CommonConstants.USER_AVATAR && CommonConstants.USER_AVATAR.length > 0 ? CommonConstants.FILE_URL_PREFIX + CommonConstants.USER_AVATAR : $r('app.media.user_white'))
  653. // .width(px2vp(48))
  654. // .height(px2vp(48))
  655. //
  656. // }
  657. // .layoutWeight(1)
  658. // }
  659. // .width('22%')
  660. // .height('90%')
  661. // .alignItems(VerticalAlign.Center)
  662. // .justifyContent(FlexAlign.SpaceEvenly)
  663. // .onClick(() => {
  664. // this.AvatarController.open()
  665. // })
  666. // }
  667. // .width('40%')
  668. // .height('90%')
  669. // .alignItems(VerticalAlign.Center)
  670. // .justifyContent(FlexAlign.End)
  671. }
  672. .width('100%')
  673. .height('100%')
  674. .alignItems(VerticalAlign.Center)
  675. .justifyContent(FlexAlign.Center)
  676. }
  677. .width('100%')
  678. .height('8%')
  679. if (this.viewSelection === 1) {
  680. if (this.trigger === 0) {
  681. Column() {
  682. Select([{ value: '操作员1' },
  683. { value: '操作员2' },
  684. { value: '操作员3' },
  685. { value: '操作员4' },
  686. { value: '操作员5' }])
  687. .selected(2)
  688. .height('80px')
  689. .value('操作员2')//.fontColor('#ff8d1f1f')
  690. // .selectedOptionBgColor('#ffb81b1b')
  691. // .selectedOptionFontColor('#ffa11cc6')
  692. // .optionFontColor('#ff3972b0')
  693. //.optionBgColor('#ff77e946')
  694. .backgroundColor('#00000000')
  695. .font({ size: '51px', weight: 500 })
  696. .fontColor('#ffff')
  697. .selectedOptionFont({ size: 16, weight: 400 })
  698. .optionFont({ size: 16, weight: 400 })
  699. .onSelect((index: number) => {
  700. console.info('Select:' + index)
  701. })
  702. Text(this.items.length + "个设备")
  703. .width('100%')
  704. .opacity(0.6)
  705. .fontSize('32px')
  706. .fontColor('#FFFFFF')
  707. .fontWeight(FontWeight.Medium)
  708. .textAlign(TextAlign.Start)
  709. }.height('10%')
  710. .width('100%')
  711. .alignItems(HorizontalAlign.Start)
  712. } else if (this.trigger === 1) {
  713. Column()
  714. .height('1%')
  715. .width('100%')
  716. .alignItems(HorizontalAlign.Start)
  717. }
  718. Row({ space: 100 }) {
  719. Text('设备')
  720. .fontSize($r('app.float.fontSize_24'))
  721. .fontColor('#ffff')
  722. .fontWeight(FontWeight.Medium)
  723. .onClick(() => {
  724. this.click = 0
  725. })
  726. .height('100%')
  727. Text('工作台')
  728. .fontSize($r('app.float.fontSize_24'))
  729. .fontColor('#ffff')
  730. .fontWeight(FontWeight.Medium)
  731. .onClick(() => {
  732. this.click = 1
  733. })
  734. .height('100%')
  735. Column() {
  736. Text('工艺区域')
  737. .fontSize($r('app.float.fontSize_24'))
  738. .fontColor('#ffff')
  739. .fontWeight(FontWeight.Medium)
  740. .onClick(() => {
  741. this.click = 2
  742. })
  743. .height('100%')
  744. }
  745. .justifyContent(FlexAlign.Center)
  746. .height('100%')
  747. }.width('100%')
  748. .height("10%")
  749. if (this.click === 0) {
  750. Column() {
  751. // Scroll(this.scroller){
  752. Grid(this.scroller) {
  753. ForEach(this.items, (item: hardwareList, index) => {
  754. GridItem() {
  755. // if (item.select){
  756. Row() {
  757. Column() {
  758. Text(item.name)
  759. .fontColor('#FFFFFF')
  760. .fontWeight(FontWeight.Medium)
  761. .fontSize($r('app.float.fontSize_24'))
  762. Text(item.state + '|' + item.text)
  763. .fontColor('#FFFFFF')
  764. .opacity(0.6)
  765. .fontWeight(FontWeight.Regular)
  766. .fontSize($r('app.float.fontSize_20'))
  767. Row() {
  768. Image(item.type)
  769. .width(px2vp(120))
  770. .height(px2vp(120))
  771. .margin({ top: 40 })
  772. Blank()
  773. Image(item.select === true ? item.open : item.colse)
  774. .width(px2vp(80))
  775. .height(px2vp(80))
  776. .margin({ top: 40 })
  777. .onClick(() => {
  778. // if (item.select){
  779. item.select = !item.select
  780. // }
  781. // else {
  782. // item.select=true
  783. // }
  784. this.items[index] = {
  785. name: this.items[index].name,
  786. type: this.items[index].type,
  787. temp: this.items[index].temp,
  788. state: this.items[index].state,
  789. text: this.items[index].text,
  790. open: this.items[index].open,
  791. colse: this.items[index].colse,
  792. select: this.items[index].select,
  793. }
  794. })
  795. }.height('50%')
  796. .width('100%')
  797. .padding({ left: 10 })
  798. }
  799. .width('100%')
  800. .padding(10)
  801. .borderRadius(10)
  802. .alignItems(HorizontalAlign.Start)
  803. // .justifyContent(FlexAlign.Center)
  804. .height('100%')
  805. }
  806. .width('100%')
  807. .height('30%')
  808. .padding({ left: 10 })
  809. .borderRadius(10)
  810. .backgroundColor('#66ffffff')
  811. .onClick(() => {
  812. this.index = index
  813. this.swtich = item.select
  814. this.DeviceName = item.name
  815. this.DeviceImage = item.type
  816. this.temp = item.temp
  817. this.open1 = item.open
  818. this.colse = item.colse
  819. this.state = item.state
  820. this.text1 = item.text
  821. this.dialogController1.open()
  822. })
  823. // }
  824. // else {
  825. // Row(){
  826. // Column(){
  827. // Text(item.name)
  828. // Row(){
  829. // Text(item.state+'|'+item.text)
  830. // }
  831. // .height('30%')
  832. // Row(){
  833. // Image(item.type)
  834. // .width('150px')
  835. // .height('150px')
  836. // Blank()
  837. // Image(item.colse)
  838. // .width('100px')
  839. // .height('100px')
  840. // .onClick(()=>{
  841. // item.select=true
  842. // this.items[index]= {
  843. // name: this.items[index].name,
  844. // type: this.items[index].type,
  845. // temp: this.items[index].temp,
  846. // state: this.items[index].state,
  847. // text: this.items[index].text,
  848. // open: this.items[index].open,
  849. // colse: this.items[index].colse,
  850. // select: this.items[index].select,
  851. // select1: this.items[index].select1
  852. // }
  853. // })
  854. //
  855. //
  856. // }.height('50%')
  857. // .width('100%')
  858. // .padding({left:10})
  859. // }.width('100%')
  860. // .padding(10)
  861. // .borderRadius(10)
  862. // .alignItems(HorizontalAlign.Start)
  863. // // .justifyContent(FlexAlign.Center)
  864. // .height('100%')
  865. // }.width('100%')
  866. // .height('35%')
  867. // .padding({ left:10 })
  868. // .borderRadius(10)
  869. // .backgroundColor('#66ffffff')
  870. // .onClick(()=>{
  871. // this.DeviceName=item.name
  872. // this.DeviceImage=item.type
  873. // this.dialogController.open()
  874. // })
  875. // }
  876. }
  877. })
  878. }
  879. .columnsTemplate('1fr 1fr 1fr 1fr 1fr 1fr')
  880. .columnsGap(10)
  881. .rowsGap(10)
  882. .onScrollIndex((first: number) => {
  883. console.info(first.toString())
  884. })
  885. .width('100%')
  886. .height('100%')
  887. .editMode(true) //设置Grid是否进入编辑模式,进入编辑模式可以拖拽Grid组件内部GridItem
  888. .supportAnimation(true) //设置Grid是否开启拖拽补位动画
  889. .onItemDragStart((event: ItemDragInfo, itemIndex: number) => { //第一次拖拽此事件绑定的组件时,触发回调。
  890. this.text = itemIndex
  891. return this.pixelMapBuilder(itemIndex) //设置拖拽过程中显示的图片。
  892. })
  893. .onItemDrop((event: ItemDragInfo, itemIndex: number, insertIndex: number, isSuccess: boolean) => { //绑定此事件的组件可作为拖拽释放目标,当在本组件范围内停止拖拽行为时,触发回调。
  894. // isSuccess=false时,说明drop的位置在grid外部;insertIndex > length时,说明有新增元素的事件发生
  895. if (!isSuccess || insertIndex >= this.items.length) {
  896. return
  897. }
  898. console.info('beixiang' + itemIndex + '', insertIndex + '') //itemIndex拖拽起始位置,insertIndex拖拽插入位置
  899. this.changeIndex(itemIndex, insertIndex)
  900. })
  901. // }
  902. // .onScrollEdge(()=>{
  903. // this.trigger=1
  904. // })
  905. .height('80%')
  906. .width('100%')
  907. .padding({ top: 10 })
  908. }
  909. } else if (this.click === 1) {
  910. Staging()
  911. } else if (this.click === 2) {
  912. ProcessArea()
  913. }
  914. } else if (this.viewSelection === 0) {
  915. Stack() {
  916. Image($r('app.media.Scene_graph'))
  917. .width(px2vp(1874))
  918. .height(px2vp(659))
  919. .borderRadius(px2vp(16))
  920. Flex() {
  921. Image($r('app.media.List_icon'))
  922. .width(px2vp(120))
  923. .height(px2vp(80))
  924. .margin({ left: px2vp(445), top: px2vp(289) })
  925. .onClick(() => {
  926. this.IconController.open()
  927. })
  928. Image($r('app.media.List_icon'))
  929. .width(px2vp(120))
  930. .height(px2vp(80))
  931. .margin({ left: px2vp(6), top: px2vp(408) })
  932. .onClick(() => {
  933. this.IconController.open()
  934. })
  935. Image($r('app.media.List_icon'))
  936. .width(px2vp(120))
  937. .height(px2vp(80))
  938. .margin({ left: px2vp(80), top: px2vp(287) })
  939. .onClick(() => {
  940. this.IconController.open()
  941. })
  942. Image($r('app.media.List_icon'))
  943. .width(px2vp(120))
  944. .height(px2vp(80))
  945. .margin({ left: px2vp(140), top: px2vp(287) })
  946. .onClick(() => {
  947. this.IconController.open()
  948. })
  949. }.width(px2vp(1874))
  950. .height(px2vp(659))
  951. }
  952. .width(px2vp(1874))
  953. .alignContent(Alignment.Center)
  954. .height(px2vp(900))
  955. .margin({ top: 10 })
  956. .borderRadius(px2vp(16))
  957. .backgroundColor($r('app.color.black_100'))
  958. }
  959. }.width('100%').height('92%')
  960. .padding(20)
  961. // Stack() {
  962. // Image($r('app.media.bottombg'))
  963. // .width('100%')
  964. // .height('100%')
  965. // Text()
  966. // .width('100%')
  967. // .height('100%')
  968. // .backgroundImage($r('app.media.bottombg'))
  969. // .backgroundImageSize({width:'100%',height:'100%'})
  970. // }
  971. // .width('100%')
  972. // .height('8%')
  973. // .backgroundImage($r('app.media.bottombg'))
  974. // .backgroundImageSize({width:'100%',height:'100%'})
  975. }
  976. .backgroundImage($r('app.media.zhihuigc'))
  977. .backgroundImageSize({ width: '100%', height: '100%' })
  978. .width('100%')
  979. .height('100%')
  980. if (this.donghua1 === 1) {
  981. Column() {
  982. Image($r('app.media.LOGO_donghua'))
  983. .width('100%')
  984. .height('100%')
  985. }
  986. .width('8%')
  987. .height('40%')
  988. } else if (this.donghua1 === 2) {
  989. }
  990. }
  991. .width('100%')
  992. .height('100%')
  993. .alignContent(Alignment.Bottom)
  994. }
  995. }
  996. @CustomDialog
  997. struct iconList {
  998. controller: CustomDialogController
  999. build() {
  1000. Column() {
  1001. Text('#2装配工位001')
  1002. .width('100%')
  1003. .fontSize($r('app.float.fontSize_24'))
  1004. .fontColor('#FFFFFF')
  1005. .fontWeight(FontWeight.Medium)
  1006. .textAlign(TextAlign.Center)
  1007. Row() {
  1008. Column() {
  1009. Text('螺丝刀-十字')
  1010. .fontSize($r('app.float.fontSize_24'))
  1011. .fontColor('#FFFFFF')
  1012. .fontWeight(FontWeight.Medium)
  1013. .textAlign(TextAlign.Center)
  1014. Text('1#装配工位')
  1015. .fontSize($r('app.float.fontSize_20'))
  1016. .fontColor('#FFFFFF')
  1017. .fontWeight(FontWeight.Regular)
  1018. .textAlign(TextAlign.Center)
  1019. Image($r('app.media.screwdriver'))
  1020. .width(px2vp(80))
  1021. .height(px2vp(80))
  1022. }
  1023. .width(px2vp(200))
  1024. .height(px2vp(200))
  1025. .margin({ right: px2vp(20) })
  1026. .borderRadius(px2vp(16))
  1027. .backgroundColor('#ff9f9b9b')
  1028. Column() {
  1029. Text('镊子')
  1030. .fontSize($r('app.float.fontSize_24'))
  1031. .fontColor('#FFFFFF')
  1032. .fontWeight(FontWeight.Medium)
  1033. .textAlign(TextAlign.Center)
  1034. Text('2#装配工位')
  1035. .fontSize($r('app.float.fontSize_20'))
  1036. .fontColor('#FFFFFF')
  1037. .fontWeight(FontWeight.Regular)
  1038. .textAlign(TextAlign.Center)
  1039. Image($r('app.media.tweezers'))
  1040. .width(px2vp(80))
  1041. .height(px2vp(80))
  1042. }.width(px2vp(200))
  1043. .height(px2vp(200))
  1044. .borderRadius(px2vp(16))
  1045. .backgroundColor('#ff9f9b9b')
  1046. }
  1047. .width(px2vp(420))
  1048. .height(px2vp(200))
  1049. .margin({ bottom: px2vp(20), top: px2vp(40) })
  1050. Row() {
  1051. Column() {
  1052. Text('扳手')
  1053. .fontSize($r('app.float.fontSize_24'))
  1054. .fontColor('#FFFFFF')
  1055. .fontWeight(FontWeight.Medium)
  1056. .textAlign(TextAlign.Center)
  1057. Text('3#装配工位')
  1058. .fontSize($r('app.float.fontSize_20'))
  1059. .fontColor('#FFFFFF')
  1060. .fontWeight(FontWeight.Regular)
  1061. .textAlign(TextAlign.Center)
  1062. Image($r('app.media.magnifier'))
  1063. .width(px2vp(80))
  1064. .height(px2vp(80))
  1065. }
  1066. .width(px2vp(200))
  1067. .height(px2vp(200))
  1068. .margin({ right: px2vp(20) })
  1069. .borderRadius(px2vp(16))
  1070. .backgroundColor('#ff9f9b9b')
  1071. Column() {
  1072. Text('放大镜')
  1073. .fontSize($r('app.float.fontSize_24'))
  1074. .fontColor('#FFFFFF')
  1075. .fontWeight(FontWeight.Medium)
  1076. .textAlign(TextAlign.Center)
  1077. Text('1#装配工位')
  1078. .fontSize($r('app.float.fontSize_20'))
  1079. .fontColor('#FFFFFF')
  1080. .fontWeight(FontWeight.Regular)
  1081. .textAlign(TextAlign.Center)
  1082. Image($r('app.media.magnifier'))
  1083. .width(px2vp(80))
  1084. .height(px2vp(80))
  1085. }.width(px2vp(200))
  1086. .height(px2vp(200))
  1087. .borderRadius(px2vp(16))
  1088. .backgroundColor('#ff9f9b9b')
  1089. }
  1090. .width(px2vp(420))
  1091. .height(px2vp(200))
  1092. }
  1093. .width(px2vp(500))
  1094. .height(px2vp(550))
  1095. .borderRadius(px2vp(16))
  1096. .alignItems(HorizontalAlign.Center)
  1097. .backgroundColor($r('app.color.black_60'))
  1098. }
  1099. }
  1100. //弹窗组件
  1101. @CustomDialog
  1102. struct NoticeDialog {
  1103. controller: CustomDialogController
  1104. Notices: NoticeInfo[] = []
  1105. build() {
  1106. Column({ space: 10 }) {
  1107. Row() {
  1108. Text('通知')
  1109. .fontSize($r('app.float.fontSize_24'))
  1110. .fontWeight(FontWeight.Medium)
  1111. .fontColor($r('app.color.general_font_color'))
  1112. .opacity($r('app.float.general_font_opacity'))
  1113. }
  1114. Row() {
  1115. List() {
  1116. ForEach(this.Notices, (item: NoticeInfo) => {
  1117. ListItem() {
  1118. Row() {
  1119. Text(item.Notice)
  1120. .fontSize($r('app.float.fontSize_24'))
  1121. .fontColor($r('app.color.general_font_color'))
  1122. .opacity($r('app.float.general_font_opacity'))
  1123. Text(item.NoticeDate)
  1124. .fontSize($r('app.float.fontSize_24'))
  1125. .fontColor($r('app.color.general_font_color'))
  1126. .opacity($r('app.float.card_font_default_opacity'))
  1127. }
  1128. .justifyContent(FlexAlign.SpaceBetween)
  1129. .width('100%')
  1130. }
  1131. })
  1132. }
  1133. }
  1134. .width('90%')
  1135. .height('80%')
  1136. .alignItems(VerticalAlign.Top)
  1137. .borderRadius($r('app.float.notice_size'))
  1138. .borderWidth($r('app.float.general_border_width'))
  1139. .borderColor($r('app.color.general_border_color'))
  1140. }
  1141. .width('45%')
  1142. .height('70%')
  1143. .justifyContent(FlexAlign.Center)
  1144. .backgroundColor($r('app.color.page_general_background'))
  1145. .borderRadius($r('app.float.notice_size'))
  1146. }
  1147. }
  1148. //头像点击弹窗
  1149. @CustomDialog
  1150. struct AvatarClick {
  1151. @State shutdownTransparency: number = 0
  1152. private cardType: number = 0
  1153. @State cardSorting: number = 0
  1154. @State cardServices: UniversalCard[] = [{}]
  1155. @State x: number = 0
  1156. @State y: number = 0
  1157. @State textValue: string = ''
  1158. @State inputValue: string = ''
  1159. @State avatarFrame: boolean = false
  1160. loginDialogController: CustomDialogController = new CustomDialogController({
  1161. builder: login({
  1162. textValue: $textValue,
  1163. inputValue: $inputValue,
  1164. }),
  1165. alignment: DialogAlignment.Center,
  1166. autoCancel: false,
  1167. customStyle: true
  1168. })
  1169. shutdownDialogController: CustomDialogController = new CustomDialogController({
  1170. builder: shutdown({
  1171. textValue: $textValue,
  1172. inputValue: $inputValue,
  1173. shutdownTransparency: this.shutdownTransparency
  1174. }),
  1175. alignment: DialogAlignment.Center,
  1176. autoCancel: false,
  1177. customStyle: true
  1178. })
  1179. controller: CustomDialogController
  1180. build() {
  1181. Column() {
  1182. Text('个人设置')
  1183. .height('33%')
  1184. .fontSize(px2vp(32))
  1185. .fontWeight(FontWeight.Medium)
  1186. .fontColor('#e6000000')
  1187. .onClick(() => {
  1188. router.pushUrl({
  1189. url: 'pages/SetPage'
  1190. })
  1191. })
  1192. Divider()
  1193. Text('退出登录')
  1194. .height('33%')
  1195. .fontSize(px2vp(32))
  1196. .fontWeight(FontWeight.Medium)
  1197. .fontColor('#e6000000')
  1198. .onClick(() => {
  1199. this.loginDialogController.open()
  1200. this.controller
  1201. })
  1202. Divider()
  1203. Text('开关/重启')
  1204. .height('33%')
  1205. .fontSize(px2vp(32))
  1206. .fontWeight(FontWeight.Medium)
  1207. .fontColor('#e6000000')
  1208. .onClick(() => {
  1209. this.shutdownTransparency = 1
  1210. this.shutdownDialogController.open()
  1211. this.avatarFrame = !this.avatarFrame
  1212. })
  1213. }
  1214. .width('15%')
  1215. .height('25%')
  1216. .backgroundColor('#ffff')
  1217. .margin({ top: '4%', right: '1%' })
  1218. .borderRadius(21)
  1219. }
  1220. }
  1221. //开关重启
  1222. @CustomDialog
  1223. struct shutdown {
  1224. @Link shutdownTransparency: number
  1225. @Link textValue: string
  1226. @Link inputValue: string
  1227. controller: CustomDialogController
  1228. build() {
  1229. Column() {
  1230. Row() {
  1231. Image($r('app.media.restart'))
  1232. .width(px2vp(107))
  1233. .height(px2vp(107))
  1234. .onClick(() => {
  1235. this.shutdownTransparency = 0
  1236. this.controller.close()
  1237. })
  1238. Blank()
  1239. Image($r('app.media.shutdown'))
  1240. .width(px2vp(107))
  1241. .height(px2vp(107))
  1242. .onClick(() => {
  1243. let pro = new process.ProcessManager();
  1244. pro.exit(0);
  1245. this.shutdownTransparency = 0
  1246. })
  1247. }.width('30%')
  1248. .height('20%')
  1249. Row() {
  1250. Text('重启')
  1251. .fontWeight(FontWeight.Medium)
  1252. .fontSize(px2vp(27))
  1253. .width(px2vp(107))
  1254. .height(px2vp(107))
  1255. .textAlign(TextAlign.Center)
  1256. .fontColor('#FFFFFF')
  1257. Blank()
  1258. Text('关机')
  1259. .fontWeight(FontWeight.Medium)
  1260. .fontSize(px2vp(27))
  1261. .width(px2vp(107))
  1262. .textAlign(TextAlign.Center)
  1263. .height(px2vp(107))
  1264. .fontColor('#FFFFFF')
  1265. // .onClick(()=>{
  1266. // try {
  1267. // power.('shutdown_test');
  1268. // } catch(err) {
  1269. // console.error('shutdown failed, err: ' + err);
  1270. // }
  1271. // })
  1272. }.width('30%')
  1273. .height('20%')
  1274. }
  1275. .width('100%')
  1276. .height('100%')
  1277. .borderRadius(15)
  1278. .backgroundColor('#cc000000')
  1279. .justifyContent(FlexAlign.Center)
  1280. .alignItems(HorizontalAlign.Center)
  1281. }
  1282. }
  1283. //登录退出
  1284. @CustomDialog
  1285. struct login {
  1286. @Link textValue: string
  1287. @Link inputValue: string
  1288. controller: CustomDialogController
  1289. build() {
  1290. Column() {
  1291. Text('退出登录')
  1292. .textAlign(TextAlign.Center)
  1293. .fontColor('#e6000000')
  1294. .fontSize(px2vp(53))
  1295. .fontWeight(FontWeight.Medium)
  1296. .width('100%')
  1297. .height('30%')
  1298. Text('是否返回登录页?')
  1299. .textAlign(TextAlign.Center)
  1300. .width('100%')
  1301. .height('30%')
  1302. Row({ space: 10 }) {
  1303. Text('取消')
  1304. .width('40%')
  1305. .borderRadius(21)
  1306. .height('70%')
  1307. .textAlign(TextAlign.Center)
  1308. .backgroundColor('#0f000000')
  1309. .fontColor('#0A59F7')
  1310. .onClick(() => {
  1311. this.controller.close()
  1312. })
  1313. Text('确认')
  1314. .width('40%')
  1315. .height('70%')
  1316. .borderRadius(21)
  1317. .backgroundColor('#0A59F7')
  1318. .textAlign(TextAlign.Center)
  1319. .fontColor('#ffff')
  1320. .onClick(() => {
  1321. this.goOut()
  1322. })
  1323. }
  1324. .width('100%')
  1325. .justifyContent(FlexAlign.Center)
  1326. .height('30%')
  1327. }.width('25%')
  1328. .height('20%')
  1329. .borderRadius(15)
  1330. .backgroundColor('#ffff')
  1331. }
  1332. goOut = async () => {
  1333. this.controller.close()
  1334. CommonConstants.LOGIN_OUT = true
  1335. let userInfo = await UserAuthModel.getLast()
  1336. if (userInfo) {
  1337. userInfo.isLogin = false
  1338. UserAuthModel.updateUser(userInfo)
  1339. }
  1340. router.replaceUrl({
  1341. url: 'pages/LoginPage'
  1342. })
  1343. }
  1344. }
  1345. @CustomDialog
  1346. struct Device {
  1347. scroller: Scroller = new Scroller()
  1348. @Link state: string
  1349. @Link text1: string
  1350. @Link index: number
  1351. @Link private items: Array<hardwareList>
  1352. @Link open1: Resource
  1353. @Link colse: Resource
  1354. @Link temp: number
  1355. @Link textValue: string
  1356. @Link swtich: boolean
  1357. @Link DeviceName: string
  1358. @State outSetValueOne: number = 40
  1359. @Link DeviceImage: Resource
  1360. @Link inputValue: string
  1361. @State selest: number = 0
  1362. @State onclick: number = 0
  1363. controller: CustomDialogController
  1364. build() {
  1365. Column() {
  1366. Row() {
  1367. Image($r('app.media.back_white'))
  1368. .width($r('app.float.robot_image_select_size'))
  1369. .padding({ left: 10 })
  1370. .onClick(() => {
  1371. this.controller.close()
  1372. })
  1373. Text(this.DeviceName)
  1374. .fontWeight(FontWeight.Medium)
  1375. .fontSize('40px')
  1376. .fontColor('#ffff')
  1377. }.width('100%')
  1378. .height('10%')
  1379. Column() {
  1380. Image(this.DeviceImage)
  1381. .width('50%')
  1382. }.width('100%')
  1383. .height('30%')
  1384. Blank()
  1385. Text('ID:95234723')
  1386. .fontColor('#ffff')
  1387. .height('5%')
  1388. // if (this.selest===0){
  1389. // Row(){
  1390. // Column(){
  1391. // Text('控制')
  1392. // .fontSize('32px')
  1393. // .fontColor('#0A59F7')
  1394. // .fontWeight(FontWeight.Medium)
  1395. // Blank()
  1396. // Divider()
  1397. // .width('30%')
  1398. // .strokeWidth(2)
  1399. // .backgroundColor('#0A59F7')
  1400. //
  1401. // }.width('30%')
  1402. // .height('100%')
  1403. // .onClick(()=>{
  1404. // this.selest=0
  1405. // })
  1406. // Column(){
  1407. // Text('指南')
  1408. // .fontSize('32px')
  1409. // .fontColor('#ffff')
  1410. //
  1411. // .fontWeight(FontWeight.Medium)
  1412. // }.width('30%')
  1413. // .height('100%')
  1414. // .onClick(()=>{
  1415. // this.selest=1
  1416. // })
  1417. //
  1418. // }.width('100%')
  1419. // .height('5%')
  1420. // .justifyContent(FlexAlign.Center)
  1421. //
  1422. // }else if (this.selest===1){
  1423. // Row(){
  1424. // Column(){
  1425. // Text('控制')
  1426. // .fontSize('32px')
  1427. // .fontColor('#ffff')
  1428. // .fontWeight(FontWeight.Medium)
  1429. // }.width('30%')
  1430. // .height('100%')
  1431. // .onClick(()=>{
  1432. // this.selest=0
  1433. // })
  1434. // Column(){
  1435. // Text('指南')
  1436. // .fontSize('32px')
  1437. // .fontColor('#0A59F7')
  1438. // .fontWeight(FontWeight.Medium)
  1439. // Blank()
  1440. // Divider()
  1441. // .width('30%')
  1442. // .strokeWidth(2)
  1443. // .backgroundColor('#0A59F7')
  1444. //
  1445. // }.width('30%')
  1446. // .height('100%')
  1447. // }.width('100%')
  1448. // .height('5%')
  1449. // .justifyContent(FlexAlign.Center)
  1450. // }
  1451. if (this.selest === 0) {
  1452. Row() {
  1453. Text('在位检查')
  1454. .fontWeight(FontWeight.Medium)
  1455. .fontSize('40px')
  1456. .fontColor('#ffff')
  1457. Blank()
  1458. // if (this.swtich===0){
  1459. Image(this.swtich === true ? $r('app.media.open') : $r('app.media.colse'))
  1460. .width('15%')
  1461. .onClick(() => {
  1462. this.onclick = 1
  1463. // this.items[this.index].select=! this.items[this.index].select
  1464. // this.swtich=!this.swtich
  1465. // this.items[this.index]= {
  1466. // name: this.items[this.index].name,
  1467. // type: this.items[this.index].type,
  1468. // temp: this.items[this.index].temp,
  1469. // state: this.items[this.index].state,
  1470. // text: this.items[this.index].text,
  1471. // open: this.items[this.index].open,
  1472. // colse: this.items[this.index].colse,
  1473. // select: this.items[this.index].select,
  1474. // }
  1475. })
  1476. // .onClick(()=>{
  1477. // this.swtich=false
  1478. // })
  1479. // }else if (this.swtich===false){
  1480. // Image($r('app.media.colse'))
  1481. // .width('15%')
  1482. // .onClick(()=>{
  1483. // this.swtich=true
  1484. // })
  1485. // }
  1486. }
  1487. .width('90%')
  1488. .height('15%')
  1489. .padding({ left: 10, right: 10 })
  1490. .backgroundColor('#33ffffff')
  1491. .borderRadius(21)
  1492. .margin(10)
  1493. Blank()
  1494. if (this.onclick === 1) {
  1495. Column() {
  1496. Text(this.DeviceName)
  1497. .fontSize($r('app.float.fontSize_20'))
  1498. .fontColor($r('app.color.white_100'))
  1499. Text('ID:95234723')
  1500. .fontColor('#ffff')
  1501. .height('5%')
  1502. Row() {
  1503. Image($r('app.media.normal_icon'))
  1504. .width(px2vp(20))
  1505. .height(px2vp(20))
  1506. .margin({ right: px2vp(10) })
  1507. Text('#01装配工位')
  1508. .fontSize($r('app.float.fontSize_14'))
  1509. .fontColor($r('app.color.green_100'))
  1510. }.width(px2vp(200))
  1511. .height(px2vp(100))
  1512. .justifyContent(FlexAlign.Center)
  1513. }.width('100%')
  1514. .alignItems(HorizontalAlign.Center)
  1515. }
  1516. // Row(){
  1517. // Column(){
  1518. // Text('亮度')
  1519. // .fontWeight(FontWeight.Medium)
  1520. // .fontSize('32px')
  1521. // .fontColor('#ffff')
  1522. // Text(this.outSetValueOne.toString()+'%')
  1523. // .fontWeight(FontWeight.Regular)
  1524. // .fontSize('27px')
  1525. // .opacity(0.6)
  1526. // .fontColor('#ffff')
  1527. // }.height('100%')
  1528. // .width('20%')
  1529. // .justifyContent(FlexAlign.Center)
  1530. // // Slider({ value:this.outSetValueOne, min: 0, max: 100, style: SliderStyle.OutSet })
  1531. // // .layoutWeight(2)
  1532. // // .blockColor('#fff')
  1533. // // .trackColor('#fffy')
  1534. // // .width('80%')
  1535. //
  1536. // }.width('90%')
  1537. // .height('15%')
  1538. // .backgroundColor('#33ffffff')
  1539. // .borderRadius(21)
  1540. // .margin(10)
  1541. } else if (this.selest === 1) {
  1542. Row() {
  1543. }
  1544. .width('90%')
  1545. .height('15%')
  1546. .padding({ left: 10, right: 10 })
  1547. .backgroundColor('#33ffffff')
  1548. .borderRadius(21)
  1549. .margin(10)
  1550. Row() {
  1551. }
  1552. .width('90%')
  1553. .height('15%')
  1554. .padding({ left: 10, right: 10 })
  1555. .backgroundColor('#33ffffff')
  1556. .borderRadius(21)
  1557. .margin(10)
  1558. }
  1559. Blank()
  1560. }.width('30%')
  1561. .backgroundColor('#000000')
  1562. .height('80%')
  1563. .borderRadius(21)
  1564. }
  1565. }
  1566. @CustomDialog
  1567. struct Devicepop_up {
  1568. onCancel() {
  1569. console.info('onCancel')
  1570. }
  1571. onAccept() {
  1572. console.info(' onAccept')
  1573. }
  1574. existApp() {
  1575. console.info(' existApp')
  1576. }
  1577. scroller: Scroller = new Scroller()
  1578. Devicepop_up1: CustomDialogController = new CustomDialogController({
  1579. builder: Devicepop_up1({
  1580. inputValue: $inputValue,
  1581. }),
  1582. // gridCount: 3,
  1583. cancel: this.existApp,
  1584. //autoCancel: true,
  1585. alignment: DialogAlignment.Bottom,
  1586. //justifyContent:
  1587. offset: { dx: 0, dy: -80 },
  1588. customStyle: true,
  1589. })
  1590. @Link success: boolean
  1591. @Link inputValue: string
  1592. @Link timeoutID: number
  1593. @Link timeoutID1: number
  1594. @State selest: number = 0
  1595. controller: CustomDialogController
  1596. build() {
  1597. if (this.success) {
  1598. Column() {
  1599. Text('照相机')
  1600. .fontSize(px2vp(51))
  1601. .fontColor('#000000')
  1602. .fontWeight(FontWeight.Medium)
  1603. .textAlign(TextAlign.Center)
  1604. .width('100%')
  1605. .margin({ top: 20 })
  1606. Image($r('app.media.xiangji'))
  1607. .width('60%')
  1608. .height('60%')
  1609. Row() {
  1610. Image($r('app.media.ConnectionSuccessful'))
  1611. .width(px2vp(30))
  1612. .height(px2vp(30))
  1613. Text('设备连接成功')
  1614. .fontColor('#ff5edd4f')
  1615. .fontSize(px2vp(27))
  1616. .padding({ left: 10 })
  1617. }.width('100%')
  1618. .height('10%')
  1619. .justifyContent(FlexAlign.Center)
  1620. }
  1621. .width('30%')
  1622. .backgroundColor('#fff')
  1623. .height('40%')
  1624. .borderRadius(21)
  1625. .onClick(() => {
  1626. clearTimeout(this.timeoutID);
  1627. clearTimeout(this.timeoutID1);
  1628. this.controller.close()
  1629. })
  1630. .transition({ translate: { x: -150, y: -500, }, opacity: 1,
  1631. scale: {
  1632. x: 0,
  1633. y: 0,
  1634. z: 0,
  1635. centerX: '50%',
  1636. centerY: '100%'
  1637. } })
  1638. .transition({ type: TransitionType.Insert, translate: { x: 0, y: -150, }, opacity: 1,
  1639. scale: {
  1640. x: 0,
  1641. y: 0,
  1642. z: 0,
  1643. centerX: '50%',
  1644. centerY: '100%'
  1645. } })
  1646. }
  1647. }
  1648. }
  1649. @CustomDialog
  1650. struct Devicepop_up1 {
  1651. scroller: Scroller = new Scroller()
  1652. @Link inputValue: string
  1653. @State selest: number = 0
  1654. controller: CustomDialogController
  1655. // 若尝试在CustomDialog中传入多个其他的Controller,以实现在CustomDialog中打开另一个或另一些CustomDialog,那么此处需要将指向自己的controller放在最后
  1656. build() {
  1657. Column() {
  1658. Text('RFID读卡器')
  1659. .fontSize(px2vp(51))
  1660. .fontColor('#000000')
  1661. .fontWeight(FontWeight.Medium)
  1662. .textAlign(TextAlign.Center)
  1663. .width('100%')
  1664. .margin({ top: 20 })
  1665. Image($r('app.media.RFID'))
  1666. .width('60%')
  1667. .height('60%')
  1668. Row() {
  1669. Image($r('app.media.ConnectionSuccessful'))
  1670. .width(px2vp(30))
  1671. .height(px2vp(30))
  1672. Text('设备连接成功')
  1673. .fontColor('#ff5edd4f')
  1674. .fontSize(px2vp(27))
  1675. .padding({ left: 10 })
  1676. }.width('100%')
  1677. .height('10%')
  1678. .justifyContent(FlexAlign.Center)
  1679. }
  1680. .width('30%')
  1681. .backgroundColor('#fff')
  1682. .height('40%')
  1683. .borderRadius(21)
  1684. .transition({ type: TransitionType.Delete, translate: { x: 0, y: -100, }, opacity: 1,
  1685. scale: {
  1686. x: 0,
  1687. y: 0,
  1688. z: 0,
  1689. centerX: '50%',
  1690. centerY: '100%'
  1691. } })
  1692. }
  1693. }