UNPKG

fx-form-widget

Version:
64 lines 1.72 kB
import React, { useEffect, useState } from 'react'; import { ProTable } from '@ant-design/pro-components'; import './index.less'; var serialNumber = { title: '序号', valueType: 'index', fixed: 'left', width: 50 }; var Table = function Table(props) { var schemas = props.schemas, dataSource = props.dataSource, showIndex = props.showIndex, title = props.title, _props$pageSize = props.pageSize, pageSize = _props$pageSize === void 0 ? 10 : _props$pageSize; var _useState = useState([]), dataColumns = _useState[0], setDataColumns = _useState[1]; var renderSubForm2TablClounm = function renderSubForm2TablClounm(schemas) { var newColumns = schemas.map(function (schema) { var fieldName = schema.fieldName, label = schema.label, wid = schema.wid; return { title: label, dataIndex: fieldName ? fieldName : wid, ellipsis: true, width: 200 }; }); setDataColumns(newColumns); }; useEffect(function () { renderSubForm2TablClounm(schemas); }, [schemas]); var newColumns = showIndex ? [serialNumber].concat(dataColumns) : dataColumns; return /*#__PURE__*/React.createElement(ProTable, { columns: newColumns, rowKey: "key", style: { width: '100%' }, options: false, scroll: { x: 1300 }, dataSource: dataSource, pagination: { showQuickJumper: true, pageSize: pageSize, pageSizeOptions: [pageSize] }, search: false, bordered: true, dateFormatter: "string", className: "custom-table", headerTitle: title, toolBarRender: function toolBarRender() { return []; } }); }; export default Table;