Commit fccc2e0a63cf7edb5c083eaeaafdc0b777e41ecc
Merge branch 'sqy_dev' into 'main'
'fix:场景联动编辑回显', '调整配置文件' See merge request huang/yun-teng-iot-front!175
Showing
13 changed files
with
578 additions
and
443 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/config.data.ts
renamed from
src/views/rule/linkedge/config.ts
@@ -359,7 +359,7 @@ export const actionSchema: FormSchema[] = [ | @@ -359,7 +359,7 @@ export const actionSchema: FormSchema[] = [ | ||
359 | placeholder: '请选择设备', | 359 | placeholder: '请选择设备', |
360 | mode: 'multiple', | 360 | mode: 'multiple', |
361 | }, | 361 | }, |
362 | - ifShow: ({ values }) => isPart(values.device), | 362 | + ifShow: ({ values }) => isPart(values.device) && isDeviceOut(values.outTarget), |
363 | colProps: { span: 6 }, | 363 | colProps: { span: 6 }, |
364 | }, | 364 | }, |
365 | { | 365 | { |
@@ -392,7 +392,7 @@ export const actionSchema: FormSchema[] = [ | @@ -392,7 +392,7 @@ export const actionSchema: FormSchema[] = [ | ||
392 | options: [ | 392 | options: [ |
393 | { | 393 | { |
394 | label: '紧急', | 394 | label: '紧急', |
395 | - value: ' CRITICAL', | 395 | + value: 'CRITICAL', |
396 | }, | 396 | }, |
397 | { | 397 | { |
398 | label: '重要', | 398 | label: '重要', |
@@ -427,209 +427,3 @@ export const actionSchema: FormSchema[] = [ | @@ -427,209 +427,3 @@ export const actionSchema: FormSchema[] = [ | ||
427 | slot: 'clearAlarm', | 427 | slot: 'clearAlarm', |
428 | }, | 428 | }, |
429 | ]; | 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 | -} |
src/views/rule/linkedge/config/formatData.ts
renamed from
src/views/rule/linkedge/cpns/format-data/index.ts
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 | -}; | 1 | +import { formatToDateTime } from '/@/utils/dateUtil'; |
61 | 2 | ||
62 | -export const genConditionData = (actionData) => { | 3 | +// 生成触发器或执行条件JSON数据 |
4 | +export const genTriggerOrConditionData = (triggerData) => { | ||
63 | const { | 5 | const { |
64 | triggerType, | 6 | triggerType, |
65 | entityId, | 7 | entityId, |
@@ -71,8 +13,8 @@ export const genConditionData = (actionData) => { | @@ -71,8 +13,8 @@ export const genConditionData = (actionData) => { | ||
71 | operationType, | 13 | operationType, |
72 | triggered, | 14 | triggered, |
73 | schedule, | 15 | schedule, |
74 | - } = actionData; | ||
75 | - const mapPredicate = predicate.map((item) => { | 16 | + } = triggerData; |
17 | + const mapPredicate = predicate?.map((item) => { | ||
76 | return { | 18 | return { |
77 | key: { | 19 | key: { |
78 | type: type1, | 20 | type: type1, |
@@ -81,10 +23,11 @@ export const genConditionData = (actionData) => { | @@ -81,10 +23,11 @@ export const genConditionData = (actionData) => { | ||
81 | valueType: operationType, | 23 | valueType: operationType, |
82 | value: null, | 24 | value: null, |
83 | predicate: { | 25 | predicate: { |
84 | - type: operationType, | 26 | + type: operationType === 'DATE_TIME' ? 'NUMERIC' : operationType, |
85 | operation: item.operation, | 27 | operation: item.operation, |
86 | value: { | 28 | value: { |
87 | - defaultValue: item.value, | 29 | + defaultValue: |
30 | + operationType === 'DATE_TIME' ? Number(formatToDateTime(item.value, 'x')) : item.value, | ||
88 | userValue: null, | 31 | userValue: null, |
89 | dynamicValue: null, | 32 | dynamicValue: null, |
90 | }, | 33 | }, |
@@ -137,8 +80,8 @@ export const genActionData = (conditionData) => { | @@ -137,8 +80,8 @@ export const genActionData = (conditionData) => { | ||
137 | schedule, | 80 | schedule, |
138 | entityId, | 81 | entityId, |
139 | deviceId, | 82 | deviceId, |
83 | + checked, | ||
140 | } = conditionData; | 84 | } = conditionData; |
141 | - | ||
142 | const mapPredicate = predicate?.map((item) => { | 85 | const mapPredicate = predicate?.map((item) => { |
143 | return { | 86 | return { |
144 | key: { | 87 | key: { |
@@ -158,7 +101,6 @@ export const genActionData = (conditionData) => { | @@ -158,7 +101,6 @@ export const genActionData = (conditionData) => { | ||
158 | }, | 101 | }, |
159 | }; | 102 | }; |
160 | }); | 103 | }); |
161 | - console.log(doContext); | ||
162 | return [ | 104 | return [ |
163 | { | 105 | { |
164 | alarmProfileId: alarm_config, | 106 | alarmProfileId: alarm_config, |
@@ -195,7 +137,229 @@ export const genActionData = (conditionData) => { | @@ -195,7 +137,229 @@ export const genActionData = (conditionData) => { | ||
195 | }, | 137 | }, |
196 | }, | 138 | }, |
197 | } | 139 | } |
198 | - : doContext, | 140 | + : { |
141 | + ...doContext, | ||
142 | + alarmLevel: outTarget === 'MSG_NOTIFY' ? alarm_level : undefined, | ||
143 | + }, | ||
199 | }, | 144 | }, |
200 | ]; | 145 | ]; |
201 | }; | 146 | }; |
147 | + | ||
148 | +import { Number_Operation, String_Operation, Boolean_Operation } from '/@/enums/operationEnum'; | ||
149 | + | ||
150 | +export const operationNumber_OR_TIME = [ | ||
151 | + { label: '等于', value: Number_Operation.EQUAL }, | ||
152 | + { label: '不等于', value: Number_Operation.NOT_EQUAL }, | ||
153 | + { label: '小于', value: Number_Operation.LESS }, | ||
154 | + { label: '小于等于', value: Number_Operation.LESS_OR_EQUAL }, | ||
155 | + { label: '大于', value: Number_Operation.GREATER }, | ||
156 | + { label: '大于等于', value: Number_Operation.GREATER_OR_EQUAL }, | ||
157 | +]; | ||
158 | + | ||
159 | +export const operationString = [ | ||
160 | + { label: '等于', value: String_Operation.EQUAL }, | ||
161 | + { label: '不等于', value: String_Operation.NOT_EQUAL }, | ||
162 | + { label: '开始于', value: String_Operation.BEGAN_IN }, | ||
163 | + { label: '结束于', value: String_Operation.END_IN }, | ||
164 | + { label: '包含', value: String_Operation.INCLUDE }, | ||
165 | + { label: '不包含', value: String_Operation.NOT_INCLUDE }, | ||
166 | +]; | ||
167 | + | ||
168 | +export const operationBoolean = [ | ||
169 | + { label: '等于', value: Boolean_Operation.EQUAL }, | ||
170 | + { label: '不等于', value: Boolean_Operation.NOT_EQUAL }, | ||
171 | +]; | ||
172 | + | ||
173 | +// 查找操作符 | ||
174 | +export function findOperation(valueType, operation) { | ||
175 | + switch (valueType) { | ||
176 | + case 'NUMERIC' || 'DATE_TIME': | ||
177 | + return operationNumber_OR_TIME.find((item) => item.value === operation); | ||
178 | + case 'STRING': | ||
179 | + return operationString.find((item) => item.value === operation); | ||
180 | + case 'BOOLEAN': | ||
181 | + return operationBoolean.find((item) => item.value === operation); | ||
182 | + } | ||
183 | +} | ||
184 | + | ||
185 | +export function isType(operationType) { | ||
186 | + switch (operationType) { | ||
187 | + case 'NUMERIC': | ||
188 | + return [ | ||
189 | + { | ||
190 | + field: 'operation', | ||
191 | + label: '执行操作', | ||
192 | + component: 'Select', | ||
193 | + required: true, | ||
194 | + componentProps: { | ||
195 | + options: operationNumber_OR_TIME, | ||
196 | + }, | ||
197 | + colProps: { | ||
198 | + span: 8, | ||
199 | + }, | ||
200 | + }, | ||
201 | + { | ||
202 | + field: 'value', | ||
203 | + label: '操作值', | ||
204 | + required: true, | ||
205 | + component: 'InputNumber', | ||
206 | + colProps: { | ||
207 | + span: 8, | ||
208 | + }, | ||
209 | + }, | ||
210 | + ]; | ||
211 | + case 'STRING': | ||
212 | + return [ | ||
213 | + { | ||
214 | + field: 'ignoreCase', | ||
215 | + label: '忽略大小写', | ||
216 | + component: 'Checkbox', | ||
217 | + labelWidth: 150, | ||
218 | + colProps: { | ||
219 | + span: 7, | ||
220 | + }, | ||
221 | + }, | ||
222 | + { | ||
223 | + field: 'operation', | ||
224 | + label: '执行操作', | ||
225 | + component: 'Select', | ||
226 | + required: true, | ||
227 | + componentProps: { | ||
228 | + options: operationString, | ||
229 | + }, | ||
230 | + colProps: { | ||
231 | + span: 7, | ||
232 | + }, | ||
233 | + }, | ||
234 | + { | ||
235 | + field: 'value', | ||
236 | + label: '操作值', | ||
237 | + required: true, | ||
238 | + component: 'Input', | ||
239 | + colProps: { | ||
240 | + span: 7, | ||
241 | + }, | ||
242 | + }, | ||
243 | + ]; | ||
244 | + case 'BOOLEAN': | ||
245 | + return [ | ||
246 | + { | ||
247 | + field: 'operation', | ||
248 | + label: '执行操作', | ||
249 | + component: 'Select', | ||
250 | + required: true, | ||
251 | + componentProps: { | ||
252 | + options: operationBoolean, | ||
253 | + }, | ||
254 | + colProps: { | ||
255 | + span: 8, | ||
256 | + }, | ||
257 | + }, | ||
258 | + { | ||
259 | + field: 'value', | ||
260 | + label: '操作值', | ||
261 | + component: 'Select', | ||
262 | + required: true, | ||
263 | + componentProps: { | ||
264 | + options: [ | ||
265 | + { | ||
266 | + label: '真', | ||
267 | + value: 'true', | ||
268 | + }, | ||
269 | + { | ||
270 | + label: '假', | ||
271 | + value: 'false', | ||
272 | + }, | ||
273 | + ], | ||
274 | + }, | ||
275 | + colProps: { | ||
276 | + span: 8, | ||
277 | + }, | ||
278 | + }, | ||
279 | + ]; | ||
280 | + case 'DATE_TIME': | ||
281 | + return [ | ||
282 | + { | ||
283 | + field: 'operation', | ||
284 | + label: '执行操作', | ||
285 | + required: true, | ||
286 | + component: 'Select', | ||
287 | + componentProps: { | ||
288 | + options: operationNumber_OR_TIME, | ||
289 | + }, | ||
290 | + colProps: { | ||
291 | + span: 8, | ||
292 | + }, | ||
293 | + }, | ||
294 | + { | ||
295 | + field: 'value', | ||
296 | + label: '操作值', | ||
297 | + required: true, | ||
298 | + component: 'DatePicker', | ||
299 | + componentProps: { | ||
300 | + showTime: true, | ||
301 | + }, | ||
302 | + colProps: { | ||
303 | + span: 8, | ||
304 | + }, | ||
305 | + }, | ||
306 | + ]; | ||
307 | + } | ||
308 | +} | ||
309 | +export function conditionPreView(data, operationType) { | ||
310 | + if (operationType === 'NUMERIC' || operationType === 'DATE_TIME') { | ||
311 | + const { EQUAL, NOT_EQUAL, LESS, LESS_OR_EQUAL, GREATER, GREATER_OR_EQUAL } = Number_Operation; | ||
312 | + return data.map((item) => { | ||
313 | + return { | ||
314 | + operation: | ||
315 | + item?.operation === EQUAL | ||
316 | + ? '等于' | ||
317 | + : item?.operation === NOT_EQUAL | ||
318 | + ? '不等于' | ||
319 | + : item?.operation === LESS | ||
320 | + ? '小于' | ||
321 | + : item?.operation === LESS_OR_EQUAL | ||
322 | + ? '小于等于' | ||
323 | + : item?.operation === GREATER | ||
324 | + ? '大于' | ||
325 | + : item?.operation === GREATER_OR_EQUAL | ||
326 | + ? '大于等于' | ||
327 | + : '', | ||
328 | + value: item.value, | ||
329 | + attribute: item.attribute, | ||
330 | + }; | ||
331 | + }); | ||
332 | + } else if (operationType === 'STRING') { | ||
333 | + const { EQUAL, NOT_EQUAL, BEGAN_IN, END_IN, INCLUDE, NOT_INCLUDE } = String_Operation; | ||
334 | + return data.map((item) => { | ||
335 | + return { | ||
336 | + operation: | ||
337 | + item?.operation === EQUAL | ||
338 | + ? '等于' | ||
339 | + : item?.operation === NOT_EQUAL | ||
340 | + ? '不等于' | ||
341 | + : item?.operation === BEGAN_IN | ||
342 | + ? '开始于' | ||
343 | + : item?.operation === END_IN | ||
344 | + ? '结束于' | ||
345 | + : item?.operation === INCLUDE | ||
346 | + ? '包含' | ||
347 | + : item?.operation === NOT_INCLUDE | ||
348 | + ? '不包含' | ||
349 | + : '', | ||
350 | + value: item.value, | ||
351 | + attribute: item.attribute, | ||
352 | + }; | ||
353 | + }); | ||
354 | + } else if (operationType === 'BOOLEAN') { | ||
355 | + const { EQUAL, NOT_EQUAL } = Boolean_Operation; | ||
356 | + return data.map((item) => { | ||
357 | + return { | ||
358 | + operation: | ||
359 | + item?.operation === EQUAL ? '等于' : item?.operation === NOT_EQUAL ? '不等于' : '', | ||
360 | + value: item.value, | ||
361 | + attribute: item.attribute, | ||
362 | + }; | ||
363 | + }); | ||
364 | + } | ||
365 | +} |
@@ -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> |
@@ -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'; |