index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <div
  3. style="width: 100%; height: 100%"
  4. class="bs-design-wrap"
  5. >
  6. <div class="content">
  7. <div
  8. v-for="(item, index) in option.data"
  9. :key="index"
  10. class="content_item"
  11. :style="{
  12. 'border-color': option.borderColor,
  13. 'border-width': option.borderWidth + 'px',
  14. 'background-color': option.bgColor,
  15. 'font-size': option.fontSize + 'px',
  16. 'min-width': option.width + 'px',
  17. 'height': option.height + 'px',
  18. color: option.color,
  19. 'border-radius': option.borderRadius + 'px',
  20. 'font-weight': option.fontWeight,
  21. 'margin-right':
  22. index !== option.data.length - 1 ? option.marginRight + 'px' : ''
  23. }"
  24. >
  25. {{ item }}
  26. </div>
  27. </div>
  28. </div>
  29. </template>
  30. <script>
  31. import '@jiaminghi/data-view/lib/components/digitalFlop/src/main.css'
  32. import { refreshComponentMixin } from 'data-room-ui/js/mixins/refreshComponent'
  33. import commonMixins from 'data-room-ui/js/mixins/commonMixins'
  34. import paramsMixins from 'data-room-ui/js/mixins/paramsMixins'
  35. import linkageMixins from 'data-room-ui/js/mixins/linkageMixins'
  36. function formatter (number, format) {
  37. const numbers = number.toString().split('').reverse()
  38. const segs = []
  39. while (numbers.length) {
  40. segs.push(numbers.splice(0, format).join(''))
  41. }
  42. return segs.join(',').split('').reverse().join('')
  43. }
  44. export default {
  45. name: 'DvDigitalFlop',
  46. components: {
  47. // DigitalFlop
  48. },
  49. mixins: [refreshComponentMixin, paramsMixins, commonMixins, linkageMixins],
  50. props: {
  51. // 卡片的属性
  52. config: {
  53. type: Object,
  54. default: () => ({})
  55. }
  56. },
  57. data () {
  58. return {}
  59. },
  60. computed: {
  61. option () {
  62. let str = this.config.option.data
  63. if (!this.config.option.data) return { ...this.config.customize, data: [] }
  64. if (
  65. this.config.option.data.toString().split('').length <
  66. this.config.customize.numberDigits
  67. ) {
  68. const len =
  69. this.config.customize.numberDigits -
  70. this.config.option.data.toString().split('').length
  71. for (let i = 0; i < len; i++) {
  72. // eslint-disable-next-line vue/no-side-effects-in-computed-properties
  73. str =
  74. (this.config.customize.placeHolder
  75. ? this.config.customize.placeHolder
  76. : ' ') + str
  77. }
  78. }
  79. const a =
  80. this.config.customize.formatter === 0
  81. ? str
  82. : formatter(str, this.config.customize.formatter)
  83. const arr = a.toString().split('')
  84. if (this.config.customize.slotRight !== '') {
  85. arr.push(this.config.customize.slotRight)
  86. }
  87. if (this.config.customize.slotLeft !== '') {
  88. arr.unshift(this.config.customize.slotLeft)
  89. }
  90. return {
  91. ...this.config.customize,
  92. data: arr
  93. }
  94. }
  95. },
  96. watch: {},
  97. mounted () {
  98. },
  99. methods: {
  100. dataFormatting (config, data) {
  101. let dataList = ''
  102. if (data.data instanceof Array) {
  103. dataList = config.dataSource.dimensionField
  104. ? data.data[0][config.dataSource.dimensionField]
  105. : data.data[0].value
  106. } else {
  107. dataList = data.data[config.dataSource.dimensionField]
  108. }
  109. config.option = {
  110. ...config.option,
  111. data: dataList
  112. }
  113. return config
  114. }
  115. }
  116. }
  117. </script>
  118. <style lang="scss" scoped>
  119. .light-theme {
  120. background-color: #ffffff;
  121. color: #000000;
  122. }
  123. .auto-theme {
  124. background-color: rgba(0, 0, 0, 0);
  125. }
  126. .dark-theme {
  127. background-color: rgb(31, 31, 31);
  128. }
  129. .bs-design-wrap {
  130. position: relative;
  131. width: 100%;
  132. height: 100%;
  133. background-color: transparent;
  134. border-radius: 4px;
  135. box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.1);
  136. box-sizing: border-box;
  137. .content {
  138. display: flex;
  139. flex-direction: row;
  140. justify-content: center;
  141. width: 100%;
  142. height: 100%;
  143. align-items: center;
  144. &_item {
  145. height: 100%;
  146. display: flex;
  147. justify-content: center;
  148. align-items: center;
  149. border: 1px solid rgba(131, 191, 246, 0);
  150. overflow: hidden;
  151. }
  152. }
  153. }
  154. .title-box {
  155. height: 40px;
  156. padding: 10px 10px 0 0;
  157. box-sizing: border-box;
  158. .title {
  159. font-size: 14px;
  160. color: #333;
  161. font-weight: bold;
  162. border-left: 3px solid #007aff;
  163. padding-left: 16px;
  164. }
  165. .target-value {
  166. overflow-y: auto;
  167. height: 60px;
  168. font-weight: bold;
  169. width: 100%;
  170. font-size: 20px;
  171. color: #333;
  172. padding: 16px 0 0 22px;
  173. box-sizing: border-box;
  174. }
  175. }
  176. .el-icon-warning {
  177. color: #ffd600;
  178. }
  179. .title-hover {
  180. &:hover {
  181. cursor: move;
  182. }
  183. }
  184. /*滚动条样式*/
  185. ::v-deep ::-webkit-scrollbar {
  186. width: 4px;
  187. border-radius: 4px;
  188. height: 4px;
  189. }
  190. ::v-deep ::-webkit-scrollbar-thumb {
  191. background: #dddddd !important;
  192. border-radius: 10px;
  193. }
  194. </style>