index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  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 class="right-bigscreen-time-title">-->
  125. <!-- {{ screen.updateDate || '-' }}-->
  126. <!-- </div>-->
  127. </div>
  128. </div>
  129. </div>
  130. </div>
  131. <div class="footer-pagination-wrap">
  132. <!-- <div class="footer-pagination-wrap-text">
  133. 总共 {{ totalCount }} 个项目
  134. </div> -->
  135. <div class="bs-pagination">
  136. <el-pagination
  137. class="bs-el-pagination"
  138. popper-class="bs-el-pagination"
  139. background
  140. layout="total, prev, pager, next, sizes"
  141. :page-size="size"
  142. prev-text="上一页"
  143. next-text="下一页"
  144. :total="totalCount"
  145. :page-sizes="[10, 20, 50, 100]"
  146. :current-page="current"
  147. @current-change="currentChangeHandle"
  148. @size-change="sizeChangeHandle"
  149. />
  150. </div>
  151. </div>
  152. </div>
  153. <!-- 新增或编辑弹窗 -->
  154. <EditForm
  155. ref="EditForm"
  156. :type="pageType"
  157. @refreshData="reSearch"
  158. />
  159. </div>
  160. </template>
  161. <script>
  162. import { get, post } from 'packages/js/utils/http'
  163. import { pageMixins } from 'packages/js/mixins/page'
  164. import EditForm from './EditForm.vue'
  165. export default {
  166. name: 'BigScreenList',
  167. mixins: [pageMixins],
  168. props: {
  169. type: {
  170. type: String,
  171. default: 'bigScreenCatalog'
  172. },
  173. catalogInfo: {
  174. type: Object,
  175. default: () => {}
  176. }
  177. },
  178. components: { EditForm },
  179. data () {
  180. return {
  181. templateLoading: false,
  182. searchKey: '',
  183. list: [],
  184. defaultImg: require('./images/defaultImg.png'),
  185. loading: false
  186. }
  187. },
  188. computed: {
  189. hint () {
  190. return this.pageType === 'bigScreen' ? '大屏' : '组件'
  191. },
  192. code () {
  193. return this.catalogInfo?.page?.code
  194. },
  195. gridComputed () {
  196. return this.list.length > 2
  197. },
  198. pageType () {
  199. return this.type === 'bigScreenCatalog' ? 'bigScreen' : 'component'
  200. }
  201. },
  202. watch: {
  203. code (value) {
  204. this.current = 1
  205. this.getDataList()
  206. }
  207. },
  208. mounted () {
  209. this.getDataList()
  210. },
  211. methods: {
  212. getDataList () {
  213. this.loading = true
  214. get('/bigScreen/design/page', {
  215. parentCode: this.code || null,
  216. current: this.current,
  217. size: this.size,
  218. searchKey: this.searchKey,
  219. type: this.pageType
  220. })
  221. .then((data) => {
  222. this.list = data.list
  223. this.totalCount = data.totalCount
  224. })
  225. .finally(() => {
  226. this.loading = false
  227. })
  228. },
  229. preview (screen) {
  230. const { href } = this.$router.resolve({
  231. path: window.BS_CONFIG?.routers?.previewUrl || '/big-screen/preview', // 这里写的是要跳转的路由地址
  232. query: {
  233. code: screen.code
  234. }
  235. })
  236. window.open(href, '_blank')
  237. },
  238. design (screen) {
  239. const path = window.BS_CONFIG?.routers?.designUrl || '/big-screen/design'
  240. const { href } = this.$router.resolve({
  241. path,
  242. query: {
  243. code: screen.code
  244. }
  245. })
  246. window.open(href, '_self')
  247. },
  248. add () {
  249. const page = {
  250. code: '',
  251. type: 'bigScreen'
  252. }
  253. this.$refs.EditForm.init(page, this.catalogInfo.page)
  254. },
  255. edit (screen) {
  256. this.$refs.EditForm.init(screen, this.catalogInfo.page)
  257. },
  258. del (screen) {
  259. this.$confirm(`确定删除该${this.hint}?`, '提示', {
  260. confirmButtonText: '确定',
  261. cancelButtonText: '取消',
  262. type: 'warning',
  263. customClass: 'bs-el-message-box'
  264. })
  265. .then(async () => {
  266. post(`/bigScreen/design/delete/${screen.code}`)
  267. .then(() => {
  268. this.$message({
  269. type: 'success',
  270. message: '删除成功'
  271. })
  272. this.getDataList()
  273. })
  274. .catch(() => {
  275. this.$message({
  276. type: 'error',
  277. message: '删除失败!'
  278. })
  279. })
  280. })
  281. .catch()
  282. },
  283. copy (screen) {
  284. this.$confirm(`确定复制该${this.hint}?`, '提示', {
  285. confirmButtonText: '确定',
  286. cancelButtonText: '取消',
  287. type: 'warning',
  288. customClass: 'bs-el-message-box'
  289. })
  290. .then(async () => {
  291. post(`/bigScreen/design/copy/${screen.code}`)
  292. .then(() => {
  293. this.$message({
  294. type: 'success',
  295. message: '复制成功'
  296. })
  297. this.getDataList()
  298. })
  299. .catch(() => {
  300. this.$message({
  301. type: 'error',
  302. message: '复制失败!'
  303. })
  304. })
  305. })
  306. .catch((e) => {
  307. console.error(e)
  308. })
  309. }
  310. }
  311. }
  312. </script>
  313. <style lang="scss" scoped>
  314. @import '../assets/style/bsTheme.scss';
  315. .big-screen-list-wrap {
  316. position: relative;
  317. height: 100%;
  318. // margin:0 16px;
  319. margin-left: 16px;
  320. // padding: 16px;
  321. color: #9ea9b2;
  322. background-color: var(--bs-background-2) !important;
  323. .internal-box{
  324. height: calc(100% - 32px);
  325. padding: 16px;
  326. }
  327. .top-search-wrap {
  328. display: flex;
  329. align-items: center;
  330. justify-content: flex-end;
  331. margin-bottom: 16px;
  332. .el-input {
  333. width: 200px;
  334. margin-right: 20px;
  335. /deep/.el-input__inner {
  336. background-color: var(--bs-background-1) !important;
  337. }
  338. }
  339. }
  340. .list-wrap {
  341. /* display: grid; */
  342. overflow: auto;
  343. padding-right: 5px;
  344. // 间隙自适应
  345. justify-content: space-around;
  346. // max-height: calc(100vh - 304px);
  347. max-height: calc(100% - 90px);
  348. display: grid;
  349. grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  350. grid-gap: 15px;
  351. padding-bottom: 10px;
  352. // /deep/ .el-loading-mask {
  353. // display: flex;
  354. // align-items: center;
  355. // justify-content: center;
  356. // height: calc(100vh - 260px) !important;
  357. // z-index: 999;
  358. // top: 50px;
  359. // }
  360. .big-screen-card-wrap {
  361. position: relative;
  362. height: 180px;
  363. cursor: pointer;
  364. &:hover {
  365. .screen-card__hover {
  366. height: 180px;
  367. }
  368. }
  369. .screen-card__hover {
  370. position: absolute;
  371. z-index: 999;
  372. top: 0;
  373. right: 0;
  374. left: 0;
  375. display: flex;
  376. overflow: hidden;
  377. align-items: center;
  378. justify-content: center;
  379. height: 0;
  380. transition: height 0.4s;
  381. background: #00000099;
  382. .screen-card__hover-box {
  383. position: absolute;
  384. width: 100%;
  385. height: 100%;
  386. background: #00000080;
  387. display: flex;
  388. overflow: hidden;
  389. align-items: center;
  390. justify-content: center;
  391. }
  392. .preview {
  393. display: flex;
  394. flex-direction: row;
  395. justify-content: space-evenly;
  396. width: 100%;
  397. cursor: pointer;
  398. color: var(--bs-el-color-primary);
  399. .circle {
  400. position: relative;
  401. display: flex;
  402. align-items: center;
  403. justify-content: center;
  404. width: 40px;
  405. height: 40px;
  406. border: 1px solid var(--bs-el-color-primary);
  407. border-radius: 50%;
  408. &:hover {
  409. color: #fff;
  410. background: var(--bs-el-color-primary);
  411. }
  412. span {
  413. font-size: 12px;
  414. }
  415. }
  416. }
  417. }
  418. .big-screen-card-inner {
  419. overflow: hidden;
  420. width: 100%;
  421. height: 100%;
  422. cursor: pointer;
  423. background-color: var(--bs-background-2);
  424. box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
  425. color: var(--bs-el-title);
  426. border: 1px solid var(--bs-background-1);
  427. &:hover {
  428. color: var(--bs-el-text);
  429. border: 1px solid var(--bs-el-color-primary);
  430. }
  431. .add-big-screen-card-text {
  432. color: var(--bs-el-color-primary);
  433. font-size: 24px;
  434. }
  435. .big-screen-card-img {
  436. width: 100%;
  437. height: 150px;
  438. img {
  439. width: 100%;
  440. height: 100%;
  441. object-fit: cover;
  442. }
  443. /deep/.image-slot {
  444. height: 100%;
  445. background-color: var(--bs-background-2);
  446. display: flex;
  447. align-items: center;
  448. justify-content: center;
  449. }
  450. /deep/.el-image__error {
  451. background-color: #1d1d1d;
  452. }
  453. }
  454. .big-screen-bottom {
  455. display: flex;
  456. align-items: center;
  457. flex-direction: row;
  458. justify-content: space-between;
  459. box-sizing: border-box;
  460. width: 100%;
  461. /*height: 26px;*/
  462. padding: 0 10px;
  463. height: calc(100% - 150px);
  464. color: var(--bs-el-title);
  465. background-color: var(--bs-background-2);
  466. .left-bigscreen-title {
  467. font-size: 14px;
  468. overflow: hidden;
  469. width: 120px;
  470. white-space: nowrap;
  471. text-overflow: ellipsis;
  472. }
  473. .right-bigscreen-time-title {
  474. font-size: 14px;
  475. overflow: hidden;
  476. width: 140px;
  477. white-space: nowrap;
  478. text-overflow: ellipsis;
  479. }
  480. }
  481. .big-screen-card-text {
  482. font-size: 14px;
  483. padding: 10px;
  484. text-align: center;
  485. color: #333;
  486. }
  487. }
  488. .big-screen-card-inner-add {
  489. display: flex;
  490. align-items: center;
  491. justify-content: center;
  492. }
  493. }
  494. .error-img-text{
  495. overflow:hidden;
  496. padding:0 10px;
  497. white-space: nowrap;
  498. text-overflow: ellipsis;
  499. -o-text-overflow:ellipsis;
  500. }
  501. }
  502. .el-loading-parent--relative {
  503. position: unset !important;
  504. }
  505. .footer-pagination-wrap {
  506. // position: absolute;
  507. // bottom: 16px;
  508. // right: auto;
  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. </style>