AicsKnowledgeBase_client/AicsKnowledgeBase/qml/page/SearchPage.qml

244 lines
7.6 KiB
QML

import QtQuick
import QtQuick.Layouts
import QtQuick.Window
import QtQuick.Controls
import QtQuick.Controls.Basic
import FluentUI
import "qrc:///AicsKnowledgeBase/qml/global"
import "qrc:///AicsKnowledgeBase/qml/component"
FluArea {
id: searchPage
property string url: ''
backgroundColor: "#f9f9f9"
Layout.fillHeight: true
Layout.fillWidth: true
Layout.topMargin: 20
paddings: 10
// FluText {
// Layout.topMargin: 20
// text: "Search"
// }
/*
按标题,内容搜索
*/
ColumnLayout {
width: parent.width
RowLayout {
width: parent.width
// FluDropDownButton{
// id:select_model
// Layout.alignment: Qt.AlignLeft
// text:"标题"
// items:[
// FluMenuItem{
// text:"标题"
// onClicked: {
// select_model.text = text
// }
// },
// FluMenuItem{
// text:"内容"
// onClicked: {
// select_model.text = text
// }
// },
// FluMenuItem{
// text:"标题及内容"
// onClicked: {
// select_model.text = text
// }
// }
// ]
// }
FluTextBox {
placeholderText: "对标题进行搜索……"
Layout.fillWidth: true
}
FluIconButton {
Layout.alignment: Qt.AlignRight
iconSource: FluentIcons.Search
onClicked: {
var allTags = inputTags.getAllTags(tags.tagList)
var allTagId = []
console.log(allTags)
for (var i = 0; i < allTags.length; i++) {
var url = "?name="
url = url + allTags[i]
console.log(url)
Request.get(url, function (result, data) {
allTagId.push()
})
}
}
}
}
FluCheckBox {
id: searchTitleAndContent
text: "同时搜索简介和内容"
}
//按文件类型
RowLayout {
id: selectFormat
width: parent.width
FluText {
Layout.alignment: Qt.AlignLeft
text: "类型: "
}
FluCheckBox {
id: selectAllFormat
text: "all"
Component.onCompleted: {
clicked()
}
onClicked: {
selectVideo.checked = true
selectDoc.checked = true
selectAudio.checked = true
}
}
FluCheckBox {
id: selectVideo
text: "Video"
onClicked: {
selectFormat.setAllStatus()
}
}
FluCheckBox {
id: selectDoc
text: "Doc"
onClicked: {
selectFormat.setAllStatus()
}
}
FluCheckBox {
id: selectAudio
text: "Audio"
onClicked: {
selectFormat.setAllStatus()
}
}
function setAllStatus() {
selectAllFormat.checked = selectVideo.checked
&& selectDoc.checked && selectAudio.checked
}
}
RowLayout {
id: inputTags
width: parent.width
height: 32
FluText {
Layout.alignment: Qt.AlignLeft
text: "标签: "
}
Tag {
id: tags
width: 290
}
function getAllTags(tagList) {
var allTags = []
for (var i = 0; i < tagList.count; i++) {
var item = tagList.get(i)
allTags.push(item.tag)
}
return allTags
//console.log(allTags)
}
}
FluArea {
backgroundColor: "#f9f9f9"
border.width: 0
width: parent.width
height: 500
FileList {
disableHeader: true
dataModel: ListModel {
ListElement {
uuid: "0"
title: "File 1"
isDir: true
brief: "This is a test file"
type: "FOLDER"
}
ListElement {
uuid: "2"
title: "File 2"
isDir: false
brief: "This is a test file"
size: 500
type: "WORD"
date: "2020-09-09"
pageView: 100
stars: 10
}
ListElement {
uuid: "3"
title: "File 3"
isDir: false
brief: "This is a test file"
type: "PPT"
date: "2020-09-09"
pageView: 100
size: 10200000022
stars: 10
}
}
}
}
}
function getKnowledgeDetail(uuid, title, brief, tags) {
var raw = Request.getAwait("/knowledget/" + uuid)
var data = JSON.parse(raw)
var item = {
"uuid": uuid,
"title": title,
"brief": brief,
"isDir": false,
"date": data.createTime,
"fuuid": data.parent.id,
"pageView": data.knowledgeFileAttribute.pageView,
"stars": data.knowledgeFileAttribute.stars,
"size": data.knowledgeFileAttribute.size,
"type": getType(data.knowledgeFileAttribute.suffix),
"tags": tags
}
}
function getType(suffix) {
if (suffix === "ppt" || suffix === "pptx")
return "PPT"
else if (suffix === "doc" || suffix === "docx")
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"
}
}