MainScreen.qml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. import QtQuick
  2. import QtQuick.Controls
  3. import com.lock 1.0 // 导入 C++ 类
  4. import com.InteractiveTask 1.0
  5. Item {
  6. id: mainscreen
  7. width: 1920
  8. height: 1080
  9. property int login_timeout: 99
  10. property bool loginStat: false
  11. property bool opendoor: false
  12. property string lastItemStr : "";
  13. signal signal_logout
  14. Connections {
  15. target: mainscreen
  16. onVisibleChanged: {
  17. if (mainscreen.visible === true)
  18. {
  19. proThread.moveCursorTo(0, 0);
  20. material_sel_background.opacity = 1;
  21. material_exc_background.opacity = 0;
  22. set_sel_background.opacity = 0;
  23. }
  24. }
  25. }
  26. Rectangle {
  27. id: rectangle
  28. x: 0
  29. y: 0
  30. width: 267
  31. height: 1080
  32. color: "#4c2b7ae9"
  33. Image {
  34. id: logoImage
  35. x: 34
  36. y: 40
  37. width: 200
  38. height: 50
  39. source: "qrc:/png/bozz.png"
  40. fillMode: Image.PreserveAspectFit
  41. }
  42. Label {
  43. id: label1
  44. x: 54
  45. y: 105
  46. text: qsTr("物资管理")
  47. color: "#ddffffff"
  48. font.pixelSize: 40
  49. font.bold: true
  50. }
  51. Canvas {
  52. anchors.fill: parent
  53. onPaint: {
  54. var ctx = getContext("2d");
  55. ctx.lineWidth = 5; // 设置线的宽度
  56. ctx.strokeStyle = "white"; // 设置线的颜色为白色
  57. ctx.beginPath();
  58. ctx.moveTo(45, 165); // 直线的起点
  59. ctx.lineTo(225, 165); // 直线的终点
  60. ctx.stroke(); // 绘制直线
  61. ctx.beginPath();
  62. ctx.moveTo(45, 930); // 直线的起点
  63. ctx.lineTo(225, 930); // 直线的终点
  64. ctx.stroke(); // 绘制直线
  65. }
  66. }
  67. Rectangle {
  68. id: rectangle1
  69. x: 44
  70. y: 176
  71. width: 180
  72. height: 560
  73. color: "#00ffffff"
  74. Button {
  75. id: material_sel
  76. x: 0
  77. y: 10
  78. width: 180
  79. height: 180
  80. hoverEnabled: false
  81. background: Rectangle {
  82. id:material_sel_background
  83. color: "#942b7ae9" // 设置背景为透明
  84. radius: 10 // 可选,设置圆角
  85. opacity: 1
  86. }
  87. icon.height: 120
  88. icon.width: 120
  89. display: AbstractButton.TextUnderIcon
  90. icon.source: "qrc:/png/material.png"
  91. icon.color: "#00ffffff"
  92. text: qsTr("物资管理")
  93. font.pixelSize: 30
  94. palette.buttonText: "white" // 设置字体颜色为绿
  95. Connections {
  96. target: material_sel
  97. onClicked: {
  98. if(setView.visible === true || materialException.visible === true)
  99. {
  100. material_sel_background.opacity = 1;
  101. material_exc_background.opacity = 0;
  102. set_sel_background.opacity = 0;
  103. switchViewOff();
  104. changeModel_text(material_sel.text);
  105. materialSelmodel.visible = true;
  106. // proThread.moveCursorTo(0, 0);
  107. }
  108. }
  109. }
  110. }
  111. Button {
  112. id: material_exc
  113. x: 0
  114. y: 200
  115. width: 180
  116. height: 180
  117. hoverEnabled: false
  118. visible: true
  119. background: Rectangle {
  120. id:material_exc_background
  121. color: "#942b7ae9" // 设置背景为透明
  122. radius: 10 // 可选,设置圆角
  123. opacity: 0
  124. }
  125. icon.height: 120
  126. icon.width: 120
  127. display: AbstractButton.TextUnderIcon
  128. icon.source: "qrc:/png/exception.png"
  129. icon.color: "#00ffffff"
  130. text: qsTr("异常处理")
  131. font.pixelSize: 30
  132. palette.buttonText: "white" // 设置字体颜色为绿
  133. Connections {
  134. target: material_exc
  135. onClicked: {
  136. if(setView.visible === true || materialSelmodel.visible === true)
  137. {
  138. material_sel_background.opacity = 0;
  139. material_exc_background.opacity = 1;
  140. set_sel_background.opacity = 0;
  141. switchViewOff();
  142. changeModel_text(material_exc.text);
  143. materialSelmodel.visible = false;
  144. materialException.visible = true;
  145. // proThread.moveCursorTo(0, 0);
  146. }
  147. }
  148. }
  149. }
  150. }
  151. Button {
  152. id: set_sel
  153. x: 44
  154. y: 740
  155. width: 180
  156. height: 180
  157. hoverEnabled: false
  158. background: Rectangle {
  159. id: set_sel_background
  160. color: "#942b7ae9" // 设置背景为透明
  161. radius: 10 // 可选,设置圆角
  162. opacity: 0
  163. }
  164. icon.height: 120
  165. icon.width: 120
  166. display: AbstractButton.TextUnderIcon
  167. icon.source: "qrc:/png/set.png"
  168. icon.color: "#00ffffff"
  169. text: qsTr("设置")
  170. font.pixelSize: 30
  171. palette.buttonText: "white" // 设置字体颜色为绿色
  172. visible: true
  173. Connections {
  174. target: set_sel
  175. onClicked: {
  176. if(materialSelmodel.visible === true || materialException.visible === true)
  177. {
  178. material_sel_background.opacity = 0;
  179. material_exc_background.opacity = 0;
  180. set_sel_background.opacity = 1;
  181. switchViewOff();
  182. changeModel_text(set_sel.text);
  183. setView.load_configParam(false);
  184. setView.fingerVisible = true;
  185. setView.visible = true;
  186. // proThread.moveCursorTo(0, 0);
  187. }
  188. }
  189. }
  190. }
  191. Text {
  192. id: timeDisplay
  193. x: 44
  194. y: 950
  195. font.pixelSize: 32
  196. color: "white"
  197. text: Qt.formatDateTime(new Date(), "yyyy-MM-dd\nhh:mm:ss")
  198. horizontalAlignment: Text.AlignHCenter
  199. verticalAlignment: Text.AlignVCenter
  200. anchors.verticalCenterOffset: 451
  201. anchors.horizontalCenterOffset: 0
  202. // 添加颜色渐变动画
  203. // Behavior on color {
  204. // ColorAnimation { duration: 500 }
  205. // }
  206. }
  207. }
  208. Rectangle {
  209. x: 326
  210. y: 21
  211. width: 185
  212. height: 84
  213. color: "transparent"
  214. // 图片
  215. Image {
  216. id: model_icon
  217. source: "qrc:/png/material.png" // 图片路径(可以是本地文件或资源文件)
  218. width: 60
  219. height: 60
  220. anchors.left: parent.left
  221. anchors.verticalCenter: parent.verticalCenter
  222. }
  223. // 文字
  224. Text {
  225. id: model_text
  226. text: "物资管理"
  227. color: "white"
  228. font.pixelSize: 30
  229. anchors.left: model_icon.right // 文字在图片右侧
  230. anchors.leftMargin: 10 // 图片和文字之间的间距
  231. anchors.verticalCenter: parent.verticalCenter
  232. }
  233. }
  234. Rectangle {
  235. x: 1375
  236. y: 21
  237. width: 524
  238. height: 84
  239. color: "transparent"
  240. Text {
  241. id: user_timeout
  242. visible: false
  243. text: "系统将于 " + formatNumber(login_timeout) + " 秒后退出"
  244. color: "white"
  245. font.pixelSize: 30
  246. anchors.left: parent.left
  247. anchors.verticalCenter: parent.verticalCenter
  248. }
  249. // 图片
  250. Image {
  251. id: user_icon
  252. source: "qrc:/png/user_title.png" // 图片路径(可以是本地文件或资源文件)
  253. width: 60
  254. height: 60
  255. anchors.left: user_timeout.right
  256. anchors.leftMargin: 10
  257. anchors.verticalCenter: parent.verticalCenter
  258. }
  259. Button {
  260. id: user_text
  261. background: Rectangle {
  262. radius: 2 // 可选,设置圆角
  263. opacity: 0
  264. }
  265. text: ""
  266. anchors.left: user_icon.right // 文字在图片右侧
  267. anchors.leftMargin: 10 // 图片和文字之间的间距
  268. anchors.verticalCenter: parent.verticalCenter
  269. font.pixelSize: 30
  270. palette.buttonText: "white" // 设置字体颜色为绿
  271. onClicked: {
  272. if(opendoor === false)
  273. {
  274. logout()
  275. }
  276. }
  277. }
  278. }
  279. Timer {
  280. interval: 1000
  281. running: true
  282. repeat: true
  283. onTriggered: {
  284. timeDisplay.text = Qt.formatDateTime(new Date(), "yyyy-MM-dd\nhh:mm:ss")
  285. // timeDisplay.color = Qt.rgba(Math.random(), Math.random(), Math.random(), 1) // 随机颜色
  286. if(opendoor === false)
  287. {
  288. if(mainScreen.visible === true && login_timeout > 0)
  289. {
  290. login_timeout = login_timeout - 1
  291. if(login_timeout == 30)
  292. {
  293. user_timeout.visible = true;
  294. }
  295. }
  296. else{
  297. if(loginStat == true)
  298. {
  299. logout()
  300. }
  301. }
  302. }
  303. else{
  304. login_timeout = pConfig.sloginTimeout;
  305. }
  306. }
  307. }
  308. // 格式化函数:将整数格式化为两位数字并补零
  309. function formatNumber(number) {
  310. // 使用 padStart 方法补零
  311. return number.toString().padStart(2, '0');
  312. }
  313. function lockStat_callback(left, right) {
  314. if(left === false || right === false)
  315. {
  316. opendoor = true;
  317. }
  318. else if(left === true && right === true)
  319. {
  320. opendoor = false;
  321. }
  322. }
  323. function login_return_param(name, auth){
  324. user_text.text = name;
  325. loginStat = true;
  326. }
  327. function changeModel_text(value) {
  328. // refreshListMode();
  329. if (value === material_sel.text || value === set_sel.text || value === material_exc.text)
  330. {
  331. set_sel.opacity = 1
  332. material_exc.opacity = 1
  333. }
  334. else
  335. {
  336. set_sel.opacity = 0.5
  337. material_exc.opacity = 0.5
  338. }
  339. if(value === material_sel.text)
  340. {
  341. model_text.text = material_sel.text;
  342. model_icon.source = "qrc:/png/takeback.png";
  343. resetLogin_timeout();
  344. }
  345. else if(value === set_sel.text)
  346. {
  347. model_text.text = set_sel.text;
  348. model_icon.source = "qrc:/png/set.png";
  349. resetLogin_timeout();
  350. }
  351. else if(value === "物资取还")
  352. {
  353. model_text.text = "物资取还";
  354. model_icon.source = "qrc:/png/takeback.png";
  355. resetLogin_timeout();
  356. }
  357. else if(value === "物资使用说明")
  358. {
  359. model_text.text = "物资使用说明";
  360. model_icon.source = "qrc:/png/instructions.png";
  361. resetLogin_timeout();
  362. }
  363. else if(value === "物资检查")
  364. {
  365. model_text.text = "物资检查计划";
  366. model_icon.source = "qrc:/png/inspection.png";
  367. resetLogin_timeout();
  368. }
  369. else if(value === "物资检查表")
  370. {
  371. model_text.text = "物资检查表";
  372. model_icon.source = "qrc:/png/inspection.png";
  373. resetLogin_timeout();
  374. }
  375. else if(value === "维修/更换")
  376. {
  377. model_text.text = "维修/更换";
  378. model_icon.source = "qrc:/png/replacement.png";
  379. resetLogin_timeout();
  380. }
  381. else if(value === "异常处理")
  382. {
  383. model_text.text = "异常处理";
  384. model_icon.source = "qrc:/png/exception_handle.png";
  385. resetLogin_timeout();
  386. }
  387. }
  388. function changeModel_text_Instructions(value) {
  389. model_text.text = value;
  390. model_icon.source = "qrc:/png/instructions.png";
  391. }
  392. function resetLogin_timeout()
  393. {
  394. user_timeout.visible = false;
  395. login_timeout = pConfig.sloginTimeout;
  396. }
  397. function logout()
  398. {
  399. user_timeout.visible = false;
  400. loginStat = false;
  401. materialStatistics.visible = false;
  402. materialTakeBack.visible = false;
  403. materialInstructions.visible = false;
  404. materialCheckPlan.visible = false;
  405. materialCheckForm.visible = false;
  406. materialCheckSign.visible = false;
  407. materialCheckUpdate.visible = false;
  408. materialReplace.visible = false;
  409. materialReplaceHand.visible = false;
  410. materialReplaceAuto.visible = false;
  411. materialManualReplace.visible = false;
  412. materialException.visible = false;
  413. // materialExceptionUpdate.visible = false;
  414. materialExceptionReport.visible = false;
  415. // materialExceptionFinish.visible = false;
  416. facialRecognition.visible = false;
  417. materialStocktaking.visible = false;
  418. waitPromptBox.hide();
  419. hangPromptBox.hideExecuteCallback();
  420. infoPromptBox.hide();
  421. materialSelmodel.visible = false;
  422. setView.visible = false;
  423. mainScreen.visible = false;
  424. loginScreen.visible = true;
  425. loginScreen.focus = true;
  426. signal_logout();
  427. }
  428. function switchViewOff()
  429. {
  430. materialSelmodel.visible = false;
  431. setView.fingerVisible = false;
  432. setView.visible = false;
  433. materialStatistics.visible = false;
  434. materialTakeBack.visible = false;
  435. materialInstructions.visible = false;
  436. materialCheckPlan.visible = false;
  437. materialCheckForm.visible = false;
  438. materialCheckSign.visible = false;
  439. materialCheckUpdate.visible = false;
  440. materialReplace.visible = false;
  441. materialReplaceHand.visible = false;
  442. materialReplaceAuto.visible = false;
  443. materialManualReplace.visible = false;
  444. materialException.visible = false;
  445. // materialExceptionUpdate.visible = false;
  446. materialExceptionReport.visible = false;
  447. // materialExceptionFinish.visible = false;
  448. materialStocktaking.visible = false;
  449. facialRecognition.visible = false;
  450. waitPromptBox.hide();
  451. hangPromptBox.hideExecuteCallback();
  452. infoPromptBox.hide();
  453. }
  454. function switchViewOnEx()
  455. {
  456. if (lastItemStr === "materialCheckPlan")
  457. {
  458. materialCheckPlan.visible = true;
  459. }
  460. else if (lastItemStr === "materialCheckForm")
  461. {
  462. materialCheckForm.visible = true;
  463. }
  464. else if (lastItemStr === "materialCheckSign")
  465. {
  466. materialCheckSign.visible = true;
  467. }
  468. else if (lastItemStr === "materialTakeBack")
  469. {
  470. materialTakeBack.visible = true;
  471. }
  472. else if (lastItemStr === "materialReplace")
  473. {
  474. materialReplace.visible = true;
  475. }
  476. else if (lastItemStr === "materialManualReplace")
  477. {
  478. materialManualReplace.visible = true;
  479. }
  480. else if (lastItemStr === "materialException")
  481. {
  482. materialException.visible = true;
  483. }
  484. }
  485. function switchViewOffEx()
  486. {
  487. if (materialCheckPlan.visible === true)
  488. {
  489. lastItemStr = "materialCheckPlan";
  490. }
  491. else if (materialCheckForm.visible === true)
  492. {
  493. lastItemStr = "materialCheckForm";
  494. }
  495. else if (materialCheckSign.visible === true)
  496. {
  497. lastItemStr = "materialCheckSign";
  498. }
  499. else if (materialTakeBack.visible === true)
  500. {
  501. lastItemStr = "materialTakeBack";
  502. }
  503. else if (materialReplace.visible === true)
  504. {
  505. lastItemStr = "materialReplace";
  506. }
  507. else if (materialManualReplace.visible === true)
  508. {
  509. lastItemStr = "materialManualReplace";
  510. }
  511. else if (materialException.visible === true)
  512. {
  513. lastItemStr = "materialException";
  514. }
  515. materialSelmodel.visible = false;
  516. setView.fingerVisible = false;
  517. setView.visible = false;
  518. materialStatistics.visible = false;
  519. materialTakeBack.visible = false;
  520. materialInstructions.visible = false;
  521. materialCheckPlan.visible = false;
  522. materialCheckForm.visible = false;
  523. materialCheckSign.visible = false;
  524. materialCheckUpdate.visible = false;
  525. materialReplace.visible = false;
  526. materialReplaceHand.visible = false;
  527. materialReplaceAuto.visible = false;
  528. materialManualReplace.visible = false;
  529. materialException.visible = false;
  530. // materialExceptionUpdate.visible = false;
  531. materialExceptionReport.visible = false;
  532. // materialExceptionFinish.visible = false;
  533. materialStocktaking.visible = false;
  534. facialRecognition.visible = false;
  535. waitPromptBox.hide();
  536. hangPromptBox.hideExecuteCallback();
  537. infoPromptBox.hide();
  538. }
  539. function get_error_callback(isError)
  540. {
  541. material_exc.visible = isError;
  542. }
  543. // 刷新model列表
  544. function refreshListMode()
  545. {
  546. var taskType = InteractiveTask.TypeMaterialExceptionRefreshListModel;
  547. interactiveCore.appendTask(
  548. taskType, "", ()=>{
  549. if (materialexception_modelMaterialException.count() > 0)
  550. {
  551. material_exc.visible = true;
  552. }
  553. else
  554. {
  555. material_exc.visible = false;
  556. }
  557. });
  558. }
  559. }