fix: 组态优化 支持快速输入 默认置底 增加底座

This commit is contained in:
huanghao1412 2024-02-28 15:38:09 +08:00
parent 23fc25bd43
commit eea358ccad
19 changed files with 223 additions and 11 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

View File

@ -10,7 +10,7 @@ import { GraphConfig } from './Graph/index'
export default [ export default [
// ProcessConfig, // ProcessConfig,
RadarConfig, // RadarConfig,
// FunnelConfig, // FunnelConfig,
// HeatmapConfig, // HeatmapConfig,
WaterPoloConfig, WaterPoloConfig,

View File

@ -14,7 +14,7 @@ export const option = {
top: 0, top: 0,
scale: 1, scale: 1,
// 展示标题 // 展示标题
isThereATitleComponet: true, isThereATitleComponet: false,
} }
export default class Config extends PublicConfigClass implements CreateComponentType export default class Config extends PublicConfigClass implements CreateComponentType

View File

@ -1,5 +1,21 @@
<template> <template>
<CollapseItem name="组态" :expanded="true"> <CollapseItem name="组态" :expanded="true">
<SettingItemBox name="标题">
<SettingItem name="如果有标题将展示">
<n-space justify="start">
<n-switch v-model:value="optionData.isThereATitleComponet" size="small" />
</n-space>
</SettingItem>
</SettingItemBox>
<SettingItemBox name="快捷输入" :alone="true">
<SettingItem name="输入0,0,1相当于距离顶部0,距离左侧0,缩放为1">
<n-input
v-model:value="allValue"
size="small"
placeholder="请输入"
></n-input>
</SettingItem>
</SettingItemBox>
<SettingItemBox name="位置"> <SettingItemBox name="位置">
<SettingItem name="距离顶部"> <SettingItem name="距离顶部">
<n-input-number <n-input-number
@ -18,21 +34,20 @@
<SettingItem name="缩放"> <SettingItem name="缩放">
<n-input-number <n-input-number
v-model:value="optionData.scale" v-model:value="optionData.scale"
step="0.1"
size="small" size="small"
placeholder="请输入" placeholder="请输入"
></n-input-number> ></n-input-number>
</SettingItem> </SettingItem>
</SettingItemBox> </SettingItemBox>
<SettingItemBox name="标题"> <SettingItemBox name="提示" :alone="true">
<SettingItem name="如果有将展示"> <n-text>在预览页使用alt+滚轮进行缩放</n-text>
<n-switch v-model:value="optionData.isThereATitleComponet" size="small" />
</SettingItem>
</SettingItemBox> </SettingItemBox>
</CollapseItem> </CollapseItem>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { PropType } from 'vue' import { PropType, ref, watch } from 'vue'
import { import {
CollapseItem, CollapseItem,
SettingItemBox, SettingItemBox,
@ -46,6 +61,18 @@ const props = defineProps({
required: true, required: true,
}, },
}) })
const allValue = ref('')
watch(() => allValue.value, v => {
v.split(',').forEach((item, i) => {
if(!isNaN(Number(item)) && item !== '') {
if(i === 0) props.optionData.top = Number(item)
else if(i === 1) props.optionData.left = Number(item)
else if(i === 2) props.optionData.scale = Number(item)
}
})
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -0,0 +1,28 @@
import { PublicConfigClass } from '@/packages/public'
import { CreateComponentType } from '@/packages/index.d'
import { BaseConfig } from './index'
import cloneDeep from 'lodash/cloneDeep'
export const option = {
// 图片
dataset: '',
// 适应方式
fit: 'fill',
// 圆角
// borderRadius: 0
}
export default class Config extends PublicConfigClass implements CreateComponentType
{
constructor() {
super();
this.attr = {
...this.attr,
w: 500,
h: 500,
}
}
public key = BaseConfig.key
public chartConfig = cloneDeep(BaseConfig)
public option = cloneDeep(option)
}

View File

@ -0,0 +1,62 @@
<template>
<collapse-item name="属性" :expanded="true">
<setting-item-box name="样式">
<setting-item name="类型">
<n-select
v-model:value="optionData.fit"
size="small"
:options="fitList"
></n-select>
</setting-item>
<!-- <setting-item name="圆角">-->
<!-- <n-input-number-->
<!-- v-model:value="optionData.borderRadius"-->
<!-- size="small"-->
<!-- :min="0"-->
<!-- placeholder="圆角"-->
<!-- ></n-input-number>-->
<!-- </setting-item>-->
</setting-item-box>
</collapse-item>
</template>
<script setup lang="ts">
import { PropType } from 'vue'
import { option } from './config'
import {
CollapseItem,
SettingItemBox,
SettingItem,
} from '@/components/Pages/ChartItemSetting'
const props = defineProps({
optionData: {
type: Object as PropType<typeof option>,
required: true,
},
})
//
const fitList = [
{
value: 'fill',
label: 'fill'
},
{
value: 'contain',
label: 'contain'
},
{
value: 'cover',
label: 'cover'
},
{
value: 'scale-down',
label: 'scale-down'
},
{
value: 'none',
label: 'none'
},
]
</script>

View File

@ -0,0 +1,14 @@
import { ConfigType, PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d'
import { ChatCategoryEnum,ChatCategoryEnumName } from '@/packages/components/Decorates/index.d'
export const BaseConfig: ConfigType = {
key: 'Base',
chartKey: 'VBase',
conKey: 'VCBase',
title: '底座',
category: ChatCategoryEnum.BASE,
categoryName: ChatCategoryEnumName.BASE,
package: PackagesCategoryEnum.DECORATES,
chartFrame: ChartFrameEnum.STATIC,
image: ''
}

View File

@ -0,0 +1,48 @@
<template>
<div :style="getStyle(borderRadius)">
<n-image
:object-fit="fit"
preview-disabled
:src="imageInfo"
:fallback-src="requireErrorImg()"
:width="w"
lazy
style="position: absolute;left: 0;width: 100%;height: 100%"
/>
</div>
</template>
<script setup lang="ts">
import { PropType, ref, toRefs } from 'vue'
import { requireErrorImg } from '@/utils'
import { CreateComponentType } from '@/packages/index.d'
import { fetchImages } from "@/packages/index";
const props = defineProps({
chartConfig: {
type: Object as PropType<CreateComponentType>,
required: true
}
})
const { w, h } = toRefs(props.chartConfig.attr)
const { dataset, fit, borderRadius } = toRefs(props.chartConfig.option)
let imageInfo = ref('')
//
const fetchImageUrl = async () => {
imageInfo.value = await fetchImages(props.chartConfig.chartConfig)
}
fetchImageUrl()
const getStyle = (radius: number) => {
return {
// borderRadius: `${radius}px`,
overflow: 'hidden'
}
}
</script>
<style lang="scss" scoped>
</style>

View File

@ -0,0 +1,27 @@
import { BaseConfig } from './Base/index'
import { PackagesCategoryEnum } from '@/packages/index.d'
import { ChatCategoryEnum, ChatCategoryEnumName } from '../index.d'
const topbarNames = [
'Base1.png',
'Base2.png',
'Base3.png',
'Base4.png',
'Base5.png',
'Base6.png',
'Base7.png',
'Base8.png',
]
const base = topbarNames.map((name, i) => ({
...BaseConfig,
category: ChatCategoryEnum.BASE,
categoryName: ChatCategoryEnumName.BASE,
package: PackagesCategoryEnum.DECORATES,
dataset: name,
// 既是缩略图 又是背景图
image: name,
title: `底座${i + 1}`,
redirectComponent: `${BaseConfig.package}/${BaseConfig.category}/${BaseConfig.key}` // 跳转组件路径规则packageName/categoryName/componentKey
}))
export default base

View File

@ -3,7 +3,8 @@ export enum ChatCategoryEnum {
DECORATE = 'Decorates', DECORATE = 'Decorates',
THREE = 'Three', THREE = 'Three',
MORE = 'Mores', MORE = 'Mores',
TOPBARS = 'TopBars' TOPBARS = 'TopBars',
BASE = 'Base'
} }
export enum ChatCategoryEnumName { export enum ChatCategoryEnumName {
@ -11,5 +12,6 @@ export enum ChatCategoryEnumName {
DECORATE = '装饰', DECORATE = '装饰',
THREE = '三维', THREE = '三维',
MORE = '更多', MORE = '更多',
TOPBARS = '顶栏' TOPBARS = '顶栏',
BASE = '底座'
} }

View File

@ -1,8 +1,9 @@
import Borders from './Borders' import Borders from './Borders'
import TopBars from './TopBars' import TopBars from './TopBars'
import Base from './Base'
import Decorates from './Decorates' import Decorates from './Decorates'
// import Three from './Three' // import Three from './Three'
import Mores from './Mores' import Mores from './Mores'
// export const DecorateList = [...Borders, ...Decorates, ...Three, ...Mores] // export const DecorateList = [...Borders, ...Decorates, ...Three, ...Mores]
export const DecorateList = [...Borders, ...TopBars, ...Decorates, ...Mores] export const DecorateList = [...Borders, ...TopBars, ...Base, ...Decorates, ...Mores]

View File

@ -128,8 +128,11 @@ const dblclickHandle = async (item: ConfigType) => {
newComponent.chartConfig.title = item.title newComponent.chartConfig.title = item.title
newComponent.chartConfig.chartFrame = item.chartFrame newComponent.chartConfig.chartFrame = item.chartFrame
} }
let isHead = false
let isHeadList = ['EngineeringConfig']
if(isHeadList.includes(newComponent.chartConfig.key)) isHead = true
// //
chartEditStore.addComponentList(newComponent, false, true) chartEditStore.addComponentList(newComponent, isHead, true)
// //
chartEditStore.setTargetSelectChart(newComponent.id) chartEditStore.setTargetSelectChart(newComponent.id)
loadingFinish() loadingFinish()