This commit is contained in:
ln1778 2024-09-05 19:03:22 +08:00
parent ab371f676a
commit 3f5e264a37
2 changed files with 40 additions and 18 deletions

View File

@ -1,22 +1,22 @@
<template>
<div>
<div class="uploadbox">
<el-upload
action=""
:auto-upload="false"
list-type="picture-card"
v-bind="$attrs"
v-on="$listeners"
:on-preview="handlePictureCardPreview"
:on-remove="handleRemove"
:file-list="fileList"
@change="onUpdate"
ref="agupdateref"
>
<i class="el-icon-plus"></i>
</el-upload>
<el-dialog :visible.sync="dialogVisible">
<img width="100%" :src="dialogImageUrl" alt="">
</el-dialog>
</div>
</template>
@ -24,6 +24,7 @@
export default {
name: "agUpdate",
props:['style','class'],
data() {
return {
dialogImageUrl: '',
@ -32,22 +33,40 @@
};
},
mounted() {
console.log(this.$refs.agupdateref,'this.$refs.agupdateref');
let input=this.$refs.agupdateref.$vnode&&this.$refs.agupdateref.$vnode.elm.querySelector('input[type=file]');
if(input){
input.addEventListener('change',this.onUpdate);
}
let input=this.$refs.agupdateref.vnode;
console.log(input,'input');
},
methods: {
handleRemove(file, fileList) {
console.log(file, fileList);
handleRemove(file, fileList) {
this.fileList=fileList;
this.$emit('onRemove',file,this.fileList);
},
handlePictureCardPreview(file) {
this.dialogImageUrl = file.url;
this.dialogVisible = true;
},
onUpdate(e){
console.log(e,"ee");
let uplist=[];
let files=[...e.target.files];
files.map((item,index) => {
let filerender=new FileReader();
filerender.onload=function(e){
uplist.push({
name:item.name,
url:e.target.result,
raw:item
});
if(files.length-1==index){
this.fileList.push(...uplist);
this.$emit('onUpload',uplist,this.fileList);
}
}.bind(this);
filerender.readAsDataURL(item);
});
}
},

View File

@ -47,7 +47,7 @@
<div>{{row.date}} </div>
</template>
</agTable>
<agUpdate>
<agUpdate @onUpload="onUpload" multiple style="width:120px">
</agUpdate>
<!-- <el-input
@ -370,6 +370,9 @@ export default {
this.$refs.aginputref.value=123;
},
methods: {
onUpload(files,filelist){
console.log("onblur",files,filelist);
},
onblur(val,elem){
console.log("onblur",val,elem,this);