From 3e821d288845b9f416777cabf128e43dc2fea8be Mon Sep 17 00:00:00 2001 From: chunquansang <916920620@è¯@qq.com> Date: Mon, 22 Jan 2024 09:45:29 +0800 Subject: [PATCH] =?UTF-8?q?feat=C3=AF:=20mock=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectList/components/MyCreateForm.tsx | 6 +- .../AlgorithmModelList/components/Columns.tsx | 9 +- .../Resource/AlgorithmModelList/detail.tsx | 71 +-- .../ModelImageList/components/CreateForm.tsx | 172 ++++--- .../components/MyCreateForm.tsx | 153 +++--- src/pages/Setting/AlgorithmSetting.tsx | 439 +++++++++--------- src/pages/Setting/components/UpdateForm.tsx | 56 ++- .../System/OperationRecordList/index.tsx | 2 +- src/pages/Welcome/components/FootInfoCard.tsx | 24 +- .../Welcome/components/NavInfoCardList.tsx | 12 +- src/services/project/typings.d.ts | 1 + 11 files changed, 525 insertions(+), 420 deletions(-) diff --git a/src/pages/Project/ProjectList/components/MyCreateForm.tsx b/src/pages/Project/ProjectList/components/MyCreateForm.tsx index 9b55734..32a2ee8 100644 --- a/src/pages/Project/ProjectList/components/MyCreateForm.tsx +++ b/src/pages/Project/ProjectList/components/MyCreateForm.tsx @@ -100,13 +100,17 @@ const MyCreateForm: React.FC = (props) => { setFileList([...curFile]); }; + // todo disabled: !v?.defaultVersionFkId,设置 暂时设置为false 创建成功后报error const getModelData = () => { postAlgorithmModelGetAlgorithmModelFkSelect({ keyword: '' }).then((res) => { + console.log(66666, res.data) let result = (res.data?.list || []).map((v: any) => { + console.log(v) return { key: v.id, title: v.name, chosen: false, + disabled: false, }; }); setModalData(result); @@ -341,7 +345,7 @@ const MyCreateForm: React.FC = (props) => { name="model" title="关联算法模型" stepProps={{ - description: '选择算法模型', + description: '请先为模型设置默认版本', }} onFinish={async () => { return true; diff --git a/src/pages/Resource/AlgorithmModelList/components/Columns.tsx b/src/pages/Resource/AlgorithmModelList/components/Columns.tsx index 98515a5..5d2a3d9 100644 --- a/src/pages/Resource/AlgorithmModelList/components/Columns.tsx +++ b/src/pages/Resource/AlgorithmModelList/components/Columns.tsx @@ -13,7 +13,7 @@ export const AlgorithmModelColumns = [{ title: (), - dataIndex: "category_fk_id", + dataIndex: "categoryFkId", },{ title: (), - dataIndex: "create_time", + dataIndex: "createTime", + valueType: 'dateTime', },{ title: (), - dataIndex: "update_time", + dataIndex: "updateTime", + valueType: 'dateTime', },] + diff --git a/src/pages/Resource/AlgorithmModelList/detail.tsx b/src/pages/Resource/AlgorithmModelList/detail.tsx index c4d5801..0f5b349 100644 --- a/src/pages/Resource/AlgorithmModelList/detail.tsx +++ b/src/pages/Resource/AlgorithmModelList/detail.tsx @@ -1,4 +1,7 @@ -import { postAlgorithmModelGetAlgorithmModelById } from '@/services/resource/AlgorithmModel'; +import { + postAlgorithmModelGetAlgorithmModelById, + putAlgorithmModelUpdateAlgorithmModel +} from '@/services/resource/AlgorithmModel'; import { deleteModelVersionDeleteModelVersion, postModelVersionGetModelVersionList } from '@/services/resource/ModelVersion'; import { ArrowLeftOutlined, PlusOutlined } from '@ant-design/icons'; import { @@ -17,7 +20,9 @@ import MyCreateForm from '../ModelVersionList/components/MyCreateForm'; import TableActionCard from '@/components/TableActionCard'; import IsDelete from '@/components/TableActionCard/isDelete'; import UpdateForm from '../ModelVersionList/components/UpdateForm'; - +import {proTableCommonOptions} from "../../../../config/defaultTable"; +import {AlgorithmModelColumns} from "./components/Columns" +import IsConfirmAction from "@/components/TableActionCard/isConfirmAction"; /**styles */ const detailStylesProps = { @@ -66,35 +71,20 @@ const AlgorithmModelDetail: React.FC = () => { dataIndex: 'id', sorter: true, }, - - { - title: ( - - ), - dataIndex: 'modelFkId', - hideInSearch: false, - }, - + + { title: , dataIndex: 'version', hideInSearch: true, }, - + { title: , dataIndex: 'path', hideInSearch: true, }, - - { - title: ( - - ), - dataIndex: 'startCode', - hideInSearch: true, - }, - + { title: ( @@ -105,7 +95,7 @@ const AlgorithmModelDetail: React.FC = () => { hideInSearch: true, valueType: 'switch', }, - + { title: , dataIndex: 'remark', @@ -123,7 +113,7 @@ const AlgorithmModelDetail: React.FC = () => { 5: { text: '已关闭', status: 'Error' }, }, }, - + { title: ( @@ -133,7 +123,7 @@ const AlgorithmModelDetail: React.FC = () => { hideInSearch: true, valueType: 'dateTime', }, - + { title: ( @@ -152,6 +142,32 @@ const AlgorithmModelDetail: React.FC = () => { { + // setPublishModalOpen(true); + putAlgorithmModelUpdateAlgorithmModel({ + id: record.modelFkId, + defaultVersionFkId: record.id, + }) + .then(() => { + message.success( + intl.formatMessage({ id: 'common.success', defaultMessage: '$$$' }), + ); + }) + .catch(() => { + message.error( + intl.formatMessage({ id: 'common.failure', defaultMessage: '$$$' }), + ); + }); + }} + > + ), + }, { key: 'update', renderDom: ( @@ -243,7 +259,7 @@ const AlgorithmModelDetail: React.FC = () => { column={4} title="模型详细信息" tooltip="包含了模型详细信息" - columns={columns} + columns={AlgorithmModelColumns} request={async () => { console.log(routeParams, 'id'); const resp = await postAlgorithmModelGetAlgorithmModelById({ @@ -284,9 +300,12 @@ const AlgorithmModelDetail: React.FC = () => { actionRef={actionRef} tableStyle={{ paddingTop: 15, paddingBottom: 15 }} columns={columns} + scroll={{ + x: proTableCommonOptions.scrollX, + }} cardBordered toolBarRender={() => [ - + ]} request={async (params = {}, sort) => { const { current, ...rest } = params; diff --git a/src/pages/Resource/ModelImageList/components/CreateForm.tsx b/src/pages/Resource/ModelImageList/components/CreateForm.tsx index af40af0..bc64969 100644 --- a/src/pages/Resource/ModelImageList/components/CreateForm.tsx +++ b/src/pages/Resource/ModelImageList/components/CreateForm.tsx @@ -4,6 +4,7 @@ import { ModalForm, ProForm, ProFormDependency, + ProFormTextArea, ProFormSelect, ProFormText, } from '@ant-design/pro-components'; @@ -53,12 +54,12 @@ const CreateForm: React.FC = (props) => { return false; } - if (!isValidIPv4(form.getFieldValue('IP'))) { + if (!isValidIPv4(form.getFieldValue('ip'))) { message.warning('无效的服务器地址'); return; } - if (!isValidPort(form.getFieldValue('IPPort'))) { + if (!isValidPort(form.getFieldValue('ipPort'))) { message.warning('无效的端口'); return; } @@ -66,7 +67,7 @@ const CreateForm: React.FC = (props) => { setIsFlag(true); } - const handleResponse = (data) => { + const handleResponse = (data: any) => { console.log(data, 'handleResponse'); // 对返回的数据进行处理 }; @@ -74,15 +75,16 @@ const CreateForm: React.FC = (props) => { async function postCurrentIP() { // http://192.168.10.96:5003/v2/_catalog const resp = await axios.get( - `http://${form.getFieldValue('IP')}:${form.getFieldValue('IPPort')}/v2/_catalog`, + `http://${form.getFieldValue('ip')}:${form.getFieldValue('ipPort')}/v2/_catalog`, ); console.log(resp, 'resp'); return resp?.data; } - async function doChangeUseIPPort() { + async function doChangeUseipPort() { + form.setFieldValue('imageVersion', null) const resp = await axios.get( - `http://${form.getFieldValue('IP')}:${form.getFieldValue('IPPort')}/v2/${form.getFieldValue('useIPPort')}/tags/list`, + `http://${form.getFieldValue('ip')}:${form.getFieldValue('ipPort')}/v2/${form.getFieldValue('imageName')}/tags/list`, ); let finalData = resp?.data?.tags?.map((v: any) => { return { @@ -108,7 +110,7 @@ const CreateForm: React.FC = (props) => { } return ( - + width={proFormModelWidth} title={intl.formatMessage({ id: 'resource.model_image.table.list.add', @@ -123,6 +125,9 @@ const CreateForm: React.FC = (props) => { }} submitTimeout={2000} onFinish={async (values) => { + console.log(4444, values) + // let imageId = `${values.ip}:${values.ipPort}/${values.imageName}:${values.imageVersion}` + // console.log(5555, imageId) postModelImageCreateModelImage(values) .then(() => { message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '$$$' })); @@ -162,40 +167,10 @@ const CreateForm: React.FC = (props) => { }, ]} /> - - } - placeholder={`${intl.formatMessage({ - id: 'common.please_select', - defaultMessage: '$$$', - })}${intl.formatMessage({ - id: 'resource.model_image.table.list.modelVersionFkId', - defaultMessage: '$$$', - })}`} - required={true} - showSearch - debounceTime={1000} - request={async (keyWord) => { - const resp = await postModelVersionGetModelVersionFkSelect({ - keyword: keyWord?.keyWords || '', - }); - return resp.data.list.map((v: any) => { - return { - label: v.name, - value: v.id, - }; - }); - }} - /> } @@ -206,40 +181,22 @@ const CreateForm: React.FC = (props) => { id: 'resource.model_image.table.list.path', defaultMessage: '$$$', })}`} - required={false} - /> - - } - placeholder={`${intl.formatMessage({ - id: 'common.please_input', - defaultMessage: '$$$', - })}${intl.formatMessage({ - id: 'resource.model_image.table.list.startCode', - defaultMessage: '$$$', - })}`} - required={false} - /> - - } - placeholder={`${intl.formatMessage({ - id: 'common.please_input', - defaultMessage: '$$$', - })}${intl.formatMessage({ - id: 'resource.model_image.table.list.remark', - defaultMessage: '$$$', - })}`} - required={false} + required={true} + disabled={true} + rules={[ + { + required: true, + message: ( + + ), + }, + ]} /> - {/* + {/* // TODO update联动查询 */} @@ -252,22 +209,24 @@ const CreateForm: React.FC = (props) => { { - setIsFlag(false); - }} + fieldProps={{onChange: () => { + setIsFlag(false)} + }} /> { - setIsFlag(false); + fieldProps={{onChange: () => { + setIsFlag(false)} }} /> - - - +
+ +
+ + + + ), })); setModelData(model_data); @@ -184,34 +184,34 @@ const AlgorithmSetting: React.FC = () => { subTitle: 经典算法, avatar: 'https://gw.alipayobjects.com/zos/antfincdn/UCSiy1j6jx/xingzhuang.svg', content: ( - -
-
-
{JSON.stringify(item.configId)}
- -
- -
- -
+
+
{JSON.stringify(item.configId)}
+ +
+ + + + ), }; }); @@ -227,180 +227,175 @@ const AlgorithmSetting: React.FC = () => { } useEffect(() => { postDeviceGroupGetDeviceGroupTree() - .then((resp) => { - setNodeTreeData(resp.data.tree); - setHasInit(true); - }) - .catch(() => { - message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '$$$' })); - }); + .then((resp) => { + setNodeTreeData(resp.data.tree); + setHasInit(true); + }) + .catch(() => { + message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '$$$' })); + }); }, []); return ( - - { - // TODO_1 此处接口需要重新联调 - console.log(info.node, 'onSelect_info'); - setSelectNodes(selectKeys); - fetchProjectInfoByGroupId(info?.node); - fetchProjectByGroupId(info?.node); - actionRef.current?.reload(); - }} - checkStrictly={false} - /> - ) - } - rightDom={ - <> - - - - {tabs?.length ? ( + + { + // TODO_1 此处接口需要重新联调 + console.log(info.node, 'onSelect_info'); + setSelectNodes(selectKeys); + fetchProjectInfoByGroupId(info?.node); + fetchProjectByGroupId(info?.node); + actionRef.current?.reload(); + }} + checkStrictly={false} + /> + ) + } + rightDom={ <> - { - setActiveMode('1'); // 重置到项目详情 - changeProjectTab(key); - }} - > - -
    - {tabModeList.map((item) => { - // TODO 统一使用button默认效果 'primary' : 'default' - return ( -
  • changeMode(item)} - style={{ - padding: '16px 12px 0 0', + + + + {tabs?.length ? ( + <> + { + setActiveMode('1'); // 重置到项目详情 + changeProjectTab(key); }} + > + +
      - - - ); - })} -
    + {tabModeList.map((item) => { + return ( +
  • changeMode(item)} + style={{ + padding: '16px 12px 0 0', + }} + > + +
  • + ); + })} +
- {/* 项目 */} - {activeMode === '1' ? ( - <> -
- 模型列表 - {/* // TODO 需要对接接口 */} - {false ? ( - + {/* 项目 */} + {activeMode === '1' ? ( + <> +
+ 模型列表 + {/* // TODO 需要对接接口 */} + {( + + )} +
+ + actionRef={actionRef} + style={{ + padding: '0px 16px 16px', + }} + className="gn" + ghost={true} + itemCardProps={{ + ghost: true, + bodyStyle: { padding: 0, margin: 0 }, + }} + pagination={{ + defaultPageSize: 6, + showSizeChanger: false, + }} + showActions="hover" + grid={{ gutter: 8, xs: 1, md: 2, xl: 3, xxl: 4 }} + metas={{ + type: {}, + content: {}, + actions: { + cardActionProps: 'extra', + }, + }} + dataSource={modelData} + /> + ) : ( - +
+ +
)} -
- - style={{ - padding: '0px 16px 16px', - }} - className="gn" - ghost={true} - itemCardProps={{ - ghost: true, - bodyStyle: { padding: 0, margin: 0 }, - }} - pagination={{ - defaultPageSize: 6, - showSizeChanger: false, - }} - showActions="hover" - grid={{ gutter: 8, xs: 1, md: 2, xl: 3, xxl: 4 }} - metas={{ - type: {}, - content: {}, - actions: { - cardActionProps: 'extra', - }, - }} - dataSource={modelData} - /> +
- ) : ( -
- -
- )} - - - ) : ( - <> - + ) : ( + <> + + + )} - )} - - } - >
- } - updateModalOpen={updateModalOpen} - handleModal={handleUpdateModal} - groupId={currentRow?.id || 0} - reload={actionRef.current?.reload} - projectModelConfigId={projectConfigId} - /> -
+ } + >
+ } + updateModalOpen={updateModalOpen} + handleModal={handleUpdateModal} + groupId={currentRow?.id || 0} + reload={actionRef.current?.reload} + projectModelConfigId={projectConfigId} + /> +
); }; diff --git a/src/pages/Setting/components/UpdateForm.tsx b/src/pages/Setting/components/UpdateForm.tsx index f6b7d35..c1f51e0 100644 --- a/src/pages/Setting/components/UpdateForm.tsx +++ b/src/pages/Setting/components/UpdateForm.tsx @@ -18,6 +18,7 @@ import { useIntl } from '@umijs/max'; import { Modal, message } from 'antd'; import React, { useEffect, useState } from 'react'; import { proFormMaxItemStyleProps, proFormMaxModelWidth } from '../../../../config/defaultForm'; +import {postModelImageGetModelImageFkSelect} from "@/services/resource/ModelImage"; /**styles */ const modelParamsFormItemProps = { @@ -226,12 +227,12 @@ const UpdateForm: React.FC = (props) => { return ( // eslint-disable-next-line react/jsx-key
= (props) => { tooltip={item.remark} /> ); - } else { - return <>; } })}
@@ -261,6 +260,50 @@ const UpdateForm: React.FC = (props) => { + + name="image" + title="镜像配置" + stepProps={{ + description: '镜像选择', + }} + onFinish={async (values: any) => { + configResult.imageFkId = values.imageFkId; + return true; + }} + > + <> + + {renderProjectItems()} + {isInit && projectModelConfig.modelFkId && projectModelConfig.modelFkId !== 0 && ( + + 基础镜像 + (选择基础镜像) + + } + onChange={handleSelectChange} + initialValue={projectModelConfig.imageFkId} + // dependencies 的内容会注入 request 中 + request={async () => { + let resp = await postModelImageGetModelImageFkSelect({ + }); + return resp.data.list.map((v: any) => { + return { + label: v.name, + value: v.id, + }; + }); + }} + /> + )} + + + @@ -404,7 +447,7 @@ const UpdateForm: React.FC = (props) => { - {/* 关联算法模型 */} + {/* 设备关联配置 */} = (props) => { description: '设备关联配置', }} onFinish={async () => { + console.log(targetKeys, 'targetKeys') configResult.devices = targetKeys.join(','); + console.log(configResult.devices, 'targetKeys') configResult.id = props.projectModelConfigId; putProjectModelConfigUpdateProjectModelConfig(configResult) .then(() => { @@ -424,7 +469,8 @@ const UpdateForm: React.FC = (props) => { props.reload(); return true; }) - .catch(() => { + .catch((err) => { + console.log(err) message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '$$$' })); return false; }); diff --git a/src/pages/System/OperationRecordList/index.tsx b/src/pages/System/OperationRecordList/index.tsx index 37e3c26..e1048c5 100644 --- a/src/pages/System/OperationRecordList/index.tsx +++ b/src/pages/System/OperationRecordList/index.tsx @@ -298,7 +298,7 @@ const OperationRecordList: React.FC = () => { },]; return ( - + headerTitle={intl.formatMessage({ id: 'pages.searchTable.title', defaultMessage: '$$$', diff --git a/src/pages/Welcome/components/FootInfoCard.tsx b/src/pages/Welcome/components/FootInfoCard.tsx index 9701cb9..1155188 100644 --- a/src/pages/Welcome/components/FootInfoCard.tsx +++ b/src/pages/Welcome/components/FootInfoCard.tsx @@ -18,10 +18,10 @@ const { useState } = React; // static data 静态数据 const data = [ - { rank: 1, keyword: '网点一', users: 1000, range: 37, status: 1 }, - { rank: 2, keyword: '网点二', users: 800, range: 62, status: 1 }, - { rank: 3, keyword: '网点三', users: 1500, range: 20, status: 0 }, - { rank: 4, keyword: '网点四', users: 1200, range: 36, status: 0 }, + { rank: 1, keyword: '产线A01', users: 100, range: 37, status: 1 }, + { rank: 2, keyword: '产线A02', users: 80, range: 62, status: 1 }, + { rank: 3, keyword: '产线A03', users: 150, range: 20, status: 0 }, + { rank: 4, keyword: '产线A04', users: 120, range: 36, status: 0 }, // 添加更多数据项 ]; @@ -88,9 +88,9 @@ const trendItemHeadStyle = { padding: 0 }; /**state 初始化数据 */ const offendingTrendData: Record[] = [ - { label: '玩手机', value1: 11093, value2: '17.1', status: 0 }, - { label: '打瞌睡', value1: 26, value2: '27.1', status: 1 }, - { label: '离岗', value1: 145, value2: '37.1', status: 1 }, + { label: '表面缺陷', value1: 204, value2: '17.1', status: 0 }, + { label: '抽烟检测', value1: 26, value2: '27.1', status: 1 }, + { label: '划痕检测', value1: 145, value2: '37.1', status: 1 }, ]; /**methods 事件交互 */ @@ -158,7 +158,7 @@ const DonutChart: React.FC = () => { legend: { orient: 'vertical', left: 10, - data: ['玩手机', '打瞌睡', '离岗'], + data: ['表面缺陷', '划痕检测', '抽烟检测'], }, series: [ { @@ -182,9 +182,9 @@ const DonutChart: React.FC = () => { show: false, }, data: [ - { value: 235, name: '玩手机'}, - { value: 510, name: '打瞌睡' }, - { value: 134, name: '离岗' }, + { value: 235, name: '表面缺陷'}, + { value: 510, name: '划痕检测' }, + { value: 134, name: '抽烟检测' }, ], }, ], @@ -232,7 +232,7 @@ const FootInfoCard: React.FC = () => { { } colSpan={topColSpanProps} style={topItemStyle} - + > { } colSpan={topColSpanProps} style={topItemStyle1} - + > { gutter={24} wrap ghost - title="覆盖网点" + title="覆盖车间" headStyle={topItemHeadStyle} extra={ <> @@ -141,12 +141,12 @@ const NavInfoCardList: React.FC = () => { } colSpan={topColSpanProps} style={topItemStyle2} - + > @@ -189,7 +189,7 @@ const NavInfoCardList: React.FC = () => { } colSpan={topColSpanProps} style={topItemStyle3} - + >