index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. <template>
  2. <div class="big-screen-list-wrap">
  3. <div class="top-search-wrap">
  4. <el-input
  5. v-model="searchKey"
  6. class="bs-el-input"
  7. placeholder="请输入图片名称"
  8. prefix-icon="el-icon-search"
  9. clearable
  10. @clear="reSearch"
  11. @keyup.enter.native="reSearch"
  12. />
  13. <el-select
  14. v-model="extend"
  15. class="bs-el-select"
  16. popper-class="bs-el-select"
  17. placeholder="请选择图片格式"
  18. clearable
  19. @change="reSearch"
  20. >
  21. <el-option
  22. v-for="item in options"
  23. :key="item.value"
  24. :label="item.label"
  25. :value="item.value"
  26. />
  27. </el-select>
  28. <el-button
  29. size="small"
  30. style="margin-right: 20px"
  31. type="primary"
  32. @click="reSearch"
  33. >
  34. 搜索
  35. </el-button>
  36. <el-upload
  37. accept="image/*, video/*"
  38. class="upload-demo"
  39. :action="upLoadUrl"
  40. :headers="headers"
  41. :data="{ module: code }"
  42. :before-upload="beforeUpload"
  43. :on-success="uploadSuccess"
  44. :on-error="uploadError"
  45. multiple
  46. :file-list="fileList"
  47. :show-file-list="false"
  48. >
  49. <el-button
  50. size="small"
  51. type="primary"
  52. >
  53. 上传资源
  54. </el-button>
  55. </el-upload>
  56. </div>
  57. <div
  58. v-if="list.length !== 0"
  59. v-loading="loading"
  60. class="list-wrap bs-scrollbar"
  61. element-loading-text="加载中"
  62. :style="{
  63. display: gridComputed ? 'grid' : 'flex',
  64. justifyContent: gridComputed ? 'space-around' : 'flex-start'
  65. }"
  66. >
  67. <!-- <div v-if="list.length !== 0"> -->
  68. <div
  69. v-for="screen in list"
  70. :key="screen.id"
  71. class="big-screen-card-wrap"
  72. :style="{
  73. width: gridComputed ? 'auto' : '290px'
  74. }"
  75. >
  76. <div class="big-screen-card-inner">
  77. <div class="screen-card__hover">
  78. <div class="screen-card__hover-box">
  79. <div class="preview">
  80. <div
  81. class="screen-card__oper-label circle"
  82. @click="preview(screen)"
  83. >
  84. <span>预览</span>
  85. </div>
  86. <div
  87. class="circle"
  88. @click="downLoad(screen)"
  89. >
  90. <span>下载</span>
  91. </div>
  92. <div
  93. class="circle"
  94. @click="del(screen)"
  95. >
  96. <span>删除</span>
  97. </div>
  98. <div
  99. class="circle"
  100. @click="copy(screen)"
  101. >
  102. <span>链接</span>
  103. </div>
  104. </div>
  105. </div>
  106. </div>
  107. <div class="big-screen-card-img">
  108. <el-image
  109. :src="screen.url"
  110. fit="contain"
  111. style="width: 100%; height: 100%"
  112. >
  113. <div
  114. slot="placeholder"
  115. class="image-slot"
  116. >
  117. 加载中···
  118. </div>
  119. </el-image>
  120. </div>
  121. <div class="big-screen-bottom">
  122. <div
  123. class="left-bigscreen-title"
  124. :title="screen.originalName"
  125. >
  126. {{ screen.originalName }}
  127. </div>
  128. </div>
  129. </div>
  130. </div>
  131. </div>
  132. <div
  133. v-else
  134. class="empty"
  135. >
  136. 暂无数据
  137. </div>
  138. <div class="footer-pagination-wrap">
  139. <!-- <div class="footer-pagination-wrap-text">
  140. 总共 {{ totalCount }} 个项目
  141. </div> -->
  142. <div class="bs-pagination">
  143. <el-pagination
  144. class="bs-el-pagination"
  145. popper-class="bs-el-pagination"
  146. background
  147. layout="total, prev, pager, next, sizes"
  148. :page-size="size"
  149. prev-text="上一页"
  150. next-text="下一页"
  151. :total="totalCount"
  152. :page-sizes="[10, 20, 50, 100]"
  153. :current-page="current"
  154. @current-change="currentChangeHandle"
  155. @size-change="sizeChangeHandle"
  156. />
  157. </div>
  158. </div>
  159. <!-- 新增或编辑弹窗 -->
  160. <EditForm
  161. ref="EditForm"
  162. @refreshData="reSearch"
  163. />
  164. </div>
  165. </template>
  166. <script>
  167. import { get, post, download } from 'packages/js/utils/http'
  168. import { pageMixins } from 'packages/js/mixins/page'
  169. import EditForm from './EditForm.vue'
  170. export default {
  171. name: 'BigScreenList',
  172. mixins: [pageMixins],
  173. props: {
  174. type: {
  175. type: String,
  176. default: 'bigScreen' // bigScreen | template
  177. },
  178. catalogInfo: {
  179. type: Object,
  180. default: () => {}
  181. }
  182. },
  183. components: { EditForm },
  184. data () {
  185. return {
  186. upLoadUrl:
  187. 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. 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. 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. 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. 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. position: relative;
  326. height: 100%;
  327. // height: calc(100% - 16px);
  328. padding: 16px;
  329. color: #9ea9b2;
  330. // margin:0 16px;
  331. margin-left: 16px;
  332. background-color: var(--bs-background-2) !important;
  333. .top-search-wrap {
  334. display: flex;
  335. align-items: center;
  336. justify-content: flex-end;
  337. margin-bottom: 12px;
  338. .el-input {
  339. width: 200px;
  340. margin-right: 20px;
  341. /deep/.el-input__inner {
  342. background-color: var(--bs-background-1) !important;
  343. }
  344. }
  345. .el-select {
  346. margin-right: 20px;
  347. /deep/.el-input__inner {
  348. background-color: var(--bs-background-1) !important;
  349. }
  350. }
  351. }
  352. .list-wrap {
  353. /* display: grid; */
  354. overflow: auto;
  355. // 间隙自适应
  356. justify-content: space-around;
  357. // max-height: calc(100vh - 304px);
  358. height: calc(100% - 96px);
  359. display: grid;
  360. grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  361. grid-gap: 15px;
  362. // /deep/ .el-loading-mask {
  363. // display: flex;
  364. // align-items: center;
  365. // justify-content: center;
  366. // height: calc(100vh - 260px) !important;
  367. // z-index: 999;
  368. // top: 50px;
  369. // }
  370. .big-screen-card-wrap {
  371. position: relative;
  372. height: 230px;
  373. cursor: pointer;
  374. &:hover {
  375. .screen-card__hover {
  376. height: 230px;
  377. }
  378. }
  379. .screen-card__hover {
  380. position: absolute;
  381. z-index: 999;
  382. top: 0;
  383. right: 0;
  384. left: 0;
  385. display: flex;
  386. overflow: hidden;
  387. align-items: center;
  388. justify-content: center;
  389. height: 0;
  390. transition: height 0.4s;
  391. background: #00000099;
  392. .screen-card__hover-box {
  393. position: absolute;
  394. width: 100%;
  395. height: 100%;
  396. background: #00000080;
  397. display: flex;
  398. overflow: hidden;
  399. align-items: center;
  400. justify-content: center;
  401. }
  402. .preview {
  403. display: flex;
  404. flex-direction: row;
  405. justify-content: space-evenly;
  406. width: 100%;
  407. cursor: pointer;
  408. color: var(--bs-el-color-primary);
  409. .circle {
  410. position: relative;
  411. display: flex;
  412. align-items: center;
  413. justify-content: center;
  414. width: 40px;
  415. height: 40px;
  416. border: 1px solid var(--bs-el-color-primary);
  417. border-radius: 50%;
  418. &:hover {
  419. color: #fff;
  420. background: var(--bs-el-color-primary);
  421. }
  422. span {
  423. font-size: 12px;
  424. }
  425. }
  426. }
  427. }
  428. .big-screen-card-inner {
  429. overflow: hidden;
  430. width: 100%;
  431. height: 100%;
  432. cursor: pointer;
  433. background-color: var(--bs-background-2);
  434. box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
  435. color: var(--bs-el-title);
  436. border: 1px solid var(--bs-background-1);
  437. &:hover {
  438. color: var(--bs-el-text);
  439. border: 1px solid var(--bs-el-color-primary);
  440. }
  441. .add-big-screen-card-text {
  442. color: var(--bs-el-color-primary);
  443. font-size: 24px;
  444. }
  445. .big-screen-card-img {
  446. width: 100%;
  447. height: 180px;
  448. img {
  449. width: 100%;
  450. height: 100%;
  451. object-fit: cover;
  452. }
  453. /deep/.image-slot {
  454. height: 100%;
  455. background-color: var(--bs-background-2);
  456. display: flex;
  457. align-items: center;
  458. justify-content: center;
  459. }
  460. /deep/.el-image__error {
  461. background-color: #1d1d1d;
  462. }
  463. }
  464. .big-screen-bottom {
  465. display: flex;
  466. align-items: center;
  467. flex-direction: row;
  468. justify-content: space-between;
  469. box-sizing: border-box;
  470. width: 100%;
  471. /*height: 26px;*/
  472. padding: 0 10px;
  473. height: calc(100% - 180px);
  474. color: var(--bs-el-title);
  475. background-color: var(--bs-background-2);
  476. .left-bigscreen-title {
  477. font-size: 14px;
  478. overflow: hidden;
  479. width: 100%;
  480. white-space: nowrap;
  481. text-overflow: ellipsis;
  482. }
  483. .right-bigscreen-time-title {
  484. font-size: 14px;
  485. overflow: hidden;
  486. width: 140px;
  487. white-space: nowrap;
  488. text-overflow: ellipsis;
  489. }
  490. }
  491. .big-screen-card-text {
  492. font-size: 14px;
  493. padding: 10px;
  494. text-align: center;
  495. color: #333;
  496. }
  497. }
  498. .big-screen-card-inner-add {
  499. display: flex;
  500. align-items: center;
  501. justify-content: center;
  502. }
  503. }
  504. }
  505. .el-loading-parent--relative {
  506. position: unset !important;
  507. }
  508. .footer-pagination-wrap {
  509. // position: absolute;
  510. // bottom: 10px;
  511. // display: flex;
  512. // align-items: center;
  513. // justify-content: flex-end;
  514. // width: 100%;
  515. position: absolute;
  516. bottom: 16px;
  517. right: 12px;
  518. // padding: 0 16px;
  519. }
  520. }
  521. .bs-pagination {
  522. ::v-deep .el-input__inner {
  523. width: 110px !important;
  524. border: none;
  525. background: var(--bs-el-background-1);
  526. }
  527. }
  528. .empty {
  529. width: 100%;
  530. height: 70%;
  531. display: flex;
  532. justify-content: center;
  533. align-items: center;
  534. }
  535. </style>