index.vue 13 KB

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