index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. <template>
  2. <div class="big-screen-list-wrap">
  3. <div class="internal-box">
  4. <div class="top-search-wrap">
  5. <el-select
  6. v-if="catalogInfo !== 'system'"
  7. v-model="catalogCode"
  8. class="bs-el-select"
  9. popper-class="bs-el-select"
  10. placeholder="请选择分组"
  11. clearable
  12. @change="reSearch"
  13. >
  14. <el-option
  15. v-for="item in catalogList"
  16. :key="item.code"
  17. :label="item.name"
  18. :value="item.code"
  19. />
  20. </el-select>
  21. <el-input
  22. v-model="searchKey"
  23. class="bs-el-input"
  24. placeholder="请输入组件名称"
  25. prefix-icon="el-icon-search"
  26. clearable
  27. @clear="reSearch"
  28. @keyup.enter.native="reSearch"
  29. />
  30. <el-button
  31. type="primary"
  32. @click="reSearch"
  33. >
  34. 搜索
  35. </el-button>
  36. <el-button
  37. v-if="catalogInfo !== 'system'"
  38. type="primary"
  39. @click="catalogManage"
  40. >
  41. 分组管理
  42. </el-button>
  43. </div>
  44. <div
  45. v-loading="loading"
  46. class="list-wrap bs-scrollbar"
  47. element-loading-text="加载中"
  48. :style="{
  49. display: gridComputed ? 'grid' : 'flex',
  50. justifyContent: gridComputed ? 'space-around' : 'flex-start'
  51. }"
  52. >
  53. <!-- 第一个是新增大屏卡片 -->
  54. <div
  55. v-if="catalogInfo !== 'system'"
  56. class="big-screen-card-wrap"
  57. :style="{
  58. width: gridComputed ? 'auto' : '290px'
  59. }"
  60. @click="add"
  61. >
  62. <div class="big-screen-card-inner big-screen-card-inner-add">
  63. <div class="add-big-screen-card">
  64. <div class="add-big-screen-card-inner">
  65. <div class="add-big-screen-card-text">
  66. 新建组件
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. <!-- 后面遍历 list -->
  73. <div
  74. v-for="screen in list"
  75. :key="screen.id"
  76. class="big-screen-card-wrap"
  77. :style="{
  78. width: gridComputed ? 'auto' : '290px'
  79. }"
  80. >
  81. <div class="big-screen-card-inner">
  82. <div class="screen-card__hover">
  83. <div class="screen-card__hover-box">
  84. <div class="preview">
  85. <div
  86. class="screen-card__oper-label circle"
  87. @click="preview(screen)"
  88. >
  89. <span>预览</span>
  90. </div>
  91. <div
  92. v-if="catalogInfo !== 'system'"
  93. class="circle"
  94. @click="design(screen)"
  95. >
  96. <span>设计</span>
  97. </div>
  98. <div
  99. v-if="catalogInfo !== 'system'"
  100. class="circle"
  101. @click="edit(screen)"
  102. >
  103. <span>编辑</span>
  104. </div>
  105. <div
  106. v-if="catalogInfo !== 'system'"
  107. class="circle"
  108. @click="copy(screen)"
  109. >
  110. <span>复制</span>
  111. </div>
  112. <div
  113. v-if="catalogInfo !== 'system'"
  114. class="circle"
  115. @click="del(screen)"
  116. >
  117. <span>删除</span>
  118. </div>
  119. </div>
  120. </div>
  121. </div>
  122. <div class="big-screen-card-img">
  123. <el-image
  124. :src="catalogInfo !== 'system' ? screen.coverPicture : screen.img"
  125. fit="fill"
  126. style="width: 100%; height: 100%"
  127. >
  128. <div
  129. slot="placeholder"
  130. class="image-slot"
  131. >
  132. 加载中···
  133. </div>
  134. <div
  135. slot="error"
  136. class="image-slot"
  137. style="font-size: 20px"
  138. >
  139. <div class="error-img-text">
  140. {{ catalogInfo !== 'system'? screen.name : screen.title }}
  141. </div>
  142. </div>
  143. </el-image>
  144. </div>
  145. <div class="big-screen-bottom">
  146. <div
  147. class="left-bigscreen-title"
  148. :title="catalogInfo !== 'system'? screen.name : screen.title"
  149. >
  150. {{ catalogInfo !== 'system'? screen.name : screen.title }}
  151. </div>
  152. </div>
  153. </div>
  154. </div>
  155. </div>
  156. <div
  157. v-if="catalogInfo !== 'system'"
  158. class="footer-pagination-wrap"
  159. >
  160. <!-- <div class="footer-pagination-wrap-text">
  161. 总共 {{ totalCount }} 个项目
  162. </div> -->
  163. <div class="bs-pagination">
  164. <el-pagination
  165. class="bs-el-pagination"
  166. popper-class="bs-el-pagination"
  167. background
  168. layout="total, prev, pager, next, sizes"
  169. :page-size="size"
  170. prev-text="上一页"
  171. next-text="下一页"
  172. :total="totalCount"
  173. :page-sizes="[10, 20, 50, 100]"
  174. :current-page="current"
  175. @current-change="currentChangeHandle"
  176. @size-change="sizeChangeHandle"
  177. />
  178. </div>
  179. </div>
  180. </div>
  181. <!-- 新增或编辑弹窗 -->
  182. <EditForm
  183. v-if="catalogInfo !== 'system'"
  184. ref="EditForm"
  185. :type="catalogInfo"
  186. @refreshData="reSearch"
  187. />
  188. <CatalogEditForm
  189. v-if="catalogInfo !== 'system'"
  190. ref="CatalogEditForm"
  191. :catalog-type="catalogType"
  192. @updateCatalogList="updateCatalogList"
  193. />
  194. </div>
  195. </template>
  196. <script>
  197. import { get, post } from 'data-room-ui/js/utils/http'
  198. import { pageMixins } from 'data-room-ui/js/mixins/page'
  199. import EditForm from './EditForm.vue'
  200. import CatalogEditForm from './CatalogEditForm'
  201. import innerRemoteComponents, { getRemoteComponents } from 'data-room-ui/RemoteComponents/remoteComponentsList'
  202. export default {
  203. name: 'BigScreenList',
  204. mixins: [pageMixins],
  205. props: {
  206. catalogInfo: {
  207. type: String,
  208. default: ''
  209. }
  210. },
  211. components: { EditForm, CatalogEditForm },
  212. data () {
  213. return {
  214. name: '',
  215. catalogVisible: false,
  216. templateLoading: false,
  217. searchKey: '',
  218. list: [],
  219. defaultImg: require('./images/defaultImg.png'),
  220. loading: false,
  221. catalogList: [], // 分组列表
  222. catalogCode: ''
  223. }
  224. },
  225. computed: {
  226. catalogType () {
  227. if (this.catalogInfo === 'component') {
  228. return 'componentCatalog'
  229. } else {
  230. return 'bizComponentCatalog'
  231. }
  232. },
  233. code () {
  234. return ''
  235. },
  236. gridComputed () {
  237. return this.list.length > 2
  238. }
  239. },
  240. watch: {
  241. catalogInfo () {
  242. this.reset()
  243. this.init()
  244. },
  245. catalogCode (value) {
  246. this.reSearch()
  247. }
  248. },
  249. mounted () {
  250. this.init()
  251. },
  252. methods: {
  253. reset () {
  254. this.searchKey = ''
  255. this.current = 1
  256. this.size = 10
  257. this.catalogCode = ''
  258. this.init()
  259. },
  260. init () {
  261. if (this.catalogInfo !== 'system') {
  262. this.getDataList()
  263. this.getCatalogList()
  264. } else {
  265. this.list = []
  266. this.list = [...innerRemoteComponents, ...getRemoteComponents()]
  267. }
  268. },
  269. updateCatalogList (list) {
  270. this.catalogList = list
  271. },
  272. reSearch () {
  273. if (this.catalogInfo !== 'system') {
  274. this.current = 1
  275. this.getDataList()
  276. } else {
  277. const arr = [...innerRemoteComponents, ...getRemoteComponents()]
  278. this.list = arr?.filter((item) => item.title.indexOf(this.searchKey) !== -1)
  279. }
  280. },
  281. catalogManage () {
  282. this.$refs.CatalogEditForm.formVisible = true
  283. },
  284. // 获取分组列表
  285. getCatalogList () {
  286. this.$dataRoomAxios.get(`/bigScreen/type/list/${this.catalogType}`)
  287. .then((data) => {
  288. this.catalogList = data
  289. })
  290. .catch(() => {})
  291. },
  292. getDataList () {
  293. this.loading = true
  294. if (this.catalogInfo === 'component') {
  295. this.$dataRoomAxios.get('/bigScreen/design/page', {
  296. parentCode: this.catalogCode || null,
  297. current: this.current,
  298. size: this.size,
  299. searchKey: this.searchKey,
  300. type: 'component'
  301. })
  302. .then((data) => {
  303. this.list = data.list
  304. this.totalCount = data.totalCount
  305. })
  306. .finally(() => {
  307. this.loading = false
  308. })
  309. } else {
  310. this.$dataRoomAxios.get('/bigScreen/bizComponent/page', {
  311. current: this.current,
  312. size: this.size,
  313. // searchKey: this.searchKey,
  314. name: this.searchKey,
  315. type: this.catalogCode || null
  316. })
  317. .then((data) => {
  318. this.list = data.list
  319. this.totalCount = data.totalCount
  320. })
  321. .finally(() => {
  322. this.loading = false
  323. })
  324. }
  325. },
  326. preview (screen) {
  327. let path = ''
  328. let query = {
  329. code: screen.code
  330. }
  331. if (this.catalogInfo === 'component') {
  332. path = (window.BS_CONFIG?.routers?.previewUrl || '/big-screen/preview')
  333. } else {
  334. path = (window.BS_CONFIG?.routers?.bizComponentPreviewUrl || 'big-screen-biz-component-preview')
  335. }
  336. if (this.catalogInfo === 'system') {
  337. query = {
  338. dirName: screen.customize.vueSysComponentDirName
  339. }
  340. }
  341. const { href } = this.$router.resolve({
  342. path, // 这里写的是要跳转的路由地址
  343. query
  344. })
  345. window.open(href, '_blank')
  346. },
  347. design (screen) {
  348. const path = this.catalogInfo === 'component' ? (window.BS_CONFIG?.routers?.designUrl || '/big-screen/design') : (window.BS_CONFIG?.routers?.bizComponentDesignUrl || 'big-screen-biz-component-design')
  349. const { href } = this.$router.resolve({
  350. path,
  351. query: {
  352. code: screen.code
  353. }
  354. })
  355. window.open(href, '_self')
  356. },
  357. add () {
  358. const page = {
  359. code: '',
  360. type: this.catalogInfo === 'component' ? 'bigScreen' : 'bizComponent'
  361. }
  362. this.$refs.EditForm.init(page, this.catalogCode)
  363. },
  364. edit (screen) {
  365. this.$refs.EditForm.init(screen, this.catalogCode)
  366. },
  367. del (screen) {
  368. this.$confirm('确定删除该组件', '提示', {
  369. confirmButtonText: '确定',
  370. cancelButtonText: '取消',
  371. type: 'warning',
  372. customClass: 'bs-el-message-box'
  373. })
  374. .then(async () => {
  375. const url = this.catalogInfo === 'component' ? `/bigScreen/design/delete/${screen.code}` : `/bigScreen/bizComponent/delete/${screen.id}`
  376. post(url)
  377. .then(() => {
  378. this.$message({
  379. type: 'success',
  380. message: '删除成功'
  381. })
  382. this.getDataList()
  383. })
  384. .catch(() => {
  385. this.$message({
  386. type: 'error',
  387. message: '删除失败!'
  388. })
  389. })
  390. })
  391. .catch()
  392. },
  393. copy (screen) {
  394. const url = this.catalogInfo === 'component' ? `/bigScreen/design/copy/${screen.code}` : `/bigScreen/bizComponent/copy/${screen.code}`
  395. this.$confirm('确定复制该组件', '提示', {
  396. confirmButtonText: '确定',
  397. cancelButtonText: '取消',
  398. type: 'warning',
  399. customClass: 'bs-el-message-box'
  400. })
  401. .then(async () => {
  402. post(url)
  403. .then(() => {
  404. this.$message({
  405. type: 'success',
  406. message: '复制成功'
  407. })
  408. this.getDataList()
  409. })
  410. .catch(() => {
  411. this.$message({
  412. type: 'error',
  413. message: '复制失败!'
  414. })
  415. })
  416. })
  417. .catch((e) => {
  418. console.error(e)
  419. })
  420. }
  421. }
  422. }
  423. </script>
  424. <style lang="scss" scoped>
  425. @import '../assets/style/bsTheme.scss';
  426. .big-screen-list-wrap {
  427. position: relative;
  428. height: 100%;
  429. // padding: 16px;
  430. // margin:0 16px;
  431. margin-left: 16px;
  432. color: #9ea9b2;
  433. background-color: var(--bs-background-2) !important;
  434. .internal-box{
  435. height: calc(100% - 32px);
  436. padding: 16px;
  437. }
  438. .top-search-wrap {
  439. display: flex;
  440. align-items: center;
  441. justify-content: flex-end;
  442. margin-bottom: 12px;
  443. .el-input {
  444. width: 200px;
  445. margin-right: 20px;
  446. ::v-deep.el-input__inner {
  447. background-color: var(--bs-background-1) !important;
  448. }
  449. }
  450. .el-select {
  451. margin-right: 20px;
  452. ::v-deep.el-input__inner {
  453. background-color: var(--bs-background-1) !important;
  454. }
  455. }
  456. }
  457. .list-wrap {
  458. /* display: grid; */
  459. overflow: auto;
  460. padding-right: 5px;
  461. // 间隙自适应
  462. justify-content: space-around;
  463. // max-height: calc(100vh - 304px);
  464. max-height: calc(100% - 90px);
  465. display: grid;
  466. grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  467. grid-gap: 15px;
  468. padding-bottom: 10px;
  469. // ::v-deep .el-loading-mask {
  470. // display: flex;
  471. // align-items: center;
  472. // justify-content: center;
  473. // height: calc(100vh - 260px) !important;
  474. // z-index: 999;
  475. // top: 50px;
  476. // }
  477. .big-screen-card-wrap {
  478. position: relative;
  479. height: 180px;
  480. cursor: pointer;
  481. &:hover {
  482. .screen-card__hover {
  483. height: 180px;
  484. }
  485. }
  486. .screen-card__hover {
  487. position: absolute;
  488. z-index: 999;
  489. top: 0;
  490. right: 0;
  491. left: 0;
  492. display: flex;
  493. overflow: hidden;
  494. align-items: center;
  495. justify-content: center;
  496. height: 0;
  497. transition: height 0.4s;
  498. background: #00000099;
  499. .screen-card__hover-box {
  500. position: absolute;
  501. width: 100%;
  502. height: 100%;
  503. background: #00000080;
  504. display: flex;
  505. overflow: hidden;
  506. align-items: center;
  507. justify-content: center;
  508. }
  509. .preview {
  510. display: flex;
  511. flex-direction: row;
  512. justify-content: space-evenly;
  513. width: 100%;
  514. cursor: pointer;
  515. color: var(--bs-el-color-primary);
  516. .circle {
  517. position: relative;
  518. display: flex;
  519. align-items: center;
  520. justify-content: center;
  521. width: 40px;
  522. height: 40px;
  523. border: 1px solid var(--bs-el-color-primary);
  524. border-radius: 50%;
  525. &:hover {
  526. color: #fff;
  527. background: var(--bs-el-color-primary);
  528. }
  529. span {
  530. font-size: 12px;
  531. }
  532. }
  533. }
  534. }
  535. .big-screen-card-inner {
  536. overflow: hidden;
  537. width: 100%;
  538. height: 100%;
  539. cursor: pointer;
  540. background-color: var(--bs-background-2);
  541. box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
  542. color: var(--bs-el-title);
  543. border: 1px solid var(--bs-background-1);
  544. &:hover {
  545. color: var(--bs-el-text);
  546. border: 1px solid var(--bs-el-color-primary);
  547. }
  548. .add-big-screen-card-text {
  549. color: var(--bs-el-color-primary);
  550. font-size: 24px;
  551. }
  552. .big-screen-card-img {
  553. width: 100%;
  554. height: 150px;
  555. img {
  556. width: 100%;
  557. height: 100%;
  558. object-fit: cover;
  559. }
  560. ::v-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. ::v-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% - 150px);
  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. // position: absolute;
  617. // bottom: 16px;
  618. // right: 16px;
  619. // display: flex;
  620. // align-items: center;
  621. // justify-content: flex-end;
  622. // width: 100%;
  623. position: absolute;
  624. bottom: 16px;
  625. right: 12px;
  626. // padding: 0 16px;
  627. }
  628. .error-img-text{
  629. overflow:hidden;
  630. padding:0 10px;
  631. white-space: nowrap;
  632. text-overflow: ellipsis;
  633. -o-text-overflow:ellipsis;
  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. </style>