From 9f5cd5caf1dd4a4e478c119be097a559b2da346f Mon Sep 17 00:00:00 2001 From: donghao Date: Tue, 25 Jun 2024 17:44:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=A8=A1=E5=9E=8B=E9=83=A8=E7=BD=B2?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E6=9B=B4=E6=96=B0=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E8=81=94=E8=B0=83=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/TableActionCard/index.tsx | 5 +- src/locales/zh-CN/model.ts | 10 +- .../BusinessModel/components/createForm.tsx | 17 +- .../BusinessModel/components/updateForm.tsx | 464 ++++++++++++++++++ src/pages/Business/BusinessModel/index.tsx | 44 +- .../components/updateServerForm.tsx | 2 +- .../DeviceGroup/components/baseInfo.tsx | 10 +- .../DeviceGroup/components/createForm.tsx | 4 +- .../components/updateDeviceForm.tsx | 1 - .../DeviceGroup/components/updateForm.tsx | 1 - .../ModelDetail/components/createForm.tsx | 5 +- .../ModelDetail/components/updateForm.tsx | 15 +- src/pages/Model/ModelDetail/index.tsx | 11 +- src/pages/Model/ModelIndex/index.tsx | 119 ++--- src/pages/Model/ModelRuntimeLib/index.tsx | 103 ++-- .../BusinessInfo/components/accountPsw.tsx | 5 +- .../BusinessInfo/components/baseInfo.tsx | 5 +- src/pages/Project/BusinessInfo/index.tsx | 6 +- src/pages/Project/BusinessProject/index.tsx | 6 +- src/services/business/model.ts | 4 +- src/utils/forMath.ts | 12 +- 21 files changed, 672 insertions(+), 177 deletions(-) create mode 100644 src/pages/Business/BusinessModel/components/updateForm.tsx diff --git a/src/components/TableActionCard/index.tsx b/src/components/TableActionCard/index.tsx index 63f7917..c3e6785 100644 --- a/src/components/TableActionCard/index.tsx +++ b/src/components/TableActionCard/index.tsx @@ -2,7 +2,7 @@ * @Author: zhoux zhouxia@supervision.ltd * @Date: 2023-11-14 15:49:36 * @LastEditors: donghao donghao@supervision.ltd - * @LastEditTime: 2024-06-24 14:07:20 + * @LastEditTime: 2024-06-25 14:26:32 * @FilePath: \general-ai-platform-web\src\components\TableActionCard\index.tsx * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ @@ -59,7 +59,6 @@ const TableActionCard: React.FC = (props) => { setMoreActions(startMoreActions); } }, [props.renderActions]); - return (
{prevActions.map((item, index) => { @@ -74,8 +73,10 @@ const TableActionCard: React.FC = (props) => { ); })} {isHasMore ? ( + // TODO 此处有警告需要解决 findDOMNode is deprecated and will be removed in the next major release. Instead, add a ref directly to the element you want to reference e.stopPropagation()} getPopupContainer={(triggerNode) => triggerNode.parentNode} > diff --git a/src/locales/zh-CN/model.ts b/src/locales/zh-CN/model.ts index f00ff1f..bc3ce0d 100644 --- a/src/locales/zh-CN/model.ts +++ b/src/locales/zh-CN/model.ts @@ -2,7 +2,7 @@ * @Author: donghao donghao@supervision.ltd * @Date: 2024-04-10 17:21:34 * @LastEditors: donghao donghao@supervision.ltd - * @LastEditTime: 2024-06-06 15:07:50 + * @LastEditTime: 2024-06-25 14:42:13 * @FilePath: \general-ai-manage\src\locales\zh-CN\model.ts * @Description: 模型管理 */ @@ -64,7 +64,9 @@ export const model_version: { [key: string]: string } = { 'model_detail.version.table.list.remark': '备注', 'model_detail.version.table.list.createTime': '创建时间', 'model_detail.version.table.list.updateTime': '更新时间', - 'model_detail.version.table.list.add': '新建模型版本', + 'model_detail.version.table.list.action.add': '新建模型版本', + 'model_detail.version.table.list.action.edit': '编辑模型版本', + 'model_detail.version.table.list.update': '更新模型版本', 'model_detail.version.stepForm.base': '版本信息', 'model_detail.version.stepForm.base.description': '填写版本基础信息', @@ -87,7 +89,9 @@ export const model_version: { [key: string]: string } = { // 业务模型 export const business_model: { [key: string]: string } = { 'business_model.table.title': '业务模型列表', - 'business_model.table.list.add.name': '创建模型', + 'business_model.table.list.action.add': '创建模型', + 'business_model.table.list.action.edit': '编辑模型', + 'business_model.table.list.name': '业务模型名称', 'business_model.table.list.createTime': '创建时间', 'business_model.stepForm.base': '基本信息', diff --git a/src/pages/Business/BusinessModel/components/createForm.tsx b/src/pages/Business/BusinessModel/components/createForm.tsx index e3da8c4..9e51f47 100644 --- a/src/pages/Business/BusinessModel/components/createForm.tsx +++ b/src/pages/Business/BusinessModel/components/createForm.tsx @@ -97,11 +97,11 @@ const CreateForm: React.FC = (props) => { // test 测试数据 useEffect(() => { // 初始化赋值 - setCurrFormData({ - name: '晶圆检测工艺00', - comment: - '测试一下备注测试一下备注测试一下备注测试一下备注测试一下备注测试一下备注测试一下备注测试一下备注测试一下备注测试一下备注测试一下备注测试一下备注', - }); + // setCurrFormData({ + // name: '晶圆检测工艺00', + // comment: + // '测试一下备注测试一下备注测试一下备注测试一下备注测试一下备注测试一下备注测试一下备注测试一下备注测试一下备注测试一下备注测试一下备注测试一下备注', + // }); }, [props.createModalOpen]); return (
@@ -154,7 +154,7 @@ const CreateForm: React.FC = (props) => { + } width={proFormMaxModelWidth} onCancel={() => { @@ -252,10 +252,13 @@ const CreateForm: React.FC = (props) => { ), }} onFinish={async () => { + if (modelLinkKeys.length === 0) { + message.warning('请至少选择一项内容'); + return false; + } return true; }} > - {/* //TODO 062501 此项校验必填 与UI确定调整尺寸布局 */} void; + commInfo: Record; + values: Record; + reload: any; +}; +const waitTime = (time: number = 100) => { + return new Promise((resolve) => { + setTimeout(() => { + resolve(true); + }, time); + }); +}; + +const UpdateForm: React.FC = (props) => { + const intl = useIntl(); + // state + const [currFormData, setCurrFormData] = useState>({}); + + // 关联模型state + const [modalData, setModalData] = useState([]); + const [modelLinkKeys, setModelLinkKeys] = useState([]); + + // 关联节点state + const [deviceTreeList, setDeviceTreeList] = useState[]>([]); + const [deviceLinkKeys, setDeviceLinkKeys] = useState([]); + + // const [form] = Form.useForm(); + const [current, setCurrent] = useState(0); + const formRef = useRef(); + + // 获取所有模型选项 + const loadModelData = async () => { + const resp = await apiModelListSimple(); + if (isSuccessApi(resp) && resp?.data) { + console.log('apiModelListSimple_resp', resp.data); + let result = (resp.data?.result || []).map((v: any) => { + console.log(v); + return { + key: v.id, + title: v.name, + chosen: false, + disabled: false, + }; + }); + setModalData(result); + } + }; + // 设备节点树 + async function loadDeviceTree() { + const resp = await apiEntityNodes({ entity_id: props.commInfo.id }); + if (isSuccessApi(resp)) { + setDeviceTreeList(resp?.data.data); + } + } + + const handleChange = (newTargetKeys: string[]) => { + console.log(newTargetKeys, 'newTargetKeys'); + setModelLinkKeys(newTargetKeys); + }; + + function resetForm() { + setCurrFormData({}); + formRef.current?.resetFields(); + } + + // 处理其它表单内容 + function setOthersData() { + const { basemodel_list, link_node_list } = props.values; + console.log('mathExtractIds', mathExtractIds(basemodel_list)); + const currModelLinkKeys = mathExtractIds(basemodel_list); + if (isArrayAndNotEmpty(currModelLinkKeys)) { + handleChange(currModelLinkKeys); + } + const currLinkNodeList = mathExtractIds(link_node_list, 'node_id'); + console.log(currLinkNodeList, 'currLinkNodeList'); + if (isArrayAndNotEmpty(currLinkNodeList)) { + setDeviceLinkKeys(currLinkNodeList); + } + } + + useEffect(() => { + setModelLinkKeys([]); + // 初始化赋值 + if (props.updateModalOpen && props.values?.id) { + loadModelData(); + loadDeviceTree(); + setCurrFormData({ + ...props.values, + business_logic: props.values?.business_logic_md5, + business_conf_file: props.values?.business_conf_md5, + }); + setOthersData(); + console.log(props.values, 'useEffect_values', currFormData); + } else { + resetForm(); + } + }, [props.updateModalOpen, props.values]); + return ( +
+ + onFinish={async (values) => { + console.log('All form values:', values, { + ...currFormData, + entity_id: props.commInfo.id, + basemodel_ids: modelLinkKeys, + link_node_ids: deviceLinkKeys, + }); + // 在这里处理提交数据,例如调用API + let resp = await apiModelDeploymentEdit({ + ...values, + id: props.values?.id, + entity_id: props.commInfo.id, + basemodel_ids: isArrayAndNotEmpty(modelLinkKeys) ? modelLinkKeys.join(',') : '', + business_logic: currFormData?.business_logic, + business_conf_file: currFormData?.business_conf_file, + link_node_ids: isArrayAndNotEmpty(deviceLinkKeys) ? deviceLinkKeys.join(',') : '', + }); + if (isSuccessApi(resp)) { + message.success( + intl.formatMessage({ id: 'common.action.success', defaultMessage: '$$$' }), + ); + props.reload(); + props.handleModal(); + } else { + message.error( + resp?.meta?.message || + intl.formatMessage({ id: 'common.action.failure', defaultMessage: '$$$' }), + ); + } + return true; + }} + stepsProps={proFormStepsFormProps.stepsProps} + current={current} + onCurrentChange={setCurrent} + formProps={{ + validateMessages: { + required: `${intl.formatMessage({ + id: 'common.form.required', + defaultMessage: '此项为必填项', + })}`, + }, + }} + stepsFormRender={(dom, submitter) => { + return ( + + } + width={proFormMaxModelWidth} + onCancel={() => { + setCurrent(0); + formRef.current?.resetFields(); + props.handleModal(); + }} + open={props.updateModalOpen} + footer={submitter} + destroyOnClose + > + {dom} + + ); + }} + > + {/* 基本信息 数据创建 */} + + className="gn_form" + name="base" + formRef={formRef} + title={} + stepProps={{ + description: ( + + ), + }} + onFinish={async () => { + // setFormData(formRef.current?.getFieldsValue()); + await waitTime(500); + return true; + }} + > + + } + placeholder={`${intl.formatMessage({ + id: 'common.please_input', + defaultMessage: '$$$', + })}${intl.formatMessage({ + id: 'business_model.form.modelFkId', + defaultMessage: '$$$', + })}`} + required={true} + initialValue={currFormData?.name} + rules={[ + { + required: true, + message: ( + + ), + }, + ]} + /> + } + placeholder={`${intl.formatMessage({ + id: 'common.please_input', + defaultMessage: '$$$', + })}${intl.formatMessage({ + id: 'business_model.form.remark', + defaultMessage: '$$$', + })}`} + initialValue={currFormData?.comment} + required={false} + /> + + + {/* 关联算法模型 */} + + name="baseModel" + title={ + + } + stepProps={{ + description: ( + + ), + }} + onFinish={async () => { + if (modelLinkKeys.length === 0) { + message.warning('请至少选择一项内容'); + return false; + } + return true; + }} + > + item.title} + /> + + {/* 业务代码 */} + + className="gn_form" + name="project_file" + title={ + + } + style={{ width: proFormMaxItemStyleProps.width }} + stepProps={{ + description: ( + + ), + }} + > + + 上传业务代码 +
(请上传格式为zip.tar.gz的模型文件)
+
+ ), + title: ( +
+ 拖拽文件到这里,或 + 点此添加 +
+ ), + description: '', + icon: , + name: 'business_logic_arr', + max: 1, + initialValue: currFormData?.business_logic_md5 + ? [ + { + uid: currFormData?.business_logic_md5, + name: currFormData?.business_logic_name || currFormData?.business_logic_md5, + status: 'done', + url: '/file/' + currFormData?.business_logic_md5, + }, + ] + : [], + }} + afterUploadFile={({ resp }) => { + setCurrFormData((data) => { + return { ...data, business_logic: resp?.data?.result }; + }); + }} + afterRemoveFile={() => { + setCurrFormData((data) => { + return { ...data, business_logic: '' }; + }); + }} + openPreviewFile={true} + /> + + {/* 参数配置 */} + + className="gn_form" + name="config" + title={} + stepProps={{ + description: ( + + ), + }} + onFinish={async (values: any) => { + console.log(values, 'config_values'); + return true; + }} + > + + 上传配置文件 +
(请上传格式为.json.yaml.yml的模型文件)
+
+ ), + title: ( +
+ 拖拽文件到这里,或 + 点此添加 +
+ ), + description: '', + icon: , + name: 'business_conf_file_arr', + max: 1, + initialValue: currFormData?.business_conf_md5 + ? [ + { + uid: currFormData?.business_conf_md5, + name: currFormData?.business_conf_name || currFormData?.business_conf_md5, + status: 'done', + url: '/file/' + currFormData?.business_conf_md5, + }, + ] + : [], + }} + afterUploadFile={({ resp }) => { + setCurrFormData((data) => { + return { ...data, business_conf_file: resp?.data?.result }; + }); + }} + afterRemoveFile={() => { + setCurrFormData((data) => { + return { ...data, business_conf_file: '' }; + }); + }} + openPreviewFile={true} + /> + + {/* 关联节点 */} + + name="group" + title={} + stepProps={{ + description: ( + + ), + }} + onFinish={async () => { + return true; + }} + style={{ width: proFormMaxItemStyleProps.width }} + > +
{'节点信息'}
+ { + // form.setFieldsValue({menuIds: checkedKeys}) + console.log(checkedKeys, 'checkedKeys'); + setDeviceLinkKeys(checkedKeys); + // formRef3.current?.setFieldValue('groupIds', checkedKeys) + }} + treeData={deviceTreeList} + /> + + +
+ ); +}; +export default UpdateForm; diff --git a/src/pages/Business/BusinessModel/index.tsx b/src/pages/Business/BusinessModel/index.tsx index 367f7da..238ff85 100644 --- a/src/pages/Business/BusinessModel/index.tsx +++ b/src/pages/Business/BusinessModel/index.tsx @@ -2,7 +2,7 @@ * @Author: donghao donghao@supervision.ltd * @Date: 2024-04-22 15:23:36 * @LastEditors: donghao donghao@supervision.ltd - * @LastEditTime: 2024-06-25 10:00:13 + * @LastEditTime: 2024-06-25 15:10:47 * @FilePath: \general-ai-platform-web\src\pages\Node\BusinessModel\index.tsx * @Description: 业务模型 * @交互说明 @@ -28,6 +28,8 @@ import { Button, message } from 'antd'; import { useRef, useState } from 'react'; import { proTablePaginationOptions } from '../../../../config/defaultTable'; import CreateForm from './components/createForm'; +import UpdateForm from './components/updateForm'; + import DetailCard from './components/detailCard'; const BusinessModel: React.FC = () => { const intl = useIntl(); @@ -37,7 +39,7 @@ const BusinessModel: React.FC = () => { const [commInfo] = useState>({ ...getStoreBusinessInfo() }); // 通用信息 const [createModalOpen, setCreateModalOpen] = useState(false); - // const [updateModalOpen, setUpdateModalOpen] = useState(false); + const [updateModalOpen, setUpdateModalOpen] = useState(false); const [detailModalOpen, setDetailModalOpen] = useState(false); // 编辑窗口是否打开 const [currentRow, setCurrentRow] = useState>({}); @@ -51,19 +53,22 @@ const BusinessModel: React.FC = () => { setCreateModalOpen(!createModalOpen); }; // 编辑 - // const handleUpdateModal = () => { - // setUpdateModalOpen(!updateModalOpen); - // }; + const handleUpdateModal = () => { + setUpdateModalOpen(!updateModalOpen); + }; // 详情 const handleDetailModal = () => { setDetailModalOpen(!detailModalOpen); }; // 设备节点信息 - async function loadDetail(record) { + async function loadDetail(record, isOpenDetail = false) { const resp = await apiModelDeploymentInfo({ id: record?.model_id }); if (isSuccessApi(resp) && resp?.data) { setCurrentRow({ ...resp?.data, id: record?.model_id }); + if (isOpenDetail) { + setUpdateModalOpen(true); + } } } @@ -117,7 +122,21 @@ const BusinessModel: React.FC = () => { ), }, - // TODO 062502 编辑接口在新建交互完善后对接 + { + key: 'update', + renderDom: ( + + ), + }, { key: 'destroy', renderDom: ( @@ -167,7 +186,7 @@ const BusinessModel: React.FC = () => { setCreateModalOpen(true); }} > - + } > @@ -189,7 +208,7 @@ const BusinessModel: React.FC = () => { search={false} options={{ fullScreen: false, setting: false, density: false, reload: false }} actionRef={actionRef} - rowKey="id" + rowKey="model_id" onDataSourceChange={(data) => { console.log(data, 'onDataSourceChange_data'); // let CategoryFkIdIds: any = data.map((v) => { @@ -235,6 +254,13 @@ const BusinessModel: React.FC = () => { commInfo={commInfo} reload={reloadList} /> + = (props) => { defaultMessage: '$$$', })}`} /> - {/* // TODO 密码默认渲染*** */} + {/* 密码默认渲染*** */} } diff --git a/src/pages/Business/DeviceGroup/components/baseInfo.tsx b/src/pages/Business/DeviceGroup/components/baseInfo.tsx index 673d4c2..5226279 100644 --- a/src/pages/Business/DeviceGroup/components/baseInfo.tsx +++ b/src/pages/Business/DeviceGroup/components/baseInfo.tsx @@ -2,7 +2,7 @@ * @Author: donghao donghao@supervision.ltd * @Date: 2024-04-23 17:00:00 * @LastEditors: donghao donghao@supervision.ltd - * @LastEditTime: 2024-05-28 16:45:52 + * @LastEditTime: 2024-06-25 14:08:27 * @FilePath: \general-ai-platform-web\src\pages\Business\DeviceGroup\components\baseInfo.tsx * @Description: 基本信息展示 * @@ -25,14 +25,6 @@ const BaseInfo: React.FC = ({ info }) => { { title: , dataIndex: 'parent_name', - // TODO 需要接口返回上级节点的名称 - // render: (_, record) => { - // if(record?.lon && record?.lat){ - // return record?.lon + ',' + record?.lat; - - // } - // return '-' - // }, }, { title: , diff --git a/src/pages/Business/DeviceGroup/components/createForm.tsx b/src/pages/Business/DeviceGroup/components/createForm.tsx index 9502c61..a05a3a0 100644 --- a/src/pages/Business/DeviceGroup/components/createForm.tsx +++ b/src/pages/Business/DeviceGroup/components/createForm.tsx @@ -4,8 +4,7 @@ import { ModalForm, ProForm, ProFormText, ProFormTextArea } from '@ant-design/pr import { FormattedMessage, useIntl } from '@umijs/max'; import { Form, message } from 'antd'; -import React from // , {useEffect} -'react'; +import React from 'react'; // , {useEffect} import { proFormSmallItemStyleProps, proFormSmallModelWidth, @@ -109,7 +108,6 @@ const CreateForm: React.FC = (props) => { label={ } - // TODO 此处在联调时确定下上级节点数据获取来源 placeholder={ !props.parentInfo?.name ? `${intl.formatMessage({ diff --git a/src/pages/Business/DeviceGroup/components/updateDeviceForm.tsx b/src/pages/Business/DeviceGroup/components/updateDeviceForm.tsx index 14fb993..4781b13 100644 --- a/src/pages/Business/DeviceGroup/components/updateDeviceForm.tsx +++ b/src/pages/Business/DeviceGroup/components/updateDeviceForm.tsx @@ -72,7 +72,6 @@ const UpdateDeviceForm: React.FC = (props) => { submitTimeout={2000} onFinish={async (values) => { console.log(values, 'add_finish_values'); - // TODO 对接新增接口 let resp = await apiEntityNodesDeviceEdit({ ...values, device_id: props.values.device_id, diff --git a/src/pages/Business/DeviceGroup/components/updateForm.tsx b/src/pages/Business/DeviceGroup/components/updateForm.tsx index 6480189..5d29a20 100644 --- a/src/pages/Business/DeviceGroup/components/updateForm.tsx +++ b/src/pages/Business/DeviceGroup/components/updateForm.tsx @@ -112,7 +112,6 @@ const UpdateForm: React.FC = (props) => { label={ } - // TODO 此处在联调时确定下上级节点数据获取来源 placeholder={ !props.values?.parent_name ? `${intl.formatMessage({ diff --git a/src/pages/Model/ModelDetail/components/createForm.tsx b/src/pages/Model/ModelDetail/components/createForm.tsx index eb70a77..3e1de60 100644 --- a/src/pages/Model/ModelDetail/components/createForm.tsx +++ b/src/pages/Model/ModelDetail/components/createForm.tsx @@ -98,7 +98,10 @@ const CreateForm: React.FC = (props) => { + } width={proFormSmallModelWidth} onCancel={() => { diff --git a/src/pages/Model/ModelDetail/components/updateForm.tsx b/src/pages/Model/ModelDetail/components/updateForm.tsx index 345a037..1cf78e7 100644 --- a/src/pages/Model/ModelDetail/components/updateForm.tsx +++ b/src/pages/Model/ModelDetail/components/updateForm.tsx @@ -54,10 +54,8 @@ const UpdateForm: React.FC = (props) => { function resetForm() { setCurrFormData({}); } - // test 测试数据 useEffect(() => { // 初始化赋值 - if (props.updateModalOpen && props.values?.version_id) { setCurrFormData({ ...props.values, @@ -69,13 +67,6 @@ const UpdateForm: React.FC = (props) => { } }, [props.updateModalOpen, props.values]); - // useEffect(() => { - // if (formProjectFileRef) { - // formProjectFileRef.current?.setFieldValue('model_file_arr', [ - - // ]); - // } - // }, [props.updateModalOpen, props.values, formProjectFileRef]); return ( = (props) => { + } width={proFormSmallModelWidth} onCancel={() => { @@ -426,7 +420,6 @@ const UpdateForm: React.FC = (props) => { 请上传格式为.json.yaml.yml的模型文件 */} - {/* // TODO label字重与上面统一, 操作按钮需要与输入框对齐 */} {/* { title: , dataIndex: 'name', }, - // TODO 缺失默认版本信息字段 { title: ( ), - dataIndex: 'version', + dataIndex: 'default_version', + render: (dom, record) => ( +
+ {record?.default_version ? V : <>} + {dom || '-'} +
+ ), }, { title: , diff --git a/src/pages/Model/ModelIndex/index.tsx b/src/pages/Model/ModelIndex/index.tsx index 95031d3..a2919c9 100644 --- a/src/pages/Model/ModelIndex/index.tsx +++ b/src/pages/Model/ModelIndex/index.tsx @@ -2,7 +2,7 @@ * @Author: donghao donghao@supervision.ltd * @Date: 2024-04-07 14:02:00 * @LastEditors: donghao donghao@supervision.ltd - * @LastEditTime: 2024-06-14 14:08:11 + * @LastEditTime: 2024-06-25 14:31:24 * @FilePath: \general-ai-manage\src\pages\ModelIndex\ModelIndex.tsx * @Description: 模型列表首页 * @交互说明 @@ -122,6 +122,12 @@ const ModelIndex: React.FC = () => { ), dataIndex: 'default_version', hideInSearch: true, + render: (dom, record) => ( +
+ {record?.default_version ? V : <>} + {dom} +
+ ), }, { @@ -295,62 +301,63 @@ const ModelIndex: React.FC = () => { } > - {/* // TODO 需要控制表格溢出滚动高度 */} - { - console.log(data, 'onDataSourceChange_data'); - // let CategoryFkIdIds: any = data.map((v) => { - // return v.categoryFkId; - // }); - // setCategoryFkIdIds(CategoryFkIdIds); - }} - pagination={{ - ...proTablePaginationOptions, - pageSize: currentPageSize, - onChange: (pageNo, pageSize) => setCurrentPageSize(pageSize), - }} - columnsState={{ - persistenceKey: 'algorithm_model_list', - persistenceType: 'localStorage', - }} - request={async (params = {}, sort) => { - const { current, ...rest } = params; - const reqParams = { - pageNo: current, - desc: false, - orderKey: '', - ...rest, - }; - if (sort && Object.keys(sort).length) { - reqParams.orderKey = Object.keys(sort)[0]; - let sort_select = sort[reqParams.orderKey]; - reqParams.desc = sort_select === 'descend'; - } - let resp = await apiModelList({ ...reqParams, ...querysData }); - if (!isSuccessApi(resp)) { - return { data: [], success: true }; - } - return { - data: resp.data.data, - success: resp.success, - total: resp.data.count, - current: current, +
+ { + console.log(data, 'onDataSourceChange_data'); + // let CategoryFkIdIds: any = data.map((v) => { + // return v.categoryFkId; + // }); + // setCategoryFkIdIds(CategoryFkIdIds); + }} + pagination={{ + ...proTablePaginationOptions, pageSize: currentPageSize, - }; - }} - columns={columns} - /> + onChange: (pageNo, pageSize) => setCurrentPageSize(pageSize), + }} + columnsState={{ + persistenceKey: 'algorithm_model_list', + persistenceType: 'localStorage', + }} + request={async (params = {}, sort) => { + const { current, ...rest } = params; + const reqParams = { + pageNo: current, + desc: false, + orderKey: '', + ...rest, + }; + if (sort && Object.keys(sort).length) { + reqParams.orderKey = Object.keys(sort)[0]; + let sort_select = sort[reqParams.orderKey]; + reqParams.desc = sort_select === 'descend'; + } + let resp = await apiModelList({ ...reqParams, ...querysData }); + if (!isSuccessApi(resp)) { + return { data: [], success: true }; + } + return { + data: resp.data.data, + success: resp.success, + total: resp.data.count, + current: current, + pageSize: currentPageSize, + }; + }} + columns={columns} + /> +
{ } > - {/* // TODO 需要控制表格溢出滚动高度 */} - { - console.log(data, 'onDataSourceChange_data'); - // let CategoryFkIdIds: any = data.map((v) => { - // return v.categoryFkId; - // }); - // setCategoryFkIdIds(CategoryFkIdIds); - }} - pagination={{ - ...proTablePaginationOptions, - pageSize: currentPageSize, - onChange: (pageNo, pageSize) => setCurrentPageSize(pageSize), - }} - columnsState={{ - persistenceKey: 'algorithm_model_list', - persistenceType: 'localStorage', - }} - request={async (params = {}) => { - const { current, ...rest } = params; - const reqParams = { - pageNo: current, - - ...rest, - }; - let resp = await apiModelHubList({ ...reqParams, ...querysData }); - if (!isSuccessApi(resp)) { - return { data: [], success: true }; - } - console.log(resp, 'apiEntityNodesDeviceList_resp'); - return { - data: resp.data?.data, - success: resp.success, - total: resp.data.count, - current: current, +
+ { + console.log(data, 'onDataSourceChange_data'); + // let CategoryFkIdIds: any = data.map((v) => { + // return v.categoryFkId; + // }); + // setCategoryFkIdIds(CategoryFkIdIds); + }} + pagination={{ + ...proTablePaginationOptions, pageSize: currentPageSize, - }; - }} - columns={columns} - /> + onChange: (pageNo, pageSize) => setCurrentPageSize(pageSize), + }} + columnsState={{ + persistenceKey: 'algorithm_model_list', + persistenceType: 'localStorage', + }} + request={async (params = {}) => { + const { current, ...rest } = params; + const reqParams = { + pageNo: current, + + ...rest, + }; + let resp = await apiModelHubList({ ...reqParams, ...querysData }); + if (!isSuccessApi(resp)) { + return { data: [], success: true }; + } + console.log(resp, 'apiEntityNodesDeviceList_resp'); + return { + data: resp.data?.data, + success: resp.success, + total: resp.data.count, + current: current, + pageSize: currentPageSize, + }; + }} + columns={columns} + /> +
; }; -// TODO 企业账号未获取到 const AccountPsw: React.FC = (props) => { const [form] = ProForm.useForm(); // form 对象 const intl = useIntl(); @@ -44,7 +43,7 @@ const AccountPsw: React.FC = (props) => { } diff --git a/src/pages/Project/BusinessInfo/components/baseInfo.tsx b/src/pages/Project/BusinessInfo/components/baseInfo.tsx index 1078519..9e30bf9 100644 --- a/src/pages/Project/BusinessInfo/components/baseInfo.tsx +++ b/src/pages/Project/BusinessInfo/components/baseInfo.tsx @@ -2,7 +2,7 @@ * @Author: donghao donghao@supervision.ltd * @Date: 2024-04-23 17:00:00 * @LastEditors: donghao donghao@supervision.ltd - * @LastEditTime: 2024-05-27 13:33:14 + * @LastEditTime: 2024-06-25 14:03:51 * @FilePath: \general-ai-platform-web\src\pages\Project\BusinessInfo\components\baseInfo.tsx * @Description: 基本信息展示 * @@ -14,7 +14,6 @@ import { FormattedMessage } from '@umijs/max'; type BaseInfoProps = { info: Record; }; -// TODO 行业信息、服务有效期未从接口获取到 const BaseInfo: React.FC = ({ info }) => { // 模型基本信息 const ModelDetailColumns = [ @@ -39,7 +38,7 @@ const BaseInfo: React.FC = ({ info }) => { defaultMessage="服务有效期" /> ), - dataIndex: 'validity_period', + dataIndex: 'expire_at', }, { title: , diff --git a/src/pages/Project/BusinessInfo/index.tsx b/src/pages/Project/BusinessInfo/index.tsx index 546c962..ccdd641 100644 --- a/src/pages/Project/BusinessInfo/index.tsx +++ b/src/pages/Project/BusinessInfo/index.tsx @@ -15,7 +15,6 @@ import { getBusinessAlgorithmList } from '@/services/testApi/businessProject'; import { isSuccessApi } from '@/utils/forApi'; import { ProCard, ProList } from '@ant-design/pro-components'; import { Button } from 'antd'; -import businessLogoIcon from '/public/home/business_logo.svg'; import React, { useEffect, useState } from 'react'; import { proTablePaginationOptions } from '../../../../config/defaultTable'; @@ -125,8 +124,7 @@ const BusinessInfo: React.FC = () => { >
- {/* // TODO 替换使用公司的logo字段 */} - +
{detailInfo?.name}
@@ -141,7 +139,7 @@ const BusinessInfo: React.FC = () => {
账号信息}> - +
diff --git a/src/pages/Project/BusinessProject/index.tsx b/src/pages/Project/BusinessProject/index.tsx index 7bb26dc..a9910fe 100644 --- a/src/pages/Project/BusinessProject/index.tsx +++ b/src/pages/Project/BusinessProject/index.tsx @@ -2,7 +2,7 @@ * @Author: donghao donghao@supervision.ltd * @Date: 2024-04-07 14:02:00 * @LastEditors: donghao donghao@supervision.ltd - * @LastEditTime: 2024-06-24 14:36:52 + * @LastEditTime: 2024-06-25 14:26:08 * @FilePath: \general-ai-manage\src\pages\BusinessProject\BusinessProject.tsx * @Description: 企业项目首页 * @交互说明 @@ -11,7 +11,7 @@ * 3. 新增、编辑、删除(企业)功能 * # 省市二级联动,使用city数据源 * # 企业logo添加需要上传base64编码(小图标适用) - * // TODO 本页有警告需要解决 + * */ import { CommButton, TextButton } from '@/components/Button'; import { isSuccessApi } from '@/utils/forApi'; @@ -130,7 +130,7 @@ const BusinessProject: React.FC = () => { info={item} renderActions={[ { - key: 'update', + key: 'updateDetail', renderDom: (
( `/api/v1/enterprise/model/deployment/delete`, diff --git a/src/utils/forMath.ts b/src/utils/forMath.ts index c58264a..855ca9f 100644 --- a/src/utils/forMath.ts +++ b/src/utils/forMath.ts @@ -2,7 +2,7 @@ * @Author: donghao donghao@supervision.ltd * @Date: 2024-06-18 13:36:03 * @LastEditors: donghao donghao@supervision.ltd - * @LastEditTime: 2024-06-20 16:22:01 + * @LastEditTime: 2024-06-25 14:54:04 * @FilePath: \general-ai-platform-web\src\utils\math.ts * @Description: 数学方法库 */ @@ -50,7 +50,11 @@ export function mathConvertJoinArrayToString(inputArr: string[]): string { * @param objectsArray - The array of objects, each containing an 'id' property. * @returns An array of 'id' values, or an empty array if input is invalid. */ -export function mathExtractIds(objectsArray: any): (number | string)[] { +export function mathExtractIds(objectsArray: any, formatKey?: string): (number | string)[] { + if (!formatKey) { + // eslint-disable-next-line no-param-reassign + formatKey = 'id'; + } // Check if the input is an array if (!Array.isArray(objectsArray)) { console.error('Input is not an array'); @@ -59,12 +63,12 @@ export function mathExtractIds(objectsArray: any): (number | string)[] { // Check if every item in the array is an object and has an 'id' property for (const obj of objectsArray) { - if (typeof obj !== 'object' || obj === null || !('id' in obj)) { + if (typeof obj !== 'object' || obj === null || !(formatKey in obj)) { console.error("Invalid object in array or missing 'id' property"); return []; } } // Map the array to extract 'id' properties - return objectsArray.map((obj) => obj.id); + return objectsArray.map((obj) => obj[formatKey]); }