index.vue 19 KB

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