Merge branch 'main' of http://101.34.228.45:3000/auto/AicsKnowledgeBase into main
commit
db82f35384
|
@ -28,7 +28,7 @@ Item {
|
|||
delegate: fileListItemDelegate
|
||||
Component.onCompleted: {
|
||||
if (autoRequest) {
|
||||
update()
|
||||
topColumnLayout.update()
|
||||
} else {
|
||||
listView.model = dataModel
|
||||
}
|
||||
|
@ -47,14 +47,15 @@ Item {
|
|||
}])
|
||||
}
|
||||
function update() {
|
||||
console.log("1231231")
|
||||
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
|
||||
var items = []
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
var file = files[i]
|
||||
console.log(file.name)
|
||||
|
@ -86,7 +87,14 @@ Item {
|
|||
}
|
||||
modelItem.tags = tagString
|
||||
}
|
||||
fileListModel.append(modelItem)
|
||||
items.push(modelItem)
|
||||
}
|
||||
fileListModel.clear()
|
||||
for (i = 0; i < items.length; i++) {
|
||||
if (items[i].isDir)
|
||||
fileListModel.insert(0, items[i])
|
||||
else
|
||||
fileListModel.append(items[i])
|
||||
}
|
||||
console.log(fileListModel.count)
|
||||
listView.currentIndex = -1
|
||||
|
@ -120,7 +128,7 @@ Item {
|
|||
RowLayout {
|
||||
Layout.preferredWidth: parent.width
|
||||
Item {
|
||||
Layout.alignment: Qt.AlignRight
|
||||
anchors.right: uploadBtn.left
|
||||
height: 28
|
||||
width: 28
|
||||
InputDialog {
|
||||
|
@ -134,12 +142,14 @@ Item {
|
|||
onPositiveClicked: text => {
|
||||
var param = {
|
||||
"name": text,
|
||||
"parentId": header.items[header.items.length
|
||||
- 1].uuid
|
||||
"parentId": header.items.length === 0 ? null : header.items[header.items.length - 1].uuid
|
||||
}
|
||||
Request.post(
|
||||
"/knowledge",
|
||||
JSON.stringify(param))
|
||||
Request.post("/knowledge",
|
||||
JSON.stringify(
|
||||
param)).then(
|
||||
function (response) {
|
||||
topColumnLayout.update()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,8 +164,47 @@ Item {
|
|||
}
|
||||
}
|
||||
}
|
||||
UploadButton {
|
||||
header: header
|
||||
FluButton {
|
||||
id: uploadIcon
|
||||
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")
|
||||
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)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
RowLayout {
|
||||
|
@ -226,9 +275,15 @@ Item {
|
|||
console.log(tag)
|
||||
}
|
||||
onRefresh: {
|
||||
console.log("------------" + listView.headerItem)
|
||||
parent.refresh()
|
||||
}
|
||||
}
|
||||
function refresh() {
|
||||
console.log("refresh")
|
||||
listView.headerItem.update()
|
||||
}
|
||||
}
|
||||
|
||||
function doubleClicked() {
|
||||
listView.currentIndex = index
|
||||
if (model.isDir) {
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import QtQuick 2.15
|
||||
import FluentUI
|
||||
import QtQuick.Layouts
|
||||
import "qrc:///AicsKnowledgeBase/qml/global"
|
||||
|
||||
FluArea {
|
||||
id: fileItem
|
||||
property string uuid
|
||||
property string fuuid: null
|
||||
property var fuuid: null
|
||||
property string title
|
||||
property string brief
|
||||
property string date
|
||||
|
@ -48,7 +49,26 @@ FluArea {
|
|||
FluMenuItem {
|
||||
text: "移动至"
|
||||
onClicked: {
|
||||
moveDialog.load()
|
||||
moveDialog.open()
|
||||
}
|
||||
TreeViewDialog {
|
||||
id: moveDialog
|
||||
title: "选择目标文件夹"
|
||||
buttonFlags: FluContentDialog.PositiveButton | FluContentDialog.NegativeButton
|
||||
negativeText: "取消"
|
||||
positiveText: "确定"
|
||||
onPositiveClicked: uuid => {
|
||||
var param = {
|
||||
"parentId": uuid,
|
||||
"name": fileItem.title
|
||||
}
|
||||
Request.put(
|
||||
"/knowledge/" + fileItem.uuid,
|
||||
JSON.stringify(param), () => {
|
||||
refresh()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
FluMenuItem {
|
||||
|
|
|
@ -0,0 +1,178 @@
|
|||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Window
|
||||
import FluentUI
|
||||
import "qrc:///AicsKnowledgeBase/qml/global"
|
||||
|
||||
FluPopup {
|
||||
id: popup
|
||||
property string title: "Title"
|
||||
property string neutralText: "Neutral"
|
||||
property string negativeText: "Negative"
|
||||
property string positiveText: "Positive"
|
||||
x: (parent.width - width) / 2
|
||||
y: (parent.height - height) / 2
|
||||
signal neutralClicked
|
||||
signal negativeClicked
|
||||
signal positiveClicked(var 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
|
||||
function load() {
|
||||
tree_view.updateData(pullFolderLevel())
|
||||
}
|
||||
function pullFolderLevel() {
|
||||
var root = {
|
||||
"text": "/",
|
||||
"expanded": true,
|
||||
"items": getNextLevel("null"),
|
||||
"data": {
|
||||
"uuid": null
|
||||
}
|
||||
}
|
||||
return root
|
||||
}
|
||||
function getNextLevel(uuid) {
|
||||
var items = []
|
||||
var raw = (Request.getAwait("/knowledge/" + uuid))
|
||||
var data = JSON.parse(raw).children
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
if (data[i].knowledgeFileAttribute !== null)
|
||||
continue
|
||||
console.log(data[i].name)
|
||||
var item = {
|
||||
"text": data[i].name,
|
||||
"expanded": false,
|
||||
"items": [],
|
||||
"data"//getNextLevel(data[i].id),
|
||||
: {
|
||||
"uuid": data[i].id
|
||||
}
|
||||
}
|
||||
items.push(item)
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
FluArea {
|
||||
id: text_message
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 10
|
||||
paddings: 10
|
||||
height: 300
|
||||
anchors {
|
||||
top: text_title.bottom
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
FluTreeView {
|
||||
id: tree_view
|
||||
width: parent.width - 20
|
||||
selectionMode: FluTreeView.Single
|
||||
anchors {
|
||||
top: parent.top
|
||||
left: parent.left
|
||||
bottom: parent.bottom
|
||||
}
|
||||
onItemClicked: model => {}
|
||||
|
||||
Component.onCompleted: {
|
||||
createItem()
|
||||
//updateData(pullFolderLevel())
|
||||
}
|
||||
}
|
||||
}
|
||||
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: {
|
||||
if (tree_view.currentElement === null) {
|
||||
showError("没有选中数据")
|
||||
return
|
||||
}
|
||||
popup.close()
|
||||
console.log(tree_view.currentElement.data.uuid)
|
||||
positiveClicked(tree_view.currentElement.data.uuid)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,6 +18,14 @@ QtObject {
|
|||
xhr.send()
|
||||
}
|
||||
|
||||
function getAwait(url) {
|
||||
var xhr = new XMLHttpRequest
|
||||
xhr.open("GET", baseUrl + url, false)
|
||||
xhr.send(null)
|
||||
// wait for response then return response data
|
||||
return xhr.responseText
|
||||
}
|
||||
|
||||
// POST
|
||||
function post(url, arg, success, failure) {
|
||||
var xhr = new XMLHttpRequest
|
||||
|
@ -30,6 +38,18 @@ QtObject {
|
|||
xhr.send(arg)
|
||||
}
|
||||
|
||||
// PUT
|
||||
function put(url, arg, success, failure) {
|
||||
var xhr = new XMLHttpRequest
|
||||
xhr.open("PUT", baseUrl + url, true)
|
||||
xhr.setRequestHeader('Content-Type', 'application/json')
|
||||
xhr.withCredentials = true
|
||||
xhr.onreadystatechange = function () {
|
||||
handleResponse(xhr, success, failure)
|
||||
}
|
||||
xhr.send(arg)
|
||||
}
|
||||
|
||||
|
||||
/* function post(url, arg, success, failure) {
|
||||
var xhr = new XMLHttpRequest
|
||||
|
|
Loading…
Reference in New Issue