初始化
This commit is contained in:
91
frontend/packages/BasicComponents/Numbers/index.vue
Normal file
91
frontend/packages/BasicComponents/Numbers/index.vue
Normal file
@@ -0,0 +1,91 @@
|
||||
<template>
|
||||
<div class="bs-design-wrap" :class="`bs-text-${customTheme}`">
|
||||
<div class="content-box" :key="domkey"
|
||||
:style="{ 'text-align': config.customize.align, 'letter-spacing': config.customize.letterSpacing + 'px', 'font-family': config.customize.fontFamily, 'font-size': config.customize.fontSize + 'px', 'font-weight': +config.customize.fontWeight, 'background-image': `-webkit-linear-gradient(${config.customize.color})` }">
|
||||
{{ config.customize.title }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import cloneDeep from 'lodash/cloneDeep'
|
||||
import { settingToTheme } from 'data-room-ui/js/utils/themeFormatting'
|
||||
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'
|
||||
export default {
|
||||
name: 'Texts',
|
||||
components: {},
|
||||
mixins: [paramsMixins, commonMixins, linkageMixins],
|
||||
props: {
|
||||
// 卡片的属性
|
||||
config: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
domkey: 0,
|
||||
customClass: {}
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
},
|
||||
mounted() {
|
||||
this.chartInit()
|
||||
},
|
||||
methods: {
|
||||
changeStyle(config) {
|
||||
config.customize.title = config.customize.thousands ? config.customize?.title?.toString()?.replace(/\B(?=(\d{3})+(?!\d))/g, ',') : config.customize.title
|
||||
this.changeChartConfig(config)
|
||||
config = { ...this.config, ...config }
|
||||
// 样式改变时更新主题配置
|
||||
config.theme = settingToTheme(cloneDeep(config), this.customTheme)
|
||||
this.changeChartConfig(config)
|
||||
if (config.code === this.activeCode) {
|
||||
this.changeActiveItemConfig(config)
|
||||
}
|
||||
return config
|
||||
},
|
||||
// 通过表达式计算得来的值
|
||||
getDataByExpression(config) {
|
||||
const result = new Function('dataset', 'computedDatas', this.config.expression)
|
||||
config.customize.title = result(this.dataset, this.computedDatas)
|
||||
// 同时将计算得来的值保存到公共的数据存储的地方
|
||||
this.updateComputedDatas({ code: config.code, title: config.title, data: config.customize.title })
|
||||
},
|
||||
dataFormatting(config, data) {
|
||||
// 文本数据配置原则:选择数据集则以后端返回的数据为主,否则以设置面板中标题设置为准
|
||||
if (config.dataSource.businessKey && config.dataSource.source === 'dataset') {
|
||||
config.customize.title = data && data.data && data.data.length ? data.data[0][config.dataSource.metricField] : '暂无数据'
|
||||
config.option.data = data && data.data && data.data.length ? data.data : []
|
||||
}
|
||||
this.domkey += 1;
|
||||
return config
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import "../../assets/fonts/numberFont/stylesheet.css";
|
||||
|
||||
.bs-design-wrap {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
//justify-content: center;
|
||||
}
|
||||
|
||||
.content-box {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
/* 将背景设为渐变 */
|
||||
/*background-image: -webkit-linear-gradient(left, #6294F7, #C85D14);*/
|
||||
/* 规定背景绘制区域 */
|
||||
-webkit-background-clip: text;
|
||||
/* 将文字隐藏 */
|
||||
-webkit-text-fill-color: transparent;
|
||||
}
|
||||
</style>
|
||||
212
frontend/packages/BasicComponents/Numbers/setting.vue
Normal file
212
frontend/packages/BasicComponents/Numbers/setting.vue
Normal file
@@ -0,0 +1,212 @@
|
||||
<!--
|
||||
* @description: 标题属性设置面板
|
||||
* @Date: 2022-08-17 16:53:28
|
||||
* @Author: shiyi
|
||||
-->
|
||||
<template>
|
||||
<div class="bs-setting-wrap">
|
||||
<el-form
|
||||
ref="form"
|
||||
label-width="100px"
|
||||
label-position="left"
|
||||
:model="config"
|
||||
:rules="rules"
|
||||
class="bs-el-form"
|
||||
>
|
||||
<SettingTitle>标题</SettingTitle>
|
||||
<div class="bs-setting-wrap">
|
||||
<el-form-item
|
||||
label="标题"
|
||||
label-width="100px"
|
||||
prop="title"
|
||||
>
|
||||
<el-input
|
||||
v-model="config.title"
|
||||
placeholder="请输入标题"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<SettingTitle>位置</SettingTitle>
|
||||
<div class="lc-field-body">
|
||||
<PosWhSetting :config="config" />
|
||||
</div>
|
||||
<SettingTitle v-if="config.border">
|
||||
边框
|
||||
</SettingTitle>
|
||||
<div class="lc-field-body">
|
||||
<BorderSetting
|
||||
v-if="config.border"
|
||||
label-width="100px"
|
||||
:config="config.border"
|
||||
:big-title="config.title"
|
||||
/>
|
||||
</div>
|
||||
<SettingTitle>旋转</SettingTitle>
|
||||
<div class="lc-field-body">
|
||||
<RotateSetting
|
||||
:config="config"
|
||||
/>
|
||||
</div>
|
||||
<SettingTitle>基础</SettingTitle>
|
||||
<div class="lc-field-body">
|
||||
<el-form-item
|
||||
label="字体大小"
|
||||
label-width="100px"
|
||||
>
|
||||
<el-input
|
||||
v-model="config.customize.fontSize"
|
||||
placeholder="请输入字体大小"
|
||||
clearable
|
||||
>
|
||||
<template slot="append">
|
||||
px
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="数字权重"
|
||||
label-width="100px"
|
||||
>
|
||||
<el-input-number
|
||||
v-model="config.customize.fontWeight"
|
||||
class="bs-el-input-number"
|
||||
placeholder="请输入数字权重"
|
||||
:min="0"
|
||||
:step="100"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="数字间距"
|
||||
label-width="100px"
|
||||
>
|
||||
<el-input-number
|
||||
v-model="config.customize.letterSpacing"
|
||||
class="bs-el-input-number"
|
||||
placeholder="请输入数字间距"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="字体类型"
|
||||
label-width="100px"
|
||||
>
|
||||
<el-select
|
||||
v-model="config.customize.fontFamily"
|
||||
popper-class="bs-el-select"
|
||||
class="bs-el-select"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in fontFamilyList"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="数字对齐方式"
|
||||
label-width="100px"
|
||||
>
|
||||
<el-select
|
||||
v-model="config.customize.align"
|
||||
popper-class="bs-el-select"
|
||||
class="bs-el-select"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in alignList"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<!-- 是否开启语音播报 -->
|
||||
<el-form-item
|
||||
label="千分位分隔"
|
||||
label-width="100px"
|
||||
>
|
||||
<el-switch
|
||||
v-model="config.customize.thousands"
|
||||
:active-value="true"
|
||||
:inactive-value="false"
|
||||
class="bs-el-switch"
|
||||
/>
|
||||
</el-form-item>
|
||||
<TextGradient
|
||||
v-model="config.customize.color"
|
||||
label="数字"
|
||||
/>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import SettingTitle from 'data-room-ui/SettingTitle/index.vue'
|
||||
import BorderSetting from 'data-room-ui/BigScreenDesign/RightSetting/BorderSetting.vue'
|
||||
import TextGradient from 'data-room-ui/BigScreenDesign/RightSetting/TextGradient/index'
|
||||
import PosWhSetting from 'data-room-ui/BigScreenDesign/RightSetting/PosWhSetting.vue'
|
||||
import RotateSetting from 'data-room-ui/BigScreenDesign/RightSetting/RotateSetting.vue'
|
||||
import fontList from 'data-room-ui/js/utils/fontList'
|
||||
import { mapMutations } from 'vuex'
|
||||
export default {
|
||||
name: 'NumberSetting',
|
||||
components: {
|
||||
TextGradient,
|
||||
PosWhSetting,
|
||||
SettingTitle,
|
||||
BorderSetting,
|
||||
RotateSetting
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
fontFamilyList: fontList,
|
||||
alignList: [{
|
||||
label: '靠左',
|
||||
value: 'left'
|
||||
},
|
||||
{
|
||||
label: '居中',
|
||||
value: 'center'
|
||||
},
|
||||
{
|
||||
label: '靠右',
|
||||
value: 'right'
|
||||
}],
|
||||
rules: {
|
||||
title: [
|
||||
{ required: true, message: '请输入标题', trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
config: {
|
||||
get () {
|
||||
return this.$store.state.bigScreen.activeItemConfig
|
||||
},
|
||||
set (val) {
|
||||
this.$store.state.bigScreen.activeItemConfig = val
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
},
|
||||
mounted () {},
|
||||
methods: {
|
||||
...mapMutations({
|
||||
updateDataset: 'bigScreen/updateDataset',
|
||||
updateComputedDatas: 'bigScreen/updateComputedDatas'
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import "../../assets/style/settingWrap.scss";
|
||||
.bs-setting-wrap{
|
||||
padding-top: 16px;
|
||||
}
|
||||
.lc-field-body {
|
||||
padding: 12px 16px;
|
||||
}
|
||||
</style>
|
||||
70
frontend/packages/BasicComponents/Numbers/settingConfig.js
Normal file
70
frontend/packages/BasicComponents/Numbers/settingConfig.js
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* @Descripttion:
|
||||
* @Author: liu.shiyi
|
||||
* @Date: 2022-10-13 11:18:03
|
||||
* @LastEditTime: 2022-10-13 13:55:11
|
||||
*/
|
||||
import { commonConfig, displayOption } from 'data-room-ui/js/config'
|
||||
|
||||
export const settingConfig = {
|
||||
theme: 'dark',
|
||||
data: [],
|
||||
text: '文本标签占位符', // text内容
|
||||
// 设置面板属性的显隐
|
||||
displayOption: {
|
||||
...displayOption,
|
||||
metricField: {
|
||||
// 指标
|
||||
label: '指标',
|
||||
enable: true,
|
||||
multiple: false // 是否多选
|
||||
},
|
||||
dimensionField: {
|
||||
// 维度
|
||||
label: '维度', // 维度/查询字段
|
||||
enable: false,
|
||||
multiple: true // 是否多选
|
||||
},
|
||||
text: { // 文本占位符
|
||||
label: '占位内容', // 维度/查询字段
|
||||
enable: true
|
||||
},
|
||||
expression: { // 文本占位符
|
||||
label: '表达式', // 维度/查询字段
|
||||
enable: true
|
||||
}
|
||||
}
|
||||
}
|
||||
const customConfig = {
|
||||
type: 'numbers',
|
||||
root: {
|
||||
version: '2023111401',
|
||||
url: 'https://www.runoob.com/',
|
||||
expression: 'return ',
|
||||
expressionCodes: [],
|
||||
// 绕x轴旋转角度
|
||||
rotateX: 0,
|
||||
// 绕y轴旋转角度
|
||||
rotateY: 0,
|
||||
// 绕z轴旋转角度
|
||||
rotateZ: 0,
|
||||
// 透视距离
|
||||
perspective: 0,
|
||||
skewX: 0,
|
||||
skewY: 0
|
||||
},
|
||||
customize: {
|
||||
title: '1234',
|
||||
fontSize: 40,
|
||||
fontWeight: 700,
|
||||
fontFamily: 'ds-digitalbold', // 字体类型
|
||||
color: 'left,#ffffff,#ffffff',
|
||||
thousands: false, // 千分位分隔
|
||||
align: 'center', // 文字对齐方式
|
||||
letterSpacing: 1// 文字间距
|
||||
}
|
||||
|
||||
}
|
||||
export const dataConfig = {
|
||||
...commonConfig(customConfig)
|
||||
}
|
||||
Reference in New Issue
Block a user