import QtQuick import QtQuick.Layouts import QtQuick.Controls import QtQuick.Shapes import QtQuick.Dialogs import "./app.js" as App import "./common" Rectangle { id: root property var appId: App.appId property var plusFile: App.plusFile property var g_user: "" property var g_sn: "8441" property var appPath: "/"+plusFile+"/"+appId+"/" property var firstPath: "" Component.onCompleted: { firstPath = common.firstPath() g_user = common.getCurrentUser() common.initAppScript(appId, "hsvp", "hsvp.py", plusFile) } onVisibleChanged: { if(visible) { g_user = common.getCurrentUser() } } gradient: Gradient { GradientStop { position: 0.0; color: "#ecf3fb" } // 左上角颜色 GradientStop { position: 1.0; color: "#b7d6fb" } // 右上角颜色 orientation: Gradient.Horizontal } function initJsonModel(model, jsonFile) { var data = get_json(jsonFile); if (data) { if (data.infos) { model.clear(); for (var i = 0; i < data.infos.length; i++) { model.append(data.infos[i]); } } else { console.error("JSON file does not contain 'infos' property"); } } else { console.error("Failed to retrieve data from JSON file"); } } function updateJsonFile(model, jsonFile) { var data = [] for (var i = 0; i < model.count; i++) { var obj = model.get(i); var plainObject = {}; for (var key in obj) { plainObject[key] = obj[key]; } data.push(plainObject); } save_json(jsonFile, {"infos":data}) } function execute(funcName, param={}) { console.info("params",JSON.stringify(param)) var funcInstance = getFuncInstance(funcName) taskActuatorManager.start(funcInstance.taskId, param) return funcInstance.taskId } function stopExecute(taskId) { taskActuatorManager.stop(taskId) } function getFuncInstance(funcName) { var funcInstance = {} for(var i = 0; i < funcModel.count; i++) { if(funcModel.get(i).name == funcName) { funcInstance = funcModel.get(i) break } } return funcInstance } function get_json(fileName) { return hsvp.getJson(firstPath + appPath + fileName) } function save_json(fileName, jsonObj) { hsvp.setJson(firstPath + appPath + fileName, jsonObj) } ListModel{ id: funcModel } ListModel{ id: funcTaskModel } FontLoader { id: customFontLoader source: "./resource/PingFang SC Medium.ttf" // 字体文件的路径 } Rectangle { id: bar anchors.left: parent.left anchors.right: parent.right anchors.top: parent.top anchors.topMargin: 24 anchors.leftMargin: 23 anchors.rightMargin: 23 height: 45 radius: 9 property var currentIndex: 0 Row{ anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left anchors.leftMargin: 52 spacing: 80 QxTitleButton { text: qsTr("测试") isSelected: bar.currentIndex == 0 textColor: isSelected ? "#007EFF" : "#737373" iconSource: isSelected ? "../resource/bd1.png" : "../resource/bd0.png" onClicked: bar.currentIndex = 0 } QxTitleButton { text: qsTr("系统设置") isSelected: bar.currentIndex == 1 textColor: isSelected ? "#007EFF" : "#737373" iconSource: isSelected ? "../resource/set1.png" : "../resource/set0.png" onClicked: bar.currentIndex = 1 } } Row { anchors.verticalCenter: parent.verticalCenter anchors.right: parent.right anchors.rightMargin: 15 spacing: 13 Row{ spacing: 1 Image{ source: "./resource/user.png" width: 18 height: 18 } QxText{ text: "测试人员: " + g_user } } Item{ width: 10 height: 18 Rectangle{ width: 1 height: 11 color: "#BFBFBF" anchors.centerIn: parent } } Row{ spacing: 1 Image{ source: "./resource/sn.png" width: 18 height: 18 } QxText{ text:"SN: " + g_sn } } } } StackLayout { id: layout anchors.top: bar.bottom anchors.bottom: parent.bottom anchors.left: parent.left anchors.right: parent.right anchors.leftMargin: 23 anchors.rightMargin: 23 anchors.topMargin: 20 anchors.bottomMargin: 29 currentIndex: bar.currentIndex Test {} SettingView{} } TestDetail{ id: testDetail anchors.fill: parent visible: false } }