index.vue 19 KB

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