mirror of
https://gitee.com/dromara/go-view.git
synced 2024-11-30 02:38:30 +08:00
feat: 新增 tab 组件
This commit is contained in:
parent
339d1305ce
commit
b18e67face
BIN
src/assets/images/chart/informations/inputs_tab.png
Normal file
BIN
src/assets/images/chart/informations/inputs_tab.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.9 KiB |
@ -23,8 +23,6 @@ const props = defineProps({
|
||||
})
|
||||
|
||||
const { w, h } = toRefs(props.chartConfig.attr)
|
||||
const rangeDate = ref<number | number[]>()
|
||||
|
||||
const option = shallowReactive({
|
||||
value: {
|
||||
selectValue: props.chartConfig.option.selectValue,
|
||||
|
@ -0,0 +1,40 @@
|
||||
import dayjs from 'dayjs'
|
||||
import cloneDeep from 'lodash/cloneDeep'
|
||||
import { PublicConfigClass } from '@/packages/public'
|
||||
import { CreateComponentType } from '@/packages/index.d'
|
||||
import { chartInitConfig } from '@/settings/designSetting'
|
||||
import { COMPONENT_INTERACT_EVENT_KET } from '@/enums/eventEnum'
|
||||
import { interactActions, ComponentInteractEventEnum } from './interact'
|
||||
import { InputsTabConfig } from './index'
|
||||
|
||||
export const option = {
|
||||
// 时间组件展示类型,必须和 interactActions 中定义的数据一致
|
||||
[COMPONENT_INTERACT_EVENT_KET]: ComponentInteractEventEnum.DATA,
|
||||
// 默认值
|
||||
tabLabel: '选项1',
|
||||
// 样式
|
||||
tabType: 'segment',
|
||||
// 暴露配置内容给用户
|
||||
dataset: [
|
||||
{
|
||||
label: '选项1',
|
||||
value: '1'
|
||||
},
|
||||
{
|
||||
label: '选项2',
|
||||
value: '2'
|
||||
},
|
||||
{
|
||||
label: '选项3',
|
||||
value: '3'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
export default class Config extends PublicConfigClass implements CreateComponentType {
|
||||
public key = InputsTabConfig.key
|
||||
public attr = { ...chartInitConfig, w: 460, h: 32, zIndex: -1 }
|
||||
public chartConfig = cloneDeep(InputsTabConfig)
|
||||
public interactActions = interactActions
|
||||
public option = cloneDeep(option)
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
<template>
|
||||
<collapse-item name="标签页配置" :expanded="true">
|
||||
<setting-item-box name="默认值" :alone="true">
|
||||
<n-select size="small" v-model:value="optionData.tabType" :options="tabTypeOptions" />
|
||||
</setting-item-box>
|
||||
</collapse-item>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { PropType } from 'vue'
|
||||
import { CollapseItem, SettingItemBox } from '@/components/Pages/ChartItemSetting'
|
||||
import { option } from './config'
|
||||
|
||||
defineProps({
|
||||
optionData: {
|
||||
type: Object as PropType<typeof option>,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
|
||||
const tabTypeOptions = [
|
||||
{
|
||||
label: '线条',
|
||||
value: 'bar'
|
||||
},
|
||||
{
|
||||
label: '分段',
|
||||
value: 'segment'
|
||||
}
|
||||
]
|
||||
</script>
|
@ -0,0 +1,14 @@
|
||||
import { ConfigType, PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d'
|
||||
import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d'
|
||||
|
||||
export const InputsTabConfig: ConfigType = {
|
||||
key: 'InputsTab',
|
||||
chartKey: 'VInputsTab',
|
||||
conKey: 'VCInputsTab',
|
||||
title: '标签选择器',
|
||||
category: ChatCategoryEnum.INPUTS,
|
||||
categoryName: ChatCategoryEnumName.INPUTS,
|
||||
package: PackagesCategoryEnum.INFORMATIONS,
|
||||
chartFrame: ChartFrameEnum.STATIC,
|
||||
image: 'inputs_tab.png'
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
<template>
|
||||
<n-tabs :type="option.value.tabType" @update:value="onChange">
|
||||
<n-tab v-for="(item, index) in option.value.dataset" :name="item.label" :key="index"> {{ item.label }} </n-tab>
|
||||
</n-tabs>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { PropType, toRefs, shallowReactive, watch } from 'vue'
|
||||
import cloneDeep from 'lodash/cloneDeep'
|
||||
import { CreateComponentType } from '@/packages/index.d'
|
||||
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||
import { useChartInteract } from '@/hooks'
|
||||
import { InteractEventOn } from '@/enums/eventEnum'
|
||||
import { ComponentInteractParamsEnum } from './interact'
|
||||
|
||||
const props = defineProps({
|
||||
chartConfig: {
|
||||
type: Object as PropType<CreateComponentType>,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
|
||||
const { w, h } = toRefs(props.chartConfig.attr)
|
||||
const option = shallowReactive({
|
||||
value: cloneDeep(props.chartConfig.option)
|
||||
})
|
||||
|
||||
// 监听事件改变
|
||||
const onChange = (v: string) => {
|
||||
if (v === undefined) return
|
||||
const selectItem = option.value.dataset.find((item: { label: string; value: any }) => item.label === v)
|
||||
// 存储到联动数据
|
||||
useChartInteract(
|
||||
props.chartConfig,
|
||||
useChartEditStore,
|
||||
{ [ComponentInteractParamsEnum.DATA]: selectItem.value },
|
||||
InteractEventOn.CHANGE
|
||||
)
|
||||
}
|
||||
|
||||
// 手动更新
|
||||
watch(
|
||||
() => props.chartConfig.option,
|
||||
(newData: any) => {
|
||||
option.value = newData
|
||||
onChange(newData.tabValue)
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
deep: true
|
||||
}
|
||||
)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@include deep() {
|
||||
}
|
||||
</style>
|
@ -0,0 +1,27 @@
|
||||
import { InteractEventOn, InteractActionsType } from '@/enums/eventEnum'
|
||||
|
||||
// 时间组件类型
|
||||
export enum ComponentInteractEventEnum {
|
||||
DATA = 'data'
|
||||
}
|
||||
|
||||
// 联动参数
|
||||
export enum ComponentInteractParamsEnum {
|
||||
DATA = 'data'
|
||||
}
|
||||
|
||||
// 定义组件触发回调事件
|
||||
export const interactActions: InteractActionsType[] = [
|
||||
{
|
||||
interactType: InteractEventOn.CHANGE,
|
||||
interactName: '选择完成',
|
||||
componentEmitEvents: {
|
||||
[ComponentInteractEventEnum.DATA]: [
|
||||
{
|
||||
value: ComponentInteractParamsEnum.DATA,
|
||||
label: '选择项'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
@ -1,4 +1,5 @@
|
||||
import { InputsDateConfig } from './InputsDate/index'
|
||||
import { InputsSelectConfig } from './InputsSelect/index'
|
||||
import { InputsTabConfig } from './InputsTab/index'
|
||||
|
||||
export default [InputsDateConfig, InputsSelectConfig]
|
||||
export default [InputsDateConfig, InputsSelectConfig, InputsTabConfig]
|
||||
|
Loading…
Reference in New Issue
Block a user