From 42b9ecf2ffd6048bb5bda2d3a1fbf35493d54be9 Mon Sep 17 00:00:00 2001 From: karlis <2995621482@qq.com> Date: Thu, 6 Jul 2023 16:09:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0FileListItem=E5=8F=B3?= =?UTF-8?q?=E9=94=AE=E8=8F=9C=E5=8D=95=E5=92=8C=E9=83=A8=E5=88=86=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AicsKnowledgeBase/qml/component/FileList.qml | 174 ++++++++++-------- .../qml/component/FileListItem.qml | 47 +++++ 2 files changed, 141 insertions(+), 80 deletions(-) diff --git a/AicsKnowledgeBase/qml/component/FileList.qml b/AicsKnowledgeBase/qml/component/FileList.qml index 5ea92ec..78cfd61 100644 --- a/AicsKnowledgeBase/qml/component/FileList.qml +++ b/AicsKnowledgeBase/qml/component/FileList.qml @@ -38,6 +38,7 @@ Item { Component { id: fileListItemHeader ColumnLayout { + id: topColumnLayout function add(folderName, uuid) { console.log(header.items) header.items = header.items.concat([{ @@ -45,6 +46,77 @@ Item { "uuid": uuid }]) } + function update() { + var uuid = header.items.length + === 0 ? "null" : header.items[header.items.length - 1].uuid + Request.get("/knowledge/" + uuid, function (response) { + var data = JSON.parse(response) + console.log(response) + console.log(data.knowledgeFileAttribute) + fileListModel.clear() + var files = data.children + for (var i = 0; i < files.length; i++) { + var file = files[i] + console.log(file.name) + var modelItem = { + "title": file.name, + "uuid": file.id, + "date"// cut time after 'T' + : file.createTime.substring(0, 10), + "fuuid": uuid + } + if (file.knowledgeFileAttribute === null) { + modelItem.type = "folder" + modelItem.isDir = true + modelItem.size = 0 + } else { + modelItem.isDir = false + modelItem.type = getType( + file.knowledgeFileAttribute.suffix) + modelItem.size = file.knowledgeFileAttribute.size + modelItem.brief = file.knowledgeFileAttribute.brief + modelItem.pageView = file.knowledgeFileAttribute.pageView + modelItem.stars = 0 + // merge file.knowledgeFileAttribute.tags array to a string + var tagString = "" + for (var j = 0; j < file.knowledgeFileAttribute.tags.length; j++) { + if (j != 0) + tagString = tagString + "," + tagString = tagString + file.knowledgeFileAttribute.tags[j].name + } + modelItem.tags = tagString + } + fileListModel.append(modelItem) + } + console.log(fileListModel.count) + listView.currentIndex = -1 + }) + } + function getType(suffix) { + if (suffix === "ppt" || suffix === "pptx") + return "PPT" + else if (suffix === "doc" || suffix === "docx") + return "WORD" + else if (suffix === "pdf") + return "PDF" + else if (suffix === "txt") + return "TXT" + else if (suffix === "xls" || suffix === "xlsx") + return "EXCEL" + else if (suffix === "zip" || suffix === "rar") + return "ZIP" + else if (suffix === "png" || suffix === "jpg" + || suffix === "jpeg" || suffix === "gif") + return "IMAGE" + else if (suffix === "mp3" || suffix === "wav") + return "AUDIO" + else if (suffix === "mp4" || suffix === "avi" + || suffix === "rmvb" || suffix === "rm" + || suffix === "wmv" || suffix === "mkv") + return "VIDEO" + else + return "OTHER" + } RowLayout { Layout.preferredWidth: parent.width Item { @@ -53,14 +125,21 @@ Item { width: 28 InputDialog { id: dialog - title: "н¨Îļþ¼Ð" + title: "新建文件夹" buttonFlags: FluContentDialog.PositiveButton | FluContentDialog.NegativeButton - negativeText: "È¡Ïû" - positiveText: "È·¶¨" - message: "ÇëÊäÈëÎļþ¼ÐÃû³Æ" + negativeText: "å–消" + positiveText: "确定" + message: "请输入文件夹å称" onPositiveClicked: text => { - console.log(text) + var param = { + "name": text, + "parentId": header.items[header.items.length + - 1].uuid + } + Request.post( + "/knowledge", + JSON.stringify(param)) } } @@ -77,7 +156,7 @@ Item { } FluButton { Layout.alignment: Qt.AlignRight - text: "ÉÏ´«" + text: "上传" onClicked: function () { console.log("click") fileDialog.open() @@ -135,7 +214,7 @@ Item { header.items = header.items.slice( 0, header.count() - 1) } - fileListItemHeaderItem.update() + topColumnLayout.update() } } FluBreadcrumbBar { @@ -150,81 +229,9 @@ Item { } } onItemsChanged: { - fileListItemHeaderItem.update() + topColumnLayout.update() } } - - function getType(suffix) { - if (suffix === "ppt" || suffix === "pptx") - return "PPT" - else if (suffix === "doc" || suffix === "docx") - return "WORD" - else if (suffix === "pdf") - return "PDF" - else if (suffix === "txt") - return "TXT" - else if (suffix === "xls" || suffix === "xlsx") - return "EXCEL" - else if (suffix === "zip" || suffix === "rar") - return "ZIP" - else if (suffix === "png" || suffix === "jpg" - || suffix === "jpeg" || suffix === "gif") - return "IMAGE" - else if (suffix === "mp3" || suffix === "wav") - return "AUDIO" - else if (suffix === "mp4" || suffix === "avi" - || suffix === "rmvb" || suffix === "rm" - || suffix === "wmv" || suffix === "mkv") - return "VIDEO" - else - return "OTHER" - } - - function update() { - var uuid = header.items.length - === 0 ? "null" : header.items[header.items.length - 1].uuid - Request.get("/knowledge/" + uuid, function (response) { - var data = JSON.parse(response) - console.log(response) - console.log(data.knowledgeFileAttribute) - fileListModel.clear() - var files = data.children - for (var i = 0; i < files.length; i++) { - var file = files[i] - console.log(file.name) - var modelItem = { - "title": file.name, - "uuid": file.id, - "date"// cut time after 'T' - : file.createTime.substring(0, 10) - } - if (file.knowledgeFileAttribute === null) { - modelItem.type = "folder" - modelItem.isDir = true - modelItem.size = 0 - } else { - modelItem.isDir = false - modelItem.type = getType( - file.knowledgeFileAttribute.suffix) - modelItem.size = file.knowledgeFileAttribute.size - modelItem.brief = file.knowledgeFileAttribute.brief - modelItem.pageView = file.knowledgeFileAttribute.pageView - modelItem.stars = 0 - // merge file.knowledgeFileAttribute.tags array to a string - var tagString = "" - for (var j = 0; j < file.knowledgeFileAttribute.tags.length; j++) { - if (j != 0) - tagString = tagString + "," - tagString = tagString + file.knowledgeFileAttribute.tags[j].name - } - modelItem.tags = tagString - } - fileListModel.append(modelItem) - } - console.log(fileListModel.count) - listView.currentIndex = -1 - }) - } } } } @@ -238,6 +245,7 @@ Item { FileListItem { id: fileListItem uuid: model.uuid + fuuid: model.fuuid width: parent.width height: parent.height title: model.title @@ -256,6 +264,9 @@ Item { emit: search(tag) console.log(tag) } + onRefresh: { + listView.headerItem.update() + } } function doubleClicked() { listView.currentIndex = index @@ -275,6 +286,7 @@ Item { isDir: true brief: "This is a test file" type: "FOLDER" + fuuid: "1" } ListElement { uuid: "2" @@ -286,6 +298,7 @@ Item { date: "2020-09-09" pageView: 100 stars: 10 + fuuid: "1" } ListElement { uuid: "3" @@ -297,6 +310,7 @@ Item { pageView: 100 size: 10200000022 stars: 10 + fuuid: "1" } } } diff --git a/AicsKnowledgeBase/qml/component/FileListItem.qml b/AicsKnowledgeBase/qml/component/FileListItem.qml index 2eaab06..c7383b3 100644 --- a/AicsKnowledgeBase/qml/component/FileListItem.qml +++ b/AicsKnowledgeBase/qml/component/FileListItem.qml @@ -5,6 +5,7 @@ import QtQuick.Layouts FluArea { id: fileItem property string uuid + property string fuuid: null property string title property string brief property string date @@ -18,6 +19,46 @@ FluArea { property int stars property var colorList: ["blue", "green", "orange", "red", "yellow", "purple", "pink", "brown", "teal", "cyan", "gray", "darkgray"] signal tagClicked(string tag) + signal refresh + FluMenu { + id: menu + FluMenuItem { + text: "é‡å‘½å" + onClicked: { + dialog.open() + } + InputDialog { + id: dialog + title: "é‡å‘½å" + buttonFlags: FluContentDialog.PositiveButton | FluContentDialog.NegativeButton + negativeText: "å–消" + positiveText: "确定" + message: fileItem.title + onPositiveClicked: text => { + var param = { + "name": text, + "parentId": fuuid + } + Request.post("/knowledge", + JSON.stringify(param)) + refresh() + } + } + } + FluMenuItem { + text: "移动至" + onClicked: { + refresh() + } + } + FluMenuItem { + text: "删除" + onClicked: { + Request.delete("/knowledge/" + uuid) + refresh() + } + } + } ColumnLayout { id: row @@ -30,9 +71,15 @@ FluArea { anchors.fill: parent MouseArea { anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton onDoubleClicked: { fileItem.parent.doubleClicked() } + onClicked: { + if (mouse.button === Qt.RightButton) { + menu.popup() + } + } } RowLayout { id: titleRow