index.vue 17 KB

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