import React, { useState, useEffect } from "react";
import {
Table,
Divider,
Card,
Descriptions,
Typography,
Spin,
Row,
Col,
Tooltip,
Rate,
Drawer,
Image,
} from "antd";
import { postFetch } from "@/utils/doFetch";
import AutoTable from "@/components/Tableform";
import styles from "./index.less";
const { Paragraph } = Typography;
const Details = (props) => {
/**
* dataSource: 整个页面的数据,Object
* totalPath: 整个详情页的接口,String
* totalParams: 整个详情页接口的参数
* totalCard: 整个页面的模块,Array
* col: 列数
*
* totalCard中的每一项变量:cardTitle每一个模块的标题;itemData每一个模块的数据信息(Array)
* itemData中的每一项变量:key所对应的字段;title每一项label标题;type每一项的类型(file,img,textarea,table,不填默认就是普通的展示类型);col每一项的占比;columns表格类型所用;path当类型为表格时,若该表格是单独查询出来的可以填入path;urlName 当传入文件为url为字符串时
*
*/
const {
totalPath = "",
dataSource,
totalCard,
totalParams,
col,
bottomNode,
topNode,
} = props;
const [pageData, cp] = useState({});
useEffect(() => {
if (dataSource) {
cp(dataSource);
} else if (!dataSource && !Array.isArray(totalPath)) {
postFetch({
url: totalPath,
params: totalParams ? { ...totalParams } : {},
}).then((res) => {
if (res.code == "0000") {
if (!res.data) {
return;
}
cp(res?.data?.data);
}
});
}
}, []);
const getCol = (itemcol) => {
if (itemcol) {
return itemcol;
} else {
return col ? col : { xs: 24, sm: 24, md: 12, lg: 8, xl: 8, xxl: 6 };
}
};
//获取每一项
const getItem = (itemData) => {
const {
type,
key,
title,
columns,
path,
urlName,
col,
rowKey,
expandable,
} = itemData,
value = dataSource[key];
if (!type || type == "input") {
return value == 0 || value ? (
{value}