修改
This commit is contained in:
parent
c02d3afc58
commit
2c01bd70d1
@ -1,46 +1,51 @@
|
||||
<template>
|
||||
<div class="upload-box">
|
||||
<div v-for="(item, index) in fileList" class="items">
|
||||
<img v-if="item.filePath" :src="item.filePath" class="upload-image" />
|
||||
<div class="upload-handle" @click.stop>
|
||||
<div class="handle-icon" @click="handleEdit(index)" v-if="!self_disabled">
|
||||
<n-icon size="20">
|
||||
<EditOutlined />
|
||||
</n-icon>
|
||||
</div>
|
||||
<div class="handle-icon" @click="onPreview(index)">
|
||||
<n-icon size="20">
|
||||
<ZoomInOutlined />
|
||||
</n-icon>
|
||||
</div>
|
||||
<div class="handle-icon" @click="handleRemove(index)" v-if="!self_disabled">
|
||||
<n-icon size="20">
|
||||
<DeleteOutlined />
|
||||
</n-icon>
|
||||
<div class="img-box">
|
||||
<div v-for="(item, index) in fileList" class="items">
|
||||
<img v-if="item.filePath" :src="item.filePath" class="upload-image" />
|
||||
<div class="upload-handle" @click.stop>
|
||||
<div class="handle-icon" @click="handleEdit(index)" v-if="!self_disabled">
|
||||
<n-icon size="20">
|
||||
<EditOutlined />
|
||||
</n-icon>
|
||||
</div>
|
||||
<div class="handle-icon" @click="onPreview(index)">
|
||||
<n-icon size="20">
|
||||
<ZoomInOutlined />
|
||||
</n-icon>
|
||||
</div>
|
||||
<div class="handle-icon" @click="handleRemove(index)" v-if="!self_disabled">
|
||||
<n-icon size="20">
|
||||
<DeleteOutlined />
|
||||
</n-icon>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<n-upload
|
||||
action="#"
|
||||
:id="uuid"
|
||||
class="upload-demo my-upload-images"
|
||||
:multiple="multiple"
|
||||
ref="uploadRef"
|
||||
:style="{ width: width, height: height }"
|
||||
:disabled="loading ? true : self_disabled || fileList.length >= props.limit"
|
||||
@before-upload="beforeUpload"
|
||||
@change="handleUploadChange"
|
||||
:max="limit"
|
||||
v-model:file-list="fileList"
|
||||
:show-file-list="false"
|
||||
v-if="!self_disabled"
|
||||
:accept="props.fileType"
|
||||
>
|
||||
<n-icon size="40" color="#666666" v-if="!loading">
|
||||
<PlusOutlined />
|
||||
</n-icon>
|
||||
<n-progress type="circle" v-else :percentage="progress" />
|
||||
</n-upload>
|
||||
</div>
|
||||
<div class="n-upload__tip">
|
||||
<slot name="tip"></slot><span v-if="limit">,最多{{ limit }}张</span>
|
||||
</div>
|
||||
<n-upload
|
||||
action="#"
|
||||
:id="uuid"
|
||||
class="upload-demo my-upload-images"
|
||||
:multiple="multiple"
|
||||
ref="uploadRef"
|
||||
:style="{ width: width, height: height }"
|
||||
:disabled="loading ? true : self_disabled || fileList.length >= props.limit"
|
||||
@before-upload="beforeUpload"
|
||||
@change="handleUploadChange"
|
||||
:max="limit"
|
||||
v-model:file-list="fileList"
|
||||
:show-file-list="false"
|
||||
v-if="!self_disabled"
|
||||
:accept="props.fileType"
|
||||
>
|
||||
<n-icon size="40" color="#666666" v-if="!loading">
|
||||
<PlusOutlined />
|
||||
</n-icon>
|
||||
<n-progress type="circle" v-else :percentage="progress" />
|
||||
</n-upload>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -118,7 +123,6 @@
|
||||
*/
|
||||
const fileList = computed({
|
||||
get: () => {
|
||||
console.log(props.fileLists);
|
||||
return props.fileLists;
|
||||
},
|
||||
set: (val) => {
|
||||
@ -141,8 +145,6 @@
|
||||
const handleHttpUpload = async (options) => {
|
||||
loading.value = true;
|
||||
try {
|
||||
// 设置允许做大上传张数验证
|
||||
onExceed();
|
||||
// 上传文件
|
||||
const formData = new FormData();
|
||||
formData.append('file', options.file.file);
|
||||
@ -194,7 +196,6 @@
|
||||
* @param options 参数
|
||||
*/
|
||||
const handleHttpUploads = async (options: UploadRequestOptions) => {
|
||||
console.log(options);
|
||||
const configData = await getOssConfig();
|
||||
let date = new Date();
|
||||
let year = date.getFullYear();
|
||||
@ -214,8 +215,6 @@
|
||||
let filePath = props.name + '/' + year + '/' + month + '/' + day + '/' + fileName;
|
||||
loading.value = true;
|
||||
try {
|
||||
// 设置允许做大上传张数验证
|
||||
onExceed();
|
||||
// 文件请求头
|
||||
const headers = {
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
@ -379,27 +378,64 @@
|
||||
<style scoped lang="less">
|
||||
.upload-box {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
> div {
|
||||
margin-right: 10px;
|
||||
margin-bottom: 10px;
|
||||
position: relative;
|
||||
|
||||
&.items {
|
||||
width: v-bind(width);
|
||||
height: v-bind(height);
|
||||
border: 1px dashed #d9d9d9;
|
||||
border-radius: 4px;
|
||||
padding: 5px;
|
||||
.img-box {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
> div {
|
||||
margin-right: 10px;
|
||||
margin-bottom: 10px;
|
||||
position: relative;
|
||||
|
||||
&.items {
|
||||
width: v-bind(width);
|
||||
height: v-bind(height);
|
||||
border: 1px dashed #d9d9d9;
|
||||
border-radius: 4px;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
.upload-handle {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
.upload-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
.upload-handle {
|
||||
opacity: 1;
|
||||
.upload-handle {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
cursor: pointer;
|
||||
background: rgb(0 0 0 / 60%);
|
||||
opacity: 0;
|
||||
|
||||
.handle-icon {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0 6%;
|
||||
color: aliceblue;
|
||||
span {
|
||||
font-size: 85%;
|
||||
line-height: 85%;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.n-upload) {
|
||||
position: relative;
|
||||
display: flex;
|
||||
@ -419,38 +455,10 @@
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
.upload-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.upload-handle {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
cursor: pointer;
|
||||
background: rgb(0 0 0 / 60%);
|
||||
opacity: 0;
|
||||
|
||||
.handle-icon {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0 6%;
|
||||
color: aliceblue;
|
||||
span {
|
||||
font-size: 85%;
|
||||
line-height: 85%;
|
||||
}
|
||||
}
|
||||
.n-upload__tip {
|
||||
line-height: 18px;
|
||||
font-size: 12px;
|
||||
margin-top: 7px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@ -79,7 +79,9 @@
|
||||
:multiple="true"
|
||||
:fileLists="item.filePath"
|
||||
:z-index="index"
|
||||
/>
|
||||
>
|
||||
<template #tip>支持扩展名: jpg png jpeg;文件大小不超过200M</template>
|
||||
</UploadImgs>
|
||||
</template>
|
||||
<template v-else-if="item.type == 'file'">
|
||||
<UploadFile
|
||||
|
Loading…
Reference in New Issue
Block a user