Compare commits

..

No commits in common. "5534104e870d3d5dc58d6e8f08728d08fb7d2fae" and "9ec13b35b8b6d1bd1b68d55cffe2089c65a70b1b" have entirely different histories.

5 changed files with 4 additions and 253 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -7,60 +7,11 @@
<template> <template>
<div class="assets-upload"> <div class="assets-upload">
<section class="operations"> asset upload
<el-button type="text" class="expand-btn" @click="expand = !expand">
<i class="el-icon-folder-opened" v-if="expand"></i>
<i class="el-icon-folder" v-else></i>
展开
</el-button>
<div class="preview-btn">
<i class="el-icon-view"></i>
预览
</div>
</section>
<section class="file-area">
<el-upload class="equipment-upload" drag action="uploadUrl" multiple>
<i class="el-icon-upload"></i>
<div class="el-upload__text">
<span>将文件拖到此处或</span>
<em>点击上传</em>
</div>
<div class="el-upload__tip" slot="tip">
<!-- 只能上传jpg/png文件且不超过500kb -->
some tips....
</div>
</el-upload>
<!-- <div
class="file-list__item"
v-for="n in 9"
:key="n"
:style="{
display: n > 4 && !expand ? 'none' : 'block',
}"
:data-name="n"
:class="{ 'default-icon': !isPicMode }">
<i class="el-icon-delete"></i>
</div> -->
<div
class="file-list__item"
v-for="(file, index) in files"
:key="file.fileName"
:style="{
display: index > 3 && !expand ? 'none' : 'block',
background: isPicMode ? `url(${file.fileUrl}) no-repeat` : `url(${defaultBg}) no-repeat`,
backgroundSize: isPicMode ? '100% 100%' : '64px',
backgroundPosition: isPicMode ? '0% 0%' : 'center',
}"
:data-name="file.fileName">
<i class="el-icon-delete"></i>
</div>
</section>
</div> </div>
</template> </template>
<script> <script>
import defaultBg from '../../../../../assets/images/default-file-icon.png';
export default { export default {
name: 'AssetsUpload', name: 'AssetsUpload',
components: {}, components: {},
@ -77,73 +28,14 @@ export default {
type: String, type: String,
default: '', default: '',
}, },
isPicMode: {
type: Boolean,
default: false,
},
}, },
emits: ['update-filelist'], emits: ['update-filelist'],
data() { data() {
return { return {
defaultBg,
expand: false,
fileList: [], fileList: [],
files: [
//
{
fileName: 'sf.docs',
fileType: 'asset',
fileUrl:
'https://hbimg.b0.upaiyun.com/cc7475787bd08ed926b68eaf53fa1f2c5473259115e3c-gJdObd_fw658',
},
{
fileName: 'sddf.docs',
fileType: 'asset',
fileUrl: 'https://img0.sc115.com/wm/xqx/pic1/1501xofo4ssolji.jpg',
},
{
fileName: 'jjj.docs',
fileType: 'asset',
fileUrl:
'https://www.mms591.com/www.mms591.com-photo/2013081823/1-130QR34544.jpg',
},
{
fileName: 'asdfasdf.docs',
fileType: 'asset',
fileUrl:
'https://hbimg.b0.upaiyun.com/8f6bced5f2e38d3a021b2c48d5a98dfb6317e3e12c6a0-QmhJ5v_fw658',
},
{
fileName: 'asdkj.docs',
fileType: 'asset',
fileUrl:
'https://www.mms591.com/www.mms591.com-photo/2013013021/1-130130212034.jpg',
},
{
fileName: 'lkasjdf.docs',
fileType: 'asset',
fileUrl:
'https://www.mms591.com/www.mms591.com-photo/2013072122/1-130H1223057.jpg',
},
{
fileName: 'asdf.docs',
fileType: 'asset',
fileUrl:
'https://img.1ppt.com/uploads/allimg/1212/1-1212101ZH5A2.jpg',
},
{
fileName: 'afdffff.docs',
fileType: 'asset',
fileUrl:
'https://www.mms591.com/www.mms591.com-photo/2013051721/1-13051H11945.jpg',
},
],
}; };
}, },
computed: {}, computed: {},
mounted() {
console.log('this.ispicmocde', this.isPicMode);
},
methods: { methods: {
handleUpload() { handleUpload() {
switch (this.type) { switch (this.type) {
@ -153,142 +45,11 @@ export default {
break; break;
} }
}, },
updateFileList(appendFilelist) { updateFileList(appendFilelist) { // Array
// Array
this.$emit('update-filelist', this.appendFilelist); this.$emit('update-filelist', this.appendFilelist);
}, },
}, },
}; };
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss"></style>
.assets-upload {
position: relative;
}
.operations {
position: absolute;
top: -36px;
right: 0;
display: flex;
align-items: center;
}
.expand-btn,
.preview-btn {
font-size: 14px;
line-height: 1.2;
display: inline-block;
padding-left: 20px;
cursor: pointer;
z-index: 1000;
}
.expand-btn {
margin-right: 12px;
}
.preview-btn {
color: #ccc;
}
.expand-btn,
.preview-btn:hover,
.preview-btn.active {
// color: #0042d0;
color: #0b58ff;
}
:deep(.equipment-upload) {
background: #ccc4;
.el-upload-dragger {
width: 188px;
height: 128px;
}
.el-icon-upload {
margin: 12px 0;
font-size: 48px;
}
.el-upload__text {
font-size: 12px;
line-height: 2px;
display: flex;
flex-direction: column;
em {
margin-top: 12px;
}
}
.el-upload__tip {
margin: 0 0 12px;
transform: translateY(-12px);
user-select: none;
}
}
.file-list {
padding: 12px;
border: 1px solid #ccc;
}
// custom
.file-area {
display: grid;
grid-template-columns: repeat(5, 188px);
grid-auto-rows: 128px;
gap: 24px 18px;
place-content: center;
}
.file-list__item {
background-color: #fff;
border: 1px dashed #d9d9d9;
border-radius: 6px;
-webkit-box-sizing: border-box;
box-sizing: border-box;
text-align: center;
cursor: pointer;
position: relative;
// overflow: hidden;
&:hover {
.el-icon-delete {
display: block;
}
}
.el-icon-delete {
color: #ccc;
position: absolute;
top: 8px;
right: 8px;
display: none;
&:hover {
color: rgb(210, 41, 41);
}
}
}
.file-list__item:hover {
border-color: #0b58ff;
}
.file-list__item::after {
content: attr(data-name);
position: absolute;
left: 0;
bottom: -16px;
font-size: 14px;
line-height: 1;
}
.default-icon {
background: url(../../../../../assets/images/default-file-icon.png) no-repeat;
background-position: center;
background-size: 64px;
}
</style>

View File

@ -75,7 +75,6 @@
v-if="col.subcomponent" v-if="col.subcomponent"
:key="col.key" :key="col.key"
:is="col.subcomponent" :is="col.subcomponent"
v-bind="col.bind"
:inlineStyle="col.style"></component> :inlineStyle="col.style"></component>
</el-form-item> </el-form-item>
</el-col> </el-col>

View File

@ -187,9 +187,6 @@ export default {
// //
return { return {
...col, ...col,
bind: {
...col.bind
},
style: { style: {
left: 0, left: 0,
right: 'unset', right: 'unset',

View File

@ -462,9 +462,6 @@ export default {
label: '上传资料', label: '上传资料',
fieldName: 'assets', fieldName: 'assets',
subcomponent: AssetsUpload, subcomponent: AssetsUpload,
bind: {
'is-pic-mode': false,
},
}, },
], ],
[ [
@ -474,9 +471,6 @@ export default {
label: '上传图片', label: '上传图片',
fieldName: 'images', fieldName: 'images',
subcomponent: AssetsUpload, subcomponent: AssetsUpload,
bind: {
'is-pic-mode': true,
},
}, },
], ],
] ]