PageStandard.qml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  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. onTextChanged: {
  241. std_PTV = Number(text)
  242. }
  243. }
  244. InputLine{
  245. id:std_negative_target
  246. paraName: "负压目标值(kPa):"
  247. paraLength: 60
  248. onTextChanged: {
  249. std_NTV = Number(text)
  250. }
  251. }
  252. }
  253. InputLine{
  254. id:std_intervaltime
  255. paraName: "测量间隔(秒):"
  256. paraLength: 60
  257. onTextChanged: {
  258. std_interval = Number(text)
  259. }
  260. }
  261. GridLayout {
  262. id: grid
  263. columns: 3
  264. columnSpacing: 30
  265. rows:5
  266. rowSpacing: 10
  267. Text { text: "单个油仓容积V(L)"; font.bold: true; font.pointSize: 12; wrapMode: Text.WrapAnywhere; Layout.maximumWidth: 180}
  268. Text { text: "油气回收系统压力变动限值(kPa)"; font.bold: true; font.pointSize: 12; wrapMode: Text.WrapAnywhere; Layout.maximumWidth: 180}
  269. Text { text: "油气回收阀压力变动限值(kPa)"; font.bold: true; font.pointSize: 12; wrapMode: Text.WrapAnywhere; Layout.maximumWidth: 180}
  270. //level 1
  271. InputLine{
  272. id:level1_v
  273. paraName: " V≥ "
  274. paraLength: para_len
  275. validator:RegExpValidator {
  276. regExp: /[0-9]*/
  277. }
  278. onTextChanged: {
  279. volume[0] = Number(text)
  280. //console.log("level1 volume[0] == " + volume[0]);
  281. }
  282. }
  283. InputLine{
  284. id:level1_st
  285. paraName: " ≤ "
  286. paraLength: para_len
  287. onTextChanged: {
  288. s_threshold[0] = Number(text)
  289. //console.log("level1 s_threshold[0] == " + s_threshold[0]);
  290. }
  291. }
  292. InputLine{
  293. id:level1_vt
  294. paraName: " ≤ "
  295. paraLength: para_len
  296. onTextChanged: {
  297. v_threshold[0] = Number(text)
  298. }
  299. }
  300. //level 2
  301. InputLine{
  302. id:level2_v
  303. paraName: " V≥ "
  304. paraLength: para_len
  305. validator:RegExpValidator {
  306. regExp: /[0-9]*/
  307. }
  308. onTextChanged: {
  309. volume[1] = Number(text)
  310. }
  311. }
  312. InputLine{
  313. id:level2_st
  314. paraName: " ≤ "
  315. paraLength: para_len
  316. onTextChanged: {
  317. s_threshold[1] = Number(text)
  318. }
  319. }
  320. InputLine{
  321. id:level2_vt
  322. paraName: " ≤ "
  323. paraLength: para_len
  324. onTextChanged: {
  325. v_threshold[1] = Number(text)
  326. }
  327. }
  328. //level 3
  329. InputLine{
  330. id:level3_v
  331. paraName: " V≥ "
  332. paraLength: para_len
  333. validator:RegExpValidator {
  334. regExp: /[0-9]*/
  335. }
  336. onTextChanged: {
  337. volume[2] = Number(text)
  338. }
  339. }
  340. InputLine{
  341. id:level3_st
  342. paraName: " ≤ "
  343. paraLength: para_len
  344. onTextChanged: {
  345. s_threshold[2] = Number(text)
  346. }
  347. }
  348. InputLine{
  349. id:level3_vt
  350. paraName: " ≤ "
  351. paraLength: para_len
  352. onTextChanged: {
  353. v_threshold[2] = Number(text)
  354. }
  355. }
  356. //level 4
  357. InputLine{
  358. id:level4_v
  359. paraName: " V≥ "
  360. paraLength: para_len
  361. validator:RegExpValidator {
  362. regExp: /[0-9]*/
  363. }
  364. text:"0"
  365. onTextChanged: {
  366. volume[3] = Number(text)
  367. }
  368. }
  369. InputLine{
  370. id:level4_st
  371. paraName: " ≤ "
  372. paraLength: para_len
  373. onTextChanged: {
  374. s_threshold[3] = Number(text)
  375. }
  376. }
  377. InputLine{
  378. id:level4_vt
  379. paraName: " ≤ "
  380. paraLength: para_len
  381. onTextChanged: {
  382. v_threshold[3] = Number(text)
  383. }
  384. }
  385. }
  386. }
  387. }
  388. }
  389. UserButton {
  390. id: exitButton
  391. text: "退出"
  392. width: 120
  393. height: 60
  394. //anchors.horizontalCenter: parent
  395. onClicked: {
  396. page_set.update_standard()
  397. standard_root.destroy()
  398. }
  399. }
  400. }
  401. }
  402. }
  403. Component.onCompleted: {
  404. update_listView()
  405. standard_listView.currentIndex = 0;
  406. update_detail()
  407. }
  408. }