Commit 478618a02d13e1ead0179a6a2441caf378b4c33a
1 parent
c2cbd62e
fix: product profile page && configuration center page layout change pagination not update
Showing
2 changed files
with
29 additions
and
49 deletions
1 | 1 | <script setup lang="ts"> |
2 | - import { List, Card, Button, PaginationProps, Popover, Slider, Tooltip } from 'ant-design-vue'; | |
3 | - import { ReloadOutlined, AppstoreOutlined } from '@ant-design/icons-vue'; | |
2 | + import { List, Card, Button, PaginationProps, Tooltip } from 'ant-design-vue'; | |
3 | + import { ReloadOutlined } from '@ant-design/icons-vue'; | |
4 | 4 | import { computed, onMounted, reactive, ref, unref } from 'vue'; |
5 | 5 | import { OrganizationIdTree, useResetOrganizationTree } from '../../common/organizationIdTree'; |
6 | 6 | import { |
... | ... | @@ -21,7 +21,7 @@ |
21 | 21 | import { cloneDeep } from 'lodash'; |
22 | 22 | import { usePermission } from '/@/hooks/web/usePermission'; |
23 | 23 | import { useGlobSetting } from '/@/hooks/setting'; |
24 | - import { AuthIcon } from '/@/components/Widget'; | |
24 | + import { AuthIcon, CardLayoutButton } from '/@/components/Widget'; | |
25 | 25 | import AuthDropDown from '/@/components/Widget/AuthDropDown.vue'; |
26 | 26 | |
27 | 27 | const listColumn = ref(5); |
... | ... | @@ -34,6 +34,7 @@ |
34 | 34 | size: 'small', |
35 | 35 | showTotal: (total: number) => `共 ${total} 条数据`, |
36 | 36 | current: 1, |
37 | + pageSize: unref(listColumn) * 2, | |
37 | 38 | onChange: (page: number) => { |
38 | 39 | pagination.current = page; |
39 | 40 | getListData(); |
... | ... | @@ -63,16 +64,16 @@ |
63 | 64 | async function getListData(value: Recordable = {}) { |
64 | 65 | try { |
65 | 66 | loading.value = true; |
66 | - const pageSize = 4 * unref(listColumn); | |
67 | + const pageSize = unref(listColumn) * 2; | |
67 | 68 | const { items, total } = await getPage({ |
68 | 69 | organizationId: unref(organizationId), |
69 | 70 | ...value, |
70 | 71 | page: pagination.current!, |
71 | 72 | pageSize, |
72 | 73 | }); |
74 | + | |
73 | 75 | dataSource.value = items; |
74 | - pagination.total = total; | |
75 | - pagination.pageSize = pageSize; | |
76 | + Object.assign(pagination, { total, pageSize }); | |
76 | 77 | } catch (error) { |
77 | 78 | } finally { |
78 | 79 | loading.value = false; |
... | ... | @@ -138,6 +139,11 @@ |
138 | 139 | } catch (error) {} |
139 | 140 | }; |
140 | 141 | |
142 | + const handleCardLayoutChange = () => { | |
143 | + pagination.current = 1; | |
144 | + getListData(); | |
145 | + }; | |
146 | + | |
141 | 147 | const listEl = ref<Nullable<ComponentElRef>>(null); |
142 | 148 | |
143 | 149 | onMounted(() => { |
... | ... | @@ -180,23 +186,7 @@ |
180 | 186 | <Authority :value="ConfigurationPermission.CREATE"> |
181 | 187 | <Button type="primary" @click="handleCreateOrUpdate()">新增组态</Button> |
182 | 188 | </Authority> |
183 | - <Popover :trigger="['hover']"> | |
184 | - <template #content> | |
185 | - <div class="w-50"> | |
186 | - <div>每行显示数量</div> | |
187 | - <Slider | |
188 | - v-model:value="listColumn" | |
189 | - :max="12" | |
190 | - :min="4" | |
191 | - :marks="{ 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10, 11: 11, 12: 12 }" | |
192 | - @change="getListData" | |
193 | - /> | |
194 | - </div> | |
195 | - </template> | |
196 | - <Button type="primary"> | |
197 | - <AppstoreOutlined /> | |
198 | - </Button> | |
199 | - </Popover> | |
189 | + <CardLayoutButton v-model:value="listColumn" @change="handleCardLayoutChange" /> | |
200 | 190 | <Tooltip title="刷新"> |
201 | 191 | <Button type="primary" @click="getListData"> |
202 | 192 | <ReloadOutlined @click="getListData" /> |
... | ... | @@ -256,28 +246,6 @@ |
256 | 246 | ]" |
257 | 247 | :trigger="['hover']" |
258 | 248 | /> |
259 | - <!-- <Dropdown | |
260 | - :dropMenuList="[ | |
261 | - { | |
262 | - text: '编辑', | |
263 | - auth: ConfigurationPermission.UPDATE, | |
264 | - icon: 'clarity:note-edit-line', | |
265 | - event: '', | |
266 | - onClick: handleCreateOrUpdate.bind(null, item), | |
267 | - }, | |
268 | - { | |
269 | - text: '删除', | |
270 | - auth: ConfigurationPermission.DELETE, | |
271 | - icon: 'ant-design:delete-outlined', | |
272 | - color: 'error', | |
273 | - event: '', | |
274 | - onClick: handleDelete.bind(null, item), | |
275 | - }, | |
276 | - ]" | |
277 | - :trigger="['hover']" | |
278 | - > | |
279 | - <EllipsisOutlined key="ellipsis" /> | |
280 | - </Dropdown> --> | |
281 | 249 | </template> |
282 | 250 | <Card.Meta> |
283 | 251 | <template #title> |
... | ... | @@ -308,6 +276,10 @@ |
308 | 276 | height: 24px; |
309 | 277 | } |
310 | 278 | |
279 | + .configuration-list:deep(.ant-card-body) { | |
280 | + padding: 16px !important; | |
281 | + } | |
282 | + | |
311 | 283 | .configuration-list:deep(.ant-list-empty-text) { |
312 | 284 | @apply w-full h-full flex justify-center items-center; |
313 | 285 | } | ... | ... |
... | ... | @@ -62,10 +62,13 @@ |
62 | 62 | |
63 | 63 | const loading = ref(false); |
64 | 64 | |
65 | + const colNumber = ref(5); | |
66 | + | |
65 | 67 | const pagination = reactive<PaginationProps>({ |
66 | 68 | size: 'small', |
67 | 69 | showTotal: (total: number) => `共 ${total} 条数据`, |
68 | 70 | current: 1, |
71 | + pageSize: unref(colNumber) * 2, | |
69 | 72 | onChange: (page: number) => { |
70 | 73 | pagination.current = page; |
71 | 74 | getDataSource(); |
... | ... | @@ -74,8 +77,6 @@ |
74 | 77 | |
75 | 78 | const dataSource = ref<ProfileRecord[]>([]); |
76 | 79 | |
77 | - const colNumber = ref(5); | |
78 | - | |
79 | 80 | const getSelectAllFlag = computed(() => { |
80 | 81 | return unref(dataSource).every((item) => item.checked); |
81 | 82 | }); |
... | ... | @@ -93,13 +94,14 @@ |
93 | 94 | setFieldsValue(otherParams); |
94 | 95 | } |
95 | 96 | const params = getFieldsValue(); |
97 | + const pageSize = unref(colNumber) * 2; | |
96 | 98 | const { items, total } = await deviceConfigGetQuery({ |
97 | 99 | page: pagination.current, |
98 | 100 | pageSize: unref(colNumber) * 2, |
99 | 101 | ...params, |
100 | 102 | ...otherParams, |
101 | 103 | }); |
102 | - pagination.total = total; | |
104 | + Object.assign(pagination, { total, pageSize }); | |
103 | 105 | dataSource.value = items.map((item) => ({ ...item, checked: false })); |
104 | 106 | } catch (error) { |
105 | 107 | } finally { |
... | ... | @@ -162,6 +164,12 @@ |
162 | 164 | throw error; |
163 | 165 | } |
164 | 166 | }; |
167 | + | |
168 | + const handleCardLayoutChange = () => { | |
169 | + pagination.current = 1; | |
170 | + getDataSource(); | |
171 | + }; | |
172 | + | |
165 | 173 | const { query: routeParams } = useRoute(); |
166 | 174 | onMounted(() => { |
167 | 175 | getDataSource(routeParams); |
... | ... | @@ -204,7 +212,7 @@ |
204 | 212 | </Authority> |
205 | 213 | |
206 | 214 | <ModeSwitchButton :value="$props.mode" @change="handleModeChange" /> |
207 | - <CardLayoutButton v-model:value="colNumber" @change="getDataSource" /> | |
215 | + <CardLayoutButton v-model:value="colNumber" @change="handleCardLayoutChange" /> | |
208 | 216 | |
209 | 217 | <Tooltip title="刷新"> |
210 | 218 | <Button type="primary" @click="getDataSource"> | ... | ... |