|
@@ -103,13 +103,13 @@
|
|
|
</span>
|
|
|
<template #dropdown>
|
|
|
<el-dropdown-menu>
|
|
|
- <el-dropdown-item @click="fileUpload">
|
|
|
- <img src="../../assets/images/file.png" alt="">
|
|
|
+ <!-- <el-dropdown-item @click="fileUpload">
|
|
|
+ <img src="../../assets/images/file.png" alt="">
|
|
|
<span id="uploadButton">上传</span>
|
|
|
<input id="fileInput" type="file" style="display: none;">
|
|
|
- </el-dropdown-item>
|
|
|
+ </el-dropdown-item> -->
|
|
|
<template v-for="(item, index) in arrorMenu">
|
|
|
- <el-dropdown-item>
|
|
|
+ <el-dropdown-item @click="arrowClick(item, index)">
|
|
|
<img :src="item.img" alt="">
|
|
|
<span>{{ item.name }}</span>
|
|
|
</el-dropdown-item>
|
|
@@ -334,6 +334,30 @@
|
|
|
</template>
|
|
|
</el-dialog>
|
|
|
</div>
|
|
|
+ <!-- 文件上传 -->
|
|
|
+ <div>
|
|
|
+ <el-dialog v-model="uploadModal" title="文件上传" width="30%">
|
|
|
+ <el-upload class="upload-demo" drag :http-request="onSuccess" multiple>
|
|
|
+ <el-icon class="el-icon--upload"><upload-filled /></el-icon>
|
|
|
+ <div class="el-upload__text">
|
|
|
+ 拖入或<em>点击上传</em>
|
|
|
+ </div>
|
|
|
+ <template #tip>
|
|
|
+ <div class="el-upload__tip">
|
|
|
+ 请选择或拖入文件
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-upload>
|
|
|
+ <template #footer>
|
|
|
+ <span class="dialog-footer">
|
|
|
+ <el-button @click="uploadModal = false">取消</el-button>
|
|
|
+ <el-button type="primary" @click="sureUpload">
|
|
|
+ 确认
|
|
|
+ </el-button>
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -389,6 +413,7 @@ export default {
|
|
|
let addBoser = ref(false)
|
|
|
let addFile = ref(false)
|
|
|
let anyP = ref(false)
|
|
|
+ let uploadModal = ref(false)
|
|
|
let selectedBox = ref(-1)
|
|
|
let newName = ref('')
|
|
|
let clickRowId = ref("")
|
|
@@ -398,6 +423,7 @@ export default {
|
|
|
let tranvalue = ref([])
|
|
|
let useSpace = ref(0)
|
|
|
let allSpace = ref(0)
|
|
|
+ let fileArr = ref([])
|
|
|
let boserForm = ref({
|
|
|
spaceId: "",//空间id
|
|
|
dirName: "",
|
|
@@ -457,10 +483,10 @@ export default {
|
|
|
},
|
|
|
])
|
|
|
let arrorMenu = ref([
|
|
|
- // {
|
|
|
- // img: file,
|
|
|
- // name: "文件"
|
|
|
- // },
|
|
|
+ {
|
|
|
+ img: file,
|
|
|
+ name: "文件"
|
|
|
+ },
|
|
|
{
|
|
|
img: folder,
|
|
|
name: '文件夹'
|
|
@@ -698,32 +724,60 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
- function fileUpload() {
|
|
|
- const fileInput = document.getElementById('fileInput');
|
|
|
- const uploadButton = document.getElementById('uploadButton');
|
|
|
- // 监听按钮点击事件
|
|
|
- uploadButton.addEventListener('click', function () {
|
|
|
- // 模拟点击文件上传输入框
|
|
|
- fileInput.click();
|
|
|
- });
|
|
|
- // 监听文件选择事件
|
|
|
- fileInput.addEventListener('change', function () {
|
|
|
- const files = fileInput.files[0]; // 获取选择的文件
|
|
|
- myfile.uploadFile({
|
|
|
- spaceId: 1,
|
|
|
- dirId: 1,
|
|
|
- file: files
|
|
|
- }).then(res => {
|
|
|
- console.log(res, '222');
|
|
|
- if (res.code === 200) {
|
|
|
- ElMessage({
|
|
|
- message: "上传文件成功",
|
|
|
- type: "success"
|
|
|
- })
|
|
|
- getAll()
|
|
|
- }
|
|
|
- })
|
|
|
- });
|
|
|
+ // function fileUpload() {
|
|
|
+ // const fileInput = document.getElementById('fileInput');
|
|
|
+ // const uploadButton = document.getElementById('uploadButton');
|
|
|
+ // // 监听按钮点击事件
|
|
|
+ // uploadButton.addEventListener('click', function () {
|
|
|
+ // // 模拟点击文件上传输入框
|
|
|
+ // fileInput.click();
|
|
|
+ // });
|
|
|
+ // // 监听文件选择事件
|
|
|
+ // fileInput.addEventListener('change', function () {
|
|
|
+ // const files = fileInput.files[0]; // 获取选择的文件
|
|
|
+ // console.log(files, 'file');
|
|
|
+ // myfile.uploadFile({
|
|
|
+ // spaceId: 1,
|
|
|
+ // dirId: 1,
|
|
|
+ // file: files
|
|
|
+ // }).then(res => {
|
|
|
+ // console.log(res, '222');
|
|
|
+ // if (res.code === 200) {
|
|
|
+ // ElMessage({
|
|
|
+ // message: "上传文件成功",
|
|
|
+ // type: "success"
|
|
|
+ // })
|
|
|
+ // getAll()
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ function arrowClick(row, num) {
|
|
|
+ if (row.name === '文件') {
|
|
|
+ uploadModal.value = true
|
|
|
+ } else {
|
|
|
+ uploadModal.value = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 确认上传
|
|
|
+ function sureUpload() {
|
|
|
+ myfile.uploadFile({
|
|
|
+ spaceId: 1,
|
|
|
+ dirId: 1,
|
|
|
+ file: fileArr.value
|
|
|
+ }).then(res => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ ElMessage({
|
|
|
+ message: "上传文件成功",
|
|
|
+ type: "success"
|
|
|
+ })
|
|
|
+ getAll()
|
|
|
+ uploadModal.value = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ function onSuccess(file, val) {
|
|
|
+ fileArr.value = file.file
|
|
|
}
|
|
|
// 筛选后缀图片
|
|
|
function getImage(file) {
|
|
@@ -879,7 +933,7 @@ export default {
|
|
|
createNewFile,
|
|
|
fileForm,
|
|
|
sureAddFile,
|
|
|
- fileUpload,
|
|
|
+ // fileUpload,
|
|
|
txt,
|
|
|
pptx,
|
|
|
xlxs,
|
|
@@ -900,6 +954,11 @@ export default {
|
|
|
useSpace,//使用空间
|
|
|
allSpace,//总空间
|
|
|
percent,
|
|
|
+ arrowClick,
|
|
|
+ uploadModal,
|
|
|
+ sureUpload,
|
|
|
+ onSuccess,
|
|
|
+ fileArr,
|
|
|
}
|
|
|
},
|
|
|
created() {
|