Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-admin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
project
jinfa-admin
Commits
302948ed
Commit
302948ed
authored
May 17, 2021
by
前端-许佳敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修复表格上方筛选条件刷新后消失
parent
44670edd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
94 additions
and
1 deletion
+94
-1
index.tsx
src/components/NiceForm/index.tsx
+10
-1
keepAlive.ts
src/components/NiceForm/utils/keepAlive.ts
+46
-0
session.ts
src/components/NiceForm/utils/session.ts
+38
-0
No files found.
src/components/NiceForm/index.tsx
View file @
302948ed
import
React
from
'react'
;
import
React
,
{
useEffect
}
from
'react'
;
import
SchemaForm
,
{
IAntdSchemaFormProps
,
createVirtualBox
,
registerVirtualBox
,
Schema
,
SchemaField
,
FormButtonGroup
,
Reset
,
createControllerBox
,
registerValidationRules
,
}
from
'@formily/antd'
;
...
...
@@ -28,6 +28,7 @@ import DateRangePickerUnix from './components/DateRangePickerUnix';
import
SmilingFace
from
'./components/SmilingFace'
;
import
AntUpload
from
'./components/AntUpload'
;
import
'./index.less'
import
{
currentStateType
,
getCurrentState
}
from
'./utils/keepAlive'
;
export
interface
NiceFormProps
extends
IAntdSchemaFormProps
{}
...
...
@@ -104,6 +105,14 @@ const NiceForm: React.FC<NiceFormProps> = props => {
const
defineComponents
=
Object
.
assign
(
componentExport
,
components
);
useEffect
(()
=>
{
let
paginationInfo
:
currentStateType
=
getCurrentState
();
// @ts-ignore
reset
.
actions
.
setFormState
(
state
=>
(
state
.
values
=
paginationInfo
.
queryParams
),
);
},
[])
return
(
<
SchemaForm
colon=
{
false
}
components=
{
defineComponents
}
{
...
reset
}
>
{
children
}
...
...
src/components/NiceForm/utils/keepAlive.ts
0 → 100644
View file @
302948ed
import
{
get
,
set
,
remove
}
from
'./session'
;
const
STATE_KEY
=
'currentState'
;
export
interface
currentStateType
{
pathname
:
string
;
current
:
number
;
pageSize
:
number
;
queryParams
:
any
;
}
/**
* 保存表格状态
* @param current
* @param pageSize
*/
export
const
saveCurrentState
=
(
current
:
number
,
pageSize
:
number
,
queryParams
?:
any
,
)
=>
{
let
currentPage
=
get
(
STATE_KEY
);
set
(
STATE_KEY
,
Object
.
assign
(
currentPage
?
currentPage
:
{},
{
pathname
:
window
.
location
.
pathname
,
current
,
pageSize
,
queryParams
,
}),
);
};
/**
* 获取表格状态数据
*/
export
const
getCurrentState
=
()
=>
{
return
get
(
STATE_KEY
);
};
/**
* 清除表格状态数据
*/
export
const
clearCurrentState
=
()
=>
{
return
remove
(
STATE_KEY
);
};
src/components/NiceForm/utils/session.ts
0 → 100644
View file @
302948ed
export
const
get
=
key
=>
{
let
result
;
result
=
sessionStorage
.
getItem
(
key
);
if
(
result
)
{
if
(
isJSON
(
result
))
{
result
=
JSON
.
parse
(
result
);
}
return
result
;
}
return
undefined
;
};
export
const
set
=
(
key
,
value
)
=>
{
if
(
typeof
value
===
'object'
)
{
value
=
JSON
.
stringify
(
value
);
}
sessionStorage
.
setItem
(
key
,
value
);
};
export
const
remove
=
key
=>
{
sessionStorage
.
removeItem
(
key
);
};
const
isJSON
=
str
=>
{
if
(
typeof
str
===
'string'
)
{
try
{
var
obj
=
JSON
.
parse
(
str
);
if
(
typeof
obj
===
'object'
&&
obj
)
{
return
true
;
}
else
{
return
false
;
}
}
catch
(
e
)
{
return
false
;
}
}
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment