index.vue 17 KB

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