index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  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 'packages/js/utils/http'
  198. import { pageMixins } from 'packages/js/mixins/page'
  199. import EditForm from './EditForm.vue'
  200. import CatalogEditForm from './CatalogEditForm'
  201. import innerRemoteComponents, { getRemoteComponents } from 'packages/RemoteComponents/remoteComponentsList'
  202. export default {
  203. name: 'BigScreenList',
  204. mixins: [pageMixins],
  205. props: { },
  206. components: { EditForm, CatalogEditForm },
  207. data () {
  208. return {
  209. name: '',
  210. catalogInfo: 'component',
  211. catalogVisible: false,
  212. templateLoading: false,
  213. searchKey: '',
  214. list: [],
  215. defaultImg: require('./images/defaultImg.png'),
  216. loading: false,
  217. catalogList: [], // 分组列表
  218. catalogCode: ''
  219. }
  220. },
  221. computed: {
  222. catalogType () {
  223. if (this.catalogInfo === 'component') {
  224. return 'componentCatalog'
  225. } else {
  226. return 'bizComponentCatalog'
  227. }
  228. },
  229. code () {
  230. return ''
  231. },
  232. gridComputed () {
  233. return this.list.length > 2
  234. }
  235. },
  236. watch: {
  237. $route (val) {
  238. this.catalogInfo = val.query.type || 'component'
  239. this.reset()
  240. this.init()
  241. },
  242. catalogCode (value) {
  243. this.reSearch()
  244. }
  245. },
  246. mounted () {
  247. this.catalogInfo = this.$route.query.type || 'component'
  248. this.init()
  249. },
  250. methods: {
  251. reset () {
  252. this.searchKey = ''
  253. this.current = 1
  254. this.size = 10
  255. this.catalogCode = ''
  256. this.init()
  257. },
  258. init () {
  259. if (this.catalogInfo !== 'system') {
  260. this.getDataList()
  261. this.getCatalogList()
  262. } else {
  263. this.list = []
  264. this.list = [...innerRemoteComponents, ...getRemoteComponents()]
  265. }
  266. },
  267. updateCatalogList (list) {
  268. this.catalogList = list
  269. },
  270. reSearch () {
  271. if (this.catalogInfo !== 'system') {
  272. this.current = 1
  273. this.getDataList()
  274. } else {
  275. const arr = [...innerRemoteComponents, ...getRemoteComponents()]
  276. this.list = arr?.filter((item) => item.title.indexOf(this.searchKey) !== -1)
  277. }
  278. },
  279. catalogManage () {
  280. this.$refs.CatalogEditForm.formVisible = true
  281. },
  282. // 获取分组列表
  283. getCatalogList () {
  284. get(`/bigScreen/type/list/${this.catalogType}`)
  285. .then((data) => {
  286. this.catalogList = data
  287. })
  288. .catch(() => {})
  289. },
  290. getDataList () {
  291. this.loading = true
  292. if (this.catalogInfo === 'component') {
  293. get('/bigScreen/design/page', {
  294. parentCode: this.catalogCode || null,
  295. current: this.current,
  296. size: this.size,
  297. searchKey: this.searchKey,
  298. type: 'component'
  299. })
  300. .then((data) => {
  301. this.list = data.list
  302. this.totalCount = data.totalCount
  303. })
  304. .finally(() => {
  305. this.loading = false
  306. })
  307. } else {
  308. get('/bigScreen/bizComponent/page', {
  309. current: this.current,
  310. size: this.size,
  311. // searchKey: this.searchKey,
  312. name: this.searchKey,
  313. type: this.catalogCode || null
  314. })
  315. .then((data) => {
  316. this.list = data.list
  317. this.totalCount = data.totalCount
  318. })
  319. .finally(() => {
  320. this.loading = false
  321. })
  322. }
  323. },
  324. preview (screen) {
  325. let path = ''
  326. let query = {
  327. code: screen.code
  328. }
  329. if (this.catalogInfo === 'component') {
  330. path = (window.BS_CONFIG?.routers?.previewUrl || '/big-screen/preview')
  331. } else {
  332. path = (window.BS_CONFIG?.routers?.bizComponentPreviewUrl || 'big-screen-biz-component-preview')
  333. }
  334. if (this.catalogInfo === 'system') {
  335. query = {
  336. dirName: screen.customize.vueSysComponentDirName
  337. }
  338. }
  339. const { href } = this.$router.resolve({
  340. path, // 这里写的是要跳转的路由地址
  341. query
  342. })
  343. window.open(href, '_blank')
  344. },
  345. design (screen) {
  346. const path = this.catalogInfo === 'component' ? (window.BS_CONFIG?.routers?.designUrl || '/big-screen/design') : (window.BS_CONFIG?.routers?.bizComponentDesignUrl || 'big-screen-biz-component-design')
  347. const { href } = this.$router.resolve({
  348. path,
  349. query: {
  350. code: screen.code
  351. }
  352. })
  353. window.open(href, '_self')
  354. },
  355. add () {
  356. const page = {
  357. code: '',
  358. type: this.catalogInfo === 'component' ? 'bigScreen' : 'bizComponent'
  359. }
  360. this.$refs.EditForm.init(page, this.catalogCode)
  361. },
  362. edit (screen) {
  363. this.$refs.EditForm.init(screen, this.catalogCode)
  364. },
  365. del (screen) {
  366. this.$confirm('确定删除该组件', '提示', {
  367. confirmButtonText: '确定',
  368. cancelButtonText: '取消',
  369. type: 'warning',
  370. customClass: 'bs-el-message-box'
  371. })
  372. .then(async () => {
  373. const url = this.catalogInfo === 'component' ? `/bigScreen/design/delete/${screen.code}` : `/bigScreen/bizComponent/delete/${screen.id}`
  374. post(url)
  375. .then(() => {
  376. this.$message({
  377. type: 'success',
  378. message: '删除成功'
  379. })
  380. this.getDataList()
  381. })
  382. .catch(() => {
  383. this.$message({
  384. type: 'error',
  385. message: '删除失败!'
  386. })
  387. })
  388. })
  389. .catch()
  390. },
  391. copy (screen) {
  392. const url = this.catalogInfo === 'component' ? `/bigScreen/design/copy/${screen.code}` : `/bigScreen/bizComponent/copy/${screen.code}`
  393. this.$confirm('确定复制该组件', '提示', {
  394. confirmButtonText: '确定',
  395. cancelButtonText: '取消',
  396. type: 'warning',
  397. customClass: 'bs-el-message-box'
  398. })
  399. .then(async () => {
  400. post(url)
  401. .then(() => {
  402. this.$message({
  403. type: 'success',
  404. message: '复制成功'
  405. })
  406. this.getDataList()
  407. })
  408. .catch(() => {
  409. this.$message({
  410. type: 'error',
  411. message: '复制失败!'
  412. })
  413. })
  414. })
  415. .catch((e) => {
  416. console.error(e)
  417. })
  418. }
  419. }
  420. }
  421. </script>
  422. <style lang="scss" scoped>
  423. @import '../assets/style/bsTheme.scss';
  424. .big-screen-list-wrap {
  425. position: relative;
  426. height: 100%;
  427. // padding: 16px;
  428. // margin:0 16px;
  429. margin-left: 16px;
  430. color: #9ea9b2;
  431. background-color: var(--bs-background-2) !important;
  432. .internal-box{
  433. height: calc(100% - 32px);
  434. padding: 16px;
  435. }
  436. .top-search-wrap {
  437. display: flex;
  438. align-items: center;
  439. justify-content: flex-end;
  440. margin-bottom: 12px;
  441. .el-input {
  442. width: 200px;
  443. margin-right: 20px;
  444. /deep/.el-input__inner {
  445. background-color: var(--bs-background-1) !important;
  446. }
  447. }
  448. .el-select {
  449. margin-right: 20px;
  450. /deep/.el-input__inner {
  451. background-color: var(--bs-background-1) !important;
  452. }
  453. }
  454. }
  455. .list-wrap {
  456. /* display: grid; */
  457. overflow: auto;
  458. padding-right: 5px;
  459. // 间隙自适应
  460. justify-content: space-around;
  461. // max-height: calc(100vh - 304px);
  462. max-height: calc(100% - 90px);
  463. display: grid;
  464. grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  465. grid-gap: 15px;
  466. padding-bottom: 10px;
  467. // /deep/ .el-loading-mask {
  468. // display: flex;
  469. // align-items: center;
  470. // justify-content: center;
  471. // height: calc(100vh - 260px) !important;
  472. // z-index: 999;
  473. // top: 50px;
  474. // }
  475. .big-screen-card-wrap {
  476. position: relative;
  477. height: 180px;
  478. cursor: pointer;
  479. &:hover {
  480. .screen-card__hover {
  481. height: 180px;
  482. }
  483. }
  484. .screen-card__hover {
  485. position: absolute;
  486. z-index: 999;
  487. top: 0;
  488. right: 0;
  489. left: 0;
  490. display: flex;
  491. overflow: hidden;
  492. align-items: center;
  493. justify-content: center;
  494. height: 0;
  495. transition: height 0.4s;
  496. background: #00000099;
  497. .screen-card__hover-box {
  498. position: absolute;
  499. width: 100%;
  500. height: 100%;
  501. background: #00000080;
  502. display: flex;
  503. overflow: hidden;
  504. align-items: center;
  505. justify-content: center;
  506. }
  507. .preview {
  508. display: flex;
  509. flex-direction: row;
  510. justify-content: space-evenly;
  511. width: 100%;
  512. cursor: pointer;
  513. color: var(--bs-el-color-primary);
  514. .circle {
  515. position: relative;
  516. display: flex;
  517. align-items: center;
  518. justify-content: center;
  519. width: 40px;
  520. height: 40px;
  521. border: 1px solid var(--bs-el-color-primary);
  522. border-radius: 50%;
  523. &:hover {
  524. color: #fff;
  525. background: var(--bs-el-color-primary);
  526. }
  527. span {
  528. font-size: 12px;
  529. }
  530. }
  531. }
  532. }
  533. .big-screen-card-inner {
  534. overflow: hidden;
  535. width: 100%;
  536. height: 100%;
  537. cursor: pointer;
  538. background-color: var(--bs-background-2);
  539. box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
  540. color: var(--bs-el-title);
  541. border: 1px solid var(--bs-background-1);
  542. &:hover {
  543. color: var(--bs-el-text);
  544. border: 1px solid var(--bs-el-color-primary);
  545. }
  546. .add-big-screen-card-text {
  547. color: var(--bs-el-color-primary);
  548. font-size: 24px;
  549. }
  550. .big-screen-card-img {
  551. width: 100%;
  552. height: 150px;
  553. img {
  554. width: 100%;
  555. height: 100%;
  556. object-fit: cover;
  557. }
  558. /deep/.image-slot {
  559. height: 100%;
  560. background-color: var(--bs-background-2);
  561. display: flex;
  562. align-items: center;
  563. justify-content: center;
  564. }
  565. /deep/.el-image__error {
  566. background-color: #1d1d1d;
  567. }
  568. }
  569. .big-screen-bottom {
  570. display: flex;
  571. align-items: center;
  572. flex-direction: row;
  573. justify-content: space-between;
  574. box-sizing: border-box;
  575. width: 100%;
  576. /*height: 26px;*/
  577. padding: 0 10px;
  578. height: calc(100% - 150px);
  579. color: var(--bs-el-title);
  580. background-color: var(--bs-background-2);
  581. .left-bigscreen-title {
  582. font-size: 14px;
  583. overflow: hidden;
  584. width: 120px;
  585. white-space: nowrap;
  586. text-overflow: ellipsis;
  587. }
  588. .right-bigscreen-time-title {
  589. font-size: 14px;
  590. overflow: hidden;
  591. width: 140px;
  592. white-space: nowrap;
  593. text-overflow: ellipsis;
  594. }
  595. }
  596. .big-screen-card-text {
  597. font-size: 14px;
  598. padding: 10px;
  599. text-align: center;
  600. color: #333;
  601. }
  602. }
  603. .big-screen-card-inner-add {
  604. display: flex;
  605. align-items: center;
  606. justify-content: center;
  607. }
  608. }
  609. }
  610. .el-loading-parent--relative {
  611. position: unset !important;
  612. }
  613. .footer-pagination-wrap {
  614. // position: absolute;
  615. // bottom: 16px;
  616. // right: 16px;
  617. // display: flex;
  618. // align-items: center;
  619. // justify-content: flex-end;
  620. // width: 100%;
  621. position: absolute;
  622. bottom: 16px;
  623. right: 12px;
  624. // padding: 0 16px;
  625. }
  626. .error-img-text{
  627. overflow:hidden;
  628. padding:0 10px;
  629. white-space: nowrap;
  630. text-overflow: ellipsis;
  631. -o-text-overflow:ellipsis;
  632. }
  633. }
  634. .bs-pagination {
  635. ::v-deep .el-input__inner {
  636. width: 110px !important;
  637. border: none;
  638. background: var(--bs-el-background-1);
  639. }
  640. }
  641. </style>