PageStandard.qml 16 KB

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