deletComplaintImg.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <div v-if="itemData.fileInfoList">
  3. <van-col span="6" v-for="(urls, index) in itemData.fileInfoList" :key="index">
  4. <div class="imgview2">
  5. <van-icon name="close" size="16" v-on:click="deleteImg(index, urls.id)" />
  6. <img :src="urls.fileUrl" width="100px" height="100px" @click="previewsImg(index)" />
  7. </div>
  8. </van-col>
  9. </div>
  10. </template>
  11. <script>
  12. import { ImagePreview } from 'vant';
  13. import { removeSummaryPhoto, removePhoto } from '@/api/index';
  14. export default {
  15. name: 'deleteUploadImg',
  16. props: {
  17. itemData: {
  18. type: Object,
  19. default: {},
  20. },
  21. },
  22. data() {
  23. return {
  24. url: process.env.VUE_APP_Target1 + process.env.VUE_APP_BASE_API,
  25. };
  26. },
  27. methods: {
  28. deleteImg(index, id) {
  29. var fileName = {
  30. fileId: id,
  31. };
  32. removeSummaryPhoto(fileName).then((res) => {
  33. if (res.code == 200) {
  34. this.$toast('删除成功!');
  35. this.$emit('deleteImg', { itemData: this.itemData, index: index });
  36. // this.imgs.splice(index, 1);
  37. } else {
  38. this.$toast('删除失败!');
  39. }
  40. });
  41. },
  42. previewsImg(index) {
  43. var arrimg = [];
  44. for (var imgi = 0; imgi < this.itemData.fileInfoList.length; imgi++) {
  45. arrimg.push(this.itemData.fileInfoList[imgi].fileUrl);
  46. }
  47. ImagePreview({
  48. images: arrimg,
  49. startPosition: index,
  50. onClose() {
  51. // do something
  52. },
  53. });
  54. },
  55. },
  56. };
  57. </script>
  58. <style lang="scss" scoped>
  59. .imgview2 {
  60. height: 80px;
  61. width: 80px;
  62. padding: 3px;
  63. /* border: 1px solid #ccc; */
  64. height: 72px;
  65. position: relative;
  66. border-radius: 5px;
  67. display: inline-block;
  68. i {
  69. position: absolute;
  70. right: -2px;
  71. top: -3px;
  72. color: white;
  73. background: red;
  74. overflow: hidden;
  75. border-radius: 50%;
  76. }
  77. img {
  78. width: 100%;
  79. height: 100%;
  80. }
  81. }
  82. </style>