index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  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. console.log(isValidFileType)
  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. 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. 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. 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. 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. position: relative;
  327. height: 100%;
  328. padding: 16px;
  329. color: #9ea9b2;
  330. margin:0 16px;
  331. background-color: var(--bs-background-2) !important;
  332. .top-search-wrap {
  333. display: flex;
  334. align-items: center;
  335. justify-content: flex-end;
  336. margin-bottom: 12px;
  337. .el-input {
  338. width: 200px;
  339. margin-right: 20px;
  340. /deep/.el-input__inner {
  341. background-color: var(--bs-background-1) !important;
  342. }
  343. }
  344. .el-select {
  345. margin-right: 20px;
  346. /deep/.el-input__inner {
  347. background-color: var(--bs-background-1) !important;
  348. }
  349. }
  350. }
  351. .list-wrap {
  352. /* display: grid; */
  353. overflow: auto;
  354. // 间隙自适应
  355. justify-content: space-around;
  356. max-height: calc(100vh - 304px);
  357. display: grid;
  358. grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  359. grid-gap: 15px;
  360. // /deep/ .el-loading-mask {
  361. // display: flex;
  362. // align-items: center;
  363. // justify-content: center;
  364. // height: calc(100vh - 260px) !important;
  365. // z-index: 999;
  366. // top: 50px;
  367. // }
  368. .big-screen-card-wrap {
  369. position: relative;
  370. height: 230px;
  371. cursor: pointer;
  372. &:hover {
  373. .screen-card__hover {
  374. height: 230px;
  375. }
  376. }
  377. .screen-card__hover {
  378. position: absolute;
  379. z-index: 999;
  380. top: 0;
  381. right: 0;
  382. left: 0;
  383. display: flex;
  384. overflow: hidden;
  385. align-items: center;
  386. justify-content: center;
  387. height: 0;
  388. transition: height 0.4s;
  389. background: #00000099;
  390. .screen-card__hover-box {
  391. position: absolute;
  392. width: 100%;
  393. height: 100%;
  394. background: #00000080;
  395. display: flex;
  396. overflow: hidden;
  397. align-items: center;
  398. justify-content: center;
  399. }
  400. .preview {
  401. display: flex;
  402. flex-direction: row;
  403. justify-content: space-evenly;
  404. width: 100%;
  405. cursor: pointer;
  406. color: var(--bs-el-color-primary);
  407. .circle {
  408. position: relative;
  409. display: flex;
  410. align-items: center;
  411. justify-content: center;
  412. width: 40px;
  413. height: 40px;
  414. border: 1px solid var(--bs-el-color-primary);
  415. border-radius: 50%;
  416. &:hover {
  417. color: #fff;
  418. background: var(--bs-el-color-primary);
  419. }
  420. span {
  421. font-size: 12px;
  422. }
  423. }
  424. }
  425. }
  426. .big-screen-card-inner {
  427. overflow: hidden;
  428. width: 100%;
  429. height: 100%;
  430. cursor: pointer;
  431. background-color: var(--bs-background-2);
  432. box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
  433. color: var(--bs-el-title);
  434. border: 1px solid var(--bs-background-1);
  435. &:hover {
  436. color: var(--bs-el-text);
  437. border: 1px solid var(--bs-el-color-primary);
  438. }
  439. .add-big-screen-card-text {
  440. color: var(--bs-el-color-primary);
  441. font-size: 24px;
  442. }
  443. .big-screen-card-img {
  444. width: 100%;
  445. height: 180px;
  446. img {
  447. width: 100%;
  448. height: 100%;
  449. object-fit: cover;
  450. }
  451. /deep/.image-slot {
  452. height: 100%;
  453. background-color: var(--bs-background-2);
  454. display: flex;
  455. align-items: center;
  456. justify-content: center;
  457. }
  458. /deep/.el-image__error {
  459. background-color: #1d1d1d;
  460. }
  461. }
  462. .big-screen-bottom {
  463. display: flex;
  464. align-items: center;
  465. flex-direction: row;
  466. justify-content: space-between;
  467. box-sizing: border-box;
  468. width: 100%;
  469. /*height: 26px;*/
  470. padding: 0 10px;
  471. height: calc(100% - 180px);
  472. color: var(--bs-el-title);
  473. background-color: var(--bs-background-2);
  474. .left-bigscreen-title {
  475. font-size: 14px;
  476. overflow: hidden;
  477. width: 100%;
  478. white-space: nowrap;
  479. text-overflow: ellipsis;
  480. }
  481. .right-bigscreen-time-title {
  482. font-size: 14px;
  483. overflow: hidden;
  484. width: 140px;
  485. white-space: nowrap;
  486. text-overflow: ellipsis;
  487. }
  488. }
  489. .big-screen-card-text {
  490. font-size: 14px;
  491. padding: 10px;
  492. text-align: center;
  493. color: #333;
  494. }
  495. }
  496. .big-screen-card-inner-add {
  497. display: flex;
  498. align-items: center;
  499. justify-content: center;
  500. }
  501. }
  502. }
  503. .el-loading-parent--relative {
  504. position: unset !important;
  505. }
  506. .footer-pagination-wrap {
  507. // position: absolute;
  508. // bottom: 10px;
  509. // display: flex;
  510. // align-items: center;
  511. // justify-content: flex-end;
  512. // width: 100%;
  513. position: absolute;
  514. bottom: 16px;
  515. right: 12px;
  516. // padding: 0 16px;
  517. }
  518. }
  519. .bs-pagination {
  520. ::v-deep .el-input__inner {
  521. width: 110px !important;
  522. border: none;
  523. background: var(--bs-el-background-1);
  524. }
  525. }
  526. .empty {
  527. width: 100%;
  528. height: 70%;
  529. display: flex;
  530. justify-content: center;
  531. align-items: center;
  532. }
  533. </style>