index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. <template>
  2. <div class="big-screen-list-wrap">
  3. <div class="internal-box">
  4. <div class="top-search-wrap">
  5. <el-select
  6. v-if="catalogInfo !== 'system'"
  7. v-model="catalogCode"
  8. class="bs-el-select"
  9. popper-class="bs-el-select"
  10. placeholder="请选择分组"
  11. clearable
  12. @change="reSearch"
  13. >
  14. <el-option
  15. v-for="item in catalogList"
  16. :key="item.code"
  17. :label="item.name"
  18. :value="item.code"
  19. />
  20. </el-select>
  21. <el-input
  22. v-model="searchKey"
  23. class="bs-el-input"
  24. placeholder="请输入组件名称"
  25. prefix-icon="el-icon-search"
  26. clearable
  27. @clear="reSearch"
  28. @keyup.enter.native="reSearch"
  29. />
  30. <el-button
  31. type="primary"
  32. @click="reSearch"
  33. >
  34. 搜索
  35. </el-button>
  36. <el-button
  37. v-if="catalogInfo !== 'system'"
  38. type="primary"
  39. @click="catalogManage"
  40. >
  41. 分组管理
  42. </el-button>
  43. </div>
  44. <div
  45. v-loading="loading"
  46. class="list-wrap bs-scrollbar"
  47. element-loading-text="加载中"
  48. :style="{
  49. display: gridComputed ? 'grid' : 'flex',
  50. justifyContent: gridComputed ? 'space-around' : 'flex-start'
  51. }"
  52. >
  53. <!-- 第一个是新增大屏卡片 -->
  54. <div
  55. v-if="catalogInfo !== 'system'"
  56. class="big-screen-card-wrap"
  57. :style="{
  58. width: gridComputed ? 'auto' : '290px'
  59. }"
  60. @click="add"
  61. >
  62. <div class="big-screen-card-inner big-screen-card-inner-add">
  63. <div class="add-big-screen-card">
  64. <div class="add-big-screen-card-inner">
  65. <div class="add-big-screen-card-text">
  66. 新建组件
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. <!-- 后面遍历 list -->
  73. <div
  74. v-for="screen in list"
  75. :key="screen.id"
  76. class="big-screen-card-wrap"
  77. :style="{
  78. width: gridComputed ? 'auto' : '290px'
  79. }"
  80. >
  81. <div class="big-screen-card-inner">
  82. <div class="screen-card__hover">
  83. <div class="screen-card__hover-box">
  84. <div class="preview">
  85. <div
  86. class="screen-card__oper-label circle"
  87. @click="preview(screen)"
  88. >
  89. <span>预览</span>
  90. </div>
  91. <div
  92. v-if="catalogInfo !== 'system'"
  93. class="circle"
  94. @click="design(screen)"
  95. >
  96. <span>设计</span>
  97. </div>
  98. <div
  99. v-if="catalogInfo !== 'system'"
  100. class="circle"
  101. @click="edit(screen)"
  102. >
  103. <span>编辑</span>
  104. </div>
  105. <div
  106. v-if="catalogInfo !== 'system'"
  107. class="circle"
  108. @click="copy(screen)"
  109. >
  110. <span>复制</span>
  111. </div>
  112. <div
  113. v-if="catalogInfo !== 'system'"
  114. class="circle"
  115. @click="del(screen)"
  116. >
  117. <span>删除</span>
  118. </div>
  119. </div>
  120. </div>
  121. </div>
  122. <div class="big-screen-card-img">
  123. <el-image
  124. :src="catalogInfo !== 'system' ? screen.coverPicture : screen.img"
  125. fit="fill"
  126. style="width: 100%; height: 100%"
  127. >
  128. <div
  129. slot="placeholder"
  130. class="image-slot"
  131. >
  132. 加载中···
  133. </div>
  134. <div
  135. slot="error"
  136. class="image-slot"
  137. style="font-size: 20px"
  138. >
  139. <div class="error-img-text">
  140. {{ catalogInfo !== 'system' ? screen.name : screen.title }}
  141. </div>
  142. </div>
  143. </el-image>
  144. </div>
  145. <div class="big-screen-bottom">
  146. <div
  147. class="left-bigscreen-title"
  148. :title="catalogInfo !== 'system' ? screen.name : screen.title"
  149. >
  150. {{ catalogInfo !== 'system' ? screen.name : screen.title }}
  151. </div>
  152. </div>
  153. </div>
  154. </div>
  155. </div>
  156. <div
  157. v-if="catalogInfo !== 'system'"
  158. class="footer-pagination-wrap"
  159. >
  160. <!-- <div class="footer-pagination-wrap-text">
  161. 总共 {{ totalCount }} 个项目
  162. </div> -->
  163. <div class="bs-pagination">
  164. <el-pagination
  165. class="bs-el-pagination"
  166. popper-class="bs-el-pagination"
  167. background
  168. layout="total, prev, pager, next, sizes"
  169. :page-size="size"
  170. prev-text="上一页"
  171. next-text="下一页"
  172. :total="totalCount"
  173. :page-sizes="[10, 20, 50, 100]"
  174. :current-page="current"
  175. @current-change="currentChangeHandle"
  176. @size-change="sizeChangeHandle"
  177. />
  178. </div>
  179. </div>
  180. </div>
  181. <!-- 新增或编辑弹窗 -->
  182. <EditForm
  183. v-if="catalogInfo !== 'system'"
  184. ref="EditForm"
  185. :type="catalogInfo"
  186. @refreshData="reSearch"
  187. />
  188. <CatalogEditForm
  189. v-if="catalogInfo !== 'system'"
  190. ref="CatalogEditForm"
  191. :catalog-type="catalogType"
  192. @updateCatalogList="updateCatalogList"
  193. />
  194. </div>
  195. </template>
  196. <script>
  197. import { pageMixins } from 'data-room-ui/js/mixins/page'
  198. import EditForm from './EditForm.vue'
  199. import CatalogEditForm from './CatalogEditForm'
  200. import innerRemoteComponents, { getRemoteComponents } from 'data-room-ui/RemoteComponents/remoteComponentsList'
  201. export default {
  202. name: 'BigScreenList',
  203. mixins: [pageMixins],
  204. props: {
  205. catalogInfo: {
  206. type: String,
  207. default: ''
  208. }
  209. },
  210. components: { EditForm, CatalogEditForm },
  211. data () {
  212. return {
  213. name: '',
  214. catalogVisible: false,
  215. templateLoading: false,
  216. searchKey: '',
  217. list: [],
  218. defaultImg: require('./images/defaultImg.png'),
  219. loading: false,
  220. catalogList: [], // 分组列表
  221. catalogCode: ''
  222. }
  223. },
  224. computed: {
  225. catalogType () {
  226. if (this.catalogInfo === 'component') {
  227. return 'componentCatalog'
  228. } else {
  229. return 'bizComponentCatalog'
  230. }
  231. },
  232. code () {
  233. return ''
  234. },
  235. gridComputed () {
  236. return this.list.length > 2
  237. }
  238. },
  239. watch: {
  240. catalogInfo () {
  241. this.reset()
  242. this.init()
  243. },
  244. catalogCode (value) {
  245. this.reSearch()
  246. }
  247. },
  248. mounted () {
  249. this.init()
  250. },
  251. methods: {
  252. reset () {
  253. this.searchKey = ''
  254. this.current = 1
  255. this.size = 10
  256. this.catalogCode = ''
  257. this.init()
  258. },
  259. init () {
  260. if (this.catalogInfo !== 'system') {
  261. this.getDataList()
  262. this.getCatalogList()
  263. } else {
  264. this.list = []
  265. this.list = [...innerRemoteComponents, ...getRemoteComponents()]
  266. }
  267. },
  268. updateCatalogList (list) {
  269. this.catalogList = list
  270. },
  271. reSearch () {
  272. if (this.catalogInfo !== 'system') {
  273. this.current = 1
  274. this.getDataList()
  275. } else {
  276. const arr = [...innerRemoteComponents, ...getRemoteComponents()]
  277. this.list = arr?.filter((item) => item.title.indexOf(this.searchKey) !== -1)
  278. }
  279. },
  280. catalogManage () {
  281. this.$refs.CatalogEditForm.formVisible = true
  282. },
  283. // 获取分组列表
  284. getCatalogList () {
  285. this.$dataRoomAxios.get(`/bigScreen/type/list/${this.catalogType}`)
  286. .then((data) => {
  287. this.catalogList = data
  288. })
  289. .catch(() => { })
  290. },
  291. getDataList () {
  292. this.loading = true
  293. if (this.catalogInfo === 'component') {
  294. this.$dataRoomAxios.get('/bigScreen/design/page', {
  295. parentCode: this.catalogCode || null,
  296. current: this.current,
  297. size: this.size,
  298. searchKey: this.searchKey,
  299. type: 'component'
  300. })
  301. .then((data) => {
  302. this.list = data.list
  303. this.totalCount = data.totalCount
  304. })
  305. .finally(() => {
  306. this.loading = false
  307. })
  308. } else {
  309. this.$dataRoomAxios.get('/bigScreen/bizComponent/page', {
  310. current: this.current,
  311. size: this.size,
  312. // searchKey: this.searchKey,
  313. name: this.searchKey,
  314. type: this.catalogCode || null
  315. })
  316. .then((data) => {
  317. this.list = data.list
  318. this.totalCount = data.totalCount
  319. })
  320. .finally(() => {
  321. this.loading = false
  322. })
  323. }
  324. },
  325. preview (screen) {
  326. let path = ''
  327. let query = {
  328. code: screen.code
  329. }
  330. if (this.catalogInfo === 'component') {
  331. path = (window.BS_CONFIG?.routers?.previewUrl || '/big-screen/preview')
  332. } else {
  333. path = (window.BS_CONFIG?.routers?.bizComponentPreviewUrl || 'big-screen-biz-component-preview')
  334. }
  335. if (this.catalogInfo === 'system') {
  336. query = {
  337. dirName: screen.customize.vueSysComponentDirName
  338. }
  339. }
  340. const { href } = this.$router.resolve({
  341. path, // 这里写的是要跳转的路由地址
  342. query
  343. })
  344. window.open(href, '_blank')
  345. },
  346. design (screen) {
  347. const path = this.catalogInfo === 'component' ? (window.BS_CONFIG?.routers?.designUrl || '/big-screen/design') : (window.BS_CONFIG?.routers?.bizComponentDesignUrl || 'big-screen-biz-component-design')
  348. const { href } = this.$router.resolve({
  349. path,
  350. query: {
  351. code: screen.code
  352. }
  353. })
  354. window.open(href, '_self')
  355. },
  356. add () {
  357. const page = {
  358. code: '',
  359. type: this.catalogInfo === 'component' ? 'bigScreen' : 'bizComponent'
  360. }
  361. this.$refs.EditForm.init(page, this.catalogCode)
  362. },
  363. edit (screen) {
  364. this.$refs.EditForm.init(screen, this.catalogCode)
  365. },
  366. del (screen) {
  367. this.$confirm('确定删除该组件', '提示', {
  368. confirmButtonText: '确定',
  369. cancelButtonText: '取消',
  370. type: 'warning',
  371. customClass: 'bs-el-message-box'
  372. })
  373. .then(async () => {
  374. const url = this.catalogInfo === 'component' ? `/bigScreen/design/delete/${screen.code}` : `/bigScreen/bizComponent/delete/${screen.id}`
  375. this.$dataRoomAxios.post(url)
  376. .then(() => {
  377. this.$message({
  378. type: 'success',
  379. message: '删除成功'
  380. })
  381. this.getDataList()
  382. })
  383. .catch(() => {
  384. this.$message({
  385. type: 'error',
  386. message: '删除失败!'
  387. })
  388. })
  389. })
  390. .catch()
  391. },
  392. copy (screen) {
  393. const url = this.catalogInfo === 'component' ? `/bigScreen/design/copy/${screen.code}` : `/Component/copy/${screen.code}`
  394. this.$confirm('确定复制该组件', '提示', {
  395. confirmButtonText: '确定',
  396. cancelButtonText: '取消',
  397. type: 'warning',
  398. customClass: 'bs-el-message-box'
  399. })
  400. .then(async () => {
  401. this.$dataRoomAxios.post(url)
  402. .then(() => {
  403. this.$message({
  404. type: 'success',
  405. message: '复制成功'
  406. })
  407. this.getDataList()
  408. })
  409. .catch(() => {
  410. this.$message({
  411. type: 'error',
  412. message: '复制失败!'
  413. })
  414. })
  415. })
  416. .catch((e) => {
  417. console.error(e)
  418. })
  419. }
  420. }
  421. }
  422. </script>
  423. <style lang="scss" scoped>
  424. @import '../assets/style/bsTheme.scss';
  425. .big-screen-list-wrap {
  426. .el-select {
  427. display: inline-block !important;
  428. position: relative !important;
  429. width: auto !important;
  430. }
  431. position: relative;
  432. height: 100%;
  433. // padding: 16px;
  434. // margin:0 16px;
  435. margin-left: 16px;
  436. color: #9ea9b2;
  437. background-color: var(--bs-background-2) !important;
  438. .internal-box {
  439. height: calc(100% - 32px);
  440. padding: 16px;
  441. }
  442. .top-search-wrap {
  443. display: flex;
  444. align-items: center;
  445. justify-content: flex-end;
  446. margin-bottom: 12px;
  447. .el-input {
  448. width: 200px;
  449. margin-right: 20px;
  450. ::v-deep.el-input__inner {
  451. background-color: var(--bs-background-1) !important;
  452. }
  453. }
  454. .el-select {
  455. margin-right: 20px;
  456. ::v-deep.el-input__inner {
  457. background-color: var(--bs-background-1) !important;
  458. }
  459. }
  460. }
  461. .list-wrap {
  462. /* display: grid; */
  463. overflow: auto;
  464. padding-right: 5px;
  465. // 间隙自适应
  466. justify-content: space-around;
  467. // max-height: calc(100vh - 304px);
  468. max-height: calc(100% - 90px);
  469. display: grid;
  470. grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  471. grid-gap: 15px;
  472. padding-bottom: 10px;
  473. // ::v-deep .el-loading-mask {
  474. // display: flex;
  475. // align-items: center;
  476. // justify-content: center;
  477. // height: calc(100vh - 260px) !important;
  478. // z-index: 999;
  479. // top: 50px;
  480. // }
  481. .big-screen-card-wrap {
  482. position: relative;
  483. height: 180px;
  484. cursor: pointer;
  485. &:hover {
  486. .screen-card__hover {
  487. height: 180px;
  488. }
  489. }
  490. .screen-card__hover {
  491. position: absolute;
  492. z-index: 999;
  493. top: 0;
  494. right: 0;
  495. left: 0;
  496. display: flex;
  497. overflow: hidden;
  498. align-items: center;
  499. justify-content: center;
  500. height: 0;
  501. transition: height 0.4s;
  502. background: #00000099;
  503. .screen-card__hover-box {
  504. position: absolute;
  505. width: 100%;
  506. height: 100%;
  507. background: #00000080;
  508. display: flex;
  509. overflow: hidden;
  510. align-items: center;
  511. justify-content: center;
  512. }
  513. .preview {
  514. display: flex;
  515. flex-direction: row;
  516. justify-content: space-evenly;
  517. width: 100%;
  518. cursor: pointer;
  519. color: var(--bs-el-color-primary);
  520. .circle {
  521. position: relative;
  522. display: flex;
  523. align-items: center;
  524. justify-content: center;
  525. width: 40px;
  526. height: 40px;
  527. border: 1px solid var(--bs-el-color-primary);
  528. border-radius: 50%;
  529. &:hover {
  530. color: #fff;
  531. background: var(--bs-el-color-primary);
  532. }
  533. span {
  534. font-size: 12px;
  535. }
  536. }
  537. }
  538. }
  539. .big-screen-card-inner {
  540. overflow: hidden;
  541. width: 100%;
  542. height: 100%;
  543. cursor: pointer;
  544. background-color: var(--bs-background-2);
  545. box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
  546. color: var(--bs-el-title);
  547. border: 1px solid var(--bs-background-1);
  548. &:hover {
  549. color: var(--bs-el-text);
  550. border: 1px solid var(--bs-el-color-primary);
  551. }
  552. .add-big-screen-card-text {
  553. color: var(--bs-el-color-primary);
  554. font-size: 24px;
  555. }
  556. .big-screen-card-img {
  557. width: 100%;
  558. height: 150px;
  559. img {
  560. width: 100%;
  561. height: 100%;
  562. object-fit: cover;
  563. }
  564. ::v-deep.image-slot {
  565. height: 100%;
  566. background-color: var(--bs-background-2);
  567. display: flex;
  568. align-items: center;
  569. justify-content: center;
  570. }
  571. ::v-deep.el-image__error {
  572. background-color: #1d1d1d;
  573. }
  574. }
  575. .big-screen-bottom {
  576. display: flex;
  577. align-items: center;
  578. flex-direction: row;
  579. justify-content: space-between;
  580. box-sizing: border-box;
  581. width: 100%;
  582. /*height: 26px;*/
  583. padding: 0 10px;
  584. height: calc(100% - 150px);
  585. color: var(--bs-el-title);
  586. background-color: var(--bs-background-2);
  587. .left-bigscreen-title {
  588. font-size: 14px;
  589. overflow: hidden;
  590. width: 120px;
  591. white-space: nowrap;
  592. text-overflow: ellipsis;
  593. }
  594. .right-bigscreen-time-title {
  595. font-size: 14px;
  596. overflow: hidden;
  597. width: 140px;
  598. white-space: nowrap;
  599. text-overflow: ellipsis;
  600. }
  601. }
  602. .big-screen-card-text {
  603. font-size: 14px;
  604. padding: 10px;
  605. text-align: center;
  606. color: #333;
  607. }
  608. }
  609. .big-screen-card-inner-add {
  610. display: flex;
  611. align-items: center;
  612. justify-content: center;
  613. }
  614. }
  615. }
  616. .el-loading-parent--relative {
  617. position: unset !important;
  618. }
  619. .footer-pagination-wrap {
  620. // position: absolute;
  621. // bottom: 16px;
  622. // right: 16px;
  623. // display: flex;
  624. // align-items: center;
  625. // justify-content: flex-end;
  626. // width: 100%;
  627. position: absolute;
  628. bottom: 16px;
  629. right: 12px;
  630. // padding: 0 16px;
  631. }
  632. .error-img-text {
  633. overflow: hidden;
  634. padding: 0 10px;
  635. white-space: nowrap;
  636. text-overflow: ellipsis;
  637. -o-text-overflow: ellipsis;
  638. }
  639. }
  640. .bs-pagination {
  641. ::v-deep .el-input__inner {
  642. width: 110px !important;
  643. border: none;
  644. background: var(--bs-el-background-1);
  645. }
  646. }
  647. </style>