Commit edf25625ce3b52e4c299c3e080ed3c80bcb5c089
Merge branch 'main_dev' of http://git.yunteng.com/yunteng/thingskit-front into fix/DEFECT-1384
Showing
7 changed files
with
41 additions
and
8 deletions
@@ -120,6 +120,7 @@ | @@ -120,6 +120,7 @@ | ||
120 | totals: RecordType[]; | 120 | totals: RecordType[]; |
121 | tooltips: RecordType[]; | 121 | tooltips: RecordType[]; |
122 | todayTotals: RecordType[]; | 122 | todayTotals: RecordType[]; |
123 | + withUnit?: boolean; | ||
123 | } | 124 | } |
124 | 125 | ||
125 | defineProps<{ | 126 | defineProps<{ |
@@ -190,6 +191,7 @@ | @@ -190,6 +191,7 @@ | ||
190 | 191 | ||
191 | const messageTotal: StatisticalItemType = { | 192 | const messageTotal: StatisticalItemType = { |
192 | images: msgPicture, | 193 | images: msgPicture, |
194 | + withUnit: true, | ||
193 | totals: [ | 195 | totals: [ |
194 | { label: '消息数', value: messageInfo?.messageCount }, | 196 | { label: '消息数', value: messageInfo?.messageCount }, |
195 | { label: '消息点数', value: messageInfo?.dataPointsCount }, | 197 | { label: '消息点数', value: messageInfo?.dataPointsCount }, |
@@ -8,13 +8,14 @@ | @@ -8,13 +8,14 @@ | ||
8 | label: string; | 8 | label: string; |
9 | } | 9 | } |
10 | 10 | ||
11 | - withDefaults( | 11 | + const props = withDefaults( |
12 | defineProps<{ | 12 | defineProps<{ |
13 | value?: { | 13 | value?: { |
14 | images: string; | 14 | images: string; |
15 | totals: RecordType[]; | 15 | totals: RecordType[]; |
16 | tooltips: RecordType[]; | 16 | tooltips: RecordType[]; |
17 | todayTotals: RecordType[]; | 17 | todayTotals: RecordType[]; |
18 | + withUnit?: boolean; | ||
18 | }; | 19 | }; |
19 | }>(), | 20 | }>(), |
20 | { | 21 | { |
@@ -26,6 +27,17 @@ | @@ -26,6 +27,17 @@ | ||
26 | }), | 27 | }), |
27 | } | 28 | } |
28 | ); | 29 | ); |
30 | + | ||
31 | + const getThresholdValue = (value: number) => { | ||
32 | + const record = { value, unit: null }; | ||
33 | + | ||
34 | + if (!props.value?.withUnit) return record; | ||
35 | + | ||
36 | + if (value > 10 ** 6) return { unit: 'M', value: value / 10 ** 6 }; | ||
37 | + if (value > 10 ** 3) return { unit: 'K', value: value / 10 ** 4 }; | ||
38 | + | ||
39 | + return record; | ||
40 | + }; | ||
29 | </script> | 41 | </script> |
30 | 42 | ||
31 | <template> | 43 | <template> |
@@ -41,7 +53,8 @@ | @@ -41,7 +53,8 @@ | ||
41 | :style="{ width: `${100 / value.totals.length}%` }" | 53 | :style="{ width: `${100 / value.totals.length}%` }" |
42 | > | 54 | > |
43 | <div class="font-bold text-2xl"> | 55 | <div class="font-bold text-2xl"> |
44 | - <CountTo :end-val="item.value ?? 0" class="break-all" /> | 56 | + <CountTo :end-val="getThresholdValue(item.value).value ?? 0" class="break-all" /> |
57 | + <span>{{ getThresholdValue(item.value).unit || '' }}</span> | ||
45 | </div> | 58 | </div> |
46 | <div class="text-gray-600">{{ item.label }}</div> | 59 | <div class="text-gray-600">{{ item.label }}</div> |
47 | </div> | 60 | </div> |
@@ -176,8 +176,17 @@ export const formSchema: BFormSchema[] = [ | @@ -176,8 +176,17 @@ export const formSchema: BFormSchema[] = [ | ||
176 | field: 'name', | 176 | field: 'name', |
177 | label: '报表名称', | 177 | label: '报表名称', |
178 | colProps: { span: 24 }, | 178 | colProps: { span: 24 }, |
179 | - required: true, | ||
180 | component: 'Input', | 179 | component: 'Input', |
180 | + rules: [ | ||
181 | + { required: true, message: '请输入报表名称' }, | ||
182 | + { | ||
183 | + validator(_rule, value, _callback) { | ||
184 | + const reg = /[\/\\]/; | ||
185 | + if (reg.test(value)) return Promise.reject('报表名称中存在斜杠或反斜杠'); | ||
186 | + return Promise.resolve(); | ||
187 | + }, | ||
188 | + }, | ||
189 | + ], | ||
181 | componentProps: { | 190 | componentProps: { |
182 | maxLength: 64, | 191 | maxLength: 64, |
183 | placeholder: '请输入报表名称', | 192 | placeholder: '请输入报表名称', |
@@ -61,7 +61,7 @@ | @@ -61,7 +61,7 @@ | ||
61 | return isBoolean(componetDesign) ? componetDesign : true; | 61 | return isBoolean(componetDesign) ? componetDesign : true; |
62 | }); | 62 | }); |
63 | 63 | ||
64 | - const setDataSourceFormsEl = (uuid: string, instance: PublicFormInstaceType, index) => { | 64 | + const setDataSourceFormsEl = (uuid: string, instance: PublicFormInstaceType, index: number) => { |
65 | const findIndex = unref(props.dataSource).findIndex((item) => item.uuid === uuid); | 65 | const findIndex = unref(props.dataSource).findIndex((item) => item.uuid === uuid); |
66 | if (~findIndex) { | 66 | if (~findIndex) { |
67 | dataSourceFormsEl.value[index] = { uuid, instance }; | 67 | dataSourceFormsEl.value[index] = { uuid, instance }; |
@@ -49,6 +49,8 @@ | @@ -49,6 +49,8 @@ | ||
49 | 49 | ||
50 | const dataSourceFormSpinning = ref(false); | 50 | const dataSourceFormSpinning = ref(false); |
51 | 51 | ||
52 | + let firstEnter = true; | ||
53 | + | ||
52 | const selectWidgetKeys = ref<SelectedWidgetKeys>({ | 54 | const selectWidgetKeys = ref<SelectedWidgetKeys>({ |
53 | componentKey: TextComponent1Config.key, | 55 | componentKey: TextComponent1Config.key, |
54 | categoryKey: PackagesCategoryEnum.TEXT, | 56 | categoryKey: PackagesCategoryEnum.TEXT, |
@@ -69,7 +71,7 @@ | @@ -69,7 +71,7 @@ | ||
69 | } as DataSourceType; | 71 | } as DataSourceType; |
70 | }; | 72 | }; |
71 | 73 | ||
72 | - const dataSource = ref<DataSourceType[]>(Array.from({ length: 1 }, () => genNewDataSourceItem())); | 74 | + const dataSource = ref<DataSourceType[]>([]); |
73 | 75 | ||
74 | const currentMode = ref<DataActionModeEnum>(DataActionModeEnum.CREATE); | 76 | const currentMode = ref<DataActionModeEnum>(DataActionModeEnum.CREATE); |
75 | 77 | ||
@@ -83,6 +85,7 @@ | @@ -83,6 +85,7 @@ | ||
83 | const { mode, record } = params; | 85 | const { mode, record } = params; |
84 | currentMode.value = mode; | 86 | currentMode.value = mode; |
85 | currentRecord.value = record; | 87 | currentRecord.value = record; |
88 | + firstEnter = false; | ||
86 | if (mode === DataActionModeEnum.UPDATE) { | 89 | if (mode === DataActionModeEnum.UPDATE) { |
87 | const config = useGetComponentConfig(record.frontId); | 90 | const config = useGetComponentConfig(record.frontId); |
88 | if (!config) return; | 91 | if (!config) return; |
@@ -128,12 +131,17 @@ | @@ -128,12 +131,17 @@ | ||
128 | const category = useGetCategoryByComponentKey(value); | 131 | const category = useGetCategoryByComponentKey(value); |
129 | const needReset = | 132 | const needReset = |
130 | [oldCategory, category].some((item) => item === PackagesCategoryEnum.CONTROL) && | 133 | [oldCategory, category].some((item) => item === PackagesCategoryEnum.CONTROL) && |
131 | - oldCategory !== category; | 134 | + oldCategory !== category && |
135 | + firstEnter; | ||
136 | + | ||
137 | + firstEnter = true; | ||
138 | + | ||
132 | dataSource.value = unref(dataSource).map((item) => ({ | 139 | dataSource.value = unref(dataSource).map((item) => ({ |
133 | ...item, | 140 | ...item, |
134 | ...(needReset ? { attribute: null } : {}), | 141 | ...(needReset ? { attribute: null } : {}), |
135 | componentInfo: { ...unref(getComponentConfig).persetOption, ...item.componentInfo }, | 142 | componentInfo: { ...unref(getComponentConfig).persetOption, ...item.componentInfo }, |
136 | })); | 143 | })); |
144 | + | ||
137 | if ((window as any).requestIdleCallback as unknown as boolean) { | 145 | if ((window as any).requestIdleCallback as unknown as boolean) { |
138 | (window as any).requestIdleCallback( | 146 | (window as any).requestIdleCallback( |
139 | () => { | 147 | () => { |
@@ -18,6 +18,7 @@ | @@ -18,6 +18,7 @@ | ||
18 | import { DataComponentRecord } from '/@/api/dataBoard/model'; | 18 | import { DataComponentRecord } from '/@/api/dataBoard/model'; |
19 | import { computed } from 'vue'; | 19 | import { computed } from 'vue'; |
20 | import { useGetComponentConfig } from '../../../packages/hook/useGetComponetConfig'; | 20 | import { useGetComponentConfig } from '../../../packages/hook/useGetComponetConfig'; |
21 | + import { isBoolean } from '/@/utils/is'; | ||
21 | 22 | ||
22 | const props = defineProps<{ | 23 | const props = defineProps<{ |
23 | sourceInfo: WidgetDataType; | 24 | sourceInfo: WidgetDataType; |
@@ -83,7 +84,8 @@ | @@ -83,7 +84,8 @@ | ||
83 | const hasTrendQueryIcon = computed(() => { | 84 | const hasTrendQueryIcon = computed(() => { |
84 | const frontId = props.sourceInfo.frontId; | 85 | const frontId = props.sourceInfo.frontId; |
85 | const config = useGetComponentConfig(frontId); | 86 | const config = useGetComponentConfig(frontId); |
86 | - return !!config.persetOption?.trendQuery; | 87 | + const flag = config.persetOption?.trendQuery; |
88 | + return isBoolean(flag) ? flag : true; | ||
87 | }); | 89 | }); |
88 | 90 | ||
89 | async function handleCopy() { | 91 | async function handleCopy() { |