From ce1b50bb3695dfb7d8eb222f4e741144ab1fc312 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=8D=9A=E6=96=87?= <1179111926@qq.com> Date: Fri, 12 Aug 2022 15:26:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E9=80=9A=E4=B8=BB=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Equipment/List/Index/index.less | 4 +- src/pages/Equipment/List/Index/index.tsx | 362 ++++++++++++++++------ 2 files changed, 275 insertions(+), 91 deletions(-) diff --git a/src/pages/Equipment/List/Index/index.less b/src/pages/Equipment/List/Index/index.less index 2fa761b..12b47d0 100644 --- a/src/pages/Equipment/List/Index/index.less +++ b/src/pages/Equipment/List/Index/index.less @@ -123,7 +123,6 @@ padding: 0 20px; > aside { - height: 124px; background: #ffffff; > div:first-child { @@ -144,7 +143,8 @@ .li { display: flex; - + border: 1px solid #ebf3ff; + border-top: 0; i { font-size: 34px; color: #a0a4f7; diff --git a/src/pages/Equipment/List/Index/index.tsx b/src/pages/Equipment/List/Index/index.tsx index 57be5d6..b8820ed 100644 --- a/src/pages/Equipment/List/Index/index.tsx +++ b/src/pages/Equipment/List/Index/index.tsx @@ -1,7 +1,17 @@ import styles from './index.less'; -import { Select, Input, Button, Row, Modal, Form, message, Empty } from 'antd'; +import { + Select, + Input, + Button, + Row, + Modal, + Form, + message, + Empty, + Spin, +} from 'antd'; import Fetch from '@/utils/fetch'; -import { useEffect, useState, FC } from 'react'; +import { useEffect, useState, FC, useRef } from 'react'; import { connect, @@ -20,58 +30,89 @@ interface PageProps extends ConnectProps { } const Page: FC = ({ basic, dispatch }) => { - const [facilityList, setFacilityList] = useState([{}]); - const [visible, setVisible] = useState(false); + const [facilityList, setFacilityList] = useState([]); + const [localList, setLocalList] = useState([]); + const [firmList, setFirmList] = useState([]); + const [visible, setVisible] = useState(false); + const [loading, setLoading] = useState(true); const [form] = Form.useForm(); + const editId = useRef(null); useEffect(() => { - getData(); + getData('1'); + getData('2'); + getFirmList(); }, []); - const getData = async () => { - const res = await Fetch('/openi/resource/getResourceStatus'); + const getData = async (type: string) => { + setLoading(true); + const res = await Fetch('/openi/dataCenter/page', { + method: 'get', + params: { + type, + pageSize: 1000000, + pageNumber: 1, + }, + }); if (res.result === 'success') { - dispatch({ - type: 'basic/setActionData', - payload: { - resource: res?.data?.[0]?.resource ? '已开通' : '未开通', - cert: res?.data?.[0]?.cert ? '已开通' : '未开通', - }, - }); + const data = res?.data?.[0]; + if (type === '1') { + setFacilityList(data.list || []); + } else { + setLocalList(data.list || []); + } } + setLoading(false); }; - const open = async () => { - const res = await Fetch.post('/openi/resource/clickOpenResource'); + const getFirmList = async () => { + const res = await Fetch('/openi/producer/list'); if (res.result === 'success') { - form.setFieldsValue({ dbUser, dbPasswd, dbServerIp }); - setVisible(true); + const data = res?.data?.[0]; + setFirmList(data); } }; - const certificateOpen = async () => { - if (!company) { - message.warn('选择单位不能为空'); - return; - } - if (!certSign) { - message.warn('请先下载证书'); - return; - } - const res = await Fetch.post('/openi/resource/openCertSystem'); + const handleFinish = async (v: any) => { + const res = await Fetch('/openi/dataCenter/editOrAdd', { + method: 'post', + data: { + ...v, + type: visible, + id: editId.current, + }, + }); if (res.result === 'success') { - history.replace('/basic/certificate'); + getData(visible); + setVisible(false); } }; - const handleFinish = (v: any) => { - const { dbUser, dbPasswd, dbServerIp } = v; - dispatch({ - type: 'basic/setActionData', - payload: { dbUser, dbPasswd, dbServerIp }, + const addList = (type: string) => { + setVisible(type); + }; + + const deleteList = (type: string, id: any) => { + Modal.confirm({ + title: '提示', + okText: '确认', + cancelText: '取消', + content: '确认删除吗?', + onOk: async () => { + const res = await Fetch(`/openi/dataCenter/delete/${id}`, { + method: 'post', + }); + if (res.result === 'success') { + getData(type); + } + }, }); - setVisible(false); - history.replace('/basic/device'); + }; + + const editList = (type: string, param: any) => { + form.setFieldsValue({ ...param }); + editId.current = param.id; + setVisible(type); }; return ( @@ -117,60 +158,172 @@ const Page: FC = ({ basic, dispatch }) => { -
-
-
数据中心设备列表
- -
-
- {!facilityList.length && } - {!!facilityList.length && - facilityList.map((e: any, i: number) => { - return ( - + ); + })} +
+
+
+
+
数据管理终端列表
+ +
+
+ {!localList.length && } + {!!localList.length && + localList.map((e: any, i: number) => { + return ( +
- - ); - })} + + + + + + + ); + })} +
- + { + form.resetFields(); + editId.current = null; + }} okText="保存" cancelText="取消" onOk={() => { @@ -183,46 +336,77 @@ const Page: FC = ({ basic, dispatch }) => {
- + + + + + + +