Commit 1656a41f authored by 田翔's avatar 田翔

fix: 接入组件

parent fb513653
......@@ -3,12 +3,16 @@ import { Table, Tooltip } from 'antd'
const TablePack = (props) => {
const { } = props
const { value, widget } = props
// console.log('props', props)
if (widget) {
console.log('widget', widget)
}
return (
<div>{JSON.stringify(props)}</div>
<div>{value}</div>
)
}
......
import React, { useEffect, useMemo, useState } from 'react'
import styles from './index.less'
import { Table, Tooltip } from 'antd'
import { Table, Tooltip, message } from 'antd'
import SearchGroup from './components/SearchGroup'
import TablePack from './components/TablePack'
import { GetAccountConfigInfo, GetAccountPageList, getStationListByUserID, GetTableJson } from '../../apis/process'
......@@ -20,7 +20,6 @@ const getFileInfo = (formJson) => {
}
}
}
console.log('obj', obj)
return obj
}
......@@ -28,18 +27,18 @@ const TableRender = (props) => {
const userID = window?.globalConfig?.userInfo?.OID || 1
const { accountName } = props
const [params, setParams] = useState({ userID: userID, accountName, direction: 'desc', timeField: '录入时间', pageIndex: 1, pageSize: 100 })
const [loading, setLoading] = useState(false)
const [config, setConfig] = useState({ webShowFieldGroup: '', formJson: '' })
const [dataSource, setDataSource] = useState([])
const columns = useMemo(() => {
const fileColumns = useMemo(() => {
const { webShowFieldGroup, formJson } = config
let showField = webShowFieldGroup ? webShowFieldGroup.split(',').filter(v => v) : []
let json = getFileInfo(formJson)
let array = []
showField.forEach(v => {
array.push({
key: new Date().getTime(),
title: json[v]?.title || v,
dataIndex: v,
width: 120,
......@@ -55,38 +54,55 @@ const TableRender = (props) => {
return array
}, [config])
const columns = useMemo(() => {
return [
{
title: '序号',
dataIndex: 'r',
key: 'r',
width: 50,
fixed: 'left',
},
...fileColumns,
{
title: '操作',
width: 50,
fixed: 'right',
render: (r) => {
return '详情'
}
}
]
}, [fileColumns])
const search = (values) => {
setParams({ ...params, ...values })
getDataSource({ ...params, ...values })
}
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) => {
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)
const { code, data, msg } = await GetAccountPageList({ ...params, ...param })
if (code === 0) {
setDataSource(JSON.parse(data.jsonData))
} else {
setDataSource([])
message.error(msg)
}
setLoading(false)
}
const getData = () => {
getConfig()
getDataSource({ accountName })
getDataSource()
}
useEffect(() => {
......@@ -96,11 +112,12 @@ const TableRender = (props) => {
return (
<div className={styles.tableRender}>
<div className={styles.top}>
<SearchGroup />
<SearchGroup onChange={search} />
</div>
<div className={styles.bottom}>
<Table
size='small'
rowKey='ID'
bordered
loading={loading}
columns={columns}
......
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