修改:收藏/取消收藏多个文件
This commit is contained in:
parent
d11650d343
commit
f2ee0f415c
@ -48,13 +48,19 @@ export default {
|
|||||||
return request({
|
return request({
|
||||||
url: 'favorite',
|
url: 'favorite',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
params
|
params,
|
||||||
|
paramsSerializer: function(params) {
|
||||||
|
return qs.stringify(params, { arrayFormat: 'repeat' })
|
||||||
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
return request({
|
return request({
|
||||||
url: 'unFavorite',
|
url: 'unFavorite',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
params
|
params,
|
||||||
|
paramsSerializer: function(params) {
|
||||||
|
return qs.stringify(params, { arrayFormat: 'repeat' })
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -418,6 +418,10 @@
|
|||||||
ButtonUpload
|
ButtonUpload
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
|
isCollectView: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
emptyStatus: {
|
emptyStatus: {
|
||||||
'type': String,
|
'type': String,
|
||||||
'default': '空空如也~',
|
'default': '空空如也~',
|
||||||
@ -1690,7 +1694,7 @@
|
|||||||
this.rowContextData = row
|
this.rowContextData = row
|
||||||
}
|
}
|
||||||
const isFavorite = this.rowContextData.isFavorite
|
const isFavorite = this.rowContextData.isFavorite
|
||||||
this.highlightFavorite(isFavorite, false)
|
this.highlightFavorite(this.isCollectView ? true : isFavorite, false)
|
||||||
},
|
},
|
||||||
// 单元格hover进入时事件
|
// 单元格hover进入时事件
|
||||||
cellMouseEnter(row) {
|
cellMouseEnter(row) {
|
||||||
@ -1827,6 +1831,7 @@
|
|||||||
if (this.$refs.fileListTable.tableSelectData.length > 1 && this.$refs.fileListTable.tableSelectData.findIndex(item => item.index === row.index) > -1) {
|
if (this.$refs.fileListTable.tableSelectData.length > 1 && this.$refs.fileListTable.tableSelectData.findIndex(item => item.index === row.index) > -1) {
|
||||||
this.menusIsMultiple = true
|
this.menusIsMultiple = true
|
||||||
this.menus = this.multipleRightMenus
|
this.menus = this.multipleRightMenus
|
||||||
|
this.highlightFavorite(this.isCollectView, false)
|
||||||
} else {
|
} else {
|
||||||
this.$refs.fileListTable.clearSelection()
|
this.$refs.fileListTable.clearSelection()
|
||||||
this.$refs.fileListTable.toggleRowSelection([{row:row}])
|
this.$refs.fileListTable.toggleRowSelection([{row:row}])
|
||||||
@ -1869,10 +1874,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
menuFavoriteOver(index, isFavorite) {
|
menuFavoriteOver(index, isFavorite) {
|
||||||
this.highlightFavorite(isFavorite, true)
|
this.highlightFavorite(this.isCollectView ? true: isFavorite, false)
|
||||||
},
|
},
|
||||||
menuFavoriteLeave(index, isFavorite) {
|
menuFavoriteLeave(index, isFavorite) {
|
||||||
this.highlightFavorite(isFavorite, false)
|
this.highlightFavorite(this.isCollectView ? true : isFavorite, false)
|
||||||
},
|
},
|
||||||
// 是否高亮收图标
|
// 是否高亮收图标
|
||||||
highlightFavorite(isFavorite, isHover) {
|
highlightFavorite(isFavorite, isHover) {
|
||||||
@ -2263,13 +2268,18 @@
|
|||||||
},
|
},
|
||||||
// 收藏/取消收藏
|
// 收藏/取消收藏
|
||||||
favoriteOperating(isFavorite) {
|
favoriteOperating(isFavorite) {
|
||||||
|
const fileIds = this.getSelectIdList()
|
||||||
this.rowContextData.isFavorite = isFavorite
|
this.rowContextData.isFavorite = isFavorite
|
||||||
this.highlightFavorite(isFavorite, true)
|
this.highlightFavorite(isFavorite, true)
|
||||||
api.favoriteUrl({
|
api.favoriteUrl({
|
||||||
token: this.$store.state.user.token,
|
fileIds: fileIds,
|
||||||
id: this.rowContextData.id,
|
|
||||||
isFavorite: isFavorite
|
isFavorite: isFavorite
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
|
// 收藏页面
|
||||||
|
if(!isFavorite && this.isCollectView){
|
||||||
|
// 移除列表
|
||||||
|
this.removeSelectItme()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
// 删除
|
// 删除
|
||||||
@ -2295,27 +2305,7 @@
|
|||||||
fileIds: fileIds
|
fileIds: fileIds
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
// 移除列表
|
// 移除列表
|
||||||
let removeFileIndexList = []
|
this.removeSelectItme()
|
||||||
if(this.$refs.fileListTable.tableSelectData.length > 0){
|
|
||||||
this.$refs.fileListTable.tableSelectData.forEach(item => {
|
|
||||||
let fileIndex = this.fileList.findIndex(file => file.id === item.id)
|
|
||||||
if(fileIndex > -1){
|
|
||||||
removeFileIndexList.push(fileIndex)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
// 先清空之前选择的数据
|
|
||||||
this.$refs.fileListTable.doLayout()
|
|
||||||
this.$refs.fileListTable.clearSelection()
|
|
||||||
this.$refs.fileListTable.tableSelectData = []
|
|
||||||
const that = this
|
|
||||||
setTimeout(function () {
|
|
||||||
// 再执行移除
|
|
||||||
removeFileIndexList.forEach(fileIndex => {
|
|
||||||
that.fileList.splice(fileIndex,1)
|
|
||||||
})
|
|
||||||
},300)
|
|
||||||
|
|
||||||
}).then(()=>{
|
}).then(()=>{
|
||||||
this.$notify({
|
this.$notify({
|
||||||
title: '删除成功',
|
title: '删除成功',
|
||||||
@ -2325,6 +2315,43 @@
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
// 获取选中项id列表
|
||||||
|
getSelectIdList(){
|
||||||
|
const fileIds = []
|
||||||
|
if (this.selectRowData.length > 1 || this.menusIsMultiple) {
|
||||||
|
this.$refs.fileListTable.tableSelectData.forEach(value => {
|
||||||
|
fileIds.push(value.id)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
fileIds.push(this.rowContextData.id)
|
||||||
|
}
|
||||||
|
return fileIds
|
||||||
|
},
|
||||||
|
// 移除选中项
|
||||||
|
removeSelectItme(){
|
||||||
|
let removeFileIndexList = []
|
||||||
|
if(this.$refs.fileListTable.tableSelectData.length > 0){
|
||||||
|
this.$refs.fileListTable.tableSelectData.forEach(item => {
|
||||||
|
let fileIndex = this.fileList.findIndex(file => file.id === item.id)
|
||||||
|
if(fileIndex > -1){
|
||||||
|
removeFileIndexList.push(fileIndex)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 先清空之前选择的数据
|
||||||
|
this.$refs.fileListTable.doLayout()
|
||||||
|
this.$refs.fileListTable.clearSelection()
|
||||||
|
this.$refs.fileListTable.tableSelectData = []
|
||||||
|
// 反序
|
||||||
|
removeFileIndexList = removeFileIndexList.reverse()
|
||||||
|
const that = this
|
||||||
|
setTimeout(function () {
|
||||||
|
// 再执行移除
|
||||||
|
for (let i = 0; i < removeFileIndexList.length; i++) {
|
||||||
|
that.fileList.splice(removeFileIndexList[i],1)
|
||||||
|
}
|
||||||
|
},300)
|
||||||
|
},
|
||||||
// 点击文件或文件夹
|
// 点击文件或文件夹
|
||||||
fileClick(row) {
|
fileClick(row) {
|
||||||
if (row.isFolder) {
|
if (row.isFolder) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user