Showing
13 changed files
with
344 additions
and
1003 deletions
@@ -88,7 +88,7 @@ export const screenLinkPageByDeptIdGetDevice = (params: ScreenByDeptIdParams) => | @@ -88,7 +88,7 @@ export const screenLinkPageByDeptIdGetDevice = (params: ScreenByDeptIdParams) => | ||
88 | }; | 88 | }; |
89 | 89 | ||
90 | /** | 90 | /** |
91 | - * 获取住址下的告警配置 | 91 | + * 获取组织下的告警配置 |
92 | */ | 92 | */ |
93 | export const getOrganizationAlarmConfig = (params: { organizationId }) => { | 93 | export const getOrganizationAlarmConfig = (params: { organizationId }) => { |
94 | return defHttp.get({ | 94 | return defHttp.get({ |
@@ -57,7 +57,7 @@ | @@ -57,7 +57,7 @@ | ||
57 | </div> | 57 | </div> |
58 | <Card v-else :bordered="false" :bodyStyle="{ padding: 0 }" v-bind="$attrs"> | 58 | <Card v-else :bordered="false" :bodyStyle="{ padding: 0 }" v-bind="$attrs"> |
59 | <Skeleton active :paragraph="{ rows: 10 }" :loading="!tenantTop10"> | 59 | <Skeleton active :paragraph="{ rows: 10 }" :loading="!tenantTop10"> |
60 | - <Descriptions :column="1" title="租户消息量TOP10" v-if="tenantTop10.length"> | 60 | + <Descriptions :column="1" title="租户消息量TOP10"> |
61 | <template v-for="(item, index) in tenantTop10" :key="item.name"> | 61 | <template v-for="(item, index) in tenantTop10" :key="item.name"> |
62 | <DescriptionsItem> | 62 | <DescriptionsItem> |
63 | <span | 63 | <span |
@@ -143,7 +143,7 @@ | @@ -143,7 +143,7 @@ | ||
143 | </DescriptionsItem> | 143 | </DescriptionsItem> |
144 | </template> | 144 | </template> |
145 | </Descriptions> | 145 | </Descriptions> |
146 | - <Empty v-else :image="Empty.PRESENTED_IMAGE_SIMPLE" /> | 146 | + <Empty v-if="!tenantTop10.length" :image="Empty.PRESENTED_IMAGE_SIMPLE" /> |
147 | </Skeleton> | 147 | </Skeleton> |
148 | <h1 style="color: rgba(0, 0, 0, 0.85); font-weight: bold; font-size: 16px"> | 148 | <h1 style="color: rgba(0, 0, 0, 0.85); font-weight: bold; font-size: 16px"> |
149 | 本月即将过期租户</h1 | 149 | 本月即将过期租户</h1 |
@@ -61,6 +61,7 @@ | @@ -61,6 +61,7 @@ | ||
61 | class="mt-4" | 61 | class="mt-4" |
62 | :actionIndex="index" | 62 | :actionIndex="index" |
63 | :actionData="actionData" | 63 | :actionData="actionData" |
64 | + :triggerData="triggerData" | ||
64 | :ref="skipUnwrap.actionItemRefs" | 65 | :ref="skipUnwrap.actionItemRefs" |
65 | @deleteAction="deleteAction" | 66 | @deleteAction="deleteAction" |
66 | /> | 67 | /> |
@@ -80,9 +81,9 @@ | @@ -80,9 +81,9 @@ | ||
80 | <script lang="ts" setup> | 81 | <script lang="ts" setup> |
81 | import { ref, watch, unref, computed, nextTick } from 'vue'; | 82 | import { ref, watch, unref, computed, nextTick } from 'vue'; |
82 | import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | 83 | import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; |
83 | - import { formSchema, organizationId } from './config'; | 84 | + import { formSchema, organizationId } from './config/config.data.ts'; |
84 | import { BasicForm, useForm } from '/@/components/Form'; | 85 | import { BasicForm, useForm } from '/@/components/Form'; |
85 | - import { genTriggerData, genConditionData, genActionData } from './cpns/format-data'; | 86 | + import { genTriggerOrConditionData, genActionData } from './config/formatData.ts'; |
86 | import { Divider } from 'ant-design-vue'; | 87 | import { Divider } from 'ant-design-vue'; |
87 | import { PlusOutlined } from '@ant-design/icons-vue'; | 88 | import { PlusOutlined } from '@ant-design/icons-vue'; |
88 | import { useMessage } from '/@/hooks/web/useMessage'; | 89 | import { useMessage } from '/@/hooks/web/useMessage'; |
@@ -95,6 +96,7 @@ | @@ -95,6 +96,7 @@ | ||
95 | import Condition from './cpns/Condition.vue'; | 96 | import Condition from './cpns/Condition.vue'; |
96 | import Action from './cpns/Action.vue'; | 97 | import Action from './cpns/Action.vue'; |
97 | import { useUserStore } from '/@/store/modules/user'; | 98 | import { useUserStore } from '/@/store/modules/user'; |
99 | + import { findOperation } from './config/formatData.ts'; | ||
98 | 100 | ||
99 | const emit = defineEmits(['register', 'success']); | 101 | const emit = defineEmits(['register', 'success']); |
100 | 102 | ||
@@ -114,6 +116,7 @@ | @@ -114,6 +116,7 @@ | ||
114 | let getConditionFormValue = ref([]); | 116 | let getConditionFormValue = ref([]); |
115 | let getActionFormValue = ref([]); | 117 | let getActionFormValue = ref([]); |
116 | const editEntryIdData = ref([]); | 118 | const editEntryIdData = ref([]); |
119 | + const editAlarmConfigData = ref([]); | ||
117 | const isUpdate = ref(false); | 120 | const isUpdate = ref(false); |
118 | const id = ref(undefined); | 121 | const id = ref(undefined); |
119 | const tenantId = ref(undefined); | 122 | const tenantId = ref(undefined); |
@@ -148,62 +151,206 @@ | @@ -148,62 +151,206 @@ | ||
148 | const options = await screenLinkPageByDeptIdGetDevice({ | 151 | const options = await screenLinkPageByDeptIdGetDevice({ |
149 | organizationId, | 152 | organizationId, |
150 | }); | 153 | }); |
154 | + // 获取当前组织下的告警配置 | ||
155 | + const alarmConfig = await getOrganizationAlarmConfig({ organizationId }); | ||
156 | + | ||
151 | // 生成回显时对应得组件数量 | 157 | // 生成回显时对应得组件数量 |
152 | triggerData.value = [...new Array(triggers.length).keys()]; | 158 | triggerData.value = [...new Array(triggers.length).keys()]; |
153 | conditionData.value = [...new Array(doConditions.length).keys()]; | 159 | conditionData.value = [...new Array(doConditions.length).keys()]; |
154 | actionData.value = [...new Array(doActions.length).keys()]; | 160 | actionData.value = [...new Array(doActions.length).keys()]; |
155 | // 回显设备列表 | 161 | // 回显设备列表 |
156 | - editEntryIdData.value = options.items.map((v) => { | 162 | + editEntryIdData.value = options.items.map((item) => { |
163 | + return { | ||
164 | + value: item.tbDeviceId, | ||
165 | + label: item.name, | ||
166 | + }; | ||
167 | + }); | ||
168 | + editAlarmConfigData.value = alarmConfig.map((item) => { | ||
157 | return { | 169 | return { |
158 | - value: v.tbDeviceId, | ||
159 | - label: v.name, | 170 | + value: item.id, |
171 | + label: item.name, | ||
160 | }; | 172 | }; |
161 | }); | 173 | }); |
162 | nextTick(() => { | 174 | nextTick(() => { |
163 | setEditFields(skipUnwrap.triggerItemRefs, editEntryIdData); | 175 | setEditFields(skipUnwrap.triggerItemRefs, editEntryIdData); |
164 | setEditFields(skipUnwrap.conditionItemRefs, editEntryIdData); | 176 | setEditFields(skipUnwrap.conditionItemRefs, editEntryIdData); |
165 | setEditFields(skipUnwrap.actionItemRefs, editEntryIdData); | 177 | setEditFields(skipUnwrap.actionItemRefs, editEntryIdData); |
178 | + setEditAlarmConfig(skipUnwrap.actionItemRefs, editAlarmConfigData); | ||
166 | }); | 179 | }); |
167 | 180 | ||
168 | // 回显触发器数据---此处是个闭包! | 181 | // 回显触发器数据---此处是个闭包! |
169 | triggers.forEach((trigger, index) => { | 182 | triggers.forEach((trigger, index) => { |
170 | - nextTick(() => { | 183 | + nextTick(async () => { |
171 | unref(skipUnwrap.triggerItemRefs)[index].setFieldsFormValueFun({ | 184 | unref(skipUnwrap.triggerItemRefs)[index].setFieldsFormValueFun({ |
185 | + triggered: trigger.triggerCondition.condition.spec.type, | ||
186 | + device: trigger.entityType, | ||
172 | triggerType: trigger.triggerType, | 187 | triggerType: trigger.triggerType, |
173 | - entityId: trigger.entityId, | ||
174 | - type1: trigger.triggerCondition?.condition[0]?.key?.type, | ||
175 | - type2: trigger.triggerCondition?.condition[0]?.key?.key, | ||
176 | - operation: trigger.triggerCondition?.condition[0]?.predicate?.operation, | ||
177 | - value: trigger.triggerCondition?.condition[0]?.predicate?.value?.defaultValue, | 188 | + type1: trigger.triggerCondition?.condition.condition[0]?.key?.type, |
189 | + type2: trigger.triggerCondition?.condition.condition[0]?.key?.key, | ||
190 | + operationType: trigger.triggerCondition?.condition.condition[0].valueType, | ||
191 | + detail: trigger.triggerCondition?.alarmDetails, | ||
192 | + }); | ||
193 | + // 设置值operationType | ||
194 | + unref(skipUnwrap.triggerItemRefs)[index].operationType = | ||
195 | + trigger.triggerCondition?.condition.condition[0].valueType; | ||
196 | + | ||
197 | + const ConditionScreeningForm = await unref(skipUnwrap.triggerItemRefs)[ | ||
198 | + index | ||
199 | + ].getRefItemConditionScreeningRefs(); | ||
200 | + triggerData.value = [...new Array(triggers.length).keys()]; | ||
201 | + | ||
202 | + // 设置对应条件筛选的个数 | ||
203 | + unref(skipUnwrap.triggerItemRefs)[index].setConditionScreeningList([ | ||
204 | + ...new Array(trigger.triggerCondition.condition.condition.length).keys(), | ||
205 | + ]); | ||
206 | + // 操作符类型 NUMERIC|String|Boolean|DATE_TIME | ||
207 | + const valueType = trigger.triggerCondition?.condition.condition[0].valueType; | ||
208 | + | ||
209 | + // 循环设置条件筛选值。TODO:此处设置顺序有问题 | ||
210 | + nextTick(() => { | ||
211 | + const richTextList = []; | ||
212 | + trigger.triggerCondition.condition.condition.forEach(async (item, index) => { | ||
213 | + const formItem = { | ||
214 | + operation: item.predicate.operation, | ||
215 | + value: String(item.predicate.value.defaultValue), | ||
216 | + }; | ||
217 | + richTextList.push({ | ||
218 | + // 查询中文操作符 | ||
219 | + operation: findOperation(valueType, item.predicate.operation).label, | ||
220 | + value: String(item.predicate.value.defaultValue), | ||
221 | + attribute: trigger.triggerCondition?.condition.condition[0]?.key?.key, | ||
222 | + }); | ||
223 | + ConditionScreeningForm.value[index].setFieldsValue(formItem); | ||
224 | + }); | ||
225 | + | ||
226 | + unref(skipUnwrap.triggerItemRefs)[index].setRichText(richTextList); | ||
178 | }); | 227 | }); |
179 | }); | 228 | }); |
180 | }); | 229 | }); |
181 | 230 | ||
182 | - doConditions.forEach((item, index) => { | ||
183 | - nextTick(() => { | 231 | + doConditions.forEach((condition, index) => { |
232 | + nextTick(async () => { | ||
184 | unref(skipUnwrap.conditionItemRefs)[index].setFieldsFormValueFun({ | 233 | unref(skipUnwrap.conditionItemRefs)[index].setFieldsFormValueFun({ |
185 | - triggerType: item?.triggerType, | ||
186 | - entityId: item?.entityId, | ||
187 | - type: item.triggerCondition?.condition[0].key.key, | ||
188 | - operation: item?.triggerCondition?.condition[0]?.predicate?.operation, | ||
189 | - value: item?.triggerCondition?.condition[0]?.predicate?.value?.defaultValue, | 234 | + triggered: condition.triggerCondition.condition.spec.type, |
235 | + device: condition.entityType, | ||
236 | + triggerType: condition.triggerType, | ||
237 | + type1: condition.triggerCondition?.condition.condition[0]?.key?.type, | ||
238 | + type2: condition.triggerCondition?.condition.condition[0]?.key?.key, | ||
239 | + operationType: condition.triggerCondition?.condition.condition[0].valueType, | ||
240 | + detail: condition.triggerCondition?.alarmDetails, | ||
241 | + }); | ||
242 | + // 设置值operationType | ||
243 | + unref(skipUnwrap.conditionItemRefs)[index].operationType = | ||
244 | + condition.triggerCondition?.condition.condition[0].valueType; | ||
245 | + | ||
246 | + const ConditionScreeningForm = await unref(skipUnwrap.conditionItemRefs)[ | ||
247 | + index | ||
248 | + ].getRefItemConditionScreeningRefs(); | ||
249 | + triggerData.value = [...new Array(condition.length).keys()]; | ||
250 | + | ||
251 | + // 设置对应条件筛选的个数 | ||
252 | + unref(skipUnwrap.conditionItemRefs)[index].setConditionScreeningList([ | ||
253 | + ...new Array(condition.triggerCondition.condition.condition.length).keys(), | ||
254 | + ]); | ||
255 | + // 操作符类型 NUMERIC|String|Boolean|DATE_TIME | ||
256 | + const valueType = condition.triggerCondition?.condition.condition[0].valueType; | ||
257 | + | ||
258 | + // 循环设置条件筛选值。TODO:此处设置顺序有问题 | ||
259 | + nextTick(() => { | ||
260 | + const richTextList = []; | ||
261 | + condition.triggerCondition.condition.condition.forEach(async (item, index) => { | ||
262 | + const formItem = { | ||
263 | + operation: item.predicate.operation, | ||
264 | + value: String(item.predicate.value.defaultValue), | ||
265 | + }; | ||
266 | + richTextList.push({ | ||
267 | + // 查询中文操作符 | ||
268 | + operation: findOperation(valueType, item.predicate.operation).label, | ||
269 | + value: String(item.predicate.value.defaultValue), | ||
270 | + attribute: condition.triggerCondition?.condition.condition[0]?.key?.key, | ||
271 | + }); | ||
272 | + ConditionScreeningForm.value[index].setFieldsValue(formItem); | ||
273 | + }); | ||
274 | + unref(skipUnwrap.conditionItemRefs)[index].setRichText(richTextList); | ||
190 | }); | 275 | }); |
191 | }); | 276 | }); |
192 | }); | 277 | }); |
193 | 278 | ||
194 | - doActions.forEach((item, index) => { | 279 | + doActions.forEach((action, index) => { |
195 | nextTick(() => { | 280 | nextTick(() => { |
196 | unref(skipUnwrap.actionItemRefs)[index].setFieldsFormValueFun({ | 281 | unref(skipUnwrap.actionItemRefs)[index].setFieldsFormValueFun({ |
197 | - outTarget: item.outTarget, | ||
198 | - deviceId: item.deviceId, | 282 | + outTarget: action.outTarget, |
283 | + device: action.entityType, | ||
284 | + deviceId: action.deviceId, | ||
285 | + alarm_config: action.alarmProfileId, | ||
286 | + alarm_level: action.doContext.alarmLevel, | ||
199 | }); | 287 | }); |
200 | - unref(skipUnwrap.actionItemRefs)[index].setJsonValue(item.doContext.params); | 288 | + if (action.outTarget === 'DEVICE_OUT') { |
289 | + unref(skipUnwrap.actionItemRefs)[index].setJsonValue(action.doContext.params); | ||
290 | + } | ||
291 | + if (action.doContext.clearRule) { | ||
292 | + unref(skipUnwrap.actionItemRefs)[index].checked = true; | ||
293 | + nextTick(async () => { | ||
294 | + unref(skipUnwrap.actionItemRefs)[index].clearAlarmRef.setFieldsFormValueFun({ | ||
295 | + triggered: action.doContext?.clearRule?.triggerCondition?.condition.spec.type, | ||
296 | + device: action.entityType, | ||
297 | + triggerType: action.doContext?.clearRule.triggerType, | ||
298 | + type1: action.doContext.clearRule.triggerCondition.condition.condition[0].key.type, | ||
299 | + type2: action.doContext.clearRule.triggerCondition.condition.condition[0].key.key, | ||
300 | + operationType: | ||
301 | + action.doContext.clearRule.triggerCondition.condition.condition[0].valueType, | ||
302 | + detail: action.doContext.clearRule.triggerCondition?.alarmDetails, | ||
303 | + }); | ||
304 | + // 设置值operationType | ||
305 | + | ||
306 | + unref(skipUnwrap.actionItemRefs)[index].clearAlarmRef.operationType = | ||
307 | + action.doContext.clearRule.triggerCondition.condition.condition[0].valueType; | ||
308 | + | ||
309 | + const ConditionScreeningForm = await unref(skipUnwrap.actionItemRefs)[ | ||
310 | + index | ||
311 | + ].getRefItemConditionScreeningRefs(); | ||
312 | + triggerData.value = [...new Array(action.length).keys()]; | ||
313 | + | ||
314 | + // // 设置对应条件筛选的个数 | ||
315 | + unref(skipUnwrap.actionItemRefs)[index].setConditionScreeningList([ | ||
316 | + ...new Array( | ||
317 | + action.doContext.clearRule.triggerCondition.condition.condition.length | ||
318 | + ).keys(), | ||
319 | + ]); | ||
320 | + // 操作符类型 NUMERIC|String|Boolean|DATE_TIME | ||
321 | + const valueType = | ||
322 | + action.doContext.clearRule.triggerCondition?.condition.condition[0].valueType; | ||
323 | + | ||
324 | + // 循环设置条件筛选值。TODO:此处设置顺序有问题 | ||
325 | + nextTick(() => { | ||
326 | + const richTextList = []; | ||
327 | + action.doContext.clearRule.triggerCondition.condition.condition.forEach( | ||
328 | + (item, index) => { | ||
329 | + const formItem = { | ||
330 | + operation: item.predicate.operation, | ||
331 | + value: String(item.predicate.value.defaultValue), | ||
332 | + }; | ||
333 | + richTextList.push({ | ||
334 | + // 查询中文操作符 | ||
335 | + operation: findOperation(valueType, item.predicate.operation).label, | ||
336 | + value: String(item.predicate.value.defaultValue), | ||
337 | + attribute: | ||
338 | + action.doContext.clearRule.triggerCondition?.condition.condition[0]?.key | ||
339 | + ?.key, | ||
340 | + }); | ||
341 | + ConditionScreeningForm.value[index].setFieldsValue(formItem); | ||
342 | + } | ||
343 | + ); | ||
344 | + unref(skipUnwrap.actionItemRefs)[index].setRichText(richTextList); | ||
345 | + }); | ||
346 | + }); | ||
347 | + } | ||
201 | }); | 348 | }); |
202 | }); | 349 | }); |
203 | } | 350 | } |
204 | if (unref(isUpdate) === 3) isView.value = false; | 351 | if (unref(isUpdate) === 3) isView.value = false; |
205 | setDrawerProps({ | 352 | setDrawerProps({ |
206 | - showFooter: isView.value, | 353 | + showFooter: unref(isView), |
207 | loading: false, | 354 | loading: false, |
208 | }); | 355 | }); |
209 | }); | 356 | }); |
@@ -214,6 +361,12 @@ | @@ -214,6 +361,12 @@ | ||
214 | item.updateFieldDeviceId(deviceList); | 361 | item.updateFieldDeviceId(deviceList); |
215 | }); | 362 | }); |
216 | }; | 363 | }; |
364 | + // 设置告警配置options | ||
365 | + const setEditAlarmConfig = (linkAge, alarmConfigList) => { | ||
366 | + unref(linkAge).map((item) => { | ||
367 | + item.updateEditFieldAlarmConfig(alarmConfigList); | ||
368 | + }); | ||
369 | + }; | ||
217 | // 监听组织变化更新设备列表 | 370 | // 监听组织变化更新设备列表 |
218 | const deviceList = ref([]); | 371 | const deviceList = ref([]); |
219 | const alarmConfigList = ref([]); | 372 | const alarmConfigList = ref([]); |
@@ -271,16 +424,14 @@ | @@ -271,16 +424,14 @@ | ||
271 | */ | 424 | */ |
272 | const getFormValueFunc = () => { | 425 | const getFormValueFunc = () => { |
273 | getTriggerFormValue.value = unref(skipUnwrap.triggerItemRefs)?.map((item) => { | 426 | getTriggerFormValue.value = unref(skipUnwrap.triggerItemRefs)?.map((item) => { |
274 | - return genTriggerData(item.getFieldsValueFunc()); | 427 | + return genTriggerOrConditionData(item.getFieldsValueFunc()); |
275 | }); | 428 | }); |
276 | getConditionFormValue.value = unref(skipUnwrap.conditionItemRefs).map((item) => { | 429 | getConditionFormValue.value = unref(skipUnwrap.conditionItemRefs).map((item) => { |
277 | - return genConditionData(item.getFieldsValueFunc()); | 430 | + return genTriggerOrConditionData(item.getFieldsValueFunc()); |
278 | }); | 431 | }); |
279 | getActionFormValue.value = unref(skipUnwrap.actionItemRefs).map((item) => { | 432 | getActionFormValue.value = unref(skipUnwrap.actionItemRefs).map((item) => { |
280 | - console.log(item.jsonInstance.get()); | ||
281 | return genActionData(item.getFieldsValueFunc()); | 433 | return genActionData(item.getFieldsValueFunc()); |
282 | }); | 434 | }); |
283 | - console.log(getActionFormValue.value); | ||
284 | }; | 435 | }; |
285 | const handleSubmit = async () => { | 436 | const handleSubmit = async () => { |
286 | let basicFormValue = await validate(); | 437 | let basicFormValue = await validate(); |
@@ -300,7 +451,7 @@ | @@ -300,7 +451,7 @@ | ||
300 | id: unref(id), | 451 | id: unref(id), |
301 | tenantId: unref(tenantId), | 452 | tenantId: unref(tenantId), |
302 | }; | 453 | }; |
303 | - console.log(postAddOrEditData); | 454 | + |
304 | await screenLinkPageAddApi(postAddOrEditData, unref(isUpdate)); | 455 | await screenLinkPageAddApi(postAddOrEditData, unref(isUpdate)); |
305 | createMessage.success(`${unref(isUpdate) ? '编辑' : '新增'}成功`); | 456 | createMessage.success(`${unref(isUpdate) ? '编辑' : '新增'}成功`); |
306 | closeDrawer(); | 457 | closeDrawer(); |
@@ -319,7 +470,6 @@ | @@ -319,7 +470,6 @@ | ||
319 | unref(conditionData).splice(conditionIndex, 1); | 470 | unref(conditionData).splice(conditionIndex, 1); |
320 | }; | 471 | }; |
321 | const deleteAction = ({ actionIndex, outTarget }) => { | 472 | const deleteAction = ({ actionIndex, outTarget }) => { |
322 | - // console.log(actionIndex, outTarget.value); | ||
323 | unref(actionData).splice(actionIndex, 1); | 473 | unref(actionData).splice(actionIndex, 1); |
324 | if (unref(outTarget) === 'MSG_NOTIFY') { | 474 | if (unref(outTarget) === 'MSG_NOTIFY') { |
325 | userStore.setOutTarget('DEVICE_OUT'); | 475 | userStore.setOutTarget('DEVICE_OUT'); |
src/views/rule/linkedge/config.ts
deleted
100644 → 0
1 | -import { ref, h } from 'vue'; | ||
2 | -import { BasicColumn, FormSchema } from '/@/components/Table'; | ||
3 | -import { | ||
4 | - screenLinkOrganizationGetApi, | ||
5 | - screenLinkPagePutApi, | ||
6 | -} from '/@/api/ruleengine/ruleengineApi'; | ||
7 | -import { Switch } from 'ant-design-vue'; | ||
8 | -import { useMessage } from '/@/hooks/web/useMessage'; | ||
9 | -import { copyTransFun } from '/@/utils/fnUtils'; | ||
10 | - | ||
11 | -/** | ||
12 | - * 所使用的枚举值 | ||
13 | - */ | ||
14 | - | ||
15 | -export enum TriggerEnum { | ||
16 | - IS_DEVICE_ACT = 'DEVICE_TRIGGER', | ||
17 | - IS_TIME_ACT = 'SCHEDULE_TRIGGER', | ||
18 | - IS_SCENE_ACT = 'SCENE_TRIGGER', | ||
19 | - IS_HAND_ACT = 'HAND_ACT', | ||
20 | - IS_MSG_NOTIFY = 'MSG_NOTIFY', | ||
21 | - IS_DEVICE_STATUS = 'DEVICE_STATUS', | ||
22 | - IS_TIME_ALL = 'SCHEDULE_TRIGGER', | ||
23 | -} | ||
24 | -export const isDevice = (type: string) => { | ||
25 | - return type === TriggerEnum.IS_DEVICE_ACT; | ||
26 | -}; | ||
27 | - | ||
28 | -export const isTime = (type: string) => { | ||
29 | - return type === TriggerEnum.IS_TIME_ACT; | ||
30 | -}; | ||
31 | - | ||
32 | -export const columns: BasicColumn[] = [ | ||
33 | - { | ||
34 | - title: '场景联动名称', | ||
35 | - dataIndex: 'name', | ||
36 | - width: 200, | ||
37 | - }, | ||
38 | - { | ||
39 | - title: '触发方式', | ||
40 | - dataIndex: 'triggerType', | ||
41 | - format: (_: string, record: Recordable) => { | ||
42 | - return record.triggers[0]?.triggerType == 'DEVICE_TRIGGER' | ||
43 | - ? '设备触发' | ||
44 | - : record.triggers[0]?.triggerType == 'SCHEDULE_TRIGGER' | ||
45 | - ? '定时触发' | ||
46 | - : record.triggers[0]?.triggerType == 'SCENE_TRIGGER' | ||
47 | - ? '场景触发' | ||
48 | - : '手动触发'; | ||
49 | - }, | ||
50 | - width: 200, | ||
51 | - }, | ||
52 | - { | ||
53 | - title: '状态', | ||
54 | - dataIndex: 'status', | ||
55 | - width: 120, | ||
56 | - customRender: ({ record }) => { | ||
57 | - if (!Reflect.has(record, 'pendingStatus')) { | ||
58 | - record.pendingStatus = false; | ||
59 | - } | ||
60 | - return h(Switch, { | ||
61 | - checked: record.status === 1, | ||
62 | - checkedChildren: '启用', | ||
63 | - unCheckedChildren: '禁用', | ||
64 | - loading: record.pendingStatus, | ||
65 | - onChange(checked: boolean) { | ||
66 | - record.pendingStatus = true; | ||
67 | - const newStatus = checked ? 1 : 0; | ||
68 | - const { createMessage } = useMessage(); | ||
69 | - screenLinkPagePutApi({ id: record.id, status: newStatus }) | ||
70 | - .then(() => { | ||
71 | - record.status = newStatus; | ||
72 | - if (record.status == 1) { | ||
73 | - createMessage.success(`启用成功`); | ||
74 | - } else { | ||
75 | - createMessage.success('禁用成功'); | ||
76 | - } | ||
77 | - }) | ||
78 | - .finally(() => { | ||
79 | - record.pendingStatus = false; | ||
80 | - }); | ||
81 | - }, | ||
82 | - }); | ||
83 | - }, | ||
84 | - }, | ||
85 | - { | ||
86 | - title: '描述', | ||
87 | - dataIndex: 'description', | ||
88 | - width: 200, | ||
89 | - }, | ||
90 | - { | ||
91 | - title: '创建者', | ||
92 | - dataIndex: 'creatorName', | ||
93 | - width: 200, | ||
94 | - }, | ||
95 | - { | ||
96 | - title: '创建时间', | ||
97 | - dataIndex: 'createTime', | ||
98 | - width: 180, | ||
99 | - }, | ||
100 | -]; | ||
101 | -export const organizationId = ref(''); | ||
102 | -export const formSchema: FormSchema[] = [ | ||
103 | - { | ||
104 | - field: 'name', | ||
105 | - label: '场景联动名称', | ||
106 | - colProps: { span: 24 }, | ||
107 | - required: true, | ||
108 | - component: 'Input', | ||
109 | - | ||
110 | - componentProps: { | ||
111 | - maxLength: 36, | ||
112 | - placeholder: '请输入场景联动名称', | ||
113 | - }, | ||
114 | - }, | ||
115 | - { | ||
116 | - required: true, | ||
117 | - field: 'organizationId', | ||
118 | - label: '所属组织', | ||
119 | - colProps: { span: 24 }, | ||
120 | - component: 'ApiTreeSelect', | ||
121 | - componentProps: { | ||
122 | - api: async () => { | ||
123 | - const data = await screenLinkOrganizationGetApi(); | ||
124 | - copyTransFun(data as any as any[]); | ||
125 | - return data; | ||
126 | - }, | ||
127 | - onChange(value) { | ||
128 | - organizationId.value = value; | ||
129 | - }, | ||
130 | - }, | ||
131 | - }, | ||
132 | - { | ||
133 | - field: 'description', | ||
134 | - label: '描述', | ||
135 | - colProps: { span: 24 }, | ||
136 | - component: 'InputTextArea', | ||
137 | - componentProps: { | ||
138 | - maxLength: 255, | ||
139 | - placeholder: '请输入描述', | ||
140 | - }, | ||
141 | - }, | ||
142 | -]; | ||
143 | - | ||
144 | -export const searchFormSchema: FormSchema[] = [ | ||
145 | - { | ||
146 | - field: 'organizationId', | ||
147 | - label: '所属组织', | ||
148 | - colProps: { span: 6 }, | ||
149 | - component: 'ApiTreeSelect', | ||
150 | - componentProps: { | ||
151 | - placeholder: '请选择组织', | ||
152 | - api: async () => { | ||
153 | - const data = await screenLinkOrganizationGetApi(); | ||
154 | - copyTransFun(data as any as any[]); | ||
155 | - return data; | ||
156 | - }, | ||
157 | - }, | ||
158 | - }, | ||
159 | - { | ||
160 | - field: 'name', | ||
161 | - label: '名称', | ||
162 | - component: 'Input', | ||
163 | - colProps: { span: 6 }, | ||
164 | - componentProps: { | ||
165 | - maxLength: 36, | ||
166 | - placeholder: '请输入场景联动名称', | ||
167 | - }, | ||
168 | - }, | ||
169 | - { | ||
170 | - field: 'status', | ||
171 | - label: '状态', | ||
172 | - component: 'Select', | ||
173 | - componentProps: { | ||
174 | - placeholder: '请选择状态', | ||
175 | - options: [ | ||
176 | - { label: '启用', value: '1' }, | ||
177 | - { label: '禁用', value: '0' }, | ||
178 | - ], | ||
179 | - }, | ||
180 | - colProps: { span: 6 }, | ||
181 | - }, | ||
182 | -]; | ||
183 | -// 持续时间 | ||
184 | -const isTimeDuration = (type) => { | ||
185 | - return type === 'timeDuration'; | ||
186 | -}; | ||
187 | -const isReplace = (type) => { | ||
188 | - return type === 'replace'; | ||
189 | -}; | ||
190 | -// 部分 | ||
191 | -const isPart = (type: string) => { | ||
192 | - return type === 'PART'; | ||
193 | -}; | ||
194 | - | ||
195 | -export const trigger_condition_schema: FormSchema[] = [ | ||
196 | - { | ||
197 | - field: 'triggered', | ||
198 | - label: '', | ||
199 | - component: 'Select', | ||
200 | - componentProps: { | ||
201 | - placeholder: '请选择触发类型', | ||
202 | - options: [ | ||
203 | - { label: '简单', value: 'SIMPLE' }, | ||
204 | - { label: '持续时长', value: 'timeDuration' }, | ||
205 | - { label: '重复次数', value: 'replace' }, | ||
206 | - ], | ||
207 | - }, | ||
208 | - colProps: { span: 6 }, | ||
209 | - }, | ||
210 | - { | ||
211 | - field: 'device', | ||
212 | - label: '', | ||
213 | - component: 'Select', | ||
214 | - componentProps: { | ||
215 | - placeholder: '请选择设备', | ||
216 | - options: [ | ||
217 | - { label: '全部', value: 'ALL' }, | ||
218 | - { label: '部分', value: 'PART' }, | ||
219 | - ], | ||
220 | - }, | ||
221 | - colProps: { span: 6 }, | ||
222 | - }, | ||
223 | - { | ||
224 | - field: 'entityId', | ||
225 | - label: '', | ||
226 | - component: 'Select', | ||
227 | - componentProps: { | ||
228 | - placeholder: '请选择设备', | ||
229 | - mode: 'multiple', | ||
230 | - }, | ||
231 | - ifShow: ({ values }) => isPart(values.device), | ||
232 | - colProps: { span: 6 }, | ||
233 | - }, | ||
234 | - { | ||
235 | - field: 'time', | ||
236 | - label: '', | ||
237 | - component: 'Input', | ||
238 | - componentProps: { | ||
239 | - placeholder: '请输入持续时间', | ||
240 | - }, | ||
241 | - ifShow: ({ values }) => isTimeDuration(values.triggered), | ||
242 | - colProps: { span: 6 }, | ||
243 | - }, | ||
244 | - { | ||
245 | - field: 'timeUnit', | ||
246 | - label: '', | ||
247 | - component: 'Input', | ||
248 | - componentProps: { | ||
249 | - placeholder: '请输入持续时间单位', | ||
250 | - }, | ||
251 | - ifShow: ({ values }) => isTimeDuration(values.triggered), | ||
252 | - colProps: { span: 6 }, | ||
253 | - }, | ||
254 | - { | ||
255 | - field: 'replaceValue', | ||
256 | - label: '', | ||
257 | - component: 'Input', | ||
258 | - componentProps: { | ||
259 | - placeholder: '事件计数值', | ||
260 | - }, | ||
261 | - ifShow: ({ values }) => isReplace(values.triggered), | ||
262 | - colProps: { span: 6 }, | ||
263 | - }, | ||
264 | - { | ||
265 | - field: 'triggerType', | ||
266 | - label: '', | ||
267 | - component: 'Select', | ||
268 | - componentProps: { | ||
269 | - placeholder: '设备触发', | ||
270 | - options: [ | ||
271 | - { label: '设备触发', value: 'DEVICE_TRIGGER' }, | ||
272 | - // { label: '定时触发', value: 'SCHEDULE_TRIGGER' }, | ||
273 | - // { label: '场景触发', value: 'SCENE_TRIGGER' }, | ||
274 | - // { label: '手动触发', value: 'HAND_ACT' }, | ||
275 | - ], | ||
276 | - }, | ||
277 | - colProps: { span: 6 }, | ||
278 | - }, | ||
279 | - | ||
280 | - { | ||
281 | - field: 'type1', | ||
282 | - label: '', | ||
283 | - component: 'Select', | ||
284 | - componentProps: { | ||
285 | - placeholder: '属性触发方式', | ||
286 | - options: [{ label: '属性触发', value: 'TIME_SERIES' }], | ||
287 | - }, | ||
288 | - ifShow: ({ values }) => isDevice(values.triggerType), | ||
289 | - colProps: { span: 6 }, | ||
290 | - }, | ||
291 | - { | ||
292 | - field: 'type2', | ||
293 | - label: '', | ||
294 | - component: 'AutoComplete', | ||
295 | - componentProps: { | ||
296 | - placeholder: '请选择属性', | ||
297 | - }, | ||
298 | - ifShow: ({ values }) => isDevice(values.triggerType), | ||
299 | - colProps: { span: 6 }, | ||
300 | - }, | ||
301 | - { | ||
302 | - field: 'operationType', | ||
303 | - label: '', | ||
304 | - component: 'Select', | ||
305 | - slot: 'operationType', | ||
306 | - colProps: { span: 6 }, | ||
307 | - }, | ||
308 | - { | ||
309 | - field: 'detail', | ||
310 | - label: '', | ||
311 | - component: 'InputTextArea', | ||
312 | - componentProps: { | ||
313 | - placeholder: '请输入详情', | ||
314 | - }, | ||
315 | - colProps: { | ||
316 | - span: 13, | ||
317 | - }, | ||
318 | - }, | ||
319 | -]; | ||
320 | -// !!!----------------------------------------------------^_^------------------------------------------------------------!!! | ||
321 | -enum ActionEnum { | ||
322 | - DEVICE_OUT = 'DEVICE_OUT', | ||
323 | - ALARM_OUT = 'MSG_NOTIFY', | ||
324 | -} | ||
325 | -const isDeviceOut = (type: string) => type === ActionEnum.DEVICE_OUT; | ||
326 | -const isAlarmOut = (type: string) => type === ActionEnum.ALARM_OUT; | ||
327 | - | ||
328 | -export const actionSchema: FormSchema[] = [ | ||
329 | - { | ||
330 | - field: 'outTarget', | ||
331 | - label: '', | ||
332 | - component: 'Select', | ||
333 | - required: true, | ||
334 | - componentProps: { | ||
335 | - placeholder: '请选择执行动作', | ||
336 | - }, | ||
337 | - slot: 'outTarget', | ||
338 | - colProps: { span: 6 }, | ||
339 | - }, | ||
340 | - { | ||
341 | - field: 'device', | ||
342 | - label: '', | ||
343 | - component: 'Select', | ||
344 | - componentProps: { | ||
345 | - placeholder: '请选择设备', | ||
346 | - options: [ | ||
347 | - { label: '全部', value: 'ALL' }, | ||
348 | - { label: '部分', value: 'PART' }, | ||
349 | - ], | ||
350 | - }, | ||
351 | - ifShow: ({ values }) => isDeviceOut(values.outTarget), | ||
352 | - colProps: { span: 6 }, | ||
353 | - }, | ||
354 | - { | ||
355 | - field: 'deviceId', | ||
356 | - label: '', | ||
357 | - component: 'Select', | ||
358 | - componentProps: { | ||
359 | - placeholder: '请选择设备', | ||
360 | - mode: 'multiple', | ||
361 | - }, | ||
362 | - ifShow: ({ values }) => isPart(values.device), | ||
363 | - colProps: { span: 6 }, | ||
364 | - }, | ||
365 | - { | ||
366 | - field: 'alarm_config', | ||
367 | - label: '', | ||
368 | - component: 'Select', | ||
369 | - componentProps: { | ||
370 | - placeholder: '请选择告警配置', | ||
371 | - }, | ||
372 | - ifShow: ({ values }) => values.outTarget === 'MSG_NOTIFY', | ||
373 | - colProps: { span: 6 }, | ||
374 | - }, | ||
375 | - { | ||
376 | - field: 'doContext', | ||
377 | - component: 'Input', | ||
378 | - label: '', | ||
379 | - slot: 'doContext', | ||
380 | - show: ({ values }) => isDeviceOut(values.outTarget), | ||
381 | - colProps: { | ||
382 | - span: 24, | ||
383 | - }, | ||
384 | - }, | ||
385 | - { | ||
386 | - field: 'alarm_level', | ||
387 | - component: 'Select', | ||
388 | - label: '', | ||
389 | - show: ({ values }) => isAlarmOut(values.outTarget), | ||
390 | - componentProps: { | ||
391 | - placeholder: '请选择告警等级', | ||
392 | - options: [ | ||
393 | - { | ||
394 | - label: '紧急', | ||
395 | - value: ' CRITICAL', | ||
396 | - }, | ||
397 | - { | ||
398 | - label: '重要', | ||
399 | - value: 'MAJOR', | ||
400 | - }, | ||
401 | - { | ||
402 | - label: '次要', | ||
403 | - value: 'MINOR', | ||
404 | - }, | ||
405 | - { | ||
406 | - label: '警告', | ||
407 | - value: 'WARNING', | ||
408 | - }, | ||
409 | - { | ||
410 | - label: '不确定', | ||
411 | - value: 'INDETERMINATE', | ||
412 | - }, | ||
413 | - ], | ||
414 | - }, | ||
415 | - colProps: { | ||
416 | - span: 6, | ||
417 | - }, | ||
418 | - }, | ||
419 | - { | ||
420 | - field: 'clear_alarm', | ||
421 | - component: 'Checkbox', | ||
422 | - label: '', | ||
423 | - show: ({ values }) => isAlarmOut(values.outTarget), | ||
424 | - colProps: { | ||
425 | - span: 8, | ||
426 | - }, | ||
427 | - slot: 'clearAlarm', | ||
428 | - }, | ||
429 | -]; | ||
430 | -import { Number_Operation, String_Operation, Boolean_Operation } from '/@/enums/operationEnum'; | ||
431 | -export function isType(operationType) { | ||
432 | - switch (operationType) { | ||
433 | - case 'NUMERIC': | ||
434 | - return [ | ||
435 | - { | ||
436 | - field: 'operation', | ||
437 | - label: '执行操作', | ||
438 | - component: 'Select', | ||
439 | - required: true, | ||
440 | - componentProps: { | ||
441 | - options: [ | ||
442 | - { label: '等于', value: Number_Operation.EQUAL }, | ||
443 | - { label: '不等于', value: Number_Operation.NOT_EQUAL }, | ||
444 | - { label: '小于', value: Number_Operation.LESS }, | ||
445 | - { label: '小于等于', value: Number_Operation.LESS_OR_EQUAL }, | ||
446 | - { label: '大于', value: Number_Operation.GREATER }, | ||
447 | - { label: '大于等于', value: Number_Operation.GREATER_OR_EQUAL }, | ||
448 | - ], | ||
449 | - }, | ||
450 | - colProps: { | ||
451 | - span: 8, | ||
452 | - }, | ||
453 | - }, | ||
454 | - { | ||
455 | - field: 'value', | ||
456 | - label: '操作值', | ||
457 | - required: true, | ||
458 | - component: 'InputNumber', | ||
459 | - colProps: { | ||
460 | - span: 8, | ||
461 | - }, | ||
462 | - }, | ||
463 | - ]; | ||
464 | - case 'STRING': | ||
465 | - return [ | ||
466 | - { | ||
467 | - field: 'ignoreCase', | ||
468 | - label: '忽略大小写', | ||
469 | - component: 'Checkbox', | ||
470 | - labelWidth: 150, | ||
471 | - colProps: { | ||
472 | - span: 7, | ||
473 | - }, | ||
474 | - }, | ||
475 | - { | ||
476 | - field: 'operation', | ||
477 | - label: '执行操作', | ||
478 | - component: 'Select', | ||
479 | - required: true, | ||
480 | - componentProps: { | ||
481 | - options: [ | ||
482 | - { label: '等于', value: String_Operation.EQUAL }, | ||
483 | - { label: '不等于', value: String_Operation.NOT_EQUAL }, | ||
484 | - { label: '开始于', value: String_Operation.BEGAN_IN }, | ||
485 | - { label: '结束于', value: String_Operation.END_IN }, | ||
486 | - { label: '包含', value: String_Operation.INCLUDE }, | ||
487 | - { label: '不包含', value: String_Operation.NOT_INCLUDE }, | ||
488 | - ], | ||
489 | - }, | ||
490 | - colProps: { | ||
491 | - span: 7, | ||
492 | - }, | ||
493 | - }, | ||
494 | - { | ||
495 | - field: 'value', | ||
496 | - label: '操作值', | ||
497 | - required: true, | ||
498 | - component: 'Input', | ||
499 | - colProps: { | ||
500 | - span: 7, | ||
501 | - }, | ||
502 | - }, | ||
503 | - ]; | ||
504 | - case 'BOOLEAN': | ||
505 | - return [ | ||
506 | - { | ||
507 | - field: 'operation', | ||
508 | - label: '执行操作', | ||
509 | - component: 'Select', | ||
510 | - required: true, | ||
511 | - componentProps: { | ||
512 | - options: [ | ||
513 | - { label: '等于', value: Boolean_Operation.EQUAL }, | ||
514 | - { label: '不等于', value: Boolean_Operation.NOT_EQUAL }, | ||
515 | - ], | ||
516 | - }, | ||
517 | - colProps: { | ||
518 | - span: 8, | ||
519 | - }, | ||
520 | - }, | ||
521 | - { | ||
522 | - field: 'value', | ||
523 | - label: '操作值', | ||
524 | - component: 'Select', | ||
525 | - required: true, | ||
526 | - componentProps: { | ||
527 | - options: [ | ||
528 | - { | ||
529 | - label: '真', | ||
530 | - value: 'true', | ||
531 | - }, | ||
532 | - { | ||
533 | - label: '假', | ||
534 | - value: 'false', | ||
535 | - }, | ||
536 | - ], | ||
537 | - }, | ||
538 | - colProps: { | ||
539 | - span: 8, | ||
540 | - }, | ||
541 | - }, | ||
542 | - ]; | ||
543 | - case 'TIME': | ||
544 | - return [ | ||
545 | - { | ||
546 | - field: 'operation', | ||
547 | - label: '执行操作', | ||
548 | - required: true, | ||
549 | - component: 'Select', | ||
550 | - componentProps: { | ||
551 | - options: [ | ||
552 | - { label: '等于', value: Number_Operation.EQUAL }, | ||
553 | - { label: '不等于', value: Number_Operation.NOT_EQUAL }, | ||
554 | - { label: '小于', value: Number_Operation.LESS }, | ||
555 | - { label: '小于等于', value: Number_Operation.LESS_OR_EQUAL }, | ||
556 | - { label: '大于', value: Number_Operation.GREATER }, | ||
557 | - { label: '大于等于', value: Number_Operation.GREATER_OR_EQUAL }, | ||
558 | - ], | ||
559 | - }, | ||
560 | - colProps: { | ||
561 | - span: 8, | ||
562 | - }, | ||
563 | - }, | ||
564 | - { | ||
565 | - field: 'value', | ||
566 | - label: '操作值', | ||
567 | - required: true, | ||
568 | - component: 'DatePicker', | ||
569 | - componentProps: { | ||
570 | - showTime: true, | ||
571 | - }, | ||
572 | - colProps: { | ||
573 | - span: 8, | ||
574 | - }, | ||
575 | - }, | ||
576 | - ]; | ||
577 | - } | ||
578 | -} | ||
579 | -export function conditionPreView(data, operationType) { | ||
580 | - if (operationType === 'NUMERIC' || operationType === 'TIME') { | ||
581 | - const { EQUAL, NOT_EQUAL, LESS, LESS_OR_EQUAL, GREATER, GREATER_OR_EQUAL } = Number_Operation; | ||
582 | - return data.map((item) => { | ||
583 | - return { | ||
584 | - operation: | ||
585 | - item?.operation === EQUAL | ||
586 | - ? '等于' | ||
587 | - : item?.operation === NOT_EQUAL | ||
588 | - ? '不等于' | ||
589 | - : item?.operation === LESS | ||
590 | - ? '小于' | ||
591 | - : item?.operation === LESS_OR_EQUAL | ||
592 | - ? '小于等于' | ||
593 | - : item?.operation === GREATER | ||
594 | - ? '大于' | ||
595 | - : item?.operation === GREATER_OR_EQUAL | ||
596 | - ? '大于等于' | ||
597 | - : '', | ||
598 | - value: item.value, | ||
599 | - attribute: item.attribute, | ||
600 | - }; | ||
601 | - }); | ||
602 | - } else if (operationType === 'STRING') { | ||
603 | - const { EQUAL, NOT_EQUAL, BEGAN_IN, END_IN, INCLUDE, NOT_INCLUDE } = String_Operation; | ||
604 | - return data.map((item) => { | ||
605 | - return { | ||
606 | - operation: | ||
607 | - item?.operation === EQUAL | ||
608 | - ? '等于' | ||
609 | - : item?.operation === NOT_EQUAL | ||
610 | - ? '不等于' | ||
611 | - : item?.operation === BEGAN_IN | ||
612 | - ? '开始于' | ||
613 | - : item?.operation === END_IN | ||
614 | - ? '结束于' | ||
615 | - : item?.operation === INCLUDE | ||
616 | - ? '包含' | ||
617 | - : item?.operation === NOT_INCLUDE | ||
618 | - ? '不包含' | ||
619 | - : '', | ||
620 | - value: item.value, | ||
621 | - attribute: item.attribute, | ||
622 | - }; | ||
623 | - }); | ||
624 | - } else if (operationType === 'BOOLEAN') { | ||
625 | - const { EQUAL, NOT_EQUAL } = Boolean_Operation; | ||
626 | - return data.map((item) => { | ||
627 | - return { | ||
628 | - operation: | ||
629 | - item?.operation === EQUAL ? '等于' : item?.operation === NOT_EQUAL ? '不等于' : '', | ||
630 | - value: item.value, | ||
631 | - attribute: item.attribute, | ||
632 | - }; | ||
633 | - }); | ||
634 | - } | ||
635 | -} |
@@ -32,7 +32,7 @@ | @@ -32,7 +32,7 @@ | ||
32 | import { CollapseContainer } from '/@/components/Container/index'; | 32 | import { CollapseContainer } from '/@/components/Container/index'; |
33 | import { BasicForm, useForm } from '/@/components/Form/index'; | 33 | import { BasicForm, useForm } from '/@/components/Form/index'; |
34 | import { Radio, Card, Select } from 'ant-design-vue'; | 34 | import { Radio, Card, Select } from 'ant-design-vue'; |
35 | - import { trigger_condition_schema } from '../config'; | 35 | + import { trigger_condition_schema } from '../config/config.data.ts'; |
36 | import { getAttribute } from '/@/api/ruleengine/ruleengineApi'; | 36 | import { getAttribute } from '/@/api/ruleengine/ruleengineApi'; |
37 | import ConditionScreening from './ConditionScreening.vue'; | 37 | import ConditionScreening from './ConditionScreening.vue'; |
38 | 38 | ||
@@ -100,7 +100,7 @@ | @@ -100,7 +100,7 @@ | ||
100 | }, | 100 | }, |
101 | { | 101 | { |
102 | label: '时间', | 102 | label: '时间', |
103 | - value: 'TIME', | 103 | + value: 'DATE_TIME', |
104 | }, | 104 | }, |
105 | ]; | 105 | ]; |
106 | const childGetFieldsValue = () => getFieldsValue(); | 106 | const childGetFieldsValue = () => getFieldsValue(); |
@@ -114,5 +114,6 @@ | @@ -114,5 +114,6 @@ | ||
114 | childGetFieldsValue, | 114 | childGetFieldsValue, |
115 | conditionScreeningRef, | 115 | conditionScreeningRef, |
116 | schedule, | 116 | schedule, |
117 | + operationType, | ||
117 | }); | 118 | }); |
118 | </script> | 119 | </script> |
@@ -3,10 +3,7 @@ | @@ -3,10 +3,7 @@ | ||
3 | <CollapseContainer ref="collapseContainerRef" @expand="handleExpand"> | 3 | <CollapseContainer ref="collapseContainerRef" @expand="handleExpand"> |
4 | <template #title> | 4 | <template #title> |
5 | <div>条件筛选</div> | 5 | <div>条件筛选</div> |
6 | - <RichText | ||
7 | - :firstAttribute="firstAttribute" | ||
8 | - :otherAttribute="otherAttribute" | ||
9 | - @resetFilter="resetFilter" | 6 | + <RichText :otherAttribute="otherAttribute" @resetFilter="resetFilter" |
10 | /></template> | 7 | /></template> |
11 | 8 | ||
12 | <template v-for="(item, index) in conditionScreeningList" :key="item"> | 9 | <template v-for="(item, index) in conditionScreeningList" :key="item"> |
@@ -29,7 +26,7 @@ | @@ -29,7 +26,7 @@ | ||
29 | <script lang="ts" setup> | 26 | <script lang="ts" setup> |
30 | import { unref, ref } from 'vue'; | 27 | import { unref, ref } from 'vue'; |
31 | import ConditionScreeningForm from './ConditionScreeningForm.vue'; | 28 | import ConditionScreeningForm from './ConditionScreeningForm.vue'; |
32 | - import { conditionPreView } from '../config.ts'; | 29 | + import { conditionPreView } from '../config/formatData.ts'; |
33 | import { CollapseContainer } from '/@/components/Container/index'; | 30 | import { CollapseContainer } from '/@/components/Container/index'; |
34 | import RichText from './RichText.vue'; | 31 | import RichText from './RichText.vue'; |
35 | const props = defineProps({ | 32 | const props = defineProps({ |
@@ -50,53 +47,51 @@ | @@ -50,53 +47,51 @@ | ||
50 | collapseContainerRef.value.handleExpand(); | 47 | collapseContainerRef.value.handleExpand(); |
51 | } | 48 | } |
52 | unref(conditionScreeningList).push(Date.now()); | 49 | unref(conditionScreeningList).push(Date.now()); |
50 | + const lastIndex = refItem.conditionScreeningRefs.value.length - 1; | ||
51 | + refItem.conditionScreeningRefs.value[lastIndex]?.appendSchemaByField( | ||
52 | + { | ||
53 | + field: 'AND', | ||
54 | + label: '和', | ||
55 | + component: 'Input', | ||
56 | + slot: 'and', | ||
57 | + colProps: { span: 3 }, | ||
58 | + }, | ||
59 | + 'value' | ||
60 | + ); | ||
53 | }; | 61 | }; |
54 | const handleExpand = (show) => { | 62 | const handleExpand = (show) => { |
55 | isPreview.value = show; | 63 | isPreview.value = show; |
56 | }; | 64 | }; |
57 | 65 | ||
58 | - const firstAttribute = ref({}); | ||
59 | const otherAttribute = ref([]); | 66 | const otherAttribute = ref([]); |
60 | // 预览条件筛选结果 | 67 | // 预览条件筛选结果 |
61 | const preView = async () => { | 68 | const preView = async () => { |
62 | const attributes = []; | 69 | const attributes = []; |
63 | const fieldsValue = props.childGetFieldsValue(); | 70 | const fieldsValue = props.childGetFieldsValue(); |
64 | for (let i = 0; i < unref(refItem.conditionScreeningRefs).length; i++) { | 71 | for (let i = 0; i < unref(refItem.conditionScreeningRefs).length; i++) { |
65 | - if (i === 0) { | ||
66 | - const attr = conditionPreView( | ||
67 | - [ | ||
68 | - { | ||
69 | - ...unref(refItem.conditionScreeningRefs)[i].getFieldsValue(), | ||
70 | - attribute: fieldsValue.type2, | ||
71 | - }, | ||
72 | - ], | ||
73 | - fieldsValue.operationType | ||
74 | - ); | ||
75 | - firstAttribute.value = attr[0]; | ||
76 | - await unref(refItem.conditionScreeningRefs)[i].validate(); | ||
77 | - continue; | ||
78 | - } | ||
79 | const valid = await unref(refItem.conditionScreeningRefs)[i].validate(); | 72 | const valid = await unref(refItem.conditionScreeningRefs)[i].validate(); |
80 | if (!valid) return; | 73 | if (!valid) return; |
81 | - | ||
82 | attributes.push({ | 74 | attributes.push({ |
83 | ...unref(refItem.conditionScreeningRefs)[i].getFieldsValue(), | 75 | ...unref(refItem.conditionScreeningRefs)[i].getFieldsValue(), |
84 | attribute: fieldsValue.type2, | 76 | attribute: fieldsValue.type2, |
85 | }); | 77 | }); |
86 | } | 78 | } |
87 | otherAttribute.value = conditionPreView(attributes, fieldsValue.operationType); | 79 | otherAttribute.value = conditionPreView(attributes, fieldsValue.operationType); |
88 | - | ||
89 | collapseContainerRef.value.handleExpand(); | 80 | collapseContainerRef.value.handleExpand(); |
90 | }; | 81 | }; |
91 | 82 | ||
92 | const resetFilter = () => { | 83 | const resetFilter = () => { |
93 | - firstAttribute.value = {}; | ||
94 | otherAttribute.value = []; | 84 | otherAttribute.value = []; |
95 | }; | 85 | }; |
96 | const deleteConditionForm = (index) => { | 86 | const deleteConditionForm = (index) => { |
97 | unref(conditionScreeningList).splice(index, 1); | 87 | unref(conditionScreeningList).splice(index, 1); |
88 | + const lastIndex = refItem.conditionScreeningRefs.value.length - 2; | ||
89 | + refItem.conditionScreeningRefs.value[lastIndex]?.removeSchemaByFiled('AND'); | ||
98 | }; | 90 | }; |
91 | + | ||
99 | defineExpose({ | 92 | defineExpose({ |
100 | refItem, | 93 | refItem, |
94 | + conditionScreeningList, | ||
95 | + otherAttribute, | ||
101 | }); | 96 | }); |
102 | </script> | 97 | </script> |
@@ -17,7 +17,7 @@ | @@ -17,7 +17,7 @@ | ||
17 | import { BasicForm, useForm } from '/@/components/Form/index'; | 17 | import { BasicForm, useForm } from '/@/components/Form/index'; |
18 | import { Icon } from '/@/components/Icon'; | 18 | import { Icon } from '/@/components/Icon'; |
19 | import { Tooltip } from 'ant-design-vue'; | 19 | import { Tooltip } from 'ant-design-vue'; |
20 | - import { isType } from '../config.ts'; | 20 | + import { isType } from '../config/formatData.ts'; |
21 | defineProps({ | 21 | defineProps({ |
22 | index: { | 22 | index: { |
23 | type: Number, | 23 | type: Number, |
1 | <template> | 1 | <template> |
2 | - <div class="flex ml-4" v-if="firstAttribute?.value && firstAttribute?.attribute"> | ||
3 | - <div class="text" style="color: #305680">{{ firstAttribute?.attribute }}</div> | ||
4 | - {{ firstAttribute?.operation }} | ||
5 | - <div class="text" style="color: #ff8c68">{{ firstAttribute?.value }}</div> | ||
6 | - {{ firstAttribute?.compoundConditions ?? '' }} | ||
7 | - </div> | ||
8 | <div | 2 | <div |
9 | v-if="otherAttribute.length > 0 && otherAttribute[0].value && otherAttribute[0].operation" | 3 | v-if="otherAttribute.length > 0 && otherAttribute[0].value && otherAttribute[0].operation" |
10 | class="flex" | 4 | class="flex" |
11 | > | 5 | > |
12 | - <template v-for="item in otherAttribute" :key="item.value"> | 6 | + <template v-for="(item, index) in otherAttribute" :key="item.value"> |
13 | <div class="flex" v-if="item?.value && item?.attribute"> | 7 | <div class="flex" v-if="item?.value && item?.attribute"> |
14 | <div class="text mr-2" style="color: #305680">{{ item.attribute }}</div> | 8 | <div class="text mr-2" style="color: #305680">{{ item.attribute }}</div> |
15 | {{ item.operation }} | 9 | {{ item.operation }} |
16 | <div class="text ml-2" style="color: #ff8c68">{{ item.value }}</div> | 10 | <div class="text ml-2" style="color: #ff8c68">{{ item.value }}</div> |
17 | - {{ item.compoundConditions ?? '' }} | 11 | + <span v-if="otherAttribute[index + 1]">和</span> |
18 | </div> | 12 | </div> |
19 | </template> | 13 | </template> |
20 | </div> | 14 | </div> |
@@ -23,10 +17,6 @@ | @@ -23,10 +17,6 @@ | ||
23 | <script lang="ts" setup> | 17 | <script lang="ts" setup> |
24 | import { watch, inject } from 'vue'; | 18 | import { watch, inject } from 'vue'; |
25 | defineProps({ | 19 | defineProps({ |
26 | - firstAttribute: { | ||
27 | - type: Object, | ||
28 | - default: () => {}, | ||
29 | - }, | ||
30 | otherAttribute: { | 20 | otherAttribute: { |
31 | type: Array, | 21 | type: Array, |
32 | default: () => [], | 22 | default: () => [], |
@@ -51,13 +51,13 @@ | @@ -51,13 +51,13 @@ | ||
51 | import { BasicForm, useForm } from '/@/components/Form/index'; | 51 | import { BasicForm, useForm } from '/@/components/Form/index'; |
52 | import { Tooltip, Select, Checkbox, Card } from 'ant-design-vue'; | 52 | import { Tooltip, Select, Checkbox, Card } from 'ant-design-vue'; |
53 | import { Icon } from '/@/components/Icon'; | 53 | import { Icon } from '/@/components/Icon'; |
54 | - import { actionSchema } from '../config'; | 54 | + import { actionSchema } from '../config/config.data.ts'; |
55 | import jsoneditor from 'jsoneditor'; | 55 | import jsoneditor from 'jsoneditor'; |
56 | import 'jsoneditor/dist/jsoneditor.min.css'; | 56 | import 'jsoneditor/dist/jsoneditor.min.css'; |
57 | import { QuestionCircleOutlined } from '@ant-design/icons-vue'; | 57 | import { QuestionCircleOutlined } from '@ant-design/icons-vue'; |
58 | import { useUserStore } from '/@/store/modules/user'; | 58 | import { useUserStore } from '/@/store/modules/user'; |
59 | import ClearAlarm from './ClearAlarm.vue'; | 59 | import ClearAlarm from './ClearAlarm.vue'; |
60 | - defineProps({ | 60 | + const props = defineProps({ |
61 | actionIndex: { | 61 | actionIndex: { |
62 | type: Number, | 62 | type: Number, |
63 | required: true, | 63 | required: true, |
@@ -66,13 +66,22 @@ | @@ -66,13 +66,22 @@ | ||
66 | type: Array, | 66 | type: Array, |
67 | default: () => [], | 67 | default: () => [], |
68 | }, | 68 | }, |
69 | + triggerData: { | ||
70 | + type: Array, | ||
71 | + default: () => [], | ||
72 | + }, | ||
69 | }); | 73 | }); |
74 | + | ||
70 | const emit = defineEmits(['deleteAction']); | 75 | const emit = defineEmits(['deleteAction']); |
71 | const userStore = useUserStore(); | 76 | const userStore = useUserStore(); |
72 | const options = computed(() => { | 77 | const options = computed(() => { |
73 | return [ | 78 | return [ |
74 | { label: '设备输出', value: 'DEVICE_OUT' }, | 79 | { label: '设备输出', value: 'DEVICE_OUT' }, |
75 | - { label: '告警输出', value: 'MSG_NOTIFY', disabled: userStore.getOutTarget === 'MSG_NOTIFY' }, | 80 | + { |
81 | + label: '告警输出', | ||
82 | + value: 'MSG_NOTIFY', | ||
83 | + disabled: userStore.getOutTarget === 'MSG_NOTIFY' || !props.triggerData.length, | ||
84 | + }, | ||
76 | ]; | 85 | ]; |
77 | }); | 86 | }); |
78 | const hasDisabled = ref(false); | 87 | const hasDisabled = ref(false); |
@@ -96,19 +105,14 @@ | @@ -96,19 +105,14 @@ | ||
96 | clearAlarmRef?.value?.conditionScreeningRef?.refItem?.conditionScreeningRefs?.value?.map( | 105 | clearAlarmRef?.value?.conditionScreeningRef?.refItem?.conditionScreeningRefs?.value?.map( |
97 | (item) => item.getFieldsValue() | 106 | (item) => item.getFieldsValue() |
98 | ); | 107 | ); |
99 | - console.log({ | ||
100 | - ...getFieldsValue(), | ||
101 | - ...clearAlarmRef?.value?.getFieldsValue(), | ||
102 | - predicate, | ||
103 | - doContext: unref(jsonInstance.value).get(), | ||
104 | - schedule: clearAlarmRef?.value?.schedule, | ||
105 | - }); | 108 | + |
106 | return { | 109 | return { |
107 | ...getFieldsValue(), | 110 | ...getFieldsValue(), |
108 | ...clearAlarmRef?.value?.getFieldsValue(), | 111 | ...clearAlarmRef?.value?.getFieldsValue(), |
109 | predicate, | 112 | predicate, |
110 | doContext: unref(jsonInstance.value).get(), | 113 | doContext: unref(jsonInstance.value).get(), |
111 | schedule: clearAlarmRef?.value?.schedule, | 114 | schedule: clearAlarmRef?.value?.schedule, |
115 | + checked: checked.value, | ||
112 | }; | 116 | }; |
113 | }; | 117 | }; |
114 | const setFieldsFormValueFun = (fieldsValue) => { | 118 | const setFieldsFormValueFun = (fieldsValue) => { |
@@ -123,6 +127,14 @@ | @@ -123,6 +127,14 @@ | ||
123 | }, | 127 | }, |
124 | }); | 128 | }); |
125 | }; | 129 | }; |
130 | + const updateEditFieldAlarmConfig = (alarmConfigList) => { | ||
131 | + updateSchema({ | ||
132 | + field: 'alarm_config', | ||
133 | + componentProps: { | ||
134 | + options: alarmConfigList, | ||
135 | + }, | ||
136 | + }); | ||
137 | + }; | ||
126 | const updateFieldAlarmConfig = (alarmConfigList) => { | 138 | const updateFieldAlarmConfig = (alarmConfigList) => { |
127 | updateSchema({ | 139 | updateSchema({ |
128 | field: 'alarm_config', | 140 | field: 'alarm_config', |
@@ -169,6 +181,18 @@ | @@ -169,6 +181,18 @@ | ||
169 | 181 | ||
170 | const operationType = ref<string>(''); | 182 | const operationType = ref<string>(''); |
171 | const clearAlarmRef = ref(); | 183 | const clearAlarmRef = ref(); |
184 | + | ||
185 | + const getRefItemConditionScreeningRefs = async () => { | ||
186 | + await nextTick(); | ||
187 | + return clearAlarmRef.value.conditionScreeningRef.refItem.conditionScreeningRefs; | ||
188 | + }; | ||
189 | + const setConditionScreeningList = (list) => { | ||
190 | + clearAlarmRef.value.conditionScreeningRef.conditionScreeningList = list; | ||
191 | + }; | ||
192 | + | ||
193 | + const setRichText = (list) => { | ||
194 | + clearAlarmRef.value.conditionScreeningRef.otherAttribute = list; | ||
195 | + }; | ||
172 | provide('operationType', operationType); | 196 | provide('operationType', operationType); |
173 | defineExpose({ | 197 | defineExpose({ |
174 | getFieldsValueFunc, | 198 | getFieldsValueFunc, |
@@ -180,6 +204,12 @@ | @@ -180,6 +204,12 @@ | ||
180 | getJsonValue, | 204 | getJsonValue, |
181 | setJsonValue, | 205 | setJsonValue, |
182 | jsonInstance, | 206 | jsonInstance, |
207 | + updateEditFieldAlarmConfig, | ||
208 | + checked, | ||
209 | + clearAlarmRef, | ||
210 | + getRefItemConditionScreeningRefs, | ||
211 | + setConditionScreeningList, | ||
212 | + setRichText, | ||
183 | }); | 213 | }); |
184 | </script> | 214 | </script> |
185 | 215 |
1 | <template> | 1 | <template> |
2 | - <CollapseContainer style="background-color: #f2f2f2" :title="`执行条件 ${conditionIndex + 1}`"> | ||
3 | - <template #action> | ||
4 | - <div class="flex"> | ||
5 | - <div> | ||
6 | - <span class="mr-2">启用规则</span> | ||
7 | - <RadioGroup v-model:value="schedule" :options="scheduleOptions" /> | 2 | + <div> |
3 | + <CollapseContainer style="background-color: #f2f2f2" :title="`执行条件${conditionIndex + 1}`"> | ||
4 | + <template #action> | ||
5 | + <div class="flex"> | ||
6 | + <div> | ||
7 | + <span class="mr-2">启用规则</span> | ||
8 | + <RadioGroup v-model:value="schedule" :options="scheduleOptions" /> | ||
9 | + </div> | ||
10 | + <Tooltip title="移除" class="ml-4"> | ||
11 | + <Icon | ||
12 | + icon="fluent:delete-off-20-regular" | ||
13 | + size="20" | ||
14 | + class="mr-2 cursor-pointer" | ||
15 | + @click="handleDelete(conditionIndex)" | ||
16 | + /> | ||
17 | + </Tooltip> | ||
8 | </div> | 18 | </div> |
9 | - <Tooltip title="移除" class="ml-4"> | ||
10 | - <Icon | ||
11 | - icon="fluent:delete-off-20-regular" | ||
12 | - size="20" | ||
13 | - class="mr-2 cursor-pointer" | ||
14 | - @click="handleDelete(conditionIndex)" | 19 | + </template> |
20 | + <BasicForm @register="registerForm"> | ||
21 | + <template #operationType="{ model, field }"> | ||
22 | + <Select | ||
23 | + :options="options" | ||
24 | + v-model:value="model[field]" | ||
25 | + @change="operationType = model[field]" | ||
26 | + placeholder="请选择比较类型" | ||
27 | + allowClear | ||
15 | /> | 28 | /> |
16 | - </Tooltip> | ||
17 | - </div> | ||
18 | - </template> | ||
19 | - <BasicForm @register="registerCondition"> | ||
20 | - <template #operationType="{ model, field }"> | ||
21 | - <Select | ||
22 | - :options="options" | ||
23 | - v-model:value="model[field]" | ||
24 | - @change="operationType = model[field]" | ||
25 | - placeholder="请选择比较类型" | ||
26 | - allowClear | 29 | + </template> |
30 | + </BasicForm> | ||
31 | + <Card size="small" :bordered="false" style="border: 2px dashed #797979" v-if="operationType"> | ||
32 | + <ConditionScreening | ||
33 | + :childGetFieldsValue="childGetFieldsValue" | ||
34 | + ref="conditionScreeningRef" | ||
27 | /> | 35 | /> |
28 | - </template> | ||
29 | - </BasicForm> | ||
30 | - <Card size="small" :bordered="false" style="border: 2px dashed #797979" v-if="operationType"> | ||
31 | - <ConditionScreening :childGetFieldsValue="childGetFieldsValue" ref="conditionScreeningRef" /> | ||
32 | - </Card> | ||
33 | - </CollapseContainer> | 36 | + </Card> |
37 | + </CollapseContainer> | ||
38 | + </div> | ||
34 | </template> | 39 | </template> |
35 | <script lang="ts" setup> | 40 | <script lang="ts" setup> |
36 | - import { ref, provide } from 'vue'; | 41 | + import { ref, provide, nextTick } from 'vue'; |
37 | import { CollapseContainer } from '/@/components/Container/index'; | 42 | import { CollapseContainer } from '/@/components/Container/index'; |
38 | import { BasicForm, useForm } from '/@/components/Form/index'; | 43 | import { BasicForm, useForm } from '/@/components/Form/index'; |
44 | + import { Icon } from '/@/components/Icon'; | ||
39 | import { Tooltip, Radio, Card, Select } from 'ant-design-vue'; | 45 | import { Tooltip, Radio, Card, Select } from 'ant-design-vue'; |
40 | - | ||
41 | - import { trigger_condition_schema } from '../config'; | 46 | + import { trigger_condition_schema } from '../config/config.data.ts'; |
42 | import { getAttribute } from '/@/api/ruleengine/ruleengineApi'; | 47 | import { getAttribute } from '/@/api/ruleengine/ruleengineApi'; |
43 | - import { Icon } from '/@/components/Icon'; | ||
44 | import ConditionScreening from './ConditionScreening.vue'; | 48 | import ConditionScreening from './ConditionScreening.vue'; |
45 | const RadioGroup = Radio.Group; | 49 | const RadioGroup = Radio.Group; |
46 | 50 | ||
@@ -51,13 +55,12 @@ | @@ -51,13 +55,12 @@ | ||
51 | }, | 55 | }, |
52 | }); | 56 | }); |
53 | const emit = defineEmits(['deleteCondition']); | 57 | const emit = defineEmits(['deleteCondition']); |
54 | - | ||
55 | - const [registerCondition, { getFieldsValue, updateSchema, resetFields, setFieldsValue }] = | ||
56 | - useForm({ | ||
57 | - schemas: trigger_condition_schema, | ||
58 | - showActionButtonGroup: false, | ||
59 | - }); | ||
60 | const conditionScreeningRef = ref(); | 58 | const conditionScreeningRef = ref(); |
59 | + const [registerForm, { resetFields, getFieldsValue, updateSchema, setFieldsValue }] = useForm({ | ||
60 | + schemas: trigger_condition_schema, | ||
61 | + showActionButtonGroup: false, | ||
62 | + }); | ||
63 | + | ||
61 | const getFieldsValueFunc = () => { | 64 | const getFieldsValueFunc = () => { |
62 | const predicate = conditionScreeningRef?.value?.refItem?.conditionScreeningRefs?.value?.map( | 65 | const predicate = conditionScreeningRef?.value?.refItem?.conditionScreeningRefs?.value?.map( |
63 | (item) => { | 66 | (item) => { |
@@ -66,7 +69,6 @@ | @@ -66,7 +69,6 @@ | ||
66 | ); | 69 | ); |
67 | return { ...getFieldsValue(), predicate, schedule: schedule.value }; | 70 | return { ...getFieldsValue(), predicate, schedule: schedule.value }; |
68 | }; | 71 | }; |
69 | - const resetFieldsValueFunc = () => resetFields(); | ||
70 | const updateFieldDeviceId = (deviceList: any[]) => { | 72 | const updateFieldDeviceId = (deviceList: any[]) => { |
71 | updateSchema({ | 73 | updateSchema({ |
72 | field: 'entityId', | 74 | field: 'entityId', |
@@ -80,22 +82,30 @@ | @@ -80,22 +82,30 @@ | ||
80 | }, | 82 | }, |
81 | }); | 83 | }); |
82 | }; | 84 | }; |
85 | + const resetFieldsValueFunc = () => resetFields(); | ||
86 | + // 回显数据函数 | ||
83 | const setFieldsFormValueFun = (fieldsValue) => { | 87 | const setFieldsFormValueFun = (fieldsValue) => { |
84 | setFieldsValue(fieldsValue); | 88 | setFieldsValue(fieldsValue); |
85 | }; | 89 | }; |
86 | const updateFieldAttributeFunc = async () => { | 90 | const updateFieldAttributeFunc = async () => { |
87 | const data1 = await getAttribute(); | 91 | const data1 = await getAttribute(); |
88 | - const data = data1.map((m) => ({ label: m, value: m })); | 92 | + const options = data1.map((m) => { |
93 | + return { | ||
94 | + label: m, | ||
95 | + value: m, | ||
96 | + }; | ||
97 | + }); | ||
89 | updateSchema({ | 98 | updateSchema({ |
90 | - field: 'type', | 99 | + field: 'type2', |
91 | componentProps: { | 100 | componentProps: { |
92 | placeholder: '请选择属性', | 101 | placeholder: '请选择属性', |
93 | - options: data, | 102 | + options, |
94 | }, | 103 | }, |
95 | }); | 104 | }); |
96 | }; | 105 | }; |
97 | - const handleDelete = (conditionIndex) => { | ||
98 | - emit('deleteCondition', conditionIndex); | 106 | + |
107 | + const handleDelete = (triggerIndex) => { | ||
108 | + emit('deleteCondition', triggerIndex); | ||
99 | }; | 109 | }; |
100 | 110 | ||
101 | const schedule = ref('ANY_TIME'); | 111 | const schedule = ref('ANY_TIME'); |
@@ -105,6 +115,7 @@ | @@ -105,6 +115,7 @@ | ||
105 | { label: '自定义启用', value: 'CUSTOM' }, | 115 | { label: '自定义启用', value: 'CUSTOM' }, |
106 | ]; | 116 | ]; |
107 | const operationType = ref<string>(''); | 117 | const operationType = ref<string>(''); |
118 | + | ||
108 | const options = [ | 119 | const options = [ |
109 | { | 120 | { |
110 | label: '数字', | 121 | label: '数字', |
@@ -120,19 +131,35 @@ | @@ -120,19 +131,35 @@ | ||
120 | }, | 131 | }, |
121 | { | 132 | { |
122 | label: '时间', | 133 | label: '时间', |
123 | - value: 'TIME', | 134 | + value: 'DATE_TIME', |
124 | }, | 135 | }, |
125 | ]; | 136 | ]; |
126 | - provide('operationType', operationType); | ||
127 | - | ||
128 | // 子组件获取父组件的值 | 137 | // 子组件获取父组件的值 |
129 | const childGetFieldsValue = () => getFieldsValue(); | 138 | const childGetFieldsValue = () => getFieldsValue(); |
130 | 139 | ||
140 | + provide('operationType', operationType); | ||
141 | + | ||
142 | + // 获取conditionScreeningForm的组件 | ||
143 | + const getRefItemConditionScreeningRefs = async () => { | ||
144 | + await nextTick(); | ||
145 | + return conditionScreeningRef.value.refItem.conditionScreeningRefs; | ||
146 | + }; | ||
147 | + | ||
148 | + const setConditionScreeningList = (list) => { | ||
149 | + conditionScreeningRef.value.conditionScreeningList = list; | ||
150 | + }; | ||
151 | + const setRichText = (list) => { | ||
152 | + conditionScreeningRef.value.otherAttribute = list; | ||
153 | + }; | ||
131 | defineExpose({ | 154 | defineExpose({ |
132 | getFieldsValueFunc, | 155 | getFieldsValueFunc, |
133 | updateFieldDeviceId, | 156 | updateFieldDeviceId, |
134 | resetFieldsValueFunc, | 157 | resetFieldsValueFunc, |
135 | setFieldsFormValueFun, | 158 | setFieldsFormValueFun, |
136 | childGetFieldsValue, | 159 | childGetFieldsValue, |
160 | + operationType, | ||
161 | + getRefItemConditionScreeningRefs, | ||
162 | + setConditionScreeningList, | ||
163 | + setRichText, | ||
137 | }); | 164 | }); |
138 | </script> | 165 | </script> |
src/views/rule/linkedge/cpns/format-data/index.ts
deleted
100644 → 0
1 | -export const genTriggerData = (triggerData) => { | ||
2 | - const { | ||
3 | - triggerType, | ||
4 | - entityId, | ||
5 | - type1, | ||
6 | - type2, | ||
7 | - device, | ||
8 | - detail, | ||
9 | - predicate, | ||
10 | - operationType, | ||
11 | - triggered, | ||
12 | - schedule, | ||
13 | - } = triggerData; | ||
14 | - const mapPredicate = predicate.map((item) => { | ||
15 | - return { | ||
16 | - key: { | ||
17 | - type: type1, | ||
18 | - key: type2, | ||
19 | - }, | ||
20 | - valueType: operationType, | ||
21 | - value: null, | ||
22 | - predicate: { | ||
23 | - type: operationType, | ||
24 | - operation: item.operation, | ||
25 | - value: { | ||
26 | - defaultValue: item.value, | ||
27 | - userValue: null, | ||
28 | - dynamicValue: null, | ||
29 | - }, | ||
30 | - }, | ||
31 | - }; | ||
32 | - }); | ||
33 | - return { | ||
34 | - triggerType, | ||
35 | - entityType: device, | ||
36 | - entityId: entityId?.length ? entityId : null, | ||
37 | - triggerCondition: { | ||
38 | - alarmDetails: detail, | ||
39 | - condition: { | ||
40 | - condition: mapPredicate, | ||
41 | - spec: { | ||
42 | - type: triggered, | ||
43 | - // unit: 'SECONDS', | ||
44 | - // predicate: { | ||
45 | - // defaultValue: 30, | ||
46 | - // userValue: null, | ||
47 | - // dynamicValue: null, | ||
48 | - // }, | ||
49 | - }, | ||
50 | - }, | ||
51 | - schedule: { | ||
52 | - type: schedule, | ||
53 | - // timezone: 'Asia/Shanghai', | ||
54 | - // daysOfWeek: [2, 3], | ||
55 | - // startsOn: 8700000, | ||
56 | - // endsOn: 30300000, | ||
57 | - }, | ||
58 | - }, | ||
59 | - }; | ||
60 | -}; | ||
61 | - | ||
62 | -export const genConditionData = (actionData) => { | ||
63 | - const { | ||
64 | - triggerType, | ||
65 | - entityId, | ||
66 | - type1, | ||
67 | - type2, | ||
68 | - device, | ||
69 | - detail, | ||
70 | - predicate, | ||
71 | - operationType, | ||
72 | - triggered, | ||
73 | - schedule, | ||
74 | - } = actionData; | ||
75 | - const mapPredicate = predicate.map((item) => { | ||
76 | - return { | ||
77 | - key: { | ||
78 | - type: type1, | ||
79 | - key: type2, | ||
80 | - }, | ||
81 | - valueType: operationType, | ||
82 | - value: null, | ||
83 | - predicate: { | ||
84 | - type: operationType, | ||
85 | - operation: item.operation, | ||
86 | - value: { | ||
87 | - defaultValue: item.value, | ||
88 | - userValue: null, | ||
89 | - dynamicValue: null, | ||
90 | - }, | ||
91 | - }, | ||
92 | - }; | ||
93 | - }); | ||
94 | - return { | ||
95 | - triggerType, | ||
96 | - entityType: device, | ||
97 | - entityId: entityId?.length ? entityId : null, | ||
98 | - triggerCondition: { | ||
99 | - alarmDetails: detail, | ||
100 | - condition: { | ||
101 | - condition: mapPredicate, | ||
102 | - spec: { | ||
103 | - type: triggered, | ||
104 | - // unit: 'SECONDS', | ||
105 | - // predicate: { | ||
106 | - // defaultValue: 30, | ||
107 | - // userValue: null, | ||
108 | - // dynamicValue: null, | ||
109 | - // }, | ||
110 | - }, | ||
111 | - }, | ||
112 | - schedule: { | ||
113 | - type: schedule, | ||
114 | - // timezone: 'Asia/Shanghai', | ||
115 | - // daysOfWeek: [2, 3], | ||
116 | - // startsOn: 8700000, | ||
117 | - // endsOn: 30300000, | ||
118 | - }, | ||
119 | - }, | ||
120 | - }; | ||
121 | -}; | ||
122 | - | ||
123 | -export const genActionData = (conditionData) => { | ||
124 | - const { | ||
125 | - alarm_config, | ||
126 | - alarm_level, | ||
127 | - detail, | ||
128 | - device, | ||
129 | - doContext, | ||
130 | - operationType, | ||
131 | - outTarget, | ||
132 | - predicate, | ||
133 | - triggerType, | ||
134 | - triggered, | ||
135 | - type1, | ||
136 | - type2, | ||
137 | - schedule, | ||
138 | - entityId, | ||
139 | - deviceId, | ||
140 | - } = conditionData; | ||
141 | - | ||
142 | - const mapPredicate = predicate?.map((item) => { | ||
143 | - return { | ||
144 | - key: { | ||
145 | - type: type1, | ||
146 | - key: type2, | ||
147 | - }, | ||
148 | - valueType: operationType, | ||
149 | - value: null, | ||
150 | - predicate: { | ||
151 | - type: operationType, | ||
152 | - operation: item.operation, | ||
153 | - value: { | ||
154 | - defaultValue: item.value, | ||
155 | - userValue: null, | ||
156 | - dynamicValue: null, | ||
157 | - }, | ||
158 | - }, | ||
159 | - }; | ||
160 | - }); | ||
161 | - console.log(doContext); | ||
162 | - return [ | ||
163 | - { | ||
164 | - alarmProfileId: alarm_config, | ||
165 | - outTarget, | ||
166 | - entityType: device, | ||
167 | - entityId: entityId?.length ? entityId : null, | ||
168 | - deviceId, | ||
169 | - doContext: mapPredicate?.length | ||
170 | - ? { | ||
171 | - alarmLevel: alarm_level, | ||
172 | - clearRule: { | ||
173 | - triggerType, | ||
174 | - triggerCondition: { | ||
175 | - alarmDetails: detail, | ||
176 | - condition: { | ||
177 | - condition: mapPredicate, | ||
178 | - spec: { | ||
179 | - type: triggered, | ||
180 | - // unit: 'SECONDS', | ||
181 | - // predicate: { | ||
182 | - // defaultValue: 30, | ||
183 | - // userValue: null, | ||
184 | - // dynamicValue: null, | ||
185 | - // }, | ||
186 | - }, | ||
187 | - }, | ||
188 | - schedule: { | ||
189 | - type: schedule, | ||
190 | - // timezone: 'Asia/Shanghai', | ||
191 | - // daysOfWeek: [2, 3], | ||
192 | - // startsOn: 8700000, | ||
193 | - // endsOn: 30300000, | ||
194 | - }, | ||
195 | - }, | ||
196 | - }, | ||
197 | - } | ||
198 | - : doContext, | ||
199 | - }, | ||
200 | - ]; | ||
201 | -}; |
@@ -38,12 +38,12 @@ | @@ -38,12 +38,12 @@ | ||
38 | </div> | 38 | </div> |
39 | </template> | 39 | </template> |
40 | <script lang="ts" setup> | 40 | <script lang="ts" setup> |
41 | - import { ref, provide } from 'vue'; | 41 | + import { ref, provide, nextTick } from 'vue'; |
42 | import { CollapseContainer } from '/@/components/Container/index'; | 42 | import { CollapseContainer } from '/@/components/Container/index'; |
43 | import { BasicForm, useForm } from '/@/components/Form/index'; | 43 | import { BasicForm, useForm } from '/@/components/Form/index'; |
44 | import { Icon } from '/@/components/Icon'; | 44 | import { Icon } from '/@/components/Icon'; |
45 | import { Tooltip, Radio, Card, Select } from 'ant-design-vue'; | 45 | import { Tooltip, Radio, Card, Select } from 'ant-design-vue'; |
46 | - import { trigger_condition_schema } from '../config'; | 46 | + import { trigger_condition_schema } from '../config/config.data.ts'; |
47 | import { getAttribute } from '/@/api/ruleengine/ruleengineApi'; | 47 | import { getAttribute } from '/@/api/ruleengine/ruleengineApi'; |
48 | import ConditionScreening from './ConditionScreening.vue'; | 48 | import ConditionScreening from './ConditionScreening.vue'; |
49 | const RadioGroup = Radio.Group; | 49 | const RadioGroup = Radio.Group; |
@@ -100,39 +100,6 @@ | @@ -100,39 +100,6 @@ | ||
100 | componentProps: { | 100 | componentProps: { |
101 | placeholder: '请选择属性', | 101 | placeholder: '请选择属性', |
102 | options, | 102 | options, |
103 | - onChange(value) { | ||
104 | - if (value) { | ||
105 | - updateSchema([ | ||
106 | - { | ||
107 | - field: 'operation', | ||
108 | - ifShow: true, | ||
109 | - }, | ||
110 | - { | ||
111 | - field: 'value', | ||
112 | - ifShow: true, | ||
113 | - }, | ||
114 | - ]); | ||
115 | - setFieldsValue({ | ||
116 | - operation: '', | ||
117 | - value: '', | ||
118 | - }); | ||
119 | - return; | ||
120 | - } | ||
121 | - updateSchema([ | ||
122 | - { | ||
123 | - field: 'operation', | ||
124 | - ifShow: false, | ||
125 | - }, | ||
126 | - { | ||
127 | - field: 'value', | ||
128 | - ifShow: false, | ||
129 | - }, | ||
130 | - ]); | ||
131 | - setFieldsValue({ | ||
132 | - operation: '', | ||
133 | - value: '', | ||
134 | - }); | ||
135 | - }, | ||
136 | }, | 103 | }, |
137 | }); | 104 | }); |
138 | }; | 105 | }; |
@@ -148,6 +115,7 @@ | @@ -148,6 +115,7 @@ | ||
148 | { label: '自定义启用', value: 'CUSTOM' }, | 115 | { label: '自定义启用', value: 'CUSTOM' }, |
149 | ]; | 116 | ]; |
150 | const operationType = ref<string>(''); | 117 | const operationType = ref<string>(''); |
118 | + | ||
151 | const options = [ | 119 | const options = [ |
152 | { | 120 | { |
153 | label: '数字', | 121 | label: '数字', |
@@ -163,7 +131,7 @@ | @@ -163,7 +131,7 @@ | ||
163 | }, | 131 | }, |
164 | { | 132 | { |
165 | label: '时间', | 133 | label: '时间', |
166 | - value: 'TIME', | 134 | + value: 'DATE_TIME', |
167 | }, | 135 | }, |
168 | ]; | 136 | ]; |
169 | // 子组件获取父组件的值 | 137 | // 子组件获取父组件的值 |
@@ -171,11 +139,27 @@ | @@ -171,11 +139,27 @@ | ||
171 | 139 | ||
172 | provide('operationType', operationType); | 140 | provide('operationType', operationType); |
173 | 141 | ||
142 | + // 获取conditionScreeningForm的组件 | ||
143 | + const getRefItemConditionScreeningRefs = async () => { | ||
144 | + await nextTick(); | ||
145 | + return conditionScreeningRef.value.refItem.conditionScreeningRefs; | ||
146 | + }; | ||
147 | + | ||
148 | + const setConditionScreeningList = (list) => { | ||
149 | + conditionScreeningRef.value.conditionScreeningList = list; | ||
150 | + }; | ||
151 | + const setRichText = (list) => { | ||
152 | + conditionScreeningRef.value.otherAttribute = list; | ||
153 | + }; | ||
174 | defineExpose({ | 154 | defineExpose({ |
175 | getFieldsValueFunc, | 155 | getFieldsValueFunc, |
176 | updateFieldDeviceId, | 156 | updateFieldDeviceId, |
177 | resetFieldsValueFunc, | 157 | resetFieldsValueFunc, |
178 | setFieldsFormValueFun, | 158 | setFieldsFormValueFun, |
179 | childGetFieldsValue, | 159 | childGetFieldsValue, |
160 | + operationType, | ||
161 | + getRefItemConditionScreeningRefs, | ||
162 | + setConditionScreeningList, | ||
163 | + setRichText, | ||
180 | }); | 164 | }); |
181 | </script> | 165 | </script> |
@@ -20,13 +20,13 @@ | @@ -20,13 +20,13 @@ | ||
20 | label: '编辑', | 20 | label: '编辑', |
21 | icon: 'clarity:note-edit-line', | 21 | icon: 'clarity:note-edit-line', |
22 | onClick: handleEdit.bind(null, record), | 22 | onClick: handleEdit.bind(null, record), |
23 | - ifShow: record.creator === userId, | 23 | + ifShow: record.creator === userId && record.status !== 1, |
24 | }, | 24 | }, |
25 | { | 25 | { |
26 | label: '删除', | 26 | label: '删除', |
27 | icon: 'ant-design:delete-outlined', | 27 | icon: 'ant-design:delete-outlined', |
28 | color: 'error', | 28 | color: 'error', |
29 | - ifShow: record.creator === userId, | 29 | + ifShow: record.creator === userId && record.status !== 1, |
30 | popConfirm: { | 30 | popConfirm: { |
31 | title: '是否确认删除', | 31 | title: '是否确认删除', |
32 | confirm: handleDeleteOrBatchDelete.bind(null, record), | 32 | confirm: handleDeleteOrBatchDelete.bind(null, record), |
@@ -50,7 +50,7 @@ | @@ -50,7 +50,7 @@ | ||
50 | import { screenLinkPageGetApi, screenLinkPageDeleteApi } from '/@/api/ruleengine/ruleengineApi'; | 50 | import { screenLinkPageGetApi, screenLinkPageDeleteApi } from '/@/api/ruleengine/ruleengineApi'; |
51 | import { useBatchDelete } from '/@/hooks/web/useBatchDelete'; | 51 | import { useBatchDelete } from '/@/hooks/web/useBatchDelete'; |
52 | 52 | ||
53 | - import { columns, searchFormSchema } from './config'; | 53 | + import { columns, searchFormSchema } from './config/config.data.ts'; |
54 | import { USER_INFO_KEY } from '/@/enums/cacheEnum'; | 54 | import { USER_INFO_KEY } from '/@/enums/cacheEnum'; |
55 | import { getAuthCache } from '/@/utils/auth'; | 55 | import { getAuthCache } from '/@/utils/auth'; |
56 | import { authBtn } from '/@/enums/roleEnum'; | 56 | import { authBtn } from '/@/enums/roleEnum'; |