yinweiwen
2 years ago
5 changed files with 85 additions and 13 deletions
@ -0,0 +1,50 @@ |
|||
import React, { useState, useRef, useEffect } from 'react'; |
|||
import { connect } from 'react-redux'; |
|||
import { Button, Empty, Space, Spin, Tag, Descriptions } from 'antd'; |
|||
import '../style.less'; |
|||
|
|||
const ProductCard = (props) => { |
|||
const { dispatch, actions, productId, product, loading } = props |
|||
|
|||
const { meta } = actions; |
|||
|
|||
useEffect(() => { |
|||
if (!!productId) { |
|||
dispatch(meta.getProduct(productId)) |
|||
} |
|||
}, []); |
|||
|
|||
return ( |
|||
<Spin spinning={loading}> |
|||
<Descriptions title="Product Info" bordered> |
|||
<Descriptions.Item label="ID" span={3} >{product?.Id}</Descriptions.Item> |
|||
<Descriptions.Item label="名称" span={2}>{product?.Name}</Descriptions.Item> |
|||
<Descriptions.Item label="型号" span={1}>{product?.Model}</Descriptions.Item> |
|||
<Descriptions.Item label="描述" span={3}>{product?.Desc}</Descriptions.Item> |
|||
<Descriptions.Item label="更新时间" span={3}>{product?.UpdatedAt}</Descriptions.Item> |
|||
<Descriptions.Item label="创建时间" span={3}>{product?.CreatedAt}</Descriptions.Item> |
|||
<Descriptions.Item label="所属公司" >{product?.Company}</Descriptions.Item> |
|||
<Descriptions.Item label="创建用户" >{product?.Username}</Descriptions.Item> |
|||
<Descriptions.Item label="资源类型" span={3}>{product?.FilterResource}</Descriptions.Item> |
|||
</Descriptions> |
|||
</Spin> |
|||
) |
|||
} |
|||
|
|||
function mapStateToProps(state) { |
|||
const { auth, global, product } = state; |
|||
let p = {} |
|||
if (product && product.data && (product.data.data ?? []).length > 0) { |
|||
p=product.data.data[0]; |
|||
} |
|||
|
|||
return { |
|||
user: auth.user, |
|||
actions: global.actions, |
|||
loading: product.isRequesting, |
|||
product: p, |
|||
productCaps: product.data?.data ?? [], |
|||
}; |
|||
} |
|||
|
|||
export default connect(mapStateToProps)(ProductCard); |
Loading…
Reference in new issue