diff --git a/code/web/client/src/sections/meta/actions/meta.js b/code/web/client/src/sections/meta/actions/meta.js index 9e07ed5..a0a5673 100644 --- a/code/web/client/src/sections/meta/actions/meta.js +++ b/code/web/client/src/sections/meta/actions/meta.js @@ -15,6 +15,17 @@ export function list(query) { }) } +export function getProduct(productId){ + return dispatch => basicAction({ + type: 'get', + dispatch: dispatch, + actionType: 'GET_PRODUCT', + url: ApiTable.getProduct.replace('{productId}', productId), + msg: { error: '获取设备失败' }, + reducer: { name: 'product' } + }) +} + export function listProducts(query) { return dispatch => basicAction({ type: 'get', diff --git a/code/web/client/src/sections/meta/containers/ProductCard.js b/code/web/client/src/sections/meta/containers/ProductCard.js new file mode 100644 index 0000000..0cc5c56 --- /dev/null +++ b/code/web/client/src/sections/meta/containers/ProductCard.js @@ -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 ( + + + {product?.Id} + {product?.Name} + {product?.Model} + {product?.Desc} + {product?.UpdatedAt} + {product?.CreatedAt} + {product?.Company} + {product?.Username} + {product?.FilterResource} + + + ) +} + +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); \ No newline at end of file diff --git a/code/web/client/src/sections/meta/containers/ProductsProfile.js b/code/web/client/src/sections/meta/containers/ProductsProfile.js index e64c835..25e07c0 100644 --- a/code/web/client/src/sections/meta/containers/ProductsProfile.js +++ b/code/web/client/src/sections/meta/containers/ProductsProfile.js @@ -1,16 +1,17 @@ import React, { useState, useRef, useEffect } from 'react'; import { connect } from 'react-redux'; -import { Button, Space, Tag } from 'antd'; +import { Button, Space, Tag ,Drawer} from 'antd'; import '../style.less'; import ProTable from '@ant-design/pro-table'; import ConfigModal from './ConfigModal'; +import ProductCard from './ProductCard'; const ProductsProfile = (props) => { const { dispatch, actions, products } = props const { meta } = actions; - const [configModalVis, setConfigModalVis] = useState(false) - const [editData, setEditData] = useState(null) + const [drawVis, setDrawVis] = useState(false) + const [pid, setPid] = useState(null) // 过滤后数据,用于表格展示 const [fdata, setFdata] = useState([]) @@ -64,6 +65,18 @@ const ProductsProfile = (props) => { valueType: 'image', hideInSearch: true, }, + { + title: '操作', + width: 180, + key: 'option', + valueType: 'option', + render: (tx, record) => [ + { + setPid(record.Id); + setDrawVis(true); + }}>查看详情, + ], + }, ] const requestList = async (params, sorter) => { @@ -134,15 +147,10 @@ const ProductsProfile = (props) => { { - configModalVis ? - { - setConfigModalVis(false) - setEditData(null) - }} - editData={editData} - /> : '' + drawVis ? + setDrawVis(false)} visible={drawVis}> + + : '' } ) diff --git a/code/web/client/src/utils/webapi.js b/code/web/client/src/utils/webapi.js index b75d376..f4c34a4 100644 --- a/code/web/client/src/utils/webapi.js +++ b/code/web/client/src/utils/webapi.js @@ -21,6 +21,7 @@ export const ApiTable = { getFactors: 'v1/searchFactor', // 监测因素 getProducts: 'v1/products', + getProduct: 'v1/product/{productId}', getEnterprisesMembers: 'enterprises/{enterpriseId}/members', }; diff --git a/code/web/package.json b/code/web/package.json index 21112a0..0dea475 100644 --- a/code/web/package.json +++ b/code/web/package.json @@ -61,6 +61,8 @@ }, "dependencies": { "@ant-design/icons": "^4.6.2", + "@ant-design/pro-components": "^2.3.25", + "@ant-design/pro-descriptions": "^2.0.21", "@ant-design/pro-form": "^1.34.0", "@ant-design/pro-table": "^2.48.0", "@antv/g6": "^4.2.5", @@ -93,4 +95,4 @@ "webpack-dev-server": "^3.11.2", "xlsx": "^0.16.9" } -} \ No newline at end of file +}