123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- <template>
- <div
- style="width: 100%; height: 100%"
- class="bs-design-wrap"
- >
- <div class="content">
- <div
- v-for="(item, index) in option.data"
- :key="index"
- class="content_item"
- :style="{
- 'border-color': option.borderColor,
- 'border-width': option.borderWidth + 'px',
- 'background-color': option.bgColor,
- 'font-size': option.fontSize + 'px',
- 'min-width': option.width + 'px',
- 'height': option.height + 'px',
- color: option.color,
- 'border-radius': option.borderRadius + 'px',
- 'font-weight': option.fontWeight,
- 'margin-right':
- index !== option.data.length - 1 ? option.marginRight + 'px' : ''
- }"
- >
- {{ item }}
- </div>
- </div>
- </div>
- </template>
- <script>
- import '@jiaminghi/data-view/lib/components/digitalFlop/src/main.css'
- import { refreshComponentMixin } from 'data-room-ui/js/mixins/refreshComponent'
- import commonMixins from 'data-room-ui/js/mixins/commonMixins'
- import paramsMixins from 'data-room-ui/js/mixins/paramsMixins'
- import linkageMixins from 'data-room-ui/js/mixins/linkageMixins'
- function formatter (number, format) {
- const numbers = number.toString().split('').reverse()
- const segs = []
- while (numbers.length) {
- segs.push(numbers.splice(0, format).join(''))
- }
- return segs.join(',').split('').reverse().join('')
- }
- export default {
- name: 'DvDigitalFlop',
- components: {
- // DigitalFlop
- },
- mixins: [refreshComponentMixin, paramsMixins, commonMixins, linkageMixins],
- props: {
- // 卡片的属性
- config: {
- type: Object,
- default: () => ({})
- }
- },
- data () {
- return {}
- },
- computed: {
- option () {
- let str = this.config.option.data
- if (!this.config.option.data) return { ...this.config.customize, data: [] }
- if (
- this.config.option.data.toString().split('').length <
- this.config.customize.numberDigits
- ) {
- const len =
- this.config.customize.numberDigits -
- this.config.option.data.toString().split('').length
- for (let i = 0; i < len; i++) {
- // eslint-disable-next-line vue/no-side-effects-in-computed-properties
- str =
- (this.config.customize.placeHolder
- ? this.config.customize.placeHolder
- : ' ') + str
- }
- }
- const a =
- this.config.customize.formatter === 0
- ? str
- : formatter(str, this.config.customize.formatter)
- const arr = a.toString().split('')
- if (this.config.customize.slotRight !== '') {
- arr.push(this.config.customize.slotRight)
- }
- if (this.config.customize.slotLeft !== '') {
- arr.unshift(this.config.customize.slotLeft)
- }
- return {
- ...this.config.customize,
- data: arr
- }
- }
- },
- watch: {},
- mounted () {
- },
- methods: {
- dataFormatting (config, data) {
- let dataList = ''
- if (data.data instanceof Array) {
- dataList = config.dataSource.dimensionField
- ? data.data[0][config.dataSource.dimensionField]
- : data.data[0].value
- } else {
- dataList = data.data[config.dataSource.dimensionField]
- }
- config.option = {
- ...config.option,
- data: dataList
- }
- return config
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .light-theme {
- background-color: #ffffff;
- color: #000000;
- }
- .auto-theme {
- background-color: rgba(0, 0, 0, 0);
- }
- .dark-theme {
- background-color: rgb(31, 31, 31);
- }
- .bs-design-wrap {
- position: relative;
- width: 100%;
- height: 100%;
- background-color: transparent;
- border-radius: 4px;
- box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.1);
- box-sizing: border-box;
- .content {
- display: flex;
- flex-direction: row;
- justify-content: center;
- width: 100%;
- height: 100%;
- align-items: center;
- &_item {
- height: 100%;
- display: flex;
- justify-content: center;
- align-items: center;
- border: 1px solid rgba(131, 191, 246, 0);
- overflow: hidden;
- }
- }
- }
- .title-box {
- height: 40px;
- padding: 10px 10px 0 0;
- box-sizing: border-box;
- .title {
- font-size: 14px;
- color: #333;
- font-weight: bold;
- border-left: 3px solid #007aff;
- padding-left: 16px;
- }
- .target-value {
- overflow-y: auto;
- height: 60px;
- font-weight: bold;
- width: 100%;
- font-size: 20px;
- color: #333;
- padding: 16px 0 0 22px;
- box-sizing: border-box;
- }
- }
- .el-icon-warning {
- color: #ffd600;
- }
- .title-hover {
- &:hover {
- cursor: move;
- }
- }
- /*滚动条样式*/
- ::v-deep ::-webkit-scrollbar {
- width: 4px;
- border-radius: 4px;
- height: 4px;
- }
- ::v-deep ::-webkit-scrollbar-thumb {
- background: #dddddd !important;
- border-radius: 10px;
- }
- </style>
|