|
|
@@ -2,10 +2,9 @@ import SearchComponent from '@/components/SearchComponent';
|
|
|
import { getMenuPathByCode, MENUS_CODE } from '@/utils/menu';
|
|
|
import { CheckCircleOutlined, DeleteOutlined, EditOutlined, StopOutlined } from '@ant-design/icons';
|
|
|
import { PageContainer } from '@ant-design/pro-layout';
|
|
|
-import ProList from '@jetlinks/pro-list';
|
|
|
import type { ProColumns } from '@jetlinks/pro-table';
|
|
|
-import { Badge, Button, Card, message, Popconfirm } from 'antd';
|
|
|
-import { useState } from 'react';
|
|
|
+import { Badge, Button, Card, Col, message, Pagination, Popconfirm, Row } from 'antd';
|
|
|
+import { useEffect, useState } from 'react';
|
|
|
import { useHistory } from 'umi';
|
|
|
import styles from './index.less';
|
|
|
import Service from './service';
|
|
|
@@ -14,41 +13,35 @@ export const service = new Service('gateway/device');
|
|
|
|
|
|
const AccessConfig = () => {
|
|
|
const history = useHistory();
|
|
|
- const [param, setParam] = useState({});
|
|
|
- // const actionRef = useRef<ActionType>();
|
|
|
+ const [param, setParam] = useState<any>({ pageSize: 10 });
|
|
|
|
|
|
const columns: ProColumns<any>[] = [
|
|
|
{
|
|
|
title: '名称',
|
|
|
dataIndex: 'name',
|
|
|
},
|
|
|
- // {
|
|
|
- // title: '状态',
|
|
|
- // dataIndex: 'state',
|
|
|
- // align: 'center',
|
|
|
- // valueType: 'select',
|
|
|
- // valueEnum: {
|
|
|
- // // 1: {
|
|
|
- // // text: intl.formatMessage({
|
|
|
- // // id: 'pages.searchTable.titleStatus.normal',
|
|
|
- // // defaultMessage: '正常',
|
|
|
- // // }),
|
|
|
- // // status: 1,
|
|
|
- // // },
|
|
|
- // // 0: {
|
|
|
- // // text: intl.formatMessage({
|
|
|
- // // id: 'pages.searchTable.titleStatus.disable',
|
|
|
- // // defaultMessage: '禁用',
|
|
|
- // // }),
|
|
|
- // // status: 0,
|
|
|
- // // },
|
|
|
- // },
|
|
|
- // render: (text, record) => (
|
|
|
- // <Badge status={record.status === 1 ? 'success' : 'error'} text={text} />
|
|
|
- // ),
|
|
|
- // },
|
|
|
];
|
|
|
|
|
|
+ const [dataSource, setDataSource] = useState<any>({
|
|
|
+ data: [],
|
|
|
+ pageSize: 10,
|
|
|
+ pageIndex: 0,
|
|
|
+ total: 0,
|
|
|
+ });
|
|
|
+
|
|
|
+ const handleSearch = (params: any) => {
|
|
|
+ setParam(params);
|
|
|
+ service
|
|
|
+ .queryList({ ...params, sorts: [{ name: 'createTime', order: 'desc' }] })
|
|
|
+ .then((resp) => {
|
|
|
+ setDataSource(resp.result);
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ handleSearch(param);
|
|
|
+ }, []);
|
|
|
+
|
|
|
return (
|
|
|
<PageContainer>
|
|
|
<Card>
|
|
|
@@ -56,12 +49,14 @@ const AccessConfig = () => {
|
|
|
field={columns}
|
|
|
pattern={'simple'}
|
|
|
onSearch={(data: any) => {
|
|
|
- setParam(data);
|
|
|
- // actionRef.current?.reset?.();
|
|
|
+ const dt = {
|
|
|
+ pageSize: 10,
|
|
|
+ terms: [...data.terms],
|
|
|
+ };
|
|
|
+ handleSearch(dt);
|
|
|
}}
|
|
|
onReset={() => {
|
|
|
- setParam({});
|
|
|
- // actionRef.current?.reset?.();
|
|
|
+ handleSearch({ pageSize: 10 });
|
|
|
}}
|
|
|
/>
|
|
|
<div style={{ width: '100%', display: 'flex', justifyContent: 'flex-end' }}>
|
|
|
@@ -74,126 +69,135 @@ const AccessConfig = () => {
|
|
|
新增
|
|
|
</Button>
|
|
|
</div>
|
|
|
- <ProList<any>
|
|
|
- pagination={{
|
|
|
- defaultPageSize: 8,
|
|
|
- showSizeChanger: false,
|
|
|
- }}
|
|
|
- showActions="always"
|
|
|
- rowKey="id"
|
|
|
- // actionRef={actionRef}
|
|
|
- request={async (data) =>
|
|
|
- service.queryList({ ...param, ...data, sorts: [{ name: 'createTime', order: 'desc' }] })
|
|
|
- }
|
|
|
- grid={{ gutter: 16, column: 2 }}
|
|
|
- showExtra="always"
|
|
|
- metas={{
|
|
|
- title: {
|
|
|
- dataIndex: 'name',
|
|
|
- render: (text, row) => (
|
|
|
- <div style={{ fontSize: 16, width: '70%' }}>
|
|
|
- <div>
|
|
|
- {text}
|
|
|
- <Badge
|
|
|
- color={row.state.value === 'disabled' ? 'red' : 'green'}
|
|
|
- text={row.state.text}
|
|
|
- style={{ marginLeft: '20px' }}
|
|
|
- />
|
|
|
- </div>
|
|
|
- <div className={styles.desc}>{row.describe}</div>
|
|
|
- </div>
|
|
|
- ),
|
|
|
- },
|
|
|
- avatar: {
|
|
|
- render: (text, reocrd) => <div className={styles.images}>{reocrd.name}</div>,
|
|
|
- },
|
|
|
- subTitle: {
|
|
|
- render: () => <div></div>,
|
|
|
- },
|
|
|
- content: {
|
|
|
- render: (text, row) => (
|
|
|
- <div className={styles.content}>
|
|
|
- <div className={styles.server}>
|
|
|
- <div className={styles.title}>{row?.channelInfo?.name}</div>
|
|
|
- <p>
|
|
|
- {row.channelInfo?.addresses.map((item: any) => (
|
|
|
- <div key={item.address}>
|
|
|
- <Badge color={'green'} text={item.address} />
|
|
|
+ <Row gutter={[16, 16]} style={{ marginTop: 10 }}>
|
|
|
+ {dataSource.data.map((item: any) => (
|
|
|
+ <Col key={item.name} span={12}>
|
|
|
+ <Card hoverable>
|
|
|
+ <div className={styles.box}>
|
|
|
+ <div className={styles.images}>{item.name}</div>
|
|
|
+ <div className={styles.content}>
|
|
|
+ <div className={styles.header}>
|
|
|
+ <div className={styles.top}>
|
|
|
+ <div className={styles.left}>
|
|
|
+ <div className={styles.title}>{item.name}</div>
|
|
|
+ <div className={styles.status}>
|
|
|
+ <Badge
|
|
|
+ color={item.state.value === 'disabled' ? 'red' : 'green'}
|
|
|
+ text={item.state.text}
|
|
|
+ style={{ marginLeft: '20px' }}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- ))}
|
|
|
- </p>
|
|
|
- </div>
|
|
|
- <div className={styles.procotol}>
|
|
|
- <div className={styles.title}>{row?.protocolDetail?.name}</div>
|
|
|
- <p style={{ color: 'rgba(0, 0, 0, .55)' }}>{row.description}</p>
|
|
|
+ <div className={styles.action}>
|
|
|
+ <a
|
|
|
+ key="edit"
|
|
|
+ onClick={() => {
|
|
|
+ history.push(
|
|
|
+ `${getMenuPathByCode(MENUS_CODE['link/AccessConfig/Detail'])}?id=${
|
|
|
+ item.id
|
|
|
+ }`,
|
|
|
+ );
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <EditOutlined />
|
|
|
+ 编辑
|
|
|
+ </a>
|
|
|
+ <a key="warning">
|
|
|
+ <Popconfirm
|
|
|
+ title={`确认${item.state.value !== 'disabled' ? '禁用' : '启用'}`}
|
|
|
+ onConfirm={() => {
|
|
|
+ if (item.state.value !== 'disabled') {
|
|
|
+ service.shutDown(item.id).then((resp) => {
|
|
|
+ if (resp.status === 200) {
|
|
|
+ message.success('操作成功!');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ service.startUp(item.id).then((resp) => {
|
|
|
+ if (resp.status === 200) {
|
|
|
+ message.success('操作成功!');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {item.state.value !== 'disabled' ? (
|
|
|
+ <span>
|
|
|
+ <StopOutlined />
|
|
|
+ 禁用
|
|
|
+ </span>
|
|
|
+ ) : (
|
|
|
+ <span>
|
|
|
+ <CheckCircleOutlined />
|
|
|
+ 启用
|
|
|
+ </span>
|
|
|
+ )}
|
|
|
+ </Popconfirm>
|
|
|
+ </a>
|
|
|
+ <a key="remove">
|
|
|
+ <Popconfirm
|
|
|
+ title={'确认删除?'}
|
|
|
+ onConfirm={() => {
|
|
|
+ service.remove(item.id).then((resp: any) => {
|
|
|
+ if (resp.status === 200) {
|
|
|
+ message.success('操作成功!');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <DeleteOutlined />
|
|
|
+ 删除
|
|
|
+ </Popconfirm>
|
|
|
+ </a>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div className={styles.desc}>这里是接入方式的解释说明</div>
|
|
|
+ </div>
|
|
|
+ <div className={styles.container}>
|
|
|
+ <div className={styles.server}>
|
|
|
+ <div className={styles.title}>{item?.channelInfo?.name}</div>
|
|
|
+ <p>
|
|
|
+ {item.channelInfo?.addresses.map((i: any) => (
|
|
|
+ <div key={i.address}>
|
|
|
+ <Badge color={i.health === -1 ? 'red' : 'green'} text={i.address} />
|
|
|
+ </div>
|
|
|
+ ))}
|
|
|
+ </p>
|
|
|
+ </div>
|
|
|
+ <div className={styles.procotol}>
|
|
|
+ <div className={styles.title}>{item?.protocolDetail?.name}</div>
|
|
|
+ <p style={{ color: 'rgba(0, 0, 0, .55)' }}>{item.description}</p>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- ),
|
|
|
- },
|
|
|
- actions: {
|
|
|
- render: (text, row) => [
|
|
|
- <a
|
|
|
- key="edit"
|
|
|
- onClick={() => {
|
|
|
- history.push(
|
|
|
- `${getMenuPathByCode(MENUS_CODE['link/AccessConfig/Detail'])}?id=${row.id}`,
|
|
|
- );
|
|
|
- }}
|
|
|
- >
|
|
|
- <EditOutlined />
|
|
|
- 编辑
|
|
|
- </a>,
|
|
|
- <a key="warning">
|
|
|
- <Popconfirm
|
|
|
- title={`确认${row.state.value !== 'disabled' ? '禁用' : '启用'}`}
|
|
|
- onConfirm={() => {
|
|
|
- if (row.state.value !== 'disabled') {
|
|
|
- service.shutDown(row.id).then((resp) => {
|
|
|
- if (resp.status === 200) {
|
|
|
- message.success('操作成功!');
|
|
|
- }
|
|
|
- });
|
|
|
- } else {
|
|
|
- service.startUp(row.id).then((resp) => {
|
|
|
- if (resp.status === 200) {
|
|
|
- message.success('操作成功!');
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- }}
|
|
|
- >
|
|
|
- {row.state.value !== 'disabled' ? (
|
|
|
- <span>
|
|
|
- <StopOutlined />
|
|
|
- 禁用
|
|
|
- </span>
|
|
|
- ) : (
|
|
|
- <span>
|
|
|
- <CheckCircleOutlined />
|
|
|
- 启用
|
|
|
- </span>
|
|
|
- )}
|
|
|
- </Popconfirm>
|
|
|
- </a>,
|
|
|
- <a key="remove">
|
|
|
- <Popconfirm
|
|
|
- title={'确认删除?'}
|
|
|
- onConfirm={() => {
|
|
|
- service.remove(row.id).then((resp: any) => {
|
|
|
- if (resp.status === 200) {
|
|
|
- message.success('操作成功!');
|
|
|
- }
|
|
|
- });
|
|
|
- }}
|
|
|
- >
|
|
|
- <DeleteOutlined />
|
|
|
- 删除
|
|
|
- </Popconfirm>
|
|
|
- </a>,
|
|
|
- ],
|
|
|
- },
|
|
|
- }}
|
|
|
- />
|
|
|
+ </Card>
|
|
|
+ </Col>
|
|
|
+ ))}
|
|
|
+ </Row>
|
|
|
+ <div style={{ display: 'flex', marginTop: 20, justifyContent: 'flex-end' }}>
|
|
|
+ <Pagination
|
|
|
+ showSizeChanger
|
|
|
+ size="small"
|
|
|
+ className={'pro-table-card-pagination'}
|
|
|
+ total={dataSource?.total || 0}
|
|
|
+ current={dataSource?.pageIndex + 1}
|
|
|
+ onChange={(page, size) => {
|
|
|
+ handleSearch({
|
|
|
+ ...param,
|
|
|
+ pageIndex: page - 1,
|
|
|
+ pageSize: size,
|
|
|
+ });
|
|
|
+ }}
|
|
|
+ pageSizeOptions={[10, 20, 50, 100]}
|
|
|
+ pageSize={dataSource?.pageSize}
|
|
|
+ showTotal={(num) => {
|
|
|
+ const minSize = dataSource?.pageIndex * dataSource?.pageSize + 1;
|
|
|
+ const MaxSize = (dataSource?.pageIndex + 1) * dataSource?.pageSize;
|
|
|
+ return `第 ${minSize} - ${MaxSize > num ? num : MaxSize} 条/总共 ${num} 条`;
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
</Card>
|
|
|
</PageContainer>
|
|
|
);
|