Skip to content

Commit

Permalink
feat(设备分组): 设备分组重构
Browse files Browse the repository at this point in the history
树形分组

re #214
  • Loading branch information
Lind-pro committed Oct 10, 2020
1 parent 0f99498 commit 6bf552e
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 3 deletions.
4 changes: 2 additions & 2 deletions config/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
export default {
dev: {
'/jetlinks': {
target: 'http://192.168.3.183:8844/',
ws: 'ws://192.168.3.183:8844/',
target: 'http://192.168.3.146:8844/',
ws: 'ws://192.168.3.146:8844/',
// target: 'http://water.zlkjhb.com:9000/jetlinks',
// ws: 'http://water.zlkjhb.com:9000/jetlinks',
// ws: 'ws://demo.jetlinks.cn/jetlinks',
Expand Down
6 changes: 6 additions & 0 deletions config/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ export const routes = [
iconfont: 'icon-shebeifenzuguanli',
component: './device/group',
},
{
path: '/device/tree',
name: '设备树',
icon: 'gold',
component: './device/tree'
},
{
hideInMenu: true,
path: '/device/instance/add',
Expand Down
58 changes: 58 additions & 0 deletions src/pages/device/tree/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { PageHeaderWrapper } from "@ant-design/pro-layout";
import { Card, Col, Divider, Icon, Row, Table } from "antd";
import React, { Fragment, useEffect, useState } from "react";
import Service from "./service";

interface Props { }
const DeviceTree: React.FC<Props> = (props) => {

const [data, setData] = useState<any[]>([]);
const service = new Service('device');

useEffect(() => {
service.groupTree({}).subscribe((resp) => {
setData(resp);
})
}, []);
return (
<PageHeaderWrapper title="设备分组">
<Card>
<Row gutter={24}>
<Col span={8}>
<Table
key="id"
dataSource={data}
size="small"
columns={[
{ title: '序号', dataIndex: 'id' },
{ title: '名称', dataIndex: 'name' },
{
title: '操作', render: (_, record) => (
<Fragment>
<Icon type="edit" />
<Divider type="vertical" />
<Icon type="plus" />
<Divider type="vertical" />
<Icon type="close" />
</Fragment>
)
}
]} />
</Col>
<Col span={16}>
<Table
size="small"
columns={[
{ title: '序号', dataIndex: 'id' },
{ title: '名称', dataIndex: 'name' },
{ title: '状态', dataIndex: 'status' },
{ title: '操作', }
]}
/>
</Col>
</Row>
</Card>
</PageHeaderWrapper>
)
}
export default DeviceTree;
19 changes: 19 additions & 0 deletions src/pages/device/tree/service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import BaseService from "@/services/crud";
import request from "@/utils/request";
import { defer, from } from "rxjs";
import { map } from "rxjs/operators";



class Service extends BaseService<any>{

public groupTree = (param: any) => defer(
() => from(request(`/jetlinks/device/group/_query/tree`, {
method: 'GET',
})).pipe(
map(resp => resp.result)
));

}

export default Service;
1 change: 0 additions & 1 deletion src/pages/user/login2/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ interface Props {
const Login: React.FC<Props> = props => {
const { dispatch, settings, location: { query } } = props;

console.log(location, query.code, 'local');
const service = new Service('');
const [username, setUsername] = useState<string>('');
const [password, setPassword] = useState<string>('');
Expand Down

0 comments on commit 6bf552e

Please sign in to comment.