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 | 120 | totals: RecordType[]; |
121 | 121 | tooltips: RecordType[]; |
122 | 122 | todayTotals: RecordType[]; |
123 | + withUnit?: boolean; | |
123 | 124 | } |
124 | 125 | |
125 | 126 | defineProps<{ |
... | ... | @@ -190,6 +191,7 @@ |
190 | 191 | |
191 | 192 | const messageTotal: StatisticalItemType = { |
192 | 193 | images: msgPicture, |
194 | + withUnit: true, | |
193 | 195 | totals: [ |
194 | 196 | { label: '消息数', value: messageInfo?.messageCount }, |
195 | 197 | { label: '消息点数', value: messageInfo?.dataPointsCount }, | ... | ... |
... | ... | @@ -8,13 +8,14 @@ |
8 | 8 | label: string; |
9 | 9 | } |
10 | 10 | |
11 | - withDefaults( | |
11 | + const props = withDefaults( | |
12 | 12 | defineProps<{ |
13 | 13 | value?: { |
14 | 14 | images: string; |
15 | 15 | totals: RecordType[]; |
16 | 16 | tooltips: RecordType[]; |
17 | 17 | todayTotals: RecordType[]; |
18 | + withUnit?: boolean; | |
18 | 19 | }; |
19 | 20 | }>(), |
20 | 21 | { |
... | ... | @@ -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 | 41 | </script> |
30 | 42 | |
31 | 43 | <template> |
... | ... | @@ -41,7 +53,8 @@ |
41 | 53 | :style="{ width: `${100 / value.totals.length}%` }" |
42 | 54 | > |
43 | 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 | 58 | </div> |
46 | 59 | <div class="text-gray-600">{{ item.label }}</div> |
47 | 60 | </div> | ... | ... |
... | ... | @@ -176,8 +176,17 @@ export const formSchema: BFormSchema[] = [ |
176 | 176 | field: 'name', |
177 | 177 | label: '报表名称', |
178 | 178 | colProps: { span: 24 }, |
179 | - required: true, | |
180 | 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 | 190 | componentProps: { |
182 | 191 | maxLength: 64, |
183 | 192 | placeholder: '请输入报表名称', | ... | ... |
... | ... | @@ -61,7 +61,7 @@ |
61 | 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 | 65 | const findIndex = unref(props.dataSource).findIndex((item) => item.uuid === uuid); |
66 | 66 | if (~findIndex) { |
67 | 67 | dataSourceFormsEl.value[index] = { uuid, instance }; | ... | ... |
... | ... | @@ -49,6 +49,8 @@ |
49 | 49 | |
50 | 50 | const dataSourceFormSpinning = ref(false); |
51 | 51 | |
52 | + let firstEnter = true; | |
53 | + | |
52 | 54 | const selectWidgetKeys = ref<SelectedWidgetKeys>({ |
53 | 55 | componentKey: TextComponent1Config.key, |
54 | 56 | categoryKey: PackagesCategoryEnum.TEXT, |
... | ... | @@ -69,7 +71,7 @@ |
69 | 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 | 76 | const currentMode = ref<DataActionModeEnum>(DataActionModeEnum.CREATE); |
75 | 77 | |
... | ... | @@ -83,6 +85,7 @@ |
83 | 85 | const { mode, record } = params; |
84 | 86 | currentMode.value = mode; |
85 | 87 | currentRecord.value = record; |
88 | + firstEnter = false; | |
86 | 89 | if (mode === DataActionModeEnum.UPDATE) { |
87 | 90 | const config = useGetComponentConfig(record.frontId); |
88 | 91 | if (!config) return; |
... | ... | @@ -128,12 +131,17 @@ |
128 | 131 | const category = useGetCategoryByComponentKey(value); |
129 | 132 | const needReset = |
130 | 133 | [oldCategory, category].some((item) => item === PackagesCategoryEnum.CONTROL) && |
131 | - oldCategory !== category; | |
134 | + oldCategory !== category && | |
135 | + firstEnter; | |
136 | + | |
137 | + firstEnter = true; | |
138 | + | |
132 | 139 | dataSource.value = unref(dataSource).map((item) => ({ |
133 | 140 | ...item, |
134 | 141 | ...(needReset ? { attribute: null } : {}), |
135 | 142 | componentInfo: { ...unref(getComponentConfig).persetOption, ...item.componentInfo }, |
136 | 143 | })); |
144 | + | |
137 | 145 | if ((window as any).requestIdleCallback as unknown as boolean) { |
138 | 146 | (window as any).requestIdleCallback( |
139 | 147 | () => { | ... | ... |
... | ... | @@ -18,6 +18,7 @@ |
18 | 18 | import { DataComponentRecord } from '/@/api/dataBoard/model'; |
19 | 19 | import { computed } from 'vue'; |
20 | 20 | import { useGetComponentConfig } from '../../../packages/hook/useGetComponetConfig'; |
21 | + import { isBoolean } from '/@/utils/is'; | |
21 | 22 | |
22 | 23 | const props = defineProps<{ |
23 | 24 | sourceInfo: WidgetDataType; |
... | ... | @@ -83,7 +84,8 @@ |
83 | 84 | const hasTrendQueryIcon = computed(() => { |
84 | 85 | const frontId = props.sourceInfo.frontId; |
85 | 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 | 91 | async function handleCopy() { | ... | ... |