|
@@ -3,14 +3,16 @@
|
|
<el-upload
|
|
<el-upload
|
|
:action="oss_url"
|
|
:action="oss_url"
|
|
:data="dataObj"
|
|
:data="dataObj"
|
|
- :multiple="false"
|
|
|
|
|
|
+ :multiple="multiple"
|
|
:show-file-list="isShowFileList"
|
|
:show-file-list="isShowFileList"
|
|
:file-list="fileList"
|
|
:file-list="fileList"
|
|
:before-upload="beforeUpload"
|
|
:before-upload="beforeUpload"
|
|
:on-remove="handleRemove"
|
|
:on-remove="handleRemove"
|
|
:on-success="handleUploadSuccess"
|
|
:on-success="handleUploadSuccess"
|
|
>
|
|
>
|
|
- <el-button size="small" type="primary">{{ fileList.length == 0 ? '点击上传' : '重新上传' }}</el-button>
|
|
|
|
|
|
+ <el-button size="small" type="primary">{{
|
|
|
|
+ multiple ? '点击上传' : fileList.length == 0 ? '点击上传' : '重新上传'
|
|
|
|
+ }}</el-button>
|
|
</el-upload>
|
|
</el-upload>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
@@ -21,6 +23,10 @@ export default {
|
|
name: 'fileUpload',
|
|
name: 'fileUpload',
|
|
props: {
|
|
props: {
|
|
fileList: Array,
|
|
fileList: Array,
|
|
|
|
+ multiple: {
|
|
|
|
+ type: Boolean,
|
|
|
|
+ default: false
|
|
|
|
+ },
|
|
fileType: {
|
|
fileType: {
|
|
type: Array,
|
|
type: Array,
|
|
default: () => ['image', 'video', 'word', 'excel', 'ppt', 'pdf']
|
|
default: () => ['image', 'video', 'word', 'excel', 'ppt', 'pdf']
|
|
@@ -42,10 +48,12 @@ export default {
|
|
computed: {
|
|
computed: {
|
|
isShowFileList: {
|
|
isShowFileList: {
|
|
get: function () {
|
|
get: function () {
|
|
- if (this.fileList.length > 0 && this.fileList[0].url) {
|
|
|
|
- return true
|
|
|
|
- } else {
|
|
|
|
- return false
|
|
|
|
|
|
+ if (!this.multiple) {
|
|
|
|
+ if (this.fileList.length > 0 && this.fileList[0].url) {
|
|
|
|
+ return true
|
|
|
|
+ } else {
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
}
|
|
}
|
|
},
|
|
},
|
|
set: function (newValue) {}
|
|
set: function (newValue) {}
|
|
@@ -58,6 +66,7 @@ export default {
|
|
})
|
|
})
|
|
},
|
|
},
|
|
createName(name) {
|
|
createName(name) {
|
|
|
|
+ console.log(444)
|
|
const date = Date.now()
|
|
const date = Date.now()
|
|
const uuid = this.getUUID()
|
|
const uuid = this.getUUID()
|
|
const fileSuffix = name.substring(name.lastIndexOf('.') + 1)
|
|
const fileSuffix = name.substring(name.lastIndexOf('.') + 1)
|
|
@@ -68,6 +77,7 @@ export default {
|
|
this.fileList.pop()
|
|
this.fileList.pop()
|
|
},
|
|
},
|
|
beforeUpload(file) {
|
|
beforeUpload(file) {
|
|
|
|
+ console.log(file)
|
|
const fileSuffix = file.name.substring(file.name.lastIndexOf('.') + 1)
|
|
const fileSuffix = file.name.substring(file.name.lastIndexOf('.') + 1)
|
|
const imgList = ['jpg', 'jpeg', 'png']
|
|
const imgList = ['jpg', 'jpeg', 'png']
|
|
const videoList = ['mp4']
|
|
const videoList = ['mp4']
|
|
@@ -116,11 +126,15 @@ export default {
|
|
spinner: 'el-icon-loading',
|
|
spinner: 'el-icon-loading',
|
|
background: 'rgba(0, 0, 0, 0.7)'
|
|
background: 'rgba(0, 0, 0, 0.7)'
|
|
})
|
|
})
|
|
- this.fileList.pop()
|
|
|
|
|
|
+ if (!this.multiple) {
|
|
|
|
+ this.fileList.pop()
|
|
|
|
+ }
|
|
this.fileList.push({
|
|
this.fileList.push({
|
|
name: file.name,
|
|
name: file.name,
|
|
|
|
+ status: 'success',
|
|
url: this.dataObj.key
|
|
url: this.dataObj.key
|
|
})
|
|
})
|
|
|
|
+
|
|
this.showFileList = true
|
|
this.showFileList = true
|
|
loading.close()
|
|
loading.close()
|
|
}
|
|
}
|