|
|
|
@ -14,8 +14,15 @@ import { Table, Transfer } from 'antd';
|
|
|
|
|
import type { ColumnsType, TableRowSelection } from 'antd/es/table/interface';
|
|
|
|
|
import type { TransferItem, TransferProps } from 'antd/es/transfer';
|
|
|
|
|
import {TransferDirection} from "antd/es/transfer";
|
|
|
|
|
import {postAlgorithmModelGetAlgorithmModelFkSelect} from "@/services/resource/AlgorithmModel";
|
|
|
|
|
import {postDeviceGetDeviceFkSelect, postDeviceGetDeviceList} from "@/services/device/Device";
|
|
|
|
|
import {
|
|
|
|
|
postAlgorithmModelGetAlgorithmModelFkSelect,
|
|
|
|
|
postAlgorithmModelGetAllVersionsById
|
|
|
|
|
} from "@/services/resource/AlgorithmModel";
|
|
|
|
|
import {
|
|
|
|
|
postDeviceGetAllDeviceByGroup,
|
|
|
|
|
postDeviceGetDeviceFkSelect,
|
|
|
|
|
postDeviceGetDeviceList
|
|
|
|
|
} from "@/services/device/Device";
|
|
|
|
|
import {postDeviceGroupGetDeviceGroupTree} from "@/services/device/DeviceGroup";
|
|
|
|
|
import {putRoleUpdateDevicesInGroupModel} from "@/services/device/DeviceModelInGroup";
|
|
|
|
|
import {postProjectCreateProject} from "@/services/project/Project";
|
|
|
|
@ -23,50 +30,41 @@ import {beforeUploadFile} from "@/utils/common";
|
|
|
|
|
import yaml from "js-yaml";
|
|
|
|
|
import {CloseOutlined, SnippetsOutlined} from "@ant-design/icons";
|
|
|
|
|
import {FormListActionType, ProFormDatePicker} from "@ant-design/pro-form/lib";
|
|
|
|
|
import {postModelVersionGetModelVersionById} from "@/services/resource/ModelVersion";
|
|
|
|
|
import {
|
|
|
|
|
postModelVersionGetModelVersionById,
|
|
|
|
|
postModelVersionGetModelVersionFkSelect
|
|
|
|
|
} from "@/services/resource/ModelVersion";
|
|
|
|
|
|
|
|
|
|
import difference from 'lodash/difference';
|
|
|
|
|
import TableTransferList from "@/pages/Setting/components/TableTransfer";
|
|
|
|
|
import {postProjectModelConfigGetProjectModelConfigById} from "@/services/project/ProjectModelConfig";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const formContainerWidth: number = 755;
|
|
|
|
|
const stepFormItemStyleProps: Record<string, any> = {
|
|
|
|
|
width: formContainerWidth,
|
|
|
|
|
};
|
|
|
|
|
interface RecordType {
|
|
|
|
|
key: string;
|
|
|
|
|
title: string;
|
|
|
|
|
description: string;
|
|
|
|
|
disabled: boolean;
|
|
|
|
|
tag: string;
|
|
|
|
|
interface DataType extends API.Device{
|
|
|
|
|
key: string,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface DataType {
|
|
|
|
|
key: string;
|
|
|
|
|
title: string;
|
|
|
|
|
description: string;
|
|
|
|
|
disabled: boolean;
|
|
|
|
|
tag: string;
|
|
|
|
|
interface ProjectModelConfigById {
|
|
|
|
|
configId: number,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface TableTransferProps extends TransferProps<TransferItem> {
|
|
|
|
|
dataSource: DataType[];
|
|
|
|
|
leftColumns: ColumnsType<DataType>;
|
|
|
|
|
rightColumns: ColumnsType<DataType>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type FormValueType = {
|
|
|
|
|
target?: string;
|
|
|
|
|
template?: string;
|
|
|
|
|
type?: string;
|
|
|
|
|
time?: string;
|
|
|
|
|
frequency?: string;
|
|
|
|
|
} & Partial<API.DeviceModelInGroup>;
|
|
|
|
|
|
|
|
|
|
export type UpdateFormProps = {
|
|
|
|
|
updateModalOpen: boolean;
|
|
|
|
|
handleModal: () => void;
|
|
|
|
|
values: Partial<API.DeviceModelInGroup>;
|
|
|
|
|
projectModelConfigId: number;
|
|
|
|
|
groupId: number;
|
|
|
|
|
reload: any;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -120,16 +118,16 @@ const columns = [
|
|
|
|
|
const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|
|
|
|
|
|
|
|
|
const intl = useIntl();
|
|
|
|
|
const [form] = Form.useForm<API.DeviceModelInGroup>();
|
|
|
|
|
|
|
|
|
|
const [modalData, setModalData] = useState<RecordType[]>([]);
|
|
|
|
|
const [targetKeys, setTargetKeys] = useState<string[]>([]);
|
|
|
|
|
const [current, setCurrent] = useState(0);
|
|
|
|
|
|
|
|
|
|
const [configData, setConfigData] = useState([]);
|
|
|
|
|
|
|
|
|
|
const [addrValue, setAddr] = useState('')
|
|
|
|
|
const [projectModelConfig, setProjectModelConfig] = useState<API.ProjectModelConfig>({})
|
|
|
|
|
|
|
|
|
|
const [deviceData, setDeviceData] = useState<DataType[]>([])
|
|
|
|
|
const handleSelectChange = (value)=>{
|
|
|
|
|
postModelVersionGetModelVersionById({ id: value }).then((resp) => {
|
|
|
|
|
let data = resp.data.modelVersion.modelConfig?.params || [];
|
|
|
|
@ -152,46 +150,40 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|
|
|
|
}>
|
|
|
|
|
>();
|
|
|
|
|
const getModelData = () => {
|
|
|
|
|
postDeviceGetDeviceFkSelect({keyword: ''}).then((res)=>{
|
|
|
|
|
let result = (res.data?.list || []).map((v: any)=>{
|
|
|
|
|
return {
|
|
|
|
|
key: v.id,
|
|
|
|
|
title: v.name,
|
|
|
|
|
chosen: false,
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
setModalData(result);
|
|
|
|
|
})
|
|
|
|
|
// postDeviceGetDeviceFkSelect({keyword: ''}).then((res)=>{
|
|
|
|
|
// let result = (res.data?.list || []).map((v: any)=>{
|
|
|
|
|
// return {
|
|
|
|
|
// key: v.id,
|
|
|
|
|
// title: v.name,
|
|
|
|
|
// chosen: false,
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
// setModalData(result);
|
|
|
|
|
// })
|
|
|
|
|
// setMockData(tempMockData);
|
|
|
|
|
// setTargetKeys(tempTargetKeys);
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
setTargetKeys([])
|
|
|
|
|
setConfigData([])
|
|
|
|
|
if (props.updateModalOpen) {
|
|
|
|
|
getModelData();
|
|
|
|
|
|
|
|
|
|
postDeviceGetDeviceList({groupFkId: 2, page: 1, pageSize:10}).then((resp)=>{
|
|
|
|
|
console.log(111, resp)
|
|
|
|
|
// getModelData();
|
|
|
|
|
console.log(props.projectModelConfigId)
|
|
|
|
|
if (props.projectModelConfigId && props.projectModelConfigId !== 0) {
|
|
|
|
|
postProjectModelConfigGetProjectModelConfigById({id: props.projectModelConfigId}).then((resp)=>{
|
|
|
|
|
setProjectModelConfig(resp.data.ProjectModelConfig)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// postDeviceGetDeviceList({groupFkId: 2, page: 1, pageSize:10}).then((resp)=>{
|
|
|
|
|
// // console.log(111, resp)
|
|
|
|
|
// })
|
|
|
|
|
} else {
|
|
|
|
|
}
|
|
|
|
|
}, [props.updateModalOpen])
|
|
|
|
|
const handleChange = (newTargetKeys: string[]) => {
|
|
|
|
|
setTargetKeys(newTargetKeys);
|
|
|
|
|
};
|
|
|
|
|
const handleSearch = (dir: TransferDirection, value: string) => {
|
|
|
|
|
postDeviceGetDeviceFkSelect({keyword: value}).then((res)=>{
|
|
|
|
|
let result = (res.data?.list || []).map((v: any)=>{
|
|
|
|
|
return {
|
|
|
|
|
key: v.id,
|
|
|
|
|
title: v.name,
|
|
|
|
|
chosen: false,
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
setModalData(result);
|
|
|
|
|
})
|
|
|
|
|
};
|
|
|
|
|
return (
|
|
|
|
|
|
|
|
|
|
<StepsForm<{
|
|
|
|
@ -201,7 +193,16 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|
|
|
|
labelPlacement: 'vertical',
|
|
|
|
|
}}
|
|
|
|
|
current={current}
|
|
|
|
|
onCurrentChange={setCurrent}
|
|
|
|
|
onCurrentChange={(value)=>{
|
|
|
|
|
setCurrent(value)
|
|
|
|
|
if (value == 1) {
|
|
|
|
|
postDeviceGetAllDeviceByGroup({id: props.groupId}).then((resp)=>{
|
|
|
|
|
setDeviceData((resp.data?.list || []).map((v: API.Device)=>{
|
|
|
|
|
return {key: v.id, ...v}
|
|
|
|
|
}))
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
onFinish={async () => {
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
@ -229,54 +230,47 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|
|
|
|
);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
|
|
|
|
|
<StepsForm.StepForm<{
|
|
|
|
|
config: string;
|
|
|
|
|
}>
|
|
|
|
|
name="config3"
|
|
|
|
|
title="设备配置"
|
|
|
|
|
stepProps={{
|
|
|
|
|
description: '业务参数配置',
|
|
|
|
|
}}
|
|
|
|
|
onFinish={async (values: any) => {
|
|
|
|
|
console.log(targetKeys)
|
|
|
|
|
return true;
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<>
|
|
|
|
|
<TableTransferList setTargetKeys={setTargetKeys}
|
|
|
|
|
targetKeys={targetKeys}></TableTransferList>
|
|
|
|
|
</>
|
|
|
|
|
|
|
|
|
|
</StepsForm.StepForm>
|
|
|
|
|
{/* 关联算法模型 */}
|
|
|
|
|
<StepsForm.StepForm<{
|
|
|
|
|
config: string;
|
|
|
|
|
}>
|
|
|
|
|
name="config"
|
|
|
|
|
title="模型参数配置"
|
|
|
|
|
stepProps={{
|
|
|
|
|
description: '业务参数配置',
|
|
|
|
|
description: '模型参数配置',
|
|
|
|
|
}}
|
|
|
|
|
onFocus={()=>{
|
|
|
|
|
console.log("进入")
|
|
|
|
|
}}
|
|
|
|
|
onFinish={async (values: any) => {
|
|
|
|
|
return true;
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<>
|
|
|
|
|
{
|
|
|
|
|
projectModelConfig.modelFkId && projectModelConfig.modelFkId !== 0 && (
|
|
|
|
|
<ProFormSelect
|
|
|
|
|
name="addr"
|
|
|
|
|
width="xs"
|
|
|
|
|
label="模型版本"
|
|
|
|
|
onChange={handleSelectChange}
|
|
|
|
|
initialValue={projectModelConfig.modelVersionFkId}
|
|
|
|
|
// dependencies 的内容会注入 request 中
|
|
|
|
|
request={async () => [
|
|
|
|
|
{ label: 'V1.0', value: 22 },
|
|
|
|
|
{ label: 'V1.2', value: 23 },
|
|
|
|
|
]}
|
|
|
|
|
request={async () => {
|
|
|
|
|
let resp =await postAlgorithmModelGetAllVersionsById({id: projectModelConfig.modelFkId})
|
|
|
|
|
return resp.data.list.map((v: any)=>{
|
|
|
|
|
return {
|
|
|
|
|
label: v.name,
|
|
|
|
|
value: v.id
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
configData.length ?
|
|
|
|
|
(
|
|
|
|
|
configData.map((item:any, index)=> {
|
|
|
|
|
console.log(typeof item.default)
|
|
|
|
|
if (typeof item.default === 'number') {
|
|
|
|
|
return (<ProFormDigit
|
|
|
|
|
key={index}
|
|
|
|
@ -304,11 +298,40 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
): (projectModelConfig?.modelConfig || []).map((item, index)=>{
|
|
|
|
|
let value_type = typeof item.value
|
|
|
|
|
if (value_type === 'number') {
|
|
|
|
|
return (<ProFormDigit
|
|
|
|
|
key={index}
|
|
|
|
|
name={item.name}
|
|
|
|
|
label={item.name}
|
|
|
|
|
initialValue={item.value}
|
|
|
|
|
tooltip={item.remark}
|
|
|
|
|
/>)
|
|
|
|
|
} else if (value_type === 'boolean') {
|
|
|
|
|
return (<ProFormSwitch
|
|
|
|
|
key={index}
|
|
|
|
|
name={item.name}
|
|
|
|
|
label={item.name}
|
|
|
|
|
initialValue={item.value}
|
|
|
|
|
tooltip={item.remark}
|
|
|
|
|
/>)
|
|
|
|
|
} else if (value_type === 'string') {
|
|
|
|
|
return (<ProFormText
|
|
|
|
|
key={index}
|
|
|
|
|
name={item.name}
|
|
|
|
|
label={item.name}
|
|
|
|
|
initialValue={item.value}
|
|
|
|
|
tooltip={item.remark}
|
|
|
|
|
/>)
|
|
|
|
|
} else {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
</>
|
|
|
|
|
|
|
|
|
|
</StepsForm.StepForm>
|
|
|
|
|
{/* 业务参数配置 */}
|
|
|
|
|
<StepsForm.StepForm<{
|
|
|
|
|
config: string;
|
|
|
|
|
}>
|
|
|
|
@ -322,38 +345,97 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<>
|
|
|
|
|
|
|
|
|
|
<ProForm.Group>
|
|
|
|
|
{
|
|
|
|
|
configData.map((item:any, index)=> {
|
|
|
|
|
console.log(typeof item.default)
|
|
|
|
|
if (typeof item.default === 'number') {
|
|
|
|
|
(projectModelConfig?.projectConfig || []).map((item, index)=>{
|
|
|
|
|
let value_type = typeof item.value
|
|
|
|
|
if (value_type === 'number') {
|
|
|
|
|
return (<ProFormDigit
|
|
|
|
|
key={index}
|
|
|
|
|
name={item.name}
|
|
|
|
|
label={item.name}
|
|
|
|
|
initialValue={item.default}
|
|
|
|
|
initialValue={item.value}
|
|
|
|
|
tooltip={item.remark}
|
|
|
|
|
/>)
|
|
|
|
|
} else if (typeof item.default === 'boolean') {
|
|
|
|
|
} else if (value_type === 'boolean') {
|
|
|
|
|
return (<ProFormSwitch
|
|
|
|
|
key={index}
|
|
|
|
|
name={item.name}
|
|
|
|
|
label={item.name}
|
|
|
|
|
initialValue={item.default}
|
|
|
|
|
initialValue={item.value}
|
|
|
|
|
tooltip={item.remark}
|
|
|
|
|
/>)
|
|
|
|
|
} else {
|
|
|
|
|
} else if (value_type === 'string') {
|
|
|
|
|
return (<ProFormText
|
|
|
|
|
key={index}
|
|
|
|
|
name={item.name}
|
|
|
|
|
label={item.name}
|
|
|
|
|
initialValue={item.default}
|
|
|
|
|
initialValue={item.value}
|
|
|
|
|
tooltip={item.remark}
|
|
|
|
|
/>)
|
|
|
|
|
} else {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
Object.keys(projectModelConfig?.projectConfig || {}).map((item:any, index)=> {
|
|
|
|
|
let value_type = typeof projectModelConfig.projectConfig[item]
|
|
|
|
|
console.log(value_type, projectModelConfig.projectConfig[item])
|
|
|
|
|
|
|
|
|
|
if (value_type === 'number') {
|
|
|
|
|
return (<ProFormDigit
|
|
|
|
|
key={index}
|
|
|
|
|
name={item}
|
|
|
|
|
label={item}
|
|
|
|
|
initialValue={projectModelConfig.projectConfig[item]}
|
|
|
|
|
/>)
|
|
|
|
|
} else if (value_type === 'boolean') {
|
|
|
|
|
return (<ProFormSwitch
|
|
|
|
|
key={index}
|
|
|
|
|
name={item}
|
|
|
|
|
label={item}
|
|
|
|
|
initialValue={projectModelConfig.projectConfig[item]}
|
|
|
|
|
/>)
|
|
|
|
|
} else if (value_type === 'string') {
|
|
|
|
|
return (<ProFormText
|
|
|
|
|
key={index}
|
|
|
|
|
width='md'
|
|
|
|
|
name={item}
|
|
|
|
|
label={item}
|
|
|
|
|
initialValue={projectModelConfig.projectConfig[item]}
|
|
|
|
|
/>)
|
|
|
|
|
} else {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
</ProForm.Group>
|
|
|
|
|
</>
|
|
|
|
|
|
|
|
|
|
</StepsForm.StepForm>
|
|
|
|
|
{/* 关联算法模型 */}
|
|
|
|
|
|
|
|
|
|
<StepsForm.StepForm<{
|
|
|
|
|
config: string;
|
|
|
|
|
}>
|
|
|
|
|
name="config3"
|
|
|
|
|
title="设备配置"
|
|
|
|
|
stepProps={{
|
|
|
|
|
description: '设备关联配置',
|
|
|
|
|
}}
|
|
|
|
|
onFinish={async (values: any) => {
|
|
|
|
|
console.log(targetKeys)
|
|
|
|
|
return true;
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<>
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
<TableTransferList setTargetKeys={setTargetKeys} dataSource={deviceData}
|
|
|
|
|
targetKeys={targetKeys}></TableTransferList>
|
|
|
|
|
</>
|
|
|
|
|
|
|
|
|
|
</StepsForm.StepForm>
|
|
|
|
|