Commit d5b71105a2d48bf3e4b51eca5cdb4d05a01a56a6

Authored by fengwotao
1 parent 49ef9aae

perf(src/packages): 信息里的控件移除自定义样式

... ... @@ -4,26 +4,23 @@ import { PublicConfigClass } from '@/packages/public'
4 4 import { CreateComponentType } from '@/packages/index.d'
5 5 import { chartInitConfig } from '@/settings/designSetting'
6 6 import { COMPONENT_INTERACT_EVENT_KET } from '@/enums/eventEnum'
7   -import { interactActions, ComponentInteractEventEnum } from './interact'
  7 +import { interactActions, ComponentInteractEventEnum, DefaultTypeEnum, DifferUnitEnum } from './interact'
8 8 import { OverrideInputsDateConfig } from './index'
9 9
10 10 export const option = {
11 11 // 时间组件展示类型,必须和 interactActions 中定义的数据一致
12   - [COMPONENT_INTERACT_EVENT_KET]: ComponentInteractEventEnum.DATE,
  12 + [COMPONENT_INTERACT_EVENT_KET]: ComponentInteractEventEnum.DATE_RANGE,
13 13 // 下拉展示
14 14 isPanel: 0,
15   - dataset: dayjs().valueOf(),
16   - differValue: 0,
17   - selectStyleOptions: {
18   - textColor: 'black',
19   - textBackgroundColor: 'white',
20   - textBackgroundColorAlpha: 1,
21   - iconColor: 'black',
22   - //弹出下拉框
23   - textSelectModalBackgroundColor: 'black',
24   - textSelectModalTextColor: 'black'
25   - },
26   - shortcut: null
  15 + // 默认值
  16 + dataset: dayjs().valueOf() as number | number[] | null,
  17 + // 默认值类型
  18 + defaultType: DefaultTypeEnum.STATIC,
  19 + // 动态默认值偏移单位
  20 + differUnit: [DifferUnitEnum.DAY, DifferUnitEnum.DAY],
  21 + // 动态默认值偏移值
  22 + differValue: [0, 0],
  23 + shortcut: 24*60*60*1000
27 24 }
28 25
29 26 export default class Config extends PublicConfigClass implements CreateComponentType {
... ...
... ... @@ -12,114 +12,67 @@
12 12 </setting-item-box>
13 13 <setting-item-box name="基础">
14 14 <setting-item name="类型">
15   - <n-select v-model:value="optionData.componentInteractEventKey" size="small" :options="datePickerTypeOptions" />
  15 + <n-select v-model:value="optionData.componentInteractEventKey" size="small" :options="datePickerTypeOptions"
  16 + @update:value="datePickerTypeUpdate"/>
16 17 </setting-item>
17 18 </setting-item-box>
18   - <setting-item-box name="默认值" :alone="true">
19   - <n-date-picker size="small" v-model:value="optionData.dataset" :type="optionData.componentInteractEventKey" />
  19 + <setting-item-box name="默认值">
  20 + <setting-item name="类型">
  21 + <n-select v-model:value="optionData.defaultType" size="small" :options="defaultTypeOptions"
  22 + @update:value="defaultTypeUpdate" />
  23 + </setting-item>
  24 +
  25 + </setting-item-box>
  26 + <setting-item-box v-if="optionData.defaultType === DefaultTypeEnum.STATIC" :alone="true">
  27 + <setting-item name="静态默认值">
  28 + <n-date-picker size="small" clearable v-model:value="optionData.dataset" :type="optionData.componentInteractEventKey" />
  29 + </setting-item>
20 30 </setting-item-box>
21   - <setting-item-box :alone="true">
  31 + <setting-item-box v-if="optionData.defaultType === DefaultTypeEnum.DYNAMIC" >
22 32 <template #name>
23   - <n-text>动态</n-text>
  33 + <n-text></n-text>
24 34 <n-tooltip trigger="hover">
25 35 <template #trigger>
26 36 <n-icon size="21" :depth="3">
27 37 <help-outline-icon></help-outline-icon>
28 38 </n-icon>
29 39 </template>
30   - <n-text>动态值不为0时,默认值:取当天时间相加当前值</n-text>
  40 + <span>打开页面时浏览器操作系统的系统时间+偏移量(单位)</span>
31 41 </n-tooltip>
32 42 </template>
33   - <n-input-number v-model:value="optionData.differValue" class="input-num-width" size="small" :min="-40" :max="40">
34   - <template #suffix> 天 </template>
35   - </n-input-number>
36   - </setting-item-box>
37   - <setting-item-box name="文字颜色" :alone="true">
38   - <SettingItem name="颜色">
39   - <n-color-picker
40   - size="small"
41   - :modes="['hex']"
42   - v-model:value="optionData.selectStyleOptions.textColor"
43   - ></n-color-picker>
44   - </SettingItem>
45   - <SettingItem>
46   - <n-button size="small" @click="optionData.selectStyleOptions.textColor = 'black'"> 恢复默认 </n-button>
47   - </SettingItem>
48   - </setting-item-box>
49   - <setting-item-box name="背景颜色" :alone="true">
50   - <SettingItem name="颜色">
51   - <n-color-picker
52   - size="small"
53   - :modes="['hex']"
54   - v-model:value="optionData.selectStyleOptions.textBackgroundColor"
55   - ></n-color-picker>
56   - </SettingItem>
57   - <SettingItem>
58   - <n-button size="small" @click="optionData.selectStyleOptions.textBackgroundColor = 'white'">
59   - 恢复默认
60   - </n-button>
61   - </SettingItem>
62   - </setting-item-box>
63   - <setting-item-box name="透明度" :alone="true">
64   - <SettingItem name="透明度">
65   - <n-input-number
66   - :min="0"
67   - :max="1"
68   - v-model:value="optionData.selectStyleOptions.textBackgroundColorAlpha"
69   - clearable
70   - />
71   - </SettingItem>
72   - </setting-item-box>
73   - <setting-item-box name="弹出框背景色" :alone="true">
74   - <SettingItem name="背景色">
75   - <n-color-picker
76   - size="small"
77   - :modes="['hex']"
78   - v-model:value="optionData.selectStyleOptions.textSelectModalBackgroundColor"
79   - ></n-color-picker>
80   - </SettingItem>
81   - <SettingItem>
82   - <n-button size="small" @click="optionData.selectStyleOptions.textSelectModalBackgroundColor = 'white'">
83   - 恢复默认
84   - </n-button>
85   - </SettingItem>
86   - </setting-item-box>
87   - <setting-item-box name="弹出框文字颜色" :alone="true">
88   - <SettingItem name="颜色">
89   - <n-color-picker
90   - size="small"
91   - :modes="['hex']"
92   - v-model:value="optionData.selectStyleOptions.textSelectModalTextColor"
93   - ></n-color-picker>
94   - </SettingItem>
95   - <SettingItem>
96   - <n-button size="small" @click="optionData.selectStyleOptions.textSelectModalTextColor = 'black'">
97   - 恢复默认
98   - </n-button>
99   - </SettingItem>
100   - </setting-item-box>
101   - <setting-item-box name="图标颜色" :alone="true">
102   - <SettingItem name="颜色">
103   - <n-color-picker
104   - size="small"
105   - :modes="['hex']"
106   - v-model:value="optionData.selectStyleOptions.iconColor"
107   - ></n-color-picker>
108   - </SettingItem>
109   - <SettingItem>
110   - <n-button size="small" @click="optionData.selectStyleOptions.iconColor = 'black'"> 恢复默认 </n-button>
111   - </SettingItem>
  43 + <setting-item :name="differValueName">
  44 + <n-input-number v-model:value="optionData.differValue[0]" class="input-num-width" size="small">
  45 + <template #suffix>
  46 + {{DifferUnitObject[optionData.differUnit[0]]}}
  47 + </template>
  48 + </n-input-number>
  49 + </setting-item>
  50 + <setting-item :name="differUnitName">
  51 + <n-select v-model:value="optionData.differUnit[0]" size="small" :options="differUnitOptions" />
  52 + </setting-item>
  53 + <setting-item v-if="isRange" name="结束值动态偏移量">
  54 + <n-input-number v-model:value="optionData.differValue[1]" class="input-num-width" size="small">
  55 + <template #suffix>
  56 + {{DifferUnitObject[optionData.differUnit[1]]}}
  57 + </template>
  58 + </n-input-number>
  59 + </setting-item>
  60 + <setting-item v-if="isRange" name="结束值偏移单位">
  61 + <n-select v-model:value="optionData.differUnit[1]" size="small" :options="differUnitOptions" />
  62 + </setting-item>
112 63 </setting-item-box>
  64 +
113 65 </collapse-item>
114 66 </template>
115 67
116 68 <script lang="ts" setup>
117   -import { PropType } from 'vue'
  69 +import { PropType,computed } from 'vue'
118 70 import { icon } from '@/plugins'
119 71 import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
120 72 import { option } from './config'
121   -import { ComponentInteractEventEnum } from './interact'
122 73 import { intervalOption } from './shortcutTime'
  74 +import { ComponentInteractEventEnum, DefaultTypeEnum, DifferUnitEnum, DifferUnitObject } from './interact'
  75 +import dayjs from "dayjs";
123 76
124 77 const { HelpOutlineIcon } = icon.ionicons5
125 78
... ... @@ -180,9 +133,92 @@ const datePickerTypeOptions = [
180 133 }
181 134 ]
182 135
  136 +const defaultTypeOptions = [
  137 + {
  138 + label: '静态',
  139 + value: DefaultTypeEnum.STATIC
  140 + },
  141 + {
  142 + label: '动态',
  143 + value: DefaultTypeEnum.DYNAMIC
  144 + },
  145 + {
  146 + label: '无',
  147 + value: DefaultTypeEnum.NONE
  148 + }
  149 +]
  150 +
  151 +
  152 +const differUnitOptions = [
  153 + // ManipulateType
  154 + {
  155 + value: DifferUnitEnum.DAY,
  156 + label: DifferUnitObject[DifferUnitEnum.DAY]
  157 + },
  158 + {
  159 + value: DifferUnitEnum.WEEK,
  160 + label: DifferUnitObject[DifferUnitEnum.WEEK]
  161 + },
  162 + {
  163 + value: DifferUnitEnum.MONTH,
  164 + label: DifferUnitObject[DifferUnitEnum.MONTH]
  165 + },
  166 + {
  167 + value: DifferUnitEnum.QUARTER,
  168 + label: DifferUnitObject[DifferUnitEnum.QUARTER]
  169 + },
  170 + {
  171 + value: DifferUnitEnum.YEAR,
  172 + label: DifferUnitObject[DifferUnitEnum.YEAR]
  173 + },
  174 + {
  175 + value: DifferUnitEnum.HOUR,
  176 + label: DifferUnitObject[DifferUnitEnum.HOUR]
  177 + },
  178 + {
  179 + value: DifferUnitEnum.MINUTE,
  180 + label: DifferUnitObject[DifferUnitEnum.MINUTE]
  181 + },
  182 + {
  183 + value: DifferUnitEnum.SECOND,
  184 + label: DifferUnitObject[DifferUnitEnum.SECOND]
  185 + },
  186 + {
  187 + value: DifferUnitEnum.MILLISECOND,
  188 + label: DifferUnitObject[DifferUnitEnum.MILLISECOND]
  189 + }
  190 +]
  191 +
  192 +
  193 +const isRange = computed(() => {
  194 + return props.optionData.componentInteractEventKey.endsWith('range')
  195 +})
  196 +
  197 +const differValueName = computed(() => {
  198 + return isRange.value ? '开始值动态偏移量' : '动态偏移量'
  199 +})
  200 +
  201 +const differUnitName = computed(() => {
  202 + return isRange.value ? '开始值偏移单位' : '偏移单位'
  203 +})
  204 +
  205 +const datePickerTypeUpdate = () => {
  206 + props.optionData.dataset = isRange.value ? [dayjs().valueOf(), dayjs().valueOf()] : dayjs().valueOf()
  207 +}
  208 +
  209 +const defaultTypeUpdate = (v: string) => {
  210 + if (v === DefaultTypeEnum.STATIC) {
  211 + datePickerTypeUpdate()
  212 + } else {
  213 + // DefaultTypeEnum.
  214 + props.optionData.dataset = null
  215 + }
  216 +}
  217 +
