QueryPageImage.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <div>
  3. <span>
  4. <template
  5. v-for="(item,index) in images"
  6. :key="'image-' + index"
  7. >
  8. <img
  9. v-if="images && images.length > 0"
  10. :src="getImageSrc(item)"
  11. class="img-thumbnail m-div"
  12. @click="showImage(item)"
  13. />
  14. </template>
  15. </span>
  16. <Modal
  17. ref="fullImage"
  18. full="true"
  19. :title="$t('lang.QueryPageImage.viewPicture')"
  20. :show-ok-button="false"
  21. >
  22. <template #default>
  23. <template
  24. v-for="(item,index) in images"
  25. :key="'image-' + index"
  26. >
  27. <img
  28. v-if="selectedImage && selectedImage.length > 0"
  29. :src="getImageSrc(selectedImage)"
  30. style="height: 100%;width: 100%"
  31. />
  32. </template>
  33. </template>
  34. <template #footer>
  35. <div>
  36. <button
  37. class="btn btn-success"
  38. type="button"
  39. @click="download"
  40. >
  41. {{ $t('lang.QueryPageImage.downloadPictures') }}
  42. </button>
  43. </div>
  44. </template>
  45. </Modal>
  46. </div>
  47. </template>
  48. <script>
  49. var Common = require('../../common/Common.js').default;
  50. var Modal = require('../../modal/src/Modal.vue').default;
  51. export default {
  52. components: {
  53. Modal,
  54. },
  55. props: {
  56. 'className': {
  57. type: Object,
  58. default: null,
  59. },
  60. 'imageNames':{
  61. type: String,
  62. default: null,
  63. },
  64. },
  65. data: function () {
  66. this.Common = Common;
  67. return {
  68. images: [],
  69. selectedImage: '',
  70. };
  71. },
  72. watch: {
  73. /**
  74. * fieldValue发生改变
  75. */
  76. imageNames: function (value) {
  77. if (value == undefined || value.length == 0) {
  78. this.images = [];
  79. } else {
  80. this.images = value.split(',');
  81. }
  82. },
  83. },
  84. mounted: function () {
  85. if (this.imageNames == undefined || this.imageNames.length == 0) {
  86. this.images = [];
  87. } else {
  88. this.images = this.imageNames.split(',');
  89. }
  90. },
  91. methods: {
  92. showImage: function (item) {
  93. this.selectedImage = item;
  94. this.$refs.fullImage.show = true;
  95. },
  96. /**
  97. * 获取图片地址
  98. * @param {String} item 图片名称
  99. * @return {String} 图片URL地址
  100. */
  101. getImageSrc: function (item) {
  102. var _self = this;
  103. if (item != undefined && item != null) {
  104. return Common.getImageSrc(_self.selectClause, item);
  105. } else {
  106. return '';
  107. }
  108. },
  109. download: function () {
  110. window.open(this.getImageSrc(this.selectedImage));
  111. },
  112. },
  113. };
  114. </script>
  115. <style scoped>
  116. </style>