index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  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:
  188. window.BS_CONFIG?.httpConfigs?.baseURL + '/bigScreen/file/upload',
  189. searchKey: '',
  190. extend: '',
  191. options: [],
  192. list: [],
  193. fileUploadParam: {},
  194. headers: {
  195. ...window.BS_CONFIG?.httpConfigs?.headers
  196. },
  197. fileList: [],
  198. defaultImg: require('./images/defaultImg.png'),
  199. loading: false
  200. }
  201. },
  202. computed: {
  203. code () {
  204. return this.catalogInfo?.page?.code
  205. },
  206. gridComputed () {
  207. return this.list.length > 3
  208. }
  209. },
  210. watch: {
  211. code (value) {
  212. this.current = 1
  213. this.getDataList()
  214. }
  215. },
  216. mounted () {
  217. this.getOptions()
  218. this.getDataList()
  219. },
  220. methods: {
  221. uploadError () {
  222. this.$message({
  223. type: 'error',
  224. message: '上传失败'
  225. })
  226. },
  227. beforeUpload (file) {
  228. const isImage = file.type.startsWith('image/')
  229. const isVideo = file.type.startsWith('video/')
  230. const isValidFileType = isImage || isVideo
  231. if (!isValidFileType) {
  232. this.$message.error('只能上传图片或视频文件')
  233. }
  234. return isValidFileType
  235. },
  236. uploadSuccess (response, file, fileList) {
  237. if (response.code === 200) {
  238. this.$message({
  239. type: 'success',
  240. message: '上传成功'
  241. })
  242. this.getDataList()
  243. } else {
  244. this.$message({
  245. type: 'error',
  246. message: response.msg
  247. })
  248. }
  249. },
  250. getOptions () {
  251. this.$dataRoomAxios.get('/bigScreen/file/getAllFileSuffix').then((data) => {
  252. this.options = []
  253. this.options.push({ label: '全部', value: '' })
  254. // 过滤data的空数据
  255. data = data.filter((item) => item)
  256. data.forEach((item) => this.options.push({ label: item, value: item }))
  257. })
  258. },
  259. getDataList () {
  260. this.loading = true
  261. this.$dataRoomAxios.get('/bigScreen/file', {
  262. module: this.catalogInfo.page.code,
  263. current: this.current,
  264. size: this.size,
  265. extension: this.extend,
  266. searchKey: this.searchKey
  267. })
  268. .then((data) => {
  269. this.list = data.list
  270. this.totalCount = data.totalCount
  271. })
  272. .finally(() => {
  273. this.loading = false
  274. })
  275. },
  276. preview (screen) {
  277. window.open(screen.url, '_blank')
  278. },
  279. downLoad (screen) {
  280. this.$dataRoomAxios.download(`/bigScreen/file/download/${screen.id}`)
  281. },
  282. del (screen) {
  283. this.$confirm('确定删除该资源?', '提示', {
  284. confirmButtonText: '确定',
  285. cancelButtonText: '取消',
  286. type: 'warning',
  287. customClass: 'bs-el-message-box'
  288. })
  289. .then(async () => {
  290. this.$dataRoomAxios.post(`/bigScreen/file/delete/${screen.id}`)
  291. .then(() => {
  292. this.$message({
  293. type: 'success',
  294. message: '删除成功'
  295. })
  296. this.getDataList()
  297. })
  298. .catch(() => {
  299. this.$message({
  300. type: 'error',
  301. message: '删除失败!'
  302. })
  303. })
  304. })
  305. .catch()
  306. },
  307. copy (screen) {
  308. this.$message.success('复制成功')
  309. const transfer = document.createElement('input')
  310. document.body.appendChild(transfer)
  311. transfer.value = screen.url // 这里表示想要复制的内容
  312. transfer.focus()
  313. transfer.select()
  314. if (document.execCommand('copy')) {
  315. document.execCommand('copy')
  316. }
  317. transfer.blur()
  318. transfer.style.display = 'none'
  319. }
  320. }
  321. }
  322. </script>
  323. <style lang="scss" scoped>
  324. @import '../assets/style/bsTheme.scss';
  325. .big-screen-list-wrap {
  326. .el-select {
  327. display: inline-block !important;
  328. position: relative !important;
  329. width: auto !important;
  330. }
  331. position: relative;
  332. height: calc(100%);
  333. // height: calc(100% - 16px);
  334. // padding: 16px;
  335. color: #9ea9b2;
  336. // margin:0 16px;
  337. margin-left: 16px;
  338. background-color: var(--bs-background-2) !important;
  339. .internal-box {
  340. height: calc(100% - 32px);
  341. padding: 16px;
  342. }
  343. .top-search-wrap {
  344. display: flex;
  345. align-items: center;
  346. justify-content: flex-end;
  347. margin-bottom: 12px;
  348. .el-input {
  349. width: 200px;
  350. margin-right: 20px;
  351. ::v-deep.el-input__inner {
  352. background-color: var(--bs-background-1) !important;
  353. }
  354. }
  355. .el-select {
  356. margin-right: 20px;
  357. ::v-deep.el-input__inner {
  358. background-color: var(--bs-background-1) !important;
  359. }
  360. }
  361. }
  362. .list-wrap {
  363. /* display: grid; */
  364. overflow: auto;
  365. padding-right: 5px;
  366. // 间隙自适应
  367. justify-content: space-around;
  368. // max-height: calc(100vh - 304px);
  369. max-height: calc(100% - 90px);
  370. display: grid;
  371. grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  372. grid-gap: 15px;
  373. padding-bottom: 10px;
  374. // ::v-deep .el-loading-mask {
  375. // display: flex;
  376. // align-items: center;
  377. // justify-content: center;
  378. // height: calc(100vh - 260px) !important;
  379. // z-index: 999;
  380. // top: 50px;
  381. // }
  382. .big-screen-card-wrap {
  383. position: relative;
  384. height: 230px;
  385. cursor: pointer;
  386. &:hover {
  387. .screen-card__hover {
  388. height: 230px;
  389. }
  390. }
  391. .screen-card__hover {
  392. position: absolute;
  393. z-index: 999;
  394. top: 0;
  395. right: 0;
  396. left: 0;
  397. display: flex;
  398. overflow: hidden;
  399. align-items: center;
  400. justify-content: center;
  401. height: 0;
  402. transition: height 0.4s;
  403. background: #00000099;
  404. .screen-card__hover-box {
  405. position: absolute;
  406. width: 100%;
  407. height: 100%;
  408. background: #00000080;
  409. display: flex;
  410. overflow: hidden;
  411. align-items: center;
  412. justify-content: center;
  413. }
  414. .preview {
  415. display: flex;
  416. flex-direction: row;
  417. justify-content: space-evenly;
  418. width: 100%;
  419. cursor: pointer;
  420. color: var(--bs-el-color-primary);
  421. .circle {
  422. position: relative;
  423. display: flex;
  424. align-items: center;
  425. justify-content: center;
  426. width: 40px;
  427. height: 40px;
  428. border: 1px solid var(--bs-el-color-primary);
  429. border-radius: 50%;
  430. &:hover {
  431. color: #fff;
  432. background: var(--bs-el-color-primary);
  433. }
  434. span {
  435. font-size: 12px;
  436. }
  437. }
  438. }
  439. }
  440. .big-screen-card-inner {
  441. overflow: hidden;
  442. width: 100%;
  443. height: 100%;
  444. cursor: pointer;
  445. background-color: var(--bs-background-2);
  446. box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
  447. color: var(--bs-el-title);
  448. border: 1px solid var(--bs-background-1);
  449. &:hover {
  450. color: var(--bs-el-text);
  451. border: 1px solid var(--bs-el-color-primary);
  452. }
  453. .add-big-screen-card-text {
  454. color: var(--bs-el-color-primary);
  455. font-size: 24px;
  456. }
  457. .big-screen-card-img {
  458. width: 100%;
  459. height: 180px;
  460. img {
  461. width: 100%;
  462. height: 100%;
  463. object-fit: cover;
  464. }
  465. ::v-deep.image-slot {
  466. height: 100%;
  467. background-color: var(--bs-background-2);
  468. display: flex;
  469. align-items: center;
  470. justify-content: center;
  471. }
  472. ::v-deep.el-image__error {
  473. background-color: #1d1d1d;
  474. }
  475. }
  476. .big-screen-bottom {
  477. display: flex;
  478. align-items: center;
  479. flex-direction: row;
  480. justify-content: space-between;
  481. box-sizing: border-box;
  482. width: 100%;
  483. /*height: 26px;*/
  484. padding: 0 10px;
  485. height: calc(100% - 180px);
  486. color: var(--bs-el-title);
  487. background-color: var(--bs-background-2);
  488. .left-bigscreen-title {
  489. font-size: 14px;
  490. overflow: hidden;
  491. width: 100%;
  492. white-space: nowrap;
  493. text-overflow: ellipsis;
  494. }
  495. .right-bigscreen-time-title {
  496. font-size: 14px;
  497. overflow: hidden;
  498. width: 140px;
  499. white-space: nowrap;
  500. text-overflow: ellipsis;
  501. }
  502. }
  503. .big-screen-card-text {
  504. font-size: 14px;
  505. padding: 10px;
  506. text-align: center;
  507. color: #333;
  508. }
  509. }
  510. .big-screen-card-inner-add {
  511. display: flex;
  512. align-items: center;
  513. justify-content: center;
  514. }
  515. }
  516. }
  517. .el-loading-parent--relative {
  518. position: unset !important;
  519. }
  520. .footer-pagination-wrap {
  521. // position: absolute;
  522. // bottom: 10px;
  523. // display: flex;
  524. // align-items: center;
  525. // justify-content: flex-end;
  526. // width: 100%;
  527. position: absolute;
  528. bottom: 16px;
  529. right: 12px;
  530. // padding: 0 16px;
  531. }
  532. }
  533. .bs-pagination {
  534. ::v-deep .el-input__inner {
  535. width: 110px !important;
  536. border: none;
  537. background: var(--bs-el-background-1);
  538. }
  539. }
  540. .empty {
  541. width: 100%;
  542. height: 70%;
  543. display: flex;
  544. justify-content: center;
  545. align-items: center;
  546. }
  547. </style>