|
@@ -28,13 +28,20 @@
|
|
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
|
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
|
</el-upload>
|
|
</el-upload>
|
|
</div>
|
|
</div>
|
|
- <div class="line" v-if="fileList.length>0"></div>
|
|
|
|
- <div class="fileList" v-if="fileList.length>0">
|
|
|
|
|
|
+ <div class="line" v-if="fileList.length > 0"></div>
|
|
|
|
+ <div class="fileList" v-if="fileList.length > 0">
|
|
<ul>
|
|
<ul>
|
|
<li v-for="item in fileList" :key="item.guid">
|
|
<li v-for="item in fileList" :key="item.guid">
|
|
- <div><i class="el-icon-document" style="margin-right:10px"></i><span class="name" @click="checkFiles(item)">{{ item.name ?item.name:item.originalName }}</span></div>
|
|
|
|
- <div class="type">{{ item.guid?'已上传':'待上传' }}</div>
|
|
|
|
- <div class="icon" @click="onRemove(item,fileList)"><i class="el-icon-close"></i></div>
|
|
|
|
|
|
+ <div>
|
|
|
|
+ <i class="el-icon-document" style="margin-right: 10px"></i
|
|
|
|
+ ><span class="name" @click="checkFiles(item)">{{
|
|
|
|
+ item.name ? item.name : item.originalName
|
|
|
|
+ }}</span>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="type">{{ item.guid ? "已上传" : "待上传" }}</div>
|
|
|
|
+ <div class="icon" @click="onRemove(item, fileList)">
|
|
|
|
+ <i class="el-icon-close"></i>
|
|
|
|
+ </div>
|
|
</li>
|
|
</li>
|
|
</ul>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
@@ -46,55 +53,57 @@
|
|
export default {
|
|
export default {
|
|
components: {},
|
|
components: {},
|
|
props: {
|
|
props: {
|
|
- action:{
|
|
|
|
- type:String,
|
|
|
|
- default:''
|
|
|
|
|
|
+ action: {
|
|
|
|
+ type: String,
|
|
|
|
+ default: "",
|
|
},
|
|
},
|
|
- multiple:{
|
|
|
|
- type:Boolean
|
|
|
|
|
|
+ multiple: {
|
|
|
|
+ type: Boolean,
|
|
},
|
|
},
|
|
- data:{
|
|
|
|
- type:Object
|
|
|
|
|
|
+ data: {
|
|
|
|
+ type: Object,
|
|
},
|
|
},
|
|
- name:{
|
|
|
|
- type:String,
|
|
|
|
- default:''
|
|
|
|
|
|
+ name: {
|
|
|
|
+ type: String,
|
|
|
|
+ default: "",
|
|
},
|
|
},
|
|
- showFileList:{
|
|
|
|
- type:Boolean
|
|
|
|
|
|
+ showFileList: {
|
|
|
|
+ type: Boolean,
|
|
},
|
|
},
|
|
- drag:{
|
|
|
|
- type:Boolean,
|
|
|
|
- default:true
|
|
|
|
|
|
+ drag: {
|
|
|
|
+ type: Boolean,
|
|
|
|
+ default: true,
|
|
},
|
|
},
|
|
- accept:{
|
|
|
|
- type:String,
|
|
|
|
- default:''
|
|
|
|
|
|
+ accept: {
|
|
|
|
+ type: String,
|
|
|
|
+ default: "",
|
|
},
|
|
},
|
|
- listType:{
|
|
|
|
- type:String,
|
|
|
|
- default:'text'
|
|
|
|
|
|
+ listType: {
|
|
|
|
+ type: String,
|
|
|
|
+ default: "text",
|
|
},
|
|
},
|
|
- autoUpload:{
|
|
|
|
- type:Boolean,
|
|
|
|
- default:false
|
|
|
|
|
|
+ autoUpload: {
|
|
|
|
+ type: Boolean,
|
|
|
|
+ default: false,
|
|
},
|
|
},
|
|
- fileList:{
|
|
|
|
- type:Array,
|
|
|
|
- default:()=>{
|
|
|
|
- return []
|
|
|
|
- }
|
|
|
|
|
|
+ fileList: {
|
|
|
|
+ type: Array,
|
|
|
|
+ default: () => {
|
|
|
|
+ return [];
|
|
|
|
+ },
|
|
},
|
|
},
|
|
- disabled:{
|
|
|
|
- type:Boolean,
|
|
|
|
- default:false
|
|
|
|
|
|
+ disabled: {
|
|
|
|
+ type: Boolean,
|
|
|
|
+ default: false,
|
|
|
|
+ },
|
|
|
|
+ limit: {
|
|
|
|
+ type: Number,
|
|
},
|
|
},
|
|
- limit:{
|
|
|
|
- type:Number,
|
|
|
|
- }
|
|
|
|
},
|
|
},
|
|
data() {
|
|
data() {
|
|
- return {};
|
|
|
|
|
|
+ return {
|
|
|
|
+ discontent:[]
|
|
|
|
+ };
|
|
},
|
|
},
|
|
watch: {},
|
|
watch: {},
|
|
computed: {},
|
|
computed: {},
|
|
@@ -102,30 +111,68 @@ export default {
|
|
mounted() {},
|
|
mounted() {},
|
|
methods: {
|
|
methods: {
|
|
onPreview(file) {
|
|
onPreview(file) {
|
|
- this.$emit('on-preview',file)
|
|
|
|
|
|
+ this.$emit("on-preview", file);
|
|
},
|
|
},
|
|
- onRemove(file,fileList) {
|
|
|
|
- this.$emit('on-remove',file,fileList)
|
|
|
|
|
|
+ onRemove(file, fileList) {
|
|
|
|
+ this.$emit("on-remove", file, fileList);
|
|
},
|
|
},
|
|
onSuccess(response, file, fileList) {
|
|
onSuccess(response, file, fileList) {
|
|
- this.$emit('on-success',response,file,fileList)
|
|
|
|
|
|
+ this.$emit("on-success", response, file, fileList);
|
|
},
|
|
},
|
|
- onError(err,file,fileList){
|
|
|
|
- this.$emit('on-error',err,file,fileList)
|
|
|
|
|
|
+ onError(err, file, fileList) {
|
|
|
|
+ this.$emit("on-error", err, file, fileList);
|
|
},
|
|
},
|
|
- onProgress(event,file,fileList){
|
|
|
|
- this.$emit('on-progress',event,file,fileList)
|
|
|
|
|
|
+ onProgress(event, file, fileList) {
|
|
|
|
+ this.$emit("on-progress", event, file, fileList);
|
|
},
|
|
},
|
|
- onChange(file,fileList){
|
|
|
|
- this.$emit('on-change',file,fileList)
|
|
|
|
|
|
+ onChange(file, fileList) {
|
|
|
|
+ if (this.accept) {
|
|
|
|
+ var arr = this.accept.split(/,|,/g);
|
|
|
|
+ var fileType = file.name.substring(file.name.lastIndexOf("."));
|
|
|
|
+ var index = arr.findIndex(item=>{
|
|
|
|
+ return item == fileType
|
|
|
|
+ })
|
|
|
|
+ if(index == -1){
|
|
|
|
+ this.discontent.push(file)
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ this.$emit("on-change", file);
|
|
|
|
+ // this.$nextTick(()=>{
|
|
|
|
+ // if(this.discontent){
|
|
|
|
+ // this.discontent = false
|
|
|
|
+ // this.$message({
|
|
|
|
+ // message: `上传文件只支持${ this.accept.replace(/,|,/g,',') }等格式!`,
|
|
|
|
+ // type: "warning",
|
|
|
|
+ // });
|
|
|
|
+ // }
|
|
|
|
+ // })
|
|
|
|
+ this.$nextTick(()=>{
|
|
|
|
+ var b = ''
|
|
|
|
+ if(this.discontent.length>0){
|
|
|
|
+ var arr = this.discontent.map(item=>{
|
|
|
|
+ return item.name
|
|
|
|
+ })
|
|
|
|
+ // this.discontent.forEach(item=>{
|
|
|
|
+ // b = b + item.name +','
|
|
|
|
+ // })
|
|
|
|
+ this.$alert(`您上传的<span style='color:red'>${ arr.join(',') }</span>等文件格式不正确,请上传<span style='color:blue'>${ this.accept.replace(/,|,/g,',') }</span>等格式文件`, '提示', {
|
|
|
|
+ dangerouslyUseHTMLString: true,
|
|
|
|
+ confirmButtonText: '确定',
|
|
|
|
+ type:'warning',
|
|
|
|
+ callback: action => {
|
|
|
|
+ this.discontent = []
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ })
|
|
},
|
|
},
|
|
- onExceed(file,fileList){
|
|
|
|
- this.$emit('on-exceed',file,fileList)
|
|
|
|
|
|
+ onExceed(file, fileList) {
|
|
|
|
+ this.$emit("on-exceed", file, fileList);
|
|
},
|
|
},
|
|
//查看图片
|
|
//查看图片
|
|
- checkFiles(file){
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
+ checkFiles(file) {},
|
|
},
|
|
},
|
|
};
|
|
};
|
|
</script>
|
|
</script>
|
|
@@ -150,14 +197,14 @@ export default {
|
|
}
|
|
}
|
|
</style>
|
|
</style>
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|
|
-.myUpload{
|
|
|
|
- width: calc(100% - 0px);
|
|
|
|
- height:180px;
|
|
|
|
- padding: 5px;
|
|
|
|
|
|
+.myUpload {
|
|
|
|
+ width: calc(100% - 0px);
|
|
|
|
+ height: 180px;
|
|
|
|
+ padding: 5px;
|
|
}
|
|
}
|
|
.myUpload1 {
|
|
.myUpload1 {
|
|
- width: calc(100% - 20px);
|
|
|
|
- height: 100%;
|
|
|
|
|
|
+ width: calc(100% - 20px);
|
|
|
|
+ height: 100%;
|
|
padding: 5px;
|
|
padding: 5px;
|
|
display: flex;
|
|
display: flex;
|
|
align-items: center;
|
|
align-items: center;
|
|
@@ -182,32 +229,32 @@ export default {
|
|
ul {
|
|
ul {
|
|
list-style-type: none;
|
|
list-style-type: none;
|
|
padding: 0 10px;
|
|
padding: 0 10px;
|
|
- li{
|
|
|
|
|
|
+ li {
|
|
line-height: initial;
|
|
line-height: initial;
|
|
- padding:5px 10px;
|
|
|
|
|
|
+ padding: 5px 10px;
|
|
border-radius: 5px;
|
|
border-radius: 5px;
|
|
display: flex;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
justify-content: space-between;
|
|
- .type{
|
|
|
|
- display: block;
|
|
|
|
- color: #57a5f7;
|
|
|
|
|
|
+ .type {
|
|
|
|
+ display: block;
|
|
|
|
+ color: #57a5f7;
|
|
}
|
|
}
|
|
- .icon{
|
|
|
|
- display: none;
|
|
|
|
|
|
+ .icon {
|
|
|
|
+ display: none;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- li:hover{
|
|
|
|
|
|
+ li:hover {
|
|
background: #f4f4f4;
|
|
background: #f4f4f4;
|
|
- .name{
|
|
|
|
- color: #57a5f7;
|
|
|
|
- cursor: pointer;
|
|
|
|
|
|
+ .name {
|
|
|
|
+ color: #57a5f7;
|
|
|
|
+ cursor: pointer;
|
|
}
|
|
}
|
|
- .type{
|
|
|
|
- display: none;
|
|
|
|
|
|
+ .type {
|
|
|
|
+ display: none;
|
|
}
|
|
}
|
|
- .icon{
|
|
|
|
- display: block;
|
|
|
|
- cursor: pointer;
|
|
|
|
|
|
+ .icon {
|
|
|
|
+ display: block;
|
|
|
|
+ cursor: pointer;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|