index.vue 11 KB

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