Commit 4e4bf0c7 authored by 田翔's avatar 田翔

fix: 一键布局BUG修复

parent 3c941206
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "4.3.4", "version": "4.3.5",
"description": "4.3.4 强行增加分组,分组套分组解析成一个分组", "description": "4.3.5 一键布局BUG修复",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
......
...@@ -268,6 +268,17 @@ export function DeleteTableDataInfo(data) { ...@@ -268,6 +268,17 @@ export function DeleteTableDataInfo(data) {
}); });
} }
//导出数据
export function ImportAccountData(options, params, data) {
return request({
url: `${BASEURL}/ImportAccountData`,
method: 'post',
...options,
params,
data,
});
}
//导出数据 //导出数据
export function ExportAccountData({ accountName, ids, exportAll }) { export function ExportAccountData({ accountName, ids, exportAll }) {
return request({ return request({
......
...@@ -5,6 +5,7 @@ import locale from 'antd/es/date-picker/locale/zh_CN' ...@@ -5,6 +5,7 @@ import locale from 'antd/es/date-picker/locale/zh_CN'
import { PlusOutlined, DeleteOutlined, ImportOutlined, ExportOutlined, QuestionCircleOutlined, EditOutlined, DownOutlined } from '@ant-design/icons' import { PlusOutlined, DeleteOutlined, ImportOutlined, ExportOutlined, QuestionCircleOutlined, EditOutlined, DownOutlined } from '@ant-design/icons'
import styles from './search.less' import styles from './search.less'
import moment from 'moment' import moment from 'moment'
import { ImportAccountData } from '../../../../apis/process'
const { Search } = Input; const { Search } = Input;
const { RangePicker } = DatePicker; const { RangePicker } = DatePicker;
...@@ -16,7 +17,7 @@ const SearchGroup = forwardRef((props, ref) => { ...@@ -16,7 +17,7 @@ const SearchGroup = forwardRef((props, ref) => {
getQueryInfo, getQueryInfo,
})) }))
const { readOnly, btnsClick } = props const { accountName, readOnly, checkName, btnsClick } = props
const [form] = Form.useForm() const [form] = Form.useForm()
const [showPicker, setShowPicker] = useState(true) const [showPicker, setShowPicker] = useState(true)
const [dateArray, setDateArray] = useState([]) const [dateArray, setDateArray] = useState([])
...@@ -137,7 +138,7 @@ const SearchGroup = forwardRef((props, ref) => { ...@@ -137,7 +138,7 @@ const SearchGroup = forwardRef((props, ref) => {
} }
// 默认开启检查全部字段 // 默认开启检查全部字段
_data.isCheck = true; _data.isCheck = true;
importAccountData( ImportAccountData(
{ {
headers: { headers: {
'Content-Type': 'multipart/form-data', 'Content-Type': 'multipart/form-data',
...@@ -148,7 +149,7 @@ const SearchGroup = forwardRef((props, ref) => { ...@@ -148,7 +149,7 @@ const SearchGroup = forwardRef((props, ref) => {
).then(res => { ).then(res => {
if (res.code === 0) { if (res.code === 0) {
message.success('导入成功!'); message.success('导入成功!');
getAccountData(); // getAccountData();
} else { } else {
message.warning(res.msg); message.warning(res.msg);
} }
......
import React, { useMemo, useState, useRef, forwardRef, useImperativeHandle } from 'react' import React, { useMemo, useState, forwardRef, useImperativeHandle } from 'react'
import { Table, Tooltip, Button, Popconfirm, Input, Space, Tag } from 'antd' import { Table, Tooltip, Button, Popconfirm, Input, Space, Tag, Popover, Checkbox } from 'antd'
import { TweenOneGroup } from 'rc-tween-one' import { TweenOneGroup } from 'rc-tween-one'
import styles from './index.less' import styles from './index.less'
import { SearchOutlined } from '@ant-design/icons' import { SearchOutlined, FormOutlined } from '@ant-design/icons'
import ResizeableTitle from './components/ResizeableTitle' import ResizeableTitle from './components/ResizeableTitle'
import FileView from './components/FileView' import FileView from './components/FileView'
import CoordView from './components/CoordView' import CoordView from './components/CoordView'
...@@ -34,9 +34,12 @@ const TablePack = (props, ref) => { ...@@ -34,9 +34,12 @@ const TablePack = (props, ref) => {
})) }))
const { parent, readOnly, config, fieldList, loading, dataSource, rowSelection, onRow, tableChange, btnsClick } = props const { parent, readOnly, config, fieldList, loading, dataSource, rowSelection, onRow, tableChange, btnsClick } = props
const { webShowFieldGroup, formJson } = config
const [fieldResize, setFieldResize] = useState({}) const [fieldResize, setFieldResize] = useState({})
const [filteredInfo, setFilteredInfo] = useState({}) const [filteredInfo, setFilteredInfo] = useState({})
const [sortedInfo, setSortedInfo] = useState({}) const [sortedInfo, setSortedInfo] = useState({})
const [open, setOpen] = useState(false)
const [checks, setChecks] = useState([])
const filtered = useMemo(() => { const filtered = useMemo(() => {
let array = [] let array = []
...@@ -284,7 +287,11 @@ const TablePack = (props, ref) => { ...@@ -284,7 +287,11 @@ const TablePack = (props, ref) => {
] ]
}, [readOnly, parent]) }, [readOnly, parent])
const fileColumns = useMemo(() => { const checkChange = (values) => {
setChecks(values)
}
const showField = useMemo(() => {
const { webShowFieldGroup, formJson } = config const { webShowFieldGroup, formJson } = config
let showField = [] let showField = []
if (Array.isArray(fieldList) && fieldList.length > 0) { if (Array.isArray(fieldList) && fieldList.length > 0) {
...@@ -292,6 +299,11 @@ const TablePack = (props, ref) => { ...@@ -292,6 +299,11 @@ const TablePack = (props, ref) => {
} else { } else {
showField = webShowFieldGroup ? webShowFieldGroup.split(',').filter(v => v) : [] showField = webShowFieldGroup ? webShowFieldGroup.split(',').filter(v => v) : []
} }
setChecks(showField)
return showField
}, [webShowFieldGroup, fieldList])
const fileColumns = useMemo(() => {
let json = getFileInfo(formJson) let json = getFileInfo(formJson)
let array = [] let array = []
showField.forEach((v, i) => { showField.forEach((v, i) => {
...@@ -302,7 +314,31 @@ const TablePack = (props, ref) => { ...@@ -302,7 +314,31 @@ const TablePack = (props, ref) => {
} }
}) })
return array return array
}, [parent, config, fieldList, fieldResize, filteredInfo, sortedInfo]) }, [parent, formJson, showField, fieldResize, filteredInfo, sortedInfo])
const showColumns = useMemo(() => {
return fileColumns.filter(v => checks.includes(v.dataIndex))
}, [checks, fileColumns])
const content = (
<div>
<Checkbox.Group
value={checks}
style={{ width: '100%' }}
onChange={checkChange}
>
{
fileColumns.map(v => {
return (
<div key={v.dataIndex}>
<Checkbox value={v.dataIndex}>{v.title}</Checkbox>
</div>
)
})
}
</Checkbox.Group>
</div>
)
const columns = useMemo(() => { const columns = useMemo(() => {
let columns = [ let columns = [
...@@ -313,9 +349,33 @@ const TablePack = (props, ref) => { ...@@ -313,9 +349,33 @@ const TablePack = (props, ref) => {
filteredValue: null, filteredValue: null,
render: (_, r, i) => i + 1 render: (_, r, i) => i + 1
}, },
...fileColumns, ...showColumns,
{ {
title: '操作', title: (
<div className={styles.operation}>
<span>操作</span>
<span className={styles.operationSpan}>
<Popover
placement='bottomRight'
title={
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<div>列配置</div>
<Button size='small' type="link" onClick={() => setOpen(false)}>确定</Button>
</div>
}
trigger='click'
open={open}
content={content}
onOpenChange={(value) => {
setOpen(value)
}}
arrowPointAtCenter
>
<FormOutlined />
</Popover>
</span>
</div>
),
width: btns.length * 35 + 30, width: btns.length * 35 + 30,
align: 'center', align: 'center',
filteredValue: null, filteredValue: null,
...@@ -365,7 +425,7 @@ const TablePack = (props, ref) => { ...@@ -365,7 +425,7 @@ const TablePack = (props, ref) => {
return fileColumns return fileColumns
} }
return columns return columns
}, [parent, btns, fileColumns]) }, [parent, btns, dataSource, fileColumns, checks, open])
const onChange = (page, filters, sorter) => { const onChange = (page, filters, sorter) => {
setFilteredInfo(filters) setFilteredInfo(filters)
...@@ -454,6 +514,24 @@ const TablePack = (props, ref) => { ...@@ -454,6 +514,24 @@ const TablePack = (props, ref) => {
} }
}} }}
/> />
{/* <Drag
title={'列配置'}
width={500}
bodyStyle={{ height: '400px', overflow: 'auto' }}
onOk={() => setVisible(false)}
onCancel={() => setVisible(false)}
visible={visible}
getContainer={false}
>
{
checks.map(v => {
return (
)
})
}
</Drag> */}
</div> </div>
) )
......
...@@ -13,6 +13,16 @@ ...@@ -13,6 +13,16 @@
display: flex; display: flex;
align-items: center; align-items: center;
} }
.operation {
.operationSpan {
margin-left: 10px;
display: inline-block;
&:hover {
cursor: pointer;
color: #1890ff;
}
}
}
.@{ant-prefix}-table-wrapper { .@{ant-prefix}-table-wrapper {
height: 100%; height: 100%;
.@{ant-prefix}-spin-nested-loading { .@{ant-prefix}-spin-nested-loading {
......
...@@ -296,6 +296,7 @@ const Account = (props) => { ...@@ -296,6 +296,7 @@ const Account = (props) => {
<SearchGroup <SearchGroup
onChange={search} onChange={search}
btnsClick={btnsClick} btnsClick={btnsClick}
accountName={accountName}
readOnly={readOnly} readOnly={readOnly}
/> />
</div> </div>
......
...@@ -110,69 +110,6 @@ const RelationForm = (props) => { ...@@ -110,69 +110,6 @@ const RelationForm = (props) => {
return array return array
}, [formDataObj, config, mappedField, codes, dataSource]) }, [formDataObj, config, mappedField, codes, dataSource])
const columns = useMemo(() => {
let btn = ['详情']
if (!disabled) {
btn = ['详情', '编辑', '删除']
}
const { webShowFieldGroup } = config
let field = webShowFieldGroup ? webShowFieldGroup.split(',').filter(v => v) : []
let array = []
if (field.length > 0) {
array.push({ title: '序号', width: 50, align: 'center', render: (_, r, i) => i + 1 })
field.forEach(v => {
array.push({
title: v,
dataIndex: v,
key: v,
ellipsis: {
visibleTitle: false,
},
})
})
array.push({
title: '操作',
dataIndex: '',
key: 'action',
width: btn.length === 1 ? 80 : btn.length * 40,
fixed: 'right',
render: (t, r) => {
return (
<div style={{ display: 'flex', justifyContent: 'center' }}>
{
btn.map(v => {
if (v === '删除') {
return (
<Popconfirm
// disabled={selectedRowKeys.length}
title='确定要删除数据吗?'
onConfirm={() => rowClick(v, r)}
onCancel={() => { }}
okText='确定'
cancelText='取消'
>
<Button type='link' icon={icons[v]} title={v} />
</Popconfirm>
)
}
return (
<Button
type='link'
icon={icons[v]}
title={v}
onClick={() => rowClick(v, r)}
/>
)
})
}
</div>
)
}
})
}
return array
}, [disabled, config, dataSource, formState])
const rowClick = async (v, r) => { const rowClick = async (v, r) => {
if (addons) { if (addons) {
setRow(r) setRow(r)
...@@ -214,7 +151,7 @@ const RelationForm = (props) => { ...@@ -214,7 +151,7 @@ const RelationForm = (props) => {
let listItem = { type: 'delete', accountTable: accountName, id: r.ID, values: getItem('delete', r) } let listItem = { type: 'delete', accountTable: accountName, id: r.ID, values: getItem('delete', r) }
let relationForm = addons.getValue('relationForm') || { configs: [], data: [] } let relationForm = addons.getValue('relationForm') || { configs: [], data: [] }
if (r.ID.includes('前端ID')) { if (r.ID.includes('前端ID')) {
let list = relationForm.data.filter(v => v.id !== r.ID) let list = relationForm.data.filter(v => v.ID !== r.ID)
addons.setValue('relationForm', { ...relationForm, data: list }) addons.setValue('relationForm', { ...relationForm, data: list })
} else { } else {
addons.setValue('relationForm', { ...relationForm, data: [...relationForm.data, listItem] }) addons.setValue('relationForm', { ...relationForm, data: [...relationForm.data, listItem] })
......
...@@ -201,7 +201,7 @@ const getWidgetSetting = (type, { title, tableName, tableType }) => { ...@@ -201,7 +201,7 @@ const getWidgetSetting = (type, { title, tableName, tableType }) => {
} }
} else if (type === '数值') { } else if (type === '数值') {
return { return {
title: "数值", title: title,
"type": "string", "type": "string",
"widget": "NumberInput", "widget": "NumberInput",
"presetValue": "0", "presetValue": "0",
......
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