deletComplaintImg.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. width: 100%;
  61. height: 80px;
  62. position: relative;
  63. display: inline-block;
  64. i {
  65. position: absolute;
  66. right: -2px;
  67. top: -3px;
  68. color: white;
  69. background: red;
  70. overflow: hidden;
  71. border-radius: 50%;
  72. }
  73. img {
  74. width: 100%;
  75. height: 100%;
  76. }
  77. }
  78. </style>