PageSetting.qml 31 KB

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