183 218 const shortCutSelect = (value: number) => {
184 219 const startTs = Date.now() - value
185 220 const endTs = Date.now()
186 221 props.optionData.dataset = [startTs, endTs] as any
187 222 }
  223 +shortCutSelect(24*60*60*1000)//默认近1天
188 224 </script>
... ...
1 1 <template>
2 2 <n-date-picker
3 3 v-model:value="option.dataset"
  4 + clearable
4 5 :panel="!!chartConfig.option.isPanel"
5 6 :type="chartConfig.option.componentInteractEventKey"
6 7 :style="`width:${w}px;`"
... ... @@ -10,13 +11,14 @@
10 11 </template>
11 12
12 13 <script setup lang="ts">
13   -import { PropType, toRefs, shallowReactive, watch } from 'vue'
14   -import dayjs from 'dayjs'
  14 +import { PropType, toRefs, shallowReactive, watch ,ref,computed} from 'vue'
  15 +import dayjs, {ManipulateType} from 'dayjs'
15 16 import { CreateComponentType } from '@/packages/index.d'
16 17 import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
17 18 import { useChartInteract } from '@/hooks/external/useChartSelectInteract.hook'
18 19 import { InteractEventOn } from '@/enums/eventEnum'
19   -import { ComponentInteractParamsEnum } from './interact'
  20 +import {ComponentInteractEventEnum, ComponentInteractParamsEnum, DefaultTypeEnum} from './interact'
  21 +import quarterOfYear from 'dayjs/plugin/quarterOfYear';
