FileList修改样式,上传

main
karlis 2023-07-05 22:31:14 +08:00
parent 0014cc018a
commit 5c1b23421c
4 changed files with 125 additions and 97 deletions

View File

@ -35,7 +35,53 @@ Item {
Component { Component {
id: fileListItemHeader id: fileListItemHeader
ColumnLayout {
function add(folderName, uuid) {
console.log(header.items)
header.items = header.items.concat([{
"title": folderName,
"uuid": uuid
}])
}
FluButton {
Layout.alignment: Qt.AlignRight
text: "上传"
onClicked: function () {
console.log("click")
fileDialog.open()
}
FileDialog {
id: fileDialog
onAccepted: function () {
const size = FileTransferManager.getFileSize(
selectedFile)
const md5 = FileTransferManager.getFileMd5(selectedFile)
if (size <= 0 || md5 === '')
return
var body = {
"name": "test2",
"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)
}, function (res, data) {
console.log(res)
})
}
}
}
RowLayout { RowLayout {
id: fileListItemHeaderItem id: fileListItemHeaderItem
width: ListView.view.width width: ListView.view.width
@ -50,14 +96,15 @@ Item {
iconSource: FluentIcons.ForwardCall iconSource: FluentIcons.ForwardCall
onClicked: { onClicked: {
if (header.count() > 0) { if (header.count() > 0) {
header.items = header.items.slice(0, header.count() - 1) header.items = header.items.slice(
0, header.count() - 1)
} }
fileListItemHeaderItem.update() fileListItemHeaderItem.update()
} }
} }
FluBreadcrumbBar { FluBreadcrumbBar {
id: header id: header
//width: parent.width width: parent.width
height: parent.height height: parent.height
separator: ">" separator: ">"
items: [] items: []
@ -71,68 +118,36 @@ Item {
} }
} }
FluButton {
Layout.alignment: Qt.AlignRight
text: "上传"
onClicked: function () {
console.log("click")
fileDialog.open()
}
FileDialog {
id: fileDialog
onAccepted: function () {
const size = FileTransferManager.getFileSize(
selectedFile)
const md5 = FileTransferManager.getFileMd5(selectedFile)
if (size <= 0 || md5 === '')
return
var body = {
"name": "test2",
"brief": "brief",
"size": size,
"md5": md5,
"tags": [],
"parentId": 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)
}, function (res, data) {
console.log(res)
})
}
}
}
function add(folderName, uuid) {
console.log(header.items)
header.items = header.items.concat([{
"title": folderName,
"uuid": uuid
}])
}
function getType(suffix) { function getType(suffix) {
if (suffix === "ppt" || suffix === "pptx") if (suffix === "ppt" || suffix === "pptx")
return "PPT" return "PPT"
else if (suffix === "doc" || suffix === "docx") else if (suffix === "doc" || suffix === "docx")
return "WORD" return "WORD"
else if (suffix === "pdf")
return "PDF"
else if (suffix === "txt")
return "TXT"
else if (suffix === "xls" || suffix === "xlsx")
return "EXCEL"
else if (suffix === "zip" || suffix === "rar")
return "ZIP"
else if (suffix === "png" || suffix === "jpg"
|| suffix === "jpeg" || suffix === "gif")
return "IMAGE"
else if (suffix === "mp3" || suffix === "wav")
return "AUDIO"
else if (suffix === "mp4" || suffix === "avi"
|| suffix === "rmvb" || suffix === "rm"
|| suffix === "wmv" || suffix === "mkv")
return "VIDEO"
else
return "OTHER"
} }
function update() { function update() {
var uuid = header.items.length var uuid = header.items.length
=== 0 ? "null" : header.items[header.items.length - 1].uuid === 0 ? "null" : header.items[header.items.length - 1].uuid
Request.get(uuid, function (response) { Request.get("/knowledge/" + uuid, function (response) {
var data = JSON.parse(response) var data = JSON.parse(response)
console.log(data.knowledgeFileAttribute) console.log(data.knowledgeFileAttribute)
fileListModel.clear() fileListModel.clear()
@ -143,7 +158,8 @@ Item {
var modelItem = { var modelItem = {
"title": file.name, "title": file.name,
"uuid": file.id, "uuid": file.id,
"date": file.createTime "date"// cut time after 'T'
: file.createTime.substring(0, 10)
} }
if (file.knowledgeFileAttribute === null) { if (file.knowledgeFileAttribute === null) {
modelItem.type = "folder" modelItem.type = "folder"
@ -174,6 +190,7 @@ Item {
} }
} }
} }
}
Component { Component {
id: fileListItemDelegate id: fileListItemDelegate
Rectangle { Rectangle {
@ -206,6 +223,7 @@ Item {
function doubleClicked() { function doubleClicked() {
listView.currentIndex = index listView.currentIndex = index
if (model.isDir) { if (model.isDir) {
console.log(listView.headerItem)
listView.headerItem.add(model.title, model.uuid) listView.headerItem.add(model.title, model.uuid)
} else { } else {
emit: SignalFileOperation.open(model.uuid) emit: SignalFileOperation.open(model.uuid)

View File

@ -39,11 +39,13 @@ FluArea {
Image { Image {
id: icon id: icon
source: type ? "qrc:/AicsKnowledgeBase/res/" + type + ".png" : "" source: type ? "qrc:/AicsKnowledgeBase/res/" + type + ".png" : ""
Layout.preferredHeight: 18 Layout.preferredHeight: 32
Layout.preferredWidth: 18 Layout.preferredWidth: 32
} }
FluText { FluText {
id: title id: title
font.bold: true
font.pointSize: 15
text: fileItem.title text: fileItem.title
} }
} }
@ -52,17 +54,23 @@ FluArea {
id: brief id: brief
visible: !fileItem.isDir visible: !fileItem.isDir
text: fileItem.brief text: fileItem.brief
Layout.fillWidth: true
wrapMode: Text.WrapAnywhere
elide: Text.ElideRight
maximumLineCount: 2
} }
RowLayout { RowLayout {
id: infoRow id: infoRow
visible: !fileItem.isDir visible: !fileItem.isDir
FluText { FluText {
id: date id: date
color: "#5F5F5F"
text: fileItem.date text: fileItem.date
} }
FluText { FluText {
id: size id: size
// cast Byte size to right text size // cast Byte size to right text size
color: "#5F5F5F"
text: fileItem.size > 1024 text: fileItem.size > 1024
* 1024 ? (fileItem.size / 1024 / 1024).toFixed( * 1024 ? (fileItem.size / 1024 / 1024).toFixed(
2) + "MB" : (fileItem.size / 1024).toFixed( 2) + "MB" : (fileItem.size / 1024).toFixed(
@ -70,10 +78,12 @@ FluArea {
} }
FluText { FluText {
id: pageView id: pageView
color: "#5F5F5F"
text: fileItem.pageView + "浏览" text: fileItem.pageView + "浏览"
} }
FluText { FluText {
id: stars id: stars
color: "#5F5F5F"
text: fileItem.stars + "收藏" text: fileItem.stars + "收藏"
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB