Commit c72021a714cd8a2f10aa5d394d315cc601ebfd59

Authored by ww
1 parent 43386bdd

fix: DEFECT-1195 修复任务中心未配置分页

... ... @@ -28,13 +28,21 @@
28 28 },
29 29 });
30 30
  31 + const paginationChange = (page: number, pageSize: number) => {
  32 + pagination.current = page - 1 * pageSize > pagination.total ? 1 : page;
  33 + pagination.pageSize = pageSize;
  34 + getDataSource();
  35 + };
  36 +
31 37 const pagination = reactive({
32   - total: 10,
33 38 current: 1,
34 39 pageSize: 10,
  40 + total: 0,
35 41 showQuickJumper: true,
36 42 size: 'small',
37 43 showTotal: (total: number) => `共 ${total} 条数据`,
  44 + onChange: paginationChange,
  45 + onShowSizeChange: paginationChange,
38 46 });
39 47
40 48 const dataSource = ref<TaskRecordType[]>([]);
... ... @@ -44,12 +52,13 @@
44 52 try {
45 53 loading.value = true;
46 54 const params = getFieldsValue() || {};
47   - const { items } = await getTaskCenterList({
  55 + const { items, total } = await getTaskCenterList({
48 56 page: pagination.current,
49 57 pageSize: pagination.pageSize,
50 58 tbDeviceId: props.tbDeviceId,
51 59 ...params,
52 60 });
  61 + pagination.total = total;
53 62 dataSource.value = items;
54 63 } catch (error) {
55 64 throw error;
... ...
... ... @@ -35,12 +35,21 @@
35 35 },
36 36 });
37 37
  38 + const paginationChange = (page: number, pageSize: number) => {
  39 + pagination.current = page - 1 * pageSize > pagination.total ? 1 : page;
  40 + pagination.pageSize = pageSize;
  41 + getDataSource();
  42 + };
  43 +
38 44 const pagination = reactive({
39   - total: 10,
40 45 current: 1,
  46 + pageSize: 10,
  47 + total: 0,
41 48 showQuickJumper: true,
42 49 size: 'small',
43 50 showTotal: (total: number) => `共 ${total} 条数据`,
  51 + onChange: paginationChange,
  52 + onShowSizeChange: paginationChange,
44 53 });
45 54
46 55 const dataSource = ref<TaskRecordType[]>([]);
... ... @@ -49,8 +58,13 @@
49 58 try {
50 59 loading.value = true;
51 60 const params = getFieldsValue();
52   - const { items } = await getTaskCenterList({ page: 1, pageSize: 10, ...params });
  61 + const { items, total } = await getTaskCenterList({
  62 + page: pagination.current,
  63 + pageSize: pagination.pageSize,
  64 + ...params,
  65 + });
53 66 dataSource.value = items;
  67 + pagination.total = total;
54 68 } catch (error) {
55 69 throw error;
56 70 } finally {
... ...