index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  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="name"
  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. catalogInfo: {
  205. type: String,
  206. default: ''
  207. }
  208. },
  209. components: { EditForm, CatalogEditForm },
  210. data () {
  211. return {
  212. name: '',
  213. catalogVisible: false,
  214. templateLoading: false,
  215. searchKey: '',
  216. list: [],
  217. defaultImg: require('./images/defaultImg.png'),
  218. loading: false,
  219. catalogList: [], // 分组列表
  220. catalogCode: ''
  221. }
  222. },
  223. computed: {
  224. catalogType () {
  225. if (this.catalogInfo === 'component') {
  226. return 'componentCatalog'
  227. } else {
  228. return 'bizComponentCatalog'
  229. }
  230. },
  231. code () {
  232. // return this.catalogInfo?.page?.code
  233. return ''
  234. },
  235. gridComputed () {
  236. return this.list.length > 2
  237. }
  238. },
  239. watch: {
  240. catalogInfo () {
  241. this.reset()
  242. this.init()
  243. },
  244. catalogCode (value) {
  245. this.reSearch()
  246. }
  247. },
  248. mounted () {
  249. this.init()
  250. },
  251. methods: {
  252. reset () {
  253. this.name = ''
  254. },
  255. init () {
  256. if (this.catalogInfo !== 'system') {
  257. this.getDataList()
  258. this.getCatalogList()
  259. } else {
  260. this.list = []
  261. this.list = [...innerRemoteComponents, ...getRemoteComponents()]
  262. }
  263. },
  264. updateCatalogList (list) {
  265. this.catalogList = list
  266. },
  267. reSearch () {
  268. if (this.catalogInfo !== 'system') {
  269. this.current = 1
  270. this.getDataList()
  271. } else {
  272. const arr = [...innerRemoteComponents, ...getRemoteComponents()]
  273. this.list = arr?.filter((item) => item.title.indexOf(this.name) !== -1)
  274. }
  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.name,
  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 '~packages/assets/style/bsTheme.scss';
  422. .big-screen-list-wrap {
  423. position: relative;
  424. height: 100%;
  425. padding: 16px;
  426. color: #9ea9b2;
  427. background-color: var(--bs-background-1) !important;
  428. .top-search-wrap {
  429. display: flex;
  430. align-items: center;
  431. justify-content: flex-end;
  432. margin-bottom: 12px;
  433. .el-input {
  434. width: 200px;
  435. margin-right: 20px;
  436. /deep/.el-input__inner {
  437. background-color: #232832 !important;
  438. }
  439. }
  440. .el-select {
  441. margin-right: 20px;
  442. /deep/.el-input__inner {
  443. background-color: #232832 !important;
  444. }
  445. }
  446. }
  447. .list-wrap {
  448. /* display: grid; */
  449. overflow: auto;
  450. // 间隙自适应
  451. justify-content: space-around;
  452. max-height: calc(100vh - 270px);
  453. display: grid;
  454. grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  455. grid-gap: 15px;
  456. /deep/ .el-loading-mask {
  457. display: flex;
  458. align-items: center;
  459. justify-content: center;
  460. height: calc(100vh - 260px) !important;
  461. z-index: 999;
  462. top: 50px;
  463. }
  464. .big-screen-card-wrap {
  465. position: relative;
  466. height: 180px;
  467. cursor: pointer;
  468. &:hover {
  469. .screen-card__hover {
  470. height: 180px;
  471. }
  472. }
  473. .screen-card__hover {
  474. position: absolute;
  475. z-index: 999;
  476. top: 0;
  477. right: 0;
  478. left: 0;
  479. display: flex;
  480. overflow: hidden;
  481. align-items: center;
  482. justify-content: center;
  483. height: 0;
  484. transition: height 0.4s;
  485. background: #00000099;
  486. .screen-card__hover-box {
  487. position: absolute;
  488. width: 100%;
  489. height: 100%;
  490. background: #00000080;
  491. display: flex;
  492. overflow: hidden;
  493. align-items: center;
  494. justify-content: center;
  495. }
  496. .preview {
  497. display: flex;
  498. flex-direction: row;
  499. justify-content: space-evenly;
  500. width: 100%;
  501. cursor: pointer;
  502. color: var(--bs-el-color-primary);
  503. .circle {
  504. position: relative;
  505. display: flex;
  506. align-items: center;
  507. justify-content: center;
  508. width: 40px;
  509. height: 40px;
  510. border: 1px solid var(--bs-el-color-primary);
  511. border-radius: 50%;
  512. &:hover {
  513. color: #fff;
  514. background: var(--bs-el-color-primary);
  515. }
  516. span {
  517. font-size: 12px;
  518. }
  519. }
  520. }
  521. }
  522. .big-screen-card-inner {
  523. overflow: hidden;
  524. width: 100%;
  525. height: 100%;
  526. cursor: pointer;
  527. background-color: var(--bs-background-2);
  528. box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
  529. color: var(--bs-el-title);
  530. border: 1px solid var(--bs-background-2);
  531. &:hover {
  532. color: var(--bs-el-text);
  533. border: 1px solid var(--bs-el-color-primary);
  534. }
  535. .add-big-screen-card-text {
  536. font-size: 24px;
  537. }
  538. .big-screen-card-img {
  539. width: 100%;
  540. height: 150px;
  541. img {
  542. width: 100%;
  543. height: 100%;
  544. object-fit: cover;
  545. }
  546. /deep/.image-slot {
  547. height: 100%;
  548. background-color: var(--bs-background-2);
  549. display: flex;
  550. align-items: center;
  551. justify-content: center;
  552. }
  553. /deep/.el-image__error {
  554. background-color: #1d1d1d;
  555. }
  556. }
  557. .big-screen-bottom {
  558. display: flex;
  559. align-items: center;
  560. flex-direction: row;
  561. justify-content: space-between;
  562. box-sizing: border-box;
  563. width: 100%;
  564. /*height: 26px;*/
  565. padding: 0 10px;
  566. height: calc(100% - 150px);
  567. color: var(--bs-el-title);
  568. background-color: var(--bs-background-2);
  569. .left-bigscreen-title {
  570. font-size: 14px;
  571. overflow: hidden;
  572. width: 120px;
  573. white-space: nowrap;
  574. text-overflow: ellipsis;
  575. }
  576. .right-bigscreen-time-title {
  577. font-size: 14px;
  578. overflow: hidden;
  579. width: 140px;
  580. white-space: nowrap;
  581. text-overflow: ellipsis;
  582. }
  583. }
  584. .big-screen-card-text {
  585. font-size: 14px;
  586. padding: 10px;
  587. text-align: center;
  588. color: #333;
  589. }
  590. }
  591. .big-screen-card-inner-add {
  592. display: flex;
  593. align-items: center;
  594. justify-content: center;
  595. }
  596. }
  597. }
  598. .el-loading-parent--relative {
  599. position: unset !important;
  600. }
  601. .footer-pagination-wrap {
  602. position: absolute;
  603. bottom: 10px;
  604. display: flex;
  605. align-items: center;
  606. justify-content: flex-end;
  607. width: 100%;
  608. margin-top: 20px;
  609. padding: 0 20px;
  610. }
  611. .error-img-text{
  612. overflow:hidden;
  613. padding:0 10px;
  614. white-space: nowrap;
  615. text-overflow: ellipsis;
  616. -o-text-overflow:ellipsis;
  617. }
  618. }
  619. .bs-pagination {
  620. ::v-deep .el-input__inner {
  621. width: 110px !important;
  622. border: none;
  623. background: var(--bs-el-background-1);
  624. }
  625. }
  626. </style>