index.vue 19 KB

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