index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. <template>
  2. <el-dialog
  3. title="边框组件"
  4. :visible.sync="dialogVisible"
  5. width="80%"
  6. :modal="true"
  7. :modal-append-to-body="false"
  8. :appen-to-body="true"
  9. class="bs-dialog-wrap bs-el-dialog"
  10. @closed="close"
  11. >
  12. <div class="content">
  13. <div class="big-screen-list-wrap">
  14. <div
  15. v-if="remoteComponentlist.length !== 0"
  16. class="list-wrap bs-scrollbar"
  17. :style="{
  18. display: remoteComponentsGridComputed ? 'grid' : 'flex',
  19. justifyContent: remoteComponentsGridComputed ? 'space-around' : 'flex-start',
  20. }"
  21. >
  22. <div
  23. v-for="component in remoteComponentlist"
  24. :key="component.title"
  25. class="big-screen-card-wrap"
  26. :style="{
  27. width: remoteComponentsGridComputed ? 'auto' : '290px'
  28. }"
  29. @click="chooseComponent(component)"
  30. >
  31. <div
  32. :class="component.title == focus.title ? 'focus' : ''"
  33. class="big-screen-card-inner"
  34. >
  35. <div class="big-screen-card-img">
  36. <el-image
  37. :src="component.img"
  38. fit="contain"
  39. style="width: 100%; height: 100%"
  40. >
  41. <div
  42. slot="placeholder"
  43. class="image-slot"
  44. >
  45. 加载中···
  46. </div>
  47. </el-image>
  48. </div>
  49. <div class="big-screen-bottom">
  50. <div
  51. class="left-bigscreen-title"
  52. :title="component.title"
  53. >
  54. {{ getName(component.title) }}
  55. </div>
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. <div
  61. v-else
  62. class="empty"
  63. >
  64. 暂无数据
  65. </div>
  66. </div>
  67. </div>
  68. <div
  69. slot="footer"
  70. class="dialog-footer"
  71. >
  72. <el-button
  73. class="bs-el-button-default"
  74. @click="dialogVisible = false"
  75. >
  76. 取消
  77. </el-button>
  78. <el-button
  79. type="primary"
  80. @click="confirm"
  81. >
  82. 确定
  83. </el-button>
  84. </div>
  85. </el-dialog>
  86. </template>
  87. <script>
  88. import { pageMixins } from 'data-room-ui/js/mixins/page'
  89. import isEmpty from 'lodash/isEmpty'
  90. import cloneDeep from 'lodash/cloneDeep'
  91. import plotList from 'data-room-ui/BorderComponents/settingList.js'
  92. import borderComponents from 'data-room-ui/BorderComponents/bordersList'
  93. export default {
  94. name: 'ComponentDialog',
  95. mixins: [pageMixins],
  96. model: {
  97. prop: 'type',
  98. event: 'select'
  99. },
  100. props: {
  101. type: {
  102. type: String,
  103. default: ''
  104. },
  105. disable: {
  106. type: Boolean,
  107. default: false
  108. }
  109. },
  110. data () {
  111. return {
  112. dialogVisible: false,
  113. loading: false,
  114. code: '',
  115. focus: -1,
  116. searchKey: '',
  117. remoteComponentlist: []
  118. }
  119. },
  120. computed: {
  121. remoteComponentsGridComputed () {
  122. return this.remoteComponentlist.length > 3
  123. }
  124. },
  125. watch: {
  126. },
  127. mounted () {
  128. this.remoteComponentlist = [...borderComponents]
  129. this.remoteComponentlist.sort((a,b)=>{
  130. return a.title.slice(8) - b.title.slice(8)
  131. })
  132. },
  133. methods: {
  134. getName(title){
  135. plotList[Symbol.iterator]=function*(){
  136. let keys=Object.keys(plotList)
  137. for(let k of keys){
  138. yield [k,plotList[k]]
  139. }
  140. }
  141. let name
  142. for(let [key,value] of plotList){
  143. if(value.type==title){
  144. name=value.name
  145. }
  146. }
  147. return name
  148. },
  149. chooseComponent (component) {
  150. this.focus = cloneDeep(component)
  151. },
  152. close () { },
  153. init () {
  154. this.dialogVisible = true
  155. this.current = 1
  156. this.searchKey = ''
  157. this.code = ''
  158. this.focus = -1
  159. },
  160. // 点击确定
  161. confirm () {
  162. this.dialogVisible = false
  163. if (isEmpty(this.focus)) return
  164. this.$emit('select', this.focus.title)
  165. }
  166. }
  167. }
  168. </script>
  169. <style lang="scss" scoped>
  170. @import '../assets/style/bsTheme.scss';
  171. .content{
  172. height: calc(100vh - 290px);
  173. }
  174. .big-screen-list-wrap {
  175. .el-select {
  176. display: inline-block !important;
  177. position: relative !important;
  178. width: auto !important;
  179. }
  180. position: relative;
  181. height: 100%;
  182. // margin:0 16px;
  183. // padding: 16px;
  184. margin-bottom: 56px;
  185. color: #9ea9b2;
  186. background-color: var(--bs-background-2) !important;
  187. .top-search-wrap {
  188. display: flex;
  189. align-items: center;
  190. justify-content: flex-end;
  191. margin-bottom: 12px;
  192. .el-input {
  193. width: 200px;
  194. margin-right: 20px;
  195. ::v-deep.el-input__inner {
  196. background-color: var(--bs-background-1) !important;
  197. }
  198. }
  199. .el-select {
  200. margin-right: 20px;
  201. ::v-deep.el-input__inner {
  202. background-color: var(--bs-background-1) !important;
  203. }
  204. }
  205. }
  206. .list-wrap {
  207. /* display: grid; */
  208. overflow: auto;
  209. // 间隙自适应
  210. justify-content: space-around;
  211. // max-height: calc(100vh - 270px);
  212. display: grid;
  213. grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  214. grid-gap: 15px;
  215. .big-screen-card-wrap {
  216. position: relative;
  217. height: 230px;
  218. cursor: pointer;
  219. &:hover {
  220. .screen-card__hover {
  221. height: 180px;
  222. }
  223. }
  224. .screen-card__hover {
  225. position: absolute;
  226. z-index: 999;
  227. top: 0;
  228. right: 0;
  229. left: 0;
  230. display: flex;
  231. overflow: hidden;
  232. align-items: center;
  233. justify-content: center;
  234. height: 0;
  235. transition: height 0.4s;
  236. background: #00000099;
  237. }
  238. .focus {
  239. color: var(--bs-el-text) !important;
  240. border: 1px solid var(--bs-el-color-primary) !important;
  241. }
  242. .big-screen-card-inner {
  243. overflow: hidden;
  244. width: 100%;
  245. height: 100%;
  246. cursor: pointer;
  247. background-color: var(--bs-background-2);
  248. box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
  249. color: var(--bs-el-title);
  250. border: 1px solid var(--bs-background-1);
  251. &:hover {
  252. color: var(--bs-el-text);
  253. border: 1px solid var(--bs-el-color-primary);
  254. }
  255. .add-big-screen-card-text {
  256. color: var(--bs-el-color-primary);
  257. font-size: 24px;
  258. }
  259. .big-screen-card-img {
  260. width: 100%;
  261. height: 180px;
  262. img {
  263. width: 100%;
  264. height: 100%;
  265. object-fit: cover;
  266. }
  267. ::v-deep.image-slot {
  268. height: 100%;
  269. background-color: var(--bs-background-2);
  270. display: flex;
  271. align-items: center;
  272. justify-content: center;
  273. }
  274. ::v-deep.el-image__error {
  275. background-color: #1d1d1d;
  276. }
  277. }
  278. .big-screen-bottom {
  279. display: flex;
  280. align-items: center;
  281. flex-direction: row;
  282. justify-content: space-between;
  283. box-sizing: border-box;
  284. width: 100%;
  285. /*height: 26px;*/
  286. padding: 0 10px;
  287. height: calc(100% - 180px);
  288. color: var(--bs-el-title);
  289. background-color: var(--bs-background-2);
  290. .left-bigscreen-title {
  291. font-size: 14px;
  292. overflow: hidden;
  293. width: 100%;
  294. white-space: nowrap;
  295. text-overflow: ellipsis;
  296. }
  297. .right-bigscreen-time-title {
  298. font-size: 14px;
  299. overflow: hidden;
  300. width: 140px;
  301. white-space: nowrap;
  302. text-overflow: ellipsis;
  303. }
  304. }
  305. .big-screen-card-text {
  306. font-size: 14px;
  307. padding: 10px;
  308. text-align: center;
  309. color: #333;
  310. }
  311. }
  312. .big-screen-card-inner-add {
  313. display: flex;
  314. align-items: center;
  315. justify-content: center;
  316. }
  317. }
  318. }
  319. .el-loading-parent--relative {
  320. position: unset !important;
  321. }
  322. .footer-pagination-wrap {
  323. margin-top: 16px;
  324. position: absolute;
  325. width: 100%;
  326. }
  327. }
  328. .bs-pagination {
  329. ::v-deep .el-input__inner {
  330. width: 110px !important;
  331. border: none;
  332. background: var(--bs-el-background-1);
  333. }
  334. }
  335. .empty {
  336. width: 100%;
  337. height: 70%;
  338. min-height: 300px;
  339. display: flex;
  340. justify-content: center;
  341. align-items: center;
  342. }
  343. ::v-deep .el-tabs__item {
  344. color: var(--bs-el-text);
  345. }
  346. .error-img-text {
  347. overflow: hidden;
  348. padding: 0 10px;
  349. white-space: nowrap;
  350. text-overflow: ellipsis;
  351. -o-text-overflow: ellipsis;
  352. }
  353. ::v-deep .el-tabs__nav-wrap {
  354. &:after {
  355. display: none;
  356. }
  357. }
  358. .empty{
  359. height: calc(100vh - 430px);
  360. }
  361. </style>