Commit ca21e32e4a5c9dcae8e33cef7980c8128a217c58

Authored by sqy
1 parent b5e1bd47

'fix:优化场景联动'

... ... @@ -15,10 +15,10 @@ export enum Number_Operation {
15 15 export enum String_Operation {
16 16 EQUAL = 'EQUAL',
17 17 NOT_EQUAL = 'NOT_EQUAL',
18   - BEGAN_IN = 'BEGAN_IN',
19   - END_IN = 'END_IN',
20   - INCLUDE = 'INCLUDE',
21   - NOT_INCLUDE = 'NOT_INCLUDE',
  18 + BEGAN_IN = 'STARTS_WITH',
  19 + END_IN = 'ENDS_WITH',
  20 + INCLUDE = 'CONTAINS',
  21 + NOT_INCLUDE = 'NOT_CONTAINS',
22 22 }
23 23
24 24 export enum Boolean_Operation {
... ...
... ... @@ -15,7 +15,8 @@ export interface selectionOptions {
15 15 rowKey: string;
16 16 clickToRowSelect: boolean;
17 17 rowSelection: {
18   - onChange: (selectedRowKeys: string[]) => void;
  18 + onSelect: (_, __, selectedRowKeys: string[]) => void;
  19 + getCheckboxProps: (record: Recordable) => void;
19 20 type: 'radio' | 'checkbox';
20 21 };
21 22 }
... ... @@ -27,7 +28,8 @@ export const useBatchDelete = (
27 28 const selectedRowIds = ref<string[]>([]);
28 29 const hasBatchDelete = computed(() => selectedRowIds.value.length <= 0);
29 30 // 复选框事件
30   - const onSelectRowChange = (selectedRowKeys: string[]) => {
  31 + const onSelectRow = (_, __, selectedRows) => {
  32 + const selectedRowKeys = selectedRows.map((item) => item.id);
31 33 selectedRowIds.value = selectedRowKeys;
32 34 };
33 35 const handleDeleteOrBatchDelete = async (record: Recordable | null) => {
... ... @@ -41,19 +43,26 @@ export const useBatchDelete = (
41 43 try {
42 44 await deleteFn(selectedRowIds.value);
43 45 createMessage.success('批量删除成功');
44   - selectedRowIds.value = [];
  46 + console.log(selectedRowIds.value);
45 47 handleSuccess();
46   - } catch (e) {
47   - selectedRowIds.value = [];
48   - }
  48 + } catch (e) {}
  49 + selectedRowIds.value = [];
49 50 }
50 51 };
51 52 const selectionOptions: selectionOptions = {
52 53 rowKey: 'id',
53 54 clickToRowSelect: false,
54 55 rowSelection: {
55   - onChange: onSelectRowChange,
  56 + onSelect: onSelectRow,
56 57 type: 'checkbox',
  58 + getCheckboxProps(record: Recordable) {
  59 + // Demo:status为1的选择框禁用
  60 + if (record.status === 1) {
  61 + return { disabled: true };
  62 + } else {
  63 + return { disabled: false };
  64 + }
  65 + },
57 66 },
58 67 };
59 68 return { hasBatchDelete, selectionOptions, handleDeleteOrBatchDelete };
... ...
... ... @@ -17,11 +17,12 @@
17 17 <Divider orientation="left">触发器</Divider>
18 18 <div>
19 19 <template v-for="(item, index) in triggerData" :key="item">
20   - <Trigger
  20 + <TriggerOrCondition
21 21 class="mt-4"
22   - :triggerIndex="index"
  22 + title="触发器"
  23 + :index="index"
23 24 :ref="skipUnwrap.triggerItemRefs"
24   - @deleteTrigger="deleteTrigger"
  25 + @delete="deleteTriggerOrCondition"
25 26 />
26 27 </template>
27 28 <!-- 按钮 -->
... ... @@ -37,11 +38,12 @@
37 38 <Divider orientation="left">执行条件</Divider>
38 39 <div>
39 40 <template v-for="(item, index) in conditionData" :key="item">
40   - <Condition
  41 + <TriggerOrCondition
41 42 class="mt-4"
42   - :conditionIndex="index"
  43 + title="执行条件"
  44 + :index="index"
43 45 :ref="skipUnwrap.conditionItemRefs"
44   - @deleteCondition="deleteCondition"
  46 + @delete="deleteTriggerOrCondition"
45 47 />
46 48 </template>
47 49 <!-- 按钮 -->
... ... @@ -92,8 +94,7 @@
92 94 screenLinkPageByDeptIdGetDevice,
93 95 getOrganizationAlarmConfig,
94 96 } from '/@/api/ruleengine/ruleengineApi';
95   - import Trigger from './cpns/Trigger.vue';
96   - import Condition from './cpns/Condition.vue';
  97 + import TriggerOrCondition from './cpns/Trigger-Condition.vue';
97 98 import Action from './cpns/Action.vue';
98 99 import { useUserStore } from '/@/store/modules/user';
99 100 import { findOperation } from './config/formatData.ts';
... ... @@ -182,13 +183,17 @@
182 183 triggers.forEach((trigger, index) => {
183 184 nextTick(async () => {
184 185 unref(skipUnwrap.triggerItemRefs)[index].setFieldsFormValueFun({
185   - triggered: trigger.triggerCondition.condition.spec.type,
186   - device: trigger.entityType,
187   - triggerType: trigger.triggerType,
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,
  186 + triggered: trigger?.triggerCondition?.condition?.spec?.type,
  187 + device: trigger?.entityType,
  188 + triggerType: trigger?.triggerType,
  189 + type1: trigger?.triggerCondition?.condition?.condition[0]?.key?.type,
  190 + type2: trigger?.triggerCondition?.condition?.condition[0]?.key?.key,
  191 + operationType: trigger?.triggerCondition?.condition?.condition[0]?.valueType,
  192 + detail: trigger?.triggerCondition?.alarmDetails,
  193 + entityId: trigger?.entityId,
  194 + replaceValue: trigger?.triggerCondition?.condition?.spec?.predicate?.defaultValue,
  195 + time: trigger?.triggerCondition?.condition?.spec?.predicate?.defaultValue,
  196 + timeUnit: trigger?.triggerCondition?.condition?.spec?.unit,
192 197 });
193 198 // 设置值operationType
194 199 unref(skipUnwrap.triggerItemRefs)[index].operationType =
... ... @@ -197,7 +202,6 @@
197 202 const ConditionScreeningForm = await unref(skipUnwrap.triggerItemRefs)[
198 203 index
199 204 ].getRefItemConditionScreeningRefs();
200   - triggerData.value = [...new Array(triggers.length).keys()];
201 205
202 206 // 设置对应条件筛选的个数
203 207 unref(skipUnwrap.triggerItemRefs)[index].setConditionScreeningList([
... ... @@ -209,7 +213,7 @@
209 213 // 循环设置条件筛选值。TODO:此处设置顺序有问题
210 214 nextTick(() => {
211 215 const richTextList = [];
212   - trigger.triggerCondition.condition.condition.forEach(async (item, index) => {
  216 + trigger.triggerCondition.condition.condition.forEach((item, index) => {
213 217 const formItem = {
214 218 operation: item.predicate.operation,
215 219 value: String(item.predicate.value.defaultValue),
... ... @@ -231,13 +235,17 @@
231 235 doConditions.forEach((condition, index) => {
232 236 nextTick(async () => {
233 237 unref(skipUnwrap.conditionItemRefs)[index].setFieldsFormValueFun({
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,
  238 + triggered: condition?.triggerCondition?.condition?.spec?.type,
  239 + device: condition?.entityType,
  240 + triggerType: condition?.triggerType,
  241 + type1: condition?.triggerCondition?.condition?.condition[0]?.key?.type,
  242 + type2: condition?.triggerCondition?.condition?.condition[0]?.key?.key,
  243 + operationType: condition?.triggerCondition?.condition?.condition[0]?.valueType,
  244 + detail: condition?.triggerCondition?.alarmDetails,
  245 + entityId: condition?.entityId,
  246 + replaceValue: condition?.triggerCondition?.condition?.spec?.predicate?.defaultValue,
  247 + time: condition?.triggerCondition?.condition?.spec?.predicate?.defaultValue,
  248 + timeUnit: condition?.triggerCondition?.condition?.spec?.unit,
241 249 });
242 250 // 设置值operationType
243 251 unref(skipUnwrap.conditionItemRefs)[index].operationType =
... ... @@ -246,7 +254,6 @@
246 254 const ConditionScreeningForm = await unref(skipUnwrap.conditionItemRefs)[
247 255 index
248 256 ].getRefItemConditionScreeningRefs();
249   - triggerData.value = [...new Array(condition.length).keys()];
250 257
251 258 // 设置对应条件筛选的个数
252 259 unref(skipUnwrap.conditionItemRefs)[index].setConditionScreeningList([
... ... @@ -258,7 +265,7 @@
258 265 // 循环设置条件筛选值。TODO:此处设置顺序有问题
259 266 nextTick(() => {
260 267 const richTextList = [];
261   - condition.triggerCondition.condition.condition.forEach(async (item, index) => {
  268 + condition.triggerCondition.condition.condition.forEach((item, index) => {
262 269 const formItem = {
263 270 operation: item.predicate.operation,
264 271 value: String(item.predicate.value.defaultValue),
... ... @@ -292,14 +299,25 @@
292 299 unref(skipUnwrap.actionItemRefs)[index].checked = true;
293 300 nextTick(async () => {
294 301 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,
  302 + triggered: action.doContext?.clearRule?.triggerCondition?.condition?.spec?.type,
  303 + device: action?.entityType,
  304 + triggerType: action?.doContext?.clearRule?.triggerType,
  305 + type1:
  306 + action?.doContext?.clearRule?.triggerCondition?.condition?.condition[0]?.key
  307 + ?.type,
  308 + type2:
  309 + action?.doContext?.clearRule?.triggerCondition?.condition?.condition[0]?.key?.key,
300 310 operationType:
301   - action.doContext.clearRule.triggerCondition.condition.condition[0].valueType,
302   - detail: action.doContext.clearRule.triggerCondition?.alarmDetails,
  311 + action?.doContext?.clearRule?.triggerCondition?.condition?.condition[0]
  312 + ?.valueType,
  313 + detail: action?.doContext?.clearRule?.triggerCondition?.alarmDetails,
  314 + entityId: action?.doContext?.clearRule?.entityId,
  315 + replaceValue:
  316 + action?.doContext?.clearRule?.triggerCondition?.condition?.spec?.predicate
  317 + ?.defaultValue,
  318 + time: action?.doContext?.clearRule?.triggerCondition?.condition?.spec?.predicate
  319 + ?.defaultValue,
  320 + timeUnit: action?.doContext?.clearRule?.triggerCondition?.condition?.spec?.unit,
303 321 });
304 322 // 设置值operationType
305 323
... ... @@ -309,7 +327,6 @@
309 327 const ConditionScreeningForm = await unref(skipUnwrap.actionItemRefs)[
310 328 index
311 329 ].getRefItemConditionScreeningRefs();
312   - triggerData.value = [...new Array(action.length).keys()];
313 330
314 331 // // 设置对应条件筛选的个数
315 332 unref(skipUnwrap.actionItemRefs)[index].setConditionScreeningList([
... ... @@ -390,7 +407,6 @@
390 407 item.updateFieldDeviceId(deviceList);
391 408 });
392 409 }
393   -
394 410 function setAlarmConfig(linkAge, isOrganizationChange = false) {
395 411 unref(linkAge).map((item) => {
396 412 isOrganizationChange && item.resetFieldsValueFunc();
... ... @@ -463,11 +479,12 @@
463 479 };
464 480 const userStore = useUserStore();
465 481 // 删除
466   - const deleteTrigger = (triggerIndex: number) => {
467   - unref(triggerData).splice(triggerIndex, 1);
468   - };
469   - const deleteCondition = (conditionIndex: number) => {
470   - unref(conditionData).splice(conditionIndex, 1);
  482 + const deleteTriggerOrCondition = ({ index, title }) => {
  483 + if (title === '触发器') {
  484 + unref(triggerData).splice(index, 1);
  485 + } else if (title === '执行条件') {
  486 + unref(conditionData).splice(index, 1);
  487 + }
471 488 };
472 489 const deleteAction = ({ actionIndex, outTarget }) => {
473 490 unref(actionData).splice(actionIndex, 1);
... ...
... ... @@ -182,10 +182,10 @@ export const searchFormSchema: FormSchema[] = [
182 182 ];
183 183 // 持续时间
184 184 const isTimeDuration = (type) => {
185   - return type === 'timeDuration';
  185 + return type === 'DURATION';
186 186 };
187 187 const isReplace = (type) => {
188   - return type === 'replace';
  188 + return type === 'REPEATING';
189 189 };
190 190 // 部分
191 191 const isPart = (type: string) => {
... ... @@ -201,8 +201,8 @@ export const trigger_condition_schema: FormSchema[] = [
201 201 placeholder: '请选择触发类型',
202 202 options: [
203 203 { label: '简单', value: 'SIMPLE' },
204   - { label: '持续时长', value: 'timeDuration' },
205   - { label: '重复次数', value: 'replace' },
  204 + { label: '持续时长', value: 'DURATION' },
  205 + { label: '重复次数', value: 'REPEATING' },
206 206 ],
207 207 },
208 208 colProps: { span: 6 },
... ... @@ -235,21 +235,17 @@ export const trigger_condition_schema: FormSchema[] = [
235 235 field: 'time',
236 236 label: '',
237 237 component: 'Input',
238   - componentProps: {
239   - placeholder: '请输入持续时间',
240   - },
241 238 ifShow: ({ values }) => isTimeDuration(values.triggered),
242 239 colProps: { span: 6 },
  240 + slot: 'time',
243 241 },
244 242 {
245 243 field: 'timeUnit',
246 244 label: '',
247   - component: 'Input',
248   - componentProps: {
249   - placeholder: '请输入持续时间单位',
250   - },
  245 + component: 'Select',
  246 + defaultValue: 'SECONDS',
251 247 ifShow: ({ values }) => isTimeDuration(values.triggered),
252   - colProps: { span: 6 },
  248 + show: false,
253 249 },
254 250 {
255 251 field: 'replaceValue',
... ...
1 1 import { formatToDateTime } from '/@/utils/dateUtil';
2   -
  2 +import { Number_Operation, String_Operation, Boolean_Operation } from '/@/enums/operationEnum';
3 3 // 生成触发器或执行条件JSON数据
4 4 export const genTriggerOrConditionData = (triggerData) => {
5 5 const {
... ... @@ -13,7 +13,11 @@ export const genTriggerOrConditionData = (triggerData) => {
13 13 operationType,
14 14 triggered,
15 15 schedule,
  16 + time,
  17 + timeUnit,
  18 + replaceValue,
16 19 } = triggerData;
  20 + console.log(time, timeUnit, replaceValue);
17 21 const mapPredicate = predicate?.map((item) => {
18 22 return {
19 23 key: {
... ... @@ -21,15 +25,15 @@ export const genTriggerOrConditionData = (triggerData) => {
21 25 key: type2,
22 26 },
23 27 valueType: operationType,
24   - value: null,
  28 + // value: null,
25 29 predicate: {
26 30 type: operationType === 'DATE_TIME' ? 'NUMERIC' : operationType,
27 31 operation: item.operation,
28 32 value: {
29 33 defaultValue:
30 34 operationType === 'DATE_TIME' ? Number(formatToDateTime(item.value, 'x')) : item.value,
31   - userValue: null,
32   - dynamicValue: null,
  35 + // userValue: null,
  36 + // dynamicValue: null,
33 37 },
34 38 },
35 39 };
... ... @@ -44,12 +48,17 @@ export const genTriggerOrConditionData = (triggerData) => {
44 48 condition: mapPredicate,
45 49 spec: {
46 50 type: triggered,
47   - // unit: 'SECONDS',
48   - // predicate: {
49   - // defaultValue: 30,
50   - // userValue: null,
51   - // dynamicValue: null,
52   - // },
  51 + unit: triggered === 'DURATION' ? timeUnit : undefined,
  52 + predicate: {
  53 + defaultValue:
  54 + triggered === 'DURATION'
  55 + ? time
  56 + : triggered === 'REPEATING'
  57 + ? replaceValue
  58 + : undefined,
  59 + // userValue: null,
  60 + // dynamicValue: null,
  61 + },
53 62 },
54 63 },
55 64 schedule: {
... ... @@ -80,8 +89,10 @@ export const genActionData = (conditionData) => {
80 89 schedule,
81 90 entityId,
82 91 deviceId,
83   - checked,
  92 + time,
  93 + timeUnit,
84 94 } = conditionData;
  95 +
85 96 const mapPredicate = predicate?.map((item) => {
86 97 return {
87 98 key: {
... ... @@ -89,14 +100,14 @@ export const genActionData = (conditionData) => {
89 100 key: type2,
90 101 },
91 102 valueType: operationType,
92   - value: null,
  103 + // value: null,
93 104 predicate: {
94 105 type: operationType,
95 106 operation: item.operation,
96 107 value: {
97 108 defaultValue: item.value,
98   - userValue: null,
99   - dynamicValue: null,
  109 + // userValue: null,
  110 + // dynamicValue: null,
100 111 },
101 112 },
102 113 };
... ... @@ -119,12 +130,12 @@ export const genActionData = (conditionData) => {
119 130 condition: mapPredicate,
120 131 spec: {
121 132 type: triggered,
122   - // unit: 'SECONDS',
123   - // predicate: {
124   - // defaultValue: 30,
125   - // userValue: null,
126   - // dynamicValue: null,
127   - // },
  133 + unit: timeUnit,
  134 + predicate: {
  135 + defaultValue: time,
  136 + // userValue: null,
  137 + // dynamicValue: null,
  138 + },
128 139 },
129 140 },
130 141 schedule: {
... ... @@ -145,8 +156,6 @@ export const genActionData = (conditionData) => {
145 156 ];
146 157 };
147 158
148   -import { Number_Operation, String_Operation, Boolean_Operation } from '/@/enums/operationEnum';
149   -
150 159 export const operationNumber_OR_TIME = [
151 160 { label: '等于', value: Number_Operation.EQUAL },
152 161 { label: '不等于', value: Number_Operation.NOT_EQUAL },
... ...
... ... @@ -17,6 +17,17 @@
17 17 allowClear
18 18 />
19 19 </template>
  20 + <template #time="{ model, field }">
  21 + <Input v-model:value="model[field]" placeholder="请输入持续时间">
  22 + <template #addonAfter>
  23 + <Select
  24 + v-model:value="model[`timeUnit`]"
  25 + :options="timeUnitOptions"
  26 + style="width: 60px"
  27 + />
  28 + </template>
  29 + </Input>
  30 + </template>
20 31 </BasicForm>
21 32 <Card size="small" :bordered="false" style="border: 2px dashed #797979" v-if="operationType">
22 33 <ConditionScreening
... ... @@ -31,7 +42,7 @@
31 42 import { ref, provide } from 'vue';
32 43 import { CollapseContainer } from '/@/components/Container/index';
33 44 import { BasicForm, useForm } from '/@/components/Form/index';
34   - import { Radio, Card, Select } from 'ant-design-vue';
  45 + import { Radio, Card, Select, Input } from 'ant-design-vue';
35 46 import { trigger_condition_schema } from '../config/config.data.ts';
36 47 import { getAttribute } from '/@/api/ruleengine/ruleengineApi';
37 48 import ConditionScreening from './ConditionScreening.vue';
... ... @@ -103,6 +114,25 @@
103 114 value: 'DATE_TIME',
104 115 },
105 116 ];
  117 +
  118 + const timeUnitOptions = [
  119 + {
  120 + label: '秒',
  121 + value: 'SECONDS',
  122 + },
  123 + {
  124 + label: '分',
  125 + value: 'MINUTES',
  126 + },
  127 + {
  128 + label: '时',
  129 + value: 'HOURS',
  130 + },
  131 + {
  132 + label: '天',
  133 + value: 'DAYS',
  134 + },
  135 + ];
106 136 const childGetFieldsValue = () => getFieldsValue();
107 137 provide('operationType', operationType);
108 138
... ...
1   -<template>
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>
18   - </div>
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
28   - />
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"
35   - />
36   - </Card>
37   - </CollapseContainer>
38   - </div>
39   -</template>
40   -<script lang="ts" setup>
41   - import { ref, provide, nextTick } from 'vue';
42   - import { CollapseContainer } from '/@/components/Container/index';
43   - import { BasicForm, useForm } from '/@/components/Form/index';
44   - import { Icon } from '/@/components/Icon';
45   - import { Tooltip, Radio, Card, Select } from 'ant-design-vue';
46   - import { trigger_condition_schema } from '../config/config.data.ts';
47   - import { getAttribute } from '/@/api/ruleengine/ruleengineApi';
48   - import ConditionScreening from './ConditionScreening.vue';
49   - const RadioGroup = Radio.Group;
50   -
51   - defineProps({
52   - conditionIndex: {
53   - type: Number,
54   - required: true,
55   - },
56   - });
57   - const emit = defineEmits(['deleteCondition']);
58   - const conditionScreeningRef = ref();
59   - const [registerForm, { resetFields, getFieldsValue, updateSchema, setFieldsValue }] = useForm({
60   - schemas: trigger_condition_schema,
61   - showActionButtonGroup: false,
62   - });
63   -
64   - const getFieldsValueFunc = () => {
65   - const predicate = conditionScreeningRef?.value?.refItem?.conditionScreeningRefs?.value?.map(
66   - (item) => {
67   - return item.getFieldsValue();
68   - }
69   - );
70   - return { ...getFieldsValue(), predicate, schedule: schedule.value };
71   - };
72   - const updateFieldDeviceId = (deviceList: any[]) => {
73   - updateSchema({
74   - field: 'entityId',
75   - componentProps: {
76   - options: deviceList,
77   - onChange(e) {
78   - if (e) {
79   - updateFieldAttributeFunc();
80   - }
81   - },
82   - },
83   - });
84   - };
85   - const resetFieldsValueFunc = () => resetFields();
86   - // 回显数据函数
87   - const setFieldsFormValueFun = (fieldsValue) => {
88   - setFieldsValue(fieldsValue);
89   - };
90   - const updateFieldAttributeFunc = async () => {
91   - const data1 = await getAttribute();
92   - const options = data1.map((m) => {
93   - return {
94   - label: m,
95   - value: m,
96   - };
97   - });
98   - updateSchema({
99   - field: 'type2',
100   - componentProps: {
101   - placeholder: '请选择属性',
102   - options,
103   - },
104   - });
105   - };
106   -
107   - const handleDelete = (triggerIndex) => {
108   - emit('deleteCondition', triggerIndex);
109   - };
110   -
111   - const schedule = ref('ANY_TIME');
112   - const scheduleOptions = [
113   - { label: '始终启用', value: 'ANY_TIME' },
114   - { label: '定时启用', value: 'SPECIFIC_TIME' },
115   - { label: '自定义启用', value: 'CUSTOM' },
116   - ];
117   - const operationType = ref<string>('');
118   -
119   - const options = [
120   - {
121   - label: '数字',
122   - value: 'NUMERIC',
123   - },
124   - {
125   - label: '布尔值',
126   - value: 'BOOLEAN',
127   - },
128   - {
129   - label: '字符串',
130   - value: 'STRING',
131   - },
132   - {
133   - label: '时间',
134   - value: 'DATE_TIME',
135   - },
136   - ];
137   - // 子组件获取父组件的值
138   - const childGetFieldsValue = () => getFieldsValue();
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   - };
154   - defineExpose({
155   - getFieldsValueFunc,
156   - updateFieldDeviceId,
157   - resetFieldsValueFunc,
158   - setFieldsFormValueFun,
159   - childGetFieldsValue,
160   - operationType,
161   - getRefItemConditionScreeningRefs,
162   - setConditionScreeningList,
163   - setRichText,
164   - });
165   -</script>
1   -<template>
2   - <div>
3   - <CollapseContainer style="background-color: #f2f2f2" :title="`触发器 ${triggerIndex + 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(triggerIndex)"
16   - />
17   - </Tooltip>
18   - </div>
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
28   - />
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"
35   - />
36   - </Card>
37   - </CollapseContainer>
38   - </div>
39   -</template>
40   -<script lang="ts" setup>
41   - import { ref, provide, nextTick } from 'vue';
42   - import { CollapseContainer } from '/@/components/Container/index';
43   - import { BasicForm, useForm } from '/@/components/Form/index';
44   - import { Icon } from '/@/components/Icon';
45   - import { Tooltip, Radio, Card, Select } from 'ant-design-vue';
46   - import { trigger_condition_schema } from '../config/config.data.ts';
47   - import { getAttribute } from '/@/api/ruleengine/ruleengineApi';
48   - import ConditionScreening from './ConditionScreening.vue';
49   - const RadioGroup = Radio.Group;
50   -
51   - defineProps({
52   - triggerIndex: {
53   - type: Number,
54   - required: true,
55   - },
56   - });
57   - const emit = defineEmits(['deleteTrigger']);
58   - const conditionScreeningRef = ref();
59   - const [registerForm, { resetFields, getFieldsValue, updateSchema, setFieldsValue }] = useForm({
60   - schemas: trigger_condition_schema,
61   - showActionButtonGroup: false,
62   - });
63   -
64   - const getFieldsValueFunc = () => {
65   - const predicate = conditionScreeningRef?.value?.refItem?.conditionScreeningRefs?.value?.map(
66   - (item) => {
67   - return item.getFieldsValue();
68   - }
69   - );
70   - return { ...getFieldsValue(), predicate, schedule: schedule.value };
71   - };
72   - const updateFieldDeviceId = (deviceList: any[]) => {
73   - updateSchema({
74   - field: 'entityId',
75   - componentProps: {
76   - options: deviceList,
77   - onChange(e) {
78   - if (e) {
79   - updateFieldAttributeFunc();
80   - }
81   - },
82   - },
83   - });
84   - };
85   - const resetFieldsValueFunc = () => resetFields();
86   - // 回显数据函数
87   - const setFieldsFormValueFun = (fieldsValue) => {
88   - setFieldsValue(fieldsValue);
89   - };
90   - const updateFieldAttributeFunc = async () => {
91   - const data1 = await getAttribute();
92   - const options = data1.map((m) => {
93   - return {
94   - label: m,
95   - value: m,
96   - };
97   - });
98   - updateSchema({
99   - field: 'type2',
100   - componentProps: {
101   - placeholder: '请选择属性',
102   - options,
103   - },
104   - });
105   - };
106   -
107   - const handleDelete = (triggerIndex) => {
108   - emit('deleteTrigger', triggerIndex);
109   - };
110   -
111   - const schedule = ref('ANY_TIME');
112   - const scheduleOptions = [
113   - { label: '始终启用', value: 'ANY_TIME' },
114   - { label: '定时启用', value: 'SPECIFIC_TIME' },
115   - { label: '自定义启用', value: 'CUSTOM' },
116   - ];
117   - const operationType = ref<string>('');
118   -
119   - const options = [
120   - {
121   - label: '数字',
122   - value: 'NUMERIC',
123   - },
124   - {
125   - label: '布尔值',
126   - value: 'BOOLEAN',
127   - },
128   - {
129   - label: '字符串',
130   - value: 'STRING',
131   - },
132   - {
133   - label: '时间',
134   - value: 'DATE_TIME',
135   - },
136   - ];
137   - // 子组件获取父组件的值
138   - const childGetFieldsValue = () => getFieldsValue();
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   - };
154   - defineExpose({
155   - getFieldsValueFunc,
156   - updateFieldDeviceId,
157   - resetFieldsValueFunc,
158   - setFieldsFormValueFun,
159   - childGetFieldsValue,
160   - operationType,
161   - getRefItemConditionScreeningRefs,
162   - setConditionScreeningList,
163   - setRichText,
164   - });
165   -</script>
... ... @@ -13,7 +13,6 @@
13 13 {
14 14 label: '查看',
15 15 icon: 'ant-design:eye-outlined',
16   - ifShow: record.creator !== userId,
17 16 onClick: handleView.bind(null, record),
18 17 },
19 18 {
... ... @@ -65,6 +64,9 @@
65 64 screenLinkPageDeleteApi,
66 65 handleSuccess
67 66 );
  67 + const handleLog = (log) => {
  68 + console.log(log);
  69 + };
68 70 const userInfo: any = getAuthCache(USER_INFO_KEY);
69 71 const userId = userInfo.userId;
70 72 const role: string = userInfo.roles[0];
... ... @@ -125,6 +127,7 @@
125 127 authBtn,
126 128 role,
127 129 userId,
  130 + handleLog,
128 131 };
129 132 },
130 133 });
... ...