imgShow.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <el-dialog
  3. :title="title"
  4. :center="true"
  5. align="left"
  6. top="8vh"
  7. width="600px"
  8. @close="closeModel"
  9. :close-on-click-modal="false"
  10. :visible.sync="showModelThis"
  11. >
  12. <el-card>
  13. <el-row :gutter="10" >
  14. <el-col :span="24">
  15. <img class="activeImg" :src="activeImg" alt="" />
  16. </el-col>
  17. <el-col :span="24" style="text-align: right;padding-top:10px" v-if="imgList&&imgList.length>0">
  18. <div class="img-box">
  19. <img
  20. @click="initForm(i)"
  21. :class="{ active: activeIndex === i }"
  22. v-for="(img, i) in imgList"
  23. :key="'imgboxitem' + i"
  24. :src="img"
  25. alt=""
  26. />
  27. </div>
  28. </el-col>
  29. </el-row>
  30. </el-card>
  31. </el-dialog>
  32. </template>
  33. <script>
  34. export default {
  35. name: "goods",
  36. props: ["showModel", "imgList", "index"],
  37. data() {
  38. return {
  39. activeImg: "",
  40. activeIndex: this.index,
  41. showModelThis: this.showModel,
  42. };
  43. },
  44. methods: {
  45. closeModel() {
  46. this.showModelThis = false;
  47. },
  48. initForm(index) {
  49. this.activeIndex = index;
  50. this.activeImg = this.imgList[index];
  51. },
  52. },
  53. watch: {
  54. showModel: function (val) {
  55. this.showModelThis = val;
  56. if (val) {
  57. this.initForm(this.index);
  58. }
  59. },
  60. showModelThis(val) {
  61. if (!val) {
  62. this.$emit("cancel");
  63. }
  64. },
  65. },
  66. };
  67. </script>
  68. <style lang="scss" scoped>
  69. .goods {
  70. .activeImg {
  71. display: inline-block;
  72. width: 100%;
  73. }
  74. .img-box {
  75. img {
  76. width: 40px;
  77. height: 40px;
  78. display: inline-block;
  79. margin: 0 3px;
  80. border:1px solid transparent;
  81. &.active {
  82. border: 1px solid red;
  83. }
  84. &:hover {
  85. cursor: pointer;
  86. }
  87. }
  88. }
  89. }
  90. </style>