| | |
| | | </span> |
| | | </div> |
| | | </el-upload> |
| | | <el-image-viewer |
| | | v-if="showViewer" |
| | | <el-image-viewer |
| | | v-if="showViewer" |
| | | :on-close="closeViewer" |
| | | :initialIndex="tempIndex" |
| | | :url-list="srcList" |
| | | :z-index="3000" |
| | | /> |
| | | </div> |
| | | |
| | | |
| | | </template> |
| | | |
| | | <script> |
| | |
| | | type: Array, |
| | | default: () => [] |
| | | }, |
| | | maxNum: { |
| | | type: Number, |
| | | default: () => null |
| | | }, |
| | | uploadData: Object, |
| | | }, |
| | | data() { |
| | | return { |
| | | uploadImgUrl: process.env.VUE_APP_API_PREFIX + '/public/uploadPicture', |
| | | |
| | | realList: [], |
| | | srcList: [], |
| | | tempIndex: 0, |
| | |
| | | watch: { |
| | | fileList: { |
| | | handler(val) { |
| | | console.log(val); |
| | | console.log("===================",val); |
| | | if (val.length==0) { |
| | | this.realList = [] |
| | | this.srcList = [] |
| | | }else{ |
| | | this.realList=val |
| | | val.forEach(item =>{ |
| | | this.srcList.push(item.url) |
| | | }) |
| | | } |
| | | |
| | | console.log("==================srcList=",this.srcList); |
| | | } |
| | | |
| | | |
| | | } |
| | | }, |
| | | methods: { |
| | | beforeUpload(file) { |
| | | |
| | | this.$emit('beginUpload') |
| | | return true |
| | | }, |
| | | // 上传图片成功 |
| | | uploadSuccess (res, file, fileList) { |
| | | // console.log('this.fileList', this.fileList); |
| | | uploadSuccess (res, file, fileList) { |
| | | console.log('this.fileList', this.fileList); |
| | | // console.log('fileList', fileList); |
| | | this.$emit('endUpload') |
| | | this.realList = fileList |
| | | this.srcList.push(res.data.url) |
| | | // this.realList = fileList |
| | | // this.srcList.push(res.data.url) |
| | | // console.log('file', file); |
| | | if (res.code === 200) { |
| | | this.fileList.push( |
| | |
| | | this.$message.error('上传失败') |
| | | }, |
| | | handlePictureCardPreview(file) { |
| | | this.tempIndex = this.srcList.findIndex(item => item == file.response.data.url ) |
| | | this.tempIndex = this.srcList.findIndex(item => item == file.url ) |
| | | this.showViewer = true |
| | | }, |
| | | closeViewer() { |
| | |
| | | }, |
| | | handleRemove(file) { |
| | | console.log(this.fileList); |
| | | let tempIndex = this.realList.findIndex(item => item.fileurl === file.response.data.imgaddr) |
| | | let tempIndex = this.realList.findIndex(item => item.fileurl === file.fileurl) |
| | | // debugger |
| | | this.realList.splice(tempIndex, 1) |
| | | this.fileList.splice(tempIndex, 1) |
| | | this.srcList.splice(tempIndex, 1) |
| | | |
| | | |
| | | }, |
| | | }, |
| | | } |