diff --git a/src/api/file-api.js b/src/api/file-api.js index bf40969..f4742ae 100644 --- a/src/api/file-api.js +++ b/src/api/file-api.js @@ -237,6 +237,17 @@ export default { params }) }, + // 检测是否含有子分享 + hasSubShare: function(params) { + return request({ + url: '/share/has-sub-share', + method: 'get', + params, + paramsSerializer: function(params) { + return qs.stringify(params, { arrayFormat: 'repeat' }) + } + }) + }, // 取消分享 cancelShareLink: function(params) { return request({ diff --git a/src/components/ShareDialog/index.vue b/src/components/ShareDialog/index.vue index 3f42ad1..ca6f787 100644 --- a/src/components/ShareDialog/index.vue +++ b/src/components/ShareDialog/index.vue @@ -340,22 +340,42 @@ export default { // 取消分享 cancelShare() { this.cancelSharing = true - let title = '确定要取消分享 "' + this.file.name + '" 吗?' - this.$confirm(title, '提示', { - confirmButtonText: '确定', - cancelButtonText: '取消', - type: 'warning' + + api.hasSubShare({shareIds: [this.shareId]}).then(res => { + if (res.data) { + this.$confirm('选择的文件夹下存其他分享,取消分享后其下的所有分享链接都将被删除,是否继续?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + this.doCancelShareLink() + }).catch(() => { + this.cancelSharing = false + }) + } else { + let title = '确定要取消分享 "' + this.file.name + '" 吗?' + this.$confirm(title, '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + this.doCancelShareLink() + }).catch(() => { + this.cancelSharing = false + }) + } + }).catch(() => { + this.cancelSharing = false + }) + }, + doCancelShareLink() { + api.cancelShareLink({ + userId: this.$store.state.user.userId, + shareId: [this.shareId] }).then(() => { - api.cancelShareLink({ - userId: this.$store.state.user.userId, - shareId: [this.shareId] - }).then(() => { - this.$emit('onCancelShare') - this.shareDialogVisible = false - this.shareDialogClose() - }).catch(() => { - this.cancelSharing = false - }) + this.$emit('onCancelShare') + this.shareDialogVisible = false + this.shareDialogClose() }).catch(() => { this.cancelSharing = false }) diff --git a/src/views/share/index.vue b/src/views/share/index.vue index 2b4fb8b..16add54 100644 --- a/src/views/share/index.vue +++ b/src/views/share/index.vue @@ -448,30 +448,47 @@ }, // 取消分享 cancelShare(row) { - let title = row === false ? '确定要取消选中的' + this.selectRowData.length + '项分享吗?' : '确定要取消分享 "' + row.fileName + '" 吗?' - this.$confirm(title, '提示', { - confirmButtonText: '确定', - cancelButtonText: '取消', - type: 'warning' - }).then(() => { - let shareIds = [] - if(row){ + + let shareIds = [] + if(row){ + shareIds.push(row.id) + } else { + this.selectRowData.forEach(row => { shareIds.push(row.id) + }) + } + + api.hasSubShare({shareIds: shareIds}).then(res => { + if (res.data) { + this.$confirm('选择的文件夹下存其他分享,取消分享后其下的所有分享链接都将被删除,是否继续?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + this.doCancelShare(shareIds) + }) } else { - this.selectRowData.forEach(row => { - shareIds.push(row.id) + let title = row === false ? '确定要取消选中的' + this.selectRowData.length + '项分享吗?' : '确定要取消分享 "' + row.fileName + '" 吗?' + this.$confirm(title, '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + this.doCancelShare(shareIds) }) } - api.cancelShareLink({ - userId: this.$store.state.user.userId, - shareId: shareIds - }).then(() => { - if(shareIds.length === 1){ - this.fileList.splice(row.index,1) - }else{ - this.getFileList() - } - }) + }) + }, + doCancelShare(shareIds) { + api.cancelShareLink({ + userId: this.$store.state.user.userId, + shareId: shareIds + }).then(() => { + if(shareIds.length === 1){ + this.fileList.splice(row.index,1) + }else{ + this.getFileList() + } }) }, onCancelShare() {