index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  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 bs-el-input-search"
  8. :placeholder="type === 'bigScreenCatalog' ? '请输入大屏名称' : '请输入组件名称'"
  9. prefix-icon="el-icon-search"
  10. clearable
  11. @clear="reSearch"
  12. @keyup.enter.native="reSearch"
  13. />
  14. <el-button
  15. type="primary"
  16. @click="reSearch"
  17. >
  18. 搜索
  19. </el-button>
  20. </div>
  21. <div
  22. v-loading="loading"
  23. class="list-wrap bs-scrollbar"
  24. element-loading-text="加载中"
  25. :style="{
  26. display: gridComputed ? 'grid' : 'flex',
  27. justifyContent: gridComputed ? 'space-around' : 'flex-start'
  28. }"
  29. >
  30. <!-- 第一个是新增大屏卡片 -->
  31. <div
  32. class="big-screen-card-wrap"
  33. :style="{
  34. width: gridComputed ? 'auto' : '290px'
  35. }"
  36. @click="add"
  37. >
  38. <div class="big-screen-card-inner big-screen-card-inner-add">
  39. <div class="add-big-screen-card">
  40. <div class="add-big-screen-card-inner">
  41. <div class="add-big-screen-card-text">
  42. 新增{{ type === 'bigScreenCatalog' ? '大屏' : '组件' }}
  43. </div>
  44. </div>
  45. </div>
  46. </div>
  47. </div>
  48. <!-- 后面遍历 list -->
  49. <div
  50. v-for="screen in list"
  51. :key="screen.id"
  52. class="big-screen-card-wrap"
  53. :style="{
  54. width: gridComputed ? 'auto' : '290px'
  55. }"
  56. >
  57. <div class="big-screen-card-inner">
  58. <div class="screen-card__hover">
  59. <div class="screen-card__hover-box">
  60. <div class="preview">
  61. <div
  62. class="screen-card__oper-label circle"
  63. @click="preview(screen)"
  64. >
  65. <span>预览</span>
  66. </div>
  67. <div
  68. class="circle"
  69. @click="design(screen)"
  70. >
  71. <span>设计</span>
  72. </div>
  73. <div
  74. class="circle"
  75. @click="edit(screen)"
  76. >
  77. <span>编辑</span>
  78. </div>
  79. <div
  80. class="circle"
  81. @click="copy(screen)"
  82. >
  83. <span>复制</span>
  84. </div>
  85. <div
  86. class="circle"
  87. @click="del(screen)"
  88. >
  89. <span>删除</span>
  90. </div>
  91. </div>
  92. </div>
  93. </div>
  94. <div class="big-screen-card-img">
  95. <el-image
  96. :src="getCoverPicture(screen.coverPicture)"
  97. fit="fill"
  98. style="width: 100%; height: 100%"
  99. >
  100. <div
  101. slot="placeholder"
  102. class="image-slot"
  103. >
  104. 加载中···
  105. </div>
  106. <div
  107. slot="error"
  108. class="image-slot"
  109. style="font-size: 20px"
  110. >
  111. <div class="error-img-text">
  112. {{ screen.name }}
  113. </div>
  114. </div>
  115. </el-image>
  116. </div>
  117. <div class="big-screen-bottom">
  118. <div
  119. class="left-bigscreen-title"
  120. :title="screen.name"
  121. >
  122. {{ screen.name }}
  123. </div>
  124. </div>
  125. </div>
  126. </div>
  127. </div>
  128. <div class="footer-pagination-wrap">
  129. <div class="bs-pagination">
  130. <el-pagination
  131. class="bs-el-pagination"
  132. popper-class="bs-el-pagination"
  133. background
  134. layout="total, prev, pager, next, sizes"
  135. :page-size="size"
  136. prev-text="上一页"
  137. next-text="下一页"
  138. :total="totalCount"
  139. :page-sizes="[10, 20, 50, 100]"
  140. :current-page="current"
  141. @current-change="currentChangeHandle"
  142. @size-change="sizeChangeHandle"
  143. />
  144. </div>
  145. </div>
  146. </div>
  147. <!-- 新增或编辑弹窗 -->
  148. <EditForm
  149. ref="EditForm"
  150. :type="pageType"
  151. @refreshData="reSearch"
  152. />
  153. </div>
  154. </template>
  155. <script>
  156. import { pageMixins } from 'data-room-ui/js/mixins/page'
  157. import { getFileUrl } from 'data-room-ui/js/utils/file'
  158. import EditForm from './EditForm.vue'
  159. export default {
  160. name: 'BigScreenList',
  161. mixins: [pageMixins],
  162. props: {
  163. type: {
  164. type: String,
  165. default: 'bigScreenCatalog'
  166. },
  167. catalogInfo: {
  168. type: Object,
  169. default: () => { }
  170. }
  171. },
  172. components: { EditForm },
  173. data () {
  174. return {
  175. templateLoading: false,
  176. searchKey: '',
  177. list: [],
  178. loading: false
  179. }
  180. },
  181. computed: {
  182. hint () {
  183. return this.pageType === 'bigScreen' ? '大屏' : '组件'
  184. },
  185. code () {
  186. return this.catalogInfo?.page?.code
  187. },
  188. gridComputed () {
  189. return this.list.length > 2
  190. },
  191. pageType () {
  192. return this.type === 'bigScreenCatalog' ? 'bigScreen' : 'component'
  193. }
  194. },
  195. watch: {
  196. code (value) {
  197. this.current = 1
  198. this.getDataList()
  199. }
  200. },
  201. mounted () {
  202. this.getDataList()
  203. },
  204. methods: {
  205. getDataList () {
  206. this.loading = true
  207. this.$dataRoomAxios.get('/bigScreen/design/page', {
  208. parentCode: this.code || null,
  209. current: this.current,
  210. size: this.size,
  211. searchKey: this.searchKey,
  212. type: this.pageType
  213. })
  214. .then((data) => {
  215. this.list = data.list
  216. this.totalCount = data.totalCount
  217. })
  218. .finally(() => {
  219. this.loading = false
  220. })
  221. },
  222. preview (screen) {
  223. const { href } = this.$router.resolve({
  224. path: window.BS_CONFIG?.routers?.previewUrl || '/big-screen/preview', // 这里写的是要跳转的路由地址
  225. query: {
  226. code: screen.code
  227. }
  228. })
  229. window.open(href, '_blank')
  230. },
  231. design (screen) {
  232. const path = window.BS_CONFIG?.routers?.designUrl || '/big-screen/design'
  233. const { href } = this.$router.resolve({
  234. path,
  235. query: {
  236. code: screen.code
  237. }
  238. })
  239. window.open(href, '_self')
  240. },
  241. add () {
  242. const page = {
  243. code: '',
  244. type: 'bigScreen'
  245. }
  246. this.$refs.EditForm.init(page, this.catalogInfo.page)
  247. },
  248. edit (screen) {
  249. this.$refs.EditForm.init(screen, this.catalogInfo.page)
  250. },
  251. del (screen) {
  252. this.$confirm(`确定删除该${this.hint}?`, '提示', {
  253. confirmButtonText: '确定',
  254. cancelButtonText: '取消',
  255. type: 'warning',
  256. customClass: 'bs-el-message-box'
  257. })
  258. .then(async () => {
  259. this.$dataRoomAxios.post(`/bigScreen/design/delete/${screen.code}`)
  260. .then(() => {
  261. this.$message({
  262. type: 'success',
  263. message: '删除成功'
  264. })
  265. this.getDataList()
  266. })
  267. .catch(() => {
  268. this.$message({
  269. type: 'error',
  270. message: '删除失败!'
  271. })
  272. })
  273. })
  274. .catch()
  275. },
  276. copy (screen) {
  277. this.$confirm(`确定复制该${this.hint}?`, '提示', {
  278. confirmButtonText: '确定',
  279. cancelButtonText: '取消',
  280. type: 'warning',
  281. customClass: 'bs-el-message-box'
  282. })
  283. .then(async () => {
  284. this.$dataRoomAxios.post(`/bigScreen/design/copy/${screen.code}`)
  285. .then(() => {
  286. this.$message({
  287. type: 'success',
  288. message: '复制成功'
  289. })
  290. this.getDataList()
  291. })
  292. .catch(() => {
  293. this.$message({
  294. type: 'error',
  295. message: '复制失败!'
  296. })
  297. })
  298. })
  299. .catch((e) => {
  300. console.error(e)
  301. })
  302. },
  303. /**
  304. * 获取封面图片,如果是相对路径则拼接上文件访问前缀地址
  305. * @param url
  306. * @returns {*}
  307. */
  308. getCoverPicture (url) {
  309. return getFileUrl(url)
  310. },
  311. }
  312. }
  313. </script>
  314. <style lang="scss" scoped>
  315. @import '../assets/style/bsTheme.scss';
  316. .big-screen-list-wrap {
  317. .el-select {
  318. display: inline-block !important;
  319. position: relative !important;
  320. width: auto !important;
  321. }
  322. position: relative;
  323. height: 100%;
  324. // margin:0 16px;
  325. margin-left: 16px;
  326. // padding: 16px;
  327. color: #9ea9b2;
  328. background-color: var(--bs-background-2) !important;
  329. .internal-box {
  330. height: calc(100% - 32px);
  331. padding: 16px;
  332. }
  333. .top-search-wrap {
  334. display: flex;
  335. align-items: center;
  336. justify-content: flex-end;
  337. margin-bottom: 16px;
  338. .el-input {
  339. width: 200px;
  340. margin-right: 20px;
  341. ::v-deep.el-input__inner {
  342. background-color: var(--bs-background-1) !important;
  343. }
  344. }
  345. }
  346. .list-wrap {
  347. /* display: grid; */
  348. overflow: auto;
  349. padding-right: 5px;
  350. // 间隙自适应
  351. justify-content: space-around;
  352. // max-height: calc(100vh - 304px);
  353. max-height: calc(100% - 90px);
  354. display: grid;
  355. grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  356. grid-gap: 15px;
  357. padding-bottom: 10px;
  358. // ::v-deep .el-loading-mask {
  359. // display: flex;
  360. // align-items: center;
  361. // justify-content: center;
  362. // height: calc(100vh - 260px) !important;
  363. // z-index: 999;
  364. // top: 50px;
  365. // }
  366. .big-screen-card-wrap {
  367. position: relative;
  368. height: 180px;
  369. cursor: pointer;
  370. &:hover {
  371. .screen-card__hover {
  372. height: 180px;
  373. }
  374. }
  375. .screen-card__hover {
  376. position: absolute;
  377. z-index: 999;
  378. top: 0;
  379. right: 0;
  380. left: 0;
  381. display: flex;
  382. overflow: hidden;
  383. align-items: center;
  384. justify-content: center;
  385. height: 0;
  386. transition: height 0.4s;
  387. background: #00000099;
  388. .screen-card__hover-box {
  389. position: absolute;
  390. width: 100%;
  391. height: 100%;
  392. background: #00000080;
  393. display: flex;
  394. overflow: hidden;
  395. align-items: center;
  396. justify-content: center;
  397. }
  398. .preview {
  399. display: flex;
  400. flex-direction: row;
  401. justify-content: space-evenly;
  402. width: 100%;
  403. cursor: pointer;
  404. color: var(--bs-el-color-primary);
  405. .circle {
  406. position: relative;
  407. display: flex;
  408. align-items: center;
  409. justify-content: center;
  410. width: 40px;
  411. height: 40px;
  412. border: 1px solid var(--bs-el-color-primary);
  413. border-radius: 50%;
  414. &:hover {
  415. color: #fff;
  416. background: var(--bs-el-color-primary);
  417. }
  418. span {
  419. font-size: 12px;
  420. }
  421. }
  422. }
  423. }
  424. .big-screen-card-inner {
  425. overflow: hidden;
  426. width: 100%;
  427. height: 100%;
  428. cursor: pointer;
  429. background-color: var(--bs-background-2);
  430. box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
  431. color: var(--bs-el-title);
  432. border: 1px solid var(--bs-background-1);
  433. &:hover {
  434. color: var(--bs-el-text);
  435. border: 1px solid var(--bs-el-color-primary);
  436. }
  437. .add-big-screen-card-text {
  438. color: var(--bs-el-color-primary);
  439. font-size: 24px;
  440. }
  441. .big-screen-card-img {
  442. width: 100%;
  443. height: 150px;
  444. img {
  445. width: 100%;
  446. height: 100%;
  447. object-fit: cover;
  448. }
  449. ::v-deep.image-slot {
  450. height: 100%;
  451. background-color: var(--bs-background-2);
  452. display: flex;
  453. align-items: center;
  454. justify-content: center;
  455. }
  456. ::v-deep.el-image__error {
  457. background-color: #1d1d1d;
  458. }
  459. }
  460. .big-screen-bottom {
  461. display: flex;
  462. align-items: center;
  463. flex-direction: row;
  464. justify-content: space-between;
  465. box-sizing: border-box;
  466. width: 100%;
  467. /*height: 26px;*/
  468. padding: 0 10px;
  469. height: calc(100% - 150px);
  470. color: var(--bs-el-title);
  471. background-color: var(--bs-background-2);
  472. .left-bigscreen-title {
  473. font-size: 14px;
  474. overflow: hidden;
  475. width: 120px;
  476. white-space: nowrap;
  477. text-overflow: ellipsis;
  478. }
  479. .right-bigscreen-time-title {
  480. font-size: 14px;
  481. overflow: hidden;
  482. width: 140px;
  483. white-space: nowrap;
  484. text-overflow: ellipsis;
  485. }
  486. }
  487. .big-screen-card-text {
  488. font-size: 14px;
  489. padding: 10px;
  490. text-align: center;
  491. color: #333;
  492. }
  493. }
  494. .big-screen-card-inner-add {
  495. display: flex;
  496. align-items: center;
  497. justify-content: center;
  498. }
  499. }
  500. .error-img-text {
  501. overflow: hidden;
  502. padding: 0 10px;
  503. white-space: nowrap;
  504. text-overflow: ellipsis;
  505. -o-text-overflow: ellipsis;
  506. }
  507. }
  508. .el-loading-parent--relative {
  509. position: unset !important;
  510. }
  511. .footer-pagination-wrap {
  512. width: 100%;
  513. position: absolute;
  514. bottom: 16px;
  515. right: 16px;
  516. }
  517. }
  518. .bs-pagination {
  519. ::v-deep .el-input__inner {
  520. width: 110px !important;
  521. border: none;
  522. background: var(--bs-el-background-1);
  523. }
  524. }
  525. </style>