| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722 |
- import QtQuick
- import QtQuick.Controls
- import QtQuick.Layouts
- import QtQuick.Pdf
- import QtMultimedia
- import Qt.labs.platform
- import com.InteractiveTask 1.0
- Item {
- id: materialinstructions
- x: 290
- y: 130
- width: 1600
- height: 920
- signal signal_get()
- signal signal_pdf_click(string text)
- property string strMaterialTypeGet: ""
- property string strInstructionsGet: ""
- property string strJsonData: "";
- property string strInstructionsTitle: ""
- property bool bResetTimer: false
- Connections {
- target: materialinstructions
- onVisibleChanged: {
- if (materialinstructions.visible === true)
- {
- proThread.moveCursorTo(0, 0);
- // materialInstructionsModel.clear();
- // materialsellistInstructionsModel.clear();
- // signal_get();
- var taskType = InteractiveTask.TypeHttpGet_getInstructionsList;
- interactiveCore.appendTask(taskType, null, (data)=>{
- strJsonData = data;
- callback_refresh_view("全部");
- });
- }
- else
- {
- materialinstructionsPdf.visible = false;
- materialinstructionsVideo.visible = false;
- }
- }
- }
- // 标题表格
- ListModel {
- id: materialsellistInstructionsModel
- }
- // 主体表格
- ListModel {
- id: materialInstructionsModel
- }
- // 返回按钮
- Button {
- id: button_return_instructions
- 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_instructions
- onClicked: {
- materialInstructions.visible = false;
- materialSelmodel.visible = true;
- mainScreen.resetLogin_timeout();
- }
- }
- }
- Rectangle {
- id: materialsel11
- 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: 360 // 每个单元格的宽度,这里是平均分配宽度给5列
- cellHeight: 350 // 每个单元格的高度
- model: materialInstructionsModel
- delegate: Rectangle{
- width: 360
- height: 350
- color: "#00ffffff"
- Rectangle {
- x: 25
- y: 25
- width: 350
- height: 300
- color: model.color
- Image {
- x: 75
- y: 25
- width: 200
- height: 200
- visible: true
- source: model.png
- fillMode: Image.PreserveAspectFit
- }
- Text {
- x: 0
- y: 250
- width: parent.width
- height: 25
- visible: true
- text: model.instructionsTitle
- font.pixelSize: 28
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- color: "#ffffff"
- }
- MouseArea {
- anchors.fill: parent // 让MouseArea覆盖整个Image区域
- onClicked: {
- strInstructionsTitle = model.instructionsTitle;
- if (model.fileType === "0")
- {
- videoPlayer.source = model.fileUrl;
- materialinstructionsVideo.visible = true;
- }
- else if (model.fileType === "1")
- {
- signal_pdf_click(model.fileUrl);
- }
- mainScreen.resetLogin_timeout();
- }
- }
- }
- }
- }
- }
- Rectangle {
- id: materialselviewInstruction
- 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: materialsellistInstructionsModel
- delegate: Rectangle {
- width: 250
- height: 100
- color: "#00ffffff"
- Image {
- x: 0
- y: 25
- width: 50
- height: 50
- visible: true
- source: model.icon
- fillMode: Image.PreserveAspectFit
- }
- Text {
- x: 55
- y: 25
- width: parent.width - 55
- height: 50
- visible: true
- text: model.name + "(" + 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, 90); // 直线的起点
- ctx.lineTo(parent.width, 90); // 直线的终点
- ctx.stroke(); // 绘制直线
- }
- }
- MouseArea {
- anchors.fill: parent // 让MouseArea覆盖整个Image区域
- onClicked: {
- callback_refresh_view(model.name)
- }
- }
- }
- }
- }
- 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 = (materialselviewInstruction.height === 100 ? true : false);
- if(bIsUnfolding)
- {
- viewImage.rotation = 90;
- materialselviewInstruction.height = 600;
- }
- else
- {
- viewImage.rotation = 0;
- materialselviewInstruction.height = 100;
- }
- mainScreen.resetLogin_timeout();
- }
- }
- }
- }
- }
- Timer {
- interval: 1000
- running: true
- repeat: true
- onTriggered: {
- if (bResetTimer)
- {
- mainScreen.resetLogin_timeout();
- }
- }
- }
- // pdf显示
- Rectangle
- {
- id: materialinstructionsPdf
- x:0
- y:0
- width: parent.width
- height: parent.height - 100
- color: "#ffffff"
- radius: 10 // 可选,设置圆角
- visible: false
- Rectangle {
- x:0
- y:0
- width: 1600
- height: 800
- color: "#ffffff"
- radius: 10 // 可选,设置圆角
- Connections {
- target: materialinstructionsPdf
- onVisibleChanged: {
- if (materialinstructionsPdf.visible === true)
- {
- bResetTimer = true;
- mainScreen.changeModel_text_Instructions(strInstructionsTitle);
- }
- else
- {
- bResetTimer = false;
- mainScreen.changeModel_text_Instructions("物资使用说明");
- }
- }
- }
- // pdf显示-pdf文档
- PdfDocument {
- id: pdfDocument
- }
- PdfPageView {
- id: pdfView
- document: pdfDocument
- anchors.top: parent.top
- anchors.bottom: parent.bottom
- // 左右居中
- anchors.horizontalCenter: parent.horizontalCenter
- clip: true
- Connections {
- target: pdfView
- onCurrentPageChanged: {
- pdfView.scaleToPage(pdfView.parent.width, pdfView.parent.height);
- }
- }
- Component.onCompleted: {
- pdfView.scaleToPage(pdfView.parent.width, pdfView.parent.height);
- }
- }
- Image {
- id: materialinstruction_image_pdf_left
- x: 20
- y: parent.height / 2 - 64
- width: 128
- height: 128
- opacity: 0.25
- source: "qrc:/png/pdf_left.png"
- fillMode: Image.PreserveAspectFit
- visible: true;
- }
- Image {
- id: materialinstruction_image_pdf_right
- x: parent.width - 20 - 128
- y: parent.height / 2 - 64
- width: 128
- height: 128
- opacity: 0.25
- source: "qrc:/png/pdf_right.png"
- fillMode: Image.PreserveAspectFit
- visible: true;
- }
- MouseArea {
- anchors.fill: parent
- hoverEnabled: true
- onWheel: {
- if (wheel.angleDelta.y > 0) {
- // 向上滚动 - 上一页
- if (pdfView.currentPage > 0) {
- pdfView.goToPage(pdfView.currentPage - 1)
- }
- } else {
- // 向下滚动 - 下一页
- if (pdfView.currentPage < pdfView.document.pageCount - 1) {
- pdfView.goToPage(pdfView.currentPage + 1)
- }
- }
- }
- onClicked:
- {
- if (mouse.x < parent.width / 2) {
- // 向上滚动 - 上一页
- if (pdfView.currentPage > 0) {
- pdfView.goToPage(pdfView.currentPage - 1)
- }
- } else {
- // 向下滚动 - 下一页
- if (pdfView.currentPage < pdfView.document.pageCount - 1) {
- pdfView.goToPage(pdfView.currentPage + 1)
- }
- }
- }
- }
- }
- Button {
- id: button_return_instructions_pdf
- 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_instructions_pdf
- onClicked: {
- pdfDocument.source = "invalid_path";
- pdfView.document = pdfDocument;
- materialinstructionsPdf.visible = false;
- mainScreen.resetLogin_timeout();
- }
- }
- }
- }
- // mp4显示
- Rectangle
- {
- id: materialinstructionsVideo
- x:0
- y:0
- width: parent.width
- height: parent.height - 100
- color: "#000000"
- radius: 10 // 可选,设置圆角
- visible: false
- Connections {
- target: materialinstructionsVideo
- onVisibleChanged: {
- if (materialinstructionsVideo.visible === true)
- {
- bResetTimer = true;
- mainScreen.changeModel_text_Instructions(strInstructionsTitle);
- }
- else
- {
- bResetTimer = false;
- mainScreen.changeModel_text_Instructions("物资使用说明");
- }
- }
- }
- Video {
- id: videoPlayer
- anchors.fill: parent
- visible: true
- onPlaybackStateChanged: {
- if (videoPlayer.playbackState === MediaPlayer.PlayingState)
- {
- materialinstruction_image_video.visible = false;
- }
- else
- {
- materialinstruction_image_video.visible = true;
- }
- }
- }
- MouseArea {
- anchors.fill: parent
- onClicked: {
- if (videoPlayer.playbackState === MediaPlayer.PlayingState) {
- videoPlayer.pause()
- } else {
- videoPlayer.play()
- }
- }
- }
- Button {
- id: button_return_instructions_video
- 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_instructions_video
- onClicked: {
- videoPlayer.source = "";
- materialinstructionsVideo.visible = false;
- mainScreen.resetLogin_timeout();
- }
- }
- }
- Slider {
- id: progressBar
- anchors {
- left: parent.left
- right: parent.right
- bottom: parent.bottom
- margins: 10
- }
- from: 0
- to: videoPlayer.duration
- value: videoPlayer.position
- onMoved: {
- videoPlayer.seek(progressBar.value)
- }
- }
- Image {
- id: materialinstruction_image_video
- anchors.centerIn: parent
- width: 128
- height: 128
- source: "qrc:/png/play.png"
- fillMode: Image.PreserveAspectFit
- visible: true;
- }
- }
- function slot_pdf_relay(name)
- {
- pdfDocument.source = ""
- pdfDocument.source = "file:///" + name
- materialinstructionsPdf.visible = true
- pdfView.goToPage(pdfView.currentPage + 1);
- pdfView.goToPage(0);
- }
- function callback_refresh_view(title)
- {
- materialInstructionsModel.clear();
- materialsellistInstructionsModel.clear();
- var jsonObjRoot = JSON.parse(strJsonData);
- if (jsonObjRoot.code === 200)
- {
- var jsonArrData = jsonObjRoot.data;
- for (var i = 0; i < jsonArrData.length; ++i)
- {
- var jsonObjData = jsonArrData[i];
- var materialsTypeId = jsonObjData.materialsTypeId;
- var materialsTypeName = jsonObjData.materialsTypeName;
- var materialsTypeIcon = jsonObjData.materialsTypeIcon;
- var number = jsonObjData.number;
- if (materialsTypeName === "全部")
- {
- materialsTypeIcon = "qrc:/png/allsel.png";
- }
- materialsellistInstructionsModel.append({
- count: number,
- icon: materialsTypeIcon,
- name: materialsTypeName,
- view: materialsTypeName === title ? true : false
- });
- if (materialsTypeName !== title)
- {
- continue;
- }
- var jsonArrInstructions = jsonObjData.instructions;
- for (var j = 0; j < jsonArrInstructions.length; ++j)
- {
- var jsonObjInstructions = jsonArrInstructions[j];
- var fileUrl = jsonObjInstructions.fileUrl;
- var fileType = jsonObjInstructions.fileType;
- var instructionsId = jsonObjInstructions.instructionsId;
- var instructionsTitle = jsonObjInstructions.instructionsTitle;
- var png = "";
- if (fileType === "0")
- {
- png = "qrc:/png/videoImg.png";
- }
- else if (fileType === "1")
- {
- png = "qrc:/png/pdfImg.png";
- }
- materialInstructionsModel.append({
- instructionsTitle:instructionsTitle,
- png:png,
- fileType: fileType,
- fileUrl: fileUrl,
- color: "#8fffffff"
- });
- }
- }
- }
- }
- // 获取使用说明列表
- function slot_materialTypeGet(data)
- {
- strMaterialTypeGet = data;
- }
- // 获取使用说明列表
- function slot_instructionsGet(data)
- {
- strInstructionsGet = data;
- build_view("全部");
- }
- // 构建表头List
- function build_view(name)
- {
- var listStr = [];
- var mapData = {};
- materialInstructionsModel.clear();
- materialsellistInstructionsModel.clear();
- var jsonObjInstructionsRoot = JSON.parse(strInstructionsGet);
- if (jsonObjInstructionsRoot.code === 200)
- {
- var jsonObjInstructionsData = jsonObjInstructionsRoot.data;
- var jsonArrInstructionsRecords = jsonObjInstructionsData.records;
- for (var i = 0; i < jsonArrInstructionsRecords.length; ++i)
- {
- var jsonObjInstructions = jsonArrInstructionsRecords[i];
- var fileType = jsonObjInstructions.fileType;
- var fileUrl = jsonObjInstructions.fileUrl;
- var strPath = fileUrl.substring(0, fileUrl.lastIndexOf('/') + 1);
- var strName = fileUrl.substring(fileUrl.lastIndexOf('/') + 1);
- var png = "";
- if (fileType === "0")
- {
- png = "qrc:/png/videoImg.png";
- }
- else if (fileType === "1")
- {
- png = "qrc:/png/pdfImg.png";
- }
- // 获取标题
- var instructionsTitle = jsonObjInstructions.instructionsTitle;
- var materialsTypeName = jsonObjInstructions.materialsTypeName;
- if (materialsTypeName === name || name === "全部")
- {
- materialInstructionsModel.append({instructionsTitle:instructionsTitle, png:png, fileType: fileType, fileUrl: fileUrl, strPath:strPath, strName: strName, color: "#8fffffff"});
- }
- if(listStr.indexOf(materialsTypeName) === -1)
- {
- listStr.push(materialsTypeName);
- mapData[materialsTypeName] = 1;
- }
- else
- {
- mapData[materialsTypeName]++;
- }
- }
- }
- // 读取类型
- var jsonObjMaterialTypeRoot = JSON.parse(strMaterialTypeGet);
- if (jsonObjMaterialTypeRoot.code === 200)
- {
- var jsonObjMaterialTypeData = jsonObjMaterialTypeRoot.data;
- var jsonArrMaterialTypeRecords = jsonObjMaterialTypeData.records;
- var count = 0;
- for (var j = 0; j < jsonArrMaterialTypeRecords.length; ++j)
- {
- var jsonObjMaterialType = jsonArrMaterialTypeRecords[j];
- var typeName = jsonObjMaterialType.materialsTypeName;
- var typeIcon = jsonObjMaterialType.materialsTypeIcon;
- if (listStr.indexOf(typeName) !== -1)
- {
- var countView = typeName + "(" + mapData[typeName] + ")";
- materialsellistInstructionsModel.append({count: countView,icon: typeIcon, name: typeName, view: name === typeName ? true : false});
- count += mapData[typeName];
- }
- }
- var countAllView = "全部" + "(" + count + ")";
- materialsellistInstructionsModel.insert(0, {count: countAllView, icon: "qrc:/png/allsel.png", name: "全部", view: name === "全部" ? true : false});
- }
- }
- }
|