Commit 4584f8f6 by zhaochengxiang

资产管理

parent 229f5244
...@@ -43,6 +43,10 @@ export function* directoryImport(payload) { ...@@ -43,6 +43,10 @@ export function* directoryImport(payload) {
return yield call(service.directoryImport, payload); return yield call(service.directoryImport, payload);
} }
export function* assetImport(payload) {
return yield call(service.assetImport, payload);
}
export function* getDirectoryById(payload) { export function* getDirectoryById(payload) {
return yield call(service.getDirectoryById, payload); return yield call(service.getDirectoryById, payload);
} }
...@@ -52,6 +52,10 @@ export function directoryImport(payload) { ...@@ -52,6 +52,10 @@ export function directoryImport(payload) {
return filePost2("/dataassetmanager/directoryApi/import", payload) return filePost2("/dataassetmanager/directoryApi/import", payload)
} }
export function assetImport(payload) {
return filePost2("/dataassetmanager/dataAssetApi/import", payload);
}
export function getDirectoryById(payload) { export function getDirectoryById(payload) {
return GetJSON("/dataassetmanager/directoryApi/getDirectoryById", payload) return GetJSON("/dataassetmanager/directoryApi/getDirectoryById", payload)
} }
\ No newline at end of file
...@@ -16,9 +16,9 @@ const AssetDetail = (props)=>{ ...@@ -16,9 +16,9 @@ const AssetDetail = (props)=>{
footer={null} footer={null}
> >
<Descriptions size="small" column={2} bordered> <Descriptions size="small" column={2} bordered>
{boxDetail.basicAttrs&&boxDetail.basicAttrs[0]&&boxDetail.basicAttrs.map((data, index)=>{ {boxDetail.elements&&boxDetail.elements.map((element, index)=>{
return( return(
<Descriptions.Item key={index} label={data.key}>{data.value}</Descriptions.Item> <Descriptions.Item key={index} label={element.name}>{element.value}</Descriptions.Item>
) )
}) })
......
...@@ -5,7 +5,7 @@ import { showMessage } from '../../../../util'; ...@@ -5,7 +5,7 @@ import { showMessage } from '../../../../util';
const AssetModal = (props)=>{ const AssetModal = (props)=>{
const {handleCancle,visible,editBox,addType,attrBox,nodeId,attrBox2,setPageNumber,pageNumber} = props const {handleCancle,visible,editBox,addType,nodeId,attrBox,setPageNumber,pageNumber} = props
const [form] = Form.useForm() const [form] = Form.useForm()
const [saveLoad,setSaveLod] = useState(false) const [saveLoad,setSaveLod] = useState(false)
...@@ -16,27 +16,30 @@ const AssetModal = (props)=>{ ...@@ -16,27 +16,30 @@ const AssetModal = (props)=>{
//eslint-disable-next-line react-hooks/exhaustive-deps //eslint-disable-next-line react-hooks/exhaustive-deps
},[visible]) },[visible])
useEffect(()=>{ // useEffect(()=>{
if(attrBox2){ // if(attrBox){
reset() // reset()
} // }
//eslint-disable-next-line react-hooks/exhaustive-deps // //eslint-disable-next-line react-hooks/exhaustive-deps
},[attrBox2]) // },[attrBox])
const handleOk =async()=>{ const handleOk =async()=>{
setSaveLod(true) setSaveLod(true)
form.validateFields().then((value)=>{ form.validateFields().then((value)=>{
if(addType){ if(addType){
let attr = []
for (let key in value){ let elements = [...attrBox];
attr.push({'key':key,'value':value[key]}) (elements||[]).forEach((element) => {
} for (let key in value) {
let box= { if (key === element.name) {
"basicAttrs": attr, element.value = value[key];
} }
}
});
dispatch({ dispatch({
type: 'assetmanage.addOrUpdateDataAsset', type: 'assetmanage.addOrUpdateDataAsset',
payload: { params:{dirId: nodeId},data: box }, payload: { params:{dirId: nodeId},data: { elements } },
callback: data => { callback: data => {
setSaveLod(false) setSaveLod(false)
handleCancle() handleCancle()
...@@ -49,18 +52,18 @@ const AssetModal = (props)=>{ ...@@ -49,18 +52,18 @@ const AssetModal = (props)=>{
} }
}) })
}else{ }else{
let attr = [] let elements = [...attrBox];
for (let key in value){ (elements||[]).forEach((element) => {
attr.push({'key':key,'value':value[key]}) for (let key in value) {
} if (key === element.name) {
let box= { element.value = value[key];
"basicAttrs": attr, }
id:editBox.id }
});
}
dispatch({ dispatch({
type: 'assetmanage.addOrUpdateDataAsset', type: 'assetmanage.addOrUpdateDataAsset',
payload: { params:{dirId: nodeId},data: box }, payload: { params:{dirId: nodeId},data: { ...editBox, elements } },
callback: data => { callback: data => {
setSaveLod(false) setSaveLod(false)
setPageNumber({...pageNumber,rebuild:new Date().getTime()}) setPageNumber({...pageNumber,rebuild:new Date().getTime()})
...@@ -113,16 +116,19 @@ const AssetModal = (props)=>{ ...@@ -113,16 +116,19 @@ const AssetModal = (props)=>{
} }
> >
<Form {...formItemLayout} form={form}> <Form {...formItemLayout} form={form}>
{attrBox&&attrBox[0]&&attrBox.map((item,i)=>{ {attrBox.map((item,i)=>{
return(
<Form.Item return (
label={item.key} item.manualMaintain === '是' ?(
name={item.key} <Form.Item
key={`form${i}`} label={item.name}
initialValue={attrBox2[item.key]?attrBox2[item.key] :''} name={item.name}
> key={`form${i}`}
<Input /> initialValue={item.value||''}
</Form.Item> >
<Input />
</Form.Item>
) : null
) )
})} })}
</Form> </Form>
......
...@@ -4,13 +4,14 @@ import "./AssetTable.less" ...@@ -4,13 +4,14 @@ import "./AssetTable.less"
import {dispatch } from '../../../../model'; import {dispatch } from '../../../../model';
import AssetModal from "./AssetModal" import AssetModal from "./AssetModal"
import AssetDetail from "./AssetDetail" import AssetDetail from "./AssetDetail"
import ImportAsset from './ImportAsset';
import { showMessage } from '../../../../util'; import { showMessage } from '../../../../util';
const { Text } = Typography; const { Text } = Typography;
const AssetTable = (props) =>{ const AssetTable = (props) =>{
const {nodeId,} = props const {nodeId, node} = props
const [tableLoad,setTableLoad] = useState(false) const [tableLoad,setTableLoad] = useState(false)
const [attrBox,setAttrBox] = useState([]) const [attrBox,setAttrBox] = useState([])
...@@ -31,6 +32,7 @@ const AssetTable = (props) =>{ ...@@ -31,6 +32,7 @@ const AssetTable = (props) =>{
const [selectBox,setSelectBox] = useState([]) const [selectBox,setSelectBox] = useState([])
const [checkValue,setCheckValue] = useState(false) const [checkValue,setCheckValue] = useState(false)
const [ assetNames, setAssetNames ] = useState([]); const [ assetNames, setAssetNames ] = useState([]);
const [ importAssetVisible, setImportAssetVisible ] = useState(false);
useEffect(()=>{ useEffect(()=>{
getListBasicAttrs() getListBasicAttrs()
...@@ -62,11 +64,11 @@ const AssetTable = (props) =>{ ...@@ -62,11 +64,11 @@ const AssetTable = (props) =>{
type: 'assetmanage.listBasicAttrs', type: 'assetmanage.listBasicAttrs',
payload: null, payload: null,
callback: dataBox => { callback: dataBox => {
let box = {} // let box = {}
for(let item of dataBox){ // for(let item of dataBox){
box[item.key] = item.value // box[item.key] = item.value
} // }
setAttrBox2(box) // setAttrBox2(dataBox)
setAttrBox(dataBox) setAttrBox(dataBox)
}, },
error: () => { error: () => {
...@@ -82,10 +84,10 @@ const AssetTable = (props) =>{ ...@@ -82,10 +84,10 @@ const AssetTable = (props) =>{
payload: {dirId:nodeId,pageNum:page,pageSize:size,keyword:keyMessage!==''?keyMessage:undefined}, payload: {dirId:nodeId,pageNum:page,pageSize:size,keyword:keyMessage!==''?keyMessage:undefined},
callback: dataBox => { callback: dataBox => {
const _assetNames = []; const _assetNames = [];
(dataBox.data||[]).forEach((item) => { (dataBox.data||[]).forEach((table) => {
(item.basicAttrs||[]).forEach((attr) => { (table.elements||[]).forEach((element) => {
if (attr.key === '中文名称') { if (element.name === '中文名称') {
_assetNames.push(attr.value||''); _assetNames.push(element.value||'');
} }
}) })
}) })
...@@ -109,20 +111,16 @@ const AssetTable = (props) =>{ ...@@ -109,20 +111,16 @@ const AssetTable = (props) =>{
} }
const handleCancle=()=>{ const handleCancle=()=>{
let box = attrBox2 let box = [ ...attrBox];
for (let item of attrBox){ for (let element of box){
box[item.key] = '' element.value = ''
} }
setAttrBox2(box) setAttrBox(box);
setVisible({...visible,visible:false}) setVisible({...visible,visible:false})
} }
const edit = (data) =>{ const edit = (data) =>{
let box = attrBox2 setAttrBox(data.elements||[])
for (let item of data.basicAttrs){
box[item.key] = item.value
}
setAttrBox2(box)
setEditBox(data) setEditBox(data)
setVisible({addtype:false,visible:true}) setVisible({addtype:false,visible:true})
} }
...@@ -148,6 +146,14 @@ const AssetTable = (props) =>{ ...@@ -148,6 +146,14 @@ const AssetTable = (props) =>{
}) })
} }
const importAssets = () => {
setImportAssetVisible(true);
}
const exportAssets = () => {
window.open(`/api/dataassetmanager/dataAssetApi/export?parentPath=${node.path||''}`);
}
const more=(data)=>{ const more=(data)=>{
setVisible2({box:data,visible:true}) setVisible2({box:data,visible:true})
...@@ -211,6 +217,11 @@ const AssetTable = (props) =>{ ...@@ -211,6 +217,11 @@ const AssetTable = (props) =>{
} }
} }
const onImportAssetCancel = (refresh = false) => {
setImportAssetVisible(false);
refresh && getTable();
}
return( return(
<Card <Card
bordered={false} bordered={false}
...@@ -241,8 +252,8 @@ const AssetTable = (props) =>{ ...@@ -241,8 +252,8 @@ const AssetTable = (props) =>{
<Button type="primary" onClick={add}>新增</Button> <Button type="primary" onClick={add}>新增</Button>
<Button type="primary" danger onClick={dels} >删除</Button> <Button type="primary" danger onClick={dels} >删除</Button>
{/* <Button type="primary" >导入</Button> <Button type="primary" onClick={importAssets} >导入</Button>
<Button type="primary" >导出</Button> */} <Button type="primary" onClick={exportAssets} >导出</Button>
</Space> </Space>
</div> </div>
...@@ -270,11 +281,11 @@ const AssetTable = (props) =>{ ...@@ -270,11 +281,11 @@ const AssetTable = (props) =>{
} }
description={ description={
<Row> <Row>
{item.basicAttrs&&item.basicAttrs.map(data=>{ {item.elements&&item.elements.map(element=>{
return( return(
<Col md={6} key={data.key}> <Col md={6} key={element.id||''}>
<Text>{data.key}</Text> <Text>{element.name}</Text>
{data.value} {element.value}
</Col> </Col>
) )
}) })
...@@ -299,8 +310,13 @@ const AssetTable = (props) =>{ ...@@ -299,8 +310,13 @@ const AssetTable = (props) =>{
showTotal={total => `共 ${total} 条`} showTotal={total => `共 ${total} 条`}
/> />
</Checkbox.Group> </Checkbox.Group>
<AssetModal visible={visible.visible} attrBox2={attrBox2} editBox={editBox} addType={visible.addtype} handleCancle={handleCancle} attrBox={attrBox} nodeId={nodeId} setPageNumber={setPageNumber} pageNumber={pageNumber}/> <AssetModal visible={visible.visible} attrBox={attrBox} editBox={editBox} addType={visible.addtype} handleCancle={handleCancle} attrBox={attrBox} nodeId={nodeId} setPageNumber={setPageNumber} pageNumber={pageNumber}/>
<AssetDetail visible={visible2.visible} boxDetail={visible2.box} handleCancle={handleCancle2}/> <AssetDetail visible={visible2.visible} boxDetail={visible2.box} handleCancle={handleCancle2}/>
<ImportAsset
visible={importAssetVisible}
onCancel={onImportAssetCancel}
node = {node}
/>
{contextHolder} {contextHolder}
</Card> </Card>
) )
......
import React from 'react';
import { Modal, Button, Upload } from 'antd';
import { DownloadOutlined, UploadOutlined } from '@ant-design/icons';
import {dispatch } from '../../../../model';
class ImportAsset extends React.Component {
constructor() {
super();
this.state = {
fileList: [],
confirmLoading: false,
};
}
downloadTemplate = () => {
window.open("/api/dataassetmanager/dataAssetApi/getImportTemplate");
}
reset = () => {
this.setState({ fileList: [], confirmLoading: false });
}
onOk = () => {
const { node, onCancel } = this.props;
const { fileList } = this.state;
this.setState({ confirmLoading: true }, () => {
dispatch({
type: 'assetmanage.assetImport',
payload: { fileList: fileList[0], params: { parentPath: node.path||'' } },
callback: () => {
this.setState({ confirmLoading: false }, () => {
onCancel && onCancel(true);
});
},
error: () => {
this.setState({ confirmLoading: false });
}
});
});
}
render() {
const { visible, onCancel } = this.props;
const { fileList } = this.state;
const uploadProps = {
onRemove: file => {
const index = fileList.indexOf(file);
const newFileList = fileList.slice();
newFileList.splice(index, 1);
this.setState({ fileList: newFileList });
},
beforeUpload: file => {
this.setState({ fileList: [file] });
return false;
},
accept:".xlsx",
fileList: fileList||[]
};
return (
<Modal
forceRender
visible={visible}
title={'导入资产'}
width={520}
onOk={this.onOk}
onCancel={() => {
this.reset();
onCancel && onCancel();
}}
>
<>
<div>
<Button icon={<DownloadOutlined />} onClick={ this.downloadTemplate }>
模版下载
</Button>
</div>
<div className='mt-3'>
<Upload {...uploadProps}>
<Button icon={<UploadOutlined />}>
选择文件上传
</Button>
</Upload>
</div>
</>
</Modal>
)
}
}
export default ImportAsset;
\ No newline at end of file
...@@ -9,7 +9,7 @@ import './LeftTree.less'; ...@@ -9,7 +9,7 @@ import './LeftTree.less';
const {TreeNode} = Tree const {TreeNode} = Tree
const LeftTree = (props)=>{ const LeftTree = (props)=>{
const {setNodeId,nodeId} = props const {setNodeId,nodeId, setNode} = props
const [treeBox,setTreeBox] = useState([]) const [treeBox,setTreeBox] = useState([])
const [dataList,setDataList] = useState([]) const [dataList,setDataList] = useState([])
...@@ -54,6 +54,7 @@ const LeftTree = (props)=>{ ...@@ -54,6 +54,7 @@ const LeftTree = (props)=>{
payload: {dirId:nodeId}, payload: {dirId:nodeId},
callback: dataBox => { callback: dataBox => {
setDetailBox(dataBox) setDetailBox(dataBox)
setNode(dataBox)
}, },
error: () => { error: () => {
} }
......
...@@ -7,7 +7,8 @@ class Index extends React.Component { ...@@ -7,7 +7,8 @@ class Index extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
nodeId:null nodeId:null,
node: null,
}; };
} }
...@@ -19,14 +20,18 @@ class Index extends React.Component { ...@@ -19,14 +20,18 @@ class Index extends React.Component {
this.setState({nodeId:data}) this.setState({nodeId:data})
} }
setNode = (data) => {
this.setState({ node: data });
}
render() { render() {
return ( return (
<Row gutter={15} style={{backgroundColor:'#ededed'}}> <Row gutter={15} style={{backgroundColor:'#ededed'}}>
<Col span={6}> <Col span={6}>
<LeftTree setNodeId={this.setNodeId} nodeId={this.state.nodeId}/> <LeftTree setNodeId={this.setNodeId} setNode={this.setNode} nodeId={this.state.nodeId}/>
</Col> </Col>
<Col span={18}> <Col span={18}>
<AssetTable nodeId={this.state.nodeId} /> <AssetTable nodeId={this.state.nodeId} node={this.state.node} />
</Col> </Col>
</Row> </Row>
) )
......
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