import QtQuick import QtQuick.Controls import QtQuick.Layouts // import com.InteractiveCore 1.0 import com.InteractiveTask 1.0 Item { id: materialreplace x: 290 y: 130 width: 1600 height: 920 property bool takebackstat : false property bool opendoor : false signal startReader(); signal signal_openLock(); signal signal_takebackstat(bool stat); onVisibleChanged: { if (visible) { proThread.moveCursorTo(0, 0); materialreplace_btn_hand.visible = false; materialreplace_rect_table_body.visible = false; materialreplace_text_plan_title.visible = false; waitPromptBox.show(); // 先刷新数据缓存,然后调用视图刷新 console.log("准备从服务器获取消息(1)"); var taskType = InteractiveTask.TypeMaterialInfoListRefresh; interactiveCore.appendTask( taskType, null, ()=>{ console.log("准备赋值model(4)"); var taskType = InteractiveTask.TypeMaterialReplaceRefreshListModel; interactiveCore.appendTask( taskType, "0", ()=>{ // 界面显示 console.log("根据model是否为空,确定界面是否显示(6)"); if(materialreplace_modelMaterialInfo.count() === 0) { materialreplace_btn_hand.visible = false; materialreplace_rect_table_body.visible = false; materialreplace_text_plan_title.visible = true; } else { materialreplace_btn_hand.visible = true; materialreplace_rect_table_body.visible = true; materialreplace_text_plan_title.visible = false; } }); waitPromptBox.hide(); }); } else { proThread.slot_getMaterial(); } } // 标题区域 Text { id: materialreplace_text_plan_title x: 0 y: 0 width: 1600 height: 90 text: "当前没有要更换的物资" font.pixelSize: 30 color: "#d7d7d2" horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter leftPadding: 20 // 添加左边距使文本不紧贴边缘 } Rectangle { id: materialreplace_rect_autoreplace x: 0 y: 823 width: 300 height: 75 // 减去顶部圆角矩形的高度 color: "#00ffffff" visible: false Image { x: 0 y: 0 width: 75 height: 75 visible: true source: "qrc:/png/takeback.png" fillMode: Image.PreserveAspectFit } Text { x: 140 y: 0 width: 220 height: 75 visible: true text: "等待维修更换物资......" font.pixelSize: 30 horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter color: "#ffffff" } } // 手动更换 Button { id: materialreplace_btn_hand x: 928 y: 835 width: 192 height: 75 background: Rectangle { color: "#ff9900" radius: 10 // 可选,设置圆角 } text: qsTr("手动操作") font.pixelSize: 30 palette.buttonText: "white" // 设置字体颜色为绿色 Connections { target: materialreplace_btn_hand onClicked: { infoPromptBox.title("提示"); infoPromptBox.message("确定要手动操作吗?"); infoPromptBox.button_clear(); infoPromptBox.button_push("red", "取消", null, null); infoPromptBox.button_push( "#055eb3", "确定", ()=>{ // materialreplace_rect_table_hand.visible = true; materialManualReplace.visible = true; materialReplace.visible = false; }, null); infoPromptBox.show(); } } } // 自动更换 Button { id: materialreplace_btn_auto x: 1168 y: 835 width: 192 height: 75 background: Rectangle { color: "#ff0000" radius: 10 } text: qsTr("自动更换") font.pixelSize: 30 palette.buttonText: "white" // 设置字体颜色为绿色 Connections { target: materialreplace_btn_auto onClicked: { // materialreplace_dialog_autosubmit_prompt.open(); infoPromptBox.title("提示"); infoPromptBox.message("确定要自动更换物资吗?"); infoPromptBox.button_clear(); infoPromptBox.button_push("red", "取消", null, null); infoPromptBox.button_push( "#055eb3", "确定", ()=>{ materialreplace_rect_autoreplace.visible = true; takebackstat = true; pConfig.mtakebackstat = true; pConfig.imaterworkstat = 2; signal_openLock(); }, null); infoPromptBox.show(); } } } // 返回按钮 Button { id: materialreplace_btn_return x: 1408 y: 835 width: 192 height: 75 background: Rectangle { color: "#055eb3" radius: 10 } text: qsTr("返回") font.pixelSize: 30 palette.buttonText: "white" // 设置字体颜色为绿色 Connections { target: materialreplace_btn_return onClicked: { if (pConfig.sopenDoor) { infoPromptBox.title("提示"); infoPromptBox.message("柜门打开时不允许返回"); infoPromptBox.button_clear(); infoPromptBox.button_push("#055eb3", "确定", null, null); infoPromptBox.show(); } else { materialReplace.visible = false; materialSelmodel.visible = true; mainScreen.resetLogin_timeout(); } } } } // 主体表格 Rectangle { id: materialreplace_rect_table_body width: 1600 height: 800 color: "#272b7ae9" radius: 20 clip: true visible: true Rectangle { x: 50 y: 100 width: parent.width - 100 height: parent.height - 100 clip: true color: "#002b7ae9" GridView { width: parent.width height: parent.height cellWidth: 250 // 每个单元格的宽度,这里是平均分配宽度给5列 cellHeight: 350 // 每个单元格的高度 model: materialreplace_modelMaterialInfo delegate: Rectangle{ width: 250 height: 350 color: "#00ffffff" Rectangle { x: 25 y: 25 width: 200 height: 300 color: "#8fffffff" Image { x: 25 y: 25 width: 150 height: 150 visible: true source: model.materialsTypePicture fillMode: Image.PreserveAspectFit } Text { x: 0 y: 185 width: parent.width height: 50 visible: true text: model.materialsName font.pixelSize: 30 horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter color: "#ffffff" } Text { x: 0 y: 250 width: parent.width height: 25 visible: true text: model.materialsRfid font.pixelSize: 12 horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter color: "#ffffff" } Rectangle { x: 25 y: 125 width: 150 height: 50 color: { if (model.status === "0") return "#00ff00"; // 正常 - 绿色 if (model.status === "1") return "#ff0000"; // 损坏 - 红色 if (model.status === "2") return "#ff9900"; // 过期 - 橙色 if (model.status === "3") return "#ff9900"; // 放错柜子 - 橙色 return "gray"; // 默认颜色 } visible: { return model.status !== "0"; } Text { anchors.centerIn: parent // text: "待还" text:{ if (model.status === "0") return "正常"; if (model.status === "1") return "损坏"; if (model.status === "2") return "过期"; if (model.status === "3") return "放错柜子"; return "未知状态"; // 默认值 } font.pixelSize: 30 horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter color: "#ffffff" } } } } } } // 表格头 Rectangle { id: materialreplace_rect_table_head width: 1600 height: 100 // 减去顶部圆角矩形的高度 radius: 20 clip: true color: "#8f2b7ae9" Grid { x: 50 y: 0 width: parent.width - 150 height: parent.height visible: true verticalItemAlignment: Grid.AlignVCenter horizontalItemAlignment: Grid.AlignHCenter columns: 5 spacing: 20 Repeater { model: materialreplace_modelMaterialType delegate: Rectangle{ width: 250 height: 100 color: "#00ffffff" Image { x: 0 y: 25 width: 50 height: 50 visible: true source: model.materialsTypeIcon fillMode: Image.PreserveAspectFit } Text { x: 55 y: 25 width: parent.width - 55 height: 50 visible: true text: model.materialsTypeName + "(" + model.materialsTypeError + ")" font.pixelSize: 25 horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter color: "#ffffff" } Canvas { anchors.fill: parent visible: model.materialsTypeSelected onPaint: { var ctx = getContext("2d"); ctx.lineWidth = 10; // 设置线的宽度 ctx.strokeStyle = "skyblue"; // 设置线的颜色为白色 ctx.beginPath(); ctx.moveTo(0, 90); // 直线的起点 ctx.lineTo(parent.width, 90); // 直线的终点 ctx.stroke(); // 绘制直线 } } MouseArea { anchors.fill: parent // 让MouseArea覆盖整个Image区域 onClicked: { var taskType = InteractiveTask.TypeMaterialReplaceRefreshListModel; interactiveCore.appendTask(taskType, model.materialsTypeId, null); mainScreen.resetLogin_timeout(); } } } } } Image { id: viewImage x: parent.width - 80 y: 20 width: 60 height: 60 source: "qrc:/png/right.png" fillMode: Image.PreserveAspectFit MouseArea { anchors.fill: parent // 让MouseArea覆盖整个Image区域 onClicked: { var bIsUnfolding = (materialreplace_rect_table_head.height === 100 ? true : false); if(bIsUnfolding) { viewImage.rotation = 90; materialreplace_rect_table_head.height = 600; } else { viewImage.rotation = 0; materialreplace_rect_table_head.height = 100; } mainScreen.resetLogin_timeout(); } } } } } function lockStat_callback(left, right) { if (pConfig.imaterworkstat === 2) { if(left === false || right === false) { opendoor = true; if(takebackstat === true) { signal_takebackstat(true); materialreplace_btn_hand.visible = false; materialreplace_btn_auto.visible = false; // materialreplace_btn_return.enabled = false; } } else if(left === true && right === true) { opendoor = false; if(takebackstat === true) { startReader(); takebackstat = false; signal_takebackstat(false); pConfig.smaterialStock = true; materialreplace_btn_hand.visible = true; materialreplace_btn_auto.visible = true; // materialreplace_btn_return.enabled = true; // 开始读rfid // materialReplace.visible = false; mainScreen.switchViewOffEx(); materialStocktaking.set_userinfo(); materialStocktaking.materiallistclear(); materialStocktaking.visible = true; materialreplace_rect_autoreplace.visible = false; mainScreen.resetLogin_timeout(); } } } } function slot_requestertakebackMaterial() { } function slot_updateMaterialHand() { var taskType = InteractiveTask.TypeMaterialReplaceRefreshListModel; interactiveCore.appendTask(taskType, "-1", null); } // 刷新 list 视图 function refreshListModel() { // 先刷新数据缓存,然后调用视图刷新 var taskType = InteractiveTask.TypeMaterialReplaceRefreshListModel; interactiveCore.appendTask(taskType, "0", null); } }