index.vue 17 KB

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