Finish the renaming things.

This commit is contained in:
Zic
2017-12-25 23:38:14 +08:00
parent a662c8dbc7
commit 724f605ec5
3 changed files with 59 additions and 19 deletions
+26 -7
View File
@@ -6,12 +6,21 @@
<div>
<NbFilter :pager="pager" :callback="search">
<button class="btn btn-sm btn-primary" @click.stop.prevent="upload">
<i class="fa fa-plus"></i>
上传文件
</button>
<button class="btn btn-sm btn-primary" @click.stop.prevent="createDirectory">
<i class="fa fa-plus"></i>
创建文件夹
</button>
</NbFilter>
</div>
<div v-if="director.createMode">
<MatterPanel ref="newMatterPanel" @createDirectorySuccess="refresh()" :matter="newMatter"
:director="director"/>
</div>
<div v-for="matter in pager.data">
<MatterPanel @goToDirectory="goToDirectory" @deleteSuccess="refresh()" :matter="matter" :director="director"/>
</div>
@@ -52,6 +61,8 @@
return {
//当前文件夹信息。
matter: new Matter(),
//准备新建的文件。
newMatter: new Matter(),
pager: new Pager(Matter, 50),
user: this.$store.state.user,
breadcrumbs: this.$store.state.breadcrumbs,
@@ -137,7 +148,6 @@
query: query
})
}
//第一个文件
that.breadcrumbs.push({
title: that.matter.name
@@ -146,14 +156,23 @@
}
},
createDirectory() {
let newMatter = new Matter()
newMatter.name = '新建文件夹'
newMatter.dir = true
newMatter.editMode = true
this.pager.data.unshift(newMatter)
setTimeout(function () {
let that = this
that.newMatter.name = '新建文件夹'
that.newMatter.dir = true
that.newMatter.editMode = true
that.newMatter.puuid = that.matter.uuid
if (!that.newMatter.puuid) {
that.newMatter.puuid = "root"
}
that.newMatter.userUuid = that.user.uuid
that.director.createMode = true
setTimeout(function () {
that.$refs.newMatterPanel.highLight()
}, 100)
},
upload() {
}
},
watch: {
+30 -4
View File
@@ -13,9 +13,8 @@
:class="matter.uuid"
v-model="matter.name"
placeholder="请输入名称"
@blur="finishRename()"
v-on:keyup.13="enterFinishRename()"/>
@blur="blurTrigger()"
v-on:keyup.13="enterTrigger()"/>
</span>
<span class="matter-name" v-else>
{{matter.name}}
@@ -166,8 +165,35 @@
})
},
enterFinishRename() {
finishCreateDirectory() {
let that = this
that.matter.httpCreateDirectory(function () {
that.director.createMode = false
that.editMode = false
that.$emit("createDirectorySuccess", that.matter)
}, function (response) {
that.director.createMode = false
that.editMode = false
Message.error(response.data.msg)
})
},
blurTrigger() {
let that = this
if (that.matter.editMode) {
if (that.director.createMode) {
that.finishCreateDirectory()
} else if (that.director.renameMode) {
that.finishRename()
}
}
},
enterTrigger() {
$(this.$refs.editInput).blur();
},
highLight() {
$(this.$refs.editInput).select();
}
},
created() {
+3 -8
View File
@@ -78,15 +78,10 @@ export default class Matter extends BaseEntity {
}
httpCreateDirectory(userUuid, puuid, successCallback, errorCallback) {
httpCreateDirectory(successCallback, errorCallback) {
let that = this
let form = {'userUuid': userUuid, 'name': this.name}
if (puuid) {
form.puuid = puuid
} else {
form.puuid = 'root'
}
let form = {'userUuid': that.userUuid, 'name': that.name, 'puuid': that.puuid}
this.httpPost(Matter.URL_MATTER_CREATE_DIRECTORY, form, function (response) {
that.render(response.data.data)
typeof successCallback === 'function' && successCallback(response)