index.vue 14 KB

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