<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>
|