Skip to content

Commit a96b327

Browse files
authored
Fix pagination (#65)
1 parent 49c85e7 commit a96b327

File tree

8 files changed

+29
-34
lines changed

8 files changed

+29
-34
lines changed

src/pages/alert/event/AlertCurEvent.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,6 @@ export const AlertCurEvent = () => {
382382
current: pagination.current ?? 1,
383383
pageSize: pagination.pageSize ?? 10,
384384
total: pagination?.total ?? 0,
385-
showQuickJumper: true,
386-
showSizeChanger: true,
387385
showTotal: handleShowTotal,
388386
}}
389387
scroll={{

src/pages/alert/event/AlertHisEvent.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,6 @@ export const AlertHisEvent = () => {
414414
current: pagination.current ?? 1,
415415
pageSize: pagination.pageSize ?? 10,
416416
total: pagination.total ?? 0,
417-
showQuickJumper: true,
418-
showSizeChanger: true,
419417
showTotal: handleShowTotal,
420418
}}
421419
onChange={handlePageChange}

src/pages/alert/rule/create.jsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const MyFormItem = ({ name, ...props }) => {
5050
return <Form.Item name={concatName} {...props} />
5151
}
5252

53-
export const AlertRule = ({ type, handleList, ruleGroupId }) => {
53+
export const AlertRule = ({ type, ruleGroupId }) => {
5454
const [form] = Form.useForm()
5555
const { id,ruleId } = useParams()
5656
const [selectedRow,setSelectedRow] = useState({})
@@ -340,7 +340,6 @@ export const AlertRule = ({ type, handleList, ruleGroupId }) => {
340340
}
341341

342342
await createRule(params)
343-
handleList(ruleGroupId)
344343
} catch (error) {
345344
console.error(error)
346345
}
@@ -385,7 +384,6 @@ export const AlertRule = ({ type, handleList, ruleGroupId }) => {
385384
}
386385

387386
await updateRule(params)
388-
handleList(ruleGroupId)
389387
} catch (error) {
390388
console.error(error)
391389
}

src/pages/alert/rule/index.jsx

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export const AlertRuleList = () => {
148148
}, []);
149149

150150
useEffect(() => {
151-
handleList(id)
151+
handleList(id, pagination.index, pagination.size)
152152
handleListDatasource()
153153
}, [])
154154

@@ -176,11 +176,11 @@ export const AlertRuleList = () => {
176176
return matchedNames.join(', ') || 'Unknown'; // Join multiple names with commas
177177
};
178178

179-
const handleList = async (id) => {
179+
const handleList = async (id,index,size) => {
180180
try {
181181
const params = {
182-
index: pagination.index,
183-
size: pagination.size,
182+
index: index,
183+
size: size,
184184
status: selectRuleStatus,
185185
ruleGroupId: id,
186186
}
@@ -205,7 +205,7 @@ export const AlertRuleList = () => {
205205
ruleGroupId: record.ruleGroupId
206206
}
207207
await deleteRule(params)
208-
handleList(id)
208+
handleList(id, pagination.index, pagination.size)
209209
} catch (error) {
210210
console.error(error)
211211
}
@@ -219,11 +219,6 @@ export const AlertRuleList = () => {
219219
setUpdateVisible(false)
220220
}
221221

222-
const handleUpdateModalOpen = (record) => {
223-
setSelectedRow(record)
224-
setUpdateVisible(true)
225-
}
226-
227222
const onSearch = async (value) => {
228223
try {
229224
const params = {
@@ -237,9 +232,9 @@ export const AlertRuleList = () => {
237232
const res = await getRuleList(params)
238233

239234
setPagination({
240-
index: res.data.index,
241-
size: res.data.size,
242-
total: res.data.total,
235+
index: res?.data?.index,
236+
size: res?.data?.size,
237+
total: res?.data?.total,
243238
});
244239

245240
setList(res.data.list);
@@ -252,6 +247,14 @@ export const AlertRuleList = () => {
252247
setSelectRuleStatus(value)
253248
}
254249

250+
const handlePageChange = (page) => {
251+
setPagination({ ...pagination, index: page.current, size: page.size });
252+
handleList(id, page.current, page.size)
253+
};
254+
255+
const handleShowTotal = (total, range) =>
256+
`第 ${range[0]} - ${range[1]} 条 共 ${total} 条`;
257+
255258
return (
256259
<>
257260
<div style={{display: 'flex', justifyContent: 'space-between'}}>
@@ -324,6 +327,13 @@ export const AlertRuleList = () => {
324327
<Table
325328
columns={columns}
326329
dataSource={list}
330+
pagination={{
331+
index: pagination.index ?? 1,
332+
size: pagination.size ?? 10,
333+
total: pagination?.total ?? 0,
334+
showTotal: handleShowTotal,
335+
}}
336+
onChange={handlePageChange}
327337
scroll={{
328338
y: height-400
329339
}}

src/pages/alert/ruleGroup/AlertRuleGroupCreateModal.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const MyFormItem = ({ name, ...props }) => {
1414
return <Form.Item name={concatName} {...props} />
1515
}
1616

17-
export const AlertRuleGroupCreateModal = ({ visible, onClose, selectedRow, type, handleList }) => {
17+
export const AlertRuleGroupCreateModal = ({ visible, onClose, selectedRow, type, handleList, pagination}) => {
1818
const [form] = Form.useForm()
1919

2020
// 禁止输入空格
@@ -47,7 +47,7 @@ export const AlertRuleGroupCreateModal = ({ visible, onClose, selectedRow, type,
4747
const handleCreate = async (data) => {
4848
try {
4949
await createRuleGroup(data)
50-
handleList()
50+
handleList(pagination.index,pagination.size)
5151
} catch (error) {
5252
console.error(error)
5353
}
@@ -56,7 +56,7 @@ export const AlertRuleGroupCreateModal = ({ visible, onClose, selectedRow, type,
5656
const handleUpdate = async (data) => {
5757
try {
5858
await updateRuleGroup(data)
59-
handleList()
59+
handleList(pagination.index,pagination.size)
6060
} catch (error) {
6161
console.error(error)
6262
}

src/pages/alert/ruleGroup/index.jsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ export const AlertRuleGroup = ({ }) => {
156156
}
157157

158158
const onSearch = async (value) => {
159-
console.log("===>",pagination)
160159
try {
161160
const params = {
162161
index: pagination?.index,
@@ -200,10 +199,10 @@ export const AlertRuleGroup = ({ }) => {
200199
</div>
201200

202201
<AlertRuleGroupCreateModal visible={createModalVisible} onClose={handleModalClose} type='create'
203-
handleList={handleList}/>
202+
handleList={handleList} pagination={pagination}/>
204203

205204
<AlertRuleGroupCreateModal visible={updateModalVisible} onClose={handleUpdateModalClose}
206-
selectedRow={selectedRow} type='update' handleList={handleList}/>
205+
selectedRow={selectedRow} type='update' handleList={handleList} pagination={pagination}/>
207206

208207
<div style={{overflowX: 'auto', marginTop: 10}}>
209208
<Table
@@ -213,8 +212,6 @@ export const AlertRuleGroup = ({ }) => {
213212
index: pagination.index ?? 1,
214213
size: pagination.size ?? 10,
215214
total: pagination?.total ?? 0,
216-
showQuickJumper: true,
217-
showSizeChanger: true,
218215
showTotal: handleShowTotal,
219216
}}
220217
onChange={handlePageChange}

src/pages/audit/index.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,6 @@ export const AuditLog = () => {
250250
index: pagination.index ?? 1,
251251
size: pagination.size ?? 10,
252252
total: pagination?.total ?? 0,
253-
showQuickJumper: true,
254-
showSizeChanger: true,
255253
showTotal: handleShowTotal,
256254
}}
257255
onChange={handlePageChange}

src/pages/event/index.jsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -675,8 +675,6 @@ export const AlertEvent = () => {
675675
current: currentPagination.pageIndex ?? 1,
676676
pageSize: currentPagination.pageSize ?? 10,
677677
total: currentPagination?.pageTotal ?? 0,
678-
showQuickJumper: true,
679-
showSizeChanger: true,
680678
showTotal: handleShowTotal,
681679
}}
682680
onChange={handleCurrentPageChange}
@@ -693,8 +691,6 @@ export const AlertEvent = () => {
693691
current: historyPagination.pageIndex ?? 1,
694692
pageSize: historyPagination.pageSize ?? 10,
695693
total: historyPagination?.pageTotal ?? 0,
696-
showQuickJumper: true,
697-
showSizeChanger: true,
698694
showTotal: handleShowTotal,
699695
}}
700696
onChange={handleHistoryPageChange}

0 commit comments

Comments
 (0)