index.vue 16 KB

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