Commit dae7deda authored by 田翔's avatar 田翔

fix: 增加台账选择器列表显示

parent 700f0cf1
...@@ -202,7 +202,7 @@ const SearchGroup = forwardRef((props, ref) => { ...@@ -202,7 +202,7 @@ const SearchGroup = forwardRef((props, ref) => {
}; };
const btnsClick = type => { const btnsClick = type => {
props && props.btnsClick(type, null); props?.btnsClick?.(type, null);
}; };
return ( return (
......
...@@ -29,7 +29,7 @@ const TablePack = (props, ref) => { ...@@ -29,7 +29,7 @@ const TablePack = (props, ref) => {
setFilteredInfo, setFilteredInfo,
})) }))
const { parent, readOnly, config, loading, dataSource, rowSelection, onRow, tableChange, btnsClick } = props const { parent, readOnly, config, fieldList, loading, dataSource, rowSelection, onRow, tableChange, btnsClick } = props
const [filteredInfo, setFilteredInfo] = useState({}) const [filteredInfo, setFilteredInfo] = useState({})
const inputRef = useRef() const inputRef = useRef()
...@@ -126,7 +126,12 @@ const TablePack = (props, ref) => { ...@@ -126,7 +126,12 @@ const TablePack = (props, ref) => {
const fileColumns = useMemo(() => { const fileColumns = useMemo(() => {
const { webShowFieldGroup, formJson } = config const { webShowFieldGroup, formJson } = config
let showField = webShowFieldGroup ? webShowFieldGroup.split(',').filter(v => v) : [] let showField = []
if (Array.isArray(fieldList) && fieldList.length > 0) {
showField = fieldList
} else {
showField = webShowFieldGroup ? webShowFieldGroup.split(',').filter(v => v) : []
}
let json = getFileInfo(formJson) let json = getFileInfo(formJson)
let array = [] let array = []
showField.forEach(v => { showField.forEach(v => {
...@@ -157,7 +162,7 @@ const TablePack = (props, ref) => { ...@@ -157,7 +162,7 @@ const TablePack = (props, ref) => {
}) })
}) })
return array return array
}, [config, filteredInfo]) }, [config, fieldList, filteredInfo])
const columns = useMemo(() => { const columns = useMemo(() => {
let columns = [ let columns = [
......
...@@ -1761,18 +1761,24 @@ const businessWidgets = [ ...@@ -1761,18 +1761,24 @@ const businessWidgets = [
name: '台账名称', name: '台账名称',
type: 'string', type: 'string',
widget: 'AccountName', widget: 'AccountName',
// required: true,
}, },
fieldshine: { fieldshine: {
title: '映射字段', title: '映射字段',
name: '映射字段', name: '映射字段',
type: 'array', type: 'array',
widget: 'Fieldshine', widget: 'Fieldshine',
// required: true,
dependencies: ['accountName', '$id'], dependencies: ['accountName', '$id'],
default: [], default: [],
description: '多字段映射仅支持单选', description: '多字段映射仅支持单选',
}, },
fieldList: {
title: '前端显示字段',
type: 'array',
default: [],
widget: 'FieldList',
dependencies: ['accountName', '$id'],
description: '默认获取前端台账字段',
},
siteFilter: { siteFilter: {
title: '站点过滤', title: '站点过滤',
name: '站点过滤', name: '站点过滤',
......
...@@ -90,6 +90,7 @@ const XRender = (props, ref) => { ...@@ -90,6 +90,7 @@ const XRender = (props, ref) => {
}, [schemaForm, form, startTime]) }, [schemaForm, form, startTime])
const getValues = async () => { const getValues = async () => {
console.log('form', form)
let { data, errors } = await form.submit() let { data, errors } = await form.submit()
let formValue = [] let formValue = []
Object.keys(data).map((k) => { Object.keys(data).map((k) => {
......
import React, { useState, useEffect } from 'react' import React, { useState, useEffect, useRef } from 'react'
import { Input, message, Pagination } from 'antd' import { Input, message, Pagination } from 'antd'
import { SnippetsOutlined } from '@ant-design/icons' import { SnippetsOutlined } from '@ant-design/icons'
import { GetAccountConfigInfo, GetAccountPageList, getStationListByUserID } from '../../../../apis/process' import { GetAccountConfigInfo, GetAccountPageList, getStationListByUserID } from '../../../../apis/process'
...@@ -12,7 +12,7 @@ const AccountSelector = (props) => { ...@@ -12,7 +12,7 @@ const AccountSelector = (props) => {
const userID = window?.globalConfig?.userInfo?.OID || 1 const userID = window?.globalConfig?.userInfo?.OID || 1
const { value, onChange, schema, addons } = props const { value, onChange, schema, addons } = props
const { disabled, accountName, fieldshine, siteFilter, sql, isMultiple, presetValue, placeholder } = schema const { disabled, accountName, fieldshine, siteFilter, sql, isMultiple, presetValue, placeholder, fieldList } = schema
const [params, setParams] = useState({ const [params, setParams] = useState({
userID: userID, userID: userID,
...@@ -28,6 +28,7 @@ const AccountSelector = (props) => { ...@@ -28,6 +28,7 @@ const AccountSelector = (props) => {
const [config, setConfig] = useState({ webShowFieldGroup: '' }) const [config, setConfig] = useState({ webShowFieldGroup: '' })
const [visible, setVisible] = useState(false) const [visible, setVisible] = useState(false)
const [keys, setKeys] = useState([]) const [keys, setKeys] = useState([])
const tablePackRef = useRef(null)
const iconClick = () => { const iconClick = () => {
if (addons) { if (addons) {
...@@ -154,6 +155,15 @@ const AccountSelector = (props) => { ...@@ -154,6 +155,15 @@ const AccountSelector = (props) => {
getDataSource({ ...values }) getDataSource({ ...values })
} }
const btnsClick = (type) => {
if (type === '重置') {
console.log('type', type)
tablePackRef.current.setFilteredInfo({})
setParams({ ...params, queryWheres: [] })
getDataSource({ queryWheres: [] })
}
}
const pageChange = (pageIndex, pageSize) => { const pageChange = (pageIndex, pageSize) => {
getDataSource({ pageIndex, pageSize }) getDataSource({ pageIndex, pageSize })
} }
...@@ -191,15 +201,18 @@ const AccountSelector = (props) => { ...@@ -191,15 +201,18 @@ const AccountSelector = (props) => {
<SearchGroup <SearchGroup
onChange={search} onChange={search}
readOnly={true} readOnly={true}
btnsClick={btnsClick}
/> />
</div> </div>
<div className={styles.bottom}> <div className={styles.bottom}>
<TablePack <TablePack
ref={tablePackRef}
loading={loading} loading={loading}
readOnly={true} readOnly={true}
config={config} config={config}
dataSource={dataSource} dataSource={dataSource}
btnsClick={() => { }} btnsClick={btnsClick}
fieldList={fieldList}
tableChange={tableChange} tableChange={tableChange}
parent='台账选择器' parent='台账选择器'
rowSelection={{ rowSelection={{
......
import React, { useMemo, useState } from 'react'
import { Input, message, Row, Col, Checkbox } from 'antd'
import Drag from '../../../../components/Drag'
import {
GetAccountPageList,
GetAccountConfigInfo,
GetTableGroupMeta,
GetTableDataInfo,
SaveTableDataInfo,
EditTableDataInfo,
DeleteTableDataInfo
} from '../../../../../apis/process'
const FieldList = (props) => {
const { value, addons, onChange } = props
const { accountName } = addons.formData
const [visible, setVisible] = useState(false)
const [conifg, setConfig] = useState({})
const options = useMemo(() => {
const { webShowFieldGroup } = conifg
return webShowFieldGroup ? webShowFieldGroup.split(',').filter(v => v) : []
}, [conifg])
const getConfig = async () => {
const { code, data } = await GetAccountConfigInfo(accountName)
if (code === 0) {
setConfig(data)
}
}
const onOk = () => {
setVisible(false)
}
const checkChange = (value) => {
onChange(value)
}
const inputClick = () => {
if (!accountName) {
return message.error('请配置台账名称!')
}
getConfig()
setVisible(true)
}
return (
<div>
<Input value={value} onClick={inputClick} />
<Drag
title='前端显示字段'
onOk={onOk}
onCancel={() => setVisible(false)}
visible={visible}
>
<Checkbox.Group
value={value}
style={{ width: '100%' }}
onChange={checkChange}
>
<Row>
{
options.map(v => {
return (
<Col span={8}>
<Checkbox value={v}>{v}</Checkbox>
</Col>
)
})
}
</Row>
</Checkbox.Group>
</Drag>
</div>
)
}
export default FieldList
\ No newline at end of file
...@@ -6,6 +6,7 @@ import MappedField from './MappedField' ...@@ -6,6 +6,7 @@ import MappedField from './MappedField'
import ControlRules from './ControlRules' import ControlRules from './ControlRules'
import SourceType from './SourceType' import SourceType from './SourceType'
import TableName from './TableName' import TableName from './TableName'
import FieldList from './FieldList'
import FieldName from './FieldName' import FieldName from './FieldName'
import CalculateRule from './CalculateRule' import CalculateRule from './CalculateRule'
import AddressSync from './AddressSync' import AddressSync from './AddressSync'
...@@ -21,6 +22,7 @@ const groupSource = { ...@@ -21,6 +22,7 @@ const groupSource = {
ControlRules, ControlRules,
SourceType, SourceType,
TableName, TableName,
FieldList,
FieldName, FieldName,
CalculateRule, CalculateRule,
AddressSync, AddressSync,
......
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