|
@@ -4,9 +4,7 @@ import { Input, InputNumber, Select } from 'antd';
|
|
|
import React, { useEffect, useRef, useState } from 'react';
|
|
import React, { useEffect, useRef, useState } from 'react';
|
|
|
import type { ProFormInstance } from '@ant-design/pro-form';
|
|
import type { ProFormInstance } from '@ant-design/pro-form';
|
|
|
import ProForm from '@ant-design/pro-form';
|
|
import ProForm from '@ant-design/pro-form';
|
|
|
-import ObjModel from '../DeviceOutput/actions/ObjModel';
|
|
|
|
|
-import ObjInput from './ObjInput';
|
|
|
|
|
-import TypeTime from './TypeTime';
|
|
|
|
|
|
|
+import { DatePickerFormat } from '@/pages/rule-engine/Scene/Save/components';
|
|
|
|
|
|
|
|
type FunctionTableDataType = {
|
|
type FunctionTableDataType = {
|
|
|
id: string;
|
|
id: string;
|
|
@@ -25,8 +23,6 @@ interface FunctionCallProps {
|
|
|
export default (props: FunctionCallProps) => {
|
|
export default (props: FunctionCallProps) => {
|
|
|
const [editableKeys, setEditableRowKeys] = useState<React.Key[]>([]);
|
|
const [editableKeys, setEditableRowKeys] = useState<React.Key[]>([]);
|
|
|
const formRef = useRef<ProFormInstance<any>>();
|
|
const formRef = useRef<ProFormInstance<any>>();
|
|
|
- const [objVisiable, setObjVisable] = useState<boolean>(false);
|
|
|
|
|
- const [value, setValue] = useState<any>();
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
if (props.functionData && props.functionData.length) {
|
|
if (props.functionData && props.functionData.length) {
|
|
@@ -63,7 +59,7 @@ export default (props: FunctionCallProps) => {
|
|
|
}
|
|
}
|
|
|
}, [props.productId]);
|
|
}, [props.productId]);
|
|
|
|
|
|
|
|
- const getItemNode = (record: any) => {
|
|
|
|
|
|
|
+ const getItemNode = (record: any, config: any) => {
|
|
|
const type = record.type;
|
|
const type = record.type;
|
|
|
const name = record.name;
|
|
const name = record.name;
|
|
|
|
|
|
|
@@ -103,16 +99,13 @@ export default (props: FunctionCallProps) => {
|
|
|
);
|
|
);
|
|
|
case 'date':
|
|
case 'date':
|
|
|
return (
|
|
return (
|
|
|
- // <DatePickerFormat
|
|
|
|
|
- // {...config}
|
|
|
|
|
- // value={record.value}
|
|
|
|
|
- // format={record.format || 'YYYY-MM-DD HH:mm:ss'}
|
|
|
|
|
- // style={{ width: '100%' }}
|
|
|
|
|
- // />
|
|
|
|
|
- <TypeTime type={record.type === 'yyyy-MM-dd' ? 'time' : 'date'} value={record.value} />
|
|
|
|
|
|
|
+ <DatePickerFormat
|
|
|
|
|
+ {...config}
|
|
|
|
|
+ value={record.value}
|
|
|
|
|
+ format={record.format || 'YYYY-MM-DD HH:mm:ss'}
|
|
|
|
|
+ style={{ width: '100%' }}
|
|
|
|
|
+ />
|
|
|
);
|
|
);
|
|
|
- case 'object':
|
|
|
|
|
- return <ObjInput value={record.value} />;
|
|
|
|
|
default:
|
|
default:
|
|
|
return <Input value={record.value} placeholder={'请输入' + name} />;
|
|
return <Input value={record.value} placeholder={'请输入' + name} />;
|
|
|
}
|
|
}
|
|
@@ -137,15 +130,11 @@ export default (props: FunctionCallProps) => {
|
|
|
align: 'center',
|
|
align: 'center',
|
|
|
width: 260,
|
|
width: 260,
|
|
|
renderFormItem: (_, row) => {
|
|
renderFormItem: (_, row) => {
|
|
|
- return getItemNode(row.record);
|
|
|
|
|
|
|
+ return getItemNode(row.record, row);
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
- useEffect(() => {
|
|
|
|
|
- console.log(value);
|
|
|
|
|
- }, [value]);
|
|
|
|
|
-
|
|
|
|
|
return (
|
|
return (
|
|
|
<ProForm<{ table: FunctionTableDataType[] }>
|
|
<ProForm<{ table: FunctionTableDataType[] }>
|
|
|
formRef={formRef}
|
|
formRef={formRef}
|
|
@@ -153,7 +142,6 @@ export default (props: FunctionCallProps) => {
|
|
|
submitter={false}
|
|
submitter={false}
|
|
|
onValuesChange={() => {
|
|
onValuesChange={() => {
|
|
|
const values = formRef.current?.getFieldsValue();
|
|
const values = formRef.current?.getFieldsValue();
|
|
|
- console.log('---values---', values);
|
|
|
|
|
if (props.onChange) {
|
|
if (props.onChange) {
|
|
|
props.onChange(
|
|
props.onChange(
|
|
|
values.table.map((item: any) => ({
|
|
values.table.map((item: any) => ({
|
|
@@ -176,19 +164,6 @@ export default (props: FunctionCallProps) => {
|
|
|
onChange: setEditableRowKeys,
|
|
onChange: setEditableRowKeys,
|
|
|
}}
|
|
}}
|
|
|
/>
|
|
/>
|
|
|
- {objVisiable && (
|
|
|
|
|
- <ObjModel
|
|
|
|
|
- value={value}
|
|
|
|
|
- close={() => {
|
|
|
|
|
- setObjVisable(false);
|
|
|
|
|
- }}
|
|
|
|
|
- ok={(param) => {
|
|
|
|
|
- console.log('------', param);
|
|
|
|
|
- setValue(param);
|
|
|
|
|
- setObjVisable(false);
|
|
|
|
|
- }}
|
|
|
|
|
- />
|
|
|
|
|
- )}
|
|
|
|
|
</ProForm>
|
|
</ProForm>
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|