index.vue 8.7 KB

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