index.vue 19 KB

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