index.vue 10 KB

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