index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  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. filterable
  12. clearable
  13. @change="reSearch"
  14. >
  15. <el-option
  16. v-for="item in catalogList"
  17. :key="item.code"
  18. :label="item.name"
  19. :value="item.code"
  20. />
  21. </el-select>
  22. <el-input
  23. v-model="searchKey"
  24. class="bs-el-input"
  25. placeholder="请输入组件名称"
  26. prefix-icon="el-icon-search"
  27. clearable
  28. @clear="reSearch"
  29. @keyup.enter.native="reSearch"
  30. />
  31. <el-button
  32. type="primary"
  33. @click="reSearch"
  34. >
  35. 搜索
  36. </el-button>
  37. <el-button
  38. v-if="catalogInfo !== 'system'"
  39. type="primary"
  40. @click="catalogManage"
  41. >
  42. 分组管理
  43. </el-button>
  44. </div>
  45. <div
  46. v-loading="loading"
  47. class="list-wrap bs-scrollbar"
  48. element-loading-text="加载中"
  49. :style="{
  50. display: gridComputed ? 'grid' : 'flex',
  51. justifyContent: gridComputed ? 'space-around' : 'flex-start'
  52. }"
  53. >
  54. <!-- 第一个是新增大屏卡片 -->
  55. <div
  56. v-if="catalogInfo !== 'system'"
  57. class="big-screen-card-wrap"
  58. :style="{
  59. width: gridComputed ? 'auto' : '290px'
  60. }"
  61. @click="add"
  62. >
  63. <div class="big-screen-card-inner big-screen-card-inner-add">
  64. <div class="add-big-screen-card">
  65. <div class="add-big-screen-card-inner">
  66. <div class="add-big-screen-card-text">
  67. 新增组件
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. <!-- 后面遍历 list -->
  74. <div
  75. v-for="screen in list"
  76. :key="screen.id"
  77. class="big-screen-card-wrap"
  78. :style="{
  79. width: gridComputed ? 'auto' : '290px'
  80. }"
  81. >
  82. <div class="big-screen-card-inner">
  83. <div class="screen-card__hover">
  84. <div class="screen-card__hover-box">
  85. <div class="preview">
  86. <div
  87. class="screen-card__oper-label circle"
  88. @click="preview(screen)"
  89. >
  90. <span>预览</span>
  91. </div>
  92. <div
  93. v-if="catalogInfo !== 'system'"
  94. class="circle"
  95. @click="design(screen)"
  96. >
  97. <span>设计</span>
  98. </div>
  99. <div
  100. v-if="catalogInfo !== 'system'"
  101. class="circle"
  102. @click="edit(screen)"
  103. >
  104. <span>编辑</span>
  105. </div>
  106. <div
  107. v-if="catalogInfo !== 'system'"
  108. class="circle"
  109. @click="copy(screen)"
  110. >
  111. <span>复制</span>
  112. </div>
  113. <div
  114. v-if="catalogInfo !== 'system'"
  115. class="circle"
  116. @click="del(screen)"
  117. >
  118. <span>删除</span>
  119. </div>
  120. </div>
  121. </div>
  122. </div>
  123. <div class="big-screen-card-img">
  124. <el-image
  125. :src="catalogInfo !== 'system' ? getCoverPicture(screen.coverPicture) : screen.img"
  126. fit="fill"
  127. style="width: 100%; height: 100%"
  128. >
  129. <div
  130. slot="placeholder"
  131. class="image-slot"
  132. >
  133. 加载中···
  134. </div>
  135. <div
  136. slot="error"
  137. class="image-slot"
  138. style="font-size: 20px"
  139. >
  140. <div class="error-img-text">
  141. {{ catalogInfo !== 'system' ? screen.name : screen.title }}
  142. </div>
  143. </div>
  144. </el-image>
  145. </div>
  146. <div class="big-screen-bottom">
  147. <div
  148. class="left-bigscreen-title"
  149. :title="catalogInfo !== 'system' ? screen.name : screen.title"
  150. >
  151. {{ catalogInfo !== 'system' ? screen.name : screen.title }}
  152. </div>
  153. </div>
  154. </div>
  155. </div>
  156. </div>
  157. <div
  158. v-if="catalogInfo !== 'system'"
  159. class="footer-pagination-wrap"
  160. >
  161. <!-- <div class="footer-pagination-wrap-text">
  162. 总共 {{ totalCount }} 个项目
  163. </div> -->
  164. <div class="bs-pagination">
  165. <el-pagination
  166. class="bs-el-pagination"
  167. popper-class="bs-el-pagination"
  168. background
  169. layout="total, prev, pager, next, sizes"
  170. :page-size="size"
  171. prev-text="上一页"
  172. next-text="下一页"
  173. :total="totalCount"
  174. :page-sizes="[10, 20, 50, 100]"
  175. :current-page="current"
  176. @current-change="currentChangeHandle"
  177. @size-change="sizeChangeHandle"
  178. />
  179. </div>
  180. </div>
  181. </div>
  182. <!-- 新增或编辑弹窗 -->
  183. <EditForm
  184. v-if="catalogInfo !== 'system'"
  185. ref="EditForm"
  186. :type="catalogInfo"
  187. @refreshData="reSearch"
  188. />
  189. <CatalogEditForm
  190. v-if="catalogInfo !== 'system'"
  191. ref="CatalogEditForm"
  192. :catalog-type="catalogType"
  193. @updateCatalogList="updateCatalogList"
  194. />
  195. </div>
  196. </template>
  197. <script>
  198. import { pageMixins } from 'data-room-ui/js/mixins/page'
  199. import { getFileUrl } from 'data-room-ui/js/utils/file'
  200. import EditForm from './EditForm.vue'
  201. import CatalogEditForm from './CatalogEditForm'
  202. import innerRemoteComponents, { getRemoteComponents } from 'data-room-ui/RemoteComponents/remoteComponentsList'
  203. export default {
  204. name: 'BigScreenList',
  205. mixins: [pageMixins],
  206. props: {
  207. catalogInfo: {
  208. type: String,
  209. default: ''
  210. }
  211. },
  212. components: { EditForm, CatalogEditForm },
  213. data () {
  214. return {
  215. name: '',
  216. catalogVisible: false,
  217. templateLoading: false,
  218. searchKey: '',
  219. list: [],
  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. // 新窗口打开
  356. // window.open(href, '_self')
  357. this.$router.push({
  358. path,
  359. query: {
  360. code: screen.code
  361. }
  362. })
  363. },
  364. add () {
  365. const page = {
  366. code: '',
  367. type: this.catalogInfo === 'component' ? 'bigScreen' : 'bizComponent'
  368. }
  369. this.$refs.EditForm.init(page, this.catalogCode)
  370. },
  371. edit (screen) {
  372. this.$refs.EditForm.init(screen, this.catalogCode)
  373. },
  374. del (screen) {
  375. this.$confirm('确定删除该组件', '提示', {
  376. confirmButtonText: '确定',
  377. cancelButtonText: '取消',
  378. type: 'warning',
  379. customClass: 'bs-el-message-box'
  380. })
  381. .then(async () => {
  382. const url = this.catalogInfo === 'component' ? `/bigScreen/design/delete/${screen.code}` : `/bigScreen/bizComponent/delete/${screen.id}`
  383. this.$dataRoomAxios.post(url)
  384. .then(() => {
  385. this.$message({
  386. type: 'success',
  387. message: '删除成功'
  388. })
  389. this.getDataList()
  390. })
  391. .catch(() => {
  392. this.$message({
  393. type: 'error',
  394. message: '删除失败!'
  395. })
  396. })
  397. })
  398. .catch()
  399. },
  400. copy (screen) {
  401. const url = this.catalogInfo === 'component' ? `/bigScreen/design/copy/${screen.code}` : `/bigScreen/bizComponent/copy/${screen.code}`
  402. this.$confirm('确定复制该组件', '提示', {
  403. confirmButtonText: '确定',
  404. cancelButtonText: '取消',
  405. type: 'warning',
  406. customClass: 'bs-el-message-box'
  407. })
  408. .then(async () => {
  409. this.$dataRoomAxios.post(url)
  410. .then(() => {
  411. this.$message({
  412. type: 'success',
  413. message: '复制成功'
  414. })
  415. this.getDataList()
  416. })
  417. .catch(() => {
  418. this.$message({
  419. type: 'error',
  420. message: '复制失败!'
  421. })
  422. })
  423. })
  424. .catch((e) => {
  425. console.error(e)
  426. })
  427. },
  428. /**
  429. * 获取封面图片,如果是相对路径则拼接上文件访问前缀地址
  430. * @param url
  431. * @returns {*}
  432. */
  433. getCoverPicture (url) {
  434. return getFileUrl(url)
  435. }
  436. }
  437. }
  438. </script>
  439. <style lang="scss" scoped>
  440. @import '../assets/style/bsTheme.scss';
  441. .big-screen-list-wrap {
  442. .el-select {
  443. display: inline-block !important;
  444. position: relative !important;
  445. width: auto !important;
  446. }
  447. position: relative;
  448. height: 100%;
  449. // padding: 16px;
  450. // margin:0 16px;
  451. margin-left: 16px;
  452. color: #9ea9b2;
  453. background-color: var(--bs-background-2) !important;
  454. .internal-box {
  455. height: calc(100% - 32px);
  456. padding: 16px;
  457. }
  458. .top-search-wrap {
  459. display: flex;
  460. align-items: center;
  461. justify-content: flex-end;
  462. margin-bottom: 12px;
  463. .el-input {
  464. width: 200px;
  465. margin-right: 20px;
  466. ::v-deep.el-input__inner {
  467. background-color: var(--bs-background-1) !important;
  468. }
  469. }
  470. .el-select {
  471. margin-right: 20px;
  472. ::v-deep.el-input__inner {
  473. background-color: var(--bs-background-1) !important;
  474. }
  475. }
  476. }
  477. .list-wrap {
  478. /* display: grid; */
  479. overflow: auto;
  480. padding-right: 5px;
  481. // 间隙自适应
  482. justify-content: space-around;
  483. // max-height: calc(100vh - 304px);
  484. max-height: calc(100% - 90px);
  485. display: grid;
  486. grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  487. grid-gap: 15px;
  488. padding-bottom: 10px;
  489. // ::v-deep .el-loading-mask {
  490. // display: flex;
  491. // align-items: center;
  492. // justify-content: center;
  493. // height: calc(100vh - 260px) !important;
  494. // z-index: 999;
  495. // top: 50px;
  496. // }
  497. .big-screen-card-wrap {
  498. position: relative;
  499. height: 180px;
  500. cursor: pointer;
  501. &:hover {
  502. .screen-card__hover {
  503. height: 180px;
  504. }
  505. }
  506. .screen-card__hover {
  507. position: absolute;
  508. z-index: 999;
  509. top: 0;
  510. right: 0;
  511. left: 0;
  512. display: flex;
  513. overflow: hidden;
  514. align-items: center;
  515. justify-content: center;
  516. height: 0;
  517. transition: height 0.4s;
  518. background: #00000099;
  519. .screen-card__hover-box {
  520. position: absolute;
  521. width: 100%;
  522. height: 100%;
  523. background: #00000080;
  524. display: flex;
  525. overflow: hidden;
  526. align-items: center;
  527. justify-content: center;
  528. }
  529. .preview {
  530. display: flex;
  531. flex-direction: row;
  532. justify-content: space-evenly;
  533. width: 100%;
  534. cursor: pointer;
  535. color: var(--bs-el-color-primary);
  536. .circle {
  537. position: relative;
  538. display: flex;
  539. align-items: center;
  540. justify-content: center;
  541. width: 40px;
  542. height: 40px;
  543. border: 1px solid var(--bs-el-color-primary);
  544. border-radius: 50%;
  545. &:hover {
  546. color: #fff;
  547. background: var(--bs-el-color-primary);
  548. }
  549. span {
  550. font-size: 12px;
  551. }
  552. }
  553. }
  554. }
  555. .big-screen-card-inner {
  556. overflow: hidden;
  557. width: 100%;
  558. height: 100%;
  559. cursor: pointer;
  560. background-color: var(--bs-background-2);
  561. box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
  562. color: var(--bs-el-title);
  563. border: 1px solid var(--bs-background-1);
  564. &:hover {
  565. color: var(--bs-el-text);
  566. border: 1px solid var(--bs-el-color-primary);
  567. }
  568. .add-big-screen-card-text {
  569. color: var(--bs-el-color-primary);
  570. font-size: 24px;
  571. }
  572. .big-screen-card-img {
  573. width: 100%;
  574. height: 150px;
  575. img {
  576. width: 100%;
  577. height: 100%;
  578. object-fit: cover;
  579. }
  580. ::v-deep.image-slot {
  581. height: 100%;
  582. background-color: var(--bs-background-2);
  583. display: flex;
  584. align-items: center;
  585. justify-content: center;
  586. }
  587. ::v-deep.el-image__error {
  588. background-color: #1d1d1d;
  589. }
  590. }
  591. .big-screen-bottom {
  592. display: flex;
  593. align-items: center;
  594. flex-direction: row;
  595. justify-content: space-between;
  596. box-sizing: border-box;
  597. width: 100%;
  598. /*height: 26px;*/
  599. padding: 0 10px;
  600. height: calc(100% - 150px);
  601. color: var(--bs-el-title);
  602. background-color: var(--bs-background-2);
  603. .left-bigscreen-title {
  604. font-size: 14px;
  605. overflow: hidden;
  606. width: 100%;
  607. white-space: nowrap;
  608. text-overflow: ellipsis;
  609. }
  610. .right-bigscreen-time-title {
  611. font-size: 14px;
  612. overflow: hidden;
  613. width: 140px;
  614. white-space: nowrap;
  615. text-overflow: ellipsis;
  616. }
  617. }
  618. .big-screen-card-text {
  619. font-size: 14px;
  620. padding: 10px;
  621. text-align: center;
  622. color: #333;
  623. }
  624. }
  625. .big-screen-card-inner-add {
  626. display: flex;
  627. align-items: center;
  628. justify-content: center;
  629. }
  630. }
  631. }
  632. .el-loading-parent--relative {
  633. position: unset !important;
  634. }
  635. .footer-pagination-wrap {
  636. position: absolute;
  637. bottom: 16px;
  638. right: 16px;
  639. }
  640. .error-img-text {
  641. overflow: hidden;
  642. padding: 0 10px;
  643. white-space: nowrap;
  644. text-overflow: ellipsis;
  645. -o-text-overflow: ellipsis;
  646. }
  647. }
  648. .bs-pagination {
  649. ::v-deep .el-input__inner {
  650. width: 110px !important;
  651. border: none;
  652. background: var(--bs-el-background-1);
  653. }
  654. }
  655. </style>