|
@@ -0,0 +1,107 @@
|
|
|
+import React, { Fragment } from 'react';
|
|
|
+import { Table, Typography, Row, Badge, Divider } from 'antd';
|
|
|
+import { DeviceSearch } from '../../components/search';
|
|
|
+import { ColumnProps } from 'antd/lib/table';
|
|
|
+import {
|
|
|
+ useHeadMastList,
|
|
|
+ DustStatus,
|
|
|
+ DustRecordProps,
|
|
|
+ DevicestateKeys,
|
|
|
+ DustState,
|
|
|
+} from '../../services/headMast';
|
|
|
+const { Text } = Typography;
|
|
|
+const colums: ColumnProps<DustRecordProps>[] = [
|
|
|
+ {
|
|
|
+ title: '项目名',
|
|
|
+ dataIndex: 'project_name',
|
|
|
+ key: 'project_name',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '供应商',
|
|
|
+ dataIndex: 'provider_name',
|
|
|
+ key: 'provider_name',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '设备名',
|
|
|
+ dataIndex: 'name',
|
|
|
+ key: 'name',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '设备唯一编码',
|
|
|
+ dataIndex: 'sn',
|
|
|
+ key: 'sn',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '生产厂家',
|
|
|
+ dataIndex: 'manufacturer',
|
|
|
+ key: 'manufacturer',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '入库时间',
|
|
|
+ dataIndex: 'approve_time',
|
|
|
+ key: 'approve_time',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '状态',
|
|
|
+ dataIndex: 'state',
|
|
|
+ key: 'state',
|
|
|
+ render: (dataIndex: 0 | 1, record) => {
|
|
|
+ const isOnline = DevicestateKeys.onLine === dataIndex;
|
|
|
+ return record.status === 1 ? (
|
|
|
+ <Fragment>
|
|
|
+ <Badge color={isOnline ? 'green' : 'red'}></Badge>
|
|
|
+ <Text type={isOnline ? 'success' : 'secondary'}>
|
|
|
+ {DustState[dataIndex]}
|
|
|
+ </Text>
|
|
|
+ </Fragment>
|
|
|
+ ) : null;
|
|
|
+ },
|
|
|
+ },
|
|
|
+];
|
|
|
+const dust: React.FC = (props) => {
|
|
|
+ const [searchState, setSearchState] = React.useState({
|
|
|
+ filter: '',
|
|
|
+ state: -1,
|
|
|
+ project_id: -1,
|
|
|
+ page: 1,
|
|
|
+ });
|
|
|
+ const [deviceListState, requestDevices] = useHeadMastList();
|
|
|
+ React.useEffect(() => {
|
|
|
+ requestDevices(searchState);
|
|
|
+ }, [searchState]);
|
|
|
+
|
|
|
+ const handleSearch = (values) => {
|
|
|
+ setSearchState((preState) => ({
|
|
|
+ ...preState,
|
|
|
+ page: 1,
|
|
|
+ ...{ state: -1, project_id: -1, ...values },
|
|
|
+ }));
|
|
|
+ };
|
|
|
+ return (
|
|
|
+ <div>
|
|
|
+ <Row gutter={[0, 24]}>
|
|
|
+ <DeviceSearch onSearch={handleSearch}/>
|
|
|
+ </Row>
|
|
|
+ <Divider/>
|
|
|
+ <Table
|
|
|
+ rowKey={(record) => record.id}
|
|
|
+ pagination={{
|
|
|
+ showSizeChanger: false,
|
|
|
+ hideOnSinglePage: true,
|
|
|
+ current: deviceListState.page,
|
|
|
+ total: deviceListState.total,
|
|
|
+ onChange: (page) => {
|
|
|
+ setSearchState((preState) => ({
|
|
|
+ ...preState,
|
|
|
+ page,
|
|
|
+ }));
|
|
|
+ },
|
|
|
+ }}
|
|
|
+ columns={colums}
|
|
|
+ loading={deviceListState.loading}
|
|
|
+ dataSource={deviceListState.dataSource}/>
|
|
|
+ </div>
|
|
|
+ );
|
|
|
+};
|
|
|
+
|
|
|
+export default dust;
|