This commit is contained in:
parent
9e13f52a1d
commit
6cfe46c60b
|
|
@ -8,7 +8,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<div class="mask">
|
<div class="mask">
|
||||||
<span class="del" @click.stop="del"><i class="el-icon-delete"></i></span>
|
<span class="del" @click.stop="del(index)"><i class="el-icon-delete"></i></span>
|
||||||
</div>
|
</div>
|
||||||
<el-image class="image" :src="file.url" :preview-src-list="[file.url]" fit="cover" hide-on-click-modal append-to-body></el-image>
|
<el-image class="image" :src="file.url" :preview-src-list="[file.url]" fit="cover" hide-on-click-modal append-to-body></el-image>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="sc-upload-uploader">
|
<div class="sc-upload-uploader">
|
||||||
<el-upload ref="upload" :action="action" :accept="accept" multiple :show-file-list="true" :before-upload="before" :on-success="success" :on-error="error">
|
<el-upload ref="upload" :action="action" :accept="accept" multiple :show-file-list="true" :file-list="defaultList" :before-upload="before" :on-success="success" :on-remove="remove" :on-error="error">
|
||||||
<el-button size="small" type="primary">点击上传</el-button>
|
<el-button size="small" type="primary">点击上传</el-button>
|
||||||
</el-upload>
|
</el-upload>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -33,35 +33,39 @@
|
||||||
},
|
},
|
||||||
data(){
|
data(){
|
||||||
return {
|
return {
|
||||||
|
defaultList: this.toArr(this.modelValue),
|
||||||
fileList: []
|
fileList: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch:{
|
watch:{
|
||||||
// modelValue(){
|
modelValue(){
|
||||||
// this.fileList = this.toArr(this.modelValue);
|
|
||||||
// },
|
},
|
||||||
// fileList: {
|
fileList: {
|
||||||
// handler(){
|
handler(val){
|
||||||
// this.$emit('update:modelValue', this.toStr(this.fileList));
|
this.$emit('update:modelValue', this.toStr(val));
|
||||||
// },
|
},
|
||||||
// deep: true
|
deep: true
|
||||||
// }
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.fileList = this.toArr(this.modelValue);
|
this.fileList = this.$refs.upload.uploadFiles
|
||||||
this.$refs.upload.uploadFiles = this.fileList
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
//默认值转换为数组
|
//默认值转换为数组
|
||||||
toArr(str){
|
toArr(str){
|
||||||
var _arr = [];
|
var _arr = [];
|
||||||
var arr = str.split(",");
|
var arr = str.split(",");
|
||||||
arr.forEach(item => {
|
arr.forEach(item => {
|
||||||
_arr.push({
|
if(item){
|
||||||
name: "F",
|
_arr.push({
|
||||||
status: "success",
|
name: "F",
|
||||||
url: item
|
status: "success",
|
||||||
})
|
url: item
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
return _arr;
|
return _arr;
|
||||||
},
|
},
|
||||||
|
|
@ -75,15 +79,13 @@
|
||||||
return str;
|
return str;
|
||||||
},
|
},
|
||||||
before(){
|
before(){
|
||||||
this.fileList = this.$refs.upload.uploadFiles;
|
console.log(this.$refs.upload.uploadFiles);
|
||||||
this.fileList.forEach(item => {
|
|
||||||
if(item.status!='success'){
|
|
||||||
item.tempURL = URL.createObjectURL(item.raw);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
success(res, file){
|
success(res, file){
|
||||||
file.url = res.data.src
|
file.url = res.data.src
|
||||||
|
},
|
||||||
|
remove(){
|
||||||
|
|
||||||
},
|
},
|
||||||
error(err){
|
error(err){
|
||||||
this.$notify.error({
|
this.$notify.error({
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@
|
||||||
uploadUrl: this.$API.demo.upload.url,
|
uploadUrl: this.$API.demo.upload.url,
|
||||||
imgurl: "images/avatar.jpg",
|
imgurl: "images/avatar.jpg",
|
||||||
avatar: "",
|
avatar: "",
|
||||||
imgs: "images/avatar.jpg,images/avatar.jpg",
|
imgs: "images/avatar.jpg,images/avatar2.gif,images/avatar3.gif",
|
||||||
form: {
|
form: {
|
||||||
img1: "",
|
img1: "",
|
||||||
img2: "",
|
img2: "",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue