import QtQuick import QtQuick.Controls import com.lock 1.0 // 导入 C++ 类 import com.InteractiveTask 1.0 Item { id: mainscreen width: 1920 height: 1080 property int login_timeout: 99 property bool loginStat: false property bool opendoor: false property string lastItemStr : ""; signal signal_logout Connections { target: mainscreen onVisibleChanged: { if (mainscreen.visible === true) { proThread.moveCursorTo(0, 0); material_sel_background.opacity = 1; material_exc_background.opacity = 0; set_sel_background.opacity = 0; } } } Rectangle { id: rectangle x: 0 y: 0 width: 267 height: 1080 color: "#4c2b7ae9" Image { id: logoImage x: 34 y: 40 width: 200 height: 50 source: "qrc:/png/bozz.png" fillMode: Image.PreserveAspectFit } Label { id: label1 x: 54 y: 105 text: qsTr("物资管理") color: "#ddffffff" font.pixelSize: 40 font.bold: true } Canvas { anchors.fill: parent onPaint: { var ctx = getContext("2d"); ctx.lineWidth = 5; // 设置线的宽度 ctx.strokeStyle = "white"; // 设置线的颜色为白色 ctx.beginPath(); ctx.moveTo(45, 165); // 直线的起点 ctx.lineTo(225, 165); // 直线的终点 ctx.stroke(); // 绘制直线 ctx.beginPath(); ctx.moveTo(45, 930); // 直线的起点 ctx.lineTo(225, 930); // 直线的终点 ctx.stroke(); // 绘制直线 } } Rectangle { id: rectangle1 x: 44 y: 176 width: 180 height: 560 color: "#00ffffff" Button { id: material_sel x: 0 y: 10 width: 180 height: 180 hoverEnabled: false background: Rectangle { id:material_sel_background color: "#942b7ae9" // 设置背景为透明 radius: 10 // 可选,设置圆角 opacity: 1 } icon.height: 120 icon.width: 120 display: AbstractButton.TextUnderIcon icon.source: "qrc:/png/material.png" icon.color: "#00ffffff" text: qsTr("物资管理") font.pixelSize: 30 palette.buttonText: "white" // 设置字体颜色为绿 Connections { target: material_sel onClicked: { if(setView.visible === true || materialException.visible === true) { material_sel_background.opacity = 1; material_exc_background.opacity = 0; set_sel_background.opacity = 0; switchViewOff(); changeModel_text(material_sel.text); materialSelmodel.visible = true; // proThread.moveCursorTo(0, 0); } } } } Button { id: material_exc x: 0 y: 200 width: 180 height: 180 hoverEnabled: false visible: true background: Rectangle { id:material_exc_background color: "#942b7ae9" // 设置背景为透明 radius: 10 // 可选,设置圆角 opacity: 0 } icon.height: 120 icon.width: 120 display: AbstractButton.TextUnderIcon icon.source: "qrc:/png/exception.png" icon.color: "#00ffffff" text: qsTr("异常处理") font.pixelSize: 30 palette.buttonText: "white" // 设置字体颜色为绿 Connections { target: material_exc onClicked: { if(setView.visible === true || materialSelmodel.visible === true) { material_sel_background.opacity = 0; material_exc_background.opacity = 1; set_sel_background.opacity = 0; switchViewOff(); changeModel_text(material_exc.text); materialSelmodel.visible = false; materialException.visible = true; // proThread.moveCursorTo(0, 0); } } } } } Button { id: set_sel x: 44 y: 740 width: 180 height: 180 hoverEnabled: false background: Rectangle { id: set_sel_background color: "#942b7ae9" // 设置背景为透明 radius: 10 // 可选,设置圆角 opacity: 0 } icon.height: 120 icon.width: 120 display: AbstractButton.TextUnderIcon icon.source: "qrc:/png/set.png" icon.color: "#00ffffff" text: qsTr("设置") font.pixelSize: 30 palette.buttonText: "white" // 设置字体颜色为绿色 visible: true Connections { target: set_sel onClicked: { if(materialSelmodel.visible === true || materialException.visible === true) { material_sel_background.opacity = 0; material_exc_background.opacity = 0; set_sel_background.opacity = 1; switchViewOff(); changeModel_text(set_sel.text); setView.load_configParam(false); setView.fingerVisible = true; setView.visible = true; // proThread.moveCursorTo(0, 0); } } } } Text { id: timeDisplay x: 44 y: 950 font.pixelSize: 32 color: "white" text: Qt.formatDateTime(new Date(), "yyyy-MM-dd\nhh:mm:ss") horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter anchors.verticalCenterOffset: 451 anchors.horizontalCenterOffset: 0 // 添加颜色渐变动画 // Behavior on color { // ColorAnimation { duration: 500 } // } } } Rectangle { x: 326 y: 21 width: 185 height: 84 color: "transparent" // 图片 Image { id: model_icon source: "qrc:/png/material.png" // 图片路径(可以是本地文件或资源文件) width: 60 height: 60 anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter } // 文字 Text { id: model_text text: "物资管理" color: "white" font.pixelSize: 30 anchors.left: model_icon.right // 文字在图片右侧 anchors.leftMargin: 10 // 图片和文字之间的间距 anchors.verticalCenter: parent.verticalCenter } } Rectangle { x: 1375 y: 21 width: 524 height: 84 color: "transparent" Text { id: user_timeout visible: false text: "系统将于 " + formatNumber(login_timeout) + " 秒后退出" color: "white" font.pixelSize: 30 anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter } // 图片 Image { id: user_icon source: "qrc:/png/user_title.png" // 图片路径(可以是本地文件或资源文件) width: 60 height: 60 anchors.left: user_timeout.right anchors.leftMargin: 10 anchors.verticalCenter: parent.verticalCenter } Button { id: user_text background: Rectangle { radius: 2 // 可选,设置圆角 opacity: 0 } text: "" anchors.left: user_icon.right // 文字在图片右侧 anchors.leftMargin: 10 // 图片和文字之间的间距 anchors.verticalCenter: parent.verticalCenter font.pixelSize: 30 palette.buttonText: "white" // 设置字体颜色为绿 onClicked: { if(opendoor === false) { logout() } } } } Timer { interval: 1000 running: true repeat: true onTriggered: { timeDisplay.text = Qt.formatDateTime(new Date(), "yyyy-MM-dd\nhh:mm:ss") // timeDisplay.color = Qt.rgba(Math.random(), Math.random(), Math.random(), 1) // 随机颜色 if(opendoor === false) { if(mainScreen.visible === true && login_timeout > 0) { login_timeout = login_timeout - 1 if(login_timeout == 30) { user_timeout.visible = true; } } else{ if(loginStat == true) { logout() } } } else{ login_timeout = pConfig.sloginTimeout; } } } // 格式化函数:将整数格式化为两位数字并补零 function formatNumber(number) { // 使用 padStart 方法补零 return number.toString().padStart(2, '0'); } function lockStat_callback(left, right) { if(left === false || right === false) { opendoor = true; } else if(left === true && right === true) { opendoor = false; } } function login_return_param(name, auth){ user_text.text = name; loginStat = true; } function changeModel_text(value) { // refreshListMode(); if (value === material_sel.text || value === set_sel.text || value === material_exc.text) { set_sel.opacity = 1 material_exc.opacity = 1 } else { set_sel.opacity = 0.5 material_exc.opacity = 0.5 } if(value === material_sel.text) { model_text.text = material_sel.text; model_icon.source = "qrc:/png/takeback.png"; resetLogin_timeout(); } else if(value === set_sel.text) { model_text.text = set_sel.text; model_icon.source = "qrc:/png/set.png"; resetLogin_timeout(); } else if(value === "物资取还") { model_text.text = "物资取还"; model_icon.source = "qrc:/png/takeback.png"; resetLogin_timeout(); } else if(value === "物资使用说明") { model_text.text = "物资使用说明"; model_icon.source = "qrc:/png/instructions.png"; resetLogin_timeout(); } else if(value === "物资检查") { model_text.text = "物资检查计划"; model_icon.source = "qrc:/png/inspection.png"; resetLogin_timeout(); } else if(value === "物资检查表") { model_text.text = "物资检查表"; model_icon.source = "qrc:/png/inspection.png"; resetLogin_timeout(); } else if(value === "维修/更换") { model_text.text = "维修/更换"; model_icon.source = "qrc:/png/replacement.png"; resetLogin_timeout(); } else if(value === "异常处理") { model_text.text = "异常处理"; model_icon.source = "qrc:/png/exception_handle.png"; resetLogin_timeout(); } } function changeModel_text_Instructions(value) { model_text.text = value; model_icon.source = "qrc:/png/instructions.png"; } function resetLogin_timeout() { user_timeout.visible = false; login_timeout = pConfig.sloginTimeout; } function logout() { user_timeout.visible = false; loginStat = false; materialStatistics.visible = false; materialTakeBack.visible = false; materialInstructions.visible = false; materialCheckPlan.visible = false; materialCheckForm.visible = false; materialCheckSign.visible = false; materialCheckUpdate.visible = false; materialReplace.visible = false; materialReplaceHand.visible = false; materialReplaceAuto.visible = false; materialManualReplace.visible = false; materialException.visible = false; // materialExceptionUpdate.visible = false; materialExceptionReport.visible = false; // materialExceptionFinish.visible = false; facialRecognition.visible = false; materialStocktaking.visible = false; waitPromptBox.hide(); hangPromptBox.hideExecuteCallback(); infoPromptBox.hide(); materialSelmodel.visible = false; setView.visible = false; mainScreen.visible = false; loginScreen.visible = true; loginScreen.focus = true; signal_logout(); } function switchViewOff() { materialSelmodel.visible = false; setView.fingerVisible = false; setView.visible = false; materialStatistics.visible = false; materialTakeBack.visible = false; materialInstructions.visible = false; materialCheckPlan.visible = false; materialCheckForm.visible = false; materialCheckSign.visible = false; materialCheckUpdate.visible = false; materialReplace.visible = false; materialReplaceHand.visible = false; materialReplaceAuto.visible = false; materialManualReplace.visible = false; materialException.visible = false; // materialExceptionUpdate.visible = false; materialExceptionReport.visible = false; // materialExceptionFinish.visible = false; materialStocktaking.visible = false; facialRecognition.visible = false; waitPromptBox.hide(); hangPromptBox.hideExecuteCallback(); infoPromptBox.hide(); } function switchViewOnEx() { if (lastItemStr === "materialCheckPlan") { materialCheckPlan.visible = true; } else if (lastItemStr === "materialCheckForm") { materialCheckForm.visible = true; } else if (lastItemStr === "materialCheckSign") { materialCheckSign.visible = true; } else if (lastItemStr === "materialTakeBack") { materialTakeBack.visible = true; } else if (lastItemStr === "materialReplace") { materialReplace.visible = true; } else if (lastItemStr === "materialManualReplace") { materialManualReplace.visible = true; } else if (lastItemStr === "materialException") { materialException.visible = true; } } function switchViewOffEx() { if (materialCheckPlan.visible === true) { lastItemStr = "materialCheckPlan"; } else if (materialCheckForm.visible === true) { lastItemStr = "materialCheckForm"; } else if (materialCheckSign.visible === true) { lastItemStr = "materialCheckSign"; } else if (materialTakeBack.visible === true) { lastItemStr = "materialTakeBack"; } else if (materialReplace.visible === true) { lastItemStr = "materialReplace"; } else if (materialManualReplace.visible === true) { lastItemStr = "materialManualReplace"; } else if (materialException.visible === true) { lastItemStr = "materialException"; } materialSelmodel.visible = false; setView.fingerVisible = false; setView.visible = false; materialStatistics.visible = false; materialTakeBack.visible = false; materialInstructions.visible = false; materialCheckPlan.visible = false; materialCheckForm.visible = false; materialCheckSign.visible = false; materialCheckUpdate.visible = false; materialReplace.visible = false; materialReplaceHand.visible = false; materialReplaceAuto.visible = false; materialManualReplace.visible = false; materialException.visible = false; // materialExceptionUpdate.visible = false; materialExceptionReport.visible = false; // materialExceptionFinish.visible = false; materialStocktaking.visible = false; facialRecognition.visible = false; waitPromptBox.hide(); hangPromptBox.hideExecuteCallback(); infoPromptBox.hide(); } function get_error_callback(isError) { material_exc.visible = isError; } // 刷新model列表 function refreshListMode() { var taskType = InteractiveTask.TypeMaterialExceptionRefreshListModel; interactiveCore.appendTask( taskType, "", ()=>{ if (materialexception_modelMaterialException.count() > 0) { material_exc.visible = true; } else { material_exc.visible = false; } }); } }