Commit ca21e32e4a5c9dcae8e33cef7980c8128a217c58

Authored by sqy
1 parent b5e1bd47

'fix:优化场景联动'

@@ -15,10 +15,10 @@ export enum Number_Operation { @@ -15,10 +15,10 @@ export enum Number_Operation {
15 export enum String_Operation { 15 export enum String_Operation {
16 EQUAL = 'EQUAL', 16 EQUAL = 'EQUAL',
17 NOT_EQUAL = 'NOT_EQUAL', 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 export enum Boolean_Operation { 24 export enum Boolean_Operation {
@@ -15,7 +15,8 @@ export interface selectionOptions { @@ -15,7 +15,8 @@ export interface selectionOptions {
15 rowKey: string; 15 rowKey: string;
16 clickToRowSelect: boolean; 16 clickToRowSelect: boolean;
17 rowSelection: { 17 rowSelection: {
18 - onChange: (selectedRowKeys: string[]) => void; 18 + onSelect: (_, __, selectedRowKeys: string[]) => void;
  19 + getCheckboxProps: (record: Recordable) => void;
19 type: 'radio' | 'checkbox'; 20 type: 'radio' | 'checkbox';
20 }; 21 };
21 } 22 }
@@ -27,7 +28,8 @@ export const useBatchDelete = ( @@ -27,7 +28,8 @@ export const useBatchDelete = (
27 const selectedRowIds = ref<string[]>([]); 28 const selectedRowIds = ref<string[]>([]);
28 const hasBatchDelete = computed(() => selectedRowIds.value.length <= 0); 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 selectedRowIds.value = selectedRowKeys; 33 selectedRowIds.value = selectedRowKeys;
32 }; 34 };
33 const handleDeleteOrBatchDelete = async (record: Recordable | null) => { 35 const handleDeleteOrBatchDelete = async (record: Recordable | null) => {
@@ -41,19 +43,26 @@ export const useBatchDelete = ( @@ -41,19 +43,26 @@ export const useBatchDelete = (
41 try { 43 try {
42 await deleteFn(selectedRowIds.value); 44 await deleteFn(selectedRowIds.value);
43 createMessage.success('批量删除成功'); 45 createMessage.success('批量删除成功');
44 - selectedRowIds.value = []; 46 + console.log(selectedRowIds.value);
45 handleSuccess(); 47 handleSuccess();
46 - } catch (e) {  
47 - selectedRowIds.value = [];  
48 - } 48 + } catch (e) {}
  49 + selectedRowIds.value = [];
49 } 50 }
50 }; 51 };
51 const selectionOptions: selectionOptions = { 52 const selectionOptions: selectionOptions = {
52 rowKey: 'id', 53 rowKey: 'id',
53 clickToRowSelect: false, 54 clickToRowSelect: false,
54 rowSelection: { 55 rowSelection: {
55 - onChange: onSelectRowChange, 56 + onSelect: onSelectRow,
56 type: 'checkbox', 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 return { hasBatchDelete, selectionOptions, handleDeleteOrBatchDelete }; 68 return { hasBatchDelete, selectionOptions, handleDeleteOrBatchDelete };
@@ -17,11 +17,12 @@ @@ -17,11 +17,12 @@
17 <Divider orientation="left">触发器</Divider> 17 <Divider orientation="left">触发器</Divider>
18 <div> 18 <div>
19 <template v-for="(item, index) in triggerData" :key="item"> 19 <template v-for="(item, index) in triggerData" :key="item">
20 - <Trigger 20 + <TriggerOrCondition
21 class="mt-4" 21 class="mt-4"
22 - :triggerIndex="index" 22 + title="触发器"
  23 + :index="index"
23 :ref="skipUnwrap.triggerItemRefs" 24 :ref="skipUnwrap.triggerItemRefs"
24 - @deleteTrigger="deleteTrigger" 25 + @delete="deleteTriggerOrCondition"
25 /> 26 />
26 </template> 27 </template>
27 <!-- 按钮 --> 28 <!-- 按钮 -->
@@ -37,11 +38,12 @@ @@ -37,11 +38,12 @@
37 <Divider orientation="left">执行条件</Divider> 38 <Divider orientation="left">执行条件</Divider>
38 <div> 39 <div>
39 <template v-for="(item, index) in conditionData" :key="item"> 40 <template v-for="(item, index) in conditionData" :key="item">
40 - <Condition 41 + <TriggerOrCondition
41 class="mt-4" 42 class="mt-4"
42 - :conditionIndex="index" 43 + title="执行条件"
  44 + :index="index"
43 :ref="skipUnwrap.conditionItemRefs" 45 :ref="skipUnwrap.conditionItemRefs"
44 - @deleteCondition="deleteCondition" 46 + @delete="deleteTriggerOrCondition"
45 /> 47 />
46 </template> 48 </template>
47 <!-- 按钮 --> 49 <!-- 按钮 -->
@@ -92,8 +94,7 @@ @@ -92,8 +94,7 @@
92 screenLinkPageByDeptIdGetDevice, 94 screenLinkPageByDeptIdGetDevice,
93 getOrganizationAlarmConfig, 95 getOrganizationAlarmConfig,
94 } from '/@/api/ruleengine/ruleengineApi'; 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 import Action from './cpns/Action.vue'; 98 import Action from './cpns/Action.vue';
98 import { useUserStore } from '/@/store/modules/user'; 99 import { useUserStore } from '/@/store/modules/user';
99 import { findOperation } from './config/formatData.ts'; 100 import { findOperation } from './config/formatData.ts';
@@ -182,13 +183,17 @@ @@ -182,13 +183,17 @@
182 triggers.forEach((trigger, index) => { 183 triggers.forEach((trigger, index) => {
183 nextTick(async () => { 184 nextTick(async () => {
184 unref(skipUnwrap.triggerItemRefs)[index].setFieldsFormValueFun({ 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 // 设置值operationType 198 // 设置值operationType
194 unref(skipUnwrap.triggerItemRefs)[index].operationType = 199 unref(skipUnwrap.triggerItemRefs)[index].operationType =
@@ -197,7 +202,6 @@ @@ -197,7 +202,6 @@
197 const ConditionScreeningForm = await unref(skipUnwrap.triggerItemRefs)[ 202 const ConditionScreeningForm = await unref(skipUnwrap.triggerItemRefs)[
198 index 203 index
199 ].getRefItemConditionScreeningRefs(); 204 ].getRefItemConditionScreeningRefs();
200 - triggerData.value = [...new Array(triggers.length).keys()];  
201 205
202 // 设置对应条件筛选的个数 206 // 设置对应条件筛选的个数
203 unref(skipUnwrap.triggerItemRefs)[index].setConditionScreeningList([ 207 unref(skipUnwrap.triggerItemRefs)[index].setConditionScreeningList([
@@ -209,7 +213,7 @@ @@ -209,7 +213,7 @@
209 // 循环设置条件筛选值。TODO:此处设置顺序有问题 213 // 循环设置条件筛选值。TODO:此处设置顺序有问题
210 nextTick(() => { 214 nextTick(() => {
211 const richTextList = []; 215 const richTextList = [];
212 - trigger.triggerCondition.condition.condition.forEach(async (item, index) => { 216 + trigger.triggerCondition.condition.condition.forEach((item, index) => {
213 const formItem = { 217 const formItem = {
214 operation: item.predicate.operation, 218 operation: item.predicate.operation,
215 value: String(item.predicate.value.defaultValue), 219 value: String(item.predicate.value.defaultValue),
@@ -231,13 +235,17 @@ @@ -231,13 +235,17 @@
231 doConditions.forEach((condition, index) => { 235 doConditions.forEach((condition, index) => {
232 nextTick(async () => { 236 nextTick(async () => {
233 unref(skipUnwrap.conditionItemRefs)[index].setFieldsFormValueFun({ 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 // 设置值operationType 250 // 设置值operationType
243 unref(skipUnwrap.conditionItemRefs)[index].operationType = 251 unref(skipUnwrap.conditionItemRefs)[index].operationType =
@@ -246,7 +254,6 @@ @@ -246,7 +254,6 @@
246 const ConditionScreeningForm = await unref(skipUnwrap.conditionItemRefs)[ 254 const ConditionScreeningForm = await unref(skipUnwrap.conditionItemRefs)[
247 index 255 index
248 ].getRefItemConditionScreeningRefs(); 256 ].getRefItemConditionScreeningRefs();
249 - triggerData.value = [...new Array(condition.length).keys()];  
250 257
251 // 设置对应条件筛选的个数 258 // 设置对应条件筛选的个数
252 unref(skipUnwrap.conditionItemRefs)[index].setConditionScreeningList([ 259 unref(skipUnwrap.conditionItemRefs)[index].setConditionScreeningList([
@@ -258,7 +265,7 @@ @@ -258,7 +265,7 @@
258 // 循环设置条件筛选值。TODO:此处设置顺序有问题 265 // 循环设置条件筛选值。TODO:此处设置顺序有问题
259 nextTick(() => { 266 nextTick(() => {
260 const richTextList = []; 267 const richTextList = [];
261 - condition.triggerCondition.condition.condition.forEach(async (item, index) => { 268 + condition.triggerCondition.condition.condition.forEach((item, index) => {
262 const formItem = { 269 const formItem = {
263 operation: item.predicate.operation, 270 operation: item.predicate.operation,
264 value: String(item.predicate.value.defaultValue), 271 value: String(item.predicate.value.defaultValue),
@@ -292,14 +299,25 @@ @@ -292,14 +299,25 @@
292 unref(skipUnwrap.actionItemRefs)[index].checked = true; 299 unref(skipUnwrap.actionItemRefs)[index].checked = true;
293 nextTick(async () => { 300 nextTick(async () => {
294 unref(skipUnwrap.actionItemRefs)[index].clearAlarmRef.setFieldsFormValueFun({ 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 operationType: 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 // 设置值operationType 322 // 设置值operationType
305 323
@@ -309,7 +327,6 @@ @@ -309,7 +327,6 @@
309 const ConditionScreeningForm = await unref(skipUnwrap.actionItemRefs)[ 327 const ConditionScreeningForm = await unref(skipUnwrap.actionItemRefs)[
310 index 328 index
311 ].getRefItemConditionScreeningRefs(); 329 ].getRefItemConditionScreeningRefs();
312 - triggerData.value = [...new Array(action.length).keys()];  
313 330
314 // // 设置对应条件筛选的个数 331 // // 设置对应条件筛选的个数
315 unref(skipUnwrap.actionItemRefs)[index].setConditionScreeningList([ 332 unref(skipUnwrap.actionItemRefs)[index].setConditionScreeningList([
@@ -390,7 +407,6 @@ @@ -390,7 +407,6 @@
390 item.updateFieldDeviceId(deviceList); 407 item.updateFieldDeviceId(deviceList);
391 }); 408 });
392 } 409 }
393 -  
394 function setAlarmConfig(linkAge, isOrganizationChange = false) { 410 function setAlarmConfig(linkAge, isOrganizationChange = false) {
395 unref(linkAge).map((item) => { 411 unref(linkAge).map((item) => {
396 isOrganizationChange && item.resetFieldsValueFunc(); 412 isOrganizationChange && item.resetFieldsValueFunc();
@@ -463,11 +479,12 @@ @@ -463,11 +479,12 @@
463 }; 479 };
464 const userStore = useUserStore(); 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 const deleteAction = ({ actionIndex, outTarget }) => { 489 const deleteAction = ({ actionIndex, outTarget }) => {
473 unref(actionData).splice(actionIndex, 1); 490 unref(actionData).splice(actionIndex, 1);
@@ -182,10 +182,10 @@ export const searchFormSchema: FormSchema[] = [ @@ -182,10 +182,10 @@ export const searchFormSchema: FormSchema[] = [
182 ]; 182 ];
183 // 持续时间 183 // 持续时间
184 const isTimeDuration = (type) => { 184 const isTimeDuration = (type) => {
185 - return type === 'timeDuration'; 185 + return type === 'DURATION';
186 }; 186 };
187 const isReplace = (type) => { 187 const isReplace = (type) => {
188 - return type === 'replace'; 188 + return type === 'REPEATING';
189 }; 189 };
190 // 部分 190 // 部分
191 const isPart = (type: string) => { 191 const isPart = (type: string) => {
@@ -201,8 +201,8 @@ export const trigger_condition_schema: FormSchema[] = [ @@ -201,8 +201,8 @@ export const trigger_condition_schema: FormSchema[] = [
201 placeholder: '请选择触发类型', 201 placeholder: '请选择触发类型',
202 options: [ 202 options: [
203 { label: '简单', value: 'SIMPLE' }, 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 colProps: { span: 6 }, 208 colProps: { span: 6 },
@@ -235,21 +235,17 @@ export const trigger_condition_schema: FormSchema[] = [ @@ -235,21 +235,17 @@ export const trigger_condition_schema: FormSchema[] = [
235 field: 'time', 235 field: 'time',
236 label: '', 236 label: '',
237 component: 'Input', 237 component: 'Input',
238 - componentProps: {  
239 - placeholder: '请输入持续时间',  
240 - },  
241 ifShow: ({ values }) => isTimeDuration(values.triggered), 238 ifShow: ({ values }) => isTimeDuration(values.triggered),
242 colProps: { span: 6 }, 239 colProps: { span: 6 },
  240 + slot: 'time',
243 }, 241 },
244 { 242 {
245 field: 'timeUnit', 243 field: 'timeUnit',
246 label: '', 244 label: '',
247 - component: 'Input',  
248 - componentProps: {  
249 - placeholder: '请输入持续时间单位',  
250 - }, 245 + component: 'Select',
  246 + defaultValue: 'SECONDS',
251 ifShow: ({ values }) => isTimeDuration(values.triggered), 247 ifShow: ({ values }) => isTimeDuration(values.triggered),
252 - colProps: { span: 6 }, 248 + show: false,
253 }, 249 },
254 { 250 {
255 field: 'replaceValue', 251 field: 'replaceValue',
1 import { formatToDateTime } from '/@/utils/dateUtil'; 1 import { formatToDateTime } from '/@/utils/dateUtil';
2 - 2 +import { Number_Operation, String_Operation, Boolean_Operation } from '/@/enums/operationEnum';
3 // 生成触发器或执行条件JSON数据 3 // 生成触发器或执行条件JSON数据
4 export const genTriggerOrConditionData = (triggerData) => { 4 export const genTriggerOrConditionData = (triggerData) => {
5 const { 5 const {
@@ -13,7 +13,11 @@ export const genTriggerOrConditionData = (triggerData) => { @@ -13,7 +13,11 @@ export const genTriggerOrConditionData = (triggerData) => {
13 operationType, 13 operationType,
14 triggered, 14 triggered,
15 schedule, 15 schedule,
  16 + time,
  17 + timeUnit,
  18 + replaceValue,
16 } = triggerData; 19 } = triggerData;
  20 + console.log(time, timeUnit, replaceValue);
17 const mapPredicate = predicate?.map((item) => { 21 const mapPredicate = predicate?.map((item) => {
18 return { 22 return {
19 key: { 23 key: {
@@ -21,15 +25,15 @@ export const genTriggerOrConditionData = (triggerData) => { @@ -21,15 +25,15 @@ export const genTriggerOrConditionData = (triggerData) => {
21 key: type2, 25 key: type2,
22 }, 26 },
23 valueType: operationType, 27 valueType: operationType,
24 - value: null, 28 + // value: null,
25 predicate: { 29 predicate: {
26 type: operationType === 'DATE_TIME' ? 'NUMERIC' : operationType, 30 type: operationType === 'DATE_TIME' ? 'NUMERIC' : operationType,
27 operation: item.operation, 31 operation: item.operation,
28 value: { 32 value: {
29 defaultValue: 33 defaultValue:
30 operationType === 'DATE_TIME' ? Number(formatToDateTime(item.value, 'x')) : item.value, 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,12 +48,17 @@ export const genTriggerOrConditionData = (triggerData) => {
44 condition: mapPredicate, 48 condition: mapPredicate,
45 spec: { 49 spec: {
46 type: triggered, 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 schedule: { 64 schedule: {
@@ -80,8 +89,10 @@ export const genActionData = (conditionData) => { @@ -80,8 +89,10 @@ export const genActionData = (conditionData) => {
80 schedule, 89 schedule,
81 entityId, 90 entityId,
82 deviceId, 91 deviceId,
83 - checked, 92 + time,
  93 + timeUnit,
84 } = conditionData; 94 } = conditionData;
  95 +
85 const mapPredicate = predicate?.map((item) => { 96 const mapPredicate = predicate?.map((item) => {
86 return { 97 return {
87 key: { 98 key: {
@@ -89,14 +100,14 @@ export const genActionData = (conditionData) => { @@ -89,14 +100,14 @@ export const genActionData = (conditionData) => {
89 key: type2, 100 key: type2,
90 }, 101 },
91 valueType: operationType, 102 valueType: operationType,
92 - value: null, 103 + // value: null,
93 predicate: { 104 predicate: {
94 type: operationType, 105 type: operationType,
95 operation: item.operation, 106 operation: item.operation,
96 value: { 107 value: {
97 defaultValue: item.value, 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,12 +130,12 @@ export const genActionData = (conditionData) => {
119 condition: mapPredicate, 130 condition: mapPredicate,
120 spec: { 131 spec: {
121 type: triggered, 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 schedule: { 141 schedule: {
@@ -145,8 +156,6 @@ export const genActionData = (conditionData) => { @@ -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 export const operationNumber_OR_TIME = [ 159 export const operationNumber_OR_TIME = [
151 { label: '等于', value: Number_Operation.EQUAL }, 160 { label: '等于', value: Number_Operation.EQUAL },
152 { label: '不等于', value: Number_Operation.NOT_EQUAL }, 161 { label: '不等于', value: Number_Operation.NOT_EQUAL },
@@ -17,6 +17,17 @@ @@ -17,6 +17,17 @@
17 allowClear 17 allowClear
18 /> 18 />
19 </template> 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 </BasicForm> 31 </BasicForm>
21 <Card size="small" :bordered="false" style="border: 2px dashed #797979" v-if="operationType"> 32 <Card size="small" :bordered="false" style="border: 2px dashed #797979" v-if="operationType">
22 <ConditionScreening 33 <ConditionScreening
@@ -31,7 +42,7 @@ @@ -31,7 +42,7 @@
31 import { ref, provide } from 'vue'; 42 import { ref, provide } from 'vue';
32 import { CollapseContainer } from '/@/components/Container/index'; 43 import { CollapseContainer } from '/@/components/Container/index';
33 import { BasicForm, useForm } from '/@/components/Form/index'; 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 import { trigger_condition_schema } from '../config/config.data.ts'; 46 import { trigger_condition_schema } from '../config/config.data.ts';
36 import { getAttribute } from '/@/api/ruleengine/ruleengineApi'; 47 import { getAttribute } from '/@/api/ruleengine/ruleengineApi';
37 import ConditionScreening from './ConditionScreening.vue'; 48 import ConditionScreening from './ConditionScreening.vue';
@@ -103,6 +114,25 @@ @@ -103,6 +114,25 @@
103 value: 'DATE_TIME', 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 const childGetFieldsValue = () => getFieldsValue(); 136 const childGetFieldsValue = () => getFieldsValue();
107 provide('operationType', operationType); 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,7 +13,6 @@
13 { 13 {
14 label: '查看', 14 label: '查看',
15 icon: 'ant-design:eye-outlined', 15 icon: 'ant-design:eye-outlined',
16 - ifShow: record.creator !== userId,  
17 onClick: handleView.bind(null, record), 16 onClick: handleView.bind(null, record),
18 }, 17 },
19 { 18 {
@@ -65,6 +64,9 @@ @@ -65,6 +64,9 @@
65 screenLinkPageDeleteApi, 64 screenLinkPageDeleteApi,
66 handleSuccess 65 handleSuccess
67 ); 66 );
  67 + const handleLog = (log) => {
  68 + console.log(log);
  69 + };
68 const userInfo: any = getAuthCache(USER_INFO_KEY); 70 const userInfo: any = getAuthCache(USER_INFO_KEY);
69 const userId = userInfo.userId; 71 const userId = userInfo.userId;
70 const role: string = userInfo.roles[0]; 72 const role: string = userInfo.roles[0];
@@ -125,6 +127,7 @@ @@ -125,6 +127,7 @@
125 authBtn, 127 authBtn,
126 role, 128 role,
127 userId, 129 userId,
  130 + handleLog,
128 }; 131 };
129 }, 132 },
130 }); 133 });