Showing
1 changed file
with
91 additions
and
9 deletions
| @@ -69,6 +69,7 @@ | @@ -69,6 +69,7 @@ | ||
| 69 | import { Icon } from '/@/components/Icon'; | 69 | import { Icon } from '/@/components/Icon'; |
| 70 | import AlarmSchedule from './AlarmSchedule.vue'; | 70 | import AlarmSchedule from './AlarmSchedule.vue'; |
| 71 | import { useModal } from '/@/components/Modal'; | 71 | import { useModal } from '/@/components/Modal'; |
| 72 | + import { cloneDeep } from 'lodash-es'; | ||
| 72 | 73 | ||
| 73 | defineProps({ | 74 | defineProps({ |
| 74 | index: { | 75 | index: { |
| @@ -84,7 +85,9 @@ | @@ -84,7 +85,9 @@ | ||
| 84 | const isUpdate = ref(false); | 85 | const isUpdate = ref(false); |
| 85 | const conditionScreeningRef = ref(); | 86 | const conditionScreeningRef = ref(); |
| 86 | const [registerForm, { resetFields, getFieldsValue, updateSchema, setFieldsValue }] = useForm({ | 87 | const [registerForm, { resetFields, getFieldsValue, updateSchema, setFieldsValue }] = useForm({ |
| 87 | - schemas: trigger_condition_schema, | 88 | + //TODO-wenwei-修复 |
| 89 | + schemas: cloneDeep(trigger_condition_schema), | ||
| 90 | + //TODO-wenwei-修复 | ||
| 88 | showActionButtonGroup: false, | 91 | showActionButtonGroup: false, |
| 89 | }); | 92 | }); |
| 90 | 93 | ||
| @@ -96,14 +99,82 @@ | @@ -96,14 +99,82 @@ | ||
| 96 | return { ...getFieldsValue(), predicate, schedule: alarmScheduleRef.value.scheduleData }; | 99 | return { ...getFieldsValue(), predicate, schedule: alarmScheduleRef.value.scheduleData }; |
| 97 | }; | 100 | }; |
| 98 | 101 | ||
| 99 | - const updateFieldDeviceId = (deviceList: any[]) => { | 102 | + const updateFieldDeviceId = (deviceList: any[], orgId, isUpdate) => { |
| 103 | + if (isUpdate) { | ||
| 104 | + updateSchema({ | ||
| 105 | + field: 'entityId', | ||
| 106 | + componentProps: { | ||
| 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 | + }, | ||
| 119 | + }); | ||
| 120 | + } | ||
| 121 | + //新增、编辑都会触发onChang事件 | ||
| 100 | updateSchema({ | 122 | updateSchema({ |
| 101 | - field: 'entityId', | 123 | + field: 'device', |
| 102 | componentProps: { | 124 | componentProps: { |
| 103 | - options: deviceList, | ||
| 104 | - onChange(e) { | 125 | + options: [ |
| 126 | + { label: '全部', value: 'ALL' }, | ||
| 127 | + { label: '部分', value: 'PART' }, | ||
| 128 | + ], | ||
| 129 | + async onChange(e) { | ||
| 130 | + setFieldsValue({ type2: '' }); | ||
| 131 | + setFieldsValue({ entityId: [] }); | ||
| 132 | + //部分切换-清空或者重置为初始值 | ||
| 133 | + updateSchema({ | ||
| 134 | + field: 'type2', | ||
| 135 | + componentProps: { | ||
| 136 | + options: [], | ||
| 137 | + }, | ||
| 138 | + }); | ||
| 105 | if (e) { | 139 | if (e) { |
| 106 | - updateFieldAttributeFunc(); | 140 | + //fengtao |
| 141 | + if (e == 'ALL') { | ||
| 142 | + const data = await getAttribute(orgId, null); | ||
| 143 | + //fengtao | ||
| 144 | + const options = data.map((m) => { | ||
| 145 | + return { | ||
| 146 | + label: m, | ||
| 147 | + value: m, | ||
| 148 | + }; | ||
| 149 | + }); | ||
| 150 | + updateSchema({ | ||
| 151 | + field: 'type2', | ||
| 152 | + componentProps: { | ||
| 153 | + placeholder: '请选择属性', | ||
| 154 | + options, | ||
| 155 | + }, | ||
| 156 | + }); | ||
| 157 | + } else { | ||
| 158 | + const getT = getFieldsValue(); | ||
| 159 | + const entityId = getT.entityId; | ||
| 160 | + if (entityId !== undefined && entityId.length > 0) { | ||
| 161 | + updateFieldAttributeFunc(entityId, orgId); | ||
| 162 | + } | ||
| 163 | + updateSchema({ | ||
| 164 | + field: 'entityId', | ||
| 165 | + componentProps: { | ||
| 166 | + options: deviceList, | ||
| 167 | + onChange(e) { | ||
| 168 | + if (e) { | ||
| 169 | + //fengtao | ||
| 170 | + updateFieldAttributeFunc(e, orgId); | ||
| 171 | + //fengtao | ||
| 172 | + } | ||
| 173 | + }, | ||
| 174 | + }, | ||
| 175 | + }); | ||
| 176 | + } | ||
| 177 | + //fengtao | ||
| 107 | } | 178 | } |
| 108 | }, | 179 | }, |
| 109 | }, | 180 | }, |
| @@ -115,8 +186,17 @@ | @@ -115,8 +186,17 @@ | ||
| 115 | const setFieldsFormValueFun = (fieldsValue) => { | 186 | const setFieldsFormValueFun = (fieldsValue) => { |
| 116 | setFieldsValue(fieldsValue); | 187 | setFieldsValue(fieldsValue); |
| 117 | }; | 188 | }; |
| 118 | - const updateFieldAttributeFunc = async () => { | ||
| 119 | - const data = await getAttribute(); | 189 | + //TODO-fengtao |
| 190 | + const updateFieldAttributeFunc = async (deviceId, orgId) => { | ||
| 191 | + //TODO-fengtao | ||
| 192 | + let data; | ||
| 193 | + if (deviceId !== undefined && deviceId.length > 0) { | ||
| 194 | + const joinDeviceIds = deviceId.join(','); | ||
| 195 | + data = await getAttribute(orgId, joinDeviceIds); | ||
| 196 | + } else { | ||
| 197 | + data = await getAttribute(orgId, null); | ||
| 198 | + } | ||
| 199 | + //TODO-fengtao | ||
| 120 | const options = data.map((m) => { | 200 | const options = data.map((m) => { |
| 121 | return { | 201 | return { |
| 122 | label: m, | 202 | label: m, |
| @@ -127,10 +207,11 @@ | @@ -127,10 +207,11 @@ | ||
| 127 | field: 'type2', | 207 | field: 'type2', |
| 128 | componentProps: { | 208 | componentProps: { |
| 129 | placeholder: '请选择属性', | 209 | placeholder: '请选择属性', |
| 130 | - options, | 210 | + options: options, |
| 131 | }, | 211 | }, |
| 132 | }); | 212 | }); |
| 133 | }; | 213 | }; |
| 214 | + //TODO-fengtao | ||
| 134 | const schedule = ref('ANY_TIME'); | 215 | const schedule = ref('ANY_TIME'); |
| 135 | const operationType = ref<string>(''); | 216 | const operationType = ref<string>(''); |
| 136 | provide('operationType', operationType); | 217 | provide('operationType', operationType); |
| @@ -196,6 +277,7 @@ | @@ -196,6 +277,7 @@ | ||
| 196 | scheduleData, | 277 | scheduleData, |
| 197 | isUpdate, | 278 | isUpdate, |
| 198 | alarmScheduleRef, | 279 | alarmScheduleRef, |
| 280 | + updateFieldAttributeFunc, | ||
| 199 | }); | 281 | }); |
| 200 | </script> | 282 | </script> |
| 201 | <style> | 283 | <style> |