|
@@ -23,6 +23,7 @@ import Service from '@/pages/rule-engine/Scene/service';
|
|
|
import { useAsyncDataSource } from '@/utils/util';
|
|
import { useAsyncDataSource } from '@/utils/util';
|
|
|
import { Store } from 'jetlinks-store';
|
|
import { Store } from 'jetlinks-store';
|
|
|
import { treeFilter } from '@/utils/tree';
|
|
import { treeFilter } from '@/utils/tree';
|
|
|
|
|
+import FInputGroup from '@/components/FInputGroup';
|
|
|
|
|
|
|
|
const service = new Service('scene');
|
|
const service = new Service('scene');
|
|
|
|
|
|
|
@@ -34,56 +35,9 @@ interface Props {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const TriggerTerm = (props: Props, ref: any) => {
|
|
const TriggerTerm = (props: Props, ref: any) => {
|
|
|
- const requestParams = {
|
|
|
|
|
- trigger: {
|
|
|
|
|
- type: 'device',
|
|
|
|
|
- device: {
|
|
|
|
|
- productId: '0412-zj',
|
|
|
|
|
- selector: 'device',
|
|
|
|
|
- selectorValue: [
|
|
|
|
|
- {
|
|
|
|
|
- id: '0412-zj',
|
|
|
|
|
- name: '0412-zj',
|
|
|
|
|
- },
|
|
|
|
|
- ],
|
|
|
|
|
- operation: {
|
|
|
|
|
- operator: 'reportProperty',
|
|
|
|
|
- timer: {
|
|
|
|
|
- trigger: 'week',
|
|
|
|
|
- cron: '',
|
|
|
|
|
- when: [1, 3, 5],
|
|
|
|
|
- mod: 'period',
|
|
|
|
|
- period: {
|
|
|
|
|
- from: '09:30',
|
|
|
|
|
- to: '14:30',
|
|
|
|
|
- every: 1,
|
|
|
|
|
- unit: 'hours',
|
|
|
|
|
- },
|
|
|
|
|
- once: {
|
|
|
|
|
- time: '',
|
|
|
|
|
- },
|
|
|
|
|
- },
|
|
|
|
|
- eventId: '',
|
|
|
|
|
- readProperties: ['temparature', 'temperature-k', 'test-zhibioa'],
|
|
|
|
|
- writeProperties: {},
|
|
|
|
|
- functionId: '',
|
|
|
|
|
- functionParameters: [
|
|
|
|
|
- {
|
|
|
|
|
- name: '',
|
|
|
|
|
- value: {},
|
|
|
|
|
- },
|
|
|
|
|
- ],
|
|
|
|
|
- },
|
|
|
|
|
- defaultVariable: [],
|
|
|
|
|
- },
|
|
|
|
|
- timer: {},
|
|
|
|
|
- defaultVariable: [],
|
|
|
|
|
- },
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
const parseTermRef = useRef<any>();
|
|
const parseTermRef = useRef<any>();
|
|
|
const getParseTerm = () =>
|
|
const getParseTerm = () =>
|
|
|
- service.getParseTerm(requestParams || props.params).then((data) => {
|
|
|
|
|
|
|
+ service.getParseTerm(props.params).then((data) => {
|
|
|
Store.set('trigger-parse-term', data);
|
|
Store.set('trigger-parse-term', data);
|
|
|
parseTermRef.current = data;
|
|
parseTermRef.current = data;
|
|
|
return data.map((item: any) => ({
|
|
return data.map((item: any) => ({
|
|
@@ -97,55 +51,7 @@ const TriggerTerm = (props: Props, ref: any) => {
|
|
|
() =>
|
|
() =>
|
|
|
createForm({
|
|
createForm({
|
|
|
validateFirst: true,
|
|
validateFirst: true,
|
|
|
- initialValues:
|
|
|
|
|
- {
|
|
|
|
|
- trigger: [
|
|
|
|
|
- {
|
|
|
|
|
- terms: [
|
|
|
|
|
- {
|
|
|
|
|
- column: 'properties.temprature.current',
|
|
|
|
|
- termType: 'gt',
|
|
|
|
|
- source: 'manual',
|
|
|
|
|
- value: 123,
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- column: 'properties.test-zhibioa.recent',
|
|
|
|
|
- termType: 'gt',
|
|
|
|
|
- source: 'metrics',
|
|
|
|
|
- value: '123',
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- column: 'properties.test-zhibioa.current',
|
|
|
|
|
- termType: 'lte',
|
|
|
|
|
- source: 'manual',
|
|
|
|
|
- value: 223,
|
|
|
|
|
- },
|
|
|
|
|
- ],
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- terms: [
|
|
|
|
|
- {
|
|
|
|
|
- column: 'properties.temprature.current',
|
|
|
|
|
- termType: 'btw',
|
|
|
|
|
- source: 'manual',
|
|
|
|
|
- value: 23,
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- column: 'properties.temperature-k.current',
|
|
|
|
|
- termType: 'gt',
|
|
|
|
|
- source: 'manual',
|
|
|
|
|
- value: 123,
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- column: '_now',
|
|
|
|
|
- termType: 'eq',
|
|
|
|
|
- source: 'manual',
|
|
|
|
|
- value: '2022-04-29 00:00:07',
|
|
|
|
|
- },
|
|
|
|
|
- ],
|
|
|
|
|
- },
|
|
|
|
|
- ],
|
|
|
|
|
- } || props.value,
|
|
|
|
|
|
|
+ initialValues: props.value,
|
|
|
|
|
|
|
|
effects() {
|
|
effects() {
|
|
|
onFormValuesChange(async (f) => {
|
|
onFormValuesChange(async (f) => {
|
|
@@ -158,13 +64,13 @@ const TriggerTerm = (props: Props, ref: any) => {
|
|
|
const value = (field as Field).value;
|
|
const value = (field as Field).value;
|
|
|
|
|
|
|
|
// 找到选中的
|
|
// 找到选中的
|
|
|
- const _data = await service.getParseTerm(requestParams || props.params);
|
|
|
|
|
|
|
+ const _data = await service.getParseTerm(props.params);
|
|
|
if (!_data) return;
|
|
if (!_data) return;
|
|
|
// 树形搜索
|
|
// 树形搜索
|
|
|
const treeValue = treeFilter(_data, value, 'column');
|
|
const treeValue = treeFilter(_data, value, 'column');
|
|
|
// 找到
|
|
// 找到
|
|
|
const target =
|
|
const target =
|
|
|
- treeValue && treeValue[0].children
|
|
|
|
|
|
|
+ treeValue && treeValue[0]?.children
|
|
|
? treeValue[0]?.children.find((item) => item.column === value)
|
|
? treeValue[0]?.children.find((item) => item.column === value)
|
|
|
: treeValue[0];
|
|
: treeValue[0];
|
|
|
|
|
|
|
@@ -254,6 +160,7 @@ const TriggerTerm = (props: Props, ref: any) => {
|
|
|
FormGrid,
|
|
FormGrid,
|
|
|
FTermTypeSelect,
|
|
FTermTypeSelect,
|
|
|
TreeSelect,
|
|
TreeSelect,
|
|
|
|
|
+ FInputGroup,
|
|
|
},
|
|
},
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -302,7 +209,7 @@ const TriggerTerm = (props: Props, ref: any) => {
|
|
|
'x-decorator': 'FormItem',
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'TreeSelect',
|
|
'x-component': 'TreeSelect',
|
|
|
'x-decorator-props': {
|
|
'x-decorator-props': {
|
|
|
- gridSpan: 4,
|
|
|
|
|
|
|
+ gridSpan: 6,
|
|
|
},
|
|
},
|
|
|
'x-component-props': {
|
|
'x-component-props': {
|
|
|
placeholder: '请选择参数',
|
|
placeholder: '请选择参数',
|
|
@@ -322,21 +229,43 @@ const TriggerTerm = (props: Props, ref: any) => {
|
|
|
placeholder: '操作符',
|
|
placeholder: '操作符',
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
- source: {
|
|
|
|
|
- type: 'string',
|
|
|
|
|
|
|
+ inputGroup: {
|
|
|
|
|
+ type: 'void',
|
|
|
|
|
+ 'x-component': 'FInputGroup',
|
|
|
'x-decorator': 'FormItem',
|
|
'x-decorator': 'FormItem',
|
|
|
- 'x-component': 'Select',
|
|
|
|
|
'x-decorator-props': {
|
|
'x-decorator-props': {
|
|
|
- gridSpan: 1,
|
|
|
|
|
|
|
+ gridSpan: 4,
|
|
|
|
|
+ style: {
|
|
|
|
|
+ width: '100%',
|
|
|
|
|
+ },
|
|
|
},
|
|
},
|
|
|
- },
|
|
|
|
|
- value: {
|
|
|
|
|
- type: 'string',
|
|
|
|
|
- 'x-decorator': 'FormItem',
|
|
|
|
|
- 'x-component': 'Input',
|
|
|
|
|
- 'x-component-props': {},
|
|
|
|
|
- 'x-decorator-props': {
|
|
|
|
|
- gridSpan: 3,
|
|
|
|
|
|
|
+ 'x-component-props': {
|
|
|
|
|
+ compact: true,
|
|
|
|
|
+ style: {
|
|
|
|
|
+ width: '100%',
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ properties: {
|
|
|
|
|
+ source: {
|
|
|
|
|
+ type: 'string',
|
|
|
|
|
+ 'x-component': 'Select',
|
|
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
|
|
+ 'x-component-props': {
|
|
|
|
|
+ style: {
|
|
|
|
|
+ minWidth: '110px',
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ value: {
|
|
|
|
|
+ type: 'string',
|
|
|
|
|
+ 'x-component': 'Input',
|
|
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
|
|
+ 'x-decorator-props': {
|
|
|
|
|
+ style: {
|
|
|
|
|
+ width: 'calc(100% - 110px)',
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
remove: {
|
|
remove: {
|