123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478 |
- import QtQuick 2.15
- import QtQuick.Layouts 1.3
- import QtQuick.Controls 2.14
- import QtQuick.Controls.Styles 1.2
- import TService 1.0
- Item {
- id: standard_root
- //property var pagetype:rootitem.Page_Type_Testing
- property string title_str:"标准管理"
- property int para_len: 80
- property string stdname_str:""
- property double std_PTV: 0.0
- property double std_NTV: 0.0
- property var volume: [0,0,0,0]
- property var s_threshold: [0.0, 0.0, 0.0, 0.0]
- property var v_threshold: [0.0, 0.0, 0.0, 0.0]
- function check_volume(){
- for(var i=0; i<4-1; i++){
- var v = volume[i]
- for(var j=i+1; j<4; j++){
- if(v < volume[j]){
- return false
- }
- }
- }
- return true
- }
- function update_listView(){
- var jsonObj = StandardManager.get_names();
- lmd.clear()
- for(var i=0; i<jsonObj.num; i++){
- lmd.append({text:jsonObj.names[i]})
- }
- }
- function update_detail(){
- var jsontmp = standard_listView.model.get(standard_listView.currentIndex)
- //console.log("the index = "+index+", standardname = "+ jsontmp.text);
- jsontmp = StandardManager.get_standard(jsontmp.text);
- //console.log("the count = " + jsontmp.count +", json str:"+ JSON.stringify(jsontmp));
- std_name.text = jsontmp.name
- std_positive_target.text = jsontmp.ptv
- std_negative_target.text = jsontmp.ntv
- if(jsontmp.count === 1){
- level1_v.text = jsontmp.item[0].volume
- level1_st.text = jsontmp.item[0].s_threshold
- level1_vt.text = jsontmp.item[0].v_threshold
- }else if(jsontmp.count === 2){
- level1_v.text = jsontmp.item[0].volume
- level1_st.text = jsontmp.item[0].s_threshold
- level1_vt.text = jsontmp.item[0].v_threshold
- level2_v.text = jsontmp.item[1].volume
- level2_st.text = jsontmp.item[1].s_threshold
- level2_vt.text = jsontmp.item[1].v_threshold
- }else if(jsontmp.count === 3){
- level1_v.text = jsontmp.item[0].volume
- level1_st.text = jsontmp.item[0].s_threshold
- level1_vt.text = jsontmp.item[0].v_threshold
- level2_v.text = jsontmp.item[1].volume
- level2_st.text = jsontmp.item[1].s_threshold
- level2_vt.text = jsontmp.item[1].v_threshold
- level3_v.text = jsontmp.item[2].volume
- level3_st.text = jsontmp.item[2].s_threshold
- level3_vt.text = jsontmp.item[2].v_threshold
- }else if(jsontmp.count === 4){
- level1_v.text = jsontmp.item[0].volume
- level1_st.text = jsontmp.item[0].s_threshold
- level1_vt.text = jsontmp.item[0].v_threshold
- level2_v.text = jsontmp.item[1].volume
- level2_st.text = jsontmp.item[1].s_threshold
- level2_vt.text = jsontmp.item[1].v_threshold
- level3_v.text = jsontmp.item[2].volume
- level3_st.text = jsontmp.item[2].s_threshold
- level3_vt.text = jsontmp.item[2].v_threshold
- level4_v.text = jsontmp.item[3].volume
- level4_st.text = jsontmp.item[3].s_threshold
- level4_vt.text = jsontmp.item[3].v_threshold
- //console.log("the index = "+index+", tvolume[0] = "+ tvolume +", volume[0]"+ volume[0]);
- }
- }
- DynamicGroupBox{
- id:groupbox_all
- anchors.centerIn: parent
- anchors.fill: parent
- title: title_str
- Column {
- id: column
- //width: 600
- //height:600
- spacing: 40
- anchors.centerIn: parent
- Row {
- id: row
- //width: 600
- //height: 500
- spacing: 30
- DynamicGroupBox{
- id:groupbox_list
- width: 150
- height: 400
- //anchors.centerIn: parent
- //anchors.fill: parent
- title: "标准列表"
- //Rectangle{
- // id:rect_list
- // width: 120
- // height: 400
- // anchors.margins: 10
- // color: "white"
- // radius: 6
- // border.color: "black"
- ListView {
- //anchors.fill: parent
- anchors.centerIn: parent
- id: standard_listView
- width: 120
- height: 360
- model: ListModel{
- id: lmd
- }
- delegate: ItemDelegate {
- text: modelData
- font.bold: true
- font.pixelSize: 24
- highlighted: ListView.isCurrentItem
- Binding {
- target: background
- property: "color"
- //value: highlighted ? "#81A3CF" : "#B3B2B2"
- value:highlighted ? "#C9DDF8" : "#B3B2B2"
- }
- //text: model.index + (highlighted ? " [highlighted]" : "")
- //contentItem.color: "black"
- Binding {
- target: contentItem
- property: "color"
- value: "black"
- }
- onClicked:{
- standard_listView.currentIndex = index
- update_detail()
- }
- }
- }
- // }
- }
- Rectangle{
- id: rect_ops
- width: 180
- height: 400
- //anchors.margins: 10
- color: "transparent"
- //radius: 6
- //border.color: "black"
- Column{
- //anchors.fill: parent
- anchors.centerIn: parent
- spacing: 20
- UserButton {
- id: addButton
- text: "添加/修改"
- width: 180
- height: 60
- onClicked: {
- var standardJson={}
- var itemArrayJson=[]
- if(check_volume()){
- standardJson.name = std_name.text
- standardJson.ptv = std_PTV
- standardJson.ntv = std_NTV
- standardJson.count = 4
- for(var i=0; i<4; i++){
- var item={}
- item.volume = volume[i]
- item.s_threshold=s_threshold[i]
- item.v_threshold=v_threshold[i]
- itemArrayJson[i] = item
- }
- standardJson.item = itemArrayJson
- StandardManager.add_standard(JSON.stringify(standardJson) );
- update_listView()
- }else{
- log.show("容积必须从大到小降序排列")
- }
- }
- }
- UserButton {
- id: removeButton
- text: "删除"
- width: 180
- height: 60
- onClicked: {
- var jsontmp = standard_listView.model.get(standard_listView.currentIndex)
- StandardManager.remove_standard(jsontmp.text);
- update_listView()
- }
- }
- }
- }
- DynamicGroupBox{
- id:groupbox_detail
- width: 640
- height: 400
- //anchors.centerIn: parent
- //anchors.fill: parent
- title: "标准详情"
- Column{
- spacing:10
- InputLine{
- id:std_name
- paraName: "标准名称:"
- paraLength: 160
- onTextChanged: {
- stdname_str=text
- }
- }
- Row{
- spacing:30
- InputLine{
- id:std_positive_target
- paraName: "正压目标值(Kpa):"
- paraLength: 60
- onTextChanged: {
- std_PTV = Number(text)
- }
- }
- InputLine{
- id:std_negative_target
- paraName: "负压目标值(Kpa):"
- paraLength: 60
- onTextChanged: {
- std_NTV = Number(text)
- }
- }
- }
- GridLayout {
- id: grid
- columns: 3
- columnSpacing: 30
- rows:5
- rowSpacing: 20
- Text { text: "单个油仓容积V(L)"; font.bold: true; font.pointSize: 12; wrapMode: Text.WrapAnywhere; Layout.maximumWidth: 180}
- Text { text: "油气回收系统压力变动限值(Kpa)"; font.bold: true; font.pointSize: 12; wrapMode: Text.WrapAnywhere; Layout.maximumWidth: 180}
- Text { text: "油气回收阀压力变动限值(Kpa)"; font.bold: true; font.pointSize: 12; wrapMode: Text.WrapAnywhere; Layout.maximumWidth: 180}
- //level 1
- InputLine{
- id:level1_v
- paraName: " V≥ "
- paraLength: para_len
- validator:RegExpValidator {
- regExp: /[0-9]*/
- }
- onTextChanged: {
- volume[0] = Number(text)
- //console.log("level1 volume[0] == " + volume[0]);
- }
- }
- InputLine{
- id:level1_st
- paraName: " ≤ "
- paraLength: para_len
- onTextChanged: {
- s_threshold[0] = Number(text)
- //console.log("level1 s_threshold[0] == " + s_threshold[0]);
- }
- }
- InputLine{
- id:level1_vt
- paraName: " ≤ "
- paraLength: para_len
- onTextChanged: {
- v_threshold[0] = Number(text)
- }
- }
- //level 2
- InputLine{
- id:level2_v
- paraName: " V≥ "
- paraLength: para_len
- validator:RegExpValidator {
- regExp: /[0-9]*/
- }
- onTextChanged: {
- volume[1] = Number(text)
- }
- }
- InputLine{
- id:level2_st
- paraName: " ≤ "
- paraLength: para_len
- onTextChanged: {
- s_threshold[1] = Number(text)
- }
- }
- InputLine{
- id:level2_vt
- paraName: " ≤ "
- paraLength: para_len
- onTextChanged: {
- v_threshold[1] = Number(text)
- }
- }
- //level 3
- InputLine{
- id:level3_v
- paraName: " V≥ "
- paraLength: para_len
- validator:RegExpValidator {
- regExp: /[0-9]*/
- }
- onTextChanged: {
- volume[2] = Number(text)
- }
- }
- InputLine{
- id:level3_st
- paraName: " ≤ "
- paraLength: para_len
- onTextChanged: {
- s_threshold[2] = Number(text)
- }
- }
- InputLine{
- id:level3_vt
- paraName: " ≤ "
- paraLength: para_len
- onTextChanged: {
- v_threshold[2] = Number(text)
- }
- }
- //level 4
- InputLine{
- id:level4_v
- paraName: " V≥ "
- paraLength: para_len
- validator:RegExpValidator {
- regExp: /[0-9]*/
- }
- text:"0"
- onTextChanged: {
- volume[3] = Number(text)
- }
- }
- InputLine{
- id:level4_st
- paraName: " ≤ "
- paraLength: para_len
- onTextChanged: {
- s_threshold[3] = Number(text)
- }
- }
- InputLine{
- id:level4_vt
- paraName: " ≤ "
- paraLength: para_len
- onTextChanged: {
- v_threshold[3] = Number(text)
- }
- }
- }
- }
- }
- }
- UserButton {
- id: exitButton
- text: "退出"
- width: 120
- height: 60
- //anchors.horizontalCenter: parent
- onClicked: {
- page_set.update_standard()
- standard_root.destroy()
- }
- }
- }
- }
- Component.onCompleted: {
- update_listView()
- standard_listView.currentIndex = 0;
- update_detail()
- }
- }
|