评标场所、区域、设备代码完善

This commit is contained in:
袁帅
2022-09-28 09:53:58 +08:00
parent 8337eae99a
commit 48e74053e3
6 changed files with 215 additions and 148 deletions

View File

@ -1,7 +1,8 @@
import { ForkOutlined } from "@ant-design/icons";
import { Button, Form, Input, message, Modal, Select, Spin, Row, Col } from "antd"
import Password from "antd/lib/input/Password";
import { fromPairs, values } from "lodash";
import React, { useEffect, useState } from "react"
import React, { useEffect, useRef, useState } from "react"
import SelectDeviceModal from "./SelectDeviceModal";
import { getDeviceById, saveDevice } from "./service";
@ -65,9 +66,12 @@ const DeviceForm: React.FC<DeviceFormProps> = (props) => {
const [selectDeviceStatus, setSelectDeviceStatus] = useState<boolean>(false);
const deviceRelData = useRef<DeviceRel>();
useEffect(() => {
//清除form中数据
form.resetFields();
Int();
form.resetFields();//清除form中数据
}, [type, deviceId]);
const Int = () => {
setSping(true);
@ -81,10 +85,19 @@ const DeviceForm: React.FC<DeviceFormProps> = (props) => {
"areaId" : deviceRel.areaId,
"areaName" : deviceRel.areaName,
})
deviceRelData.current = deviceRel;
setEditInformation(false);//可编辑
} else if (type == "edit") {//=========================================================修改
getDeviceById(deviceId).then(res => {
setFilesData(res.data);
deviceRelData.current = {
placeId: res.data.placeId,
placeName: res.data.placeName,
areaId: res.data.areaId,
areaName: res.data.areaName,
platformId: res.data.platform.id,
platformName: res.data.platform.platformName,
};
setSping(false);
setEditInformation(false);//可编辑
});
@ -92,6 +105,14 @@ const DeviceForm: React.FC<DeviceFormProps> = (props) => {
getDeviceById(deviceId).then(res => {
if (res.code == 200) {
setFilesData(res.data);
deviceRelData.current = {
placeId: res.data.placeId,
placeName: res.data.placeName,
areaId: res.data.areaId,
areaName: res.data.areaName,
platformId: res.data.platform.id,
platformName: res.data.platform.platformName,
};
setSping(false);
setEditInformation(true)
}
@ -162,8 +183,16 @@ const DeviceForm: React.FC<DeviceFormProps> = (props) => {
setSelectDeviceStatus(true);
}
const returnEvalData = (value:any) => {
const SelectDeviceData = (value:any) => {
form.setFieldsValue({
deviceAbility: value.deviceAbility,
deviceCode: value.deviceCode,
deviceName: value.deviceName,
devicePlatform: value.devicePlatform,
deviceProtocol: value.deviceProtocol,
deviceType: value.deviceType,
deviceVender: value.deviceVender
})
}
// @ts-ignore
@ -198,19 +227,19 @@ const DeviceForm: React.FC<DeviceFormProps> = (props) => {
<Form.Item name="placeId" label="评标场所id" hidden>
<Input />
</Form.Item>
<Form.Item name="areadId" label="评标区域id" hidden>
<Form.Item name="areaId" label="评标区域id" hidden>
<Input />
</Form.Item>
<Form.Item name="placeName" label="评标场所" rules={[{ required: true }]}>
<Input placeholder="评标场所" disabled={true} maxLength={50} />
<Input placeholder="评标场所" disabled={true}/>
</Form.Item>
<Form.Item name="areaName" label="评标区域" rules={[{ required: true }]}>
<Input placeholder="评标区域" disabled={true} maxLength={50} />
<Input placeholder="评标区域" disabled={true}/>
</Form.Item>
<Form.Item name="platformName" label="管理平台" rules={[{ required: true }]}>
<Input placeholder="管理平台" disabled={true} maxLength={50} />
<Input placeholder="管理平台" disabled={true}/>
</Form.Item>
<Form.Item name="deviceType" label="设备类型" rules={[{ required: true }]}>
<Form.Item name="deviceType" label="设备类型" rules={[{ required: true, message: '请选择设备类型' }]}>
<Select
placeholder="请选择设备类型"
allowClear
@ -219,8 +248,8 @@ const DeviceForm: React.FC<DeviceFormProps> = (props) => {
</Select>
</Form.Item>
<Form.Item label="设备名称">
<Form.Item name="deviceName" noStyle rules={[{ required: true }]}>
<Input style={{ width: 'calc(85% - 8px)' }} placeholder="设备名称" maxLength={50} />
<Form.Item name="deviceName" noStyle rules={[{ required: true, message:'请填写设备名称/选择设备' }]}>
<Input style={{ width: 'calc(85% - 8px)' }} placeholder="请填写设备名称/选择设备" maxLength={200} />
</Form.Item>
<Button style= {{width: 'calc(15%)', margin: '0 0 0 8px'}} type='primary' onClick={() => selectDevice()}></Button>
</Form.Item>
@ -234,10 +263,10 @@ const DeviceForm: React.FC<DeviceFormProps> = (props) => {
</Select>
</Form.Item> */}
<Form.Item name="deviceCode" label="设备标识">
<Input placeholder="请填写设备标识" maxLength={50} />
<Input placeholder="请填写设备标识/选择设备" maxLength={200} />
</Form.Item>
<Form.Item name="deviceAbility" label="设备能力">
<Input placeholder="请填写设备能力" maxLength={50} />
<Input placeholder="请填写设备能力/选择设备" maxLength={200} />
</Form.Item>
<Form.Item name="deviceVender" label="设备厂家">
<Select
@ -248,13 +277,13 @@ const DeviceForm: React.FC<DeviceFormProps> = (props) => {
</Select>
</Form.Item>
<Form.Item name="deviceProtocol" label="设备接入协议">
<Input placeholder="请填写设备接入协议" maxLength={50} />
<Input placeholder="请填写设备接入协议" maxLength={200} />
</Form.Item>
<Form.Item name="deviceManagementIp" label="网络IP">
<Input placeholder="请填写网络IP" maxLength={50} />
<Input placeholder="请填写网络IP" maxLength={200} />
</Form.Item>
<Form.Item name="deviceManagementPort" label="端口">
<Input placeholder="请填写端口" maxLength={50} />
<Input placeholder="请填写端口" maxLength={200} />
</Form.Item>
{/* <Form.Item name="deviceManagementLogin" label="管理平台登录账号" >
<Input placeholder="管理平台登录账号" maxLength={50} />
@ -282,7 +311,7 @@ const DeviceForm: React.FC<DeviceFormProps> = (props) => {
</Form>
</Spin>
</Modal>
<SelectDeviceModal modalVisible={selectDeviceStatus} onCancel={() => setSelectDeviceStatus(false)} onSubmit = {(value: any) => returnEvalData(value)} values ={{deviceId}}> </SelectDeviceModal>
<SelectDeviceModal modalVisible={selectDeviceStatus} onCancel={() => setSelectDeviceStatus(false)} onSubmit = {(value: any) => SelectDeviceData(value)} values ={deviceRelData?.current}> </SelectDeviceModal>
</div>
)
}

View File

@ -1,5 +1,5 @@
import React, { useEffect, useRef, useState } from 'react';
import { Form, Input, message, Modal, Spin } from 'antd';
import { Button, Form, Input, message, Modal, Spin } from 'antd';
import ProTable, { ActionType, ProColumns } from '@ant-design/pro-table';
import { getExternDevicesAboveArea } from './service';
@ -13,11 +13,10 @@ interface SelectDeviceProps {
const SelectDevice: React.FC<SelectDeviceProps> = (props) => {
const { modalVisible, onCancel, onSubmit, values } = props;
const actionRef = useRef<ActionType>();
const [form] = Form.useForm();
//当前选择行areaId
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
//当前选择行数据
const [selectedRecord, setSelectedRecord] = useState<any>();
const selectedRecord = useRef<any>();
//loading
const [loading, setLoading] = useState<boolean>(false);
@ -30,6 +29,7 @@ const SelectDevice: React.FC<SelectDeviceProps> = (props) => {
title: '设备编码',
dataIndex: 'deviceCode',
ellipsis: true,
hideInSearch: true,
},
{
title: '设备名称',
@ -44,26 +44,33 @@ const SelectDevice: React.FC<SelectDeviceProps> = (props) => {
message.info("请选择设备");
return;
}
form.validateFields().then(value => {
value["areaId"] = selectedRecord.id;
value["placeId"] = selectedRecord.placeId;
value["areaAddress"] = selectedRecord.areaAddress;
value["areaName"] = selectedRecord.areaName;
value["contactName"] = selectedRecord.contactName;
value["contactTel"] = selectedRecord.contactTel;
value["areaNumber"] = selectedRecord.areaNumber;
onSubmit(value);
})
onSubmit(selectedRecord?.current);
onCancel();
}
useEffect(() => {
setSelectedRowKeys([]);
setSelectedRecord(null);
selectedRecord.current = null;
}, [values])
useEffect(() => {
}, [selectedRowKeys])
const queryDeviceList = async () => {
setLoading(true);
return await getExternDevicesAboveArea({platformId: values?.platformId, areaId: values?.areaId}).then(res => {
if (res?.code == 200) {
return {
data: res?.data,
success: res?.success
}
} else {
return {
data: [],
success: false,
}
}
}).finally(()=>{
setLoading(false);
})
}
return (
<Modal
@ -79,6 +86,22 @@ const SelectDevice: React.FC<SelectDeviceProps> = (props) => {
bodyStyle={{ overflowY: 'auto', }}
className="confirm table-no-alert"
centered
footer = {[
<Button key="cancel" onClick={()=>{onCancel();}}>
</Button>,
<Button key="submit" type="primary" loading={loading} onClick={()=>{onOk();}}>
</Button>,
<Button
key="query"
type="primary"
loading={loading}
onClick={()=>{actionRef?.current?.reload();}}
>
</Button>,
]}
>
<Spin spinning={loading}>
<ProTable<any>
@ -86,68 +109,23 @@ const SelectDevice: React.FC<SelectDeviceProps> = (props) => {
actionRef={actionRef}
bordered={false}
request={async (params) => {
setLoading(true);
return await getExternDevicesAboveArea(params).then(res => {
if (res?.code == 200) {
return {
data: res?.data.records,
success: res?.success,
total: res?.data.total,
}
} else {
return {
data: [],
success: false,
total: 0,
}
}
}).finally(()=>{
setLoading(false);
})
}}
rowKey="id"
search={{
labelWidth: 'auto',
return queryDeviceList();
}}
rowKey="deviceCode"
search={false}
options={false}
pagination={{
size: "small",
defaultPageSize: 5,
showSizeChanger: false,
}}
pagination={false}
rowSelection={{
type: "radio",
selectedRowKeys,
onChange: (selectedRowKeys, selectedRows) => {
setSelectedRowKeys(selectedRowKeys);
setSelectedRecord(selectedRows[0]);
selectedRecord.current = selectedRows[0];
},
}}
dateFormatter="string"
toolBarRender={false}
/>
<Form
name="basic"
form={form}
labelCol={{ span: 8 }}
wrapperCol={{ span: 16 }}
preserve={false}
>
<Form.Item
label="设备编码"
name="deviceCode"
hidden
>
<Input />
</Form.Item>
<Form.Item
label="设备名称"
name="deviceName"
hidden
>
<Input />
</Form.Item>
</Form>
</Spin>
</Modal>
);

View File

@ -1,7 +1,7 @@
import React, { useState, useRef, useEffect } from 'react';
import { Button, message, Spin, Tabs, Tree} from 'antd';
import { Button, message, Popconfirm, Spin, Tabs, Tree} from 'antd';
import ProTable, { ActionType } from '@ant-design/pro-table';
import { deviceList, getplaceareaList, roomList } from './service';
import { deviceList, getplaceareaList, deleteDevice } from './service';
import '@/assets/ld_style.less';
import { getURLInformation, isNotEmpty } from '@/utils/CommonUtils';
import ProCard from "@ant-design/pro-card";
@ -91,6 +91,24 @@ const DeviceManage: React.FC<{}> = () => {
setType("read");
setUpdateVisible(true);
}
const toDelete = async (id: string) => {
const hide = message.loading('正在删除');
try {
const success = await deleteDevice(id).then((res) => {
return res.success
});
hide();
if (success) {
message.success('删除成功');
}
} catch (error) {
hide();
message.error('删除失败请重试!');
checkRelationRef.current?.reload();
}
}
/**
* 设备管理
* @param record
@ -176,9 +194,20 @@ const DeviceManage: React.FC<{}> = () => {
<Button type="text" onClick={() => {toEdit(record.id)}} danger>
</Button>
<Button type="text" onClick={() => {}} danger>
</Button>
<Popconfirm
placement="topRight"
title={"确定删除么?"}
onConfirm={async () => {
spinSet(true)
await toDelete(record.id);
checkRelationRef.current?.reload();
spinSet(false)
}}
okText="确定"
cancelText="取消"
>
<Button type='text' ></Button>
</Popconfirm>
</>
);
},
@ -232,17 +261,10 @@ const DeviceManage: React.FC<{}> = () => {
filterType: 'query',
optionRender: (searchConfig: any, { form }) => {
return [
<Button
key="resetText"
onClick={() => {
form?.setFieldsValue({
current: 1,
});
form?.submit();
}}
>
{searchConfig?.resetText}
</Button>,
<Button key="toCreate"
type="primary" onClick={() => toAdd()}>
</Button>,
<Button
key="searchText"
onClick={() => {
@ -251,10 +273,18 @@ const DeviceManage: React.FC<{}> = () => {
>
{searchConfig?.searchText}
</Button>,
<Button key="toCreate"
type="primary" onClick={() => toAdd()}>
</Button>,
<Button
key="resetText"
onClick={() => {
form?.resetFields();
form?.setFieldsValue({
current: 1,
});
form?.submit();
}}
>
{searchConfig?.resetText}
</Button>,
];
},
}}

View File

@ -56,9 +56,20 @@ export async function saveDevice(params: any) {
* @returns
*/
export async function getExternDevicesAboveArea(params: any) {
return request('/api/biz-service-ebtp-evaluation/v1/eval/device/queryByParam', {
method: 'POST',
data: params
return request('/api/biz-service-ebtp-evaluation/v1/eval/platform/devices', {
method: 'GET',
params: params
});
}
/**
* 删除设备
* @param id
* @returns
*/
export async function deleteDevice(id: string) {
return request('/api/biz-service-ebtp-evaluation/v1/eval/device/delete/'+id, {
method: 'GET'
});
}

View File

@ -1,6 +1,6 @@
import { isNotEmpty } from '@/utils/CommonUtils';
import ProTable, { ActionType, ProColumns } from '@ant-design/pro-table';
import { Button, Spin, message } from 'antd';
import { Button, Spin, message, Popconfirm } from 'antd';
import React, { useRef, useState } from 'react';
import { useHistory } from 'umi';
import AreasModal from './modal/AreasModal';
@ -36,18 +36,23 @@ const AreasManage: React.FC<{}> = () => {
const closeAreasModal = () => {
setVisible(false);
}
//删除
const deleteAreas = async(id: string) => {
await deleteAreasInfo(id).then((res) => {
if (res?.success) {
message.success('删除成功');
}
})
.finally(()=>{
actionRef?.current?.reload();
});
//删除区域
const deleteAreas = async (id: string) => {
const hide = message.loading('正在删除');
try {
const success = await deleteAreasInfo(id).then((res) => {
return res.success
});
hide();
if (success) {
message.success('删除成功');
}
} catch (error) {
hide();
message.error('删除失败请重试!');
actionRef.current?.reload();
}
}
const columns: ProColumns<any>[] = [
{
title: '序号',
@ -122,15 +127,20 @@ const AreasManage: React.FC<{}> = () => {
>
</Button>
<Button
key="deleteAreas"
type="text"
onClick={() =>
deleteAreas(record.id)
}
<Popconfirm
placement="topRight"
title={"确定删除么?"}
onConfirm={async () => {
spinSet(true)
await deleteAreas(record.id);
actionRef.current?.reload();
spinSet(false)
}}
okText="确定"
cancelText="取消"
>
</Button>
<Button type='text' ></Button>
</Popconfirm>
</>
)
},

View File

@ -1,6 +1,6 @@
import { isNotEmpty } from '@/utils/CommonUtils';
import ProTable, { ActionType, ProColumns } from '@ant-design/pro-table';
import { Button, Spin, message } from 'antd';
import { Button, Spin, message, Popconfirm } from 'antd';
import React, { useRef, useState } from 'react';
import { useHistory } from 'umi';
import PlaceModal from './modal/PlaceModal';
@ -59,18 +59,22 @@ const PlaceManage: React.FC<{}> = () => {
const closePlaceModal = () => {
setVisible(false);
}
//删除
const deletePlace = async(id: string) => {
await deletePlaceInfo(id).then((res) => {
if (res?.success) {
message.success('删除成功');
}
})
.catch(e => {
message.error('删除失败');
}).finally(()=>{
actionRef?.current?.reload();
});
//删除场所
const deletePlace = async (id: string) => {
const hide = message.loading('正在删除');
try {
const success = await deletePlaceInfo(id).then((res) => {
return res.success
});
hide();
if (success) {
message.success('删除成功');
}
} catch (error) {
hide();
message.error('删除失败请重试!');
actionRef.current?.reload();
}
}
const columns: ProColumns<any>[] = [
{
@ -181,15 +185,20 @@ const PlaceManage: React.FC<{}> = () => {
>
</Button>
<Button
key="deletePlace"
type="text"
onClick={() =>
deletePlace(record.id)
}
<Popconfirm
placement="topRight"
title={"确定删除么?"}
onConfirm={async () => {
spinSet(true)
await deletePlace(record.id);
actionRef.current?.reload();
spinSet(false)
}}
okText="确定"
cancelText="取消"
>
</Button>
<Button type='text' ></Button>
</Popconfirm>
</>
)
},