index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  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. this.$router.push({
  241. path,
  242. query: {
  243. code: screen.code
  244. }
  245. })
  246. },
  247. add () {
  248. const page = {
  249. code: '',
  250. type: 'bigScreen'
  251. }
  252. this.$refs.EditForm.init(page, this.catalogInfo.page)
  253. },
  254. edit (screen) {
  255. this.$refs.EditForm.init(screen, this.catalogInfo.page)
  256. },
  257. del (screen) {
  258. this.$confirm(`确定删除该${this.hint}?`, '提示', {
  259. confirmButtonText: '确定',
  260. cancelButtonText: '取消',
  261. type: 'warning',
  262. customClass: 'bs-el-message-box'
  263. })
  264. .then(async () => {
  265. this.$dataRoomAxios.post(`/bigScreen/design/delete/${screen.code}`)
  266. .then(() => {
  267. this.$message({
  268. type: 'success',
  269. message: '删除成功'
  270. })
  271. this.getDataList()
  272. })
  273. .catch(() => {
  274. this.$message({
  275. type: 'error',
  276. message: '删除失败!'
  277. })
  278. })
  279. })
  280. .catch()
  281. },
  282. copy (screen) {
  283. this.$confirm(`确定复制该${this.hint}?`, '提示', {
  284. confirmButtonText: '确定',
  285. cancelButtonText: '取消',
  286. type: 'warning',
  287. customClass: 'bs-el-message-box'
  288. })
  289. .then(async () => {
  290. this.$dataRoomAxios.post(`/bigScreen/design/copy/${screen.code}`)
  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((e) => {
  306. console.error(e)
  307. })
  308. },
  309. /**
  310. * 获取封面图片,如果是相对路径则拼接上文件访问前缀地址
  311. * @param url
  312. * @returns {*}
  313. */
  314. getCoverPicture (url) {
  315. return getFileUrl(url)
  316. }
  317. }
  318. }
  319. </script>
  320. <style lang="scss" scoped>
  321. @import '../assets/style/bsTheme.scss';
  322. .big-screen-list-wrap {
  323. .el-select {
  324. display: inline-block !important;
  325. position: relative !important;
  326. width: auto !important;
  327. }
  328. position: relative;
  329. height: 100%;
  330. // margin:0 16px;
  331. margin-left: 16px;
  332. // padding: 16px;
  333. color: #9ea9b2;
  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: 16px;
  344. .el-input {
  345. width: 200px;
  346. margin-right: 20px;
  347. ::v-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. padding-right: 5px;
  356. // 间隙自适应
  357. justify-content: space-around;
  358. // max-height: calc(100vh - 304px);
  359. max-height: calc(100% - 90px);
  360. display: grid;
  361. grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  362. grid-gap: 15px;
  363. padding-bottom: 10px;
  364. // ::v-deep .el-loading-mask {
  365. // display: flex;
  366. // align-items: center;
  367. // justify-content: center;
  368. // height: calc(100vh - 260px) !important;
  369. // z-index: 999;
  370. // top: 50px;
  371. // }
  372. .big-screen-card-wrap {
  373. position: relative;
  374. height: 180px;
  375. cursor: pointer;
  376. &:hover {
  377. .screen-card__hover {
  378. height: 180px;
  379. }
  380. }
  381. .screen-card__hover {
  382. position: absolute;
  383. z-index: 999;
  384. top: 0;
  385. right: 0;
  386. left: 0;
  387. display: flex;
  388. overflow: hidden;
  389. align-items: center;
  390. justify-content: center;
  391. height: 0;
  392. transition: height 0.4s;
  393. background: #00000099;
  394. .screen-card__hover-box {
  395. position: absolute;
  396. width: 100%;
  397. height: 100%;
  398. background: #00000080;
  399. display: flex;
  400. overflow: hidden;
  401. align-items: center;
  402. justify-content: center;
  403. }
  404. .preview {
  405. display: flex;
  406. flex-direction: row;
  407. justify-content: space-evenly;
  408. width: 100%;
  409. cursor: pointer;
  410. color: var(--bs-el-color-primary);
  411. .circle {
  412. position: relative;
  413. display: flex;
  414. align-items: center;
  415. justify-content: center;
  416. width: 40px;
  417. height: 40px;
  418. border: 1px solid var(--bs-el-color-primary);
  419. border-radius: 50%;
  420. &:hover {
  421. color: #fff;
  422. background: var(--bs-el-color-primary);
  423. }
  424. span {
  425. font-size: 12px;
  426. }
  427. }
  428. }
  429. }
  430. .big-screen-card-inner {
  431. overflow: hidden;
  432. width: 100%;
  433. height: 100%;
  434. cursor: pointer;
  435. background-color: var(--bs-background-2);
  436. box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
  437. color: var(--bs-el-title);
  438. border: 1px solid var(--bs-background-1);
  439. &:hover {
  440. color: var(--bs-el-text);
  441. border: 1px solid var(--bs-el-color-primary);
  442. }
  443. .add-big-screen-card-text {
  444. color: var(--bs-el-color-primary);
  445. font-size: 24px;
  446. }
  447. .big-screen-card-img {
  448. width: 100%;
  449. height: 150px;
  450. img {
  451. width: 100%;
  452. height: 100%;
  453. object-fit: cover;
  454. }
  455. ::v-deep .image-slot {
  456. height: 100%;
  457. background-color: var(--bs-background-2);
  458. display: flex;
  459. align-items: center;
  460. justify-content: center;
  461. }
  462. ::v-deep .el-image__error {
  463. background-color: #1d1d1d;
  464. }
  465. }
  466. .big-screen-bottom {
  467. display: flex;
  468. align-items: center;
  469. flex-direction: row;
  470. justify-content: space-between;
  471. box-sizing: border-box;
  472. width: 100%;
  473. /*height: 26px;*/
  474. padding: 0 10px;
  475. height: calc(100% - 150px);
  476. color: var(--bs-el-title);
  477. background-color: var(--bs-background-2);
  478. .left-bigscreen-title {
  479. font-size: 14px;
  480. overflow: hidden;
  481. width: 100%;
  482. white-space: nowrap;
  483. text-overflow: ellipsis;
  484. }
  485. .right-bigscreen-time-title {
  486. font-size: 14px;
  487. overflow: hidden;
  488. width: 140px;
  489. white-space: nowrap;
  490. text-overflow: ellipsis;
  491. }
  492. }
  493. .big-screen-card-text {
  494. font-size: 14px;
  495. padding: 10px;
  496. text-align: center;
  497. color: #333;
  498. }
  499. }
  500. .big-screen-card-inner-add {
  501. display: flex;
  502. align-items: center;
  503. justify-content: center;
  504. }
  505. }
  506. .error-img-text {
  507. overflow: hidden;
  508. padding: 0 10px;
  509. white-space: nowrap;
  510. text-overflow: ellipsis;
  511. -o-text-overflow: ellipsis;
  512. }
  513. }
  514. .el-loading-parent--relative {
  515. position: unset !important;
  516. }
  517. .footer-pagination-wrap {
  518. width: 100%;
  519. position: absolute;
  520. bottom: 16px;
  521. right: 16px;
  522. }
  523. }
  524. .bs-pagination {
  525. ::v-deep .el-input__inner {
  526. width: 110px !important;
  527. border: none;
  528. background: var(--bs-el-background-1);
  529. }
  530. }
  531. </style>