index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  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. <el-button
  63. type='primary'
  64. @click="jumpto"
  65. >
  66. 资源管理
  67. </el-button>
  68. </div>
  69. </el-dialog>
  70. </template>
  71. <script>
  72. import { get } from 'data-room-ui/js/utils/http'
  73. import { pageMixins } from 'data-room-ui/js/mixins/page'
  74. import _ from 'lodash'
  75. export default {
  76. name: 'SourceDialog',
  77. mixins: [pageMixins],
  78. props: {},
  79. data() {
  80. return {
  81. dialogVisible: false,
  82. loading: false,
  83. options: [],
  84. code: '',
  85. focus: -1,
  86. list: [],
  87. searchKey: ''
  88. }
  89. },
  90. computed: {
  91. gridComputed() {
  92. return this.list.length > 3
  93. }
  94. },
  95. mounted() { },
  96. methods: {
  97. jumpto(){
  98. let {href} = this.$router.resolve(`/big-screen-source?edit=1`)
  99. window.open(href,'_blank')
  100. },
  101. chooseImg(img) {
  102. this.focus = _.cloneDeep(img)
  103. },
  104. close() { },
  105. init() {
  106. this.dialogVisible = true
  107. this.current = 1
  108. this.searchKey = ''
  109. this.code = ''
  110. this.focus = -1
  111. this.getDataList()
  112. this.getCatalogList()
  113. },
  114. confirm() {
  115. this.dialogVisible = false
  116. if (this.focus !== -1) {
  117. this.$emit('getImg', this.focus)
  118. }
  119. },
  120. getDataList() {
  121. this.loading = true
  122. this.$dataRoomAxios.get('/bigScreen/file', {
  123. module: this.code,
  124. current: this.current,
  125. size: this.size,
  126. extension: '',
  127. searchKey: this.searchKey
  128. })
  129. .then((data) => {
  130. this.list = data.list
  131. this.totalCount = data.totalCount
  132. })
  133. .finally(() => {
  134. this.loading = false
  135. })
  136. },
  137. // 获取目录的列表
  138. getCatalogList() {
  139. this.$dataRoomAxios.get('/bigScreen/type/list/resourceCatalog')
  140. .then((data) => {
  141. this.options = data
  142. })
  143. .catch(() => { })
  144. }
  145. }
  146. }
  147. </script>
  148. <style lang="scss" scoped>
  149. @import '../../assets/style/bsTheme.scss';
  150. .big-screen-list-wrap {
  151. .el-select {
  152. display: inline-block !important;
  153. position: relative !important;
  154. width: auto !important;
  155. }
  156. position: relative;
  157. height: 100%;
  158. // margin:0 16px;
  159. // padding: 16px;
  160. color: #9ea9b2;
  161. background-color: var(--bs-background-2) !important;
  162. .top-search-wrap {
  163. display: flex;
  164. align-items: center;
  165. justify-content: flex-end;
  166. margin-bottom: 12px;
  167. .el-input {
  168. width: 200px;
  169. margin-right: 20px;
  170. ::v-deep.el-input__inner {
  171. background-color: var(--bs-background-1) !important;
  172. }
  173. }
  174. .el-select {
  175. margin-right: 20px;
  176. ::v-deep.el-input__inner {
  177. background: var(--bs-background-1) !important;
  178. background-color: var(--bs-background-1) !important;
  179. }
  180. }
  181. }
  182. .list-wrap {
  183. /* display: grid; */
  184. overflow: auto;
  185. // 间隙自适应
  186. justify-content: space-around;
  187. // max-height: calc(100vh - 270px);
  188. display: grid;
  189. grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  190. grid-gap: 15px;
  191. // ::v-deep .el-loading-mask {
  192. // display: flex;
  193. // align-items: center;
  194. // justify-content: center;
  195. // height: calc(100vh - 260px) !important;
  196. // z-index: 999;
  197. // top: 50px;
  198. // }
  199. .big-screen-card-wrap {
  200. position: relative;
  201. height: 230px;
  202. cursor: pointer;
  203. &:hover {
  204. .screen-card__hover {
  205. height: 180px;
  206. }
  207. }
  208. .screen-card__hover {
  209. position: absolute;
  210. z-index: 999;
  211. top: 0;
  212. right: 0;
  213. left: 0;
  214. display: flex;
  215. overflow: hidden;
  216. align-items: center;
  217. justify-content: center;
  218. height: 0;
  219. transition: height 0.4s;
  220. background: #00000099;
  221. }
  222. .focus {
  223. color: var(--bs-el-text) !important;
  224. border: 1px solid var(--bs-el-color-primary) !important;
  225. }
  226. .big-screen-card-inner {
  227. overflow: hidden;
  228. width: 100%;
  229. height: 100%;
  230. cursor: pointer;
  231. background-color: var(--bs-background-2);
  232. box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
  233. color: var(--bs-el-title);
  234. border: 1px solid var(--bs-background-2);
  235. &:hover {
  236. color: var(--bs-el-text);
  237. border: 1px solid var(--bs-el-color-primary);
  238. }
  239. .add-big-screen-card-text {
  240. color: var(--bs-el-color-primary);
  241. font-size: 24px;
  242. }
  243. .big-screen-card-img {
  244. width: 100%;
  245. height: 180px;
  246. img {
  247. width: 100%;
  248. height: 100%;
  249. object-fit: cover;
  250. }
  251. ::v-deep.image-slot {
  252. height: 100%;
  253. background-color: var(--bs-background-2);
  254. display: flex;
  255. align-items: center;
  256. justify-content: center;
  257. }
  258. ::v-deep.el-image__error {
  259. background-color: #1d1d1d;
  260. }
  261. }
  262. .big-screen-bottom {
  263. display: flex;
  264. align-items: center;
  265. flex-direction: row;
  266. justify-content: space-between;
  267. box-sizing: border-box;
  268. width: 100%;
  269. /*height: 26px;*/
  270. padding: 0 10px;
  271. height: calc(100% - 180px);
  272. color: var(--bs-el-title);
  273. background-color: var(--bs-background-2);
  274. .left-bigscreen-title {
  275. font-size: 14px;
  276. overflow: hidden;
  277. width: 100%;
  278. white-space: nowrap;
  279. text-overflow: ellipsis;
  280. }
  281. .right-bigscreen-time-title {
  282. font-size: 14px;
  283. overflow: hidden;
  284. width: 140px;
  285. white-space: nowrap;
  286. text-overflow: ellipsis;
  287. }
  288. }
  289. .big-screen-card-text {
  290. font-size: 14px;
  291. padding: 10px;
  292. text-align: center;
  293. color: #333;
  294. }
  295. }
  296. .big-screen-card-inner-add {
  297. display: flex;
  298. align-items: center;
  299. justify-content: center;
  300. }
  301. }
  302. }
  303. .el-loading-parent--relative {
  304. position: unset !important;
  305. }
  306. .footer-pagination-wrap {
  307. width: 100%;
  308. position: absolute;
  309. margin-top: 16px;
  310. }
  311. }
  312. .bs-pagination {
  313. ::v-deep .el-input__inner {
  314. width: 110px !important;
  315. border: none;
  316. background: var(--bs-el-background-1);
  317. }
  318. }
  319. .empty {
  320. width: 100%;
  321. height: 70%;
  322. min-height: 300px;
  323. display: flex;
  324. justify-content: center;
  325. align-items: center;
  326. }
  327. </style>