index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  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="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 EditForm from './EditForm.vue'
  158. export default {
  159. name: 'BigScreenList',
  160. mixins: [pageMixins],
  161. props: {
  162. type: {
  163. type: String,
  164. default: 'bigScreenCatalog'
  165. },
  166. catalogInfo: {
  167. type: Object,
  168. default: () => { }
  169. }
  170. },
  171. components: { EditForm },
  172. data () {
  173. return {
  174. templateLoading: false,
  175. searchKey: '',
  176. list: [],
  177. defaultImg: require('./images/defaultImg.png'),
  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. </script>
  306. <style lang="scss" scoped>
  307. @import '../assets/style/bsTheme.scss';
  308. .big-screen-list-wrap {
  309. .el-select {
  310. display: inline-block !important;
  311. position: relative !important;
  312. width: auto !important;
  313. }
  314. position: relative;
  315. height: 100%;
  316. // margin:0 16px;
  317. margin-left: 16px;
  318. // padding: 16px;
  319. color: #9ea9b2;
  320. background-color: var(--bs-background-2) !important;
  321. .internal-box {
  322. height: calc(100% - 32px);
  323. padding: 16px;
  324. }
  325. .top-search-wrap {
  326. display: flex;
  327. align-items: center;
  328. justify-content: flex-end;
  329. margin-bottom: 16px;
  330. .el-input {
  331. width: 200px;
  332. margin-right: 20px;
  333. ::v-deep.el-input__inner {
  334. background-color: var(--bs-background-1) !important;
  335. }
  336. }
  337. }
  338. .list-wrap {
  339. /* display: grid; */
  340. overflow: auto;
  341. padding-right: 5px;
  342. // 间隙自适应
  343. justify-content: space-around;
  344. // max-height: calc(100vh - 304px);
  345. max-height: calc(100% - 90px);
  346. display: grid;
  347. grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  348. grid-gap: 15px;
  349. padding-bottom: 10px;
  350. // ::v-deep .el-loading-mask {
  351. // display: flex;
  352. // align-items: center;
  353. // justify-content: center;
  354. // height: calc(100vh - 260px) !important;
  355. // z-index: 999;
  356. // top: 50px;
  357. // }
  358. .big-screen-card-wrap {
  359. position: relative;
  360. height: 180px;
  361. cursor: pointer;
  362. &:hover {
  363. .screen-card__hover {
  364. height: 180px;
  365. }
  366. }
  367. .screen-card__hover {
  368. position: absolute;
  369. z-index: 999;
  370. top: 0;
  371. right: 0;
  372. left: 0;
  373. display: flex;
  374. overflow: hidden;
  375. align-items: center;
  376. justify-content: center;
  377. height: 0;
  378. transition: height 0.4s;
  379. background: #00000099;
  380. .screen-card__hover-box {
  381. position: absolute;
  382. width: 100%;
  383. height: 100%;
  384. background: #00000080;
  385. display: flex;
  386. overflow: hidden;
  387. align-items: center;
  388. justify-content: center;
  389. }
  390. .preview {
  391. display: flex;
  392. flex-direction: row;
  393. justify-content: space-evenly;
  394. width: 100%;
  395. cursor: pointer;
  396. color: var(--bs-el-color-primary);
  397. .circle {
  398. position: relative;
  399. display: flex;
  400. align-items: center;
  401. justify-content: center;
  402. width: 40px;
  403. height: 40px;
  404. border: 1px solid var(--bs-el-color-primary);
  405. border-radius: 50%;
  406. &:hover {
  407. color: #fff;
  408. background: var(--bs-el-color-primary);
  409. }
  410. span {
  411. font-size: 12px;
  412. }
  413. }
  414. }
  415. }
  416. .big-screen-card-inner {
  417. overflow: hidden;
  418. width: 100%;
  419. height: 100%;
  420. cursor: pointer;
  421. background-color: var(--bs-background-2);
  422. box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
  423. color: var(--bs-el-title);
  424. border: 1px solid var(--bs-background-1);
  425. &:hover {
  426. color: var(--bs-el-text);
  427. border: 1px solid var(--bs-el-color-primary);
  428. }
  429. .add-big-screen-card-text {
  430. color: var(--bs-el-color-primary);
  431. font-size: 24px;
  432. }
  433. .big-screen-card-img {
  434. width: 100%;
  435. height: 150px;
  436. img {
  437. width: 100%;
  438. height: 100%;
  439. object-fit: cover;
  440. }
  441. ::v-deep.image-slot {
  442. height: 100%;
  443. background-color: var(--bs-background-2);
  444. display: flex;
  445. align-items: center;
  446. justify-content: center;
  447. }
  448. ::v-deep.el-image__error {
  449. background-color: #1d1d1d;
  450. }
  451. }
  452. .big-screen-bottom {
  453. display: flex;
  454. align-items: center;
  455. flex-direction: row;
  456. justify-content: space-between;
  457. box-sizing: border-box;
  458. width: 100%;
  459. /*height: 26px;*/
  460. padding: 0 10px;
  461. height: calc(100% - 150px);
  462. color: var(--bs-el-title);
  463. background-color: var(--bs-background-2);
  464. .left-bigscreen-title {
  465. font-size: 14px;
  466. overflow: hidden;
  467. width: 120px;
  468. white-space: nowrap;
  469. text-overflow: ellipsis;
  470. }
  471. .right-bigscreen-time-title {
  472. font-size: 14px;
  473. overflow: hidden;
  474. width: 140px;
  475. white-space: nowrap;
  476. text-overflow: ellipsis;
  477. }
  478. }
  479. .big-screen-card-text {
  480. font-size: 14px;
  481. padding: 10px;
  482. text-align: center;
  483. color: #333;
  484. }
  485. }
  486. .big-screen-card-inner-add {
  487. display: flex;
  488. align-items: center;
  489. justify-content: center;
  490. }
  491. }
  492. .error-img-text {
  493. overflow: hidden;
  494. padding: 0 10px;
  495. white-space: nowrap;
  496. text-overflow: ellipsis;
  497. -o-text-overflow: ellipsis;
  498. }
  499. }
  500. .el-loading-parent--relative {
  501. position: unset !important;
  502. }
  503. .footer-pagination-wrap {
  504. // position: absolute;
  505. // bottom: 16px;
  506. // right: auto;
  507. // display: flex;
  508. // align-items: center;
  509. // justify-content: flex-end;
  510. width: 100%;
  511. position: absolute;
  512. bottom: 16px;
  513. right: 12px;
  514. // padding: 0 16px;
  515. }
  516. }
  517. .bs-pagination {
  518. ::v-deep .el-input__inner {
  519. width: 110px !important;
  520. border: none;
  521. background: var(--bs-el-background-1);
  522. }
  523. }
  524. </style>