Commit 7dec96f14fc5035fafc1061815b946c8e55dc503
Merge branch 'ft_local_dev' into 'main'
fix:修改Tembition上的问题 See merge request huang/yun-teng-iot-front!405
Showing
11 changed files
with
211 additions
and
237 deletions
... | ... | @@ -18,7 +18,8 @@ enum ScreenManagerApi { |
18 | 18 | SCREEN_ORGANIZATION_URL = '/organization/me/list', |
19 | 19 | SCREEN_CHANGE_STATUS = '/convert/update/scene', |
20 | 20 | SCREEN_GET_BY_DEPTID = '/scene_linkage/device/', |
21 | - GET_ATTRBUTELIST = '/device/keys', | |
21 | + // GET_ATTRBUTELIST = '/device/keys', | |
22 | + GET_ATTRBUTELIST = '/device/attributes/', | |
22 | 23 | ALARM_PROFILE = '/alarm/profile/', |
23 | 24 | MASTER_GET_DEVICE = '/device/list/master', |
24 | 25 | } |
... | ... | @@ -101,10 +102,16 @@ export const getOrganizationAlarmConfig = (params: { organizationId }) => { |
101 | 102 | /** |
102 | 103 | * 获取设备属性列表 |
103 | 104 | */ |
104 | -export const getAttribute = (orgId, deviceIds) => { | |
105 | - const joinText = deviceIds == null ? [] : '?deviceIds=' + deviceIds; | |
105 | +// export const getAttribute = (orgId, deviceIds) => { | |
106 | +// const joinText = deviceIds == null ? [] : '?deviceIds=' + deviceIds; | |
107 | +// return defHttp.get({ | |
108 | +// url: ScreenManagerApi.GET_ATTRBUTELIST + '/' + orgId + joinText, | |
109 | +// }); | |
110 | +// }; | |
111 | +export const getAttribute = (orgId) => { | |
112 | + // const joinText = deviceIds == null ? [] : '?deviceIds=' + deviceIds; | |
106 | 113 | return defHttp.get({ |
107 | - url: ScreenManagerApi.GET_ATTRBUTELIST + '/' + orgId + joinText, | |
114 | + url: `${ScreenManagerApi.GET_ATTRBUTELIST}${orgId}`, | |
108 | 115 | }); |
109 | 116 | }; |
110 | 117 | ... | ... |
... | ... | @@ -55,7 +55,6 @@ |
55 | 55 | import { screenLinkPageByDeptIdGetDevice } from '/@/api/ruleengine/ruleengineApi'; |
56 | 56 | import { Select } from 'ant-design-vue'; |
57 | 57 | import DeviceAttrCpns from './cpns/DeviceAttrCpns.vue'; |
58 | - import { SelectTypes } from 'ant-design-vue/es/select'; | |
59 | 58 | import { SchemaFiled } from './config.data'; |
60 | 59 | import { QueryWay } from '../../device/localtion/cpns/TimePeriodForm/config'; |
61 | 60 | import { AggregateDataEnum } from '../../device/localtion/cpns/TimePeriodForm/config'; |
... | ... | @@ -68,6 +67,14 @@ |
68 | 67 | device?: string; |
69 | 68 | name?: string; |
70 | 69 | attributes?: string | undefined; |
70 | + deviceProfileId?: string; | |
71 | + id?: string; | |
72 | + }; | |
73 | + type TSelectOption = { | |
74 | + value?: string; | |
75 | + label?: string; | |
76 | + deviceProfileId?: string; | |
77 | + id?: string; | |
71 | 78 | }; |
72 | 79 | const emit = defineEmits(['success', 'register']); |
73 | 80 | const bindDeviceRefObj = { |
... | ... | @@ -76,7 +83,7 @@ |
76 | 83 | const isUpdate = ref(true); |
77 | 84 | const editId = ref(''); |
78 | 85 | const orgId = ref(''); |
79 | - const selectOptions: Ref<SelectTypes['options']> = ref([]); | |
86 | + const selectOptions: Ref<TSelectOption[]> = ref([]); | |
80 | 87 | const selectDevice = ref([]); |
81 | 88 | const deviceList: Ref<TDeviceList[]> = ref([]); |
82 | 89 | const editDeviceList: Ref<TDeviceList[]> = ref([]); |
... | ... | @@ -126,18 +133,20 @@ |
126 | 133 | return { |
127 | 134 | label: item.name, |
128 | 135 | value: item.tbDeviceId, |
136 | + id: item.id, | |
137 | + deviceProfileId: item.deviceProfileId, | |
129 | 138 | }; |
130 | 139 | }); |
131 | 140 | } |
132 | 141 | } |
133 | 142 | ); |
134 | 143 | //设备Select选中 |
135 | - const handleDeviceChange = (e) => { | |
144 | + const handleDeviceChange = (_, o) => { | |
136 | 145 | if (unref(isUpdate)) { |
137 | 146 | //编辑 |
138 | 147 | let temp: any = []; |
139 | 148 | editDeviceAttr.value.forEach((f) => { |
140 | - temp = [f, ...e]; | |
149 | + temp = [f, ...o]; | |
141 | 150 | }); |
142 | 151 | let deWeightThree = () => { |
143 | 152 | let map = new Map(); |
... | ... | @@ -150,11 +159,11 @@ |
150 | 159 | }; |
151 | 160 | temp = deWeightThree(); |
152 | 161 | deviceList.value = temp; |
153 | - if (e.length !== 0) { | |
154 | - deviceList.value = e; | |
162 | + if (o.length !== 0) { | |
163 | + deviceList.value = o; | |
155 | 164 | } |
156 | 165 | } else { |
157 | - deviceList.value = e; | |
166 | + deviceList.value = o; | |
158 | 167 | } |
159 | 168 | }; |
160 | 169 | //设备取消删除 |
... | ... | @@ -284,6 +293,8 @@ |
284 | 293 | return { |
285 | 294 | label: item.name, |
286 | 295 | value: item.tbDeviceId, |
296 | + id: item.id, | |
297 | + deviceProfileId: item.deviceProfileId, | |
287 | 298 | }; |
288 | 299 | }); |
289 | 300 | const deviceIds = editResData.data.executeAttributes.map((m) => { |
... | ... | @@ -295,7 +306,16 @@ |
295 | 306 | selectDevice.value = deviceIds; |
296 | 307 | //回显设备属性 |
297 | 308 | editDeviceAttr.value = editResData.data.executeAttributes?.map((item) => { |
309 | + const T = selectOptions.value.find((o) => { | |
310 | + if (item.device === o.value) { | |
311 | + return { | |
312 | + id: o.id, | |
313 | + deviceProfileId: o.deviceProfileId, | |
314 | + }; | |
315 | + } | |
316 | + }); | |
298 | 317 | return { |
318 | + ...T, | |
299 | 319 | label: item.name, |
300 | 320 | value: item.device, |
301 | 321 | attributes: item.attributes, | ... | ... |
... | ... | @@ -43,21 +43,23 @@ |
43 | 43 | }); |
44 | 44 | const selectOptions: any = ref([]); |
45 | 45 | //获取对应设备属性 |
46 | - const getAttr = async (orgId, deviceId) => { | |
47 | - const res = await getAttribute(orgId, deviceId); | |
48 | - selectOptions.value = res.map((o) => { | |
49 | - let obj: any = {}; | |
50 | - if (o !== null) { | |
51 | - obj = { | |
52 | - label: o, | |
53 | - value: o, | |
54 | - }; | |
55 | - return obj; | |
56 | - } | |
57 | - }); | |
58 | - //如果服务端返回的数组里含有null 过滤null值 | |
59 | - const excludeNull = selectOptions.value.filter(Boolean); | |
60 | - selectOptions.value = excludeNull; | |
46 | + const getAttr = async (orgId, _) => { | |
47 | + const res = await getAttribute(orgId); | |
48 | + if (Array.isArray(res)) { | |
49 | + selectOptions.value = res.map((o) => { | |
50 | + let obj: any = {}; | |
51 | + if (o?.identifier !== null) { | |
52 | + obj = { | |
53 | + label: o?.identifier, | |
54 | + value: o?.identifier, | |
55 | + }; | |
56 | + return obj; | |
57 | + } | |
58 | + }); | |
59 | + //如果服务端返回的数组里含有null 过滤null值 | |
60 | + const excludeNull = selectOptions.value.filter(Boolean); | |
61 | + selectOptions.value = excludeNull; | |
62 | + } | |
61 | 63 | }; |
62 | 64 | //动态数据 |
63 | 65 | const dynamicInput: UnwrapRef<{ params: Params[] }> = reactive({ params: [] }); |
... | ... | @@ -69,12 +71,12 @@ |
69 | 71 | * 初始化数值 |
70 | 72 | */ |
71 | 73 | async function initVal() { |
72 | - if (props.orgId && props.value.value) { | |
73 | - await getAttr(props.orgId, props.value.value); | |
74 | + if (props.value) { | |
75 | + await getAttr(props.value?.deviceProfileId, props.value?.id); | |
74 | 76 | dynamicInput.params.push({ |
75 | 77 | name: props.value.label, |
76 | 78 | device: props.value.value, |
77 | - attributes: props.value.attributes == [] ? [] : props.value.attributes, | |
79 | + attributes: props.value?.attributes == [] ? [] : props.value.attributes, | |
78 | 80 | }); |
79 | 81 | } |
80 | 82 | } | ... | ... |
... | ... | @@ -271,10 +271,10 @@ |
271 | 271 | }; |
272 | 272 | |
273 | 273 | const validateHasData = (record: Recordable) => { |
274 | - notFoundData.value = false; | |
274 | + notFoundData.value = true; | |
275 | 275 | const { val = [], attr } = (record as unknown as ResponsData) || {}; |
276 | 276 | if (!attr || !val.length) { |
277 | - notFoundData.value = true; | |
277 | + notFoundData.value = false; | |
278 | 278 | } |
279 | 279 | }; |
280 | 280 | ... | ... |
... | ... | @@ -228,7 +228,7 @@ |
228 | 228 | // 回显触发器数据---此处是个闭包! |
229 | 229 | triggers.forEach((trigger, index) => { |
230 | 230 | nextTick(async () => { |
231 | - const selectDeviceId = ref(''); | |
231 | + const selectProductId = ref(''); | |
232 | 232 | // 回显启用规则 |
233 | 233 | unref(skipUnwrap.triggerItemRefs)[index].currentIndex = |
234 | 234 | map[trigger.triggerCondition.schedule.type]; |
... | ... | @@ -245,18 +245,16 @@ |
245 | 245 | operationType: trigger?.triggerCondition?.condition?.condition[0]?.valueType, |
246 | 246 | detail: trigger?.triggerCondition?.alarmDetails, |
247 | 247 | entityId: trigger?.entityId, |
248 | + deviceProfileId: trigger?.deviceProfileId, | |
248 | 249 | replaceValue: trigger?.triggerCondition?.condition?.spec?.predicate?.defaultValue, |
249 | 250 | time: trigger?.triggerCondition?.condition?.spec?.predicate?.defaultValue, |
250 | 251 | timeUnit: trigger?.triggerCondition?.condition?.spec?.unit, |
251 | 252 | }); |
252 | - if (trigger.entityId != undefined) { | |
253 | - selectDeviceId.value = trigger?.entityId; | |
253 | + if (trigger.deviceProfileId != undefined) { | |
254 | + selectProductId.value = trigger?.deviceProfileId; | |
254 | 255 | } |
255 | 256 | //fengtao-把设备id回传给子组件 |
256 | - unref(skipUnwrap.triggerItemRefs)[index].updateFieldAttributeFunc( | |
257 | - selectDeviceId.value, | |
258 | - provideOrgid.value | |
259 | - ); | |
257 | + unref(skipUnwrap.triggerItemRefs)[index].updateFieldAttributeFunc(selectProductId.value); | |
260 | 258 | //fengtao |
261 | 259 | // 设置值operationType |
262 | 260 | unref(skipUnwrap.triggerItemRefs)[index].operationType = |
... | ... | @@ -309,7 +307,7 @@ |
309 | 307 | |
310 | 308 | doConditions.forEach((condition, index) => { |
311 | 309 | nextTick(async () => { |
312 | - const selectDeviceId = ref(''); | |
310 | + const selectProductId = ref(''); | |
313 | 311 | // 回显启用规则 |
314 | 312 | unref(skipUnwrap.conditionItemRefs)[index].currentIndex = |
315 | 313 | map[condition.triggerCondition.schedule.type]; |
... | ... | @@ -327,17 +325,17 @@ |
327 | 325 | operationType: condition?.triggerCondition?.condition?.condition[0]?.valueType, |
328 | 326 | detail: condition?.triggerCondition?.alarmDetails, |
329 | 327 | entityId: condition?.entityId, |
328 | + deviceProfileId: condition?.deviceProfileId, | |
330 | 329 | replaceValue: condition?.triggerCondition?.condition?.spec?.predicate?.defaultValue, |
331 | 330 | time: condition?.triggerCondition?.condition?.spec?.predicate?.defaultValue, |
332 | 331 | timeUnit: condition?.triggerCondition?.condition?.spec?.unit, |
333 | 332 | }); |
334 | - if (condition?.entityId != undefined) { | |
335 | - selectDeviceId.value = condition?.entityId; | |
333 | + if (condition?.deviceProfileId != undefined) { | |
334 | + selectProductId.value = condition?.deviceProfileId; | |
336 | 335 | } |
337 | 336 | //fengtao-把设备id回传给子组件 |
338 | 337 | unref(skipUnwrap.conditionItemRefs)[index].updateFieldAttributeFunc( |
339 | - selectDeviceId.value, | |
340 | - provideOrgid.value | |
338 | + selectProductId.value | |
341 | 339 | ); |
342 | 340 | //fengtao |
343 | 341 | // 设置值operationType |
... | ... | @@ -388,10 +386,9 @@ |
388 | 386 | }); |
389 | 387 | }); |
390 | 388 | }); |
391 | - | |
392 | 389 | doActions.forEach((action, index) => { |
393 | 390 | nextTick(() => { |
394 | - const selectDeviceId = ref(''); | |
391 | + const selectProductId = ref(''); | |
395 | 392 | // 设置执行动作外层值 |
396 | 393 | unref(skipUnwrap.actionItemRefs)[index].setFieldsFormValueFun({ |
397 | 394 | ...action, |
... | ... | @@ -439,6 +436,7 @@ |
439 | 436 | .valueType, |
440 | 437 | detail: action.doContext.clearRule[index].triggerCondition.alarmDetails, |
441 | 438 | entityId: action.doContext.clearRule[index].entityId, |
439 | + deviceProfileId: action.doContext.clearRule[index]?.deviceProfileId, | |
442 | 440 | replaceValue: |
443 | 441 | action.doContext.clearRule[index].triggerCondition.condition.spec.predicate |
444 | 442 | .defaultValue, |
... | ... | @@ -447,17 +445,12 @@ |
447 | 445 | timeUnit: |
448 | 446 | action.doContext.clearRule[index].triggerCondition.condition.spec.unit, |
449 | 447 | }); |
450 | - if (action.doContext.clearRule[index].entityId != undefined) { | |
451 | - selectDeviceId.value = action.doContext.clearRule[index].entityId; | |
448 | + if (action.doContext.clearRule[index]?.deviceProfileId != undefined) { | |
449 | + selectProductId.value = action.doContext.clearRule[index]?.deviceProfileId; | |
452 | 450 | } |
453 | 451 | //fengtao-把设备id回传给子组件 |
454 | - item.updateFieldAttributeFunc(selectDeviceId.value, provideOrgid.value); | |
455 | - // item.updateFieldDeviceId( | |
456 | - // deviceList.value, | |
457 | - // provideOrgid.value, | |
458 | - // isUpdate.value, | |
459 | - // getMasterDeviceList.value | |
460 | - // ); | |
452 | + item.updateFieldAttributeFunc(selectProductId.value); | |
453 | + item.updateFieldDeviceId(deviceList.value, provideOrgid.value, isUpdate.value); | |
461 | 454 | //fengtao |
462 | 455 | // 单独设置operationType值 操作符类型 NUMERIC|String|Boolean|DATE_TIME |
463 | 456 | item.operationType = |
... | ... | @@ -534,12 +527,12 @@ |
534 | 527 | }); |
535 | 528 | |
536 | 529 | // 设置设备的options |
537 | - const setEditFields = (_linkAge, _deviceList) => { | |
538 | - // unref(linkAge).map((item) => { | |
539 | - //TODO-fengtao | |
540 | - // item.updateFieldDeviceId(deviceList, orgId, isUpdate, getMasterDeviceList); | |
541 | - //TODO-fengtao | |
542 | - // }); | |
530 | + const setEditFields = (linkAge, deviceList) => { | |
531 | + unref(linkAge).map((item) => { | |
532 | + // TODO-fengtao | |
533 | + item.updateFieldDeviceId(deviceList, orgId, isUpdate); | |
534 | + // TODO-fengtao | |
535 | + }); | |
543 | 536 | }; |
544 | 537 | // 设置告警配置options |
545 | 538 | const setEditAlarmConfig = (linkAge, alarmConfigList) => { |
... | ... | @@ -600,7 +593,7 @@ |
600 | 593 | unref(linkAge).map((item) => { |
601 | 594 | isOrganizationChange && item.resetFieldsValueFunc(); |
602 | 595 | //TODO fengtao |
603 | - // item.updateFieldDeviceId(deviceList, orgId, isUpdate, getMasterDeviceList); | |
596 | + item.updateFieldDeviceId(deviceList, orgId, isUpdate); | |
604 | 597 | if (isUpdate.value) { |
605 | 598 | item.updateEditFieldAlarmConfig(editAlarmConfigData); |
606 | 599 | } else { | ... | ... |
... | ... | @@ -3,6 +3,7 @@ import { BasicColumn, FormSchema } from '/@/components/Table'; |
3 | 3 | import { |
4 | 4 | byOrganizationIdGetMasterDevice, |
5 | 5 | screenLinkOrganizationGetApi, |
6 | + getAttribute, | |
6 | 7 | } from '/@/api/ruleengine/ruleengineApi'; |
7 | 8 | import { scheduleOptions } from './formatData'; |
8 | 9 | import { copyTransFun } from '/@/utils/fnUtils'; |
... | ... | @@ -196,6 +197,52 @@ export const trigger_condition_schema: FormSchema[] = [ |
196 | 197 | colProps: { span: 6 }, |
197 | 198 | }, |
198 | 199 | { |
200 | + field: 'deviceProfileId', | |
201 | + label: '', | |
202 | + component: 'ApiSelect', | |
203 | + colProps: { span: 6 }, | |
204 | + componentProps: ({ formActionType }) => { | |
205 | + const { updateSchema, setFieldsValue } = formActionType; | |
206 | + return { | |
207 | + api: deviceProfile, | |
208 | + placeholder: '请选择产品', | |
209 | + labelField: 'name', | |
210 | + valueField: 'id', | |
211 | + getPopupContainer: () => document.body, | |
212 | + onChange: async (e) => { | |
213 | + if (e) { | |
214 | + setFieldsValue({ type2: '' }); | |
215 | + const res = await getAttribute(e); | |
216 | + let options: any = []; | |
217 | + if (Array.isArray(res)) { | |
218 | + options = res.map((m) => { | |
219 | + return { | |
220 | + label: m?.identifier, | |
221 | + value: m?.identifier, | |
222 | + }; | |
223 | + }); | |
224 | + updateSchema({ | |
225 | + field: 'type2', | |
226 | + componentProps: { | |
227 | + placeholder: '请选择属性', | |
228 | + options, | |
229 | + }, | |
230 | + }); | |
231 | + } else { | |
232 | + updateSchema({ | |
233 | + field: 'type2', | |
234 | + componentProps: { | |
235 | + placeholder: '请选择属性', | |
236 | + options, | |
237 | + }, | |
238 | + }); | |
239 | + } | |
240 | + } | |
241 | + }, | |
242 | + }; | |
243 | + }, | |
244 | + }, | |
245 | + { | |
199 | 246 | field: 'device', |
200 | 247 | label: '', |
201 | 248 | component: 'Select', |
... | ... | @@ -208,6 +255,7 @@ export const trigger_condition_schema: FormSchema[] = [ |
208 | 255 | }, |
209 | 256 | colProps: { span: 6 }, |
210 | 257 | }, |
258 | + | |
211 | 259 | { |
212 | 260 | field: 'entityId', |
213 | 261 | label: '', |
... | ... | @@ -219,6 +267,7 @@ export const trigger_condition_schema: FormSchema[] = [ |
219 | 267 | ifShow: ({ values }) => isPart(values.device), |
220 | 268 | colProps: { span: 6 }, |
221 | 269 | }, |
270 | + | |
222 | 271 | { |
223 | 272 | field: 'time', |
224 | 273 | label: '', |
... | ... | @@ -370,17 +419,19 @@ export const actionSchema: FormSchema[] = [ |
370 | 419 | component: 'ApiSelect', |
371 | 420 | componentProps: ({ formModel }) => { |
372 | 421 | const deviceProfileId = formModel['deviceProfileId']; |
373 | - return { | |
374 | - placeholder: '请选择设备', | |
375 | - mode: 'multiple', | |
376 | - api: byOrganizationIdGetMasterDevice, | |
377 | - params: { | |
378 | - organizationId: unref(organizationId), | |
379 | - deviceProfileId, | |
380 | - }, | |
381 | - labelField: 'name', | |
382 | - valueField: 'id', | |
383 | - }; | |
422 | + if (unref(organizationId)) { | |
423 | + return { | |
424 | + placeholder: '请选择设备', | |
425 | + mode: 'multiple', | |
426 | + api: byOrganizationIdGetMasterDevice, | |
427 | + params: { | |
428 | + organizationId: unref(organizationId), | |
429 | + deviceProfileId, | |
430 | + }, | |
431 | + labelField: 'name', | |
432 | + valueField: 'id', | |
433 | + }; | |
434 | + } | |
384 | 435 | }, |
385 | 436 | ifShow: ({ values }) => isPart(values.device) && isDeviceOut(values.outTarget), |
386 | 437 | colProps: { span: 6 }, |
... | ... | @@ -394,7 +445,7 @@ export const actionSchema: FormSchema[] = [ |
394 | 445 | colProps: { |
395 | 446 | span: 6, |
396 | 447 | }, |
397 | - defaultValue: '0', | |
448 | + defaultValue: 0, | |
398 | 449 | componentProps: ({ formActionType }) => { |
399 | 450 | const { setFieldsValue } = formActionType; |
400 | 451 | return { | ... | ... |
... | ... | @@ -17,6 +17,7 @@ export const genTriggerOrConditionData = (triggerData) => { |
17 | 17 | time, |
18 | 18 | timeUnit, |
19 | 19 | replaceValue, |
20 | + deviceProfileId, | |
20 | 21 | } = triggerData; |
21 | 22 | const mapPredicate = predicate?.map((item) => { |
22 | 23 | return { |
... | ... | @@ -40,6 +41,7 @@ export const genTriggerOrConditionData = (triggerData) => { |
40 | 41 | }; |
41 | 42 | }); |
42 | 43 | return { |
44 | + deviceProfileId, | |
43 | 45 | triggerType, |
44 | 46 | entityType: device, |
45 | 47 | entityId: entityId?.length ? entityId : null, |
... | ... | @@ -115,6 +117,7 @@ export const genActionData = (actionData) => { |
115 | 117 | triggerType: item.triggerType, |
116 | 118 | entityType: item.device, |
117 | 119 | entityId: item.device === 'PART' ? item.entityId : null, |
120 | + deviceProfileId: item.deviceProfileId, | |
118 | 121 | triggerCondition: { |
119 | 122 | alarmDetails: item.detail, |
120 | 123 | condition: { | ... | ... |
... | ... | @@ -62,10 +62,10 @@ |
62 | 62 | import { CollapseContainer } from '/@/components/Container/index'; |
63 | 63 | import { BasicForm, useForm } from '/@/components/Form/index'; |
64 | 64 | import { Card, Select, Input, Tooltip } from 'ant-design-vue'; |
65 | - import { trigger_condition_schema } from '../config/config.data.ts'; | |
65 | + import { trigger_condition_schema } from '../config/config.data'; | |
66 | 66 | import { getAttribute } from '/@/api/ruleengine/ruleengineApi'; |
67 | 67 | import ConditionScreening from './ConditionScreening.vue'; |
68 | - import { scheduleOptions, timeUnitOptions, options } from '../config/formatData.ts'; | |
68 | + import { scheduleOptions, timeUnitOptions, options } from '../config/formatData'; | |
69 | 69 | import { Icon } from '/@/components/Icon'; |
70 | 70 | import AlarmSchedule from './AlarmSchedule.vue'; |
71 | 71 | import { useModal } from '/@/components/Modal'; |
... | ... | @@ -99,22 +99,12 @@ |
99 | 99 | return { ...getFieldsValue(), predicate, schedule: alarmScheduleRef.value.scheduleData }; |
100 | 100 | }; |
101 | 101 | |
102 | - const updateFieldDeviceId = (deviceList: any[], orgId, isUpdate) => { | |
102 | + const updateFieldDeviceId = (deviceList: any[], _, isUpdate) => { | |
103 | 103 | if (isUpdate) { |
104 | 104 | updateSchema({ |
105 | 105 | field: 'entityId', |
106 | 106 | componentProps: { |
107 | 107 | options: deviceList, |
108 | - onChange(e) { | |
109 | - if (e) { | |
110 | - if (isUpdate) { | |
111 | - setFieldsValue({ type2: '' }); | |
112 | - } | |
113 | - //fengtao | |
114 | - updateFieldAttributeFunc(e, orgId); | |
115 | - //fengtao | |
116 | - } | |
117 | - }, | |
118 | 108 | }, |
119 | 109 | }); |
120 | 110 | } |
... | ... | @@ -127,53 +117,15 @@ |
127 | 117 | { label: '部分', value: 'PART' }, |
128 | 118 | ], |
129 | 119 | async onChange(e) { |
130 | - setFieldsValue({ type2: '' }); | |
131 | 120 | setFieldsValue({ entityId: [] }); |
132 | - //部分切换-清空或者重置为初始值 | |
133 | - updateSchema({ | |
134 | - field: 'type2', | |
135 | - componentProps: { | |
136 | - options: [], | |
137 | - }, | |
138 | - }); | |
139 | 121 | if (e) { |
140 | 122 | //fengtao |
141 | 123 | if (e == 'ALL') { |
142 | - if (orgId) { | |
143 | - const data = await getAttribute(orgId, null); | |
144 | - //fengtao | |
145 | - const options = data.map((m) => { | |
146 | - return { | |
147 | - label: m, | |
148 | - value: m, | |
149 | - }; | |
150 | - }); | |
151 | - updateSchema({ | |
152 | - field: 'type2', | |
153 | - componentProps: { | |
154 | - placeholder: '请选择属性', | |
155 | - options, | |
156 | - }, | |
157 | - }); | |
158 | - } | |
159 | 124 | } else { |
160 | - const getT = getFieldsValue(); | |
161 | - const entityId = getT.entityId; | |
162 | - if (entityId !== undefined && entityId.length > 0) { | |
163 | - updateFieldAttributeFunc(entityId, orgId); | |
164 | - } | |
165 | 125 | updateSchema({ |
166 | 126 | field: 'entityId', |
167 | 127 | componentProps: { |
168 | 128 | options: deviceList, |
169 | - onChange(e) { | |
170 | - if (e) { | |
171 | - setFieldsValue({ type2: '' }); | |
172 | - //fengtao | |
173 | - updateFieldAttributeFunc(e, orgId); | |
174 | - //fengtao | |
175 | - } | |
176 | - }, | |
177 | 129 | }, |
178 | 130 | }); |
179 | 131 | } |
... | ... | @@ -189,30 +141,32 @@ |
189 | 141 | const setFieldsFormValueFun = (fieldsValue) => { |
190 | 142 | setFieldsValue(fieldsValue); |
191 | 143 | }; |
192 | - //TODO-fengtao | |
193 | - const updateFieldAttributeFunc = async (deviceId, orgId) => { | |
194 | - //TODO-fengtao | |
195 | - let data; | |
196 | - if (deviceId !== undefined && deviceId.length > 0) { | |
197 | - const joinDeviceIds = deviceId.join(','); | |
198 | - data = await getAttribute(orgId, joinDeviceIds); | |
144 | + const updateFieldAttributeFunc = async (e) => { | |
145 | + const res = await getAttribute(e); | |
146 | + let options: any = []; | |
147 | + if (Array.isArray(res)) { | |
148 | + options = res.map((m) => { | |
149 | + return { | |
150 | + label: m?.identifier, | |
151 | + value: m?.identifier, | |
152 | + }; | |
153 | + }); | |
154 | + updateSchema({ | |
155 | + field: 'type2', | |
156 | + componentProps: { | |
157 | + placeholder: '请选择属性', | |
158 | + options, | |
159 | + }, | |
160 | + }); | |
199 | 161 | } else { |
200 | - data = await getAttribute(orgId, null); | |
162 | + updateSchema({ | |
163 | + field: 'type2', | |
164 | + componentProps: { | |
165 | + placeholder: '请选择属性', | |
166 | + options, | |
167 | + }, | |
168 | + }); | |
201 | 169 | } |
202 | - //TODO-fengtao | |
203 | - const options = data.map((m) => { | |
204 | - return { | |
205 | - label: m, | |
206 | - value: m, | |
207 | - }; | |
208 | - }); | |
209 | - updateSchema({ | |
210 | - field: 'type2', | |
211 | - componentProps: { | |
212 | - placeholder: '请选择属性', | |
213 | - options: options, | |
214 | - }, | |
215 | - }); | |
216 | 170 | }; |
217 | 171 | //TODO-fengtao |
218 | 172 | const schedule = ref('ANY_TIME'); | ... | ... |
... | ... | @@ -62,16 +62,16 @@ |
62 | 62 | import { BasicForm, useForm } from '/@/components/Form/index'; |
63 | 63 | import { Icon } from '/@/components/Icon'; |
64 | 64 | import { Tooltip, Card, Select, Input } from 'ant-design-vue'; |
65 | - import { trigger_condition_schema } from '../config/config.data.ts'; | |
65 | + import { trigger_condition_schema } from '../config/config.data'; | |
66 | 66 | import { getAttribute } from '/@/api/ruleengine/ruleengineApi'; |
67 | 67 | import ConditionScreening from './ConditionScreening.vue'; |
68 | - import { scheduleOptions, timeUnitOptions, options } from '../config/formatData.ts'; | |
68 | + import { scheduleOptions, timeUnitOptions, options } from '../config/formatData'; | |
69 | 69 | import AlarmSchedule from './AlarmSchedule.vue'; |
70 | 70 | import { useModal } from '/@/components/Modal'; |
71 | 71 | import { cloneDeep } from 'lodash-es'; |
72 | 72 | import { useMessage } from '/@/hooks/web/useMessage'; |
73 | 73 | |
74 | - const props = defineProps({ | |
74 | + defineProps({ | |
75 | 75 | title: { |
76 | 76 | type: String, |
77 | 77 | required: true, |
... | ... | @@ -139,23 +139,13 @@ |
139 | 139 | }; |
140 | 140 | |
141 | 141 | //TODO-fengtao |
142 | - const updateFieldDeviceId = (deviceList: any[], orgId, isUpdate) => { | |
142 | + const updateFieldDeviceId = (deviceList: any[], _, isUpdate) => { | |
143 | 143 | //用于编辑回显 |
144 | 144 | if (isUpdate.value) { |
145 | 145 | updateSchema({ |
146 | 146 | field: 'entityId', |
147 | 147 | componentProps: { |
148 | 148 | options: deviceList, |
149 | - onChange(e) { | |
150 | - if (e) { | |
151 | - if (isUpdate.value) { | |
152 | - setFieldsValue({ type2: '' }); | |
153 | - } | |
154 | - //fengtao | |
155 | - updateFieldAttributeFunc(e, orgId.value); | |
156 | - //fengtao | |
157 | - } | |
158 | - }, | |
159 | 149 | }, |
160 | 150 | }); |
161 | 151 | } |
... | ... | @@ -168,52 +158,15 @@ |
168 | 158 | { label: '部分', value: 'PART' }, |
169 | 159 | ], |
170 | 160 | async onChange(e) { |
171 | - setFieldsValue({ type2: '' }); | |
172 | 161 | setFieldsValue({ entityId: [] }); |
173 | - updateSchema({ | |
174 | - field: 'type2', | |
175 | - componentProps: { | |
176 | - options: [], | |
177 | - }, | |
178 | - }); | |
179 | 162 | if (e) { |
180 | 163 | //fengtao |
181 | 164 | if (e == 'ALL') { |
182 | - if (props.provideOrgid || orgId.value) { | |
183 | - const data = await getAttribute(props.provideOrgid || orgId.value, null); | |
184 | - //fengtao | |
185 | - const options = data.map((m) => { | |
186 | - return { | |
187 | - label: m, | |
188 | - value: m, | |
189 | - }; | |
190 | - }); | |
191 | - updateSchema({ | |
192 | - field: 'type2', | |
193 | - componentProps: { | |
194 | - placeholder: '请选择属性', | |
195 | - options, | |
196 | - }, | |
197 | - }); | |
198 | - } | |
199 | 165 | } else { |
200 | - const getT = getFieldsValue(); | |
201 | - const entityId = getT.entityId; | |
202 | - if (entityId !== undefined && entityId.length > 0) { | |
203 | - updateFieldAttributeFunc(entityId, orgId.value); | |
204 | - } | |
205 | 166 | updateSchema({ |
206 | 167 | field: 'entityId', |
207 | 168 | componentProps: { |
208 | 169 | options: deviceList, |
209 | - onChange(e) { | |
210 | - if (e) { | |
211 | - setFieldsValue({ type2: '' }); | |
212 | - //fengtao | |
213 | - updateFieldAttributeFunc(e, orgId.value); | |
214 | - //fengtao | |
215 | - } | |
216 | - }, | |
217 | 170 | }, |
218 | 171 | }); |
219 | 172 | } |
... | ... | @@ -233,29 +186,32 @@ |
233 | 186 | setFieldsValue(fieldsValue); |
234 | 187 | }; |
235 | 188 | //TODO-fengtao |
236 | - const updateFieldAttributeFunc = async (deviceId, orgId) => { | |
237 | - //TODO-fengtao | |
238 | - let data; | |
239 | - if (deviceId !== undefined && deviceId.length > 0) { | |
240 | - const joinDeviceIds = deviceId.join(','); | |
241 | - data = await getAttribute(orgId || props.provideOrgid, joinDeviceIds); | |
189 | + const updateFieldAttributeFunc = async (e) => { | |
190 | + const res = await getAttribute(e); | |
191 | + let options: any = []; | |
192 | + if (Array.isArray(res)) { | |
193 | + options = res.map((m) => { | |
194 | + return { | |
195 | + label: m?.identifier, | |
196 | + value: m?.identifier, | |
197 | + }; | |
198 | + }); | |
199 | + updateSchema({ | |
200 | + field: 'type2', | |
201 | + componentProps: { | |
202 | + placeholder: '请选择属性', | |
203 | + options, | |
204 | + }, | |
205 | + }); | |
242 | 206 | } else { |
243 | - data = await getAttribute(orgId || props.provideOrgid, null); | |
207 | + updateSchema({ | |
208 | + field: 'type2', | |
209 | + componentProps: { | |
210 | + placeholder: '请选择属性', | |
211 | + options, | |
212 | + }, | |
213 | + }); | |
244 | 214 | } |
245 | - //TODO-fengtao | |
246 | - const options = data.map((m) => { | |
247 | - return { | |
248 | - label: m, | |
249 | - value: m, | |
250 | - }; | |
251 | - }); | |
252 | - updateSchema({ | |
253 | - field: 'type2', | |
254 | - componentProps: { | |
255 | - placeholder: '请选择属性', | |
256 | - options: options, | |
257 | - }, | |
258 | - }); | |
259 | 215 | }; |
260 | 216 | //TODO-fengtao |
261 | 217 | const handleDelete = (params: { index: number; title: string }) => { | ... | ... |
... | ... | @@ -170,11 +170,10 @@ |
170 | 170 | const changeOutTarget = () => { |
171 | 171 | emit('getActionFormArr'); |
172 | 172 | }; |
173 | - const [registerAction, { getFieldsValue, resetFields, updateSchema, setFieldsValue, validate }] = | |
174 | - useForm({ | |
175 | - schemas: actionSchema, | |
176 | - showActionButtonGroup: false, | |
177 | - }); | |
173 | + const [registerAction, { getFieldsValue, resetFields, setFieldsValue, validate }] = useForm({ | |
174 | + schemas: actionSchema, | |
175 | + showActionButtonGroup: false, | |
176 | + }); | |
178 | 177 | |
179 | 178 | // 获取整个执行动作表单值 |
180 | 179 | const getFieldsValueFunc = () => { |
... | ... | @@ -274,26 +273,14 @@ |
274 | 273 | const isUpdateItem = ref(''); |
275 | 274 | const deviceListItem = ref([]); |
276 | 275 | |
277 | - //TODO-fengtao | |
278 | - const updateFieldDeviceId = (deviceList, orgId, isUpdate, getMasterDeviceList) => { | |
276 | + //update 2022-11-28 | |
277 | + const updateFieldDeviceId = (deviceList, orgId, isUpdate) => { | |
279 | 278 | if (isUpdate.value) { |
280 | 279 | orgIdItem.value = orgId.value; |
281 | 280 | } |
282 | 281 | orgIdItem.value = orgId.value; |
283 | 282 | isUpdateItem.value = isUpdate.value; |
284 | - const options = getMasterDeviceList.value.map((m) => { | |
285 | - return { | |
286 | - value: m.id, | |
287 | - label: m.name, | |
288 | - }; | |
289 | - }); | |
290 | 283 | deviceListItem.value = deviceList.value; |
291 | - updateSchema({ | |
292 | - field: 'deviceId', | |
293 | - componentProps: { | |
294 | - options, | |
295 | - }, | |
296 | - }); | |
297 | 284 | }; |
298 | 285 | //FT add 2022-10-27 |
299 | 286 | const updateEditFieldAlarmConfig = (alarmConfigList) => { | ... | ... |