zhuguifei
2025-04-28 442928123f63ee497d766f9a7a14f0a6ee067e25
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<template>
    <!-- 删除文件对话框 -->
    <el-dialog
        title="删除文件"
        :visible.sync="visible"
        :close-on-click-modal="false"
        width="550px"
        @close="handleDialogClose"
    >
        <div v-if="deleteMode === 1">删除后可在回收站查看, 是否继续删除?</div>
        <div v-else-if="deleteMode === 2">此操作将永久删除该文件, 是否继续?</div>
        <div slot="footer" class="dialog-footer">
            <el-button @click="handleDialogClose">取 消</el-button>
            <el-button
                type="primary"
                :loading="sureBtnLoading"
                @click="handleDialogSure"
                >确 定</el-button
            >
        </div>
    </el-dialog>
</template>
 
<script>
// import {
//     batchDeleteFile,
//     batchDeleteRecoveryFile,
//     deleteFile,
//     deleteRecoveryFile
// } from '_r/file.js'
import {
  deleteAction,
  getAction,
  postAction,
  downFile,
  getFileAccessHttpUrl, getDeskDownloadHttpUrl
} from '@/api/manage'
export default {
    name: 'DeleteFileDialog',
    data() {
        return {
            visible: false, //  对话框是否可见
            sureBtnLoading: false
        }
    },
    methods: {
        /**
         * 删除文件对话框 | 对话框关闭的回调
         * @description 关闭对话框,重置表单
         */
        handleDialogClose() {
            this.visible = false
            this.callback('cancel')
        },
        /**
         * 删除文件对话框 | 确定按钮点击事件
         * @description 区分 删除到回收站中 | 在回收站中彻底删除,调用相应的删除文件接口
         */
        async handleDialogSure() {
            this.sureBtnLoading = true
            let res = null
            // 批量删除模式
            if (this.isBatchOperation) {
                // 区分删除类型
                switch (this.deleteMode) {
                    // 删除文件到回收站
                    case 1: {
                        res = await postAction('/document/batchdeletefile',{
                            files: JSON.stringify(this.fileInfo)
                        })
                        break
                    }
                    // 回收站中彻底删除
                    case 2: {
                        res = await postAction('/recoveryfile/batchdelete',{
                            recoveryFileIds: JSON.stringify(this.fileInfo)
                        })
                        break
                    }
                }
            } else {
                // 单文件删除模式
                // 区分删除类型
                switch (this.deleteMode) {
                    // 删除文件到回收站
                    case 1: {
                        res = await postAction('/document/deletefile',{
                            userFileId: this.fileInfo.pathId
                        })
                        break
                    }
                    // 回收站中彻底删除
                    case 2: {
                        res = await postAction('/recoveryfile/deleterecoveryfile',{
                            recoveryFileId: this.fileInfo.recoveryFileId
                        })
                        break
                    }
                }
            }
            if (res.success) {
                this.sureBtnLoading = false
                this.$message.success('删除成功')
                this.visible = false
                this.callback('confirm')
            } else {
                this.sureBtnLoading = false
                this.$message.error('删除失败,' + res.message)
            }
        }
    }
}
</script>