PageStandard.qml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  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 TService 1.0
  6. Item {
  7. id: standard_root
  8. //property var pagetype:rootitem.Page_Type_Testing
  9. property string title_str:"标准管理"
  10. property int para_len: 80
  11. property string stdname_str:""
  12. property double std_PTV: 0.0
  13. property double std_NTV: 0.0
  14. property double std_interval: 0
  15. property var volume: [0,0,0,0]
  16. property var s_threshold: [0.0, 0.0, 0.0, 0.0]
  17. property var v_threshold: [0.0, 0.0, 0.0, 0.0]
  18. function check_volume(){
  19. for(var i=0; i<4-1; i++){
  20. var v = volume[i]
  21. for(var j=i+1; j<4; j++){
  22. if(v < volume[j]){
  23. return false
  24. }
  25. }
  26. }
  27. return true
  28. }
  29. function update_listView(){
  30. var jsonObj = StandardManager.get_names();
  31. lmd.clear()
  32. for(var i=0; i<jsonObj.num; i++){
  33. lmd.append({text:jsonObj.names[i]})
  34. }
  35. }
  36. function update_detail(){
  37. var jsontmp = standard_listView.model.get(standard_listView.currentIndex)
  38. //console.log("the index = "+index+", standardname = "+ jsontmp.text);
  39. jsontmp = StandardManager.get_standard(jsontmp.text);
  40. //console.log("the count = " + jsontmp.count +", json str:"+ JSON.stringify(jsontmp));
  41. std_name.text = jsontmp.name
  42. std_positive_target.text = jsontmp.ptv
  43. std_negative_target.text = jsontmp.ntv
  44. std_intervaltime.text = jsontmp.intervals
  45. if(jsontmp.count === 1){
  46. level1_v.text = jsontmp.item[0].volume
  47. level1_st.text = jsontmp.item[0].s_threshold
  48. level1_vt.text = jsontmp.item[0].v_threshold
  49. }else if(jsontmp.count === 2){
  50. level1_v.text = jsontmp.item[0].volume
  51. level1_st.text = jsontmp.item[0].s_threshold
  52. level1_vt.text = jsontmp.item[0].v_threshold
  53. level2_v.text = jsontmp.item[1].volume
  54. level2_st.text = jsontmp.item[1].s_threshold
  55. level2_vt.text = jsontmp.item[1].v_threshold
  56. }else if(jsontmp.count === 3){
  57. level1_v.text = jsontmp.item[0].volume
  58. level1_st.text = jsontmp.item[0].s_threshold
  59. level1_vt.text = jsontmp.item[0].v_threshold
  60. level2_v.text = jsontmp.item[1].volume
  61. level2_st.text = jsontmp.item[1].s_threshold
  62. level2_vt.text = jsontmp.item[1].v_threshold
  63. level3_v.text = jsontmp.item[2].volume
  64. level3_st.text = jsontmp.item[2].s_threshold
  65. level3_vt.text = jsontmp.item[2].v_threshold
  66. }else if(jsontmp.count === 4){
  67. level1_v.text = jsontmp.item[0].volume
  68. level1_st.text = jsontmp.item[0].s_threshold
  69. level1_vt.text = jsontmp.item[0].v_threshold
  70. level2_v.text = jsontmp.item[1].volume
  71. level2_st.text = jsontmp.item[1].s_threshold
  72. level2_vt.text = jsontmp.item[1].v_threshold
  73. level3_v.text = jsontmp.item[2].volume
  74. level3_st.text = jsontmp.item[2].s_threshold
  75. level3_vt.text = jsontmp.item[2].v_threshold
  76. level4_v.text = jsontmp.item[3].volume
  77. level4_st.text = jsontmp.item[3].s_threshold
  78. level4_vt.text = jsontmp.item[3].v_threshold
  79. //console.log("the index = "+index+", tvolume[0] = "+ tvolume +", volume[0]"+ volume[0]);
  80. }
  81. }
  82. DynamicGroupBox{
  83. id:groupbox_all
  84. anchors.centerIn: parent
  85. anchors.fill: parent
  86. title: title_str
  87. Rectangle{
  88. id:rect_items
  89. //anchors.centerIn: parent
  90. //width: 1000
  91. //height: 700
  92. width: groupbox_all.width
  93. height: groupbox_all.height
  94. x:20
  95. y: !inputPanel.active ? 0 : Math.min(0, main_window.height - inputPanel.height - activeFocusItemBottom)
  96. Behavior on y {
  97. NumberAnimation {
  98. duration: 250
  99. easing.type: Easing.InOutQuad
  100. }
  101. }
  102. Column {
  103. id: column
  104. //width: 600
  105. //height:600
  106. spacing: 40
  107. anchors.centerIn: parent
  108. Row {
  109. id: row
  110. //width: 600
  111. //height: 500
  112. spacing: 30
  113. DynamicGroupBox{
  114. id:groupbox_list
  115. width: 150
  116. height: 400
  117. //anchors.centerIn: parent
  118. //anchors.fill: parent
  119. title: "标准列表"
  120. //Rectangle{
  121. // id:rect_list
  122. // width: 120
  123. // height: 400
  124. // anchors.margins: 10
  125. // color: "white"
  126. // radius: 6
  127. // border.color: "black"
  128. ListView {
  129. //anchors.fill: parent
  130. anchors.centerIn: parent
  131. id: standard_listView
  132. width: 120
  133. height: 360
  134. model: ListModel{
  135. id: lmd
  136. }
  137. delegate: ItemDelegate {
  138. text: modelData
  139. font.bold: true
  140. font.pixelSize: 24
  141. highlighted: ListView.isCurrentItem
  142. Binding {
  143. target: background
  144. property: "color"
  145. //value: highlighted ? "#81A3CF" : "#B3B2B2"
  146. value:highlighted ? "#C9DDF8" : "#B3B2B2"
  147. }
  148. //text: model.index + (highlighted ? " [highlighted]" : "")
  149. //contentItem.color: "black"
  150. Binding {
  151. target: contentItem
  152. property: "color"
  153. value: "black"
  154. }
  155. onClicked:{
  156. standard_listView.currentIndex = index
  157. update_detail()
  158. }
  159. }
  160. }
  161. // }
  162. }
  163. Rectangle{
  164. id: rect_ops
  165. width: 180
  166. height: 400
  167. //anchors.margins: 10
  168. color: "transparent"
  169. //radius: 6
  170. //border.color: "black"
  171. Column{
  172. //anchors.fill: parent
  173. anchors.centerIn: parent
  174. spacing: 20
  175. UserButton {
  176. id: addButton
  177. text: "添加/修改"
  178. width: 180
  179. height: 60
  180. onClicked: {
  181. var standardJson={}
  182. var itemArrayJson=[]
  183. if(check_volume()){
  184. standardJson.name = std_name.text
  185. standardJson.ptv = std_PTV
  186. standardJson.ntv = std_NTV
  187. standardJson.intervals = std_interval
  188. standardJson.count = 4
  189. for(var i=0; i<4; i++){
  190. var item={}
  191. item.volume = volume[i]
  192. item.s_threshold=s_threshold[i]
  193. item.v_threshold=v_threshold[i]
  194. itemArrayJson[i] = item
  195. }
  196. standardJson.item = itemArrayJson
  197. StandardManager.add_standard(JSON.stringify(standardJson) );
  198. update_listView()
  199. }else{
  200. log.show("容积必须从大到小降序排列")
  201. }
  202. }
  203. }
  204. UserButton {
  205. id: removeButton
  206. text: "删除"
  207. width: 180
  208. height: 60
  209. onClicked: {
  210. var jsontmp = standard_listView.model.get(standard_listView.currentIndex)
  211. StandardManager.remove_standard(jsontmp.text);
  212. update_listView()
  213. }
  214. }
  215. }
  216. }
  217. DynamicGroupBox{
  218. id:groupbox_detail
  219. width: 640
  220. height: 400
  221. //anchors.centerIn: parent
  222. //anchors.fill: parent
  223. title: "标准详情"
  224. Column{
  225. spacing:10
  226. InputLine{
  227. id:std_name
  228. paraName: "标准名称:"
  229. paraLength: 160
  230. onTextChanged: {
  231. stdname_str=text
  232. }
  233. }
  234. Row{
  235. spacing:30
  236. InputLine{
  237. id:std_positive_target
  238. paraName: "正压目标值(kPa):"
  239. paraLength: 60
  240. validator:RegExpValidator {
  241. regExp: /(-?[0-9]\d*((.\d+)*))*/
  242. }
  243. onTextChanged: {
  244. std_PTV = Number(text)
  245. }
  246. }
  247. InputLine{
  248. id:std_negative_target
  249. paraName: "负压目标值(kPa):"
  250. paraLength: 60
  251. validator:RegExpValidator {
  252. regExp: /(-?[0-9]\d*((.\d+)*))*/
  253. }
  254. onTextChanged: {
  255. std_NTV = Number(text)
  256. }
  257. }
  258. }
  259. InputLine{
  260. id:std_intervaltime
  261. paraName: "测量间隔(秒):"
  262. paraLength: 60
  263. validator:RegExpValidator {
  264. regExp: /[0-9]*/
  265. }
  266. onTextChanged: {
  267. std_interval = Number(text)
  268. }
  269. }
  270. GridLayout {
  271. id: grid
  272. columns: 3
  273. columnSpacing: 30
  274. rows:5
  275. rowSpacing: 10
  276. Text { text: "单个油仓容积V(L)"; font.bold: true; font.pointSize: 12; wrapMode: Text.WrapAnywhere; Layout.maximumWidth: 180}
  277. Text { text: "油气回收系统压力变动限值(kPa)"; font.bold: true; font.pointSize: 12; wrapMode: Text.WrapAnywhere; Layout.maximumWidth: 180}
  278. Text { text: "油气回收阀压力变动限值(kPa)"; font.bold: true; font.pointSize: 12; wrapMode: Text.WrapAnywhere; Layout.maximumWidth: 180}
  279. //level 1
  280. InputLine{
  281. id:level1_v
  282. paraName: " V≥ "
  283. paraLength: para_len
  284. validator:RegExpValidator {
  285. regExp: /[0-9]*/
  286. }
  287. onTextChanged: {
  288. volume[0] = Number(text)
  289. //console.log("level1 volume[0] == " + volume[0]);
  290. }
  291. }
  292. InputLine{
  293. id:level1_st
  294. paraName: " ≤ "
  295. paraLength: para_len
  296. validator:RegExpValidator {
  297. regExp: /(-?[0-9]\d*((.\d+)*))*/
  298. }
  299. onTextChanged: {
  300. s_threshold[0] = Number(text)
  301. //console.log("level1 s_threshold[0] == " + s_threshold[0]);
  302. }
  303. }
  304. InputLine{
  305. id:level1_vt
  306. paraName: " ≤ "
  307. paraLength: para_len
  308. validator:RegExpValidator {
  309. regExp: /(-?[0-9]\d*((.\d+)*))*/
  310. }
  311. onTextChanged: {
  312. v_threshold[0] = Number(text)
  313. }
  314. }
  315. //level 2
  316. InputLine{
  317. id:level2_v
  318. paraName: " V≥ "
  319. paraLength: para_len
  320. validator:RegExpValidator {
  321. regExp: /[0-9]*/
  322. }
  323. onTextChanged: {
  324. volume[1] = Number(text)
  325. }
  326. }
  327. InputLine{
  328. id:level2_st
  329. paraName: " ≤ "
  330. paraLength: para_len
  331. validator:RegExpValidator {
  332. regExp: /(-?[0-9]\d*((.\d+)*))*/
  333. }
  334. onTextChanged: {
  335. s_threshold[1] = Number(text)
  336. }
  337. }
  338. InputLine{
  339. id:level2_vt
  340. paraName: " ≤ "
  341. paraLength: para_len
  342. validator:RegExpValidator {
  343. regExp: /(-?[0-9]\d*((.\d+)*))*/
  344. }
  345. onTextChanged: {
  346. v_threshold[1] = Number(text)
  347. }
  348. }
  349. //level 3
  350. InputLine{
  351. id:level3_v
  352. paraName: " V≥ "
  353. paraLength: para_len
  354. validator:RegExpValidator {
  355. regExp: /[0-9]*/
  356. }
  357. onTextChanged: {
  358. volume[2] = Number(text)
  359. }
  360. }
  361. InputLine{
  362. id:level3_st
  363. paraName: " ≤ "
  364. paraLength: para_len
  365. validator:RegExpValidator {
  366. regExp: /(-?[0-9]\d*((.\d+)*))*/
  367. }
  368. onTextChanged: {
  369. s_threshold[2] = Number(text)
  370. }
  371. }
  372. InputLine{
  373. id:level3_vt
  374. paraName: " ≤ "
  375. paraLength: para_len
  376. validator:RegExpValidator {
  377. regExp: /(-?[0-9]\d*((.\d+)*))*/
  378. }
  379. onTextChanged: {
  380. v_threshold[2] = Number(text)
  381. }
  382. }
  383. //level 4
  384. InputLine{
  385. id:level4_v
  386. paraName: " V≥ "
  387. paraLength: para_len
  388. validator:RegExpValidator {
  389. regExp:/[0-9]*/
  390. }
  391. text:"0"
  392. onTextChanged: {
  393. volume[3] = Number(text)
  394. }
  395. }
  396. InputLine{
  397. id:level4_st
  398. paraName: " ≤ "
  399. paraLength: para_len
  400. validator:RegExpValidator {
  401. regExp: /(-?[0-9]\d*((.\d+)*))*/
  402. }
  403. onTextChanged: {
  404. s_threshold[3] = Number(text)
  405. }
  406. }
  407. InputLine{
  408. id:level4_vt
  409. paraName: " ≤ "
  410. paraLength: para_len
  411. validator:RegExpValidator {
  412. regExp: /(-?[0-9]\d*((.\d+)*))*/
  413. }
  414. onTextChanged: {
  415. v_threshold[3] = Number(text)
  416. }
  417. }
  418. }
  419. }
  420. }
  421. }
  422. UserButton {
  423. id: exitButton
  424. text: "退出"
  425. width: 120
  426. height: 60
  427. //anchors.horizontalCenter: parent
  428. onClicked: {
  429. page_set.update_standard()
  430. standard_root.destroy()
  431. }
  432. }
  433. }
  434. }
  435. }
  436. Component.onCompleted: {
  437. update_listView()
  438. standard_listView.currentIndex = 0;
  439. update_detail()
  440. }
  441. }