Commit efac719e authored by 田翔's avatar 田翔

fix: 表格初始化

parent 248b636c
This diff is collapsed.
import React, { useState, useEffect, useRef } from 'react';
import { FormRender, FormDesigner } from '../../src/index';
import { FormRender, FormDesigner, TableRender } from '../../src/index';
import { schemaValues } from './data';
import { Button, Tabs } from 'antd';
......@@ -3468,9 +3468,10 @@ const Test = (props) => {
return (
<div style={{ width: '100%', height: '100%' }}>
<FormDesigner ref={formDesignerRef} extra={true} tableName='事件工单_测试一键布局' />
{/* <FormDesigner ref={formDesignerRef} extra={true} tableName='事件工单_测试一键布局' /> */}
{/* <FormRender ref={formRenderRef} schemaValues={schemaValues} /> */}
{/* <div onClick={submit}>提交</div> */}
<TableRender accountName={'形态测试台账WY'} />
</div>
)
......
import React from 'react'
const Search = () => {
return (
<div></div>
)
}
export default Search
\ No newline at end of file
import React, { useMemo } from 'react'
import { Table, Tooltip } from 'antd'
const TablePack = (props) => {
const { loading, showField, formJson, dataSource } = props
const columns = useMemo(() => {
let array = []
showField.forEach(v => {
array.push({
key: new Date().getTime(),
title: v,
dataIndex: v,
width: 120,
ellipsis: true,
render: (value, r) => {
return (
<Tooltip placement="top" title={value}>{value}</Tooltip>
)
}
})
})
return array
}, [showField])
return (
<Table
size='small'
bordered
loading={loading}
columns={columns}
dataSource={dataSource}
pagination={false}
scroll={{ y: 'calc(100% - 50px)' }}
/>
)
}
export default TablePack
\ No newline at end of file
import React, { useEffect, useMemo, useState } from 'react'
import styles from './index.less'
import Search from './components/Search'
import TablePack from './components/TablePack'
import { GetAccountConfigInfo, GetAccountPageList, getStationListByUserID, GetTableJson } from '../../apis/process'
const TableRender = (props) => {
const userID = window?.globalConfig?.userInfo?.OID || 1
const { accountName } = props
const [loading, setLoading] = useState(false)
const [config, setConfig] = useState({ webShowFieldGroup: '', formJson: '' })
const [dataSource, setDataSource] = useState([])
const showField = useMemo(() => {
const { webShowFieldGroup } = config
return webShowFieldGroup.split(',').filter(v => v)
}, [config])
const getConfig = async () => {
const { code, data } = await GetAccountConfigInfo(accountName)
// if (code === 0) {
// setConfig(data)
// }
const res = await GetTableJson(accountName)
if (code === 0 && res.code === 0) {
setConfig({ ...data, formJson: res.data })
}
}
const getDataSource = async (param) => {
setLoading(true)
let params = {
userID: userID,
accountName: '',
direction: 'desc',
timeField: '录入时间',
pageIndex: 1,
pageSize: 100,
...param,
}
const { code, data } = await GetAccountPageList(params)
if (code === 0) {
setDataSource(JSON.parse(data.jsonData))
}
setLoading(false)
}
const getData = () => {
getConfig()
getDataSource({ accountName })
}
useEffect(() => {
getData()
}, [])
return (
<div className={styles.tableRender}>
<div className={styles.top}>
<Search />
</div>
<div className={styles.bottom}>
<TablePack
loading={loading}
showField={showField}
formJson={config.formJson}
dataSource={dataSource}
/>
</div>
</div>
)
}
export default TableRender
\ No newline at end of file
@import '~antd/es/style/themes/default.less';
.tableRender {
width: 100%;
height: 100%;
.top {
width: 100%;
height: 50px;
}
.bottom {
width: 100%;
height: calc(100% - 100px);
.@{ant-prefix}-table-wrapper {
height: 100%;
.@{ant-prefix}-spin-nested-loading {
height: 100%;
}
.@{ant-prefix}-spin-container {
height: 100%;
}
.@{ant-prefix}-table {
height: 100%;
.@{ant-prefix}-table-container {
height: 100%;
}
}
}
}
}
\ No newline at end of file
import FormRender from './core/FormRender'
import FormDesigner from './core/FormDesigner'
import TableRender from './core/TableRender'
import './main.less'
export {
FormRender,
FormDesigner,
TableRender,
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment