Commit b9f88a0f264ff583874b83f9c3821ab8019aa220
1 parent
324b412a
feat(src/packages): 信息下的控件 时间选择器,右侧配置选择日期类型默认值和快捷选择不一致问题
Showing
1 changed file
with
39 additions
and
19 deletions
@@ -7,28 +7,46 @@ | @@ -7,28 +7,46 @@ | ||
7 | <collapse-item name="时间配置" :expanded="true"> | 7 | <collapse-item name="时间配置" :expanded="true"> |
8 | <setting-item-box name="快捷选择"> | 8 | <setting-item-box name="快捷选择"> |
9 | <setting-item name="日期"> | 9 | <setting-item name="日期"> |
10 | - <n-select clearable @change="shortCutSelect" v-model:value="optionData.shortcut" size="small" :options="intervalOption" /> | 10 | + <n-select |
11 | + clearable | ||
12 | + @change="shortCutSelect" | ||
13 | + v-model:value="optionData.shortcut" | ||
14 | + size="small" | ||
15 | + :options="intervalOption" | ||
16 | + /> | ||
11 | </setting-item> | 17 | </setting-item> |
12 | </setting-item-box> | 18 | </setting-item-box> |
13 | <setting-item-box name="基础"> | 19 | <setting-item-box name="基础"> |
14 | <setting-item name="类型"> | 20 | <setting-item name="类型"> |
15 | - <n-select v-model:value="optionData.componentInteractEventKey" size="small" :options="datePickerTypeOptions" | ||
16 | - @update:value="datePickerTypeUpdate"/> | 21 | + <n-select |
22 | + v-model:value="optionData.componentInteractEventKey" | ||
23 | + size="small" | ||
24 | + :options="datePickerTypeOptions" | ||
25 | + @update:value="datePickerTypeUpdate" | ||
26 | + /> | ||
17 | </setting-item> | 27 | </setting-item> |
18 | </setting-item-box> | 28 | </setting-item-box> |
19 | <setting-item-box name="默认值"> | 29 | <setting-item-box name="默认值"> |
20 | <setting-item name="类型"> | 30 | <setting-item name="类型"> |
21 | - <n-select v-model:value="optionData.defaultType" size="small" :options="defaultTypeOptions" | ||
22 | - @update:value="defaultTypeUpdate" /> | 31 | + <n-select |
32 | + v-model:value="optionData.defaultType" | ||
33 | + size="small" | ||
34 | + :options="defaultTypeOptions" | ||
35 | + @update:value="defaultTypeUpdate" | ||
36 | + /> | ||
23 | </setting-item> | 37 | </setting-item> |
24 | - | ||
25 | </setting-item-box> | 38 | </setting-item-box> |
26 | <setting-item-box v-if="optionData.defaultType === DefaultTypeEnum.STATIC" :alone="true"> | 39 | <setting-item-box v-if="optionData.defaultType === DefaultTypeEnum.STATIC" :alone="true"> |
27 | <setting-item name="静态默认值"> | 40 | <setting-item name="静态默认值"> |
28 | - <n-date-picker size="small" clearable v-model:value="optionData.dataset" :type="optionData.componentInteractEventKey" /> | 41 | + <n-date-picker |
42 | + size="small" | ||
43 | + clearable | ||
44 | + v-model:value="optionData.dataset" | ||
45 | + :type="optionData.componentInteractEventKey" | ||
46 | + /> | ||
29 | </setting-item> | 47 | </setting-item> |
30 | </setting-item-box> | 48 | </setting-item-box> |
31 | - <setting-item-box v-if="optionData.defaultType === DefaultTypeEnum.DYNAMIC" > | 49 | + <setting-item-box v-if="optionData.defaultType === DefaultTypeEnum.DYNAMIC"> |
32 | <template #name> | 50 | <template #name> |
33 | <n-text></n-text> | 51 | <n-text></n-text> |
34 | <n-tooltip trigger="hover"> | 52 | <n-tooltip trigger="hover"> |
@@ -43,7 +61,7 @@ | @@ -43,7 +61,7 @@ | ||
43 | <setting-item :name="differValueName"> | 61 | <setting-item :name="differValueName"> |
44 | <n-input-number v-model:value="optionData.differValue[0]" class="input-num-width" size="small"> | 62 | <n-input-number v-model:value="optionData.differValue[0]" class="input-num-width" size="small"> |
45 | <template #suffix> | 63 | <template #suffix> |
46 | - {{DifferUnitObject[optionData.differUnit[0]]}} | 64 | + {{ DifferUnitObject[optionData.differUnit[0]] }} |
47 | </template> | 65 | </template> |
48 | </n-input-number> | 66 | </n-input-number> |
49 | </setting-item> | 67 | </setting-item> |
@@ -53,7 +71,7 @@ | @@ -53,7 +71,7 @@ | ||
53 | <setting-item v-if="isRange" name="结束值动态偏移量"> | 71 | <setting-item v-if="isRange" name="结束值动态偏移量"> |
54 | <n-input-number v-model:value="optionData.differValue[1]" class="input-num-width" size="small"> | 72 | <n-input-number v-model:value="optionData.differValue[1]" class="input-num-width" size="small"> |
55 | <template #suffix> | 73 | <template #suffix> |
56 | - {{DifferUnitObject[optionData.differUnit[1]]}} | 74 | + {{ DifferUnitObject[optionData.differUnit[1]] }} |
57 | </template> | 75 | </template> |
58 | </n-input-number> | 76 | </n-input-number> |
59 | </setting-item> | 77 | </setting-item> |
@@ -61,18 +79,17 @@ | @@ -61,18 +79,17 @@ | ||
61 | <n-select v-model:value="optionData.differUnit[1]" size="small" :options="differUnitOptions" /> | 79 | <n-select v-model:value="optionData.differUnit[1]" size="small" :options="differUnitOptions" /> |
62 | </setting-item> | 80 | </setting-item> |
63 | </setting-item-box> | 81 | </setting-item-box> |
64 | - | ||
65 | </collapse-item> | 82 | </collapse-item> |
66 | </template> | 83 | </template> |
67 | 84 | ||
68 | <script lang="ts" setup> | 85 | <script lang="ts" setup> |
69 | -import { PropType,computed } from 'vue' | 86 | +import { PropType, computed, ref } from 'vue' |
70 | import { icon } from '@/plugins' | 87 | import { icon } from '@/plugins' |
71 | import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting' | 88 | import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting' |
72 | import { option } from './config' | 89 | import { option } from './config' |
73 | import { intervalOption } from './shortcutTime' | 90 | import { intervalOption } from './shortcutTime' |
74 | import { ComponentInteractEventEnum, DefaultTypeEnum, DifferUnitEnum, DifferUnitObject } from './interact' | 91 | import { ComponentInteractEventEnum, DefaultTypeEnum, DifferUnitEnum, DifferUnitObject } from './interact' |
75 | -import dayjs from "dayjs"; | 92 | +import dayjs from 'dayjs' |
76 | 93 | ||
77 | const { HelpOutlineIcon } = icon.ionicons5 | 94 | const { HelpOutlineIcon } = icon.ionicons5 |
78 | 95 | ||
@@ -152,7 +169,6 @@ const defaultTypeOptions = [ | @@ -152,7 +169,6 @@ const defaultTypeOptions = [ | ||
152 | } | 169 | } |
153 | ] | 170 | ] |
154 | 171 | ||
155 | - | ||
156 | const differUnitOptions = [ | 172 | const differUnitOptions = [ |
157 | // ManipulateType | 173 | // ManipulateType |
158 | { | 174 | { |
@@ -193,7 +209,6 @@ const differUnitOptions = [ | @@ -193,7 +209,6 @@ const differUnitOptions = [ | ||
193 | } | 209 | } |
194 | ] | 210 | ] |
195 | 211 | ||
196 | - | ||
197 | const isRange = computed(() => { | 212 | const isRange = computed(() => { |
198 | return props.optionData.componentInteractEventKey.endsWith('range') | 213 | return props.optionData.componentInteractEventKey.endsWith('range') |
199 | }) | 214 | }) |
@@ -206,8 +221,13 @@ const differUnitName = computed(() => { | @@ -206,8 +221,13 @@ const differUnitName = computed(() => { | ||
206 | return isRange.value ? '开始值偏移单位' : '偏移单位' | 221 | return isRange.value ? '开始值偏移单位' : '偏移单位' |
207 | }) | 222 | }) |
208 | 223 | ||
224 | +const startTs = ref(0) | ||
225 | +const endTs = ref(0) | ||
226 | + | ||
209 | const datePickerTypeUpdate = () => { | 227 | const datePickerTypeUpdate = () => { |
210 | - props.optionData.dataset = isRange.value ? [dayjs().valueOf(), dayjs().valueOf()] : [dayjs().valueOf()] | 228 | + props.optionData.dataset = isRange.value |
229 | + ? [startTs.value ? startTs.value : dayjs().valueOf(), endTs.value ? endTs.value : dayjs().valueOf()] | ||
230 | + : [dayjs().valueOf()] | ||
211 | } | 231 | } |
212 | 232 | ||
213 | const defaultTypeUpdate = (v: string) => { | 233 | const defaultTypeUpdate = (v: string) => { |
@@ -220,9 +240,9 @@ const defaultTypeUpdate = (v: string) => { | @@ -220,9 +240,9 @@ const defaultTypeUpdate = (v: string) => { | ||
220 | } | 240 | } |
221 | 241 | ||
222 | const shortCutSelect = (value: number) => { | 242 | const shortCutSelect = (value: number) => { |
223 | - const startTs = Date.now() - value | ||
224 | - const endTs = Date.now() | ||
225 | - props.optionData.dataset = [startTs, endTs] as any | 243 | + startTs.value = Date.now() - value |
244 | + endTs.value = Date.now() | ||
245 | + props.optionData.dataset = [startTs.value, endTs.value] as any | ||
226 | } | 246 | } |
227 | // shortCutSelect(24*60*60*1000)//默认近1天 | 247 | // shortCutSelect(24*60*60*1000)//默认近1天 |
228 | </script> | 248 | </script> |