import QtQuick 2.15 import QtQuick.Layouts import FluentUI import QtQuick.Dialogs import "qrc:///AicsKnowledgeBase/qml/global" import SignalFileOperation 1.0 import AicsKB.FileTransferManager FluButton { property var header property var currentSelectedFile: null Layout.alignment: Qt.AlignRight text: "上传" onClicked: function () { console.log("click") fileDialog.open() } FileDialog { id: fileDialog onAccepted: function () { currentSelectedFile = selectedFile popup.open() } onRejected: currentSelectedFile = null } FluPopup { id: popup focus: true Rectangle { id: layout_content anchors.fill: parent implicitWidth: Window.window == null ? 400 : Math.min( Window.window.width, 400) implicitHeight: text_title.height + text_message.height + layout_actions.height color: 'transparent' radius: 5 FluText { id: text_title font: FluTextStyle.TitleLarge text: "上传知识文件" topPadding: 20 leftPadding: 20 rightPadding: 20 wrapMode: Text.WrapAnywhere anchors { top: parent.top left: parent.left right: parent.right } } FluText { id: text_message font: FluTextStyle.Body wrapMode: Text.WrapAnywhere text: "content" topPadding: 14 leftPadding: 20 rightPadding: 20 bottomPadding: 14 anchors { top: text_title.bottom left: parent.left right: parent.right } } Rectangle { id: layout_actions height: 68 radius: 5 color: FluTheme.dark ? Qt.rgba( 32 / 255, 32 / 255, 32 / 255, blurBackground ? blurOpacity - 0.4 : 1) : Qt.rgba( 243 / 255, 243 / 255, 243 / 255, blurBackground ? blurOpacity - 0.4 : 1) anchors { top: text_message.bottom left: parent.left right: parent.right } RowLayout { anchors { centerIn: parent margins: spacing fill: parent } spacing: 15 FluButton { id: negative_btn Layout.fillWidth: true Layout.fillHeight: true text: "取消" onClicked: { popup.close() } } FluFilledButton { id: positive_btn Layout.fillWidth: true Layout.fillHeight: true text: "上传" onClicked: { popup.close() let name = FileTransferManager.getFileName( currentSelectedFile) const size = FileTransferManager.getFileSize( currentSelectedFile) const md5 = FileTransferManager.getFileMd5( currentSelectedFile) if (size <= 0 || md5 === '') return var body = { "name": name, "brief": "brief", "size": size, "md5": md5, "tags": [], "parentId": currentParentId() } console.log("begin") console.log(JSON.stringify(body)) Request.post("knowledge/file", JSON.stringify(body), function (res, data) { console.log(res) console.log(data) FileTransferManager.upload( currentSelectedFile, data.id, data.ticket, name) }, function (res, data) { console.log(res) }) } } } } } } function currentParentId() { return header.items.length !== 0 ? header.items[header.items.length - 1].uuid : null } }