index.vue 13 KB

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