JobTicketColockProcess.qml 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817
  1. import QtQuick 2.12
  2. import QtQuick.Layouts 1.12
  3. import QtQuick.Controls 2.12
  4. import Loto 1.0
  5. Rectangle {
  6. id: control
  7. anchors.fill: parent
  8. // color: "#1A40A9FF"
  9. color: "transparent"
  10. radius: 20
  11. property string jobTicketNo: ""
  12. property int jobNodeId
  13. property string jobTicketStatusTypeName: "正在弹出锁具"
  14. property string jobTicketStatusIconCharactor: "\uf007"
  15. property string jobTicketStatusValue: "正在弹出锁具>>"
  16. property int lockStatusCardWidth: 169
  17. property int lockStatusCardHeight: 226
  18. property string currentCardNfc: ""
  19. property bool isReturnLock: false
  20. // 上锁
  21. property var lockModel: ListModel {
  22. // ListElement { position: "点位A"; lockStatus: "未上锁"; lockStatusIcon: "\uf09c"; name: "张三"; locked: false }
  23. // ListElement { position: "点位B"; lockStatus: "未上锁"; lockStatusIcon: "\uf09c"; name: "李四"; locked: false }
  24. }
  25. // 共锁
  26. property var colockModel: ListModel {
  27. // ListElement { userId: 0; avatar: ""; cardNfc: ""; lockStatus: "未共锁"; lockStatusIcon: "\uf09c"; name: "张三"; colocked: false }
  28. // ListElement { userId: 0; avatar: ""; cardNfc: ""; lockStatus: "未共锁"; lockStatusIcon: "\uf09c"; name: "李四"; colocked: false }
  29. // ListElement { userId: 0; avatar: ""; cardNfc: ""; lockStatus: "未共锁"; lockStatusIcon: "\uf09c"; name: "王五"; colocked: false }
  30. // ListElement { userId: 0; avatar: ""; cardNfc: ""; lockStatus: "未共锁"; lockStatusIcon: "\uf09c"; name: "王五"; colocked: false }
  31. // ListElement { userId: 0; avatar: ""; cardNfc: ""; lockStatus: "未共锁"; lockStatusIcon: "\uf09c"; name: "王五"; colocked: false }
  32. // ListElement { userId: 0; avatar: ""; cardNfc: ""; lockStatus: "未共锁"; lockStatusIcon: "\uf09c"; name: "张三"; colocked: false }
  33. // ListElement { userId: 0; avatar: ""; cardNfc: ""; lockStatus: "未共锁"; lockStatusIcon: "\uf09c"; name: "李四"; colocked: false }
  34. // ListElement { userId: 0; avatar: ""; cardNfc: ""; lockStatus: "未共锁"; lockStatusIcon: "\uf09c"; name: "王五"; colocked: false }
  35. // ListElement { userId: 0; avatar: ""; cardNfc: ""; lockStatus: "未共锁"; lockStatusIcon: "\uf09c"; name: "张三"; colocked: false }
  36. // ListElement { userId: 0; avatar: ""; cardNfc: ""; lockStatus: "未共锁"; lockStatusIcon: "\uf09c"; name: "李四"; colocked: false }
  37. // ListElement { userId: 0; avatar: ""; cardNfc: ""; lockStatus: "未共锁"; lockStatusIcon: "\uf09c"; name: "王五"; colocked: false }
  38. }
  39. property int fontSize: 16
  40. property color iconColor: "#40A9FF"
  41. property color iconBgColor: "#1A40A9FF"
  42. property int iconSize: 24
  43. property int tipLabelX: __startJobProcessBtn.x+__startJobProcessBtn.width+10
  44. Component.onCompleted: {
  45. let nodeList = WorkNodeFormModel.nodeUserList;
  46. if (nodeList.length > 0) {
  47. control.colockModel.clear();
  48. }
  49. for (let i = 0; i < nodeList.length; i++) {
  50. if (nodeList[i].type !== "jtcolocker") {
  51. continue;
  52. }
  53. control.colockModel.append({
  54. userId: nodeList[i].id,
  55. avatar: nodeList[i].avatar === null ? "" : nodeList[i].avatar,
  56. lockStatusIcon: "\uf058",
  57. name: nodeList[i].nickname,
  58. cardNfc: nodeList[i].cardNfc === null ? "" : nodeList[i].cardNfc,
  59. colocked: true,
  60. lockStatus: "已共锁"
  61. });
  62. }
  63. if (WorkNodeFormModel.modelType === "returnLock") {
  64. control.isReturnLock = true;
  65. tabBar.currentIndex = 2;
  66. }
  67. }
  68. TabBar {
  69. id: tabBar
  70. currentIndex: stackLayout.currentIndex
  71. width: parent.width
  72. enabled: !control.isReturnLock
  73. background: Rectangle {
  74. anchors.fill: parent
  75. color: "transparent"
  76. }
  77. TabButton {
  78. id: __tabBtn1
  79. height: 59
  80. background: Rectangle {
  81. implicitWidth: 100
  82. implicitHeight: height
  83. color: __tabBtn1.checked ? "#40A9FF" : "#1A40A9FF"
  84. radius: 12 // 设置圆角半径
  85. }
  86. text: qsTr("第一步:共锁人解锁")
  87. font.pixelSize: 18
  88. font.bold: true
  89. }
  90. TabButton {
  91. id: __tabBtn2
  92. height: 59
  93. background: Rectangle {
  94. implicitWidth: 100
  95. implicitHeight: height
  96. color: __tabBtn2.checked ? "#40A9FF" : "#1A40A9FF"
  97. radius: 12 // 设置圆角半径
  98. }
  99. text: qsTr("第二步:获取钥匙解锁")
  100. font.pixelSize: 18
  101. font.bold: true
  102. }
  103. TabButton {
  104. id: __tabBtn3
  105. height: 59
  106. background: Rectangle {
  107. implicitWidth: 100
  108. implicitHeight: height
  109. color: __tabBtn3.checked ? "#40A9FF" : "#1A40A9FF"
  110. radius: 12 // 设置圆角半径
  111. }
  112. text: qsTr("第三步:还锁")
  113. font.pixelSize: 18
  114. font.bold: true
  115. }
  116. }
  117. StackLayout {
  118. id: stackLayout
  119. width: parent.width
  120. height: parent.height - tabBar.height
  121. anchors.top: tabBar.bottom
  122. currentIndex: tabBar.currentIndex
  123. Rectangle {
  124. id: __firstPage
  125. width: stackLayout.width
  126. height: stackLayout.height
  127. color: "transparent"
  128. focus: true
  129. Timer {
  130. id: __firstPageTimer
  131. interval: 50
  132. running: true
  133. repeat: false
  134. onTriggered: {
  135. // 调整焦点设置的时序
  136. __firstPage.forceActiveFocus()
  137. // console.log("初始化焦点:", __firstPage.activeFocus)
  138. }
  139. }
  140. Component.onCompleted: {
  141. __firstPageTimer.start();
  142. }
  143. MButton {
  144. id: __colockTips
  145. anchors.horizontalCenter: parent.horizontalCenter
  146. y: 30
  147. height: 48
  148. width: 800
  149. btnRadius: 8
  150. buttonColor: "#1A40A9FF"
  151. pressedScale: 1.0
  152. cancelMouseArea: true
  153. text: qsTr("请所有共锁人确认共锁后,系统会自动检查共锁状态")
  154. textColor: "white"
  155. }
  156. Flickable {
  157. id: __unlockColockView
  158. anchors.horizontalCenter: parent.horizontalCenter
  159. anchors.top: __colockTips.bottom
  160. anchors.topMargin: 135
  161. width: Math.min(__colockRow.width, control.lockStatusCardWidth*4 + 45)
  162. height: __colockRow.height + 30
  163. clip: true
  164. flickableDirection: Flickable.HorizontalFlick
  165. contentWidth: __colockRow.width
  166. contentHeight: height
  167. Row {
  168. id: __colockRow
  169. spacing: 15
  170. Repeater {
  171. model: control.colockModel
  172. delegate: LockStatusCard {
  173. width: control.lockStatusCardWidth
  174. height: control.lockStatusCardHeight
  175. bgRadius: 8
  176. cardColor: "transparent"
  177. bgBorderColor: colocked ? "green" : "#40A9FF"
  178. iconCharacter: "\uf406"
  179. iconColor: "#0A1929"
  180. avatarUrl: avatar
  181. text: name
  182. textFontSize: 18
  183. textColor: "white"
  184. statusText: lockStatus
  185. statusTextFontSize: 16
  186. statusIconCharacter: lockStatusIcon
  187. statusIconSize: 20
  188. statusIconColor: "white"
  189. // onClicked: {
  190. // control.colockModel.get(index).lockStatus = "已共锁";
  191. // control.colockModel.get(index).lockStatusIcon = "\uf058";
  192. // control.colockModel.get(index).colocked = true;
  193. // }
  194. }
  195. }
  196. }
  197. }
  198. Rectangle {
  199. id: leftButton
  200. width: 50; height: 50
  201. anchors.left: __unlockColockView.left
  202. anchors.leftMargin: -55
  203. anchors.verticalCenter: __unlockColockView.verticalCenter
  204. color: 'transparent'
  205. border.color: "#40A9FF"
  206. radius: width/2
  207. visible: __unlockColockView.contentX === 0 ? false : true
  208. Text {
  209. id: iconLabel
  210. anchors.centerIn: parent
  211. text: "\uf104"
  212. color: "#40A9FF"
  213. font.pixelSize: 36
  214. font.family: iconFont.name
  215. verticalAlignment: Text.AlignVCenter
  216. horizontalAlignment: Text.AlignHCenter
  217. }
  218. MouseArea {
  219. anchors.fill: parent
  220. onClicked: {
  221. if (__unlockColockView.contentX > 0) {
  222. if (__unlockColockView.contentX > __unlockColockView.width+15) {
  223. __unlockColockView.contentX -= __unlockColockView.width+15; // 向左滚动一个页面宽度
  224. } else {
  225. __unlockColockView.contentX = 0;
  226. }
  227. } else {
  228. __unlockColockView.contentX = 0; // 如果已经到达最左侧,则不滚动
  229. }
  230. }
  231. }
  232. }
  233. Rectangle {
  234. id: rightButton
  235. width: 50; height: 50
  236. anchors.right: __unlockColockView.right
  237. anchors.rightMargin: -55
  238. anchors.verticalCenter: __unlockColockView.verticalCenter
  239. color: 'transparent'
  240. border.color: "#40A9FF"
  241. radius: width/2
  242. visible: __unlockColockView.contentX === __unlockColockView.contentWidth - __unlockColockView.width ? false : true
  243. Text {
  244. id: __rIconLabel
  245. anchors.centerIn: parent
  246. text: "\uf105"
  247. color: "#40A9FF"
  248. font.pixelSize: 36
  249. font.family: iconFont.name
  250. verticalAlignment: Text.AlignVCenter
  251. horizontalAlignment: Text.AlignHCenter
  252. }
  253. MouseArea {
  254. anchors.fill: parent
  255. onClicked: {
  256. if (__unlockColockView.contentX < __unlockColockView.contentWidth - __unlockColockView.width) {
  257. if ((__unlockColockView.contentX+__unlockColockView.width+15) >= __unlockColockView.contentWidth - __unlockColockView.width) {
  258. __unlockColockView.contentX = __unlockColockView.contentWidth - __unlockColockView.width;
  259. } else {
  260. __unlockColockView.contentX += __unlockColockView.width+15; // 向右滚动一个页面宽度
  261. }
  262. } else {
  263. __unlockColockView.contentX = __unlockColockView.contentWidth - __unlockColockView.width; // 如果已经到达最右侧,则不滚动超过内容宽度
  264. }
  265. }
  266. }
  267. }
  268. Rectangle {
  269. id: __successAndExit
  270. anchors.top: __unlockColockView.bottom
  271. anchors.topMargin: 35
  272. width: 136
  273. height: 49
  274. anchors.horizontalCenter: parent.horizontalCenter
  275. visible: false
  276. color: "#1890FF"
  277. radius: 12
  278. IconText {
  279. anchors.centerIn: parent
  280. iconCharacter: "\uf058"
  281. iconSize: 18
  282. iconColor: "white"
  283. text: qsTr("完成")
  284. textColor: "white"
  285. }
  286. MouseArea {
  287. anchors.fill: parent
  288. onClicked: {
  289. // appShowHome = true;
  290. stackLayout.currentIndex = 1;
  291. }
  292. }
  293. }
  294. }
  295. Rectangle {
  296. width: stackLayout.width
  297. height: stackLayout.height
  298. color: "transparent"
  299. MButton {
  300. id: __startJobProcessBtn
  301. x: 422
  302. y: 30
  303. height: 72
  304. width: 377
  305. buttonColor: "#40A9FF"
  306. text: qsTr("现在取出设备")
  307. textColor: "white"
  308. iconCharacter: "\uf084"
  309. iconColor: "white"
  310. onClicked: {
  311. __sleepTimer.start();
  312. InteractiveCAN.cardNo = control.jobTicketNo;
  313. InteractiveCAN.taskCode = WorkNodeFormModel.workId
  314. InteractiveCAN.openEKey();
  315. }
  316. }
  317. Text {
  318. id: __tipIconLabel
  319. x: tipLabelX
  320. y: 55
  321. text: "\uf0a5"
  322. color: "orange"
  323. font.pixelSize: 20
  324. font.family: iconFont.name
  325. verticalAlignment: Text.AlignVCenter
  326. horizontalAlignment: Text.AlignHCenter
  327. SequentialAnimation on x {
  328. loops: Animation.Infinite // 无限循环动画
  329. NumberAnimation { from: tipLabelX; to: tipLabelX + 10; duration: 400 } // 向右移动
  330. PauseAnimation { duration: 100 } // 暂停一段时间(可选)
  331. NumberAnimation { from: tipLabelX+10; to: tipLabelX; duration: 400 } // 向左移动返回原点
  332. PauseAnimation { duration: 100 } // 再次暂停(可选)
  333. }
  334. }
  335. Text {
  336. id: __tipLabel
  337. x: tipLabelX + 30
  338. y: 58
  339. text: qsTr("请点击按钮进行操作")
  340. color: "white"
  341. font.pixelSize: 16
  342. // 普通文字不使用图标字体
  343. verticalAlignment: Text.AlignVCenter
  344. horizontalAlignment: Text.AlignHCenter
  345. }
  346. Flickable {
  347. id: __subProcesses
  348. anchors.top: __startJobProcessBtn.bottom
  349. anchors.topMargin: 35
  350. anchors.horizontalCenter: parent.horizontalCenter
  351. Column {
  352. anchors.fill: parent
  353. spacing: 20
  354. JobTicketSubProcess {
  355. id: subProcess1
  356. anchors.horizontalCenter: parent.horizontalCenter
  357. width: 801
  358. height: 99
  359. jobTicketStatusTypeName: "分配钥匙"
  360. jobTicketStatusValue: "正在分配钥匙>>"
  361. }
  362. JobTicketSubProcess {
  363. id: subProcess2
  364. anchors.horizontalCenter: parent.horizontalCenter
  365. width: 801
  366. height: 99
  367. jobTicketStatusTypeName: "下发作业票"
  368. jobTicketStatusValue: "正在下发作业票>>"
  369. }
  370. JobTicketSubProcess {
  371. id: subProcess3
  372. anchors.horizontalCenter: parent.horizontalCenter
  373. width: 801
  374. height: 99
  375. jobTicketStatusTypeName: "取出钥匙"
  376. jobTicketStatusValue: "打开钥匙扣>>"
  377. }
  378. JobTicketSubProcess {
  379. id: subProcess4
  380. anchors.horizontalCenter: parent.horizontalCenter
  381. width: 801
  382. height: 99
  383. jobTicketStatusTypeName: "放回钥匙"
  384. jobTicketStatusValue: "放回钥匙>>"
  385. }
  386. Rectangle {
  387. id: __successFirstStep
  388. width: 800
  389. height: 49
  390. anchors.horizontalCenter: parent.horizontalCenter
  391. visible: false
  392. color: "#1890FF"
  393. radius: 12
  394. IconText {
  395. anchors.centerIn: parent
  396. iconCharacter: "\uf058"
  397. iconSize: 18
  398. iconColor: "green"
  399. text: qsTr("锁具和钥匙已经弹出,请及时取走并前往其对应点位上锁。上锁完成请返回锁柜还回钥匙")
  400. textColor: "white"
  401. }
  402. MouseArea {
  403. anchors.fill: parent
  404. onClicked: {
  405. tabBar.currentIndex += 1;
  406. }
  407. }
  408. }
  409. }
  410. }
  411. onVisibleChanged: {
  412. InteractiveCAN.updateKeyAndLockStatus();
  413. }
  414. }
  415. Rectangle {
  416. width: stackLayout.width
  417. height: stackLayout.height
  418. color: "transparent"
  419. MButton {
  420. id: __lockTips
  421. anchors.horizontalCenter: parent.horizontalCenter
  422. y: 30
  423. height: 48
  424. width: 800
  425. btnRadius: 8
  426. buttonColor: "#1A40A9FF"
  427. pressedScale: 1.0
  428. cancelMouseArea: true
  429. text: qsTr("请将钥匙插入锁柜,插入后,系统会自动检查上锁状态")
  430. textColor: "white"
  431. }
  432. Flickable {
  433. id: __lockView
  434. anchors.horizontalCenter: parent.horizontalCenter
  435. anchors.top: __lockTips.bottom
  436. anchors.topMargin: 135
  437. width: Math.min(__lockRow.width, control.lockStatusCardWidth*4+45)
  438. height: parent.height - __lockTips.height - 75
  439. clip: true
  440. flickableDirection: Flickable.HorizontalFlick
  441. contentWidth: __lockRow.width
  442. contentHeight: height
  443. Row {
  444. id: __lockRow
  445. spacing: 15
  446. Repeater {
  447. model: control.lockModel
  448. delegate: LockStatusCard {
  449. width: control.lockStatusCardWidth
  450. height: control.lockStatusCardHeight
  451. bgRadius: 8
  452. cardColor: "transparent"
  453. bgBorderColor: locked ? "green" : "#40A9FF"
  454. iconCharacter: "\uf406"
  455. iconColor: "#0A1929"
  456. text: name
  457. textFontSize: 18
  458. textColor: "white"
  459. statusText: lockStatus
  460. statusTextFontSize: 16
  461. statusIconCharacter: lockStatusIcon
  462. statusIconSize: 20
  463. statusIconColor: "white"
  464. // onClicked: {
  465. // control.lockModel.get(index).lockStatus = "已上锁";
  466. // control.lockModel.get(index).lockStatusIcon = "\uf058";
  467. // control.lockModel.get(index).locked = true;
  468. // }
  469. }
  470. }
  471. }
  472. }
  473. Rectangle {
  474. id: __lockLeftButton
  475. width: 50; height: 50
  476. anchors.left: __lockView.left
  477. anchors.leftMargin: -55
  478. anchors.verticalCenter: __lockView.verticalCenter
  479. color: 'transparent'
  480. border.color: "#40A9FF"
  481. radius: width/2
  482. visible: __lockView.contentX === 0 ? false : true
  483. Text {
  484. id: __lockIconLabel
  485. anchors.centerIn: parent
  486. text: "\uf104"
  487. color: "#40A9FF"
  488. font.pixelSize: 36
  489. font.family: iconFont.name
  490. verticalAlignment: Text.AlignVCenter
  491. horizontalAlignment: Text.AlignHCenter
  492. }
  493. MouseArea {
  494. anchors.fill: parent
  495. onClicked: {
  496. if (__lockView.contentX > 0) {
  497. if (__lockView.contentX > __lockView.width+15) {
  498. __lockView.contentX -= __lockView.width+15; // 向左滚动一个页面宽度
  499. } else {
  500. __lockView.contentX = 0;
  501. }
  502. } else {
  503. __lockView.contentX = 0; // 如果已经到达最左侧,则不滚动
  504. }
  505. }
  506. }
  507. }
  508. Rectangle {
  509. id: __lockRightButton
  510. width: 50; height: 50
  511. anchors.right: __lockView.right
  512. anchors.rightMargin: -55
  513. anchors.verticalCenter: __lockView.verticalCenter
  514. color: 'transparent'
  515. border.color: "#40A9FF"
  516. radius: width/2
  517. visible: __lockView.contentX === __lockView.contentWidth - __lockView.width ? false : true
  518. Text {
  519. id: __lockRIconLabel
  520. anchors.centerIn: parent
  521. text: "\uf105"
  522. color: "#40A9FF"
  523. font.pixelSize: 36
  524. font.family: iconFont.name
  525. verticalAlignment: Text.AlignVCenter
  526. horizontalAlignment: Text.AlignHCenter
  527. }
  528. MouseArea {
  529. anchors.fill: parent
  530. onClicked: {
  531. if (__lockView.contentX < __lockView.contentWidth - __lockView.width) {
  532. if ((__lockView.contentX+__lockView.width+15) >= __lockView.contentWidth - __lockView.width) {
  533. __lockView.contentX = __lockView.contentWidth - __lockView.width;
  534. } else {
  535. __lockView.contentX += __lockView.width+15; // 向右滚动一个页面宽度
  536. }
  537. } else {
  538. __lockView.contentX = __lockView.contentWidth - __lockView.width; // 如果已经到达最右侧,则不滚动超过内容宽度
  539. }
  540. }
  541. }
  542. }
  543. }
  544. }
  545. Connections {
  546. target: control.colockModel
  547. function onDataChanged() {
  548. var allColocked = true;
  549. for (var i = 0; i < control.colockModel.count; i++) {
  550. if (!control.colockModel.get(i).colocked) {
  551. allColocked = false;
  552. break;
  553. }
  554. }
  555. // 所有共锁人都已确认共锁
  556. if (allColocked) {
  557. // TODO: 显示完成按钮
  558. __successAndExit.visible = true;
  559. }
  560. }
  561. }
  562. Connections {
  563. target: InteractiveCAN
  564. function onSignalJobTicketResult(jsonResult, pointInfo) {
  565. var lockInfo = JSON.parse(jsonResult);
  566. if (!lockInfo.hasOwnProperty("data") || !Array.isArray(lockInfo.data)) {
  567. return;
  568. }
  569. for (var i = 0; i < lockInfo.data.length; i++) {
  570. var dataItem = lockInfo.data[i];
  571. if (dataItem.hasOwnProperty("taskCode")) {
  572. if (dataItem.taskCode === WorkNodeFormModel.workId.toString() && dataItem.hasOwnProperty("dataList")) {
  573. control.lockModel.clear();
  574. var dataList = dataItem.dataList;
  575. for (var j = 0; j < dataList.length; j++) {
  576. var position = dataList[j].dataId.toString();
  577. var name = pointInfo[position];
  578. var lockStatus = "";
  579. var locked = false;
  580. var status = dataList[j].status;
  581. var lockStatusIcon = "\uf058";
  582. var lockNfcinfo = dataList[j].infoRfidNo;
  583. if (status === 0) {
  584. lockStatus = "挂锁";
  585. locked = true;
  586. } else if (status === 1) {
  587. lockStatusIcon = "\uf09c";
  588. lockStatus = "解锁";
  589. } else if (status === 2) {
  590. lockStatus = "无操作";
  591. } else if (status === 3) {
  592. lockStatus = "已挂锁";
  593. locked = true;
  594. }
  595. control.lockModel.append({
  596. position: position,
  597. lockStatus: lockStatus,
  598. lockStatusIcon: lockStatusIcon,
  599. name: name,
  600. locked: locked,
  601. lockNfc: lockNfcinfo,
  602. });
  603. }
  604. }
  605. }
  606. }
  607. }
  608. function onSignalUpdateBackLockStatus(lockRfidList) {
  609. for (var i = 0; i < control.lockModel.count; i++) {
  610. for (var j = 0; j < lockRfidList.length; j++) {
  611. if (control.lockModel.get(i).lockNfc === lockRfidList[j]) {
  612. control.lockModel.get(i).lockStatus = "已还锁";
  613. break;
  614. }
  615. }
  616. }
  617. }
  618. }
  619. function convertCardNfc(cardNfc) {
  620. let hexCardNfc = "";
  621. let cardNfcInt = parseInt(cardNfc);
  622. if (isNaN(cardNfcInt)) {
  623. return hexCardNfc;
  624. }
  625. let hexStr = cardNfcInt.toString(16);
  626. if (hexStr.length % 2 === 0) {
  627. for (let i = hexStr.length / 2; i > 0; i--) {
  628. let subStr = hexStr.substr((i - 1) * 2, 2);
  629. hexCardNfc += subStr;
  630. }
  631. }
  632. return hexCardNfc.toUpperCase();
  633. }
  634. function setcardIDByKey(value) {
  635. switch(value)
  636. {
  637. case Qt.Key_0: control.currentCardNfc = control.currentCardNfc + "0";break;
  638. case Qt.Key_1: control.currentCardNfc = control.currentCardNfc + "1";break;
  639. case Qt.Key_2: control.currentCardNfc = control.currentCardNfc + "2";break;
  640. case Qt.Key_3: control.currentCardNfc = control.currentCardNfc + "3";break;
  641. case Qt.Key_4: control.currentCardNfc = control.currentCardNfc + "4";break;
  642. case Qt.Key_5: control.currentCardNfc = control.currentCardNfc + "5";break;
  643. case Qt.Key_6: control.currentCardNfc = control.currentCardNfc + "6";break;
  644. case Qt.Key_7: control.currentCardNfc = control.currentCardNfc + "7";break;
  645. case Qt.Key_8: control.currentCardNfc = control.currentCardNfc + "8";break;
  646. case Qt.Key_9: control.currentCardNfc = control.currentCardNfc + "9";break;
  647. case Qt.Key_A: control.currentCardNfc = control.currentCardNfc + "A";break;
  648. case Qt.Key_B: control.currentCardNfc = control.currentCardNfc + "B";break;
  649. case Qt.Key_C: control.currentCardNfc = control.currentCardNfc + "C";break;
  650. case Qt.Key_D: control.currentCardNfc = control.currentCardNfc + "D";break;
  651. case Qt.Key_E: control.currentCardNfc = control.currentCardNfc + "E";break;
  652. case Qt.Key_F: control.currentCardNfc = control.currentCardNfc + "F";break;
  653. case Qt.Key_Return: {
  654. if (control.currentCardNfc.length > 0) {
  655. let hexCardNfc = convertCardNfc(control.currentCardNfc);
  656. for (var i = 0; i < control.colockModel.count; i++) {
  657. console.log(hexCardNfc, control.colockModel.get(i).cardNfc.toUpperCase());
  658. if (control.colockModel.get(i).cardNfc.toUpperCase() === hexCardNfc) {
  659. control.colockModel.get(i).colocked = false;
  660. control.colockModel.get(i).lockStatus = "解锁";
  661. control.colockModel.get(i).lockStatusIcon = "\uf09c";
  662. InteractiveCAN.cardNo = control.jobTicketNo;
  663. InteractiveCAN.taskCode = WorkNodeFormModel.workId;
  664. InteractiveCAN.signalUpdateColockStatus(hexCardNfc);
  665. break;
  666. }
  667. }
  668. }
  669. control.currentCardNfc = "";
  670. return
  671. }
  672. }
  673. }
  674. Keys.onReleased: function(event) {
  675. if (__unlockColockView.visible) {
  676. setcardIDByKey(event.key);
  677. }
  678. }
  679. Timer {
  680. id: __sleepTimer
  681. interval: 200
  682. repeat: true
  683. running: false
  684. onTriggered: {
  685. if (InteractiveCAN.okOpenKey) {
  686. subProcess1.showSuccessfulColor = true;
  687. }
  688. if (InteractiveCAN.okSendJobTicket) {
  689. subProcess2.showSuccessfulColor = true;
  690. }
  691. if (InteractiveCAN.okUnLockLocks) {
  692. subProcess3.showSuccessfulColor = true;
  693. }
  694. if (InteractiveCAN.okUnlockKey) {
  695. subProcess4.showSuccessfulColor = true;
  696. __sleepTimer.stop();
  697. __successFirstStep.visible = true;
  698. }
  699. }
  700. }
  701. }