Compare commits

..

3 Commits

Author SHA1 Message Date
shmily744 3bd491ee5b Merge branch 'main' of http://101.34.228.45:3000/auto/AicsKnowledgeBase_client 2023-07-07 01:08:56 +08:00
shmily744 6868d82753 Merge branch 'main' of http://101.34.228.45:3000/auto/AicsKnowledgeBase_client
# Conflicts:
#	AicsKnowledgeBase/qml/page/SearchPage.qml
2023-07-07 01:08:43 +08:00
shmily744 ddc67c9f65 完成tag组件 2023-07-07 00:56:12 +08:00
1 changed files with 35 additions and 14 deletions

View File

@ -4,6 +4,8 @@ import QtQuick.Window
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Controls.Basic import QtQuick.Controls.Basic
import FluentUI import FluentUI
import QtQml
import "qrc:///AicsKnowledgeBase/qml/global"
Rectangle { Rectangle {
id: input id: input
@ -13,10 +15,32 @@ Rectangle {
radius: 5 radius: 5
clip: true clip: true
border.color: textInput.activeFocus ? "#268CDC":"#979592" //gray100
ListModel { id: tagListModel } ListModel { id: tagListModel }
property ListModel tagList: tagListModel property ListModel tagList: tagListModel
property var tagMap:[]
property var presetsTags:[]
property var presetsTagsItem:[]
Component.onCompleted: {
Request.get("tag?name",
function(result, data){
// console.log("success")
// console.log(result)
// console.log(data.length)
for(var i =0;i<data.length;i++){
tagMap.push([data[i].id,data[i].name])
presetsTags.push(data[i].name)
presetsTagsItem.push({title:data[i].name})
}
// console.log(tagMap)
// console.log(presetsTags)
},function (p1, p2) {
// console.log("failure")
// console.log(p1)
// console.log(p2)
})
}
Row { Row {
x: 5 x: 5
@ -48,23 +72,23 @@ Rectangle {
width: input.width - rowTag.width width: input.width - rowTag.width
height: parent.height height: parent.height
TextField { FluAutoSuggestBox{
id:textInput id:textInput
placeholderText: qsTr("按回车键Enter创建标签") anchors.verticalCenter: parent.verticalCenter
width: parent.width
placeholderText: "按回车键Enter创建标签"
Layout.preferredWidth: 300
//items:[{title:""},{title:""},{title:""}]
items: presetsTagsItem
onFocusChanged: { onFocusChanged: {
text ="" text =""
} }
anchors.verticalCenter: parent.verticalCenter
width: parent.width - 15
clip: true
background: Rectangle {
}
Keys.onReturnPressed: { Keys.onReturnPressed: {
var presetsTags = ["前端","后端","数据库"]
if (text.length === 0) if (text.length === 0)
return return
@ -72,12 +96,10 @@ Rectangle {
text = "" text = ""
return return
} }
tagListModel.append({"tag": text}) tagListModel.append({"tag": text})
//console.log(tagListModel.get(0)) //console.log(tagListModel.get(0))
text = "" text = ""
} }
Keys.onPressed: { Keys.onPressed: {
if (event.key === Qt.Key_Backspace) { if (event.key === Qt.Key_Backspace) {
if (text.length === 0 && tagListModel.count) { if (text.length === 0 && tagListModel.count) {
@ -86,7 +108,6 @@ Rectangle {
} }
} }
} }
} }
} }