添加新建文件夹静态逻辑

main
karlis 2023-07-06 15:10:13 +08:00
parent 428ee6fafe
commit fea5bd698d
3 changed files with 194 additions and 37 deletions

View File

@ -2,6 +2,7 @@ import QtQuick 2.15
import QtQuick.Layouts
import FluentUI
import QtQuick.Dialogs
import QtQuick.Controls
import "qrc:///AicsKnowledgeBase/qml/global"
import SignalFileOperation 1.0
import AicsKB.FileTransferManager
@ -44,43 +45,76 @@ Item {
"uuid": uuid
}])
}
FluButton {
Layout.alignment: Qt.AlignRight
text: "上传"
onClicked: function () {
console.log("click")
fileDialog.open()
}
FileDialog {
id: fileDialog
onAccepted: function () {
let name = FileTransferManager.getFileName(selectedFile)
const size = FileTransferManager.getFileSize(
selectedFile)
const md5 = FileTransferManager.getFileMd5(selectedFile)
if (size <= 0 || md5 === '')
return
var body = {
"name": name,
"brief": "brief",
"size": size,
"md5": md5,
"tags": [],
"parentId": header.items.length
!== 0 ? header.items[header.items.length - 1].uuid : null
RowLayout {
Layout.preferredWidth: parent.width
Item {
Layout.alignment: Qt.AlignRight
height: 28
width: 28
InputDialog {
id: dialog
title: "新建文件夹"
buttonFlags: FluContentDialog.PositiveButton
| FluContentDialog.NegativeButton
negativeText: "取消"
positiveText: "确定"
message: "请输入文件夹名称"
onPositiveClicked: text => {
console.log(text)
}
}
Image {
source: "qrc:/AicsKnowledgeBase/res/createFolder.png"
anchors.fill: parent
}
MouseArea {
anchors.fill: parent
onClicked: {
dialog.open()
}
}
}
FluButton {
Layout.alignment: Qt.AlignRight
text: "上传"
onClicked: function () {
console.log("click")
fileDialog.open()
}
FileDialog {
id: fileDialog
onAccepted: function () {
let name = FileTransferManager.getFileName(
selectedFile)
const size = FileTransferManager.getFileSize(
selectedFile)
const md5 = FileTransferManager.getFileMd5(
selectedFile)
if (size <= 0 || md5 === '')
return
var body = {
"name": name,
"brief": "brief",
"size": size,
"md5": md5,
"tags": [],
"parentId": header.items.length !== 0 ? header.items[header.items.length - 1].uuid : null
}
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(
selectedFile, data.id,
data.ticket, name)
}, function (res, data) {
console.log(res)
})
}
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(
selectedFile, data.id,
data.ticket, name)
}, function (res, data) {
console.log(res)
})
}
}
}
@ -151,6 +185,7 @@ Item {
=== 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
@ -186,7 +221,7 @@ Item {
}
fileListModel.append(modelItem)
}
console.log(fileListModel)
console.log(fileListModel.count)
listView.currentIndex = -1
})
}

View File

@ -0,0 +1,122 @@
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import QtQuick.Window
import FluentUI
FluPopup {
id: popup
property string title: "Title"
property string message: "Message"
property string neutralText: "Neutral"
property string negativeText: "Negative"
property string positiveText: "Positive"
signal neutralClicked
signal negativeClicked
signal positiveClicked(string text)
enum ButtonFlag {
NegativeButton = 1,
NeutralButton = 2,
PositiveButton = 4
}
property int buttonFlags: FluContentDialog.NegativeButton | FluContentDialog.PositiveButton
property var minWidth: {
if (Window.window == null)
return 400
return Math.min(Window.window.width, 400)
}
focus: true
Rectangle {
id: layout_content
anchors.fill: parent
implicitWidth: minWidth
implicitHeight: text_title.height + text_message.height + layout_actions.height
color: 'transparent'
radius: 5
FluText {
id: text_title
font: FluTextStyle.TitleLarge
text: title
topPadding: 20
leftPadding: 20
rightPadding: 20
wrapMode: Text.WrapAnywhere
anchors {
top: parent.top
left: parent.left
right: parent.right
}
}
FluTextBox {
id: text_message
font: FluTextStyle.Body
wrapMode: Text.WrapAnywhere
placeholderText: message
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: neutral_btn
Layout.fillWidth: true
Layout.fillHeight: true
visible: popup.buttonFlags & FluContentDialog.NeutralButton
text: neutralText
onClicked: {
popup.close()
neutralClicked()
}
}
FluButton {
id: negative_btn
Layout.fillWidth: true
Layout.fillHeight: true
visible: popup.buttonFlags & FluContentDialog.NegativeButton
text: negativeText
onClicked: {
popup.close()
negativeClicked()
}
}
FluFilledButton {
id: positive_btn
Layout.fillWidth: true
Layout.fillHeight: true
visible: popup.buttonFlags & FluContentDialog.PositiveButton
text: positiveText
onClicked: {
popup.close()
positiveClicked(text_message.text)
}
}
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB