index.vue 4.9 KB

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