index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  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. type="primary"
  41. @click="reSearch"
  42. >
  43. 搜索
  44. </el-button>
  45. </div>
  46. <div
  47. v-if="list.length !== 0"
  48. v-loading="loading"
  49. class="list-wrap bs-scrollbar"
  50. element-loading-text="加载中"
  51. :style="{
  52. display: gridComputed ? 'grid' : 'flex',
  53. justifyContent: gridComputed ? 'space-around' : 'flex-start',
  54. height: 'calc(100vh - 400px)',
  55. marginBottom: '38px'
  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="getCoverPicture(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>
  104. <div class="footer-pagination-wrap">
  105. <div class="bs-pagination">
  106. <el-pagination
  107. class="bs-el-pagination"
  108. popper-class="bs-el-pagination"
  109. background
  110. layout="total, prev, pager, next, sizes"
  111. :page-size="size"
  112. prev-text="上一页"
  113. next-text="下一页"
  114. :total="totalCount"
  115. :page-sizes="[10, 20, 50, 100]"
  116. :current-page="current"
  117. @current-change="currentChangeHandle"
  118. @size-change="sizeChangeHandle"
  119. />
  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 cloneDeep from 'lodash/cloneDeep'
  151. import { getFileUrl } from 'data-room-ui/js/utils/file'
  152. export default {
  153. name: 'SourceDialog',
  154. mixins: [pageMixins],
  155. props: {},
  156. data () {
  157. return {
  158. dialogVisible: false,
  159. loading: false,
  160. options: [],
  161. code: '',
  162. focus: -1,
  163. list: [],
  164. searchKey: '',
  165. imgExtends: ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'svg', 'webp', 'ico']
  166. }
  167. },
  168. computed: {
  169. gridComputed () {
  170. return this.list.length > 3
  171. }
  172. },
  173. mounted () { },
  174. methods: {
  175. jumpto () {
  176. const { href } = this.$router.resolve('/dataRoom-redirect?edit=source')
  177. window.open(href, '_blank')
  178. },
  179. chooseImg (img) {
  180. this.focus = cloneDeep(img)
  181. },
  182. close () { },
  183. init () {
  184. this.dialogVisible = true
  185. this.current = 1
  186. this.searchKey = ''
  187. this.code = ''
  188. this.focus = -1
  189. this.getDataList()
  190. this.getCatalogList()
  191. },
  192. confirm () {
  193. this.dialogVisible = false
  194. if (this.focus !== -1) {
  195. this.$emit('getImg', this.focus)
  196. }
  197. },
  198. getDataList () {
  199. this.loading = true
  200. this.$dataRoomAxios.get('/bigScreen/file', {
  201. module: this.code,
  202. current: this.current,
  203. size: this.size,
  204. // 资源库中只显示图片类型的文件
  205. extensionList: this.imgExtends,
  206. searchKey: this.searchKey
  207. })
  208. .then((data) => {
  209. this.list = data.list
  210. this.totalCount = data.totalCount
  211. })
  212. .finally(() => {
  213. this.loading = false
  214. })
  215. },
  216. // 获取目录的列表
  217. getCatalogList () {
  218. this.$dataRoomAxios.get('/bigScreen/type/list/resourceCatalog')
  219. .then((data) => {
  220. this.options = data
  221. })
  222. .catch(() => { })
  223. },
  224. /**
  225. * 获取文件访问地址,如果是相对路径则拼接上文件访问前缀地址
  226. * @param url
  227. * @returns {*}
  228. */
  229. getCoverPicture (url) {
  230. return getFileUrl(url)
  231. },
  232. }
  233. }
  234. </script>
  235. <style lang="scss" scoped>
  236. @import '../../assets/style/bsTheme.scss';
  237. ::v-deep .el-dialog__body{
  238. position: relative;
  239. min-height: 500px;
  240. padding: 0 16px 16px 16px !important;
  241. }
  242. .big-screen-list-wrap {
  243. .el-select {
  244. display: inline-block !important;
  245. position: relative !important;
  246. width: auto !important;
  247. }
  248. position: relative;
  249. height: 100%;
  250. // margin:0 16px;
  251. // padding: 16px;
  252. color: #9ea9b2;
  253. background-color: var(--bs-background-2) !important;
  254. .top-search-wrap {
  255. display: flex;
  256. align-items: center;
  257. justify-content: flex-end;
  258. position: sticky;
  259. top: 0px;
  260. z-index: 999;
  261. padding: 16px 0;
  262. background-color: var(--bs-background-2);
  263. .el-input {
  264. width: 200px;
  265. margin-right: 20px;
  266. ::v-deep.el-input__inner {
  267. background-color: var(--bs-background-1) !important;
  268. }
  269. }
  270. .el-select {
  271. margin-right: 20px;
  272. ::v-deep.el-input__inner {
  273. background: var(--bs-background-1) !important;
  274. background-color: var(--bs-background-1) !important;
  275. }
  276. }
  277. }
  278. .list-wrap {
  279. /* display: grid; */
  280. overflow: auto;
  281. // 间隙自适应
  282. justify-content: space-around;
  283. // max-height: calc(100vh - 270px);
  284. display: grid;
  285. grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  286. grid-gap: 15px;
  287. .big-screen-card-wrap {
  288. position: relative;
  289. height: 230px;
  290. cursor: pointer;
  291. &:hover {
  292. .screen-card__hover {
  293. height: 180px;
  294. }
  295. }
  296. .screen-card__hover {
  297. position: absolute;
  298. z-index: 999;
  299. top: 0;
  300. right: 0;
  301. left: 0;
  302. display: flex;
  303. overflow: hidden;
  304. align-items: center;
  305. justify-content: center;
  306. height: 0;
  307. transition: height 0.4s;
  308. background: #00000099;
  309. }
  310. .focus {
  311. color: var(--bs-el-text) !important;
  312. border: 1px solid var(--bs-el-color-primary) !important;
  313. }
  314. .big-screen-card-inner {
  315. overflow: hidden;
  316. width: 100%;
  317. height: 100%;
  318. cursor: pointer;
  319. background-color: var(--bs-background-2);
  320. box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
  321. color: var(--bs-el-title);
  322. border: 1px solid var(--bs-background-2);
  323. &:hover {
  324. color: var(--bs-el-text);
  325. border: 1px solid var(--bs-el-color-primary);
  326. }
  327. .add-big-screen-card-text {
  328. color: var(--bs-el-color-primary);
  329. font-size: 24px;
  330. }
  331. .big-screen-card-img {
  332. width: 100%;
  333. height: 180px;
  334. img {
  335. width: 100%;
  336. height: 100%;
  337. object-fit: cover;
  338. }
  339. ::v-deep.image-slot {
  340. height: 100%;
  341. background-color: var(--bs-background-2);
  342. display: flex;
  343. align-items: center;
  344. justify-content: center;
  345. }
  346. ::v-deep.el-image__error {
  347. background-color: #1d1d1d;
  348. }
  349. }
  350. .big-screen-bottom {
  351. display: flex;
  352. align-items: center;
  353. flex-direction: row;
  354. justify-content: space-between;
  355. box-sizing: border-box;
  356. width: 100%;
  357. /*height: 26px;*/
  358. padding: 0 10px;
  359. height: calc(100% - 180px);
  360. color: var(--bs-el-title);
  361. background-color: var(--bs-background-2);
  362. .left-bigscreen-title {
  363. font-size: 14px;
  364. overflow: hidden;
  365. width: 100%;
  366. white-space: nowrap;
  367. text-overflow: ellipsis;
  368. }
  369. .right-bigscreen-time-title {
  370. font-size: 14px;
  371. overflow: hidden;
  372. width: 140px;
  373. white-space: nowrap;
  374. text-overflow: ellipsis;
  375. }
  376. }
  377. .big-screen-card-text {
  378. font-size: 14px;
  379. padding: 10px;
  380. text-align: center;
  381. color: #333;
  382. }
  383. }
  384. .big-screen-card-inner-add {
  385. display: flex;
  386. align-items: center;
  387. justify-content: center;
  388. }
  389. }
  390. }
  391. .el-loading-parent--relative {
  392. position: unset !important;
  393. }
  394. }
  395. .footer-pagination-wrap {
  396. bottom: 5px;
  397. right: 16px;
  398. width: 100%;
  399. margin-top: 16px;
  400. position: absolute;
  401. }
  402. .bs-pagination {
  403. ::v-deep .el-input__inner {
  404. width: 110px !important;
  405. border: none;
  406. background: var(--bs-el-background-1);
  407. }
  408. }
  409. .empty {
  410. width: 100%;
  411. height: 70%;
  412. min-height: 300px;
  413. display: flex;
  414. justify-content: center;
  415. align-items: center;
  416. }
  417. </style>