selectImage.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <div class="select-image">
  3. <el-dialog :visible.sync="showDialog" :title="titleObj[imgType]" :close-on-click-modal="false"
  4. :modal-append-to-body="false" @close="cancelHandle" custom-class="select-image-dialog" center width="820px"
  5. v-dialogDrag>
  6. <el-input v-model="keyword"
  7. :placeholder="$t('OnlineExcelPage.please_input') + inputName[imgType] + $t('ETable.BalanceSheetTable.name')"
  8. clearable style="width:200px;" @input="handleSearch"></el-input>
  9. <div class="image-list">
  10. <div class="image-item" v-for="item in list" :key="item.ImageConfId">
  11. <div class="img-box">
  12. <div class="opt-box">
  13. <div class="item full-fix" @click="handleShowImgFull(item)">
  14. <img src="~@/assets/img/icons/fullsreen.png" alt="">
  15. </div>
  16. <div class="radio-fix">
  17. <el-radio v-if="imgType != 3" size="medium" v-model="momentChooseId"
  18. @change="changeRadio" :label="item.ImageConfId"></el-radio>
  19. <el-radio class="backcover-radio" v-else size="medium" v-model="momentChooseId"
  20. @click.native.prevent="clickRadio(item.ImageConfId)"
  21. :label="item.ImageConfId"></el-radio>
  22. </div>
  23. </div>
  24. <img class="img" :src="item.Url" alt="">
  25. </div>
  26. <p class="name">{{ item.ImgName || item.ImageName }}</p>
  27. </div>
  28. </div>
  29. <div style="margin-top: 20px;display: flex;justify-content:flex-end;padding-right: 40px;">
  30. <el-pagination @current-change="handleCurrentChange" :current-page="page" :page-size="pageSize"
  31. layout="total, prev, pager, next, jumper" :total="total">
  32. </el-pagination>
  33. </div>
  34. <div style="text-align:center;padding: 30px 0;margin-top: 60px;">
  35. <el-button style="width:120px;" @click="cancelHandle()">{{ $t('Dialog.cancel_btn') }}</el-button>
  36. <el-button type="primary" style="margin-left:20px;width:120px;" @click="handleSave">{{
  37. $t('Dialog.confirm_save_btn') }}</el-button>
  38. </div>
  39. <el-image-viewer :zIndex="9999" v-if="showPptViewer"
  40. :on-close="() => { this.picShowList = []; this.showPptViewer = false }" :url-list="picShowList" />
  41. </el-dialog>
  42. </div>
  43. </template>
  44. <script>
  45. import ElImageViewer from 'element-ui/packages/image/src/image-viewer';
  46. import { apiSmartReport } from '@/api/modules/smartReport'
  47. export default {
  48. components: { ElImageViewer },
  49. props: {
  50. },
  51. data() {
  52. return {
  53. momentChooseId: 0,
  54. momentChooseUrl: '',
  55. total: 0,
  56. list: [],
  57. pageSize: 8,
  58. page: 1,
  59. keyword: '',
  60. showPptViewer: false,
  61. picShowList: [],
  62. imgType: 1,
  63. showDialog: false,
  64. inputName: {
  65. 1: this.$t('SystemManage.BaseConfig.ppt_type01'),
  66. 2: this.$t('SystemManage.BaseConfig.ppt_type02'),
  67. 3: this.$t('SystemManage.BaseConfig.ppt_type03')
  68. },
  69. titleObj: {
  70. 1: this.$t('Slides.more_cover_page'),
  71. 2: this.$t('Slides.select_ground_page'),
  72. 3: this.$t('Slides.select_back_page')
  73. }
  74. }
  75. },
  76. mounted() {
  77. },
  78. methods: {
  79. handleShowImgFull(e) {
  80. console.log(e);
  81. this.picShowList = [e.Url]
  82. this.showPptViewer = true
  83. },
  84. handleCurrentChange(val) {
  85. this.page = val
  86. this.getImgList()
  87. },
  88. // 保存
  89. handleSave() {
  90. const obj = {
  91. url: this.momentChooseUrl,
  92. type: this.imgType,
  93. id: this.momentChooseId
  94. }
  95. this.cancelHandle()
  96. this.$emit('saveChoose', obj)
  97. },
  98. // 选择图片
  99. changeRadio(val) {
  100. const index = this.list.findIndex(el => el.ImageConfId == val)
  101. if (index > -1) {
  102. this.momentChooseUrl = this.list[index].Url
  103. }
  104. },
  105. // 封底图片选择
  106. clickRadio(val) {
  107. if (val === this.momentChooseId) {
  108. this.momentChooseId = 0
  109. this.momentChooseUrl = ''
  110. } else {
  111. this.momentChooseId = val
  112. const index = this.list.findIndex(el => el.ImageConfId == val)
  113. if (index > -1) {
  114. this.momentChooseUrl = this.list[index].Url
  115. }
  116. }
  117. },
  118. //资源库列表
  119. getImgList() {
  120. apiSmartReport.pptMaterialList({
  121. CurrentIndex: this.page,
  122. PageSize: this.pageSize,
  123. ImageType: this.imgType,
  124. ImageName: this.keyword,
  125. ConfType: 1
  126. }).then(res => {
  127. this.list = res.Data ? res.Data.List : []
  128. this.total = res.Data ? res.Data.Paging.Totals : 0
  129. if (!this.momentChooseId&&this.imgType!=3) {
  130. if (this.list.length) {
  131. this.momentChooseId = this.list[0].ImageConfId
  132. this.momentChooseUrl = this.list[0].Url
  133. }
  134. }
  135. })
  136. },
  137. // 搜索图片
  138. handleSearch() {
  139. this.page = 1
  140. this.getImgList()
  141. },
  142. // 打开弹框
  143. showHandle(type, id, url) {
  144. // console.log(type, id, url)
  145. this.showDialog = true
  146. this.imgType = type
  147. this.keyword = ''
  148. this.momentChooseId = id
  149. this.momentChooseUrl = url
  150. this.handleSearch()
  151. },
  152. // 关闭弹窗
  153. cancelHandle() {
  154. this.showDialog = false
  155. }
  156. }
  157. }
  158. </script>
  159. <style lang="scss">
  160. .select-image-dialog {
  161. .el-dialog__body {
  162. padding: 40px 60px !important;
  163. }
  164. .image-list {
  165. margin-top: 20px;
  166. display: flex;
  167. flex-wrap: wrap;
  168. gap: 20px;
  169. .image-item {
  170. width: 160px;
  171. .img-box {
  172. position: relative;
  173. cursor: pointer;
  174. width: 160px;
  175. .img {
  176. display: block;
  177. width: 100%;
  178. height: 160px;
  179. background-color: var(--gary-gy-3-disabled, #EBEFF6);
  180. object-fit: contain !important;
  181. box-sizing: border-box;
  182. &:hover {
  183. border: 1px solid #3375e1;
  184. }
  185. }
  186. .opt-box {
  187. position: absolute;
  188. z-index: 5;
  189. width: 100%;
  190. height: 100%;
  191. .item {
  192. width: 24px;
  193. height: 24px;
  194. display: flex;
  195. align-items: center;
  196. justify-content: center;
  197. background-color: #fff;
  198. border-radius: 50%;
  199. margin-left: 10px;
  200. img {
  201. width: 16px;
  202. height: 16px;
  203. }
  204. }
  205. .full-fix {
  206. position: absolute;
  207. top: 12px;
  208. right: 12px;
  209. }
  210. .radio-fix {
  211. position: absolute;
  212. top: 12px;
  213. left: 12px;
  214. }
  215. }
  216. &:hover {
  217. .opt-box {
  218. display: flex;
  219. }
  220. .select-box {
  221. display: block;
  222. }
  223. }
  224. }
  225. .name {
  226. padding-top: 5px;
  227. display: -webkit-box;
  228. overflow: hidden;
  229. text-overflow: ellipsis;
  230. -webkit-line-clamp: 2;
  231. line-break: anywhere;
  232. -webkit-box-orient: vertical;
  233. }
  234. }
  235. }
  236. .el-radio {
  237. .el-radio__label {
  238. display: none;
  239. }
  240. }
  241. .backcover-radio.el-radio:focus:not(.is-focus):not(:active):not(.is-disabled) .el-radio__inner {
  242. -webkit-box-shadow: none !important;
  243. box-shadow: none !important;
  244. }
  245. }
  246. </style>