PageStandard.qml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  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. Column {
  88. id: column
  89. //width: 600
  90. //height:600
  91. spacing: 40
  92. anchors.centerIn: parent
  93. Row {
  94. id: row
  95. //width: 600
  96. //height: 500
  97. spacing: 30
  98. DynamicGroupBox{
  99. id:groupbox_list
  100. width: 150
  101. height: 400
  102. //anchors.centerIn: parent
  103. //anchors.fill: parent
  104. title: "标准列表"
  105. //Rectangle{
  106. // id:rect_list
  107. // width: 120
  108. // height: 400
  109. // anchors.margins: 10
  110. // color: "white"
  111. // radius: 6
  112. // border.color: "black"
  113. ListView {
  114. //anchors.fill: parent
  115. anchors.centerIn: parent
  116. id: standard_listView
  117. width: 120
  118. height: 360
  119. model: ListModel{
  120. id: lmd
  121. }
  122. delegate: ItemDelegate {
  123. text: modelData
  124. font.bold: true
  125. font.pixelSize: 24
  126. highlighted: ListView.isCurrentItem
  127. Binding {
  128. target: background
  129. property: "color"
  130. //value: highlighted ? "#81A3CF" : "#B3B2B2"
  131. value:highlighted ? "#C9DDF8" : "#B3B2B2"
  132. }
  133. //text: model.index + (highlighted ? " [highlighted]" : "")
  134. //contentItem.color: "black"
  135. Binding {
  136. target: contentItem
  137. property: "color"
  138. value: "black"
  139. }
  140. onClicked:{
  141. standard_listView.currentIndex = index
  142. update_detail()
  143. }
  144. }
  145. }
  146. // }
  147. }
  148. Rectangle{
  149. id: rect_ops
  150. width: 180
  151. height: 400
  152. //anchors.margins: 10
  153. color: "transparent"
  154. //radius: 6
  155. //border.color: "black"
  156. Column{
  157. //anchors.fill: parent
  158. anchors.centerIn: parent
  159. spacing: 20
  160. UserButton {
  161. id: addButton
  162. text: "添加/修改"
  163. width: 180
  164. height: 60
  165. onClicked: {
  166. var standardJson={}
  167. var itemArrayJson=[]
  168. if(check_volume()){
  169. standardJson.name = std_name.text
  170. standardJson.ptv = std_PTV
  171. standardJson.ntv = std_NTV
  172. standardJson.intervals = std_interval
  173. standardJson.count = 4
  174. for(var i=0; i<4; i++){
  175. var item={}
  176. item.volume = volume[i]
  177. item.s_threshold=s_threshold[i]
  178. item.v_threshold=v_threshold[i]
  179. itemArrayJson[i] = item
  180. }
  181. standardJson.item = itemArrayJson
  182. StandardManager.add_standard(JSON.stringify(standardJson) );
  183. update_listView()
  184. }else{
  185. log.show("容积必须从大到小降序排列")
  186. }
  187. }
  188. }
  189. UserButton {
  190. id: removeButton
  191. text: "删除"
  192. width: 180
  193. height: 60
  194. onClicked: {
  195. var jsontmp = standard_listView.model.get(standard_listView.currentIndex)
  196. StandardManager.remove_standard(jsontmp.text);
  197. update_listView()
  198. }
  199. }
  200. }
  201. }
  202. DynamicGroupBox{
  203. id:groupbox_detail
  204. width: 640
  205. height: 400
  206. //anchors.centerIn: parent
  207. //anchors.fill: parent
  208. title: "标准详情"
  209. Column{
  210. spacing:10
  211. InputLine{
  212. id:std_name
  213. paraName: "标准名称:"
  214. paraLength: 160
  215. onTextChanged: {
  216. stdname_str=text
  217. }
  218. }
  219. Row{
  220. spacing:30
  221. InputLine{
  222. id:std_positive_target
  223. paraName: "正压目标值(Kpa):"
  224. paraLength: 60
  225. onTextChanged: {
  226. std_PTV = Number(text)
  227. }
  228. }
  229. InputLine{
  230. id:std_negative_target
  231. paraName: "负压目标值(Kpa):"
  232. paraLength: 60
  233. onTextChanged: {
  234. std_NTV = Number(text)
  235. }
  236. }
  237. }
  238. InputLine{
  239. id:std_intervaltime
  240. paraName: "测量间隔(秒):"
  241. paraLength: 60
  242. onTextChanged: {
  243. std_interval = Number(text)
  244. }
  245. }
  246. GridLayout {
  247. id: grid
  248. columns: 3
  249. columnSpacing: 30
  250. rows:5
  251. rowSpacing: 10
  252. Text { text: "单个油仓容积V(L)"; font.bold: true; font.pointSize: 12; wrapMode: Text.WrapAnywhere; Layout.maximumWidth: 180}
  253. Text { text: "油气回收系统压力变动限值(Kpa)"; font.bold: true; font.pointSize: 12; wrapMode: Text.WrapAnywhere; Layout.maximumWidth: 180}
  254. Text { text: "油气回收阀压力变动限值(Kpa)"; font.bold: true; font.pointSize: 12; wrapMode: Text.WrapAnywhere; Layout.maximumWidth: 180}
  255. //level 1
  256. InputLine{
  257. id:level1_v
  258. paraName: " V≥ "
  259. paraLength: para_len
  260. validator:RegExpValidator {
  261. regExp: /[0-9]*/
  262. }
  263. onTextChanged: {
  264. volume[0] = Number(text)
  265. //console.log("level1 volume[0] == " + volume[0]);
  266. }
  267. }
  268. InputLine{
  269. id:level1_st
  270. paraName: " ≤ "
  271. paraLength: para_len
  272. onTextChanged: {
  273. s_threshold[0] = Number(text)
  274. //console.log("level1 s_threshold[0] == " + s_threshold[0]);
  275. }
  276. }
  277. InputLine{
  278. id:level1_vt
  279. paraName: " ≤ "
  280. paraLength: para_len
  281. onTextChanged: {
  282. v_threshold[0] = Number(text)
  283. }
  284. }
  285. //level 2
  286. InputLine{
  287. id:level2_v
  288. paraName: " V≥ "
  289. paraLength: para_len
  290. validator:RegExpValidator {
  291. regExp: /[0-9]*/
  292. }
  293. onTextChanged: {
  294. volume[1] = Number(text)
  295. }
  296. }
  297. InputLine{
  298. id:level2_st
  299. paraName: " ≤ "
  300. paraLength: para_len
  301. onTextChanged: {
  302. s_threshold[1] = Number(text)
  303. }
  304. }
  305. InputLine{
  306. id:level2_vt
  307. paraName: " ≤ "
  308. paraLength: para_len
  309. onTextChanged: {
  310. v_threshold[1] = Number(text)
  311. }
  312. }
  313. //level 3
  314. InputLine{
  315. id:level3_v
  316. paraName: " V≥ "
  317. paraLength: para_len
  318. validator:RegExpValidator {
  319. regExp: /[0-9]*/
  320. }
  321. onTextChanged: {
  322. volume[2] = Number(text)
  323. }
  324. }
  325. InputLine{
  326. id:level3_st
  327. paraName: " ≤ "
  328. paraLength: para_len
  329. onTextChanged: {
  330. s_threshold[2] = Number(text)
  331. }
  332. }
  333. InputLine{
  334. id:level3_vt
  335. paraName: " ≤ "
  336. paraLength: para_len
  337. onTextChanged: {
  338. v_threshold[2] = Number(text)
  339. }
  340. }
  341. //level 4
  342. InputLine{
  343. id:level4_v
  344. paraName: " V≥ "
  345. paraLength: para_len
  346. validator:RegExpValidator {
  347. regExp: /[0-9]*/
  348. }
  349. text:"0"
  350. onTextChanged: {
  351. volume[3] = Number(text)
  352. }
  353. }
  354. InputLine{
  355. id:level4_st
  356. paraName: " ≤ "
  357. paraLength: para_len
  358. onTextChanged: {
  359. s_threshold[3] = Number(text)
  360. }
  361. }
  362. InputLine{
  363. id:level4_vt
  364. paraName: " ≤ "
  365. paraLength: para_len
  366. onTextChanged: {
  367. v_threshold[3] = Number(text)
  368. }
  369. }
  370. }
  371. }
  372. }
  373. }
  374. UserButton {
  375. id: exitButton
  376. text: "退出"
  377. width: 120
  378. height: 60
  379. //anchors.horizontalCenter: parent
  380. onClicked: {
  381. page_set.update_standard()
  382. standard_root.destroy()
  383. }
  384. }
  385. }
  386. }
  387. Component.onCompleted: {
  388. update_listView()
  389. standard_listView.currentIndex = 0;
  390. update_detail()
  391. }
  392. }