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> <template>
<div> <div class="uploadbox">
<el-upload <el-upload
action="" action=""
:auto-upload="false"
list-type="picture-card" list-type="picture-card"
v-bind="$attrs" v-bind="$attrs"
v-on="$listeners" v-on="$listeners"
:on-preview="handlePictureCardPreview" :on-preview="handlePictureCardPreview"
:on-remove="handleRemove" :on-remove="handleRemove"
:file-list="fileList" :file-list="fileList"
@change="onUpdate"
ref="agupdateref" ref="agupdateref"
> >
<i class="el-icon-plus"></i> <i class="el-icon-plus"></i>
</el-upload> </el-upload>
<el-dialog :visible.sync="dialogVisible"> <el-dialog :visible.sync="dialogVisible">
<img width="100%" :src="dialogImageUrl" alt=""> <img width="100%" :src="dialogImageUrl" alt="">
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
@ -24,6 +24,7 @@
export default { export default {
name: "agUpdate", name: "agUpdate",
props:['style','class'],
data() { data() {
return { return {
dialogImageUrl: '', dialogImageUrl: '',
@ -32,22 +33,40 @@
}; };
}, },
mounted() { 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: { methods: {
handleRemove(file, fileList) { handleRemove(file, fileList) {
console.log(file, fileList); this.fileList=fileList;
this.$emit('onRemove',file,this.fileList);
}, },
handlePictureCardPreview(file) { handlePictureCardPreview(file) {
this.dialogImageUrl = file.url; this.dialogImageUrl = file.url;
this.dialogVisible = true; this.dialogVisible = true;
}, },
onUpdate(e){ 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> <div>{{row.date}} </div>
</template> </template>
</agTable> </agTable>
<agUpdate> <agUpdate @onUpload="onUpload" multiple style="width:120px">
</agUpdate> </agUpdate>
<!-- <el-input <!-- <el-input
@ -370,6 +370,9 @@ export default {
this.$refs.aginputref.value=123; this.$refs.aginputref.value=123;
}, },
methods: { methods: {
onUpload(files,filelist){
console.log("onblur",files,filelist);
},
onblur(val,elem){ onblur(val,elem){
console.log("onblur",val,elem,this); console.log("onblur",val,elem,this);