index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. <template>
  2. <el-dialog title="资源库" :visible.sync="dialogVisible" width="80%" :modal="true" :modal-append-to-body="false"
  3. :appen-to-body="true" class="bs-dialog-wrap bs-el-dialog" @closed="close">
  4. <div class="content">
  5. <div class="big-screen-list-wrap">
  6. <div class="top-search-wrap">
  7. <el-input v-model="searchKey" class="bs-el-input" placeholder="请输入图片名称" prefix-icon="el-icon-search" clearable
  8. @clear="reSearch" @keyup.enter.native="reSearch" />
  9. <el-select v-model="code" class="bs-el-select" popper-class="bs-el-select" placeholder="请选择类型" clearable
  10. @change="reSearch">
  11. <el-option v-for="item in options" :key="item.id" :label="item.name" :value="item.code" />
  12. </el-select>
  13. <el-button size="small" style="margin-right: 20px" type="primary" @click="reSearch">
  14. 搜索
  15. </el-button>
  16. </div>
  17. <div v-if="list.length !== 0" v-loading="loading" class="list-wrap bs-scrollbar" element-loading-text="加载中"
  18. :style="{
  19. display: gridComputed ? 'grid' : 'flex',
  20. justifyContent: gridComputed ? 'space-around' : 'flex-start'
  21. }">
  22. <!-- <div v-if="list.length !== 0"> -->
  23. <div v-for="screen in list" :key="screen.id" class="big-screen-card-wrap" :style="{
  24. width: gridComputed ? 'auto' : '290px'
  25. }" @click="chooseImg(screen)">
  26. <div :class="focus.id == screen.id ? 'focus' : ''" class="big-screen-card-inner">
  27. <div class="big-screen-card-img">
  28. <el-image :src="screen.url" fit="contain" style="width: 100%; height: 100%">
  29. <div slot="placeholder" class="image-slot">
  30. 加载中···
  31. </div>
  32. </el-image>
  33. </div>
  34. <div class="big-screen-bottom">
  35. <div class="left-bigscreen-title" :title="screen.originalName">
  36. {{ screen.originalName }}
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. <div v-else class="empty">
  43. 暂无数据
  44. </div>
  45. <div class="footer-pagination-wrap">
  46. <div class="bs-pagination">
  47. <el-pagination class="bs-el-pagination" popper-class="bs-el-pagination" background
  48. layout="total, prev, pager, next, sizes" :page-size="size" prev-text="上一页" next-text="下一页"
  49. :total="totalCount" :page-sizes="[10, 20, 50, 100]" :current-page="current"
  50. @current-change="currentChangeHandle" @size-change="sizeChangeHandle" />
  51. </div>
  52. </div>
  53. </div>
  54. </div>
  55. <div slot="footer" class="dialog-footer">
  56. <el-button class="bs-el-button-default" @click="dialogVisible = false">
  57. 取消
  58. </el-button>
  59. <el-button type="primary" @click="confirm">
  60. 确定
  61. </el-button>
  62. </div>
  63. </el-dialog>
  64. </template>
  65. <script>
  66. import { get } from 'data-room-ui/js/utils/http'
  67. import { pageMixins } from 'data-room-ui/js/mixins/page'
  68. import _ from 'lodash'
  69. export default {
  70. name: 'SourceDialog',
  71. mixins: [pageMixins],
  72. props: {},
  73. data() {
  74. return {
  75. dialogVisible: false,
  76. loading: false,
  77. options: [],
  78. code: '',
  79. focus: -1,
  80. list: [],
  81. searchKey: ''
  82. }
  83. },
  84. computed: {
  85. gridComputed() {
  86. return this.list.length > 3
  87. }
  88. },
  89. mounted() { },
  90. methods: {
  91. chooseImg(img) {
  92. this.focus = _.cloneDeep(img)
  93. },
  94. close() { },
  95. init() {
  96. this.dialogVisible = true
  97. this.current = 1
  98. this.searchKey = ''
  99. this.code = ''
  100. this.focus = -1
  101. this.getDataList()
  102. this.getCatalogList()
  103. },
  104. confirm() {
  105. this.dialogVisible = false
  106. if (this.focus !== -1) {
  107. this.$emit('getImg', this.focus)
  108. }
  109. },
  110. getDataList() {
  111. this.loading = true
  112. this.$dataRoomAxios.get('/bigScreen/file', {
  113. module: this.code,
  114. current: this.current,
  115. size: this.size,
  116. extension: '',
  117. searchKey: this.searchKey
  118. })
  119. .then((data) => {
  120. this.list = data.list
  121. this.totalCount = data.totalCount
  122. })
  123. .finally(() => {
  124. this.loading = false
  125. })
  126. },
  127. // 获取目录的列表
  128. getCatalogList() {
  129. this.$dataRoomAxios.get('/bigScreen/type/list/resourceCatalog')
  130. .then((data) => {
  131. this.options = data
  132. })
  133. .catch(() => { })
  134. }
  135. }
  136. }
  137. </script>
  138. <style lang="scss" scoped>
  139. @import '../../assets/style/bsTheme.scss';
  140. .big-screen-list-wrap {
  141. .el-select {
  142. display: inline-block !important;
  143. position: relative !important;
  144. width: auto !important;
  145. }
  146. position: relative;
  147. height: 100%;
  148. // margin:0 16px;
  149. // padding: 16px;
  150. color: #9ea9b2;
  151. background-color: var(--bs-background-2) !important;
  152. .top-search-wrap {
  153. display: flex;
  154. align-items: center;
  155. justify-content: flex-end;
  156. margin-bottom: 12px;
  157. .el-input {
  158. width: 200px;
  159. margin-right: 20px;
  160. ::v-deep.el-input__inner {
  161. background-color: var(--bs-background-1) !important;
  162. }
  163. }
  164. .el-select {
  165. margin-right: 20px;
  166. ::v-deep.el-input__inner {
  167. background: var(--bs-background-1) !important;
  168. background-color: var(--bs-background-1) !important;
  169. }
  170. }
  171. }
  172. .list-wrap {
  173. /* display: grid; */
  174. overflow: auto;
  175. // 间隙自适应
  176. justify-content: space-around;
  177. // max-height: calc(100vh - 270px);
  178. display: grid;
  179. grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  180. grid-gap: 15px;
  181. // ::v-deep .el-loading-mask {
  182. // display: flex;
  183. // align-items: center;
  184. // justify-content: center;
  185. // height: calc(100vh - 260px) !important;
  186. // z-index: 999;
  187. // top: 50px;
  188. // }
  189. .big-screen-card-wrap {
  190. position: relative;
  191. height: 230px;
  192. cursor: pointer;
  193. &:hover {
  194. .screen-card__hover {
  195. height: 180px;
  196. }
  197. }
  198. .screen-card__hover {
  199. position: absolute;
  200. z-index: 999;
  201. top: 0;
  202. right: 0;
  203. left: 0;
  204. display: flex;
  205. overflow: hidden;
  206. align-items: center;
  207. justify-content: center;
  208. height: 0;
  209. transition: height 0.4s;
  210. background: #00000099;
  211. }
  212. .focus {
  213. color: var(--bs-el-text) !important;
  214. border: 1px solid var(--bs-el-color-primary) !important;
  215. }
  216. .big-screen-card-inner {
  217. overflow: hidden;
  218. width: 100%;
  219. height: 100%;
  220. cursor: pointer;
  221. background-color: var(--bs-background-2);
  222. box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
  223. color: var(--bs-el-title);
  224. border: 1px solid var(--bs-background-2);
  225. &:hover {
  226. color: var(--bs-el-text);
  227. border: 1px solid var(--bs-el-color-primary);
  228. }
  229. .add-big-screen-card-text {
  230. color: var(--bs-el-color-primary);
  231. font-size: 24px;
  232. }
  233. .big-screen-card-img {
  234. width: 100%;
  235. height: 180px;
  236. img {
  237. width: 100%;
  238. height: 100%;
  239. object-fit: cover;
  240. }
  241. ::v-deep.image-slot {
  242. height: 100%;
  243. background-color: var(--bs-background-2);
  244. display: flex;
  245. align-items: center;
  246. justify-content: center;
  247. }
  248. ::v-deep.el-image__error {
  249. background-color: #1d1d1d;
  250. }
  251. }
  252. .big-screen-bottom {
  253. display: flex;
  254. align-items: center;
  255. flex-direction: row;
  256. justify-content: space-between;
  257. box-sizing: border-box;
  258. width: 100%;
  259. /*height: 26px;*/
  260. padding: 0 10px;
  261. height: calc(100% - 180px);
  262. color: var(--bs-el-title);
  263. background-color: var(--bs-background-2);
  264. .left-bigscreen-title {
  265. font-size: 14px;
  266. overflow: hidden;
  267. width: 100%;
  268. white-space: nowrap;
  269. text-overflow: ellipsis;
  270. }
  271. .right-bigscreen-time-title {
  272. font-size: 14px;
  273. overflow: hidden;
  274. width: 140px;
  275. white-space: nowrap;
  276. text-overflow: ellipsis;
  277. }
  278. }
  279. .big-screen-card-text {
  280. font-size: 14px;
  281. padding: 10px;
  282. text-align: center;
  283. color: #333;
  284. }
  285. }
  286. .big-screen-card-inner-add {
  287. display: flex;
  288. align-items: center;
  289. justify-content: center;
  290. }
  291. }
  292. }
  293. .el-loading-parent--relative {
  294. position: unset !important;
  295. }
  296. .footer-pagination-wrap {
  297. width: 100%;
  298. position: absolute;
  299. margin-top: 16px;
  300. }
  301. }
  302. .bs-pagination {
  303. ::v-deep .el-input__inner {
  304. width: 110px !important;
  305. border: none;
  306. background: var(--bs-el-background-1);
  307. }
  308. }
  309. .empty {
  310. width: 100%;
  311. height: 70%;
  312. min-height: 300px;
  313. display: flex;
  314. justify-content: center;
  315. align-items: center;
  316. }
  317. </style>