index.vue 17 KB

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