index.vue 13 KB

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