添加新建文件夹静态逻辑

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