Compare commits

..

No commits in common. "b67075a3ba4d373403037ba9ac53945a20046d79" and "b6627ccd2cb6894eb07370a542f11cafcf813cb3" have entirely different histories.

5 changed files with 158 additions and 152 deletions

View File

@ -164,8 +164,47 @@ Item {
} }
} }
} }
UploadButton { FluButton {
id: uploadIcon
Layout.alignment: Qt.AlignRight 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 { RowLayout {

View File

@ -84,8 +84,17 @@ FluArea {
} }
} }
ColumnLayout {
id: row
anchors.fill: parent
anchors.margins: 10
spacing: 10
ColumnLayout {
id: clickable
anchors.fill: parent
MouseArea { MouseArea {
anchors.fill: row anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton acceptedButtons: Qt.LeftButton | Qt.RightButton
onDoubleClicked: { onDoubleClicked: {
fileItem.parent.doubleClicked() fileItem.parent.doubleClicked()
@ -96,11 +105,6 @@ FluArea {
} }
} }
} }
ColumnLayout {
id: clickable
anchors.fill: row
RowLayout { RowLayout {
id: titleRow id: titleRow
Image { Image {
@ -157,13 +161,6 @@ FluArea {
} }
} }
} }
ColumnLayout {
id: row
anchors.fill: parent
anchors.margins: 10
spacing: 10
RowLayout { RowLayout {
visible: !fileItem.isDir visible: !fileItem.isDir
Repeater { Repeater {

View File

@ -16,29 +16,27 @@ Rectangle {
radius: 5 radius: 5
clip: true clip: true
ListModel { ListModel { id: tagListModel }
id: tagListModel
}
property ListModel tagList: tagListModel property ListModel tagList: tagListModel
property var tagMap:[] property var tagMap:[]
property var presetsTags:[] property var presetsTags:[]
property var presetsTagsItem:[] property var presetsTagsItem:[]
Component.onCompleted: { Component.onCompleted: {
Request.get("tag?name", function (result, data) { Request.get("tag?name",
function(result, data){
// console.log("success") // console.log("success")
// console.log(result) // console.log(result)
// console.log(data.length) // console.log(data.length)
for(var i =0;i<data.length;i++){ for(var i =0;i<data.length;i++){
tagMap.push(data[i]) tagMap.push([data[i].id,data[i].name])
presetsTags.push(data[i].name) presetsTags.push(data[i].name)
presetsTagsItem.push({ presetsTagsItem.push({title:data[i].name})
"title": data[i].name
})
} }
// console.log(tagMap) // console.log(tagMap)
// console.log(presetsTags) // console.log(presetsTags)
}, function (p1, p2) {// console.log("failure") },function (p1, p2) {
// console.log("failure")
// console.log(p1) // console.log(p1)
// console.log(p2) // console.log(p2)
}) })
@ -64,9 +62,7 @@ Rectangle {
tagListModel.remove(index) tagListModel.remove(index)
}) })
item.tag = Qt.binding(function () { item.tag = Qt.binding(function(){return tag})
return tag
})
} }
} }
} }
@ -81,6 +77,7 @@ Rectangle {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
width: parent.width width: parent.width
placeholderText: "按回车键Enter创建标签" placeholderText: "按回车键Enter创建标签"
Layout.preferredWidth: 300 Layout.preferredWidth: 300
//items:[{title:""},{title:""},{title:""}] //items:[{title:""},{title:""},{title:""}]
@ -95,18 +92,14 @@ Rectangle {
if (text.length === 0) if (text.length === 0)
return return
var tagId if(presetsTags.indexOf(text) === -1){
for (var i = 0; i < tagMap.length; i++) { text = ""
if (tagMap[i].name === text) { return
tagListModel.append({ }
"tag": text, tagListModel.append({"tag": text})
"id": tagMap[i].id
})
//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) {
@ -118,10 +111,11 @@ Rectangle {
} }
} }
property Component tagItem: Rectangle { property Component tagItem:
Rectangle {
id: rootTagItem id: rootTagItem
property alias tag: tagText.text property alias tag: tagText.text
signal closeClicked signal closeClicked()
width: content.width width: content.width
height: 25 height: 25
@ -142,10 +136,7 @@ Rectangle {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
height: rootTagItem.height height: rootTagItem.height
Item { Item { width: 5; height: 1 }
width: 5
height: 1
}
Text { Text {
id: tagText id: tagText
@ -155,11 +146,7 @@ Rectangle {
color: "white" color: "white"
} }
Item { Item { visible: mouseArea.hovered; width: 5; height: 1 }
visible: mouseArea.hovered
width: 5
height: 1
}
Item { Item {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
@ -167,15 +154,11 @@ Rectangle {
height: rootTagItem.height height: rootTagItem.height
visible: mouseArea.hovered visible: mouseArea.hovered
Behavior on width { Behavior on width {
NumberAnimation { NumberAnimation {duration: 100}
duration: 100
}
} }
Behavior on visible { Behavior on visible {
NumberAnimation { NumberAnimation {duration: 100}
duration: 100
}
} }
Rectangle { Rectangle {
@ -206,11 +189,9 @@ Rectangle {
} }
} }
Item { Item { width: 5; height: 1 }
width: 5
height: 1
}
} }
} }
} }
} }

View File

@ -14,8 +14,7 @@ FluButton {
text: "上传" text: "上传"
onClicked: function () { onClicked: function () {
console.log("click") console.log("click")
//fileDialog.open() fileDialog.open()
popup.open()
} }
FileDialog { FileDialog {
id: fileDialog id: fileDialog
@ -53,7 +52,7 @@ FluButton {
} }
} }
Column { Row {
id: content id: content
topPadding: 14 topPadding: 14
leftPadding: 20 leftPadding: 20
@ -69,9 +68,6 @@ FluButton {
width: parent.width - parent.leftPadding - parent.rightPadding width: parent.width - parent.leftPadding - parent.rightPadding
placeholderText: "请输入简介" placeholderText: "请输入简介"
} }
Tag {
id: tags
}
} }
Rectangle { Rectangle {
@ -110,13 +106,6 @@ FluButton {
Layout.fillHeight: true Layout.fillHeight: true
text: "上传" text: "上传"
onClicked: { onClicked: {
for (var i = 0; i < tags.tagList.count; i++) {
console.log(tags.tagList.get(i).tag)
console.log(tags.tagList.get(i).id)
}
return
popup.close() popup.close()
let name = FileTransferManager.getFileName( let name = FileTransferManager.getFileName(
currentSelectedFile) currentSelectedFile)

View File

@ -11,7 +11,7 @@ FileTransferListModel::FileTransferListModel(QObject *parent)
m_roleName.insert(kSpeedRole, "speed"); m_roleName.insert(kSpeedRole, "speed");
m_roleName.insert(kPausedRole, "paused"); m_roleName.insert(kPausedRole, "paused");
//m_data.append({true, "id", "name", 30, 100, 30}); m_data.append({true, "id", "name", 30, 100, 30});
} }