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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<template>
    <!-- 查看文件详情对话框 -->
    <el-dialog class="file-compare-dialog" title="文件对比" :visible.sync="visible" :close-on-click-modal="false" width="950px"
        @close="handleDialogClose">
        <div style="height:400px">
            <div id="dropzone" ref="dropZone" style="width: 100%; height: 100%; border: 2px dashed #ccc; text-align: center;">
                <p>将文件夹拖放到此处</p>
            </div>
        </div>
 
        <div slot="footer" class="dialog-footer">
            <el-button @click="handleDialogClose">关 闭</el-button>
        </div>
    </el-dialog>
</template>
 
<script>
import router from '@/router/index'
 
export default {
    name: 'FileCompareDialog',
    data() {
        return {
            visible: false //  对话框是否可见
        }
    },
    computed: {
        // 左侧菜单选中的文件类型
        fileType() {
            return router.currentRoute.query.fileType
                ? Number(router.currentRoute.query.fileType)
                : 0
        },
        // 路由名称
        routeName() {
            return router.currentRoute.name
        }
    },
    mounted() {
        //const dropzone = document.getElementById("dropzone");
 
        document.addEventListener("dragover", function (e) {
            e.preventDefault();
            //    this.$refs.dropZone.style.borderColor = "blue";
        });
 
        document.addEventListener("dragleave", function () {
            //    this.$refs.dropZone.style.borderColor = "#ccc";
        });
 
        document.addEventListener("drop", function (e) {
            e.preventDefault();
            //    this.$refs.dropZone.style.borderColor = "#ccc";
 
            const files = e.dataTransfer.items;
 
            for (let i = 0; i < files.length; i++) {
                const item = files[i].webkitGetAsEntry();
                console.log(`output->files[i]`, files[i])
                console.log(`output->item`, item)
                if (item.isDirectory) {
                    // 提取文件夹路径
                    const folderPath = item.fullPath;
                    console.log("已选择的文件夹路径: " + folderPath);
                }
            }
        });
    },
    methods: {
        /**
         * 查看文件详情对话框 | 对话框关闭的回调
         * @description 关闭对话框
         */
        handleDialogClose() {
            this.visible = false
            this.$refs.fileInfoForm.resetFields()
            this.callback('cancel')
        },
        /**
         * 路径点击事件
         * @param {object} fileInfo 文件信息
         */
        handleClickFilePath(fileInfo) {
            router.push({
                query: { filePath: fileInfo.filePath, fileType: 0 }
            })
            this.handleDialogClose()
        }
    }
}
</script>
 
<style lang="less" scoped>
@import '~@assets/file/less/varibles.less';
 
.file-img {
    display: block;
    margin: 0 auto 8px auto;
    max-width: 120px;
    width: 40%;
    height: auto;
}
 
/deep/.el-form.file-info-form {
    .el-form-item {
        margin-bottom: 16px;
 
        .el-input__inner {
            border: none;
            font-size: 14px;
        }
 
        &.form-item-end-time {
            .el-form-item__content {
                display: flex;
                align-items: center;
 
                .el-input {
                    width: 141px;
 
                    .el-input__inner {
                        padding-right: 0;
                    }
                }
 
                .status-icon {
                    font-size: 14px;
                }
 
                .el-icon-warning {
                    color: @Warning;
                }
 
                .el-icon-time {
                    color: @Success;
                }
            }
        }
    }
}
</style>