Skip to content

Commit

Permalink
fix(多租户): 多租户资产信息
Browse files Browse the repository at this point in the history
多租户资产界面数据展示
  • Loading branch information
Lind-pro committed Jun 17, 2020
1 parent d8bed93 commit 633d51c
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const Add = (props: Props) => {

service.member.query(data.id, {}).subscribe(resp => {
setUserList(resp.data);
console.log(resp, 'res');
});
}, []);

Expand All @@ -48,10 +47,10 @@ const Add = (props: Props) => {
assetIdList: selectedAssetsId,
allPermission: true,
}));
console.log(selectedAssetsId, checkedUserList, 'dddata');
service.assets.bind(data.id, bindData).subscribe(resp => {
service.assets.bind(data.id, bindData).subscribe(() => {
setLoading(false);
message.success('绑定成功')
message.success('绑定成功');
props.close();
});
}
const rowSelection = {
Expand Down
23 changes: 17 additions & 6 deletions src/pages/system/tenant/components/assets/device/edit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ const Edit = (props: Props) => {
const { data } = props;
const [cat, setCat] = useState<boolean>(false);
const [asset, setAsset] = useState();
useEffect(() => {
console.log(data, 'dddd');
const handleSearch = () => {
service.assets.device(encodeQueryParam({
terms: {
id$assets: JSON.stringify({
Expand All @@ -32,6 +31,9 @@ const Edit = (props: Props) => {
})).subscribe(resp => {
setList(resp);
})
}
useEffect(() => {
handleSearch();
}, []);
const rowSelection = {
onChange: (selectedRowKeys: any[], selectedRows: any[]) => {
Expand Down Expand Up @@ -84,7 +86,10 @@ const Edit = (props: Props) => {
}
]}
/>
<Button onClick={() => setAdd(true)}>添加</Button>
<Button
type="primary"
style={{ marginBottom: 10 }}
onClick={() => setAdd(true)}>添加</Button>
<Table
rowKey="id"
rowSelection={rowSelection}
Expand All @@ -110,16 +115,22 @@ const Edit = (props: Props) => {
>
关闭
</Button>
<Button
{/* <Button
onClick={() => {
// autzSetting();
}}
type="primary"
>
保存
</Button>
</Button> */}
</div>
{add && <Add data={data} close={() => setAdd(false)} />}
{add && (
<Add
data={data} close={() => {
setAdd(false);
handleSearch();
}} />
)}
{cat && <User asset={asset} close={() => setCat(false)} />}
</Drawer>
)
Expand Down
15 changes: 10 additions & 5 deletions src/pages/system/tenant/components/assets/device/index.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
import React, { useState, useContext, useEffect } from "react";
import { List, Card, Tooltip, Icon } from "antd";
import { router } from "umi";
import encodeQueryParam from "@/utils/encodeParam";
import IconFont from "@/components/IconFont";
import styles from '../index.less';
import Edit from "./edit";
import { TenantContext } from "../../../detail";
import Service from "../../../service";
import encodeQueryParam from "@/utils/encodeParam";
import IconFont from "@/components/IconFont";


const Device = () => {
const avatar = 'https://tse2-mm.cn.bing.net/th/id/OIP.T1lmAIkITnIiwRmQMiUnjAAAAA?pid=Api&rs=1';
const [visible, setVisible] = useState<boolean>(false);
const data = useContext(TenantContext);
const service = new Service('tenant');

const [active, setActive] = useState(0);
const [notActive, setNotActive] = useState(0);
useEffect(() => {
const getData = () => {
service.assets.deviceCount(encodeQueryParam({
terms: {
id$assets: JSON.stringify({
Expand All @@ -42,6 +41,9 @@ const Device = () => {
})).subscribe(resp => {
setActive(resp)
})
}
useEffect(() => {
getData();
}, []);

return (
Expand Down Expand Up @@ -86,7 +88,10 @@ const Device = () => {
{visible && (
<Edit
data={data}
close={() => setVisible(false)} />
close={() => {
setVisible(false);
getData();
}} />
)}
</List.Item>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,17 @@ const Add = (props: Props) => {
assetIdList: selectedAssetsId,
allPermission: true,
}));
console.log(selectedAssetsId, checkedUserList, 'dddata');
service.assets.bind(data.id, bindData).subscribe(resp => {
console.log(checkedUserList.length, bindData, 'jjj');
if (checkedUserList.length === 0) {
message.error('请选择成员');
setLoading(false);
message.success('绑定成功')
});
} else {
service.assets.bind(data.id, bindData).subscribe(resp => {
setLoading(false);
message.success('添加成功')
props.close();
});
}
}
const rowSelection = {
onChange: (selectedRowKeys: any[], selectedRows: any[]) => {
Expand Down
24 changes: 18 additions & 6 deletions src/pages/system/tenant/components/assets/product/edit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ const Edit = (props: Props) => {
const [cat, setCat] = useState<boolean>(false);
const [asset, setAsset] = useState();
const { data } = props;
useEffect(() => {
console.log(data, 'dddd');

const handleSearch = () => {
service.assets.product(encodeQueryParam({
terms: {
id$assets: JSON.stringify({
Expand All @@ -32,6 +32,9 @@ const Edit = (props: Props) => {
})).subscribe(resp => {
setList(resp);
})
}
useEffect(() => {
handleSearch()
}, []);
const rowSelection = {
onChange: (selectedRowKeys: any[], selectedRows: any[]) => {
Expand Down Expand Up @@ -85,7 +88,10 @@ const Edit = (props: Props) => {
}
]}
/>
<Button onClick={() => setAdd(true)}>添加</Button>
<Button
type="primary"
style={{ marginBottom: 10 }}
onClick={() => setAdd(true)}>添加</Button>
<Table
rowKey="id"
rowSelection={rowSelection}
Expand All @@ -111,16 +117,22 @@ const Edit = (props: Props) => {
>
关闭
</Button>
<Button
{/* <Button
onClick={() => {
// autzSetting();
}}
type="primary"
>
保存
</Button>
</Button> */}
</div>
{add && <Add data={data} close={() => setAdd(false)} />}
{add && (
<Add data={data}
close={() => {
setAdd(false);
handleSearch();
}} />
)}
{cat && <User asset={asset} close={() => setCat(false)} />}
</Drawer>
)
Expand Down
15 changes: 10 additions & 5 deletions src/pages/system/tenant/components/assets/product/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import React, { useState, useContext, useEffect } from "react";
import { List, Card, Tooltip, Icon } from "antd";
import { router } from "umi";
import encodeQueryParam from "@/utils/encodeParam";
import IconFont from "@/components/IconFont";
import styles from '../index.less';
import Edit from "./edit";
import { TenantContext } from "../../../detail";
import Service from "../../../service";
import encodeQueryParam from "@/utils/encodeParam";
import IconFont from "@/components/IconFont";

const Product = () => {
const avatar = 'https://tse2-mm.cn.bing.net/th/id/OIP.T1lmAIkITnIiwRmQMiUnjAAAAA?pid=Api&rs=1';
const [visible, setVisible] = useState<boolean>(false);
const data = useContext(TenantContext);

Expand All @@ -18,7 +17,7 @@ const Product = () => {
const [pub, setPub] = useState(0);
const [unPub, setUnPub] = useState(0)

useEffect(() => {
const getData = () => {

service.assets.productCount(encodeQueryParam({
terms: {
Expand All @@ -44,6 +43,9 @@ const Product = () => {
})).subscribe(resp => {
setUnPub(resp)
})
}
useEffect(() => {
getData();
}, [])
return (
<List.Item style={{ paddingRight: '10px' }}>
Expand Down Expand Up @@ -88,7 +90,10 @@ const Product = () => {

<Edit
data={data}
close={() => setVisible(false)} />
close={() => {
setVisible(false);
getData();
}} />
)}
</List.Item>
)
Expand Down

0 comments on commit 633d51c

Please sign in to comment.