Merge pull request #12176 from dataease/pr@dev-v2@feat_new-picture-component

feat(仪表板、数据大屏): 图片组件支持绑定数据集
This commit is contained in:
王嘉豪 2024-09-12 17:11:24 +08:00 committed by GitHub
commit 1c5ac9f0de
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 93 additions and 20 deletions

View File

@ -28,8 +28,8 @@ const props = defineProps({
}) })
const { dvModel } = toRefs(props) const { dvModel } = toRefs(props)
const newComponent = params => { const newComponent = (componentName, innerType) => {
eventBus.emit('handleNew', { componentName: params, innerType: params }) eventBus.emit('handleNew', { componentName: componentName, innerType: innerType })
} }
const handleDragStart = e => { const handleDragStart = e => {
@ -47,22 +47,22 @@ const handleDragEnd = e => {
:themes="themes" :themes="themes"
icon="dv-picture-show" icon="dv-picture-show"
label="图片" label="图片"
drag-info="Picture&Picture" drag-info="UserView&Picture"
v-on:click="newComponent('Picture')" v-on:click="newComponent('UserView', 'Picture')"
></drag-component> ></drag-component>
<drag-component <drag-component
:themes="themes" :themes="themes"
icon="icon-video" icon="icon-video"
label="视频" label="视频"
drag-info="DeVideo&DeVideo" drag-info="DeVideo&DeVideo"
v-on:click="newComponent('DeVideo')" v-on:click="newComponent('DeVideo', 'DeVideo')"
></drag-component> ></drag-component>
<drag-component <drag-component
:themes="themes" :themes="themes"
icon="icon-stream" icon="icon-stream"
label="流媒体" label="流媒体"
drag-info="DeStreamMedia&DeStreamMedia" drag-info="DeStreamMedia&DeStreamMedia"
v-on:click="newComponent('DeStreamMedia')" v-on:click="newComponent('DeStreamMedia', 'DeStreamMedia')"
></drag-component> ></drag-component>
</div> </div>
</template> </template>

View File

@ -306,7 +306,15 @@ const list = [
component: 'UserView', component: 'UserView',
name: '图表', name: '图表',
label: '图表', label: '图表',
propValue: { textValue: '' }, propValue: {
textValue: '',
url: '',
pictureShowType: 'common', // 图片显示方式 common 正常显示 dataset 绑定数据集显示
flip: {
horizontal: false,
vertical: false
}
},
icon: 'bar', icon: 'bar',
innerType: 'bar', innerType: 'bar',
editing: false, editing: false,

View File

@ -61,6 +61,9 @@ export function findNewComponent(componentName, innerType, staticMap?) {
textValue: '' textValue: ''
} }
} }
if (newComponent.innerType === 'Picture') {
newComponent.style['adaptation'] = 'adaptation'
}
if (dvMainStore.curOriginThemes === 'light') { if (dvMainStore.curOriginThemes === 'light') {
newComponent['commonBackground'] = cloneDeep(COMMON_COMPONENT_BACKGROUND_LIGHT) newComponent['commonBackground'] = cloneDeep(COMMON_COMPONENT_BACKGROUND_LIGHT)
} else { } else {

View File

@ -78,3 +78,11 @@ export const componentsMap = {
export default function findComponent(key) { export default function findComponent(key) {
return componentsMap[key] return componentsMap[key]
} }
export function findComponentAttr(component) {
const key =
component.component === 'UserView' && component.innerType === 'Picture'
? 'PictureAttr'
: component.component + 'Attr'
return componentsMap[key]
}

View File

@ -253,7 +253,7 @@ const getFields = (id, chartId, type) => {
const chartStyleShow = computed(() => { const chartStyleShow = computed(() => {
return ( return (
view.value.type !== 'richText' && !['richText', 'Picture'].includes(view.value.type) &&
curComponent.value && curComponent.value &&
curComponent.value.component === 'UserView' curComponent.value.component === 'UserView'
) )
@ -1770,7 +1770,10 @@ const deleteChartFieldItem = id => {
<el-tab-pane name="data" :label="t('chart.chart_data')" class="padding-tab"> <el-tab-pane name="data" :label="t('chart.chart_data')" class="padding-tab">
<el-container direction="vertical"> <el-container direction="vertical">
<el-scrollbar class="has-footer drag_main_area attr-style theme-border-class"> <el-scrollbar class="has-footer drag_main_area attr-style theme-border-class">
<el-row v-if="view.type !== 'rich-text'" class="drag-data padding-lr"> <el-row
v-if="!['rich-text', 'Picture'].includes(view.type)"
class="drag-data padding-lr"
>
<span class="data-area-label">{{ t('chart.switch_chart') }}</span> <span class="data-area-label">{{ t('chart.switch_chart') }}</span>
<el-popover <el-popover
:offset="4" :offset="4"

View File

@ -1505,6 +1505,20 @@ export const CHART_TYPE_CONFIGS = [
icon: 'rich-text' icon: 'rich-text'
} }
] ]
},
{
category: 'other',
title: '图片',
display: 'hidden',
details: [
{
render: 'custom',
category: 'quota',
value: 'Picture',
title: '图片',
icon: 'picture'
}
]
} }
] ]

View File

@ -0,0 +1,19 @@
import { AbstractChartView, ChartLibraryType, ChartRenderType } from '../../types'
import { useI18n } from '@/hooks/web/useI18n'
const { t } = useI18n()
/**
* 富文本图表
*/
export class PictureChartView extends AbstractChartView {
properties: EditorProperty[] = ['background-overall-component', 'border-style']
propertyInner: EditorPropertyInner = {
'background-overall-component': ['all'],
'border-style': ['all']
}
axis: AxisType[] = ['filter']
axisConfig: AxisConfig = {}
constructor() {
super(ChartRenderType.CUSTOM, ChartLibraryType.PICTURE, 'Picture')
}
}

View File

@ -15,6 +15,7 @@ export enum ChartLibraryType {
ECHARTS = 'echarts', ECHARTS = 'echarts',
S2 = 's2', S2 = 's2',
RICH_TEXT = 'rich-text', RICH_TEXT = 'rich-text',
PICTURE = 'Picture',
INDICATOR = 'indicator' INDICATOR = 'indicator'
} }
export abstract class ChartWrapper<O> { export abstract class ChartWrapper<O> {

View File

@ -43,6 +43,7 @@ import { storeToRefs } from 'pinia'
import { checkAddHttp, setIdValueTrans } from '@/utils/canvasUtils' import { checkAddHttp, setIdValueTrans } from '@/utils/canvasUtils'
import { Base64 } from 'js-base64' import { Base64 } from 'js-base64'
import DeRichTextView from '@/custom-component/rich-text/DeRichTextView.vue' import DeRichTextView from '@/custom-component/rich-text/DeRichTextView.vue'
import DePictureV2 from '@/custom-component/picture/Component.vue'
import ChartEmptyInfo from '@/views/chart/components/views/components/ChartEmptyInfo.vue' import ChartEmptyInfo from '@/views/chart/components/views/components/ChartEmptyInfo.vue'
import { snapshotStoreWithOut } from '@/store/modules/data-visualization/snapshot' import { snapshotStoreWithOut } from '@/store/modules/data-visualization/snapshot'
import { viewFieldTimeTrans } from '@/utils/viewUtils' import { viewFieldTimeTrans } from '@/utils/viewUtils'
@ -120,7 +121,7 @@ const { view, showPosition, element, active, searchCount, scale } = toRefs(props
const titleShow = computed( const titleShow = computed(
() => () =>
element.value.innerType !== 'rich-text' && !['rich-text', 'Picture'].includes('rich-text') &&
state.title_show && state.title_show &&
showPosition.value !== 'viewDialog' showPosition.value !== 'viewDialog'
) )
@ -672,7 +673,7 @@ const chartAreaShow = computed(() => {
return true return true
} }
} }
if (view.value.type === 'rich-text') { if (['rich-text', 'Picture'].includes(view.value.type)) {
return true return true
} }
if (view.value?.isPlugin) { if (view.value?.isPlugin) {
@ -895,6 +896,11 @@ const loadPluginCategory = data => {
@onJumpClick="jumpClick" @onJumpClick="jumpClick"
@resetLoading="() => (loading = false)" @resetLoading="() => (loading = false)"
/> />
<de-picture-v2
:element="element"
:prop-value="element.propValue"
v-else-if="showChartView(ChartLibraryType.PICTURE)"
></de-picture-v2>
<de-rich-text-view <de-rich-text-view
v-else-if="showChartView(ChartLibraryType.RICH_TEXT)" v-else-if="showChartView(ChartLibraryType.RICH_TEXT)"
:themes="canvasStyleData.dashboard.themeColor" :themes="canvasStyleData.dashboard.themeColor"

View File

@ -1,8 +1,8 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, nextTick, onMounted, onUnmounted, reactive, ref, watch } from 'vue' import { computed, nextTick, onMounted, onUnmounted, reactive, ref } from 'vue'
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain' import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import findComponent from '../../utils/components' import { findComponentAttr } from '../../utils/components'
import DvSidebar from '../../components/visualization/DvSidebar.vue' import DvSidebar from '../../components/visualization/DvSidebar.vue'
import router from '@/router' import router from '@/router'
import MobileConfigPanel from './MobileConfigPanel.vue' import MobileConfigPanel from './MobileConfigPanel.vue'
@ -75,10 +75,25 @@ const initDataset = () => {
}) })
} }
const otherEditorShow = computed(() => {
return Boolean(
curComponent.value &&
(!['UserView', 'VQuery'].includes(curComponent.value?.component) ||
(curComponent.value?.component === 'UserView' &&
curComponent.value?.innerType === 'Picture')) &&
!batchOptStatus.value
)
})
const otherEditorTitle = computed(() => {
return curComponent.value?.component === 'UserView' ? '属性' : curComponent.value?.label || '属性'
})
const viewEditorShow = computed(() => { const viewEditorShow = computed(() => {
return Boolean( return Boolean(
curComponent.value && curComponent.value &&
['UserView', 'VQuery'].includes(curComponent.value.component) && ['UserView', 'VQuery'].includes(curComponent.value.component) &&
curComponent.value.innerType !== 'Picture' &&
!batchOptStatus.value !batchOptStatus.value
) )
}) })
@ -260,19 +275,15 @@ onUnmounted(() => {
</main> </main>
<!-- 右侧侧组件列表 --> <!-- 右侧侧组件列表 -->
<dv-sidebar <dv-sidebar
v-if=" v-if="otherEditorShow"
curComponent &&
!['UserView', 'VQuery'].includes(curComponent.component) &&
!batchOptStatus
"
:theme-info="'light'" :theme-info="'light'"
:title="curComponent.label || '属性'" :title="otherEditorTitle"
:width="420" :width="420"
:side-name="'componentProp'" :side-name="'componentProp'"
:aside-position="'right'" :aside-position="'right'"
class="left-sidebar" class="left-sidebar"
> >
<component :is="findComponent(curComponent['component'] + 'Attr')" :themes="'light'" /> <component :is="findComponentAttr(curComponent)" :themes="'light'" />
</dv-sidebar> </dv-sidebar>
<dv-sidebar <dv-sidebar
v-show="!curComponent && !batchOptStatus" v-show="!curComponent && !batchOptStatus"