index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. <template>
  2. <el-dialog title="组件库" :visible.sync="dialogVisible" width="80%" :modal="true" :modal-append-to-body="false"
  3. :appen-to-body="true" class="bs-dialog-wrap bs-el-dialog" @closed="close">
  4. <div class="content">
  5. <el-tabs v-model="activeName">
  6. <el-tab-pane label="自定义组件" name="combination">
  7. <div class="big-screen-list-wrap">
  8. <div class="top-search-wrap">
  9. <el-input v-model="searchKey" class="bs-el-input" placeholder="请输入组件名称" prefix-icon="el-icon-search"
  10. clearable @clear="reSearch" @keyup.enter.native="reSearch" />
  11. <el-select v-model="code" class="bs-el-select" popper-class="bs-el-select" placeholder="请选择分组" clearable
  12. @change="reSearch">
  13. <el-option v-for="item in options" :key="item.code" :label="item.name" :value="item.code" />
  14. </el-select>
  15. <el-button size="small" style="margin-right: 20px" type="primary" @click="reSearch">
  16. 搜索
  17. </el-button>
  18. </div>
  19. <div v-if="list.length !== 0" v-loading="loading" class="list-wrap bs-scrollbar" element-loading-text="加载中"
  20. :style="{
  21. display: gridComputed ? 'grid' : 'flex',
  22. justifyContent: gridComputed ? 'space-around' : 'flex-start'
  23. }">
  24. <!-- <div v-if="list.length !== 0"> -->
  25. <div v-for="screen in list" :key="screen.id" class="big-screen-card-wrap" :style="{
  26. width: gridComputed ? 'auto' : '290px'
  27. }" @click="chooseComponent(screen)">
  28. <div :class="focus.id == screen.id ? 'focus' : ''" class="big-screen-card-inner">
  29. <div class="big-screen-card-img">
  30. <el-image :src="screen.coverPicture" fit="contain" style="width: 100%; height: 100%">
  31. <div slot="placeholder" class="image-slot">
  32. 加载中···
  33. </div>
  34. <div slot="error" class="image-slot" style="font-size: 20px">
  35. <div class="error-img-text">
  36. {{ screen.name }}
  37. </div>
  38. </div>
  39. </el-image>
  40. </div>
  41. <div class="big-screen-bottom">
  42. <div class="left-bigscreen-title" :title="screen.name">
  43. {{ screen.name }}
  44. </div>
  45. </div>
  46. </div>
  47. </div>
  48. </div>
  49. <div v-else class="empty">
  50. 暂无数据
  51. </div>
  52. <div class="footer-pagination-wrap">
  53. <div class="bs-pagination">
  54. <el-pagination class="bs-el-pagination" popper-class="bs-el-pagination" background
  55. layout="total, prev, pager, next, sizes" :page-size="size" prev-text="上一页" next-text="下一页"
  56. :total="totalCount" :page-sizes="[10, 20, 50, 100]" :current-page="current"
  57. @current-change="currentChangeHandle" @size-change="sizeChangeHandle" />
  58. </div>
  59. </div>
  60. </div>
  61. </el-tab-pane>
  62. <el-tab-pane label="业务组件" name="bizComponent">
  63. <div class="big-screen-list-wrap">
  64. <div class="top-search-wrap">
  65. <el-input v-model="name" class="bs-el-input" placeholder="请输入组件名称" prefix-icon="el-icon-search" clearable
  66. @clear="reSearch" @keyup.enter.native="reSearch" />
  67. <el-select v-model="code" class="bs-el-select" popper-class="bs-el-select" placeholder="请选择分组" clearable
  68. @change="reSearch">
  69. <el-option v-for="item in options" :key="item.code" :label="item.name" :value="item.code" />
  70. </el-select>
  71. <el-button size="small" style="margin-right: 20px" type="primary" @click="reSearch">
  72. 搜索
  73. </el-button>
  74. </div>
  75. <div v-if="bizComponentList.length !== 0" v-loading="loading" class="list-wrap bs-scrollbar"
  76. element-loading-text="加载中" :style="{
  77. display: bizFridComputed ? 'grid' : 'flex',
  78. justifyContent: bizFridComputed ? 'space-around' : 'flex-start'
  79. }">
  80. <!-- <div v-if="list.length !== 0"> -->
  81. <div v-for="screen in bizComponentList" :key="screen.id" class="big-screen-card-wrap" :style="{
  82. width: bizFridComputed ? 'auto' : '290px'
  83. }" @click="chooseComponent(screen)">
  84. <div :class="focus.id == screen.id ? 'focus' : ''" class="big-screen-card-inner">
  85. <div class="big-screen-card-img">
  86. <el-image :src="screen.coverPicture" fit="contain" style="width: 100%; height: 100%">
  87. <div slot="placeholder" class="image-slot">
  88. 加载中···
  89. </div>
  90. <div slot="error" class="image-slot" style="font-size: 20px">
  91. <div class="error-img-text">
  92. {{ screen.name }}
  93. </div>
  94. </div>
  95. </el-image>
  96. </div>
  97. <div class="big-screen-bottom">
  98. <div class="left-bigscreen-title" :title="screen.name">
  99. {{ screen.name }}
  100. </div>
  101. </div>
  102. </div>
  103. </div>
  104. </div>
  105. <div v-else class="empty">
  106. 暂无数据
  107. </div>
  108. <div class="footer-pagination-wrap">
  109. <div class="bs-pagination">
  110. <el-pagination class="bs-el-pagination" popper-class="bs-el-pagination" background
  111. layout="total, prev, pager, next, sizes" :page-size="size" prev-text="上一页" next-text="下一页"
  112. :total="totalCount" :page-sizes="[10, 20, 50, 100]" :current-page="current"
  113. @current-change="currentChangeHandle" @size-change="sizeChangeHandle" />
  114. </div>
  115. </div>
  116. </div>
  117. </el-tab-pane>
  118. <el-tab-pane label="系统组件" name="remote">
  119. <div class="big-screen-list-wrap">
  120. <div v-if="remoteComponentlist.length !== 0" v-loading="loading" class="list-wrap bs-scrollbar"
  121. element-loading-text="加载中" :style="{
  122. display: remoteComponentsGridComputed ? 'grid' : 'flex',
  123. justifyContent: remoteComponentsGridComputed ? 'space-around' : 'flex-start'
  124. }">
  125. <div v-for="component in remoteComponentlist" :key="component.title" class="big-screen-card-wrap" :style="{
  126. width: remoteComponentsGridComputed ? 'auto' : '290px'
  127. }" @click="chooseComponent(component)">
  128. <div :class="component.title == focus.title ? 'focus' : ''" class="big-screen-card-inner">
  129. <div class="big-screen-card-img">
  130. <el-image :src="component.img" fit="contain" style="width: 100%; height: 100%">
  131. <div slot="placeholder" class="image-slot">
  132. 加载中···
  133. </div>
  134. </el-image>
  135. </div>
  136. <div class="big-screen-bottom">
  137. <div class="left-bigscreen-title" :title="component.title">
  138. {{ component.title }}
  139. </div>
  140. </div>
  141. </div>
  142. </div>
  143. </div>
  144. <div v-else class="empty">
  145. 暂无数据
  146. </div>
  147. </div>
  148. </el-tab-pane>
  149. </el-tabs>
  150. </div>
  151. <div slot="footer" class="dialog-footer">
  152. <el-button class="bs-el-button-default" @click="dialogVisible = false">
  153. 取消
  154. </el-button>
  155. <el-button type="primary" @click="confirm">
  156. 确定
  157. </el-button>
  158. </div>
  159. </el-dialog>
  160. </template>
  161. <script>
  162. import { get } from 'data-room-ui/js/utils/http'
  163. import { pageMixins } from 'data-room-ui/js/mixins/page'
  164. import _ from 'lodash'
  165. import innerRemoteComponents, { getRemoteComponents, getRemoteComponentConfig } from 'data-room-ui/RemoteComponents/remoteComponentsList'
  166. import { getBizComponentPage } from 'data-room-ui/js/api/bigScreenApi'
  167. export default {
  168. name: 'ComponentDialog',
  169. mixins: [pageMixins],
  170. props: {},
  171. data() {
  172. return {
  173. dialogVisible: false,
  174. loading: false,
  175. options: [], // 分组列表
  176. code: '',
  177. focus: -1,
  178. list: [],
  179. searchKey: '',
  180. name: '', // 业务组件搜索关键字
  181. activeName: 'combination',
  182. remoteComponentlist: [],
  183. // 业务组件列表
  184. bizComponentList: []
  185. }
  186. },
  187. computed: {
  188. gridComputed() {
  189. return this.list.length > 3
  190. },
  191. remoteComponentsGridComputed() {
  192. return this.remoteComponentlist.length > 3
  193. },
  194. bizFridComputed() {
  195. return this.bizComponentList.length > 3
  196. }
  197. },
  198. watch: {
  199. activeName() {
  200. this.getCatalogList()
  201. }
  202. },
  203. mounted() {
  204. this.remoteComponentlist = [...innerRemoteComponents, ...getRemoteComponents()]
  205. },
  206. methods: {
  207. chooseComponent(component) {
  208. this.focus = _.cloneDeep(component)
  209. },
  210. close() { },
  211. init() {
  212. this.dialogVisible = true
  213. this.current = 1
  214. this.searchKey = ''
  215. this.code = ''
  216. this.focus = -1
  217. this.getDataList()
  218. this.getCatalogList()
  219. },
  220. // 点击确定
  221. confirm() {
  222. this.dialogVisible = false
  223. if (this.activeName === 'combination') {
  224. if (Object.keys(this.focus).length) {
  225. this.$emit('setComponent', this.focus)
  226. }
  227. } else if (['remote'].includes(this.activeName)) {
  228. if (_.isEmpty(this.focus)) {
  229. return
  230. }
  231. this.$emit('setRemoteComponent', this.focus)
  232. } if (['bizComponent'].includes(this.activeName)) {
  233. let config = {}
  234. if (_.isEmpty(this.focus)) {
  235. return
  236. }
  237. config.code = this.focus.code
  238. config.name = this.focus.name
  239. config = getRemoteComponentConfig(this.focus.code, this.focus.name)
  240. this.$emit('setRemoteComponent', config)
  241. }
  242. },
  243. getDataList() {
  244. this.loading = true
  245. this.$dataRoomAxios.get('/bigScreen/design/page', {
  246. parentCode: this.code || null,
  247. current: this.current,
  248. size: this.size,
  249. searchKey: this.searchKey,
  250. type: 'component'
  251. })
  252. .then((data) => {
  253. this.list = data.list
  254. this.totalCount = data.totalCount
  255. })
  256. .finally(() => {
  257. this.loading = false
  258. })
  259. getBizComponentPage({
  260. parentCode: this.code || null,
  261. current: this.current,
  262. size: this.size,
  263. searchKey: this.searchKey,
  264. name: this.name
  265. }).then((data) => {
  266. this.bizComponentList = data.list
  267. this.totalCount = data.totalCount
  268. this.loading = false
  269. })
  270. },
  271. // 获取目录的列表
  272. getCatalogList() {
  273. const url = this.activeName === 'combination' ? '/bigScreen/type/list/componentCatalog' : '/bigScreen/type/list/bizComponentCatalog'
  274. get(url)
  275. .then((data) => {
  276. this.options = data
  277. })
  278. .catch(() => { })
  279. }
  280. }
  281. }
  282. </script>
  283. <style lang="scss" scoped>
  284. @import '../../assets/style/bsTheme.scss';
  285. .big-screen-list-wrap {
  286. .el-select {
  287. display: inline-block !important;
  288. position: relative !important;
  289. width: auto !important;
  290. }
  291. position: relative;
  292. height: 100%;
  293. // margin:0 16px;
  294. // padding: 16px;
  295. margin-bottom: 56px;
  296. color: #9ea9b2;
  297. background-color: var(--bs-background-2) !important;
  298. .top-search-wrap {
  299. display: flex;
  300. align-items: center;
  301. justify-content: flex-end;
  302. margin-bottom: 12px;
  303. .el-input {
  304. width: 200px;
  305. margin-right: 20px;
  306. ::v-deep.el-input__inner {
  307. background-color: var(--bs-background-1) !important;
  308. }
  309. }
  310. .el-select {
  311. margin-right: 20px;
  312. ::v-deep.el-input__inner {
  313. background-color: var(--bs-background-1) !important;
  314. }
  315. }
  316. }
  317. .list-wrap {
  318. /* display: grid; */
  319. overflow: auto;
  320. // 间隙自适应
  321. justify-content: space-around;
  322. // max-height: calc(100vh - 270px);
  323. display: grid;
  324. grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  325. grid-gap: 15px;
  326. // ::v-deep .el-loading-mask {
  327. // display: flex;
  328. // align-items: center;
  329. // justify-content: center;
  330. // height: calc(100vh - 260px) !important;
  331. // z-index: 999;
  332. // top: 50px;
  333. // }
  334. .big-screen-card-wrap {
  335. position: relative;
  336. height: 230px;
  337. cursor: pointer;
  338. &:hover {
  339. .screen-card__hover {
  340. height: 180px;
  341. }
  342. }
  343. .screen-card__hover {
  344. position: absolute;
  345. z-index: 999;
  346. top: 0;
  347. right: 0;
  348. left: 0;
  349. display: flex;
  350. overflow: hidden;
  351. align-items: center;
  352. justify-content: center;
  353. height: 0;
  354. transition: height 0.4s;
  355. background: #00000099;
  356. }
  357. .focus {
  358. color: var(--bs-el-text) !important;
  359. border: 1px solid var(--bs-el-color-primary) !important;
  360. }
  361. .big-screen-card-inner {
  362. overflow: hidden;
  363. width: 100%;
  364. height: 100%;
  365. cursor: pointer;
  366. background-color: var(--bs-background-2);
  367. box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
  368. color: var(--bs-el-title);
  369. border: 1px solid var(--bs-background-1);
  370. &:hover {
  371. color: var(--bs-el-text);
  372. border: 1px solid var(--bs-el-color-primary);
  373. }
  374. .add-big-screen-card-text {
  375. color: var(--bs-el-color-primary);
  376. font-size: 24px;
  377. }
  378. .big-screen-card-img {
  379. width: 100%;
  380. height: 180px;
  381. img {
  382. width: 100%;
  383. height: 100%;
  384. object-fit: cover;
  385. }
  386. ::v-deep.image-slot {
  387. height: 100%;
  388. background-color: var(--bs-background-2);
  389. display: flex;
  390. align-items: center;
  391. justify-content: center;
  392. }
  393. ::v-deep.el-image__error {
  394. background-color: #1d1d1d;
  395. }
  396. }
  397. .big-screen-bottom {
  398. display: flex;
  399. align-items: center;
  400. flex-direction: row;
  401. justify-content: space-between;
  402. box-sizing: border-box;
  403. width: 100%;
  404. /*height: 26px;*/
  405. padding: 0 10px;
  406. height: calc(100% - 180px);
  407. color: var(--bs-el-title);
  408. background-color: var(--bs-background-2);
  409. .left-bigscreen-title {
  410. font-size: 14px;
  411. overflow: hidden;
  412. width: 120px;
  413. white-space: nowrap;
  414. text-overflow: ellipsis;
  415. }
  416. .right-bigscreen-time-title {
  417. font-size: 14px;
  418. overflow: hidden;
  419. width: 140px;
  420. white-space: nowrap;
  421. text-overflow: ellipsis;
  422. }
  423. }
  424. .big-screen-card-text {
  425. font-size: 14px;
  426. padding: 10px;
  427. text-align: center;
  428. color: #333;
  429. }
  430. }
  431. .big-screen-card-inner-add {
  432. display: flex;
  433. align-items: center;
  434. justify-content: center;
  435. }
  436. }
  437. }
  438. .el-loading-parent--relative {
  439. position: unset !important;
  440. }
  441. .footer-pagination-wrap {
  442. margin-top: 16px;
  443. position: absolute;
  444. width: 100%;
  445. }
  446. }
  447. .bs-pagination {
  448. ::v-deep .el-input__inner {
  449. width: 110px !important;
  450. border: none;
  451. background: var(--bs-el-background-1);
  452. }
  453. }
  454. .empty {
  455. width: 100%;
  456. height: 70%;
  457. min-height: 300px;
  458. display: flex;
  459. justify-content: center;
  460. align-items: center;
  461. }
  462. ::v-deep .el-tabs__item {
  463. color: var(--bs-el-text);
  464. }
  465. .error-img-text {
  466. overflow: hidden;
  467. padding: 0 10px;
  468. white-space: nowrap;
  469. text-overflow: ellipsis;
  470. -o-text-overflow: ellipsis;
  471. }
  472. ::v-deep .el-tabs__nav-wrap {
  473. &:after {
  474. display: none;
  475. }
  476. }
  477. </style>