20 22
21 23 const props = defineProps({
22 24 chartConfig: {
... ... @@ -26,70 +28,115 @@ const props = defineProps({
26 28 })
27 29
28 30 const { w, h } = toRefs(props.chartConfig.attr)
29   -
30   -const { textColor, textBackgroundColor, iconColor, textSelectModalBackgroundColor } = toRefs(
31   - props.chartConfig.option.selectStyleOptions
32   -)
  31 +const rangeDate = ref<number | number[]>()
33 32
34 33 const option = shallowReactive({
35 34 dataset: props.chartConfig.option.dataset
36 35 })
37 36
  37 +const isRange = computed(() => {
  38 + return props.chartConfig.option.componentInteractEventKey.endsWith('range')
  39 +})
  40 +
  41 +
38 42 // 监听事件改变
39   -const onChange = (v: number | number[]) => {
40   - if (v instanceof Array) {
  43 +const onChange = (v: number | number[] | null) => {
  44 + if (isRange.value) {
  45 + let dateStart = null
  46 + let dateEnd = null
  47 + let daterange = null
  48 + if(v instanceof Array){
  49 + dateStart = v[0]
  50 + dateEnd = v[1]
  51 + daterange = `${v[0]}-${v[1]}`
  52 + }
41 53 // 存储到联动数据
42 54 useChartInteract(
43   - props.chartConfig,
44   - useChartEditStore,
45   - {
46   - [ComponentInteractParamsEnum.DATE_START]: v[0] || dayjs().valueOf(),
47   - [ComponentInteractParamsEnum.DATE_END]: v[1] || dayjs().valueOf(),
48   - [ComponentInteractParamsEnum.DATE_RANGE]: `${v[0] || dayjs().valueOf()}-${v[1] || dayjs().valueOf()}`
49   - },
50   - InteractEventOn.CHANGE
  55 + props.chartConfig,
  56 + useChartEditStore,
  57 + {
  58 + [ComponentInteractParamsEnum.DATE_START]: dateStart,
  59 + [ComponentInteractParamsEnum.DATE_END]: dateEnd,
  60 + [ComponentInteractParamsEnum.DATE_RANGE]: daterange
  61 + },
  62 + InteractEventOn.CHANGE
51 63 )
52 64 } else {
53 65 // 存储到联动数据
54 66 useChartInteract(
55   - props.chartConfig,
56   - useChartEditStore,
57   - { [ComponentInteractParamsEnum.DATE]: v || dayjs().valueOf() },
58   - InteractEventOn.CHANGE
  67 + props.chartConfig,
  68 + useChartEditStore,
  69 + { [ComponentInteractParamsEnum.DATE]: v },
  70 + InteractEventOn.CHANGE
59 71 )
60 72 }
61 73 }
62 74
63   -watch(
64   - () => props.chartConfig.option.dataset,
65   - (newData: number | number[]) => {
66   - option.dataset = newData
67   - // 关联目标组件首次请求带上默认内容
68   - onChange(newData)
69   - },
70   - {
71   - immediate: true
  75 +const getDiffDate = (type: ComponentInteractEventEnum, date: dayjs.Dayjs) => {
  76 + // 注册 quarterOfYear 插件
  77 + dayjs.extend(quarterOfYear)
  78 + switch (type) {
  79 + case ComponentInteractEventEnum.DATE:
  80 + case ComponentInteractEventEnum.DATE_RANGE:
  81 + date = date.startOf('day')
  82 + break
  83 + case ComponentInteractEventEnum.MONTH:
  84 + case ComponentInteractEventEnum.MONTH_RANGE:
  85 + date = date.startOf('month')
  86 + break
  87 + case ComponentInteractEventEnum.YEAR:
  88 + case ComponentInteractEventEnum.YEAR_RANGE:
  89 + date = date.startOf('year')
  90 + break
  91 + case ComponentInteractEventEnum.QUARTER:
  92 + case ComponentInteractEventEnum.QUARTER_RANGE:
  93 + date = date.startOf('quarter')
  94 + break
  95 + default:
  96 + break
72 97 }
73   -)
  98 + return date
  99 +}
74 100
75   -// 手动更新
76 101 watch(
77   - () => props.chartConfig.option.differValue,
78   - (newData: number) => {
79   - if (props.chartConfig.option.differValue === 0) return
80   - if (typeof option.dataset === 'object') {
81   - option.dataset[0] = dayjs().add(newData, 'day').valueOf()
82   - option.dataset[1] = dayjs().add(newData, 'day').valueOf()
83   - } else {
84   - option.dataset = dayjs().add(newData, 'day').valueOf()
  102 + () => {
  103 + return {
  104 + type: props.chartConfig.option.componentInteractEventKey as ComponentInteractEventEnum,
  105 + defaultType: props.chartConfig.option.defaultType as string,
  106 + differValue: props.chartConfig.option.differValue as number[],
  107 + differUnit: props.chartConfig.option.differUnit as ManipulateType[],
  108 + dataset: props.chartConfig.option.dataset as number | number[] | null,
  109 + };
  110 + },
  111 + (newData, oldData) => {
  112 + const hasTypeChanged = newData.type !== oldData?.type;
  113 + const hasDefaultTypeChanged = newData.defaultType !== oldData?.defaultType;
  114 + const hasDifferValueChanged = newData.differValue !== oldData?.differValue;
  115 + const hasDifferUnitChanged = newData.differUnit !== oldData?.differUnit;
  116 +
  117 + if (hasTypeChanged || hasDefaultTypeChanged || hasDifferValueChanged || hasDifferUnitChanged) {
  118 + if (newData.defaultType === DefaultTypeEnum.NONE) {
  119 + props.chartConfig.option.dataset = null;
  120 + } else if (newData.defaultType === DefaultTypeEnum.DYNAMIC) {
  121 + let date = dayjs();
  122 + if (isRange.value) {
  123 + props.chartConfig.option.dataset = [
  124 + getDiffDate(newData.type,date.add(newData.differValue[0], newData.differUnit[0])).valueOf(),
  125 + getDiffDate(newData.type,date.add(newData.differValue[1], newData.differUnit[1])).valueOf(),
  126 + ];
  127 + } else {
  128 + props.chartConfig.option.dataset = getDiffDate(newData.type,date.add(newData.differValue[0], newData.differUnit[0])).valueOf()
  129 + }
  130 + }
  131 + }
  132 + option.dataset = props.chartConfig.option.dataset;
  133 + onChange(option.dataset);
  134 + },
  135 + {
  136 + immediate: true,
85 137 }
86   - // 关联目标组件首次请求带上默认内容
87   - onChange(newData)
88   - },
89   - {
90   - immediate: true
91   - }
92   -)
  138 +);
  139 +
93 140
94 141 watch(
95 142 () => props.chartConfig.option.shortcut,
... ... @@ -106,25 +153,13 @@ watch(
106 153 )
107 154 </script>
108 155
  156 +
109 157 <style lang="scss" scoped>
110 158 @include deep() {
111 159 .n-input {
112 160 height: v-bind('h + "px"');
113 161 display: flex;
114 162 align-items: center;
115   - background: v-bind('textBackgroundColor') !important;
116   - }
117   - .n-input__input-el {
118   - color: v-bind('textColor') !important;
119   - }
120   - .n-input__placeholder {
121   - color: v-bind('textColor') !important;
122   - }
123   - .n-base-icon {
124   - color: v-bind('iconColor') !important;
125   - }
126   - .n-date-panel {
127   - background: v-bind('textSelectModalBackgroundColor') !important;
128 163 }
129 164 }
130   -</style>
  165 +</style>
\ No newline at end of file
... ...
... ... @@ -22,6 +22,37 @@ export enum ComponentInteractParamsEnum {
22 22 DATE_RANGE = 'daterange'
23 23 }
24 24
  25 +export enum DefaultTypeEnum {
  26 + NONE = "none",
  27 + STATIC = "static",
  28 + DYNAMIC = "dynamic"
  29 +}
  30 +
  31 +export enum DifferUnitEnum {
  32 + DAY = 'd',
  33 + WEEK = 'w',
  34 + MONTH = 'M',
  35 + QUARTER = 'Q',
  36 + YEAR = 'y',
  37 + HOUR = 'h',
  38 + MINUTE = 'm',
  39 + SECOND = 's',
  40 + MILLISECOND = 'ms',
  41 +}
  42 +
  43 +export const DifferUnitObject = {
  44 + // https://day.js.org/docs/en/manipulate/add
  45 + [DifferUnitEnum.DAY]: '天',
  46 + [DifferUnitEnum.WEEK]: '周',
  47 + [DifferUnitEnum.MONTH]: '月',
  48 + [DifferUnitEnum.QUARTER]: '季度',
  49 + [DifferUnitEnum.YEAR]: '年',
  50 + [DifferUnitEnum.HOUR]: '小时',
  51 + [DifferUnitEnum.MINUTE]: '分钟',
  52 + [DifferUnitEnum.SECOND]: '秒',
  53 + [DifferUnitEnum.MILLISECOND]: '毫秒',
  54 +}
  55 +
25 56 const time = [
26 57 {
27 58 value: ComponentInteractParamsEnum.DATE,
... ...
... ... @@ -27,16 +27,7 @@ export const option = {
27 27 label: '选项3',
28 28 value: '3'
29 29 }
30   - ],
31   - //自定义样式
32   - tabStyleOptions: {
33   - textColor: 'green',
34   - textActiveColor: 'black',
35   - textBackgroundColor: '#FFFFFF',
36   - tabBarColor: 'green',
37   - segmentBackgroundColor: '#F7F7FA',
38   - segmentActiveColor: '#FFFFFF'
39   - }
  30 + ]
40 31 }
41 32
42 33 export default class Config extends PublicConfigClass implements CreateComponentType {
... ...
1 1 <template>
2 2 <collapse-item name="标签页配置" :expanded="true">
3   - <setting-item-box name="默认值" :alone="true">
4   - <n-select @change="handleSelect" size="small" v-model:value="optionData.tabType" :options="tabTypeOptions" />
5   - </setting-item-box>
6   - <setting-item-box name="未激活文字颜色" :alone="true">
7   - <SettingItem name="颜色">
8   - <n-color-picker
9   - size="small"
10   - :modes="['hex']"
11   - v-model:value="optionData.tabStyleOptions.textColor"
12   - ></n-color-picker>
13   - </SettingItem>
14   - <SettingItem>
15   - <n-button size="small" @click="optionData.tabStyleOptions.textColor = 'green'"> 恢复默认 </n-button>
16   - </SettingItem>
17   - </setting-item-box>
18   - <setting-item-box name="激活文字颜色" :alone="true">
19   - <SettingItem name="颜色">
20   - <n-color-picker
21   - size="small"
22   - :modes="['hex']"
23   - v-model:value="optionData.tabStyleOptions.textActiveColor"
24   - ></n-color-picker>
25   - </SettingItem>
26   - <SettingItem>
27   - <n-button size="small" @click="optionData.tabStyleOptions.textActiveColor = 'black'"> 恢复默认 </n-button>
28   - </SettingItem>
29   - </setting-item-box>
30   - <setting-item-box v-if="optionData.tabType === 'bar'" name="导航条颜色" :alone="true">
31   - <SettingItem name="颜色">
32   - <n-color-picker
33   - size="small"
34   - :modes="['hex']"
35   - v-model:value="optionData.tabStyleOptions.tabBarColor"
36   - ></n-color-picker>
37   - </SettingItem>
38   - <SettingItem>
39   - <n-button size="small" @click="optionData.tabStyleOptions.tabBarColor = 'green'"> 恢复默认 </n-button>
40   - </SettingItem>
  3 + <setting-item-box name="标签类型" :alone="true">
  4 + <n-select size="small" v-model:value="optionData.tabType" :options="tabTypeOptions" />
41 5 </setting-item-box>
42   - <setting-item-box v-if="optionData.tabType === 'segment'" name="分段背景色" :alone="true">
43   - <SettingItem name="颜色">
44   - <n-color-picker
45   - size="small"
46   - :modes="['hex']"
47   - v-model:value="optionData.tabStyleOptions.segmentBackgroundColor"
48   - ></n-color-picker>
49   - </SettingItem>
50   - <SettingItem>
51   - <n-button size="small" @click="optionData.tabStyleOptions.segmentBackgroundColor = 'grey'"> 恢复默认 </n-button>
52   - </SettingItem>
53   - </setting-item-box>
54   - <setting-item-box v-if="optionData.tabType === 'segment'" name="分段激活背景色" :alone="true">
55   - <SettingItem name="颜色">
56   - <n-color-picker
57   - size="small"
58   - :modes="['hex']"
59   - v-model:value="optionData.tabStyleOptions.segmentActiveColor"
60   - ></n-color-picker>
61   - </SettingItem>
62   - <SettingItem>
63   - <n-button size="small" @click="optionData.tabStyleOptions.segmentActiveColor = 'white'"> 恢复默认 </n-button>
64   - </SettingItem>
  6 + <setting-item-box name="默认值" :alone="true">
  7 + <n-select size="small" v-model:value="optionData.tabLabel" value-field="label" :options="optionData.dataset" />
65 8 </setting-item-box>
66 9 </collapse-item>
67 10 </template>
... ... @@ -71,7 +14,7 @@ import { PropType } from 'vue'
71 14 import { CollapseItem, SettingItemBox } from '@/components/Pages/ChartItemSetting'
72 15 import { option } from './config'
73 16
74   -const props = defineProps({
  17 +defineProps({
75 18 optionData: {
76 19 type: Object as PropType<typeof option>,
77 20 required: true
... ... @@ -88,11 +31,4 @@ const tabTypeOptions = [
88 31 value: 'segment'
89 32 }
90 33 ]
91   -
92   -const handleSelect = (e: string) => {
93   - if (e === 'bar') {
94   - props.optionData.tabStyleOptions.segmentActiveColor = ''
95   - props.optionData.tabStyleOptions.segmentBackgroundColor = ''
96   - }
97   -}
98 34 </script>
... ...
1 1 <template>
2   - <n-tabs :type="option.value.tabType" @update:value="onChange">
  2 + <n-tabs :type="option.value.tabType" @update:value="onChange" :default-value="option.value.tabLabel">
3 3 <n-tab v-for="(item, index) in option.value.dataset" :name="item.label" :key="index"> {{ item.label }} </n-tab>
4 4 </n-tabs>
5 5 </template>
... ... @@ -22,8 +22,6 @@ const props = defineProps({
22 22
23 23 const { w, h } = toRefs(props.chartConfig.attr)
24 24
25   -const { tabStyleOptions } = toRefs(props.chartConfig.option)
26   -
27 25 const option = shallowReactive({
28 26 value: cloneDeep(props.chartConfig.option)
29 27 })
... ... @@ -60,22 +58,3 @@ watch(
60 58 }
61 59 )
62 60 </script>
63   -
64   -<style lang="scss" scoped>
65   -@include deep() {
66   - .n-tabs-tab {
67   - color: v-bind('tabStyleOptions.textColor') !important;
68   - background: v-bind('tabStyleOptions.segmentBackgroundColor') !important;
69   - }
70   - .n-tabs-tab--active {
71   - color: v-bind('tabStyleOptions.textActiveColor') !important;
72   - background: v-bind('tabStyleOptions.segmentActiveColor') !important;
73   - }
74   - .n-tabs-bar {
75   - background-color: v-bind('tabStyleOptions.tabBarColor') !important;
76   - }
77   - .n-tabs-tab-wrapper {
78   - background-color: v-bind('tabStyleOptions.segmentBackgroundColor') !important;
79   - }
80   -}
81   -</style>
... ...
... ... @@ -25,16 +25,7 @@ export const option = {
25 25 label: '选项3',
26 26 value: '3'
27 27 }
28   - ],
29   - selectStyleOptions: {
30   - textColor: 'black',
31   - textBackgroundColor: 'white',
32   - textBackgroundColorAlpha: 1,
33   - iconColor:'grey',
34   - //弹出下拉框
35   - textSelectModalBackgroundColor: 'white',
36   - textSelectModalTextColor: 'black'
37   - }
  28 + ]
38 29 }
39 30
40 31 export default class Config extends PublicConfigClass implements CreateComponentType {
... ...
1 1 <template>
2 2 <collapse-item name="下拉配置" :expanded="true">
3   - <setting-item-box name="选择项" :alone="true">
  3 + <setting-item-box name="默认值" :alone="true">
4 4 <SettingItem name="选择项">
5 5 <n-select filterable multiple size="small" v-model:value="optionData.selectValue" :options="optionData.dataset" />
6 6 </SettingItem>
7 7 </setting-item-box>
8   - <setting-item-box name="文字颜色" :alone="true">
9   - <SettingItem name="颜色">
10   - <n-color-picker
11   - size="small"
12   - :modes="['hex']"
13   - v-model:value="optionData.selectStyleOptions.textColor"
14   - ></n-color-picker>
15   - </SettingItem>
16   - <SettingItem>
17   - <n-button size="small" @click="optionData.selectStyleOptions.textColor = 'black'"> 恢复默认 </n-button>
18   - </SettingItem>
19   - </setting-item-box>
20   - <setting-item-box name="背景颜色" :alone="true">
21   - <SettingItem name="颜色">
22   - <n-color-picker
23   - size="small"
24   - :modes="['hex']"
25   - v-model:value="optionData.selectStyleOptions.textBackgroundColor"
26   - ></n-color-picker>
27   - </SettingItem>
28   - <SettingItem>
29   - <n-button size="small" @click="optionData.selectStyleOptions.textBackgroundColor = 'white'">
30   - 恢复默认
31   - </n-button>
32   - </SettingItem>
33   - </setting-item-box>
34   - <setting-item-box name="透明度" :alone="true">
35   - <SettingItem name="透明度">
36   - <n-input-number
37   - :min="0"
38   - :max="1"
39   - v-model:value="optionData.selectStyleOptions.textBackgroundColorAlpha"
40   - clearable
41   - />
42   - </SettingItem>
43   - </setting-item-box>
44   - <setting-item-box name="弹出框背景色" :alone="true">
45   - <SettingItem name="背景色">
46   - <n-color-picker
47   - size="small"
48   - :modes="['hex']"
49   - v-model:value="optionData.selectStyleOptions.textSelectModalBackgroundColor"
50   - ></n-color-picker>
51   - </SettingItem>
52   - <SettingItem>
53   - <n-button size="small" @click="optionData.selectStyleOptions.textSelectModalBackgroundColor = 'white'">
54   - 恢复默认
55   - </n-button>
56   - </SettingItem>
57   - </setting-item-box>
58   - <setting-item-box name="弹出框文字颜色" :alone="true">
59   - <SettingItem name="颜色">
60   - <n-color-picker
61   - size="small"
62   - :modes="['hex']"
63   - v-model:value="optionData.selectStyleOptions.textSelectModalTextColor"
64   - ></n-color-picker>
65   - </SettingItem>
66   - <SettingItem>
67   - <n-button size="small" @click="optionData.selectStyleOptions.textSelectModalTextColor = 'black'">
68   - 恢复默认
69   - </n-button>
70   - </SettingItem>
71   - </setting-item-box>
72   - <setting-item-box name="图标颜色" :alone="true">
73   - <SettingItem name="颜色">
74   - <n-color-picker
75   - size="small"
76   - :modes="['hex']"
77   - v-model:value="optionData.selectStyleOptions.iconColor"
78   - ></n-color-picker>
79   - </SettingItem>
80   - <SettingItem>
81   - <n-button size="small" @click="optionData.selectStyleOptions.iconColor = 'black'"> 恢复默认 </n-button>
82   - </SettingItem>
83   - </setting-item-box>
84 8 </collapse-item>
85 9 </template>
86 10
... ...
... ... @@ -4,7 +4,6 @@
4 4 v-model:value="option.value.selectValue"
5 5 :options="option.value.dataset"
6 6 :style="`width:${w}px;`"
7   - :to="false"
8 7 @update:value="onChange"
9 8 />
10 9 </template>
... ... @@ -26,15 +25,6 @@ const props = defineProps({
26 25
27 26 const { w, h } = toRefs(props.chartConfig.attr)
28 27
29   -const {
30   - textColor,
31   - textBackgroundColor,
32   - iconColor,
33   - textBackgroundColorAlpha,
34   - textSelectModalBackgroundColor,
35   - textSelectModalTextColor
36   -} = toRefs(props.chartConfig.option.selectStyleOptions) as any
37   -
38 28 const option = shallowReactive({
39 29 value: {
40 30 selectValue: props.chartConfig.option.selectValue,
... ... @@ -67,28 +57,12 @@ watch(
67 57 )
68 58 </script>
69 59
70   -<style lang="css"></style>
71   -
72 60 <style lang="scss" scoped>
73 61 @include deep() {
74 62 .n-base-selection-label {
75 63 height: v-bind('h + "px"');
76 64 display: flex;
77 65 align-items: center;
78   - background: v-bind('textBackgroundColor') !important;
79   - opacity: v-bind('textBackgroundColorAlpha') !important;
80   - }
81   - .n-base-selection-input__content {
82   - color: v-bind('textColor');
83   - }
84   - .n-base-icon {
85   - color: v-bind('iconColor') !important;
86   - }
87   - .n-select-menu {
88   - background: v-bind('textSelectModalBackgroundColor') !important;
89   - }
90   - .n-base-select-option__content {
91   - color: v-bind('textSelectModalTextColor') !important;
92 66 }
93 67 }
94 68 </style>
... ...