|
|
@ -2,9 +2,12 @@ import React, { useState, useRef, useEffect } from 'react'; |
|
|
|
import { connect } from 'react-redux'; |
|
|
|
import { Button, Empty, Space, Spin, Tag, Descriptions } from 'antd'; |
|
|
|
import '../style.less'; |
|
|
|
import { ProTable } from '@ant-design/pro-table'; |
|
|
|
import { render } from 'react-dom'; |
|
|
|
import { Link } from 'react-router-dom'; |
|
|
|
|
|
|
|
const ProductCard = (props) => { |
|
|
|
const { dispatch, actions, productId, product, loading } = props |
|
|
|
const { dispatch, actions, productId, product, products, loading } = props |
|
|
|
|
|
|
|
const { meta } = actions; |
|
|
|
|
|
|
@ -14,9 +17,31 @@ const ProductCard = (props) => { |
|
|
|
} |
|
|
|
}, []); |
|
|
|
|
|
|
|
const columns = [{ |
|
|
|
title: '能力', |
|
|
|
dataIndex: 'cmname' |
|
|
|
}, { |
|
|
|
title: '描述', |
|
|
|
dataIndex: 'cmdesc' |
|
|
|
}, { |
|
|
|
title: '接口', |
|
|
|
dataIndex: 'iname' |
|
|
|
}, { |
|
|
|
title: '协议名', |
|
|
|
dataIndex: 'pmdesc' |
|
|
|
}, { |
|
|
|
title: '协议', |
|
|
|
dataIndex: 'pmname', |
|
|
|
render: (_, item) => { |
|
|
|
return <a href={`protocol/${item.pmname}`}>{item.pmname}</a>; |
|
|
|
}, |
|
|
|
}, |
|
|
|
] |
|
|
|
|
|
|
|
const actionRef = useRef(); |
|
|
|
return ( |
|
|
|
<Spin spinning={loading}> |
|
|
|
<Descriptions title="Product Info" bordered> |
|
|
|
<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> |
|
|
@ -27,23 +52,37 @@ const ProductCard = (props) => { |
|
|
|
<Descriptions.Item label="创建用户" >{product?.Username}</Descriptions.Item> |
|
|
|
<Descriptions.Item label="资源类型" span={3}>{product?.FilterResource}</Descriptions.Item> |
|
|
|
</Descriptions> |
|
|
|
<h3>能力集合</h3> |
|
|
|
<ProTable |
|
|
|
columns={columns} |
|
|
|
actionRef={actionRef} |
|
|
|
dataSource={products} |
|
|
|
options={false} |
|
|
|
toolBarRender={false} |
|
|
|
search={false} |
|
|
|
|
|
|
|
> |
|
|
|
</ProTable> |
|
|
|
</Spin> |
|
|
|
) |
|
|
|
} |
|
|
|
|
|
|
|
function mapStateToProps(state) { |
|
|
|
const { auth, global, product } = state; |
|
|
|
console.log(product) |
|
|
|
let raw = product |
|
|
|
let p = {} |
|
|
|
if (product && product.data && (product.data.data ?? []).length > 0) { |
|
|
|
p=product.data.data[0]; |
|
|
|
p = product.data.data[0]; |
|
|
|
} |
|
|
|
console.log(raw.data?.data ?? []) |
|
|
|
|
|
|
|
return { |
|
|
|
user: auth.user, |
|
|
|
actions: global.actions, |
|
|
|
loading: product.isRequesting, |
|
|
|
product: p, |
|
|
|
productCaps: product.data?.data ?? [], |
|
|
|
products: raw.data?.data ?? [], |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|