index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. <template>
  2. <div class="big-screen-list-wrap">
  3. <div class="internal-box">
  4. <div class="top-search-wrap">
  5. <el-input
  6. v-model="searchKey"
  7. class="bs-el-input"
  8. placeholder="请输入图片名称"
  9. prefix-icon="el-icon-search"
  10. clearable
  11. @clear="reSearch"
  12. @keyup.enter.native="reSearch"
  13. />
  14. <el-select
  15. v-model="extend"
  16. class="bs-el-select"
  17. popper-class="bs-el-select"
  18. placeholder="请选择图片格式"
  19. clearable
  20. @change="reSearch"
  21. >
  22. <el-option
  23. v-for="item in options"
  24. :key="item.value"
  25. :label="item.label"
  26. :value="item.value"
  27. />
  28. </el-select>
  29. <el-button
  30. size="small"
  31. style="margin-right: 20px"
  32. type="primary"
  33. @click="reSearch"
  34. >
  35. 搜索
  36. </el-button>
  37. <el-upload
  38. accept="image/*, video/*"
  39. class="upload-demo"
  40. :action="upLoadUrl"
  41. :headers="headers"
  42. :data="{ module: code }"
  43. :before-upload="beforeUpload"
  44. :on-success="uploadSuccess"
  45. :on-error="uploadError"
  46. multiple
  47. :file-list="fileList"
  48. :show-file-list="false"
  49. >
  50. <el-button
  51. size="small"
  52. type="primary"
  53. >
  54. 上传资源
  55. </el-button>
  56. </el-upload>
  57. </div>
  58. <div
  59. v-if="list.length !== 0"
  60. v-loading="loading"
  61. class="list-wrap bs-scrollbar"
  62. element-loading-text="加载中"
  63. :style="{
  64. display: gridComputed ? 'grid' : 'flex',
  65. justifyContent: gridComputed ? 'space-around' : 'flex-start'
  66. }"
  67. >
  68. <!-- <div v-if="list.length !== 0"> -->
  69. <div
  70. v-for="screen in list"
  71. :key="screen.id"
  72. class="big-screen-card-wrap"
  73. :style="{
  74. width: gridComputed ? 'auto' : '290px'
  75. }"
  76. >
  77. <div class="big-screen-card-inner">
  78. <div class="screen-card__hover">
  79. <div class="screen-card__hover-box">
  80. <div class="preview">
  81. <div
  82. class="screen-card__oper-label circle"
  83. @click="preview(screen)"
  84. >
  85. <span>预览</span>
  86. </div>
  87. <div
  88. class="circle"
  89. @click="downLoad(screen)"
  90. >
  91. <span>下载</span>
  92. </div>
  93. <div
  94. class="circle"
  95. @click="del(screen)"
  96. >
  97. <span>删除</span>
  98. </div>
  99. <div
  100. class="circle"
  101. @click="copy(screen)"
  102. >
  103. <span>链接</span>
  104. </div>
  105. </div>
  106. </div>
  107. </div>
  108. <div class="big-screen-card-img">
  109. <el-image
  110. :src="screen.url"
  111. fit="contain"
  112. style="width: 100%; height: 100%"
  113. >
  114. <div
  115. slot="placeholder"
  116. class="image-slot"
  117. >
  118. 加载中···
  119. </div>
  120. </el-image>
  121. </div>
  122. <div class="big-screen-bottom">
  123. <div
  124. class="left-bigscreen-title"
  125. :title="screen.originalName"
  126. >
  127. {{ screen.originalName }}
  128. </div>
  129. </div>
  130. </div>
  131. </div>
  132. </div>
  133. <div
  134. v-else
  135. class="empty"
  136. >
  137. 暂无数据
  138. </div>
  139. <div class="footer-pagination-wrap">
  140. <!-- <div class="footer-pagination-wrap-text">
  141. 总共 {{ totalCount }} 个项目
  142. </div> -->
  143. <div class="bs-pagination">
  144. <el-pagination
  145. class="bs-el-pagination"
  146. popper-class="bs-el-pagination"
  147. background
  148. layout="total, prev, pager, next, sizes"
  149. :page-size="size"
  150. prev-text="上一页"
  151. next-text="下一页"
  152. :total="totalCount"
  153. :page-sizes="[10, 20, 50, 100]"
  154. :current-page="current"
  155. @current-change="currentChangeHandle"
  156. @size-change="sizeChangeHandle"
  157. />
  158. </div>
  159. </div>
  160. </div>
  161. <!-- 新增或编辑弹窗 -->
  162. <EditForm
  163. ref="EditForm"
  164. @refreshData="reSearch"
  165. />
  166. </div>
  167. </template>
  168. <script>
  169. import { pageMixins } from 'data-room-ui/js/mixins/page'
  170. import EditForm from './EditForm.vue'
  171. export default {
  172. name: 'BigScreenList',
  173. mixins: [pageMixins],
  174. props: {
  175. type: {
  176. type: String,
  177. default: 'bigScreen' // bigScreen | template
  178. },
  179. catalogInfo: {
  180. type: Object,
  181. default: () => { }
  182. }
  183. },
  184. components: { EditForm },
  185. data () {
  186. return {
  187. upLoadUrl: window.BS_CONFIG?.httpConfigs?.baseURL + '/bigScreen/file/upload',
  188. searchKey: '',
  189. extend: '',
  190. options: [],
  191. list: [],
  192. fileUploadParam: {},
  193. headers: {
  194. ...window.BS_CONFIG?.httpConfigs?.headers
  195. },
  196. fileList: [],
  197. defaultImg: require('./images/defaultImg.png'),
  198. loading: false
  199. }
  200. },
  201. computed: {
  202. code () {
  203. return this.catalogInfo?.page?.code
  204. },
  205. gridComputed () {
  206. return this.list.length > 3
  207. }
  208. },
  209. watch: {
  210. code (value) {
  211. this.current = 1
  212. this.getDataList()
  213. }
  214. },
  215. mounted () {
  216. this.getOptions()
  217. this.getDataList()
  218. },
  219. methods: {
  220. uploadError () {
  221. this.$message({
  222. type: 'error',
  223. message: '上传失败'
  224. })
  225. },
  226. beforeUpload (file) {
  227. const isImage = file.type.startsWith('image/')
  228. const isVideo = file.type.startsWith('video/')
  229. const isValidFileType = isImage || isVideo
  230. if (!isValidFileType) {
  231. this.$message.error('只能上传图片或视频文件')
  232. }
  233. return isValidFileType
  234. },
  235. uploadSuccess (response, file, fileList) {
  236. if (response.code === 200) {
  237. this.$message({
  238. type: 'success',
  239. message: '上传成功'
  240. })
  241. this.getDataList()
  242. } else {
  243. this.$message({
  244. type: 'error',
  245. message: response.msg
  246. })
  247. }
  248. },
  249. getOptions () {
  250. this.$dataRoomAxios.get('/bigScreen/file/getAllFileSuffix').then((data) => {
  251. this.options = []
  252. this.options.push({ label: '全部', value: '' })
  253. // 过滤data的空数据
  254. data = data.filter((item) => item)
  255. data.forEach((item) => this.options.push({ label: item, value: item }))
  256. })
  257. },
  258. getDataList () {
  259. this.loading = true
  260. this.$dataRoomAxios.get('/bigScreen/file', {
  261. module: this.catalogInfo.page.code,
  262. current: this.current,
  263. size: this.size,
  264. extension: this.extend,
  265. searchKey: this.searchKey
  266. })
  267. .then((data) => {
  268. this.list = data.list
  269. this.totalCount = data.totalCount
  270. })
  271. .finally(() => {
  272. this.loading = false
  273. })
  274. },
  275. preview (screen) {
  276. window.open(screen.url, '_blank')
  277. },
  278. downLoad (screen) {
  279. this.$dataRoomAxios.download(`/bigScreen/file/download/${screen.id}`)
  280. },
  281. del (screen) {
  282. this.$confirm('确定删除该资源?', '提示', {
  283. confirmButtonText: '确定',
  284. cancelButtonText: '取消',
  285. type: 'warning',
  286. customClass: 'bs-el-message-box'
  287. })
  288. .then(async () => {
  289. this.$dataRoomAxios.post(`/bigScreen/file/delete/${screen.id}`)
  290. .then(() => {
  291. this.$message({
  292. type: 'success',
  293. message: '删除成功'
  294. })
  295. this.getDataList()
  296. })
  297. .catch(() => {
  298. this.$message({
  299. type: 'error',
  300. message: '删除失败!'
  301. })
  302. })
  303. })
  304. .catch()
  305. },
  306. copy (screen) {
  307. this.$message.success('复制成功')
  308. const transfer = document.createElement('input')
  309. document.body.appendChild(transfer)
  310. transfer.value = screen.url // 这里表示想要复制的内容
  311. transfer.focus()
  312. transfer.select()
  313. if (document.execCommand('copy')) {
  314. document.execCommand('copy')
  315. }
  316. transfer.blur()
  317. transfer.style.display = 'none'
  318. }
  319. }
  320. }
  321. </script>
  322. <style lang="scss" scoped>
  323. @import '../assets/style/bsTheme.scss';
  324. .big-screen-list-wrap {
  325. .el-select {
  326. display: inline-block !important;
  327. position: relative !important;
  328. width: auto !important;
  329. }
  330. position: relative;
  331. height: calc(100%);
  332. // height: calc(100% - 16px);
  333. // padding: 16px;
  334. color: #9ea9b2;
  335. // margin:0 16px;
  336. margin-left: 16px;
  337. background-color: var(--bs-background-2) !important;
  338. .internal-box {
  339. height: calc(100% - 32px);
  340. padding: 16px;
  341. }
  342. .top-search-wrap {
  343. display: flex;
  344. align-items: center;
  345. justify-content: flex-end;
  346. margin-bottom: 12px;
  347. .el-input {
  348. width: 200px;
  349. margin-right: 20px;
  350. ::v-deep.el-input__inner {
  351. background-color: var(--bs-background-1) !important;
  352. }
  353. }
  354. .el-select {
  355. margin-right: 20px;
  356. ::v-deep.el-input__inner {
  357. background-color: var(--bs-background-1) !important;
  358. }
  359. }
  360. }
  361. .list-wrap {
  362. /* display: grid; */
  363. overflow: auto;
  364. padding-right: 5px;
  365. // 间隙自适应
  366. justify-content: space-around;
  367. // max-height: calc(100vh - 304px);
  368. max-height: calc(100% - 90px);
  369. display: grid;
  370. grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  371. grid-gap: 15px;
  372. padding-bottom: 10px;
  373. // ::v-deep .el-loading-mask {
  374. // display: flex;
  375. // align-items: center;
  376. // justify-content: center;
  377. // height: calc(100vh - 260px) !important;
  378. // z-index: 999;
  379. // top: 50px;
  380. // }
  381. .big-screen-card-wrap {
  382. position: relative;
  383. height: 230px;
  384. cursor: pointer;
  385. &:hover {
  386. .screen-card__hover {
  387. height: 230px;
  388. }
  389. }
  390. .screen-card__hover {
  391. position: absolute;
  392. z-index: 999;
  393. top: 0;
  394. right: 0;
  395. left: 0;
  396. display: flex;
  397. overflow: hidden;
  398. align-items: center;
  399. justify-content: center;
  400. height: 0;
  401. transition: height 0.4s;
  402. background: #00000099;
  403. .screen-card__hover-box {
  404. position: absolute;
  405. width: 100%;
  406. height: 100%;
  407. background: #00000080;
  408. display: flex;
  409. overflow: hidden;
  410. align-items: center;
  411. justify-content: center;
  412. }
  413. .preview {
  414. display: flex;
  415. flex-direction: row;
  416. justify-content: space-evenly;
  417. width: 100%;
  418. cursor: pointer;
  419. color: var(--bs-el-color-primary);
  420. .circle {
  421. position: relative;
  422. display: flex;
  423. align-items: center;
  424. justify-content: center;
  425. width: 40px;
  426. height: 40px;
  427. border: 1px solid var(--bs-el-color-primary);
  428. border-radius: 50%;
  429. &:hover {
  430. color: #fff;
  431. background: var(--bs-el-color-primary);
  432. }
  433. span {
  434. font-size: 12px;
  435. }
  436. }
  437. }
  438. }
  439. .big-screen-card-inner {
  440. overflow: hidden;
  441. width: 100%;
  442. height: 100%;
  443. cursor: pointer;
  444. background-color: var(--bs-background-2);
  445. box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
  446. color: var(--bs-el-title);
  447. border: 1px solid var(--bs-background-1);
  448. &:hover {
  449. color: var(--bs-el-text);
  450. border: 1px solid var(--bs-el-color-primary);
  451. }
  452. .add-big-screen-card-text {
  453. color: var(--bs-el-color-primary);
  454. font-size: 24px;
  455. }
  456. .big-screen-card-img {
  457. width: 100%;
  458. height: 180px;
  459. img {
  460. width: 100%;
  461. height: 100%;
  462. object-fit: cover;
  463. }
  464. ::v-deep.image-slot {
  465. height: 100%;
  466. background-color: var(--bs-background-2);
  467. display: flex;
  468. align-items: center;
  469. justify-content: center;
  470. }
  471. ::v-deep.el-image__error {
  472. background-color: #1d1d1d;
  473. }
  474. }
  475. .big-screen-bottom {
  476. display: flex;
  477. align-items: center;
  478. flex-direction: row;
  479. justify-content: space-between;
  480. box-sizing: border-box;
  481. width: 100%;
  482. /*height: 26px;*/
  483. padding: 0 10px;
  484. height: calc(100% - 180px);
  485. color: var(--bs-el-title);
  486. background-color: var(--bs-background-2);
  487. .left-bigscreen-title {
  488. font-size: 14px;
  489. overflow: hidden;
  490. width: 100%;
  491. white-space: nowrap;
  492. text-overflow: ellipsis;
  493. }
  494. .right-bigscreen-time-title {
  495. font-size: 14px;
  496. overflow: hidden;
  497. width: 140px;
  498. white-space: nowrap;
  499. text-overflow: ellipsis;
  500. }
  501. }
  502. .big-screen-card-text {
  503. font-size: 14px;
  504. padding: 10px;
  505. text-align: center;
  506. color: #333;
  507. }
  508. }
  509. .big-screen-card-inner-add {
  510. display: flex;
  511. align-items: center;
  512. justify-content: center;
  513. }
  514. }
  515. }
  516. .el-loading-parent--relative {
  517. position: unset !important;
  518. }
  519. .footer-pagination-wrap {
  520. right: 16px;
  521. bottom: 16px;
  522. position: absolute;
  523. }
  524. }
  525. .bs-pagination {
  526. ::v-deep .el-input__inner {
  527. width: 110px !important;
  528. border: none;
  529. background: var(--bs-el-background-1);
  530. }
  531. }
  532. .empty {
  533. width: 100%;
  534. height: 70%;
  535. display: flex;
  536. justify-content: center;
  537. align-items: center;
  538. }
  539. </style>