Commit 2612d05e by zhaochengxiang

资产

parent d3e7851b
...@@ -59,8 +59,9 @@ const AssetAction = (props) => { ...@@ -59,8 +59,9 @@ const AssetAction = (props) => {
const columns = [ const columns = [
{ {
title: '技术ID', title: '技术ID(英文名称)',
dataIndex: 'name', dataIndex: 'name',
width: 200,
ellipsis: true, ellipsis: true,
render: (text, record, _) => { render: (text, record, _) => {
return ( return (
...@@ -77,7 +78,7 @@ const AssetAction = (props) => { ...@@ -77,7 +78,7 @@ const AssetAction = (props) => {
{ {
title: '名称', title: '名称',
dataIndex: 'cnName', dataIndex: 'cnName',
width: 100, width: 200,
ellipsis: true, ellipsis: true,
}, },
{ {
......
...@@ -13,7 +13,7 @@ const AssetDetailDrawer = (props) => { ...@@ -13,7 +13,7 @@ const AssetDetailDrawer = (props) => {
forceRender forceRender
visible={ visible } visible={ visible }
title='资产详情' title='资产详情'
width='80%' width='90%'
placement="right" placement="right"
closable={ true } closable={ true }
onClose={() => { onClose={() => {
......
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
import { Modal, Button, Space, Tree, Row, Col, Table, Pagination } from "antd"; import { Modal, Button, Space, Tree, Row, Col, Table, Pagination, Select, Input, Divider, Spin } from "antd";
import { getAttributesByMetadataModel } from "../../../../service/dataassetmanager"; import { getAttributesByMetadataModel } from "../../../../service/dataassetmanager";
import { dispatch } from '../../../../model'; import { dispatch } from '../../../../model';
import { showMessage } from "../../../../util"; import { showMessage } from "../../../../util";
import useDebounce from "../../../../layout/useDebounce";
const options = [
{ name: '基础数据名称', key: 'name' },
{ name: '基础数据编码', key: 'code' },
]
const FC = (props) => { const FC = (props) => {
const { visible, onCancel, id } = props; const { visible, onCancel, id } = props;
...@@ -11,11 +17,15 @@ const FC = (props) => { ...@@ -11,11 +17,15 @@ const FC = (props) => {
const [tableData, setTableData] = useState(undefined); const [tableData, setTableData] = useState(undefined);
const [total, setTotal] = useState(0); const [total, setTotal] = useState(0);
const [ pagination, setPagination ] = useState( { pageNum: 1, pageSize: 20 } ); const [ pagination, setPagination ] = useState( { pageNum: 1, pageSize: 20 } );
const [confirmLoading, setConfirmLoading] = useState(false); const [loadingTree, setLoadingTree] = useState(false);
const [loadingTable,setLoadingTable] = useState(false);
const [currentTreeParams, setCurrentTreeParams] = useState({ const [currentTreeParams, setCurrentTreeParams] = useState({
treeId: undefined, treeId: undefined,
dataType: undefined, dataType: undefined,
}); });
const [queryProperty, setQueryProperty] = useState(options[0].key);
const [keyword, setKeyword] = useState(undefined);
const debouncedKeyword = useDebounce(keyword, 300);
const { pageNum, pageSize } = pagination; const { pageNum, pageSize } = pagination;
...@@ -30,8 +40,8 @@ const FC = (props) => { ...@@ -30,8 +40,8 @@ const FC = (props) => {
ellipsis: true, ellipsis: true,
}, },
{ {
title: '标准中文名', title: '基础数据编码',
dataIndex: 'name', dataIndex: 'code',
ellipsis: true, ellipsis: true,
render: (text, record) => { render: (text, record) => {
return <a onClick={() => { return <a onClick={() => {
...@@ -42,8 +52,8 @@ const FC = (props) => { ...@@ -42,8 +52,8 @@ const FC = (props) => {
} }
}, },
{ {
title: '标准名称', title: '基础数据名称',
dataIndex: 'cnName', dataIndex: 'name',
ellipsis: true, ellipsis: true,
render: (text, record) => { render: (text, record) => {
return <a onClick={() => { return <a onClick={() => {
...@@ -62,12 +72,13 @@ const FC = (props) => { ...@@ -62,12 +72,13 @@ const FC = (props) => {
}, [visible]) }, [visible])
useEffect(() => { useEffect(() => {
if (currentTreeParams.treeId) { if (visible && currentTreeParams.treeId) {
getTableData(); getTableData();
} }
}, [pagination, currentTreeParams]) }, [visible, pagination, currentTreeParams, queryProperty, debouncedKeyword])
const getTreeData = () => { const getTreeData = () => {
setLoadingTree(true);
dispatch({ dispatch({
type: 'assetmanage.getStandardTree', type: 'assetmanage.getStandardTree',
payload: { payload: {
...@@ -76,6 +87,7 @@ const FC = (props) => { ...@@ -76,6 +87,7 @@ const FC = (props) => {
parentClass: 'Catalog' parentClass: 'Catalog'
}, },
callback: data => { callback: data => {
setLoadingTree(false);
const filterData = data?.filter(item => item.name !== '草稿'); const filterData = data?.filter(item => item.name !== '草稿');
if (filterData && filterData.length > 0) { if (filterData && filterData.length > 0) {
...@@ -89,11 +101,15 @@ const FC = (props) => { ...@@ -89,11 +101,15 @@ const FC = (props) => {
} }
setTreeData(filterData); setTreeData(filterData);
},
error: () => {
setLoadingTree(false);
} }
}); });
} }
const getTableData = () => { const getTableData = () => {
setLoadingTable(true);
dispatch({ dispatch({
type: 'assetmanage.getStandardList', type: 'assetmanage.getStandardList',
payload: { payload: {
...@@ -101,17 +117,21 @@ const FC = (props) => { ...@@ -101,17 +117,21 @@ const FC = (props) => {
page: pageNum, page: pageNum,
size: pageSize, size: pageSize,
parentId: currentTreeParams.treeId, parentId: currentTreeParams.treeId,
keyword: '', keyword: debouncedKeyword,
queryProperty: 'name', queryProperty: queryProperty,
}, },
data: [`Catalog,StandardCatalog,${currentTreeParams.dataType}`] data: [`Catalog,StandardCatalog,${currentTreeParams.dataType}`]
}, },
callback: data => { callback: data => {
setLoadingTable(false);
data.content?.forEach(item => { data.content?.forEach(item => {
item.children = null; item.children = null;
}); });
setTableData(data.content); setTableData(data.content);
setTotal(data.totalElements); setTotal(data.totalElements);
},
error: () => {
setLoadingTable(false);
} }
}); });
} }
...@@ -145,10 +165,30 @@ const FC = (props) => { ...@@ -145,10 +165,30 @@ const FC = (props) => {
} }
} }
const onSelectChange = (value) => {
setQueryProperty(value);
}
const onSearchChange = (e) => {
setKeyword(e.target.value);
}
const changeCurrent = (page,size) => { const changeCurrent = (page,size) => {
setPagination({ pageNum: page, pageSize: size }); setPagination({ pageNum: page, pageSize: size });
} }
const reset = () => {
setLoadingTree(false);
setLoadingTable(false);
setCurrentTreeParams({
treeId: undefined,
dataType: undefined,
});
setQueryProperty(options[0].key);
setKeyword(undefined);
setPagination({ pageNum: 1, pageSize: 20 });
}
const loop = (data) => const loop = (data) =>
data?.map(item => { data?.map(item => {
if (item.children && item.children.length>0) { if (item.children && item.children.length>0) {
...@@ -164,16 +204,23 @@ const FC = (props) => { ...@@ -164,16 +204,23 @@ const FC = (props) => {
visible={ visible } visible={ visible }
centered centered
width='90%' width='90%'
onCancel={() => { onCancel?.(); } } onCancel={() => {
reset();
onCancel?.();
}}
footer={ footer={
<Space> <Space>
<Button onClick={() => onCancel?.() }>取消</Button> <Button onClick={() => {
reset();
onCancel?.();
}}>取消</Button>
</Space> </Space>
} }
bodyStyle={{ padding: '24px', height: '70vh', overflow: 'auto' }} bodyStyle={{ padding: '24px', height: '70vh', overflow: 'auto' }}
> >
<Row> <Row>
<Col span={6}> <Col span={5}>
<Spin spinning={loadingTree}>
<Tree <Tree
showLine={true} showLine={true}
showIcon={false} showIcon={false}
...@@ -181,12 +228,33 @@ const FC = (props) => { ...@@ -181,12 +228,33 @@ const FC = (props) => {
onSelect={onTreeSelect} onSelect={onTreeSelect}
selectedKeys={currentTreeParams.treeId ? [currentTreeParams.treeId]: undefined} selectedKeys={currentTreeParams.treeId ? [currentTreeParams.treeId]: undefined}
/> />
</Spin>
</Col> </Col>
<Col span={1}> <Col span={1}>
<div style={{ width: 1, height: 'calc(70vh - 48px)', backgroundColor: '#f0f0f0' }} ></div> <div style={{ width: 1, height: 'calc(70vh - 48px)', backgroundColor: '#f0f0f0' }} ></div>
</Col> </Col>
<Col span={17}> <Col span={18}>
<div>
<Space>
<Select
value={queryProperty}
onChange={onSelectChange}
style={{ width: 160 }}
>
{
options.map((option, index) => {
return (
<Select.Option key={index} value={option.key} >{option.name}</Select.Option>
)
})
}
</Select>
<Input value={keyword} onChange={onSearchChange} placeholder='请输入关键字' />
</Space>
</div>
<Divider style={{ margin: '10px 0' }} />
<Table <Table
loading={loadingTable}
columns={columns} columns={columns}
dataSource={tableData||[]} dataSource={tableData||[]}
rowKey='_id' rowKey='_id'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment