This commit is contained in:
lovemegowin
2019-06-24 15:20:25 +08:00
parent a29d761483
commit df82ee42fd
4 changed files with 31 additions and 46 deletions
-5
View File
@@ -26,11 +26,6 @@ const TwoColProps = {
@withI18n()
@Form.create()
class Filter extends Component {
componentDidUpdate(prevProps, prevState) {
if (Object.keys(prevProps.filter).length === 0) {
this.handleReset()
}
}
handleFields = fields => {
const { createTime } = fields
if (createTime.length) {
+29 -22
View File
@@ -13,9 +13,30 @@ import Modal from './components/Modal'
@withI18n()
@connect(({ user, loading }) => ({ user, loading }))
class User extends PureComponent {
componentDidMount() {
this.handleRefresh({ page: 1, pageSize: 10 })
}
handleRefresh = newQuery => {
const { location, dispatch } = this.props
const { query, pathname } = location
const payload = {
...query,
...newQuery,
}
dispatch({
type: 'user/query',
payload,
})
router.push({
pathname,
search: stringify(payload, { arrayFormat: 'repeat' }),
})
}
render() {
const { location, dispatch, user, loading, i18n } = this.props
const { query, pathname } = location
const { query } = location
const {
list,
pagination,
@@ -25,19 +46,6 @@ class User extends PureComponent {
selectedRowKeys,
} = user
const handleRefresh = newQuery => {
router.push({
pathname,
search: stringify(
{
...query,
...newQuery,
},
{ arrayFormat: 'repeat' }
),
})
}
const modalProps = {
item: modalType === 'create' ? {} : currentItem,
visible: modalVisible,
@@ -52,7 +60,7 @@ class User extends PureComponent {
type: `user/${modalType}`,
payload: data,
}).then(() => {
handleRefresh()
this.handleRefresh()
})
},
onCancel() {
@@ -66,8 +74,8 @@ class User extends PureComponent {
dataSource: list,
loading: loading.effects['user/query'],
pagination,
onChange(page) {
handleRefresh({
onChange: page => {
this.handleRefresh({
page: page.current,
pageSize: page.pageSize,
})
@@ -77,7 +85,7 @@ class User extends PureComponent {
type: 'user/delete',
payload: id,
}).then(() => {
handleRefresh({
this.handleRefresh({
page:
list.length === 1 && pagination.current > 1
? pagination.current - 1
@@ -111,10 +119,9 @@ class User extends PureComponent {
filter: {
...query,
},
onFilterChange(value) {
handleRefresh({
onFilterChange: value => {
this.handleRefresh({
...value,
page: 1,
})
},
onAdd() {
@@ -134,7 +141,7 @@ class User extends PureComponent {
ids: selectedRowKeys,
},
}).then(() => {
handleRefresh({
this.handleRefresh({
page:
list.length === selectedRowKeys.length && pagination.current > 1
? pagination.current - 1
-14
View File
@@ -22,20 +22,6 @@ export default modelExtend(pageModel, {
selectedRowKeys: [],
},
subscriptions: {
setup({ dispatch, history }) {
history.listen(location => {
if (pathMatchRegexp('/user', location.pathname)) {
const payload = location.query || { page: 1, pageSize: 10 }
dispatch({
type: 'query',
payload,
})
}
})
},
},
effects: {
*query({ payload = {} }, { call, put }) {
const data = yield call(queryUserList, payload)
+2 -5
View File
@@ -33,11 +33,8 @@ export default function request(options) {
message.error(e.message)
}
options.url =
method.toLocaleLowerCase() === 'get'
? `${url}${isEmpty(cloneData) ? '' : '?'}${qs.stringify(cloneData)}`
: url
options.url = url
options.params = cloneData
options.cancelToken = new CancelToken(cancel => {
window.cancelRequest.set(Symbol(Date.now()), {
pathname: window.location.pathname,