| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767 |
- 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});
- // }
- }
- }
|