diff --git a/src/pages/Manager/BasicManager/List/Model/index.less b/src/pages/Manager/BasicManager/List/Model/index.less index 30bd8cd..90354db 100644 --- a/src/pages/Manager/BasicManager/List/Model/index.less +++ b/src/pages/Manager/BasicManager/List/Model/index.less @@ -39,3 +39,7 @@ width: 388px; } } + +.colorBlue { + color: @primary-color; +} diff --git a/src/pages/Manager/BasicManager/List/Model/index.tsx b/src/pages/Manager/BasicManager/List/Model/index.tsx index 806d4f4..49b7b40 100644 --- a/src/pages/Manager/BasicManager/List/Model/index.tsx +++ b/src/pages/Manager/BasicManager/List/Model/index.tsx @@ -8,33 +8,37 @@ import { message, Empty, Table, - InputNumber, + Upload, Input, Col, } from 'antd'; import Fetch from '@/utils/fetch'; -import { useEffect, useState, FC, useRef, Fragment } from 'react'; +import React, { useEffect, useState, FC, useRef, Fragment } from 'react'; import { downLoadLink } from '@/utils/download'; import url from '@/utils/url'; import { ColumnsType } from 'antd/lib/table'; import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons'; +const { Dragger } = Upload; interface PageProps {} const Page: FC = () => { const [data, setData] = useState([]); const [firmList, setFirmList] = useState([]); + const [fileList, setFileList] = useState([]); const [loading, setLoading] = useState(true); const [total, setTotal] = useState(0); const [value, setValue] = useState(''); - const [visible, setVisible] = useState(false); + const [visible, setVisible] = useState(false); const [form] = Form.useForm(); + const [formAdd] = Form.useForm(); const [params, setParams] = useState({ pageNumber: 1, pageSize: 20, keywords: '', }); const editId = useRef(null); + const savedFileList = useRef([]); useEffect(() => { getData(params); @@ -117,6 +121,11 @@ const Page: FC = () => { }; const handleFinish = async (v: any) => { + console.log(v, 22222); + if (!v?.producerIdList?.length) { + message.warn('厂商不能为空'); + return; + } const res = await Fetch(`/openi/deviceType/editOrAdd`, { method: 'post', data: { @@ -132,18 +141,31 @@ const Page: FC = () => { } }; + const handleAddFinish = async (v: any) => { + console.log(v, 22); + const res = await Fetch(`/openi/deviceType/addList`, { + method: 'post', + data: v.sights || [], + }); + if (res.result === 'success') { + params.pageNumber = editId.current ? params.pageNumber : 1; + setParams({ ...params }); + getData(params); + setVisible(false); + } + }; + const handleEdit = (param: any) => { form.setFieldsValue({ ...param, producerIdList: param?.producerList?.map((e: any) => e.id), }); editId.current = param.id; - setVisible(true); + setVisible('编辑'); }; const handleAdd = () => { - form.setFieldsValue({ producerIdList: [''] }); - setVisible(true); + setVisible('新增'); }; const handleDelete = (id: any) => { @@ -169,6 +191,73 @@ const Page: FC = () => { }); }; + const handleRemoveFile = async (info: any) => { + const newFileList = fileList.filter((item) => item.uid !== info.uid); + setFileList(newFileList); + savedFileList.current = [...newFileList]; + message.info('删除成功'); + }; + + const handleBeforeUpload = (info: any) => { + if (fileList?.some((e: any) => e.name === info.name)) { + message.info(`${info.name}文件已存在`); + return false; + } + let fileText = info?.name?.substring( + info?.name?.lastIndexOf('.'), + info?.name?.length, + ); + fileText = fileText?.toLowerCase(); + if (fileText !== '.xml' && fileText !== '.XML') { + message.error('只能上传.xml,.XML格式的文档'); + return false; + } + const param = { name: info.name, uid: info.uid, file: info, percent: 0 }; + fileList.push(param); + savedFileList.current = [...fileList]; + setFileList([...fileList]); + return false; + }; + + const draggerProps = { + height: 40, + multiple: true, + withCredentials: true, + fileList, + disabled: fileList.length > 10, + maxCount: 10, + accept: '.xml, .XML', + // action: `${ENV.API_SERVER}/api/attachments.json`, + // onChange: handleChangeFile, + onRemove: handleRemoveFile, + beforeUpload: handleBeforeUpload, + }; + + const returnDom = () => { + return ( +
+ 拖拽文件或 + 点击此处上传 +
+ ); + }; + + const handleLoad = () => { + const k = [ + { + name: 'U盘', + typeNumber: '8782', + pattern: '国家保密机', + secretLevel: '3级', + managementLevel: '公司 ', + producerIdList: [''], + }, + ]; + formAdd.setFieldsValue({ + sights: k, + }); + }; + return (
@@ -224,8 +313,192 @@ const Page: FC = () => { /> { + formAdd.resetFields(); + editId.current = null; + setFileList([]); + savedFileList.current = []; + }} + cancelText="取消" + onOk={() => { + formAdd.submit(); + }} + onCancel={() => { + setVisible(false); + }} + > + {returnDom()} + + + +
+ + {(fields) => + fields.map(({ key, name, ...restField }: any, index: number) => { + return ( +
+ 新增型号{index + 1} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {(fields, { add, remove }, { errors }) => ( + <> + {fields.map(({ key, name, ...restField }, index) => ( + + + + + {fields.length > 1 ? ( + remove(name)} + /> + ) : null} + + ))} + + + + + )} + +
+ ); + }) + } +
+
+
+ { @@ -264,7 +537,7 @@ const Page: FC = () => { }, ]} > - + @@ -278,7 +551,7 @@ const Page: FC = () => { }, ]} > - + @@ -294,7 +567,7 @@ const Page: FC = () => { }, ]} > - + @@ -308,7 +581,7 @@ const Page: FC = () => { }, ]} > - + @@ -324,7 +597,7 @@ const Page: FC = () => { }, ]} > - + diff --git a/src/pages/Manager/Header/index.tsx b/src/pages/Manager/Header/index.tsx index cf4ec5a..2eb1085 100644 --- a/src/pages/Manager/Header/index.tsx +++ b/src/pages/Manager/Header/index.tsx @@ -12,11 +12,11 @@ const Header = ({ ...props }) => { const res = await Fetch('/openi/localManager/isOpen'); if (res.result === 'success') { document.title = '管理基础设施'; - if (!res?.data?.[0]) { - message.warn('当前本地管理终端未开通,已为你跳转至终端界面!'); - history.replace('/terminal'); - return; - } + // if (!res?.data?.[0]) { + // message.warn('当前本地管理终端未开通,已为你跳转至终端界面!'); + // history.replace('/terminal'); + // return; + // } } }; diff --git a/src/pages/Simulation/index.tsx b/src/pages/Simulation/index.tsx index 3579569..d543db2 100644 --- a/src/pages/Simulation/index.tsx +++ b/src/pages/Simulation/index.tsx @@ -107,7 +107,7 @@ const Progress = ({ item, onFinish, start, setVisible }: any) => {
{data.deviceId}
{data.name}
- {data.type === 4 ? ( + {data.type !== 3 ? ( setVisible(data)} className="iconfont icon-bianji10" @@ -146,7 +146,7 @@ const Progress = ({ item, onFinish, start, setVisible }: any) => {
{data.type === 1 ? ( setVisible(data)} + // onClick={() => setVisible(data)} className="iconfont icon-bianji10" /> ) : ( @@ -171,7 +171,7 @@ const Progress = ({ item, onFinish, start, setVisible }: any) => {
{data.type === 2 ? ( setVisible(data)} + // onClick={() => setVisible(data)} className="iconfont icon-bianji10" /> ) : (