mirror of
https://github.com/eyebluecn/tank-front
synced 2024-04-21 12:31:55 +00:00
Try to fix the userUuid in the FolderTree things.
This commit is contained in:
@@ -7,22 +7,22 @@
|
||||
<div>
|
||||
<NbFilter :pager="pager" :callback="search">
|
||||
|
||||
<button class="btn btn-primary btn-sm" v-if="temporaryMatterUuids.length !== pager.data.length"
|
||||
<button class="btn btn-primary btn-sm" v-if="selectedMatters.length !== pager.data.length"
|
||||
@click.stop.prevent="checkAll">
|
||||
<i class="fa fa-check-square"></i>
|
||||
全选
|
||||
</button>
|
||||
<button class="btn btn-primary btn-sm"
|
||||
v-if="pager.data.length && temporaryMatterUuids.length === pager.data.length"
|
||||
v-if="pager.data.length && selectedMatters.length === pager.data.length"
|
||||
@click.stop.prevent="checkNone">
|
||||
<i class="fa fa-square-o"></i>
|
||||
取消全选
|
||||
</button>
|
||||
<button class="btn btn-primary btn-sm" v-if="temporaryMatterUuids.length" @click.stop.prevent="deleteBatch">
|
||||
<button class="btn btn-primary btn-sm" v-if="selectedMatters.length" @click.stop.prevent="deleteBatch">
|
||||
<i class="fa fa-trash"></i>
|
||||
删除
|
||||
</button>
|
||||
<button class="btn btn-primary btn-sm" v-if="temporaryMatterUuids.length"
|
||||
<button class="btn btn-primary btn-sm" v-if="selectedMatters.length"
|
||||
@click.stop.prevent="moveBatch($createElement)">
|
||||
<i class="fa fa-arrows"></i>
|
||||
移动
|
||||
@@ -90,10 +90,11 @@
|
||||
newMatter: new Matter(),
|
||||
//目标文件夹,用于移动操作
|
||||
targetMatter: new Matter(),
|
||||
|
||||
//准备上传的一系列文件
|
||||
uploadMatters: [],
|
||||
//临时暂存区,用于文件的相关操作
|
||||
temporaryMatterUuids: [],
|
||||
//当前选中的文件
|
||||
selectedMatters: [],
|
||||
pager: new Pager(Matter, 50),
|
||||
user: this.$store.state.user,
|
||||
breadcrumbs: this.$store.state.breadcrumbs,
|
||||
@@ -146,7 +147,7 @@
|
||||
let that = this
|
||||
|
||||
//清空暂存区
|
||||
this.temporaryMatterUuids.splice(0, this.temporaryMatterUuids.length)
|
||||
this.selectedMatters.splice(0, this.selectedMatters.length)
|
||||
|
||||
let uuid = that.pager.getFilterValue('puuid')
|
||||
|
||||
@@ -269,12 +270,12 @@
|
||||
})
|
||||
},
|
||||
//选择文件时放入暂存区等待操作
|
||||
checkMatter(val) {
|
||||
if (val.checkStatus && this.temporaryMatterUuids.indexOf(val.matterUuid) === -1) {
|
||||
this.temporaryMatterUuids.push(val.matterUuid)
|
||||
} else if (!val.checkStatus && this.temporaryMatterUuids.indexOf(val.matterUuid) !== -1) {
|
||||
let index = this.temporaryMatterUuids.indexOf(val.matterUuid)
|
||||
this.temporaryMatterUuids.splice(index, 1)
|
||||
checkMatter(matter) {
|
||||
if (matter.check && this.selectedMatters.indexOf(matter) === -1) {
|
||||
this.selectedMatters.push(matter)
|
||||
} else if (!matter.check && this.selectedMatters.indexOf(matter) !== -1) {
|
||||
let index = this.selectedMatters.indexOf(matter)
|
||||
this.selectedMatters.splice(index, 1)
|
||||
}
|
||||
return true
|
||||
},
|
||||
@@ -287,7 +288,14 @@
|
||||
type: 'warning',
|
||||
callback: function (action, instance) {
|
||||
if (action === 'confirm') {
|
||||
let uuids = that.temporaryMatterUuids.join(',')
|
||||
let uuids = ""
|
||||
that.selectedMatters.forEach(function (item, index) {
|
||||
if (index === 0) {
|
||||
uuids = item.uuid
|
||||
} else {
|
||||
uuids = uuids + "," + item.uuid
|
||||
}
|
||||
})
|
||||
that.matter.httpDeleteBatch(uuids, function (response) {
|
||||
Message.success('删除成功!')
|
||||
that.refresh()
|
||||
@@ -300,13 +308,20 @@
|
||||
//批量移动
|
||||
moveBatch(createElement) {
|
||||
let that = this
|
||||
let newMatter = new Matter()
|
||||
|
||||
let targetMatter = new Matter()
|
||||
|
||||
//限制目标文件夹的用户。
|
||||
targetMatter.userUuid = this.selectedMatters[0].userUuid
|
||||
|
||||
let dom = createElement(MoveBatchPanel, {
|
||||
props: {
|
||||
targetMatter: this.targetMatter
|
||||
targetMatter: targetMatter
|
||||
}
|
||||
})
|
||||
|
||||
console.log(dom)
|
||||
|
||||
MessageBox({
|
||||
title: '移动到',
|
||||
message: dom,
|
||||
@@ -316,10 +331,18 @@
|
||||
cancelButtonText: '关闭',
|
||||
callback: (action, instance) => {
|
||||
if (action === 'confirm') {
|
||||
let uuids = that.temporaryMatterUuids.join(',')
|
||||
that.matter.httpMove(uuids, this.targetMatter.uuid, function (response) {
|
||||
let uuids = ""
|
||||
that.selectedMatters.forEach(function (item, index) {
|
||||
if (index === 0) {
|
||||
uuids = item.uuid
|
||||
} else {
|
||||
uuids = uuids + "," + item.uuid
|
||||
}
|
||||
})
|
||||
|
||||
that.matter.httpMove(uuids, targetMatter.uuid, function (response) {
|
||||
Message.success('移动成功!')
|
||||
that.targetMatter.render(new Matter())
|
||||
targetMatter.render(new Matter())
|
||||
that.refresh()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,102 +1,120 @@
|
||||
<template>
|
||||
<div class="folder-tree">
|
||||
<div class="h50 cursor folder-block" :class="{'bg-silver-white': targetMatter.uuid === matter.uuid}" @click.stop.prevent="deepFolderToggle">
|
||||
<span class="fa fa-chevron-down mr5 w14" v-if="pager.data.length && deepFolder"></span>
|
||||
<span class="fa fa-chevron-right mr5 w14" v-if="pager.data.length && !deepFolder"></span>
|
||||
<span :class="{ 'ml23': !pager.data.length }">
|
||||
<div class="folder-tree">
|
||||
<div class="h50 cursor folder-block" :class="{'bg-silver-white': targetMatter.uuid === matter.uuid}"
|
||||
@click.stop.prevent="clickItem">
|
||||
<span class="fa fa-chevron-down mr5 w14" v-if="pager.data.length && showSubFolder"></span>
|
||||
<span class="fa fa-chevron-right mr5 w14" v-if="pager.data.length && !showSubFolder"></span>
|
||||
<span :class="{ 'ml23': !pager.data.length }">
|
||||
<span v-if="matter.uuid">
|
||||
<img :src="matter.getIcon()" class="mr5" alt="文件夹" width="22" />
|
||||
<img :src="matter.getIcon()" class="mr5" alt="文件夹" width="22"/>
|
||||
<span>{{matter.name}}</span>
|
||||
</span>
|
||||
<span v-else>
|
||||
<span>全部文件</span>
|
||||
<span>根目录</span>
|
||||
</span>
|
||||
|
||||
</span>
|
||||
|
||||
</div>
|
||||
<NbExpanding>
|
||||
<div v-if="pager.data.length && deepFolder" class="pl20">
|
||||
<div v-for="(child, index) in pager.data">
|
||||
<FolderTree :matter="child" :targetMatter="targetMatter"></FolderTree>
|
||||
</div>
|
||||
</div>
|
||||
</NbExpanding>
|
||||
</div>
|
||||
<NbExpanding>
|
||||
<div v-if="pager.data.length && showSubFolder" class="pl20">
|
||||
<div v-for="(child, index) in pager.data">
|
||||
<FolderTree :matter="child" :targetMatter="targetMatter"></FolderTree>
|
||||
</div>
|
||||
</div>
|
||||
</NbExpanding>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import NbExpanding from '../../../common/widget/NbExpanding'
|
||||
import NbExpanding from '../../../common/widget/NbExpanding'
|
||||
import Pager from '../../../common/model/base/Pager'
|
||||
import Matter from '../../../common/model/matter/Matter'
|
||||
|
||||
export default {
|
||||
name: 'FolderTree',
|
||||
|
||||
data(){
|
||||
return{
|
||||
deepFolder: false,
|
||||
data() {
|
||||
return {
|
||||
showSubFolder: false,
|
||||
pager: new Pager(Matter)
|
||||
}
|
||||
},
|
||||
props:{
|
||||
},
|
||||
props: {
|
||||
targetMatter: {
|
||||
type: Matter,
|
||||
required: true
|
||||
required: true
|
||||
},
|
||||
matter: {
|
||||
type: Matter,
|
||||
required: true
|
||||
},
|
||||
deepFolderInit:{
|
||||
showSubFolderInit: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: false
|
||||
required: false,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
methods:{
|
||||
deepFolderToggle () {
|
||||
this.deepFolder = !this.deepFolder
|
||||
if(this.targetMatter.uuid !== this.matter.uuid){
|
||||
},
|
||||
|
||||
methods: {
|
||||
clickItem() {
|
||||
this.showSubFolder = !this.showSubFolder
|
||||
if (this.targetMatter.uuid !== this.matter.uuid) {
|
||||
this.targetMatter.render(this.matter)
|
||||
}
|
||||
}
|
||||
},
|
||||
setUserUuid() {
|
||||
//限制选择的范围。文件和目标文件夹必须是同一主人
|
||||
if (this.targetMatter.userUuid) {
|
||||
this.pager.setFilterValue('userUuid', this.targetMatter.userUuid)
|
||||
} else {
|
||||
console.error("目标文件夹的userUuid必须指定!")
|
||||
}
|
||||
},
|
||||
refresh() {
|
||||
console.log("FolderTree mounted!")
|
||||
|
||||
if (!this.matter.uuid) {
|
||||
this.pager.setFilterValue('puuid', 'root')
|
||||
} else {
|
||||
this.pager.setFilterValue('puuid', this.matter.uuid)
|
||||
}
|
||||
|
||||
//限制选择的范围。文件和目标文件夹必须是同一主人
|
||||
this.setUserUuid()
|
||||
|
||||
if (this.showSubFolderInit) {
|
||||
this.showSubFolder = true
|
||||
}
|
||||
|
||||
this.pager.setFilterValue('dir', true)
|
||||
this.pager.httpFastPage()
|
||||
|
||||
}
|
||||
},
|
||||
components:{
|
||||
},
|
||||
components: {
|
||||
NbExpanding
|
||||
},
|
||||
mounted() {
|
||||
if (!this.matter.uuid) {
|
||||
this.pager.setFilterValue('puuid', 'root')
|
||||
} else {
|
||||
this.pager.setFilterValue('puuid', this.matter.uuid)
|
||||
}
|
||||
|
||||
if(this.deepFolderInit){
|
||||
this.deepFolder = true
|
||||
}
|
||||
|
||||
this.pager.setFilterValue('dir', true)
|
||||
this.pager.httpFastPage()
|
||||
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.refresh()
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" rel="stylesheet/less">
|
||||
.folder-tree{
|
||||
.folder-block {
|
||||
padding: 5px 10px;
|
||||
line-height: 40px;
|
||||
&:hover {
|
||||
background: #eee;
|
||||
}
|
||||
}
|
||||
.ml23{
|
||||
margin-left: 23px;
|
||||
}
|
||||
}
|
||||
.folder-tree {
|
||||
.folder-block {
|
||||
padding: 5px 10px;
|
||||
line-height: 40px;
|
||||
&:hover {
|
||||
background: #eee;
|
||||
}
|
||||
}
|
||||
.ml23 {
|
||||
margin-left: 23px;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
},
|
||||
watch: {
|
||||
'matter.check'(newVal, oldVal) {
|
||||
this.$emit('checkMatter', {matterUuid: this.matter.uuid, checkStatus: newVal})
|
||||
this.$emit('checkMatter', this.matter)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
@@ -1,38 +1,50 @@
|
||||
<template>
|
||||
<div class="move-batch-panel h300">
|
||||
<FolderTree :matter="matter" :targetMatter="targetMatter" :deepFolderInit="true"/>
|
||||
</div>
|
||||
<div class="move-batch-panel h300">
|
||||
<FolderTree ref="folderTree" :matter="matter" :targetMatter="targetMatter" :deepFolderInit="true"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import FolderTree from '../widget/FolderTree'
|
||||
import FolderTree from '../widget/FolderTree'
|
||||
import Matter from '../../../common/model/matter/Matter'
|
||||
|
||||
export default {
|
||||
name: 'move-batch-panel',
|
||||
data(){
|
||||
return{
|
||||
data() {
|
||||
return {
|
||||
//当前matter
|
||||
matter: new Matter()
|
||||
}
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
'targetMatter.userUuid'(newVal, oldVal) {
|
||||
|
||||
console.log("move-batch-panel 听到变化")
|
||||
console.log(oldVal + "=>" + newVal)
|
||||
|
||||
this.$refs.folderTree.refresh()
|
||||
|
||||
props:{
|
||||
targetMatter:{
|
||||
type: Matter,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
components:{
|
||||
},
|
||||
props: {
|
||||
targetMatter: {
|
||||
type: Matter,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
components: {
|
||||
FolderTree
|
||||
},
|
||||
mounted(){
|
||||
},
|
||||
mounted() {
|
||||
|
||||
}
|
||||
console.log("MoveBatchPanel mounted.")
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" rel="stylesheet/less">
|
||||
.move-batch-panel{
|
||||
overflow-y: scroll;
|
||||
}
|
||||
</style>
|
||||
.move-batch-panel {
|
||||
overflow-y: scroll;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user