Commit 87353f90 authored by 田翔's avatar 田翔

fix: 重置时增加排序重置

parent 7f023aaa
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "4.1.7", "version": "4.1.8",
"description": "4.1.7 BUG修复", "description": "4.1.8 重置时增加排序重置",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
......
...@@ -201,6 +201,11 @@ const SearchGroup = forwardRef((props, ref) => { ...@@ -201,6 +201,11 @@ const SearchGroup = forwardRef((props, ref) => {
return params; return params;
}; };
const reset = () => {
form.resetFields()
btnsClick('重置')
}
const btnsClick = type => { const btnsClick = type => {
props?.btnsClick?.(type, null); props?.btnsClick?.(type, null);
}; };
...@@ -238,7 +243,7 @@ const SearchGroup = forwardRef((props, ref) => { ...@@ -238,7 +243,7 @@ const SearchGroup = forwardRef((props, ref) => {
/> />
</Form.Item> </Form.Item>
<Form.Item style={{ marginBottom: 0 }}> <Form.Item style={{ marginBottom: 0 }}>
<Button type="primary" onClick={() => btnsClick('重置')}> <Button type="primary" onClick={() => reset()}>
重置 重置
</Button> </Button>
</Form.Item> </Form.Item>
......
...@@ -27,17 +27,14 @@ const TablePack = (props, ref) => { ...@@ -27,17 +27,14 @@ const TablePack = (props, ref) => {
useImperativeHandle(ref, () => ({ useImperativeHandle(ref, () => ({
setFilteredInfo, setFilteredInfo,
setSortedInfo,
})) }))
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 [filteredInfo, setFilteredInfo] = useState({}) const [filteredInfo, setFilteredInfo] = useState({})
const [sortedInfo, setSortedInfo] = useState({})
const inputRef = useRef() const inputRef = useRef()
const handleReset = (clearFilters, confirm) => {
clearFilters()
confirm({ closeDropdown: true })
}
const getColumnSearchProps = (dataIndex) => ({ const getColumnSearchProps = (dataIndex) => ({
filterDropdown: ({ setSelectedKeys, selectedKeys, confirm, clearFilters, close }) => { filterDropdown: ({ setSelectedKeys, selectedKeys, confirm, clearFilters, close }) => {
return ( return (
...@@ -141,6 +138,7 @@ const TablePack = (props, ref) => { ...@@ -141,6 +138,7 @@ const TablePack = (props, ref) => {
width: 120, width: 120,
ellipsis: true, ellipsis: true,
sorter: true, sorter: true,
sortOrder: sortedInfo.columnKey === v ? sortedInfo.order : null,
filteredValue: filteredInfo[v] || null, filteredValue: filteredInfo[v] || null,
...getColumnSearchProps(v), ...getColumnSearchProps(v),
render: (value, r) => { render: (value, r) => {
...@@ -162,7 +160,7 @@ const TablePack = (props, ref) => { ...@@ -162,7 +160,7 @@ const TablePack = (props, ref) => {
}) })
}) })
return array return array
}, [config, fieldList, filteredInfo]) }, [config, fieldList, filteredInfo, sortedInfo])
const columns = useMemo(() => { const columns = useMemo(() => {
let columns = [ let columns = [
......
...@@ -18,18 +18,20 @@ import FormRender from '../FormRender' ...@@ -18,18 +18,20 @@ import FormRender from '../FormRender'
const Account = (props) => { const Account = (props) => {
const userID = window?.globalConfig?.userInfo?.OID || 1
const { accountName, readOnly } = props const { accountName, readOnly } = props
const [detailShow, setDetailShow] = useState(false) const userID = window?.globalConfig?.userInfo?.OID || 1
const [params, setParams] = useState({ const initParams = {
userID: userID, userID: userID,
accountName, accountName,
sortFields: '录入时间', sortFields: '录入时间',
direction: 'desc', direction: 'desc',
total: 0, total: 0,
pageIndex: 1, pageIndex: 1,
pageSize: 100 pageSize: 100,
}) queryWheres: [],
}
const [detailShow, setDetailShow] = useState(false)
const [params, setParams] = useState(initParams)
const [loading, setLoading] = useState(false) const [loading, setLoading] = useState(false)
const [dataSource, setDataSource] = useState([]) const [dataSource, setDataSource] = useState([])
const [config, setConfig] = useState({ webShowFieldGroup: '', addFieldGroup: '', formJson: {} }) const [config, setConfig] = useState({ webShowFieldGroup: '', addFieldGroup: '', formJson: {} })
...@@ -49,8 +51,9 @@ const Account = (props) => { ...@@ -49,8 +51,9 @@ const Account = (props) => {
} }
if (type === '重置') { if (type === '重置') {
tablePackRef.current.setFilteredInfo({}) tablePackRef.current.setFilteredInfo({})
setParams({ ...params, queryWheres: [] }) tablePackRef.current.setSortedInfo({})
getDataSource({ queryWheres: [] }) setParams(initParams)
getDataSource(initParams)
} }
if (type === '编辑' || type === '详情') { if (type === '编辑' || type === '详情') {
const { code, data, msg } = await GetTableDataInfo({ accountName, id }) const { code, data, msg } = await GetTableDataInfo({ accountName, id })
...@@ -131,7 +134,6 @@ const Account = (props) => { ...@@ -131,7 +134,6 @@ const Account = (props) => {
} }
const search = (values) => { const search = (values) => {
setParams({ ...params, ...values })
getDataSource({ ...values }) getDataSource({ ...values })
} }
...@@ -147,7 +149,7 @@ const Account = (props) => { ...@@ -147,7 +149,7 @@ const Account = (props) => {
const { code, data, msg } = await GetAccountPageList({ ...params, ...param }) const { code, data, msg } = await GetAccountPageList({ ...params, ...param })
if (code === 0) { if (code === 0) {
setDataSource(isJson(data.jsonData) ? JSON.parse(data.jsonData) : []) setDataSource(isJson(data.jsonData) ? JSON.parse(data.jsonData) : [])
setParams({ ...params, total: data.totalCount, pageIndex: data.pageIndex, pageSize: data.pageSize }) setParams({ ...params, ...param, total: data.totalCount, pageIndex: data.pageIndex, pageSize: data.pageSize })
} else { } else {
setDataSource([]) setDataSource([])
message.error(msg) message.error(msg)
...@@ -165,6 +167,7 @@ const Account = (props) => { ...@@ -165,6 +167,7 @@ const Account = (props) => {
} }
const tableChange = (page, filters, sorter) => { const tableChange = (page, filters, sorter) => {
tablePackRef.current.setSortedInfo({ order: sorter.order, columnKey: sorter.field })
let queryWheres = [] let queryWheres = []
Object.keys(filters).forEach(k => { Object.keys(filters).forEach(k => {
if (filters[k]?.[0]) { if (filters[k]?.[0]) {
...@@ -180,6 +183,8 @@ const Account = (props) => { ...@@ -180,6 +183,8 @@ const Account = (props) => {
getDataSource(param) getDataSource(param)
} }
console.log('params', params)
useEffect(() => { useEffect(() => {
getData() getData()
}, []) }, [])
......
...@@ -55,13 +55,13 @@ const PrintXform = (props) => { ...@@ -55,13 +55,13 @@ const PrintXform = (props) => {
{ {
formTable.map(v => { formTable.map(v => {
return ( return (
<div className={styles.printGroup}> <div className={styles.printGroup} key={v.fieldName}>
<div className={styles.groupName}>{v.title}</div> <div className={styles.groupName}>{v.title}</div>
<div className={styles.boxs}> <div className={styles.boxs}>
{ {
v.child.map(s => { v.child.map(s => {
return ( return (
<div className={styles.box} style={{ width: s.width }}> <div key={s.fieldName} className={styles.box} style={{ width: s.width }}>
<div className={styles.itemLeft} style={{ width: s.labelWidth }}>{s.title}</div> <div className={styles.itemLeft} style={{ width: s.labelWidth }}>{s.title}</div>
<div className={styles.itemRight}>{s.fieldValue}</div> <div className={styles.itemRight}>{s.fieldValue}</div>
</div> </div>
......
...@@ -130,8 +130,8 @@ const XRender = (props, ref) => { ...@@ -130,8 +130,8 @@ const XRender = (props, ref) => {
watch={watch} watch={watch}
onMount={onMount} onMount={onMount}
/> />
{print ? <PrintXform schemaForm={schemaForm} form={form} /> : null}
</Spin> </Spin>
{print ? <PrintXform schemaForm={schemaForm} form={form} /> : null}
</div> </div>
) )
......
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