PageSetting.qml 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788
  1. import QtQuick 2.15
  2. import QtQuick.Layouts 1.3
  3. import QtQuick.Controls 2.14
  4. import QtQuick.Controls.Styles 1.2
  5. import Qt.labs.qmlmodels 1.0
  6. import TService 1.0
  7. Item{
  8. id: root
  9. //anchors.fill: parent
  10. //width:1024
  11. //height: 768
  12. //anchors.centerIn: parent
  13. property var pagetype:rootitem.Page_Type_Settings
  14. property string title_str:"信息录入"
  15. property string standard_name:"国标"
  16. property string company:""
  17. property string licenseplate: ""
  18. property int compartment_num: 1
  19. property int total_volume: 0
  20. property var volume_arry: [0,0,0,0,0,0,0,0]
  21. function update_standard(){
  22. var jsonObj = StandardManager.get_names();
  23. lmd.clear()
  24. for(var i=0; i<jsonObj.num; i++){
  25. //console.log("name ===="+jsonArry.names[i]);
  26. lmd.append({text:jsonObj.names[i]})
  27. }
  28. standard_name_comboBox.currentIndex = 0
  29. }
  30. function caculate_volume(){
  31. if(root.total_volume > 0 && root.compartment_num >0){
  32. var vol = root.total_volume/root.compartment_num;
  33. var volume = parseInt(vol)
  34. if(1 == root.compartment_num){
  35. rectvolume_1.text=volume
  36. rectvolume_2.text=0
  37. rectvolume_3.text=0
  38. rectvolume_4.text=0
  39. rectvolume_5.text=0
  40. rectvolume_6.text=0
  41. rectvolume_7.text=0
  42. rectvolume_8.text=0
  43. }else if(2 == root.compartment_num){
  44. rectvolume_1.text=volume
  45. rectvolume_2.text=root.total_volume-volume
  46. rectvolume_3.text=0
  47. rectvolume_4.text=0
  48. rectvolume_5.text=0
  49. rectvolume_6.text=0
  50. rectvolume_7.text=0
  51. rectvolume_8.text=0
  52. }else if(3 == root.compartment_num){
  53. rectvolume_1.text=volume
  54. rectvolume_2.text=volume
  55. rectvolume_3.text=root.total_volume-volume*2
  56. rectvolume_4.text=0
  57. rectvolume_5.text=0
  58. rectvolume_6.text=0
  59. rectvolume_7.text=0
  60. rectvolume_8.text=0
  61. }else if(4 == root.compartment_num){
  62. rectvolume_1.text=volume
  63. rectvolume_2.text=volume
  64. rectvolume_3.text=volume
  65. rectvolume_4.text=root.total_volume-volume*3
  66. rectvolume_5.text=0
  67. rectvolume_6.text=0
  68. rectvolume_7.text=0
  69. rectvolume_8.text=0
  70. }else if(5 == root.compartment_num){
  71. rectvolume_1.text=volume
  72. rectvolume_2.text=volume
  73. rectvolume_3.text=volume
  74. rectvolume_4.text=volume
  75. rectvolume_5.text=root.total_volume-volume*4
  76. rectvolume_6.text=0
  77. rectvolume_7.text=0
  78. rectvolume_8.text=0
  79. }else if(6 == root.compartment_num){
  80. rectvolume_1.text=volume
  81. rectvolume_2.text=volume
  82. rectvolume_3.text=volume
  83. rectvolume_4.text=volume
  84. rectvolume_5.text=volume
  85. rectvolume_6.text=root.total_volume-volume*5
  86. rectvolume_7.text=0
  87. rectvolume_8.text=0
  88. }else if(7 == root.compartment_num){
  89. rectvolume_1.text=volume
  90. rectvolume_2.text=volume
  91. rectvolume_3.text=volume
  92. rectvolume_4.text=volume
  93. rectvolume_5.text=volume
  94. rectvolume_6.text=volume
  95. rectvolume_7.text=root.total_volume-volume*6
  96. rectvolume_8.text=0
  97. }else if(8 == root.compartment_num){
  98. rectvolume_1.text=volume
  99. rectvolume_2.text=volume
  100. rectvolume_3.text=volume
  101. rectvolume_4.text=volume
  102. rectvolume_5.text=volume
  103. rectvolume_6.text=volume
  104. rectvolume_7.text=volume
  105. rectvolume_8.text=root.total_volume-volume*7
  106. }
  107. }
  108. }
  109. function check_invalid(){
  110. var valid = true
  111. if(0 == licenseplate.length){
  112. valid = false
  113. log.show("车牌不能为空")
  114. return valid
  115. }
  116. if(0 == company.length){
  117. valid = false
  118. log.show("车辆单位不能为空")
  119. return valid
  120. }
  121. if(0 == total_volume){
  122. valid = false
  123. log.show("容积不能为空")
  124. return valid
  125. }
  126. if(0 == compartment_num){
  127. valid = false
  128. log.show("仓数不能为空")
  129. return valid
  130. }
  131. var all_volume = 0
  132. for(var i=0; i<compartment_num; i++){
  133. all_volume = all_volume + volume_arry[i]
  134. }
  135. if(all_volume !== total_volume){
  136. valid = false
  137. log.show("体积总容量与每仓数据不匹配")
  138. }
  139. return valid
  140. }
  141. // Component{
  142. // id:componet
  143. DynamicGroupBox{
  144. id:groupbox
  145. //width: 1020
  146. //height: 760
  147. anchors.centerIn: parent
  148. anchors.fill: parent
  149. title: title_str
  150. /*
  151. function show(){
  152. animationShow.running = true
  153. }
  154. function exit(){
  155. //BreatheTestJs.exit = true
  156. animationExit.running = true
  157. //startStopButton.running = false
  158. //stopTimer.start()
  159. }
  160. //加载任务动画效果
  161. NumberAnimation {
  162. id: animationShow
  163. target: groupbox
  164. property: "x"
  165. from: groupbox.x
  166. to: 0
  167. duration: 500
  168. }
  169. NumberAnimation {
  170. id: animationExit
  171. target: groupbox
  172. property: "x"
  173. from: groupbox.x
  174. to: 1024
  175. duration: 500
  176. }
  177. */
  178. ColumnLayout{
  179. spacing:2
  180. Rectangle{
  181. Layout.alignment: Qt.AlignCenter
  182. //Layout.fillWidth: true
  183. color: "transparent"
  184. Layout.preferredHeight: 600
  185. Layout.preferredWidth: 1240
  186. Row{
  187. anchors.centerIn: parent
  188. spacing:10
  189. Column{
  190. spacing:20
  191. DynamicGroupBox{
  192. id:standard_select
  193. title: "标准选择:"
  194. //anchors.centerIn: parent
  195. width: 360
  196. height: 160
  197. Column{
  198. spacing:10
  199. // anchors.centerIn: parent
  200. Rectangle{
  201. width:320
  202. height: 30
  203. color: "transparent"
  204. Row{
  205. spacing:30
  206. Label{
  207. text: "执行标准"
  208. //font.pixelSize: 24
  209. font.bold: true
  210. font.pixelSize: 20
  211. //color: "red"
  212. }
  213. UserComboBox{
  214. id:standard_name_comboBox
  215. //anchors.fill:parent
  216. implicitWidth: 100
  217. implicitHeight: 30
  218. bgColor:"#D2D5D9"
  219. model: ListModel{
  220. id:lmd
  221. }
  222. onCurrentTextChanged: {
  223. root.standard_name = currentText
  224. console.log("choose standard: "+root.standard_name)
  225. }
  226. }
  227. }
  228. }
  229. UserButton{
  230. text: "标准管理"
  231. font.pixelSize: 20
  232. implicitHeight: 45
  233. implicitWidth: 120
  234. //Layout.leftMargin: -30
  235. //Layout.topMargin: 10
  236. onClicked: {
  237. var compMainPage = Qt.createComponent("PageStandard.qml")
  238. .createObject(main_window, {x:0, y:0, width:main_window.width, height:main_window.height});
  239. }
  240. }
  241. }
  242. /*
  243. GridLayout{
  244. anchors.centerIn: parent
  245. columns: 2
  246. rows:2
  247. //columnSpacing: 10
  248. //rowSpacing: 5
  249. //Layout.rowSpan: 10
  250. Label{
  251. text: "执行标准"
  252. //width:120
  253. //height: 40
  254. //font.pixelSize: 24
  255. font.bold: true
  256. font.pixelSize: 20
  257. //color: "red"
  258. }
  259. //Rectangle{
  260. // id:rectcom1
  261. // implicitWidth: 100
  262. // implicitHeight:30
  263. UserComboBox{
  264. id:standard_name_comboBox
  265. //anchors.fill:parent
  266. implicitWidth: 100
  267. implicitHeight: 30
  268. bgColor:"#D2D5D9"
  269. model: ListModel{
  270. id:lmd
  271. }
  272. onCurrentTextChanged: {
  273. root.standard_name = currentText
  274. console.log("choose standard: "+root.standard_name)
  275. }
  276. }
  277. // }
  278. UserButton{
  279. text: "标准管理"
  280. font.pixelSize: 24
  281. implicitHeight: 120
  282. implicitWidth: 140
  283. //Layout.leftMargin: -30
  284. //Layout.topMargin: 10
  285. onClicked: {
  286. var compMainPage = Qt.createComponent("PageStandard.qml")
  287. .createObject(main_window, {x:0, y:0, width:main_window.width, height:main_window.height});
  288. }
  289. }
  290. }
  291. */
  292. }
  293. DynamicGroupBox{
  294. id:tankinfo
  295. title: "罐车信息"
  296. width: 360
  297. height: 320
  298. //anchors.centerIn: parent
  299. //Layout.horizontalCenter: parent.horizontalCenter
  300. //Layout.verticalCenter: parent.verticalCenter
  301. ColumnLayout{
  302. anchors.centerIn: parent
  303. spacing: 20
  304. Column{
  305. spacing: 10
  306. //Layout.alignment: Qt.AlignLeft
  307. InputLine{
  308. id:manufactureInputLine
  309. paraName: " 车辆单位:"
  310. paraLength: 200
  311. onTextChanged: {
  312. root.company = text
  313. }
  314. }
  315. InputLine{
  316. id:carplate
  317. paraName: " 车牌号:"
  318. paraLength: 200
  319. onTextChanged: {
  320. root.licenseplate = text
  321. }
  322. }
  323. InputLine{
  324. id:t_volume
  325. paraName: "总容积 (L):"
  326. text: "0"
  327. paraLength: 200
  328. validator:RegExpValidator {
  329. regExp: /[0-9]*/
  330. }
  331. onTextChanged: {
  332. if(text.length > 0){
  333. root.total_volume = Number(text)
  334. if(0 == root.compartment_num){
  335. compartment.text = "1"
  336. }
  337. root.caculate_volume()
  338. }else{
  339. root.total_volume=0
  340. }
  341. }
  342. }
  343. InputLine{
  344. id:compartment
  345. paraName: " 仓 数:"
  346. text: "1"
  347. paraLength: 200
  348. validator:IntValidator {
  349. bottom:1;
  350. top:8
  351. }
  352. onTextChanged: {
  353. if(text.length > 0){
  354. var n = Number(text);
  355. if(n >0 && n<5 ){
  356. root.compartment_num = Number(text)
  357. root.caculate_volume()
  358. //console.log("compartment:"+text)
  359. }else{
  360. if(n >4){
  361. log.show("仓数不能大于4")
  362. text="4"
  363. }
  364. if(n === 0){
  365. text="1"
  366. }
  367. }
  368. }else{
  369. root.compartment_num=0;
  370. }
  371. }
  372. }
  373. }
  374. GridLayout{
  375. //anchors.centerIn: parent
  376. columns: 2
  377. rows:4
  378. columnSpacing: 20
  379. rowSpacing: 5
  380. //Layout.rowSpan: 5
  381. InputLine{
  382. id:rectvolume_1
  383. paraName: "1仓:"
  384. text: "0"
  385. paraLength: 80
  386. validator:RegExpValidator {
  387. regExp: /[0-9]*/
  388. }
  389. onTextChanged: {
  390. root.volume_arry[0] = Number(text)
  391. //console.log("1:volume[%d]", root.volume_arry[0])
  392. }
  393. }
  394. InputLine{
  395. id:rectvolume_2
  396. paraName: "2仓:"
  397. text: "0"
  398. paraLength: 80
  399. validator:RegExpValidator {
  400. regExp: /[0-9]*/
  401. }
  402. onTextChanged: {
  403. root.volume_arry[1] = Number(text)
  404. }
  405. }
  406. InputLine{
  407. id:rectvolume_3
  408. paraName: "3仓:"
  409. text: "0"
  410. paraLength: 80
  411. validator:RegExpValidator {
  412. regExp: /[0-9]*/
  413. }
  414. onTextChanged: {
  415. root.volume_arry[2] = Number(text)
  416. }
  417. }
  418. InputLine{
  419. id:rectvolume_4
  420. paraName: "4仓:"
  421. text: "0"
  422. paraLength: 80
  423. validator:RegExpValidator {
  424. regExp: /[0-9]*/
  425. }
  426. onTextChanged: {
  427. root.volume_arry[3] = Number(text)
  428. }
  429. }
  430. InputLine{
  431. id:rectvolume_5
  432. paraName: "5仓:"
  433. text: "0"
  434. paraLength: 60
  435. visible: false
  436. validator:RegExpValidator {
  437. regExp: /[0-9]*/
  438. }
  439. onTextChanged: {
  440. root.volume_arry[4] = Number(text)
  441. }
  442. }
  443. InputLine{
  444. id:rectvolume_6
  445. paraName: "6仓:"
  446. text: "0"
  447. paraLength: 60
  448. visible: false
  449. validator:RegExpValidator {
  450. regExp: /[0-9]*/
  451. }
  452. onTextChanged: {
  453. root.volume_arry[5] = Number(text)
  454. }
  455. }
  456. InputLine{
  457. id:rectvolume_7
  458. paraName: "7仓:"
  459. text: "0"
  460. paraLength: 60
  461. visible: false
  462. validator:RegExpValidator {
  463. regExp: /[0-9]*/
  464. }
  465. onTextChanged: {
  466. root.volume_arry[6] = Number(text)
  467. }
  468. }
  469. InputLine{
  470. id:rectvolume_8
  471. paraName: "8仓:"
  472. text: "0"
  473. paraLength: 60
  474. visible: false
  475. validator:RegExpValidator {
  476. regExp: /[0-9]*/
  477. }
  478. onTextChanged: {
  479. root.volume_arry[7] = Number(text)
  480. }
  481. }
  482. }
  483. }
  484. }
  485. }
  486. DynamicGroupBox{
  487. id:visual_inspection
  488. title: "外观检查"
  489. //anchors.centerIn: parent
  490. width: 820
  491. height: 500
  492. Row{
  493. spacing:10
  494. DynamicGroupBox{
  495. id:visual_VRS
  496. title: "油气回收系统"
  497. titleFontPixel:18
  498. //anchors.centerIn: parent
  499. width: 390
  500. height: 450
  501. UserTableView{
  502. id:table_vrs
  503. table_name: "vrs"
  504. anchors.fill:parent
  505. }
  506. }
  507. DynamicGroupBox{
  508. id:visual_BLS
  509. title: "底部装油系统"
  510. titleFontPixel:18
  511. //anchors.centerIn: parent
  512. width: 390
  513. height: 450
  514. UserTableView{
  515. id:table_bls
  516. table_name: "bls"
  517. anchors.fill:parent
  518. }
  519. }
  520. }
  521. }
  522. }
  523. }
  524. Rectangle{
  525. Layout.alignment: Qt.AlignBottom
  526. Layout.fillWidth: true
  527. color: "transparent"
  528. Layout.preferredHeight: 100
  529. Layout.preferredWidth: 300
  530. UserButton {
  531. id: prev_step
  532. text: "返回首页"
  533. height: 60
  534. width: 160
  535. font.pixelSize: 24
  536. anchors.left: parent.left;
  537. anchors.leftMargin: 40;
  538. anchors.bottom: parent.bottom;
  539. anchors.bottomMargin: 10;
  540. onClicked: myLoder.sourceComponent = null // 切换显示主页面
  541. }
  542. UserButton {
  543. id: self_test
  544. text: "系统自测"
  545. height: 60
  546. width: 160
  547. font.pixelSize: 24
  548. anchors.left: prev_step.right;
  549. anchors.leftMargin: 540;
  550. anchors.bottom: parent.bottom;
  551. anchors.bottomMargin: 10;
  552. onClicked:{
  553. //var varPage = Qt.createComponent("PageLeakageInput.qml")
  554. // .createObject(main_window, {x:0, y:0, width:main_window.width/2, height:main_window.height/2});
  555. var compMainPage = Qt.createComponent("PageSelfTest.qml")
  556. .createObject(main_window, {x:0, y:0, width:main_window.width, height:main_window.height});
  557. //popupCenter.raiseItem = com_leakage
  558. //popupCenter.open()
  559. }
  560. }
  561. UserButton {
  562. id: next_step;
  563. text: "进入检测";
  564. //visible: false
  565. font.pixelSize: 24
  566. anchors.right: parent.right;
  567. anchors.rightMargin: 60;
  568. anchors.bottom: parent.bottom;
  569. anchors.bottomMargin: 10;
  570. height: 60
  571. width: 160
  572. onClicked: {
  573. //log.show(utr.state)
  574. //console.log("state ==== 1111");
  575. if(root.check_invalid()){
  576. var infoArry = [];
  577. standard_name = standard_name_comboBox.currentText;
  578. infoArry.push(standard_name)
  579. infoArry.push(licenseplate);
  580. infoArry.push(company);
  581. infoArry.push(total_volume);
  582. infoArry.push(compartment_num);
  583. for(var i=0; i<4; i++){
  584. infoArry.push(volume_arry[i])
  585. }
  586. var ret = testService.setTankinfo(infoArry);
  587. if(false === ret){
  588. log.show("设置罐车参数不成功")
  589. }else{
  590. for(var n=0; n<4; n++){
  591. switch(n){
  592. case 0:
  593. page_recoveryvalve1.volume = volume_arry[n]
  594. page_recoveryvalve1.organize = company
  595. page_recoveryvalve1.carplate = licenseplate
  596. page_recoveryvalve1.total_volume = total_volume
  597. break
  598. case 1:
  599. page_recoveryvalve2.volume = volume_arry[n]
  600. page_recoveryvalve2.organize = company
  601. page_recoveryvalve2.carplate = licenseplate
  602. page_recoveryvalve2.total_volume = total_volume
  603. break
  604. case 2:
  605. page_recoveryvalve3.volume = volume_arry[n]
  606. page_recoveryvalve3.organize = company
  607. page_recoveryvalve3.carplate = licenseplate
  608. page_recoveryvalve3.total_volume = total_volume
  609. break
  610. case 3:
  611. page_recoveryvalve4.volume = volume_arry[n]
  612. page_recoveryvalve4.organize = company
  613. page_recoveryvalve4.carplate = licenseplate
  614. page_recoveryvalve4.total_volume = total_volume
  615. break
  616. /*
  617. case 4:
  618. page_recoveryvalve5.volume = volume_arry[n]
  619. page_recoveryvalve5.organize = company
  620. page_recoveryvalve5.carplate = licenseplate
  621. page_recoveryvalve5.total_volume = total_volume
  622. break
  623. case 5:
  624. page_recoveryvalve6.volume = volume_arry[n]
  625. page_recoveryvalve6.organize = company
  626. page_recoveryvalve6.carplate = licenseplate
  627. page_recoveryvalve6.total_volume = total_volume
  628. break
  629. case 6:
  630. page_recoveryvalve7.volume = volume_arry[n]
  631. page_recoveryvalve7.organize = company
  632. page_recoveryvalve7.carplate = licenseplate
  633. page_recoveryvalve7.total_volume = total_volume
  634. break
  635. case 7:
  636. page_recoveryvalve8.volume = volume_arry[n]
  637. page_recoveryvalve8.organize = company
  638. page_recoveryvalve8.carplate = licenseplate
  639. page_recoveryvalve8.total_volume = total_volume
  640. break
  641. */
  642. }
  643. }
  644. swipeView.changePages(compartment_num)
  645. swipeView.incrementCurrentIndex();
  646. //swipeView.incrementCurrentIndex();
  647. }
  648. }else{
  649. //log.show("体积或仓数,不正确")
  650. }
  651. }
  652. }
  653. }
  654. }
  655. }
  656. // }
  657. Component.onCompleted: {
  658. var jsonObj = StandardManager.get_names()
  659. lmd.clear()
  660. for(var i=0; i<jsonObj.num; i++){
  661. //console.log("name ===="+jsonArry.names[i]);
  662. lmd.append({text:jsonObj.names[i]})
  663. }
  664. standard_name_comboBox.currentIndex = 0
  665. var jsonObj_vrs = testService.get_vrs_items()
  666. for(var j=0; j<jsonObj_vrs.count; j++){
  667. table_vrs.add_item(jsonObj_vrs.item[j])
  668. }
  669. var jsonObj_bls = testService.get_bls_items()
  670. for( j=0; j<jsonObj_bls.count; j++){
  671. table_bls.add_item(jsonObj_bls.item[j])
  672. }
  673. }
  674. }