| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634 |
- import QtQuick 2.15
- import QtQuick.Controls 2.15
- Item {
- id: materialmakeback
- x: 290
- y: 130
- width: 1600
- height: 920
- signal signal_openLock
- signal startReader
- signal signal_takebackstat(bool stat)
- property bool listviewstat : false
- property bool takebackstat : false
- property bool opendoor : false
- property int takebackviewcount: 1
- onVisibleChanged: {
- proThread.moveCursorTo(0, 0);
- }
- ListModel {
- id: materialsellistModel
- }
- ListModel {
- id: materialModel
- }
- Rectangle {
- id: materialsel
- width: 1600
- height: 800
- color: "#272b7ae9"
- radius: 20
- clip: 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: materialModel
- delegate: Rectangle{
- width: 250
- height: 350
- color: "#00ffffff"
- Rectangle {
- x: 25
- y: 25
- width: 200
- height: 300
- color: model.color
- Image {
- x: 25
- y: 25
- width: 150
- height: 150
- visible: true
- source: model.png
- fillMode: Image.PreserveAspectFit
- }
- Text {
- x: 0
- y: 185
- width: parent.width
- height: 50
- visible: true
- text: model.name
- 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.rfid
- font.pixelSize: 12
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- color: "#ffffff"
- }
- Rectangle {
- x: 25
- y: 75
- 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 {
- x: 25
- y: 125
- width: 150
- height: 50
- color: "#ff0000" // 透明背景
- visible: model.stat
- Text {
- anchors.centerIn: parent
- text: "待还"
- font.pixelSize: 30
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- color: "#ffffff"
- }
- }
- }
- }
- }
- }
- Rectangle {
- id: materialselview
- 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: materialsellistModel
- delegate: Rectangle{
- width: 250
- height: 100
- color: "#00ffffff"
- Image {
- x: 0
- y: 25
- width: 50
- height: 50
- visible: true
- source: model.source
- fillMode: Image.PreserveAspectFit
- }
- Text {
- x: 55
- y: 25
- width: parent.width - 55
- height: 50
- visible: true
- text: model.count
- font.pixelSize: 25
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- color: "#ffffff"
- }
- Canvas {
- anchors.fill: parent
- visible: model.view
- onPaint: {
- var ctx = getContext("2d");
- ctx.lineWidth = 10; // 设置线的宽度
- ctx.strokeStyle = "skyblue"; // 设置线的颜色为白色
- ctx.beginPath();
- ctx.moveTo(0, 80); // 直线的起点
- ctx.lineTo(parent.width, 80); // 直线的终点
- ctx.stroke(); // 绘制直线
- }
- }
- MouseArea {
- anchors.fill: parent // 让MouseArea覆盖整个Image区域
- onClicked: {
- sel_materialtype(model.idx)
- }
- }
- }
- }
- }
- 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: {
- if(listviewstat == false)
- {
- listviewstat = true;
- viewImage.rotation = 90;
- materialselview.height = materialselview.height + 500
- }
- else{
- listviewstat = false;
- viewImage.rotation = 0;
- materialselview.height = materialselview.height - 500
- }
- }
- }
- }
- }
- }
- Dialog {
- id: dialog
- title: "操作确认"
- x: parent.width / 2 - width / 2
- y: parent.height / 2 - height / 2
- width: 600
- height: 400
- clip: true
- modal: true
- // 自定义背景(带圆角)
- background: Rectangle {
- color: "white"
- clip: true
- }
- // 自定义标题栏
- header: Rectangle {
- x: 0
- y: 0
- width: parent.width
- height: 50 // 设置标题栏高度
- color: "#ff3968e9" // 设置标题栏背景色
- // 标题文本
- Text {
- x: 20
- y: 0
- width: 80
- height: 50 // 设置标题栏高度
- text: dialog.title
- font.pixelSize: 25
- horizontalAlignment: Text.AlignLeft
- verticalAlignment: Text.AlignVCenter
- color: "white"
- }
- }
- contentItem: Rectangle {
- x: 0
- y: 0
- width: parent.width
- height: 200
- color: "white"
- Text {
- width: parent.width
- height: 200
- text: "确认要开柜取还物资吗?"
- font.pixelSize: 30
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- }
- }
- // 自定义 DialogButtonBox
- DialogButtonBox {
- id: buttonBox
- x: 0
- y: 250
- width: parent.width
- height: 100
- // 自定义按钮
- Button {
- implicitWidth: 120
- implicitHeight: 50
- text: "确认"
- background: Rectangle {
- color: "green"
- radius: 5
- }
- contentItem: Text {
- text: parent.text
- font.pixelSize: 30
- color: "white"
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- }
- onClicked: {
- if(takebackstat === false)
- {
- takebackstat = true;
- pConfig.mtakebackstat = true;
- // button_return.enabled = false;
- pConfig.imaterworkstat = 0;
- signal_openLock()
- }
- dialog.close()
- }
- }
- Button {
- implicitWidth: 120
- implicitHeight: 50
- text: "取消"
- background: Rectangle {
- color: "red"
- radius: 5
- }
- contentItem: Text {
- text: parent.text
- font.pixelSize: 30
- color: "white"
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- }
- onClicked: {
- dialog.reject()
- }
- }
- }
- }
- Button {
- id: button_openCabinet
- x: 1168
- y: 835
- width: 192
- height: 75
- background: Rectangle {
- color: "#ff0000" // 设置背景为透明
- radius: 10 // 可选,设置圆角
- }
- text: qsTr("开柜")
- font.pixelSize: 30
- palette.buttonText: "white" // 设置字体颜色为绿色
- Connections {
- target: button_openCabinet
- onClicked: {
- dialog.open()
- }
- }
- }
- Button {
- id: button_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: button_return
- onClicked: {
- if (pConfig.sopenDoor)
- {
- infoPromptBox.title("提示");
- infoPromptBox.message("开柜状态下不允许该操作");
- infoPromptBox.button_clear();
- infoPromptBox.button_push("#055eb3", "确定", null, null);
- infoPromptBox.show();
- }
- else
- {
- materialTakeBack.visible = false;
- materialSelmodel.visible = true;
- }
- // if(takebackstat === false && opendoor === false)
- // {
- // materialTakeBack.visible = false;
- // materialSelmodel.visible = true;
- // }
- }
- }
- }
- Rectangle {
- id: delaymatrailtakebacknotice
- x: 0
- y: 823
- width: 300
- height: 75 // 减去顶部圆角矩形的高度
- color: "#00ffffff"
- visible: opendoor
- Image {
- x: 0
- y: 0
- width: 75
- height: 75
- visible: true
- source: "qrc:/png/takeback.png"
- fillMode: Image.PreserveAspectFit
- }
- Text {
- x: 80
- y: 0
- width: 220
- height: 75
- visible: false
- text: "等待取还物资......"
- font.pixelSize: 30
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- color: "#ffffff"
- }
- }
- Timer {
- interval: 100
- running: true
- repeat: true
- onTriggered: {
- if(opendoor == true)
- {
- if(takebackviewcount > 0)
- {
- takebackviewcount--;
- }
- else{
- takebackviewcount = 5;
- if(delaymatrailtakebacknotice.visible === true)
- {
- delaymatrailtakebacknotice.visible = false;
- }
- else{
- delaymatrailtakebacknotice.visible = true;
- }
- }
- }
- else{
- delaymatrailtakebacknotice.visible = false;
- }
- }
- }
- function sel_materialtype(idx)
- {
- var foundItem = null;
- for (var i = 0; i < materialsellistModel.count; ++i) {
- if (materialsellistModel.get(i).idx === idx) {
- foundItem = materialsellistModel.get(i);
- foundItem.view = true;
- }
- else{
- materialsellistModel.get(i).view = false;
- }
- }
- materialModel.clear()
- var materialname = pConfig.smaterialNameList;
- var materialpicture = pConfig.smaterialPictureList;
- var materialloanuser = pConfig.smaterialLoanUserList;
- var materialloanstate = pConfig.smaterialLoanStateList;
- var materialstatus = pConfig.smaterialStatusList;
- var materialtype = pConfig.smaterialTypeList;
- var userId = pConfig.suserId;
- for (var key in materialname)
- {
- if(foundItem.idx === "ALL")
- {
- if(materialloanstate[key] === 0)
- {
- if (materialloanuser[key] === userId)
- {
- materialModel.append({png:materialpicture[key], name: materialname[key], status: materialstatus[key], rfid: key, color: "#8fffffff", stat: true});
- }
- else
- {
- materialModel.append({png:materialpicture[key], name: materialname[key], status: materialstatus[key], rfid: key, color: "#8fffffff", stat: false});
- }
- }
- else
- {
- materialModel.append({png:materialpicture[key], name: materialname[key], status: materialstatus[key], rfid: key, color: "#00ffffff", stat: false});
- }
- }
- else{
- if(foundItem.idx === materialtype[key])
- {
- if(materialloanstate[key] === 0)
- {
- if (materialloanuser[key] === userId)
- {
- materialModel.append({png:materialpicture[key], name: materialname[key], status: materialstatus[key], rfid: key, color: "#8fffffff", stat: true});
- }
- else
- {
- materialModel.append({png:materialpicture[key], name: materialname[key], status: materialstatus[key], rfid: key, color: "#8fffffff", stat: false});
- }
- }
- else{
- materialModel.append({png:materialpicture[key], name: materialname[key], status: materialstatus[key], rfid: key, color: "#00ffffff", stat: false});
- }
- }
- }
- }
- }
- function lockStat_callback(left, right)
- {
- if(left === false || right === false)
- {
- opendoor = true;
- if(takebackstat === true)
- {
- button_openCabinet.visible = false;
- signal_takebackstat(true);
- }
- }
- else if(left === true && right === true)
- {
- opendoor = false;
- if(takebackstat === true)
- {
- // 开始读rfid
- startReader();
- takebackstat = false;
- signal_takebackstat(false);
- pConfig.smaterialStock = true;
- // button_return.enabled = true;
- button_openCabinet.visible = true;
- // materialTakeBack.visible = false;
- mainScreen.switchViewOffEx();
- materialStocktaking.set_userinfo();
- materialStocktaking.materiallistclear();
- materialStocktaking.visible = true;
- mainScreen.resetLogin_timeout();
- }
- }
- }
- function slot_updateMaterial()
- {
- materialsellistModel.clear();
- materialModel.clear();
- var typecount = pConfig.smaterialTypeCountList;
- var typepng = pConfig.smaterialTypePngList;
- var idx = 1;
- var count = 0;
- for (var typekey in typecount)
- {
- count = count + typecount[typekey];
- var viewcount = typekey + "(" + typecount[typekey] + ")";
- materialsellistModel.append({idx: typekey, source: typepng[typekey], count: viewcount, view: false});
- idx++;
- }
- materialsellistModel.insert(0, {idx: "ALL", source: "qrc:/png/allsel.png", count: "全部(" + count + ")", view: true});
- var materialname = pConfig.smaterialNameList;
- var materialpicture = pConfig.smaterialPictureList;
- var materialloanuser = pConfig.smaterialLoanUserList;
- var materialloanstate = pConfig.smaterialLoanStateList;
- var materialstatus = pConfig.smaterialStatusList;
- var materialtype = pConfig.smaterialTypeList;
- var userId = pConfig.suserId;
- for (var key in materialname)
- {
- if(materialloanstate[key] === 0)
- {
- if (materialloanuser[key] === userId)
- {
- materialModel.append({png:materialpicture[key], name: materialname[key], status: materialstatus[key], rfid: key, color: "#8fffffff", stat: true});
- }
- else
- {
- materialModel.append({png:materialpicture[key], name: materialname[key], status: materialstatus[key], rfid: key, color: "#8fffffff", stat: false});
- }
- }
- else{
- materialModel.append({png:materialpicture[key], name: materialname[key], status: materialstatus[key], rfid: key, color: "#00ffffff", stat: false});
- }
- }
- }
- }
|