初始化
This commit is contained in:
181
frontend/packages/BasicComponents/ChartTab/index.vue
Normal file
181
frontend/packages/BasicComponents/ChartTab/index.vue
Normal file
@@ -0,0 +1,181 @@
|
||||
<template>
|
||||
<div
|
||||
class="bs-design-wrap"
|
||||
:class="`bs-chart-tab-${customTheme}`"
|
||||
>
|
||||
<div
|
||||
v-if="config.customize.tabList.length"
|
||||
class="tab-title-box"
|
||||
:style="{'justify-content':config.customize.position}"
|
||||
>
|
||||
<div
|
||||
v-for="(tab,index) in config.customize.tabList"
|
||||
:key="index"
|
||||
class="tab-title-item"
|
||||
:class="{active:currentIndex === index}"
|
||||
:style="
|
||||
'font-size:' +
|
||||
config.customize.fontSize +
|
||||
'px;color:' +
|
||||
config.customize.color +
|
||||
';font-weight:' +
|
||||
config.customize.fontWeight
|
||||
"
|
||||
@click="changeTab(index)"
|
||||
>
|
||||
{{ tab.name }}
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="config.customize.tabList &&config.customize.tabList.length"
|
||||
class="line-box"
|
||||
:style="{'background-color':config.customize.lineColor}"
|
||||
/>
|
||||
<div
|
||||
v-if="config.customize.tabList &&config.customize.tabList.length"
|
||||
class="chart-item-box"
|
||||
>
|
||||
<!-- <Configuration-->
|
||||
<!-- :config="config.customize.tabList[currentIndex].chart"-->
|
||||
<!-- @openRightPanel="openRightPanel"-->
|
||||
<!-- >-->
|
||||
<div
|
||||
v-if="config.customize.tabList[currentIndex].chartCode"
|
||||
class="configuration-wrap"
|
||||
:class="{
|
||||
'active': activeCodes.includes(config.customize.tabList[currentIndex].chartCode),
|
||||
'hover': hoverCode === config.customize.tabList[currentIndex].chartCode
|
||||
}"
|
||||
@mouseenter.stop="changeHover(config.customize.tabList[currentIndex].chartCode)"
|
||||
@mouseleave="changeHover('')"
|
||||
@click.stop="changeActive(config.customize.tabList[currentIndex].chartCode)"
|
||||
>
|
||||
<RenderCardInner
|
||||
:ref="'RenderCard' + config.customize.tabList[currentIndex].chartCode"
|
||||
:config="config.customize.tabList[currentIndex].chart"
|
||||
@click.native="currentChartHandler"
|
||||
/>
|
||||
</div>
|
||||
<!-- </Configuration>-->
|
||||
</div>
|
||||
<el-empty
|
||||
v-else-if="!config.customize.tabList.length"
|
||||
description="请在右侧面板选择图表加入"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import paramsMixins from 'data-room-ui/js/mixins/paramsMixins'
|
||||
import { settingToTheme } from 'data-room-ui/js/utils/themeFormatting'
|
||||
import cloneDeep from 'lodash/cloneDeep'
|
||||
import { mapMutations, mapState } from 'vuex'
|
||||
import RenderCardInner from 'data-room-ui/Render/RenderCard2.vue'
|
||||
import Configuration from 'data-room-ui/Render/Configuration.vue'
|
||||
import { EventBus } from 'data-room-ui/js/utils/eventBus'
|
||||
export default {
|
||||
name: 'ChartTab',
|
||||
components: { Configuration, RenderCardInner },
|
||||
mixins: [paramsMixins],
|
||||
props: {
|
||||
config: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
pageCode: state => state.bigScreen.pageInfo.code,
|
||||
customTheme: state => state.bigScreen.pageInfo.pageConfig.customTheme,
|
||||
activeCode: state => state.bigScreen.activeCode,
|
||||
activeCodes: state => state.bigScreen.activeCodes,
|
||||
hoverCode: state => state.bigScreen.hoverCode,
|
||||
chartList: (state) => state.bigScreen.pageInfo.chartList
|
||||
})
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
// currentChart: null
|
||||
currentIndex: 0
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
},
|
||||
// 销毁定时器
|
||||
destroyed () {
|
||||
if (this.timer) {
|
||||
clearInterval(this.timer) // 关闭
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapMutations({
|
||||
changeChartConfig: 'bigScreen/changeChartConfig',
|
||||
changeActiveItemConfig: 'bigScreen/changeActiveItemConfig',
|
||||
changeActiveCode: 'bigScreen/changeActiveCode',
|
||||
changeHoverCode: 'bigScreen/changeHoverCode'
|
||||
}),
|
||||
changeStyle (config) {
|
||||
config = { ...this.config, ...config }
|
||||
// 样式改变时更新主题配置
|
||||
config.theme = settingToTheme(cloneDeep(config), this.customTheme)
|
||||
this.changeChartConfig(config)
|
||||
if (config.code === this.activeCode) {
|
||||
this.changeActiveItemConfig(config)
|
||||
}
|
||||
},
|
||||
// 切换tab页
|
||||
changeTab (index) {
|
||||
this.currentIndex = index
|
||||
},
|
||||
// 点击Tab中的某个组件
|
||||
currentChartHandler () {
|
||||
this.changeActiveCode(this.config.customize.tabList[this.currentIndex]?.chartCode)
|
||||
this.changeActiveItemConfig(this.config.customize.tabList[this.currentIndex]?.chart)
|
||||
},
|
||||
// 改变hover的组件
|
||||
changeHover (code) {
|
||||
this.changeHoverCode(code)
|
||||
},
|
||||
// 改变激活的组件
|
||||
changeActive (code) {
|
||||
this.changeActiveCode(code)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.bs-design-wrap{
|
||||
width: 100%;
|
||||
.tab-title-box{
|
||||
height: 40px;
|
||||
display: flex;
|
||||
&:hover{
|
||||
cursor: pointer;
|
||||
}
|
||||
.tab-title-item{
|
||||
padding:10px;
|
||||
}
|
||||
}
|
||||
.chart-item-box{
|
||||
width: 100%;
|
||||
height: calc(100% - 40px);
|
||||
&:hover{
|
||||
cursor: pointer;
|
||||
}
|
||||
.configuration-wrap{
|
||||
width: 100%;
|
||||
height: calc(100% - 40px);
|
||||
}
|
||||
}
|
||||
.active{
|
||||
color: var(--bs-el-color-primary) !important;
|
||||
}
|
||||
.line-box{
|
||||
width: 98%;
|
||||
height: 1px;
|
||||
margin: 0 auto;
|
||||
//background-color: #d0d2d6;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
342
frontend/packages/BasicComponents/ChartTab/setting.vue
Normal file
342
frontend/packages/BasicComponents/ChartTab/setting.vue
Normal file
@@ -0,0 +1,342 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-form
|
||||
ref="form"
|
||||
:model="config"
|
||||
label-width="120px"
|
||||
label-position="left"
|
||||
class="setting-body bs-el-form"
|
||||
>
|
||||
<SettingTitle>标题</SettingTitle>
|
||||
<el-form-item
|
||||
class="lc-field-body"
|
||||
label="名称"
|
||||
>
|
||||
<el-input
|
||||
v-model="config.title"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
<SettingTitle v-if="config.border">
|
||||
边框
|
||||
</SettingTitle>
|
||||
<div class="lc-field-body">
|
||||
<BorderSetting
|
||||
v-if="config.border"
|
||||
label-width="120px"
|
||||
:config="config.border"
|
||||
:big-title="config.title"
|
||||
/>
|
||||
</div>
|
||||
<SettingTitle>位置</SettingTitle>
|
||||
<div class="lc-field-body">
|
||||
<PosWhSetting
|
||||
:config="config"
|
||||
label-width="120px"
|
||||
/>
|
||||
</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-select
|
||||
v-model="config.customize.position"
|
||||
placeholder="请选择标题位置"
|
||||
popper-class="bs-el-select"
|
||||
class="bs-el-select"
|
||||
clearable
|
||||
>
|
||||
<el-option
|
||||
v-for="item in positionList"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="字体大小"
|
||||
label-width="100px"
|
||||
>
|
||||
<el-input-number
|
||||
v-model="config.customize.fontSize"
|
||||
class="bs-el-input-number"
|
||||
placeholder="请输入字体大小"
|
||||
:min="0"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="字体权重"
|
||||
label-width="100px"
|
||||
>
|
||||
<el-input-number
|
||||
v-model="config.customize.fontWeight"
|
||||
class="bs-el-input-number"
|
||||
:min="0"
|
||||
:step="100"
|
||||
placeholder="请输入字体权重"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="字体颜色"
|
||||
label-width="100px"
|
||||
>
|
||||
<el-color-picker
|
||||
v-model="config.customize.color"
|
||||
class="bs-el-color-picker"
|
||||
popper-class="bs-el-color-picker"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="分割线颜色"
|
||||
label-width="100px"
|
||||
>
|
||||
<el-color-picker
|
||||
v-model="config.customize.lineColor"
|
||||
class="bs-el-color-picker"
|
||||
popper-class="bs-el-color-picker"
|
||||
/>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<SettingTitle>内容</SettingTitle>
|
||||
<div class="lc-field-body">
|
||||
<div class="select-item select-item-title">
|
||||
<span class="option-drag" />
|
||||
<span class="input-wrap_left">图表类型</span>
|
||||
<span class="input-wrap_left">标签名称</span>
|
||||
</div>
|
||||
<draggable
|
||||
:list="config.customize.tabList"
|
||||
:animation="340"
|
||||
group="selectItem"
|
||||
handle=".option-drag"
|
||||
style="padding: 10px"
|
||||
>
|
||||
<template>
|
||||
<div
|
||||
v-for="(tab, index) in config.customize.tabList"
|
||||
:key="index"
|
||||
class="select-item"
|
||||
>
|
||||
<div class="select-line-icon option-drag">
|
||||
<i class="el-icon-rank" />
|
||||
</div>
|
||||
<div class="input-wrap">
|
||||
<el-form-item
|
||||
:prop="'customize.tabList.' + index + '.chart'"
|
||||
:rules="rules.chart"
|
||||
label-width="0px"
|
||||
>
|
||||
<el-select
|
||||
v-model="tab.chart.title"
|
||||
size="mini"
|
||||
popper-class="bs-el-select"
|
||||
class="bs-el-select"
|
||||
@change="handleChangeBindCompnents(...arguments, index)"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in componentList"
|
||||
:key="item.title"
|
||||
:label="item.title"
|
||||
:value="item.title"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="input-wrap">
|
||||
<el-form-item
|
||||
:prop="'customize.tabList.' + index + '.name'"
|
||||
:rules="rules.name"
|
||||
label-width="0px"
|
||||
>
|
||||
<el-input
|
||||
v-model="tab.name"
|
||||
placeholder="请输入标签名称"
|
||||
size="mini"
|
||||
/>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div
|
||||
class="select-line-icon option-delete"
|
||||
@click="deleteTab(index)"
|
||||
>
|
||||
<i class="el-icon-remove-outline" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</draggable>
|
||||
<div
|
||||
class="add-btn"
|
||||
@click="addTab"
|
||||
>
|
||||
新增标签页
|
||||
</div>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import draggable from 'vuedraggable'
|
||||
import SettingTitle from 'data-room-ui/SettingTitle/index.vue'
|
||||
import { chartSettingMixins } from 'data-room-ui/js/mixins/chartSettingMixins'
|
||||
import PosWhSetting from 'data-room-ui/BigScreenDesign/RightSetting/PosWhSetting.vue'
|
||||
import BorderSetting from 'data-room-ui/BigScreenDesign/RightSetting/BorderSetting.vue'
|
||||
import CloneDeep from 'lodash-es/cloneDeep'
|
||||
import plotList from 'data-room-ui/G2Plots/plotList'
|
||||
import { randomString } from 'data-room-ui/js/utils'
|
||||
import { settingToTheme } from 'data-room-ui/js/utils/themeFormatting'
|
||||
import RotateSetting from 'data-room-ui/BigScreenDesign/RightSetting/RotateSetting.vue'
|
||||
export default {
|
||||
components: {
|
||||
PosWhSetting,
|
||||
SettingTitle,
|
||||
draggable,
|
||||
BorderSetting,
|
||||
RotateSetting
|
||||
},
|
||||
mixins: [chartSettingMixins],
|
||||
data () {
|
||||
const validateChart = (rule, value, callback) => {
|
||||
if (!value) {
|
||||
return callback(new Error('请选择图表'))
|
||||
}
|
||||
callback()
|
||||
}
|
||||
return {
|
||||
positionList: [{
|
||||
label: '靠左',
|
||||
value: 'left'
|
||||
},
|
||||
{
|
||||
label: '居中',
|
||||
value: 'center'
|
||||
},
|
||||
{
|
||||
label: '靠右',
|
||||
value: 'right'
|
||||
}],
|
||||
rules: {
|
||||
name: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入标签名称',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
chart: [
|
||||
{ required: true, trigger: 'change', validator: validateChart }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
config: {
|
||||
get () {
|
||||
return this.$store.state.bigScreen.activeItemConfig
|
||||
},
|
||||
set (val) {
|
||||
this.$store.state.bigScreen.activeItemConfig = val
|
||||
}
|
||||
},
|
||||
pageCode () {
|
||||
return this.$route.query.code
|
||||
},
|
||||
componentList () {
|
||||
return [...plotList]
|
||||
}
|
||||
},
|
||||
watch: {},
|
||||
mounted () { },
|
||||
methods: {
|
||||
deleteTab (index) {
|
||||
this.config.customize.tabList.splice(index, 1)
|
||||
},
|
||||
addTab () {
|
||||
const newTab = {
|
||||
chartCode: '',
|
||||
name: '',
|
||||
chart: { parentCode: this.config.code }
|
||||
}
|
||||
this.config.customize.tabList.push(newTab)
|
||||
},
|
||||
handleChangeBindCompnents (configName, index) {
|
||||
const config = this.componentList.find(
|
||||
item => item.title === configName
|
||||
)
|
||||
config.code = randomString(12)
|
||||
this.$set(this.config.customize.tabList[index], 'name', configName)
|
||||
this.$set(this.config.customize.tabList[index], 'chart', { ...config, parentCode: this.config.code })
|
||||
this.$set(this.config.customize.tabList[index], 'chartCode', config.code)
|
||||
this.$set(this.config.customize.tabList[index].chart, 'key', config.code)
|
||||
this.$set(this.config.customize.tabList[index].chart, 'theme', settingToTheme(config, 'dark'))
|
||||
this.$set(this.config.customize.tabList[index].chart, 'theme', settingToTheme(config, 'light'))
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import "../../assets/style/settingWrap.scss";
|
||||
.lc-field-body {
|
||||
padding: 12px 16px;
|
||||
}
|
||||
.select-item {
|
||||
display: flex;
|
||||
margin-bottom: 8px;
|
||||
|
||||
.option-drag {
|
||||
cursor: move !important;
|
||||
width: 30px;
|
||||
font-size: 24px;
|
||||
}
|
||||
.input-wrap {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-right: 2px;
|
||||
|
||||
.el-input-number--mini {
|
||||
width: 90px !important;
|
||||
}
|
||||
}
|
||||
.input-wrap_left {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: left;
|
||||
}
|
||||
|
||||
.select-line-icon {
|
||||
width: 30px;
|
||||
font-size: 18px;
|
||||
cursor: pointer;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.option-delete {
|
||||
color: #f56c6c;
|
||||
}
|
||||
}
|
||||
.add-btn{
|
||||
width: 100px;
|
||||
height: 40px;
|
||||
margin: 0 auto;
|
||||
text-align: center;
|
||||
line-height:40px;
|
||||
border:1px dashed #dcdfe6;
|
||||
&:hover{
|
||||
color: #007aff;
|
||||
border:1px dashed #007aff;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
42
frontend/packages/BasicComponents/ChartTab/settingConfig.js
Normal file
42
frontend/packages/BasicComponents/ChartTab/settingConfig.js
Normal file
@@ -0,0 +1,42 @@
|
||||
import { commonConfig } from '../../js/config'
|
||||
|
||||
export const settingConfig = {
|
||||
time: '',
|
||||
theme: 'dark',
|
||||
// 设置面板属性的显隐
|
||||
displayOption: {
|
||||
dataAllocation: {
|
||||
// 是否存在数据配置
|
||||
enable: false
|
||||
}
|
||||
}
|
||||
}
|
||||
const customConfig = {
|
||||
|
||||
type: 'chartTab',
|
||||
root: {
|
||||
version: '2023071001',
|
||||
// 绕x轴旋转角度
|
||||
rotateX: 0,
|
||||
// 绕y轴旋转角度
|
||||
rotateY: 0,
|
||||
// 绕z轴旋转角度
|
||||
rotateZ: 0,
|
||||
// 透视距离
|
||||
perspective: 0,
|
||||
skewX: 0,
|
||||
skewY: 0
|
||||
},
|
||||
customize: {
|
||||
tabList: [],
|
||||
fontSize: 14,
|
||||
fontWeight: 700,
|
||||
position: 'left',
|
||||
color: 'rgb(155 159 172)',
|
||||
lineColor: '#d0d2d6'
|
||||
}
|
||||
|
||||
}
|
||||
export const dataConfig = {
|
||||
...commonConfig(customConfig)
|
||||
}
|
||||
Reference in New Issue
Block a user