HomePage.qml 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018
  1. import QtQuick
  2. import QtQuick.Controls
  3. import Felgo 4.0
  4. import "../controls"
  5. import "../common"
  6. import "../model"
  7. AppPage {
  8. id: home_Page
  9. signal updatebv(string bv)
  10. property string originalString: ""
  11. property string iccidString: ""
  12. property string boxtemptureString: ""
  13. property string collectString: ""
  14. property string gps_state: "定位中..."
  15. property string jsonenable_String: "关闭"
  16. property string imagenable_String: "关闭"
  17. property bool connect_board: false
  18. property var tt
  19. property bool isonline: false
  20. property var net_list:[]
  21. navigationBarHidden: true
  22. backgroundColor: app.theme_backgroundColor
  23. Component.onCompleted: {
  24. // 主题初始化已由Main.qml的onInitTheme统一处理
  25. // 此处不再重复读取主题配置,避免颜色闪烁
  26. console.log("HomePage loaded, current theme:", app.theme_select)
  27. }
  28. Connections {
  29. target: networkMonitor
  30. // 监听可达性变化(如从断开到连接)
  31. function onReachabilityChanged() {
  32. let status = ""
  33. if(networkMonitor.reachability===0)
  34. {
  35. status = "未知"
  36. net_sta.color = "red"
  37. }else if(networkMonitor.reachability===1){
  38. status = "离线"
  39. net_sta.color = "red"
  40. }else if(networkMonitor.reachability===2){
  41. status = "本地"
  42. }else if(networkMonitor.reachability===3){
  43. status = "局域网"
  44. }else if(networkMonitor.reachability===4){
  45. status = "在线"
  46. net_sta.color = "green"
  47. }
  48. console.log("onReachabilityChanged:",networkMonitor.reachability)
  49. net_sta.text = "网络状态:" + status
  50. }
  51. // 监听传输介质变化(如从 Wi-Fi 切换到 4G)
  52. function onTransportMediumChanged() {
  53. let nettype = "未知"
  54. console.log("onTransportMediumChanged:",networkMonitor.transportMedium)
  55. if(networkMonitor.transportMedium===0)
  56. {
  57. nettype = "未知"
  58. }else if(networkMonitor.transportMedium===1){
  59. nettype = "有线"
  60. }else if(networkMonitor.transportMedium===2){
  61. nettype = "移动网络"
  62. }else if(networkMonitor.transportMedium===3){
  63. nettype = "WIFI"
  64. }else if(networkMonitor.transportMedium===4){
  65. nettype = "蓝牙"
  66. }
  67. net_type.text = "网络类型:" + nettype
  68. }
  69. // 监听受限网络状态(如公共 Wi-Fi 登录页)
  70. function onIsBehindCaptivePortalChanged() {
  71. }
  72. // 监听计量网络状态(如移动数据流量限制)
  73. function onIsMeteredChanged() {
  74. }
  75. }
  76. // 接收并显示日志消息
  77. Connections {
  78. target: mqtt
  79. function onConnected() {
  80. console.log("mqtt connect")
  81. }
  82. function onDisconnected() {
  83. console.log("mqtt disconnect")
  84. //mqtt_text.detailText="MQTT已断开"
  85. }
  86. }
  87. // Connections{
  88. // target: myClass
  89. // }
  90. //串口
  91. Connections{
  92. target: serial
  93. function onDataReceived(data){
  94. var jsonData = JSON.parse(data)
  95. console.log("接收到主板数据:",data.toString())
  96. if(jsonData.ext.work_sta==="0"){
  97. text_devicesta.text = qsTr("<b>工作状态:</b> 待机")
  98. if(jsonData.ext.ds==="0"){
  99. }else{
  100. }
  101. }else if(jsonData.ext.work_sta==="1"){
  102. text_devicesta.text = qsTr("<b>工作状态:</b> 采集")
  103. }else if(jsonData.ext.work_sta==="2"){
  104. text_devicesta.text = qsTr("<b>工作状态:</b> 拍照")
  105. }else{
  106. text_devicesta.text = qsTr("<b>工作状态:</b>",jsonData.ext.work_sta)
  107. }
  108. if(jsonData.ext.gps==="1"){
  109. gps_state = "成功"
  110. }
  111. if(jsonData.ext.imei){
  112. originalString = jsonData.ext.imei
  113. }
  114. if(jsonData.ext.iccid){
  115. iccidString= jsonData.ext.iccid
  116. }
  117. if(jsonData.ext.coll_time&&jsonData.ext.coll_min){
  118. var sh1Arry = jsonData.ext.coll_time[0].split('-')
  119. var sh2Arry = jsonData.ext.coll_time[1].split('-')
  120. var sh3Arry = jsonData.ext.coll_time[2].split('-')
  121. var min_arry0 = jsonData.ext.coll_min[0].split('-')
  122. var min_arry1 = jsonData.ext.coll_min[1].split('-')
  123. var min_arry2 = jsonData.ext.coll_min[2].split('-')
  124. sh1.text = parseInt(sh1Arry[0])+ ":" + parseInt(min_arry0[0]) + " - " + parseInt(sh1Arry[1]) + ":" + parseInt(min_arry0[1])
  125. sh2.text = parseInt(sh2Arry[0])+ ":" + parseInt(min_arry1[0]) + " - " + parseInt(sh2Arry[1]) + ":" + parseInt(min_arry1[1])
  126. sh3.text = parseInt(sh3Arry[0])+ ":" + parseInt(min_arry2[0]) + " - " + parseInt(sh3Arry[1]) + ":" + parseInt(min_arry2[1])
  127. }
  128. if(jsonData.ext.dat_f){
  129. serial.update_dat_f_main(jsonData.ext.dat_f);
  130. }
  131. if(jsonData.ext.boxtem){
  132. text_tempture0.text = "箱内温度:" + jsonData.ext.boxtem + "℃"
  133. }
  134. text_tempture.text = "温度:" + jsonData.ext.at + "℃"
  135. text_humidity.text = "湿度:" + jsonData.ext.ah + "%RH"
  136. text_vbat.text = "电压:" + jsonData.ext.vbat + "V"
  137. text_current.text = "电流:" + jsonData.ext.current + "mA"
  138. text_lat.text = "lat:" + jsonData.ext.lat
  139. text_lng.text = "lng:" + jsonData.ext.lng
  140. var x_init_dis = jsonData.ext.x_init_dis
  141. var y_init_dis = jsonData.ext.y_init_dis
  142. if(!textInput_x.focus){
  143. textInput_x.text = x_init_dis.toString();
  144. }
  145. if(!textInput_y.focus){
  146. textInput_y.text = y_init_dis.toString();
  147. }
  148. if(jsonData.ext.tps){
  149. if("1"===jsonData.ext.tps){
  150. text_tempture_sta.text = "保护:" + "["+ jsonData.ext.tpl +"]"
  151. }else{
  152. text_tempture_sta.text = "正常:" + "["+ jsonData.ext.tpl +"]"
  153. }
  154. }
  155. var dvs = jsonData.ext.dver
  156. dvs = dvs.split("-")
  157. app.bvReceived(dvs[0])
  158. app.appReceived(dvs[1])
  159. }
  160. function onDisconnect_485(){
  161. text_devicesta.text =qsTr("485未连接,读取数据失败");
  162. originalString =serial.getId()
  163. iccidString=serial.getIccid()
  164. app.appReceived(serial.get_app_version())
  165. }
  166. function onGpsSuccess(){
  167. gps_state = "成功"
  168. text_lat.text = serial.getlat()
  169. text_lng.text = serial.getlng()
  170. }
  171. }
  172. Timer {
  173. interval: 100
  174. running: true
  175. repeat: true
  176. onTriggered: {
  177. text_stamp.text = getCurrentTime()
  178. }
  179. }
  180. function handleThemeChange(mode){
  181. theme_select = mode
  182. console.log("theme_select",theme_select)
  183. }
  184. function getCurrentTime() {
  185. var currentTime = new Date();
  186. var years = currentTime.getFullYear()
  187. var mon = currentTime.getMonth() + 1
  188. var dates = currentTime.getDate()
  189. var hours = currentTime.getHours()
  190. var mins = currentTime.getMinutes()
  191. var secs = currentTime.getSeconds()
  192. if(app.theme_md==="auto"){
  193. if(hours>=6&&hours<=18){
  194. app.theme_select = "day"
  195. }else{
  196. app.theme_select = "night"
  197. }
  198. }
  199. // 关键:将月、日、时、分、秒补到两位(不足补0)
  200. var formatNum = (num) => String(num).padStart(2, '0')
  201. return `${years}-${formatNum(mon)}-${formatNum(dates)} ${formatNum(hours)}:${formatNum(mins)}:${formatNum(secs)}`
  202. }
  203. Grid {
  204. anchors.fill: parent
  205. anchors.leftMargin: 5
  206. anchors.topMargin: 5
  207. //anchors.horizontalCenter: parent.horizontalCenter
  208. columns: 1
  209. rows: 3
  210. columnSpacing: 10
  211. rowSpacing: 5
  212. horizontalItemAlignment: Grid.AlignHCenter
  213. Row {
  214. width: parent.width *0.995
  215. height: parent.height*0.1
  216. Rectangle {
  217. width: parent.width
  218. height: parent.height
  219. color: app.cardColor
  220. radius: 2
  221. // 使用Item作为容器,设置固定位置和大小
  222. Item {
  223. // 修复:移除Row中的anchors.fill,使用Item的尺寸
  224. Row {
  225. width: parent.width
  226. height: parent.height
  227. spacing: dp(20)
  228. AppText{
  229. id: text_stamp
  230. verticalAlignment: Text.AlignVCenter
  231. text: ""
  232. fontSize: 20
  233. color: app.fontColor
  234. }
  235. AppText{
  236. id: text_imei
  237. verticalAlignment: Text.AlignVCenter
  238. text:"设备ID:" + originalString.toLowerCase()
  239. fontSize: 20
  240. color: app.fontColor
  241. }
  242. AppText{
  243. id: net_sta
  244. verticalAlignment: Text.AlignVCenter
  245. color: app.fontColor
  246. text: "联网状态:"
  247. fontSize: 20
  248. //font.bold: true
  249. }
  250. AppText{
  251. id: net_type
  252. verticalAlignment: Text.AlignVCenter
  253. color: app.fontColor
  254. text: "联网类型:"
  255. fontSize: 20
  256. //font.bold: true
  257. }
  258. AppText{
  259. id: text_gps
  260. verticalAlignment: Text.AlignVCenter
  261. text: "GPS状态:" + gps_state
  262. color: app.fontColor
  263. //font.bold: true
  264. fontSize: 20
  265. }
  266. }
  267. }
  268. }
  269. }
  270. Row{
  271. //anchors.fill: parent
  272. width: parent.width
  273. height: parent.height*0.5
  274. spacing:5
  275. Rectangle {
  276. id: container
  277. width: parent.width * 0.245
  278. height: parent.height
  279. color: app.cardColor
  280. radius: 5
  281. Rectangle {
  282. id: focus_setting
  283. anchors.fill: parent
  284. visible: false
  285. radius: 5
  286. color: app.cardColor
  287. // X坐标输入行(结构同优化前)
  288. Column {
  289. anchors.fill: parent
  290. spacing: 10
  291. Row {
  292. width: parent.width*0.6
  293. spacing: 5
  294. AppText {
  295. text: "X坐标:"
  296. color: app.fontColor
  297. font.pixelSize: 20
  298. }
  299. // 使用边框包裹
  300. ItemDelegate {
  301. width: parent.width
  302. height: 42
  303. padding: 0
  304. contentItem: AppTextInput {
  305. id: textInput_x
  306. width: parent.width
  307. height: parent.height
  308. placeholderText: "x_init_dis"
  309. text: "0"
  310. font.family: "Arial"
  311. font.pixelSize: 20
  312. // 使用验证器替代inputMask
  313. validator: DoubleValidator {
  314. decimals: 2
  315. }
  316. property real numericValue_x: Number(text) || 0
  317. onAccepted: {
  318. console.log("X坐标:", numericValue_x)
  319. serial.setHt_xy_dis(numericValue_x, textInput_y.numericValue_y)
  320. coordinateInputs.visible = false
  321. }
  322. }
  323. // 边框样式
  324. Rectangle {
  325. anchors.fill: parent
  326. color: "transparent"
  327. border.color: textInput_x.activeFocus ? "blue" : "gray"
  328. border.width: 1
  329. radius: 4
  330. }
  331. }
  332. }
  333. // Y坐标输入行(结构同优化前)
  334. Row {
  335. width: parent.width*0.6
  336. spacing: 5
  337. AppText {
  338. text: "Y坐标:"
  339. color: app.fontColor
  340. font.pixelSize: 20
  341. }
  342. // 使用边框包裹
  343. ItemDelegate {
  344. width: parent.width
  345. height: 42
  346. padding: 0
  347. contentItem: AppTextInput {
  348. id: textInput_y
  349. width: parent.width
  350. height: parent.height
  351. placeholderText: "y_init_dis"
  352. text: "0"
  353. font.family: "Arial"
  354. font.pixelSize: 20
  355. wrapMode: Text.NoWrap
  356. inputMethodHints: Qt.ImhMultiLine
  357. // 使用验证器替代inputMask
  358. validator: DoubleValidator {
  359. decimals: 0
  360. }
  361. property real numericValue_y: Number(text) || 0
  362. Keys.onReturnPressed: {
  363. console.log("Y坐标:", numericValue_y)
  364. serial.setHt_xy_dis(textInput_x.numericValue_x, numericValue_y)
  365. coordinateInputs.visible = false
  366. }
  367. }
  368. // 边框样式
  369. Rectangle {
  370. anchors.fill: parent
  371. color: "transparent"
  372. border.color: textInput_x.activeFocus ? "blue" : "gray"
  373. border.width: 1
  374. radius: 4
  375. }
  376. }
  377. }
  378. }
  379. }
  380. Column {
  381. anchors.centerIn: parent
  382. spacing: 12
  383. visible: true
  384. AppImage {
  385. id: image_01
  386. anchors.horizontalCenter: parent.horizontalCenter
  387. anchors.topMargin: 30
  388. source: "../../assets/a.svg"
  389. fillMode: Image.PreserveAspectFit
  390. }
  391. AppText {
  392. id: text_devicesta
  393. anchors.horizontalCenter: parent.horizontalCenter
  394. text: "工作状态:"
  395. color: app.fontColor
  396. font.bold: true
  397. font.pixelSize: 16
  398. }
  399. AppImage {
  400. id: focus_xy_set
  401. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  402. fillMode: Image.PreserveAspectFit // 保持纵横比适应
  403. source: "../../assets/set.svg"
  404. AppButton{
  405. anchors.fill: parent
  406. //text:" 修改"
  407. textColor: "GRAY"
  408. textSize: 10
  409. flat: true
  410. onClicked: {
  411. focus_setting.visible = !focus_setting.visible
  412. text_devicesta.visible = !text_devicesta.visible
  413. image_01.visible = !image_01.visible
  414. }
  415. }
  416. }
  417. }
  418. }
  419. Rectangle {
  420. radius: 5
  421. width: parent.width*0.245
  422. height: parent.height
  423. color: app.cardColor
  424. Timer {
  425. interval: 500
  426. running: true
  427. repeat: true
  428. onTriggered: {
  429. if(mqtt.checkLink()){
  430. mqtt_text.text="MQTT已连接:" + net_list[5]
  431. }else{
  432. mqtt_text.text="MQTT已断开:" + net_list[5]
  433. }
  434. net_list = mqtt.netMessage()
  435. if(mqtt.cache_Json_enable()===1){
  436. jsonenable_String = "开启"
  437. }else{
  438. jsonenable_String = "关闭"
  439. }
  440. if(mqtt.cache_image_enable()===1){
  441. imagenable_String = "开启"
  442. }else{
  443. imagenable_String = "关闭"
  444. }
  445. cache_json_text.text= "数据缓存:" + mqtt.cache_json_num() +
  446. "("+ mqtt.cache_Json_Maxnum()+")" + jsonenable_String
  447. cache_image_text.text = "图片缓存:" + mqtt.cache_image_num()+
  448. "("+mqtt.cache_image_Maxnum()+")" + imagenable_String
  449. if(net_list){
  450. if(net_list[0]==="1"){isonline = true}else{isonline = false}
  451. net_sta.text = qsTr("<b>联网状态:</b> %1").arg(isonline? "已联网" : "未联网")
  452. net_sta.color = qsTr("%1").arg(isonline? "green" : "red")
  453. ipv4.text = qsTr("<b>[IPV4] </b> %1").arg(net_list[4])
  454. mac.text = qsTr("<b>[MAC] </b> %1").arg(net_list[3])
  455. datt_text.text = "数据上传间隔:" + net_list[6] + "分钟"
  456. netxd_text.text = "下一次数据上传:" + net_list[7] + "秒"
  457. iccid_text.text = "SIM卡号:" + iccidString
  458. }
  459. }
  460. }
  461. Timer {
  462. id: longPressTimer
  463. interval: 1000 // 1秒
  464. onTriggered: {
  465. console.log("长按触发")
  466. serial.uploadData_Mqtt()
  467. }
  468. }
  469. MouseArea {
  470. anchors.fill: parent
  471. onPressed:{
  472. longPressTimer.start()
  473. }
  474. onReleased:{
  475. longPressTimer.stop()
  476. }
  477. }
  478. Column{
  479. anchors.centerIn: parent
  480. spacing: 5
  481. AppImage {
  482. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  483. anchors.topMargin: 30
  484. fillMode: Image.PreserveAspectFit // 保持纵横比适应
  485. source: "../../assets/net.svg"
  486. }
  487. AppText{
  488. id: text_net_title
  489. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  490. text: "网络信息"
  491. color: app.fontColor
  492. font.bold: true
  493. }
  494. AppText{
  495. id: ipv4
  496. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  497. text:"IPv4:"
  498. fontSize: 10
  499. color: "gray"
  500. }
  501. AppText{
  502. id: mac
  503. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  504. text:"MAC:"
  505. fontSize: 10
  506. color: "gray"
  507. }
  508. AppText{
  509. id: mqtt_text
  510. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  511. text:"MQTT断开连接:"
  512. fontSize: 10
  513. color: "gray"
  514. }
  515. AppText{
  516. id: datt_text
  517. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  518. text:"数据上传间隔:"
  519. fontSize: 10
  520. color: "gray"
  521. }
  522. AppText{
  523. id: netxd_text
  524. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  525. text:"下一次数据传:"
  526. fontSize: 10
  527. color: "gray"
  528. }
  529. AppText{
  530. id: iccid_text
  531. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  532. text:"SIM卡号:"
  533. fontSize: 10
  534. color: "gray"
  535. }
  536. AppText{
  537. id: cache_json_text
  538. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  539. text:"数据缓存:"
  540. fontSize: 10
  541. color: "gray"
  542. }
  543. AppText{
  544. id: cache_image_text
  545. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  546. text:"图片缓存:"
  547. fontSize: 10
  548. color: "gray"
  549. }
  550. }
  551. }
  552. Rectangle {
  553. radius: 5
  554. width: parent.width*0.245
  555. height: parent.height
  556. color: app.cardColor
  557. Column{
  558. anchors.centerIn: parent
  559. spacing: 5
  560. AppImage {
  561. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  562. anchors.topMargin: 30
  563. fillMode: Image.PreserveAspectFit // 保持纵横比适应
  564. source: "../../assets/gps.svg"
  565. }
  566. AppText{
  567. id: text_gps_title
  568. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  569. text: "定位信息"
  570. color: app.fontColor
  571. font.bold: true
  572. }
  573. AppText{
  574. id: text_lat
  575. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  576. text:"lat:"
  577. fontSize: 10
  578. color: "gray"
  579. }
  580. AppText{
  581. id: text_lng
  582. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  583. text:"lng:"
  584. fontSize: 10
  585. color: "gray"
  586. }
  587. }
  588. }
  589. Rectangle {
  590. radius: 5
  591. width: parent.width*0.245
  592. height: parent.height
  593. color: app.cardColor
  594. Rectangle{
  595. id: rec_seting
  596. anchors.fill: parent
  597. visible: false
  598. AppText {
  599. //anchors.top: parent
  600. //anchors.topMargin:10
  601. text:"采集时间设置"
  602. anchors.horizontalCenter: parent.horizontalCenter
  603. font.bold: true
  604. }
  605. Grid {
  606. anchors.centerIn: parent
  607. //anchors.horizontalCenter: parent.horizontalCenter
  608. columns: 2
  609. rows: 3
  610. rowSpacing: 5
  611. columnSpacing: 20
  612. AppTextField {
  613. id: sh1_textfield
  614. width: 60
  615. height: 30
  616. borderWidth: dp(1)
  617. radius: 5
  618. // Displays a number only keyboard on mobiles
  619. inputMethodHints: Qt.ImhDigitsOnly
  620. validator: IntValidator {
  621. bottom: 0
  622. top: 23
  623. }
  624. }
  625. AppTextField {
  626. id: sh2_textfield
  627. width: 60
  628. height: 30
  629. borderWidth: dp(1)
  630. radius: 5
  631. // Displays a number only keyboard on mobiles
  632. inputMethodHints: Qt.ImhDigitsOnly
  633. validator: IntValidator {
  634. bottom: 0
  635. top: 23
  636. }
  637. }
  638. AppTextField {
  639. id: sh3_textfield
  640. width: 60
  641. height: 30
  642. borderWidth: dp(1)
  643. radius: 5
  644. // Displays a number only keyboard on mobiles
  645. inputMethodHints: Qt.ImhDigitsOnly
  646. validator: IntValidator {
  647. bottom: 0
  648. top: 23
  649. }
  650. }
  651. AppTextField {
  652. id: sh4_textfield
  653. width: 60
  654. height: 30
  655. borderWidth: dp(1)
  656. radius: 5
  657. // Displays a number only keyboard on mobiles
  658. inputMethodHints: Qt.ImhDigitsOnly
  659. validator: IntValidator {
  660. bottom: 0
  661. top: 23
  662. }
  663. }
  664. AppTextField {
  665. id: sh5_textfield
  666. width: 60
  667. height: 30
  668. borderWidth: dp(1)
  669. radius: 5
  670. // Displays a number only keyboard on mobiles
  671. inputMethodHints: Qt.ImhDigitsOnly
  672. validator: IntValidator {
  673. bottom: 0
  674. top: 23
  675. }
  676. }
  677. AppTextField {
  678. id: sh6_textfield
  679. width: 60
  680. height: 30
  681. borderWidth: dp(1)
  682. radius: 5
  683. // Displays a number only keyboard on mobiles
  684. inputMethodHints: Qt.ImhDigitsOnly
  685. validator: IntValidator {
  686. bottom: 0
  687. top: 23
  688. }
  689. }
  690. }
  691. Row {
  692. anchors.horizontalCenter: parent.horizontalCenter
  693. anchors.bottom: parent.bottom
  694. anchors.bottomMargin: 5
  695. //spacing: -15
  696. AppButton {
  697. minimumWidth: 30
  698. minimumHeight: 15
  699. textSize: 15
  700. fontBold: false
  701. iconSize: 10
  702. text: "取消"
  703. textColor: "black"
  704. flat: false
  705. backgroundColor: "#e9e9e9"
  706. borderColor: "white"
  707. onClicked: {
  708. rec_seting.visible = false
  709. column_colt.visible = true
  710. appimage_set.visible = true
  711. image_timesvg.visible = true
  712. }
  713. }
  714. AppButton {
  715. minimumWidth: 30
  716. minimumHeight: 15
  717. textSize: 15
  718. text: "保存"
  719. textColor: "white"
  720. flat: false
  721. backgroundColor: "#0aa26b"
  722. borderColor: "white"
  723. onClicked: {
  724. var int_sh1 = parseInt(sh1_textfield.text)
  725. var int_eh1 = parseInt(sh2_textfield.text)
  726. var int_sh2 = parseInt(sh3_textfield.text)
  727. var int_eh2 = parseInt(sh4_textfield.text)
  728. var int_sh3 = parseInt(sh5_textfield.text)
  729. var int_eh3 = parseInt(sh6_textfield.text)
  730. serial.setCollt(int_sh1,int_eh1,int_sh2,int_eh2,int_sh3,int_eh3)
  731. rec_seting.visible = false
  732. column_colt.visible = true
  733. appimage_set.visible = true
  734. image_timesvg.visible = true
  735. }
  736. }
  737. }
  738. }
  739. Column{
  740. id: column_colt
  741. anchors.centerIn: parent
  742. spacing: 5
  743. AppImage {
  744. id: image_timesvg
  745. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  746. anchors.topMargin: 30
  747. fillMode: Image.PreserveAspectFit // 保持纵横比适应
  748. source: "../../assets/time.svg"
  749. }
  750. AppText{
  751. id: text_coll
  752. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  753. text: "采集时间"
  754. color: app.fontColor
  755. font.bold: true
  756. }
  757. AppText{
  758. id: sh1
  759. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  760. text:"09:00-10:00"
  761. fontSize: 10
  762. color: "gray"
  763. }
  764. AppText{
  765. id: sh2
  766. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  767. text:"14:00-16:00"
  768. fontSize: 10
  769. color: "gray"
  770. }
  771. AppText{
  772. id: sh3
  773. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  774. text:"17:00-19:00"
  775. fontSize: 10
  776. color: "gray"
  777. }
  778. AppImage {
  779. id: appimage_set
  780. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  781. fillMode: Image.PreserveAspectFit // 保持纵横比适应
  782. source: "../../assets/set.svg"
  783. AppButton{
  784. id: settime
  785. anchors.fill: parent
  786. //text:" 修改"
  787. textColor: "GRAY"
  788. textSize: 10
  789. flat: true
  790. onClicked: {
  791. var sh1Arry = sh1.text.split('-')
  792. var sh2Arry = sh2.text.split('-')
  793. var sh3Arry = sh3.text.split('-')
  794. sh1_textfield.text = parseInt(sh1Arry[0]);
  795. sh2_textfield.text= parseInt(sh1Arry[1]);
  796. sh3_textfield.text = parseInt(sh2Arry[0]);
  797. sh4_textfield.text = parseInt(sh2Arry[1]);
  798. sh5_textfield.text = parseInt(sh3Arry[0]);
  799. sh6_textfield.text = parseInt(sh3Arry[1]);
  800. column_colt.visible = false
  801. appimage_set.visible = false
  802. image_timesvg.visible = false
  803. rec_seting.visible = true
  804. }
  805. }
  806. }
  807. }
  808. }
  809. }
  810. Row {
  811. width: parent.width
  812. height: parent.height*0.38
  813. spacing: 5
  814. Rectangle {
  815. radius: 5
  816. width: parent.width*0.245
  817. height: parent.height
  818. color: app.cardColor
  819. Column {
  820. anchors.centerIn: parent
  821. spacing: 5
  822. AppImage {
  823. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  824. anchors.topMargin: 30
  825. fillMode: Image.PreserveAspectFit // 保持纵横比适应
  826. source: "../../assets/tempture.svg"
  827. }
  828. AppText{
  829. id: text_tempture
  830. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  831. text: "环境温度:"
  832. color: app.fontColor
  833. font.bold: true
  834. }
  835. AppText{
  836. id: text_tempture0
  837. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  838. text: "箱内温度:"
  839. color: app.fontColor
  840. font.bold: true
  841. }
  842. AppText{
  843. id: text_tempture_sta
  844. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  845. text:"正常"
  846. fontSize: 10
  847. color: "gray"
  848. }
  849. }
  850. }
  851. Rectangle {
  852. radius: 5
  853. width: parent.width*0.245
  854. height: parent.height
  855. color: app.cardColor
  856. Column {
  857. anchors.centerIn: parent
  858. spacing: 5
  859. AppImage {
  860. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  861. anchors.topMargin: 30
  862. fillMode: Image.PreserveAspectFit // 保持纵横比适应
  863. source: "../../assets/humidity.svg"
  864. }
  865. AppText{
  866. id: text_humidity
  867. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  868. text: "湿度:"
  869. color: app.fontColor
  870. font.bold: true
  871. }
  872. }
  873. }
  874. Rectangle {
  875. radius: 5
  876. width: parent.width*0.245
  877. height: parent.height
  878. color: app.cardColor
  879. Column {
  880. anchors.centerIn: parent
  881. spacing: 5
  882. AppImage {
  883. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  884. anchors.topMargin: 30
  885. fillMode: Image.PreserveAspectFit // 保持纵横比适应
  886. source: "../../assets/vbat.svg"
  887. }
  888. AppText{
  889. id: text_vbat
  890. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  891. text: "电压:"
  892. color: app.fontColor
  893. font.bold: true
  894. }
  895. }
  896. }
  897. Rectangle {
  898. radius: 5
  899. width: parent.width*0.245
  900. height: parent.height
  901. color: app.cardColor
  902. Column {
  903. anchors.centerIn: parent
  904. spacing: 5
  905. AppImage {
  906. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  907. anchors.topMargin: 30
  908. fillMode: Image.PreserveAspectFit // 保持纵横比适应
  909. source: "../../assets/current.svg"
  910. }
  911. AppText{
  912. id: text_current
  913. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  914. text: "电流:"
  915. color: app.fontColor
  916. font.bold: true
  917. }
  918. }
  919. }
  920. }
  921. }
  922. } // page