AicsKnowledgeBase_client/AicsKnowledgeBase/qml/page/CreateNotePage.qml

179 lines
6.0 KiB
QML

import QtQuick
import QtQuick.Layouts
import QtQuick.Window
import QtQuick.Controls
import QtQuick.Controls.Basic
import QtWebEngine 1.2
import FluentUI
import AicsKB.FileTransferManager
import SignalFileOperation 1.0
import "qrc:///AicsKnowledgeBase/qml/page"
import "qrc:///AicsKnowledgeBase/qml/component"
import "qrc:///AicsKnowledgeBase/qml/global"
FluArea {
id: edit_area
paddings: 0
backgroundColor: "#f9f9f9"
property string knowledgeFileId
property string fileType: "OTHER"
property string fileTitle: "dgfgf"
property string noteFileId
property string noteTitle: ""
property string noteContent: ""
property var tags: []
property bool isModifying: false
Component.onCompleted: {
console.log(knowledgeFileId)
isModifying = false
if (isModifying) {
Request.getSearch("/search/note/" + noteFileId + "/content",
function (response, data) {
input_title.text = data.title
input_md.contentMd = data.content
tags = data.tags
})
}
noteTitle = Qt.binding(function () {
return input_title.text
})
noteContent = Qt.binding(function () {
return input_md.contentMd
})
}
FluScrollablePage {
id: edit_page
anchors.fill: parent
leftPadding: 5
topPadding: 5
rightPadding: 5
bottomPadding: 0
Item {
Layout.fillWidth: true
implicitHeight: 30
Layout.leftMargin: 5
Layout.bottomMargin: 10
MouseArea {
anchors.fill: parent
onDoubleClicked: {
emit: SignalFileOperation.open(note_page.knowledgeFileId)
}
}
RowLayout {
id: titleRow
RowLayout {
FluIconButton {
iconSize: 12
iconSource: FluentIcons.Back
onClicked: {
emit: SignalFileOperation.back()
}
}
}
Image {
id: icon
source: edit_area.fileType ? "qrc:/AicsKnowledgeBase/res/"
+ edit_area.fileType + ".png" : ""
Layout.preferredHeight: 24
Layout.preferredWidth: 24
}
FluText {
id: title
font.bold: true
font.pointSize: 12
text: edit_area.fileTitle
}
}
}
Item {
Layout.fillWidth: true
implicitHeight: 50
FluText {
id: text_title
padding: 10
text: "标题"
font {
pointSize: 15
bold: true
}
}
FluTextBox {
id: input_title
padding: 10
placeholderText: "单行输入框"
implicitWidth: parent.width
font.pointSize: 12
anchors {
left: text_title.right
verticalCenter: text_title.verticalCenter
}
}
}
FluText {
padding: 10
text: "内容"
font {
pointSize: 15
bold: true
}
}
NoteEditPage {
id: input_md
noteId: "255454"
width: parent.width
height: width * 9 / 16
isEditable: true
isEditing: true
}
RowLayout {
Layout.alignment: Qt.AlignCenter
Layout.topMargin: 10
FluFilledButton {
text: "上传"
onClicked: {
if (noteTitle.trim() !== "" && noteContent !== "") {
console.log(noteTitle)
console.log(noteContent)
console.log(knowledgeFileId)
if (!isModifying) {
Request.post("note", JSON.stringify({
"title": noteTitle,
"content": noteContent,
"tags": [],
"linkingKnowledgeFiles": [knowledgeFileId]
}),
response => {
console.log(response)
}, response => {
console.log(response)
})
SignalFileOperation.back()
} else {
Request.put("note/" + noteFileId, JSON.stringify({
"title": noteTitle,
"content": noteContent,
"tags": [],
"linkingKnowledgeFiles": [knowledgeFileId]
}))
SignalFileOperation.back()
}
}
}
}
FluButton {
text: "取消"
onClicked: {
emit: SignalFileOperation.back()
}
}
}
}
}