import QtQuick 2.15 import QtQuick.Controls 2.15 import com.InteractiveTask 1.0 Item { id: materialselmodel x: 290 y: 130 width: 1600 height: 920 property bool listviewstat : false property int takebackCount : 0 property int instructionCount : 0 property int inspectionCount : 0 property int replacementCount : 0 property var mapCallbackPair; onVisibleChanged: { if (visible === true) { proThread.moveCursorTo(0, 0); mainScreen.changeModel_text("物资管理"); // var taskType = InteractiveTask.TypeHttpGet_getIsMaterialsLoanExceptionPage; // interactiveCore.appendTask(taskType, "", get_number); // 调用http interactiveCore.appendTask( InteractiveTask.TypeHttpGet_getCabinetHomePage, "", ()=>{ refresh_home(); refresh_oper(); }); } } function refresh_home() { takebackCount = parseInt(pConfig.srarNumber); replacementCount = parseInt(pConfig.schangeNumber); inspectionCount = parseInt(pConfig.scheckNumber); materialListModel.clear(); var typeId = pConfig.sbottomTypeId; var typeName = pConfig.sbottomTypeName; var typeIcon = pConfig.sbottomTypeIcon; var typeAll = pConfig.sbottomTypeAll; var typeBorrowable = pConfig.sbottomTypeBorrowable; for (var i = 0; i < typeId.length; ++i) { var key = typeId[i]; var count = "(" +typeBorrowable[key] + "/" + typeAll[key] + ")" materialListModel.append({source: typeIcon[key], count: count}); } } function refresh_oper() { function_listModel.clear(); mapCallbackPair = {}; // 打印所有权限 console.log("所有权限:", interactiveData.permissions); console.log("检查权限 iscs:receive-return 是否存在:", interactiveData.permissions.indexOf("iscs:receive-return") !== -1); if (interactiveData.isHavePower("iscs:receive-return")) { mapCallbackPair["iscs:receive-return"] = function() { mainScreen.changeModel_text(takebacksel.text); materialSelmodel.visible = false; materialTakeBack.visible = true; } function_listModel.append( { icon: "qrc:/png/takeback.png", count: takebackCount, nameCn: qsTr("物资取还"), nameEn: qsTr("Materials Fetch And Return"), gradientColor0: "#4c237eff", gradientColor1: "#0099ff", gradientOrientation: Gradient.Horizontal, chickCallback: "iscs:receive-return", spacing: 150 }); } console.log("检查权限 iscs:Inspection-plan 是否存在:", interactiveData.permissions.indexOf("iscs:Inspection-plan") !== -1); if (interactiveData.isHavePower("iscs:Instructions")) { mapCallbackPair["iscs:Instructions"] = function() { mainScreen.changeModel_text(instructionsel.text); materialSelmodel.visible = false materialInstructions.visible = true } function_listModel.append( { icon: "qrc:/png/instructions.png", count: instructionCount, nameCn: qsTr("物资使用说明"), nameEn: qsTr("Materials Instructions"), gradientColor0: "#80fe2828", gradientColor1: "#ff7676", gradientOrientation: Gradient.Horizontal, chickCallback: "iscs:Instructions", spacing: 60 }); } console.log("检查权限 iscs:Inspection-plan 是否存在:", interactiveData.permissions.indexOf("iscs:Inspection-plan") !== -1); if (interactiveData.isHavePower("iscs:Inspection-plan")) { mapCallbackPair["iscs:Inspection-plan"] = function() { mainScreen.changeModel_text(inspectionsel.text); materialSelmodel.visible = false materialCheckPlan.visible = true } function_listModel.append( { icon: "qrc:/png/inspection.png", count: inspectionCount, nameCn: qsTr("物资检查"), nameEn: qsTr("Materials Check"), gradientColor0: "#8014b03e", gradientColor1: "#14b03e", gradientOrientation: Gradient.Horizontal, chickCallback: "iscs:Inspection-plan", spacing: 150 }); } console.log("检查权限 iscs:replacement 是否存在:", interactiveData.permissions.indexOf("iscs:replacement") !== -1); if (interactiveData.isHavePower("iscs:replacement")) { mapCallbackPair["iscs:replacement"] = function() { mainScreen.changeModel_text(replacementsel.text); materialSelmodel.visible = false materialReplace.visible = true } function_listModel.append( { icon: "qrc:/png/inspection.png", count: replacementCount, nameCn: qsTr("维修/更换"), nameEn: qsTr("Repair / Replacement"), gradientColor0: "#80c1cb17", gradientColor1: "#c1cb17", gradientOrientation: Gradient.Horizontal, chickCallback: "iscs:replacement", spacing: 150 }); } } ListModel { id: function_listModel } Rectangle { width: 1600 height: 800 color: "#272b7ae9" radius: 20 // 可选,设置圆角 clip: true // visible: false GridView { anchors.fill: parent leftMargin: 100 rightMargin: 100 topMargin: 50 bottomMargin: 50 cellWidth: 700 cellHeight: 350 model: function_listModel delegate: Rectangle { width: 700 height: 350 color: "transparent" Button { anchors.centerIn: parent width: 600 height: 300 background: Rectangle { border.color: "#4c237eff" border.width: 2 radius: 40 gradient: Gradient { GradientStop { position: 0 color: model.gradientColor0 } GradientStop { position: 1 color: model.gradientColor1 } orientation: model.gradientOrientation } } icon.height: 200 icon.width: 200 display: AbstractButton.TextBesideIcon icon.source: model.icon text: model.nameCn font.pixelSize: 40 spacing: model.spacing palette.buttonText: "white" activeFocusOnTab: false Rectangle { x: 500 y: 30 width: 60 height: 60 visible: (model.count > 0) radius: width / 2 color: "#000000ff" border.color: "#ffffff" border.width: 3 Text { x: 10 y: 10 width: 40 height: 40 text: model.count.toString() font.pixelSize: 30 horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter color: "#ffffff" } } Text { x: 300 y: 200 width: 250 text: model.nameEn font.pixelSize: 20 color: "#ffffff" horizontalAlignment: Text.AlignRight } onClicked: { var key = model.chickCallback // 如果存在 if (mapCallbackPair.hasOwnProperty(key)) { // 进行回调函数校验 if (typeof mapCallbackPair[key] === "function") { mapCallbackPair[key](); } } } } } } } Rectangle { id: materialModel visible: false width: 1600 height: 810 color: "#272b7ae9" radius: 20 // 可选,设置圆角 Button { id: takebacksel x: 150 y: 60 width: 600 height: 300 background: Rectangle { id: password_sel_background border.color: "#4c237eff" border.width: 2 gradient: Gradient { GradientStop { position: 0 color: "#811ea5ff" } GradientStop { position: 1 color: "#0099ff" } orientation: Gradient.Horizontal } // 边框宽度 radius: 40 // 可选,设置圆角 } icon.height: 200 icon.width: 200 display: AbstractButton.TextBesideIcon icon.source: "qrc:/png/takeback.png" text: qsTr("物资取还") font.pixelSize: 40 spacing: 150 palette.buttonText: "white" // 设置字体颜色为绿 activeFocusOnTab: false Rectangle { x: 500 y: 30 width: 60 height: 60 visible: (takebackCount > 0) radius: width / 2 // 使矩形看起来像一个圆圈 color: "#000000ff" border.color: "#ffffff" border.width: 3 Text { x: 10 y: 10 width: 40 height: 40 text: qsTr(takebackCount.toString()) font.pixelSize: 30 horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter color: "#ffffff" } } Connections { target: takebacksel onClicked: { if (interactiveData.isHavePower("iscs:receive-return")) { mainScreen.changeModel_text(takebacksel.text); materialSelmodel.visible = false; materialTakeBack.visible = true; } else { infoPromptBox.title("提示"); infoPromptBox.message("没有权限"); infoPromptBox.button_clear(); infoPromptBox.button_push("#3498db", "确定", null, null); infoPromptBox.show(); } } } Text { x: 300 y: 200 text: qsTr("Materials Fetch And Return") font.pixelSize: 20 color: "#ffffff" } } Button { id: instructionsel x: 850 y: 60 width: 600 height: 300 background: Rectangle { border.color: "#4ce92b2b" border.width: 2 gradient: Gradient { GradientStop { position: 0 color: "#80fe2828" } GradientStop { position: 1 color: "#ff7676" } orientation: Gradient.Horizontal } // 边框宽度 radius: 40 // 可选,设置圆角 } icon.height: 200 icon.width: 200 display: AbstractButton.TextBesideIcon icon.source: "qrc:/png/instructions.png" text: qsTr("物资使用说明") font.pixelSize: 40 spacing: 80 palette.buttonText: "white" // 设置字体颜色为绿 activeFocusOnTab: false Rectangle { x: 500 y: 30 width: 60 height: 60 visible: (instructionCount > 0) radius: width / 2 // 使矩形看起来像一个圆圈 color: "#000000ff" border.color: "#ffffff" border.width: 3 Text { x: 10 y: 10 width: 40 height: 40 text: qsTr(instructionCount.toString()) font.pixelSize: 30 horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter color: "#ffffff" } } Connections { target: instructionsel onClicked: { if (interactiveData.isHavePower("iscs:Instructions")) { mainScreen.changeModel_text(instructionsel.text); materialSelmodel.visible = false materialInstructions.visible = true } else { infoPromptBox.title("提示"); infoPromptBox.message("没有权限"); infoPromptBox.button_clear(); infoPromptBox.button_push("#3498db", "确定", null, null); infoPromptBox.show(); } } } Text { x: 360 y: 200 text: qsTr("Materials Instructions") font.pixelSize: 20 color: "#ffffff" } } Button { id: inspectionsel x: 150 y: 440 width: 600 height: 300 background: Rectangle { border.color: "#4c14b03e" border.width: 2 gradient: Gradient { GradientStop { position: 0 color: "#8014b03e" } GradientStop { position: 1 color: "#14b03e" } orientation: Gradient.Horizontal } // 边框宽度 radius: 40 // 可选,设置圆角 } icon.height: 200 icon.width: 200 display: AbstractButton.TextBesideIcon icon.source: "qrc:/png/inspection.png" text: qsTr("物资检查") font.pixelSize: 40 spacing: 150 palette.buttonText: "white" // 设置字体颜色为绿 activeFocusOnTab: false Rectangle { x: 500 y: 30 width: 60 height: 60 visible: (inspectionCount > 0) radius: width / 2 // 使矩形看起来像一个圆圈 color: "#000000ff" border.color: "#ffffff" border.width: 3 Text { x: 10 y: 10 width: 40 height: 40 text: qsTr(inspectionCount.toString()) font.pixelSize: 30 horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter color: "#ffffff" } } Connections { target: inspectionsel onClicked: { if (interactiveData.isHavePower("iscs:Inspection-plan")) { mainScreen.changeModel_text(inspectionsel.text); materialSelmodel.visible = false materialCheckPlan.visible = true } else { infoPromptBox.title("提示"); infoPromptBox.message("没有权限"); infoPromptBox.button_clear(); infoPromptBox.button_push("#3498db", "确定", null, null); infoPromptBox.show(); } } } Text { x: 360 y: 200 text: qsTr("Materials Inspection") font.pixelSize: 20 color: "#ffffff" } } Button { id: replacementsel x: 850 y: 440 width: 600 height: 300 background: Rectangle { border.color: "#4cc1cb17" border.width: 2 gradient: Gradient { GradientStop { position: 0 color: "#80c1cb17" } GradientStop { position: 1 color: "#c1cb17" } orientation: Gradient.Horizontal } // 边框宽度 radius: 40 // 可选,设置圆角 } icon.height: 200 icon.width: 200 display: AbstractButton.TextBesideIcon icon.source: "qrc:/png/replacement.png" text: qsTr("维修/更换") font.pixelSize: 40 spacing: 150 palette.buttonText: "white" // 设置字体颜色为绿 activeFocusOnTab: false Rectangle { x: 500 y: 30 width: 60 height: 60 visible: (replacementCount > 0) radius: width / 2 // 使矩形看起来像一个圆圈 color: "#000000ff" border.color: "#ffffff" border.width: 3 Text { x: 10 y: 10 width: 40 height: 40 text: qsTr(replacementCount.toString()) font.pixelSize: 30 horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter color: "#ffffff" } } Connections { target: replacementsel onClicked: { if (interactiveData.isHavePower("iscs:replacement")) { mainScreen.changeModel_text(replacementsel.text); materialSelmodel.visible = false materialReplace.visible = true } else { infoPromptBox.title("提示"); infoPromptBox.message("没有权限"); infoPromptBox.button_clear(); infoPromptBox.button_push("#3498db", "确定", null, null); infoPromptBox.show(); } } } Text { x: 340 y: 200 text: qsTr("Materials Replacement") font.pixelSize: 20 color: "#ffffff" } } } Rectangle { id: materialviewrectangle x: 0 y: 820 width: 1600 height: 100 color: "#742b7ae9" radius: 20 clip: true Text { x: 31 y: 31 text: qsTr("物资数量(可借/总数):") font.pixelSize: 30 color: "#ffffff" } // 可选,设置圆角 ListModel { id: materialListModel } Rectangle { id: materialInfo x: 340 y: 25 width: 1100 height: 50 color: "#002b7ae9" Grid { x: 50 y: 0 width: parent.width -50 height: parent.height visible: true columns: 5 spacing: 50 Repeater { id: instantiator model: materialListModel delegate: Rectangle{ width: 150 height: 50 color: "#00ffffff" Image { x: 0 y: 0 width: 50 height: 50 visible: true source: model.source fillMode: Image.PreserveAspectFit } Text { x: 50 y: 0 width: 100 height: 50 visible: true text: model.count font.pixelSize: 30 horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter color: "#ffffff" } } } } } Image { id: viewImage x: 1507 y: 15 width: 70 height: 70 source: "qrc:/png/right.png" fillMode: Image.PreserveAspectFit MouseArea { anchors.fill: parent // 让MouseArea覆盖整个Image区域 onClicked: { viewListAll() } } } } function viewListAll() { if(listviewstat == false) { listviewstat = true; viewImage.rotation = 90; materialviewrectangle.height = materialviewrectangle.height + 500 materialviewrectangle.y = materialviewrectangle.y - 500; } else{ listviewstat = false; viewImage.rotation = 0; materialviewrectangle.height = materialviewrectangle.height - 500 materialviewrectangle.y = materialviewrectangle.y + 500; } } Component.onCompleted: { } function slot_updateMaterial() { // materialListModel.clear(); // var typeborrowablenumber = pConfig.smaterialTypeBorrowableNumberList; // var typecount = pConfig.smaterialTypeCountList; // var typepng = pConfig.smaterialTypePngList; // for (var key in typecount) // { // console.log("Key:", key, "Value:", data[key]); // var number = "(" +typeborrowablenumber[key] + "/" + typecount[key] + ")" // materialListModel.append({source: typepng[key], count: number}); // } } }