Commit 1bb3b1a3ef34c991b452a9b51a2d4b7f43fc6d13
Merge branch 'main_dev' of http://git.yunteng.com/yunteng/thingskit-front into f…
…ix/components-lateralNumericalControl
Showing
3 changed files
with
34 additions
and
1 deletions
@@ -34,6 +34,7 @@ export enum DataSourceField { | @@ -34,6 +34,7 @@ export enum DataSourceField { | ||
34 | DEVICE_ID = 'deviceId', | 34 | DEVICE_ID = 'deviceId', |
35 | DEVICE_PROFILE_ID = 'deviceProfileId', | 35 | DEVICE_PROFILE_ID = 'deviceProfileId', |
36 | ATTRIBUTE = 'attribute', | 36 | ATTRIBUTE = 'attribute', |
37 | + ATTRIBUTE_NAME = 'attributeName', | ||
37 | ATTRIBUTE_RENAME = 'attributeRename', | 38 | ATTRIBUTE_RENAME = 'attributeRename', |
38 | DEVICE_NAME = 'deviceName', | 39 | DEVICE_NAME = 'deviceName', |
39 | DEVICE_RENAME = 'deviceRename', | 40 | DEVICE_RENAME = 'deviceRename', |
@@ -118,6 +119,7 @@ export const commonDataSourceSchemas = (): FormSchema[] => { | @@ -118,6 +119,7 @@ export const commonDataSourceSchemas = (): FormSchema[] => { | ||
118 | [DataSourceField.DEVICE_PROFILE_ID]: null, | 119 | [DataSourceField.DEVICE_PROFILE_ID]: null, |
119 | [DataSourceField.DEVICE_ID]: null, | 120 | [DataSourceField.DEVICE_ID]: null, |
120 | [DataSourceField.ATTRIBUTE]: null, | 121 | [DataSourceField.ATTRIBUTE]: null, |
122 | + [DataSourceField.ATTRIBUTE_NAME]: null, | ||
121 | [DataSourceField.TRANSPORT_TYPE]: null, | 123 | [DataSourceField.TRANSPORT_TYPE]: null, |
122 | }); | 124 | }); |
123 | }, | 125 | }, |
@@ -152,6 +154,7 @@ export const commonDataSourceSchemas = (): FormSchema[] => { | @@ -152,6 +154,7 @@ export const commonDataSourceSchemas = (): FormSchema[] => { | ||
152 | setFieldsValue({ | 154 | setFieldsValue({ |
153 | [DataSourceField.DEVICE_ID]: null, | 155 | [DataSourceField.DEVICE_ID]: null, |
154 | [DataSourceField.ATTRIBUTE]: null, | 156 | [DataSourceField.ATTRIBUTE]: null, |
157 | + [DataSourceField.ATTRIBUTE_NAME]: null, | ||
155 | [DataSourceField.TRANSPORT_TYPE]: option[DataSourceField.TRANSPORT_TYPE], | 158 | [DataSourceField.TRANSPORT_TYPE]: option[DataSourceField.TRANSPORT_TYPE], |
156 | }); | 159 | }); |
157 | }, | 160 | }, |
@@ -228,6 +231,12 @@ export const commonDataSourceSchemas = (): FormSchema[] => { | @@ -228,6 +231,12 @@ export const commonDataSourceSchemas = (): FormSchema[] => { | ||
228 | }, | 231 | }, |
229 | }, | 232 | }, |
230 | { | 233 | { |
234 | + field: DataSourceField.ATTRIBUTE_NAME, | ||
235 | + component: 'Input', | ||
236 | + label: '属性名', | ||
237 | + show: false, | ||
238 | + }, | ||
239 | + { | ||
231 | field: DataSourceField.ATTRIBUTE, | 240 | field: DataSourceField.ATTRIBUTE, |
232 | component: 'ApiSelect', | 241 | component: 'ApiSelect', |
233 | label: '属性', | 242 | label: '属性', |
@@ -235,7 +244,8 @@ export const commonDataSourceSchemas = (): FormSchema[] => { | @@ -235,7 +244,8 @@ export const commonDataSourceSchemas = (): FormSchema[] => { | ||
235 | rules: [{ required: true, message: '请选择属性' }], | 244 | rules: [{ required: true, message: '请选择属性' }], |
236 | ifShow: ({ model }) => | 245 | ifShow: ({ model }) => |
237 | !(isTcpProfile(model[DataSourceField.TRANSPORT_TYPE]) && isControlComponent(category!)), | 246 | !(isTcpProfile(model[DataSourceField.TRANSPORT_TYPE]) && isControlComponent(category!)), |
238 | - componentProps({ formModel }) { | 247 | + componentProps({ formModel, formActionType }) { |
248 | + const { setFieldsValue } = formActionType; | ||
239 | const deviceProfileId = formModel[DataSourceField.DEVICE_PROFILE_ID]; | 249 | const deviceProfileId = formModel[DataSourceField.DEVICE_PROFILE_ID]; |
240 | return { | 250 | return { |
241 | api: async () => { | 251 | api: async () => { |
@@ -256,6 +266,9 @@ export const commonDataSourceSchemas = (): FormSchema[] => { | @@ -256,6 +266,9 @@ export const commonDataSourceSchemas = (): FormSchema[] => { | ||
256 | }, | 266 | }, |
257 | placeholder: '请选择属性', | 267 | placeholder: '请选择属性', |
258 | getPopupContainer: () => document.body, | 268 | getPopupContainer: () => document.body, |
269 | + onChange(value: string, option: Record<'label' | 'value', string>) { | ||
270 | + setFieldsValue({ [DataSourceField.ATTRIBUTE_NAME]: value ? option.label : null }); | ||
271 | + }, | ||
259 | }; | 272 | }; |
260 | }, | 273 | }, |
261 | }, | 274 | }, |
src/views/visual/packages/utils/index.ts
0 → 100644
1 | +import { DataSource } from '../../palette/types'; | ||
2 | +import { PublicComponentOptions } from '../index.type'; | ||
3 | +import { isArray } from '/@/utils/is'; | ||
4 | + | ||
5 | +export const getAttributeName = (option: PublicComponentOptions & DataSource) => { | ||
6 | + const { attribute, attributeRename, attributeName } = option || {}; | ||
7 | + return attributeRename || attributeName || attribute; | ||
8 | +}; | ||
9 | + | ||
10 | +export const useExtractValueByKeys = <T = Recordable>( | ||
11 | + keys: string[] | string, | ||
12 | + sourceValue: T = {} as T, | ||
13 | + defaultValue: Recordable = {} as Recordable | ||
14 | +): T => { | ||
15 | + keys = isArray(keys) ? keys : [keys]; | ||
16 | + return keys.reduce((prev, next) => { | ||
17 | + return { ...prev, [next]: sourceValue[next] || defaultValue[next] }; | ||
18 | + }, {} as T); | ||
19 | +}; |
@@ -19,6 +19,7 @@ export interface DataSource { | @@ -19,6 +19,7 @@ export interface DataSource { | ||
19 | deviceId: string; | 19 | deviceId: string; |
20 | deviceType: string; | 20 | deviceType: string; |
21 | attribute: string; | 21 | attribute: string; |
22 | + attributeName: string; | ||
22 | deviceName: string; | 23 | deviceName: string; |
23 | gatewayDevice: boolean; | 24 | gatewayDevice: boolean; |
24 | slaveDeviceId: string; | 25 | slaveDeviceId: string; |