index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  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. </div>
  340. </el-dialog>
  341. </template>
  342. <script>
  343. import { get } from 'packages/js/utils/http'
  344. import { pageMixins } from 'packages/js/mixins/page'
  345. import _ from 'lodash'
  346. import innerRemoteComponents, { getRemoteComponents, getRemoteComponentConfig } from 'packages/RemoteComponents/remoteComponentsList'
  347. import { getBizComponentPage } from 'packages/js/api/bigScreenApi'
  348. export default {
  349. name: 'ComponentDialog',
  350. mixins: [pageMixins],
  351. props: {},
  352. data () {
  353. return {
  354. dialogVisible: false,
  355. loading: false,
  356. options: [], // 分组列表
  357. code: '',
  358. focus: -1,
  359. list: [],
  360. searchKey: '',
  361. name: '', // 业务组件搜索关键字
  362. activeName: 'combination',
  363. remoteComponentlist: [],
  364. // 业务组件列表
  365. bizComponentList: []
  366. }
  367. },
  368. computed: {
  369. gridComputed () {
  370. return this.list.length > 3
  371. },
  372. remoteComponentsGridComputed () {
  373. return this.remoteComponentlist.length > 3
  374. },
  375. bizFridComputed () {
  376. return this.bizComponentList.length > 3
  377. }
  378. },
  379. watch: {
  380. activeName () {
  381. this.getCatalogList()
  382. }
  383. },
  384. mounted () {
  385. this.remoteComponentlist = [...innerRemoteComponents, ...getRemoteComponents()]
  386. },
  387. methods: {
  388. chooseComponent (component) {
  389. this.focus = _.cloneDeep(component)
  390. },
  391. close () {},
  392. init () {
  393. this.dialogVisible = true
  394. this.current = 1
  395. this.searchKey = ''
  396. this.code = ''
  397. this.focus = -1
  398. this.getDataList()
  399. this.getCatalogList()
  400. },
  401. // 点击确定
  402. confirm () {
  403. this.dialogVisible = false
  404. if (this.activeName === 'combination') {
  405. if (Object.keys(this.focus).length) {
  406. this.$emit('setComponent', this.focus)
  407. }
  408. } else if (['remote'].includes(this.activeName)) {
  409. if (_.isEmpty(this.focus)) {
  410. return
  411. }
  412. this.$emit('setRemoteComponent', this.focus)
  413. } if (['bizComponent'].includes(this.activeName)) {
  414. let config = {}
  415. if (_.isEmpty(this.focus)) {
  416. return
  417. }
  418. config.code = this.focus.code
  419. config.name = this.focus.name
  420. config = getRemoteComponentConfig(this.focus.code, this.focus.name)
  421. this.$emit('setRemoteComponent', config)
  422. }
  423. },
  424. getDataList () {
  425. this.loading = true
  426. get('/bigScreen/design/page', {
  427. parentCode: this.code || null,
  428. current: this.current,
  429. size: this.size,
  430. searchKey: this.searchKey,
  431. type: 'component'
  432. })
  433. .then((data) => {
  434. this.list = data.list
  435. this.totalCount = data.totalCount
  436. })
  437. .finally(() => {
  438. this.loading = false
  439. })
  440. getBizComponentPage({
  441. parentCode: this.code || null,
  442. current: this.current,
  443. size: this.size,
  444. searchKey: this.searchKey,
  445. name: this.name
  446. }).then((data) => {
  447. this.bizComponentList = data.list
  448. this.totalCount = data.totalCount
  449. this.loading = false
  450. })
  451. },
  452. // 获取目录的列表
  453. getCatalogList () {
  454. const url = this.activeName === 'combination' ? '/bigScreen/type/list/componentCatalog' : '/bigScreen/type/list/bizComponentCatalog'
  455. get(url)
  456. .then((data) => {
  457. this.options = data
  458. })
  459. .catch(() => {})
  460. }
  461. }
  462. }
  463. </script>
  464. <style lang="scss" scoped>
  465. @import '~packages/assets/style/bsTheme.scss';
  466. .big-screen-list-wrap {
  467. position: relative;
  468. height: 100%;
  469. margin:0 16px;
  470. padding: 16px;
  471. color: #9ea9b2;
  472. background-color: var(--bs-background-2) !important;
  473. .top-search-wrap {
  474. display: flex;
  475. align-items: center;
  476. justify-content: flex-end;
  477. margin-bottom: 12px;
  478. .el-input {
  479. width: 200px;
  480. margin-right: 20px;
  481. /deep/.el-input__inner {
  482. background-color: var(--bs-background-1) !important;
  483. }
  484. }
  485. .el-select {
  486. margin-right: 20px;
  487. /deep/.el-input__inner {
  488. background-color: var(--bs-background-1) !important;
  489. }
  490. }
  491. }
  492. .list-wrap {
  493. /* display: grid; */
  494. overflow: auto;
  495. // 间隙自适应
  496. justify-content: space-around;
  497. // max-height: calc(100vh - 270px);
  498. display: grid;
  499. grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  500. grid-gap: 15px;
  501. // /deep/ .el-loading-mask {
  502. // display: flex;
  503. // align-items: center;
  504. // justify-content: center;
  505. // height: calc(100vh - 260px) !important;
  506. // z-index: 999;
  507. // top: 50px;
  508. // }
  509. .big-screen-card-wrap {
  510. position: relative;
  511. height: 230px;
  512. cursor: pointer;
  513. &:hover {
  514. .screen-card__hover {
  515. height: 180px;
  516. }
  517. }
  518. .screen-card__hover {
  519. position: absolute;
  520. z-index: 999;
  521. top: 0;
  522. right: 0;
  523. left: 0;
  524. display: flex;
  525. overflow: hidden;
  526. align-items: center;
  527. justify-content: center;
  528. height: 0;
  529. transition: height 0.4s;
  530. background: #00000099;
  531. }
  532. .focus {
  533. color: var(--bs-el-text) !important;
  534. border: 1px solid var(--bs-el-color-primary) !important;
  535. }
  536. .big-screen-card-inner {
  537. overflow: hidden;
  538. width: 100%;
  539. height: 100%;
  540. cursor: pointer;
  541. background-color: var(--bs-background-2);
  542. box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
  543. color: var(--bs-el-title);
  544. border: 1px solid var(--bs-background-1);
  545. &:hover {
  546. color: var(--bs-el-text);
  547. border: 1px solid var(--bs-el-color-primary);
  548. }
  549. .add-big-screen-card-text {
  550. font-size: 24px;
  551. }
  552. .big-screen-card-img {
  553. width: 100%;
  554. height: 180px;
  555. img {
  556. width: 100%;
  557. height: 100%;
  558. object-fit: cover;
  559. }
  560. /deep/.image-slot {
  561. height: 100%;
  562. background-color: var(--bs-background-2);
  563. display: flex;
  564. align-items: center;
  565. justify-content: center;
  566. }
  567. /deep/.el-image__error {
  568. background-color: #1d1d1d;
  569. }
  570. }
  571. .big-screen-bottom {
  572. display: flex;
  573. align-items: center;
  574. flex-direction: row;
  575. justify-content: space-between;
  576. box-sizing: border-box;
  577. width: 100%;
  578. /*height: 26px;*/
  579. padding: 0 10px;
  580. height: calc(100% - 180px);
  581. color: var(--bs-el-title);
  582. background-color: var(--bs-background-2);
  583. .left-bigscreen-title {
  584. font-size: 14px;
  585. overflow: hidden;
  586. width: 120px;
  587. white-space: nowrap;
  588. text-overflow: ellipsis;
  589. }
  590. .right-bigscreen-time-title {
  591. font-size: 14px;
  592. overflow: hidden;
  593. width: 140px;
  594. white-space: nowrap;
  595. text-overflow: ellipsis;
  596. }
  597. }
  598. .big-screen-card-text {
  599. font-size: 14px;
  600. padding: 10px;
  601. text-align: center;
  602. color: #333;
  603. }
  604. }
  605. .big-screen-card-inner-add {
  606. display: flex;
  607. align-items: center;
  608. justify-content: center;
  609. }
  610. }
  611. }
  612. .el-loading-parent--relative {
  613. position: unset !important;
  614. }
  615. .footer-pagination-wrap {
  616. display: flex;
  617. align-items: center;
  618. justify-content: flex-end;
  619. width: 100%;
  620. margin-top: 16px;
  621. padding: 0 16px;
  622. }
  623. }
  624. .bs-pagination {
  625. ::v-deep .el-input__inner {
  626. width: 110px !important;
  627. border: none;
  628. background: var(--bs-el-background-1);
  629. }
  630. }
  631. .empty {
  632. width: 100%;
  633. height: 70%;
  634. min-height: 300px;
  635. display: flex;
  636. justify-content: center;
  637. align-items: center;
  638. }
  639. /deep/ .el-tabs__item {
  640. color: var(--bs-el-text);
  641. }
  642. .error-img-text{
  643. overflow:hidden;
  644. padding:0 10px;
  645. white-space: nowrap;
  646. text-overflow: ellipsis;
  647. -o-text-overflow:ellipsis;
  648. }
  649. ::v-deep .el-tabs__nav-wrap{
  650. &:after{
  651. display: none;
  652. }
  653. }
  654. </style>