From 3a3b7a014347b4ad202655483779dd779b6c1418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A2=81=E5=B8=85?= Date: Fri, 23 Sep 2022 17:04:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=AE=A1=E7=90=86=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E5=88=9D=E6=AD=A5=E6=90=AD=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/router_elecEvaluation.ts | 6 +- .../DeviceManage/DeviceForm.tsx | 153 ++++++++++ .../ElecEvaluation/DeviceManage/index.tsx | 268 ++++++++++++++++++ .../ElecEvaluation/DeviceManage/service.ts | 41 +++ .../components/modal/PlaceModal.tsx | 6 +- 5 files changed, 470 insertions(+), 4 deletions(-) create mode 100644 src/pages/ElecEvaluation/DeviceManage/DeviceForm.tsx create mode 100644 src/pages/ElecEvaluation/DeviceManage/index.tsx create mode 100644 src/pages/ElecEvaluation/DeviceManage/service.ts diff --git a/config/router_elecEvaluation.ts b/config/router_elecEvaluation.ts index 6a7c916..6f63442 100644 --- a/config/router_elecEvaluation.ts +++ b/config/router_elecEvaluation.ts @@ -41,10 +41,14 @@ export const elecBidEvaluation = [ path: '/ElecEvaluation/AbnormalAlarm', component: './ElecEvaluation/AbnormalAlarm' }, - {//设备管理 + {//设备查看 path: '/ElecEvaluation/Device', component: './ElecEvaluation/Device', }, + {//设备管理 + path: '/ElecEvaluation/DeviceManage', + component: './ElecEvaluation/DeviceManage', + }, {//评标现场管理 path: '/ElecEvaluation/EvalSiteManage', routes: [ diff --git a/src/pages/ElecEvaluation/DeviceManage/DeviceForm.tsx b/src/pages/ElecEvaluation/DeviceManage/DeviceForm.tsx new file mode 100644 index 0000000..f037276 --- /dev/null +++ b/src/pages/ElecEvaluation/DeviceManage/DeviceForm.tsx @@ -0,0 +1,153 @@ +import { Form, Input, Modal, Select, Spin } from "antd" +import React, { useEffect, useState } from "react" +import { getDeviceById } from "./service"; + + +interface DeviceFormProps { + modalVisible: boolean; + titleName: string; + onCancel: () => void; + status: string;//状态 0-新建 1-编辑 2-查看 + type: string; + tpId: string; + deviceId: string; + +} +const deviceTypeEnum = { + 'resource_door': { text: '门禁点' }, + 'resource_camera': { text: '监控点' }, + 'resource_nvr': { text: 'nvr' }, + 'resource_encodeDevice': { text: '编码设备' }, + 'resource_oneMachine': { text: '门禁一体机' }, +} +const layout = { + labelCol: { span: 7 }, + wrapperCol: { span: 10 }, +}; +const DeviceForm: React.FC = (props) => { + + const { titleName, modalVisible, onCancel, type, tpId, deviceId } = props; + const [spinning, setSping] = useState();//加载遮罩 + const [editInformation, setEditInformation] = useState(false);//是否可编 + const [form] = Form.useForm(); + //窗口状态 0-新建 1-编辑 2-查看 + const [modalStatus, setModalStatus] = useState(status); + + + useEffect(() => { + Int(); + form.resetFields();//清除form中数据 + }, [type, deviceId]); + const Int = () => { + + setSping(true); + if (type == "new") {//==========================================================新建 + + setSping(false); + setEditInformation(false);//可编辑 + + } else if (type == "edit") {//=========================================================修改 + console.log(deviceId); + getDeviceById(deviceId).then(res => { + if (res.code == 200) { + const data = res.data; + + form.setFieldsValue({ + "id": data.id, + "deviceName": data.deviceName, + "deviceManagementIp": data.deviceManagementIp, + "deviceCode": data.deviceCode, + "devicePlatform": data.devicePlatform, + "placeId": data.placeId, + "areaId": data.areaId, + }); + setSping(false); + setEditInformation(false);//可编辑 + + } + }); + + + } else if (type == "read") {//=========================================================查看 + getDeviceById(deviceId).then(res => { + if (res.code == 200) { + const data = res.data; + + form.setFieldsValue({ + "id": data.id, + "deviceName": data.deviceName, + "deviceManagementIp": data.deviceManagementIp, + "deviceCode": data.deviceCode, + "devicePlatform": data.devicePlatform, + "placeId": data.placeId, + "areaId": data.areaId, + }) + + setSping(false); + setEditInformation(true) + + } + }); + } + } + + + + // @ts-ignore + return ( + onCancel()} + className="返回" + width={"40%"} + /*style={{top: "2%", height: "96%", overflowY: "auto"}} + bodyStyle={{paddingTop: "16px"}}*/ + centered + + > + +
+ + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + ) +} +export default DeviceForm diff --git a/src/pages/ElecEvaluation/DeviceManage/index.tsx b/src/pages/ElecEvaluation/DeviceManage/index.tsx new file mode 100644 index 0000000..06115b5 --- /dev/null +++ b/src/pages/ElecEvaluation/DeviceManage/index.tsx @@ -0,0 +1,268 @@ +import React, { useState, useRef, useEffect } from 'react'; +import { Button, Spin, Tabs, Tree} from 'antd'; +import ProTable, { ActionType } from '@ant-design/pro-table'; +import { deviceList, getplaceareaList, roomList } from './service'; +import '@/assets/ld_style.less'; +import { getURLInformation, isNotEmpty } from '@/utils/CommonUtils'; +import ProCard from "@ant-design/pro-card"; +import DeviceForm from './DeviceForm'; + + +const deviceTypeEnum = { + 'resource_door': { text: '门禁设备' }, + 'resource_camera': { text: '监控设备' }, + 'resource_nvr': { text: 'nvr' }, + 'resource_encodeDevice': { text: '编码设备' }, + 'resource_oneMachine_face': { text: '人脸一体机' }, + 'resource_oneMachine_card': { text: '人证一体机' }, + +} +const deviceStatusEnum = { + 'online_0': { text: '离线' }, + 'online_1': { text: '在线' }, + 'online_9': { text: '无此设备' }, +} +const DeviceManage: React.FC<{}> = () => { + const checkRelationRef = useRef(); //操作数据后刷新列表 + const [treeData, setTreeData] = useState(); + const [treeId, setTreeId] = useState(); + const [updateVisible, setUpdateVisible] = useState(false) + const [type, setType] = useState();// 状态 编辑or 查看 + const [deviceId, setDeviceId] = useState("");//设备id + const [spin, spinSet] = useState(false);//加载遮罩 + const [updateChange, setUpdateChange] = useState('') + + /*拉取数据*/ + useEffect(() => { + getplaceareaList().then((res: { code: number; data: any[] | undefined; }) => { + if (res.code == 200) { + let data: any = []; + if (res.data != undefined) { + res.data.map((item: any, index: any) => { + const title1 = item.placeName; + const key1 = item.id; + let children1: any = []; + if (item.roomList != undefined) { + const children = item.roomList.map((item: any, index: any) => { + const title2 = item.areaName; + const key2 = item.id; + return { title: title2, key: key2} + }); + children1 = children; + } + const first = { title: title1, key: key1, children: children1 } + data.push(first); + }); + } + setTreeData(data); + } + }) + }, []); + + const toAdd = async (props?: any) => { + // spinSet(true); + setUpdateChange('新增设备'); + setType("new"); + setUpdateVisible(true); + + } + const toEdit = (dId: String) => { + setUpdateChange('修改设备'); + console.log(dId) + setDeviceId(dId) + setType("edit"); + setUpdateVisible(true); + } + + const toRead = (props: any) => { + setUpdateChange('查看设备'); + setDeviceId(props.id) + setType("read"); + setUpdateVisible(true); + } + /** + * 设备管理 + * @param record + */ + + const current = getURLInformation('current'); + //列表页loading + const [spinLoading, setSpinLoading] = useState(false); + + const onSelect = (selectedKeys: any, info: any) => { + selectedKeys.length == 0 ? setTreeId(null) : setTreeId(selectedKeys[0]) + + console.log(selectedKeys) + } + const columns: any[] = [ + //设备管理 + + { + title: '序号', + dataIndex: 'index', + valueType: 'index', + search: false, + width: '3%', + }, + { + title: '评标场所名称', + dataIndex: 'placeName', + width: '10%', + search: false, + }, + { + title: '评标区域名称', + dataIndex: 'areaName', + width: '10%', + search: false, + }, + { + title: '设备类型', + dataIndex: 'deviceType', + width: '10%', + valueType: 'select', + valueEnum: deviceTypeEnum, + search: false, + }, + { + title: '设备名称', + dataIndex: 'deviceName', + search: true, + width: '10%', + }, + { + title: '设备标识', + dataIndex: 'deviceCode', + search: true, + width: '10%', + }, + + { + title: '网络IP', + dataIndex: 'deviceManagementIp', + search: true, + width: '10%', + }, + { + title: '设备状态', + dataIndex: 'deviceStatus', + width: '10%', + valueType: 'select', + valueEnum: deviceStatusEnum, + search: true, + }, + + { + title: '操作', + width: '7%', + search: false, + render: (text: any, record: any) => { + return ( + <> + + + + ); + }, + }, + ]; + + return ( +
+ + + +

评标场所设备管理

+ {treeData == undefined ? null : ( + + )} +
+ + + + + await deviceList(params).then((res) => { + if (res.code == 200) { + let data = res.data; + return Promise.resolve({ + data: data.records, + success: res.success, + total: res.data.total, + current: res.data.current, + }); + } + return Promise.resolve({ + data: [], + success: false, + total: 0, + current: 1, + }); + }) + } + search={{ + filterType: 'query', + optionRender: (searchConfig: any, { form }) => { + return [ + , + , + , + ]; + }, + }} + pagination={{ + defaultCurrent: isNotEmpty(current) ? Number(current) : 1, + defaultPageSize: 10, + showSizeChanger: false, + }} //默认显示条数 + toolBarRender={false} + /> + +
+ {updateVisible ? ( + setUpdateVisible(false)} + modalVisible={updateVisible} tpId={''} /> + ) : null} +
+
+ + ); +}; +export default DeviceManage + + diff --git a/src/pages/ElecEvaluation/DeviceManage/service.ts b/src/pages/ElecEvaluation/DeviceManage/service.ts new file mode 100644 index 0000000..2089c93 --- /dev/null +++ b/src/pages/ElecEvaluation/DeviceManage/service.ts @@ -0,0 +1,41 @@ +import request from '@/utils/request'; + +export async function reserveList(data: any) { // 查询会议室/评标室预约情况 + return request('/api/biz-service-ebtp-evaluation/v1/eval/room/reserve/list', { + method: 'post', + data: { ...data, pageNo: data.current } + }); +} + +export async function roomList() { // 查询评标室列表 + ///api/biz-service-ebtp-evaluation + return request('/api/biz-service-ebtp-evaluation/v1/elec/eval/room/list', { + method: 'get', + params: {} + }); +} + + +export async function deviceList(data: any) { + // 查询设备列表 + return request('/api/biz-service-ebtp-evaluation/v1/eval/device/queryPageByParam', { + method: 'post', + data: { ...data, pageNo: data.current }, + }); +} + +export async function getplaceareaList() { + // 查询场所、区域列表 + /// /v1/elec/eval/placearea/uset/list + return request('/api/biz-service-ebtp-evaluation/v1/elec/eval/placearea/user/list', { + method: 'get', + params: {} + }); +} + +export async function getDeviceById(id: any) { + return request('/api/biz-service-ebtp-evaluation/v1/eval/device/query/' + `${id}`, { + method: 'get', + params: {} + }); +} diff --git a/src/pages/ElecEvaluation/PlaceAreasManage/components/modal/PlaceModal.tsx b/src/pages/ElecEvaluation/PlaceAreasManage/components/modal/PlaceModal.tsx index 11c6973..a905f81 100644 --- a/src/pages/ElecEvaluation/PlaceAreasManage/components/modal/PlaceModal.tsx +++ b/src/pages/ElecEvaluation/PlaceAreasManage/components/modal/PlaceModal.tsx @@ -418,12 +418,12 @@ interface PlaceInfo { -