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 | <script setup lang="ts"> | 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 | import { computed, onMounted, reactive, ref, unref } from 'vue'; | 4 | import { computed, onMounted, reactive, ref, unref } from 'vue'; |
5 | import { OrganizationIdTree, useResetOrganizationTree } from '../../common/organizationIdTree'; | 5 | import { OrganizationIdTree, useResetOrganizationTree } from '../../common/organizationIdTree'; |
6 | import { | 6 | import { |
@@ -21,7 +21,7 @@ | @@ -21,7 +21,7 @@ | ||
21 | import { cloneDeep } from 'lodash'; | 21 | import { cloneDeep } from 'lodash'; |
22 | import { usePermission } from '/@/hooks/web/usePermission'; | 22 | import { usePermission } from '/@/hooks/web/usePermission'; |
23 | import { useGlobSetting } from '/@/hooks/setting'; | 23 | import { useGlobSetting } from '/@/hooks/setting'; |
24 | - import { AuthIcon } from '/@/components/Widget'; | 24 | + import { AuthIcon, CardLayoutButton } from '/@/components/Widget'; |
25 | import AuthDropDown from '/@/components/Widget/AuthDropDown.vue'; | 25 | import AuthDropDown from '/@/components/Widget/AuthDropDown.vue'; |
26 | 26 | ||
27 | const listColumn = ref(5); | 27 | const listColumn = ref(5); |
@@ -34,6 +34,7 @@ | @@ -34,6 +34,7 @@ | ||
34 | size: 'small', | 34 | size: 'small', |
35 | showTotal: (total: number) => `共 ${total} 条数据`, | 35 | showTotal: (total: number) => `共 ${total} 条数据`, |
36 | current: 1, | 36 | current: 1, |
37 | + pageSize: unref(listColumn) * 2, | ||
37 | onChange: (page: number) => { | 38 | onChange: (page: number) => { |
38 | pagination.current = page; | 39 | pagination.current = page; |
39 | getListData(); | 40 | getListData(); |
@@ -63,16 +64,16 @@ | @@ -63,16 +64,16 @@ | ||
63 | async function getListData(value: Recordable = {}) { | 64 | async function getListData(value: Recordable = {}) { |
64 | try { | 65 | try { |
65 | loading.value = true; | 66 | loading.value = true; |
66 | - const pageSize = 4 * unref(listColumn); | 67 | + const pageSize = unref(listColumn) * 2; |
67 | const { items, total } = await getPage({ | 68 | const { items, total } = await getPage({ |
68 | organizationId: unref(organizationId), | 69 | organizationId: unref(organizationId), |
69 | ...value, | 70 | ...value, |
70 | page: pagination.current!, | 71 | page: pagination.current!, |
71 | pageSize, | 72 | pageSize, |
72 | }); | 73 | }); |
74 | + | ||
73 | dataSource.value = items; | 75 | dataSource.value = items; |
74 | - pagination.total = total; | ||
75 | - pagination.pageSize = pageSize; | 76 | + Object.assign(pagination, { total, pageSize }); |
76 | } catch (error) { | 77 | } catch (error) { |
77 | } finally { | 78 | } finally { |
78 | loading.value = false; | 79 | loading.value = false; |
@@ -138,6 +139,11 @@ | @@ -138,6 +139,11 @@ | ||
138 | } catch (error) {} | 139 | } catch (error) {} |
139 | }; | 140 | }; |
140 | 141 | ||
142 | + const handleCardLayoutChange = () => { | ||
143 | + pagination.current = 1; | ||
144 | + getListData(); | ||
145 | + }; | ||
146 | + | ||
141 | const listEl = ref<Nullable<ComponentElRef>>(null); | 147 | const listEl = ref<Nullable<ComponentElRef>>(null); |
142 | 148 | ||
143 | onMounted(() => { | 149 | onMounted(() => { |
@@ -180,23 +186,7 @@ | @@ -180,23 +186,7 @@ | ||
180 | <Authority :value="ConfigurationPermission.CREATE"> | 186 | <Authority :value="ConfigurationPermission.CREATE"> |
181 | <Button type="primary" @click="handleCreateOrUpdate()">新增组态</Button> | 187 | <Button type="primary" @click="handleCreateOrUpdate()">新增组态</Button> |
182 | </Authority> | 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 | <Tooltip title="刷新"> | 190 | <Tooltip title="刷新"> |
201 | <Button type="primary" @click="getListData"> | 191 | <Button type="primary" @click="getListData"> |
202 | <ReloadOutlined @click="getListData" /> | 192 | <ReloadOutlined @click="getListData" /> |
@@ -256,28 +246,6 @@ | @@ -256,28 +246,6 @@ | ||
256 | ]" | 246 | ]" |
257 | :trigger="['hover']" | 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 | </template> | 249 | </template> |
282 | <Card.Meta> | 250 | <Card.Meta> |
283 | <template #title> | 251 | <template #title> |
@@ -308,6 +276,10 @@ | @@ -308,6 +276,10 @@ | ||
308 | height: 24px; | 276 | height: 24px; |
309 | } | 277 | } |
310 | 278 | ||
279 | + .configuration-list:deep(.ant-card-body) { | ||
280 | + padding: 16px !important; | ||
281 | + } | ||
282 | + | ||
311 | .configuration-list:deep(.ant-list-empty-text) { | 283 | .configuration-list:deep(.ant-list-empty-text) { |
312 | @apply w-full h-full flex justify-center items-center; | 284 | @apply w-full h-full flex justify-center items-center; |
313 | } | 285 | } |
@@ -62,10 +62,13 @@ | @@ -62,10 +62,13 @@ | ||
62 | 62 | ||
63 | const loading = ref(false); | 63 | const loading = ref(false); |
64 | 64 | ||
65 | + const colNumber = ref(5); | ||
66 | + | ||
65 | const pagination = reactive<PaginationProps>({ | 67 | const pagination = reactive<PaginationProps>({ |
66 | size: 'small', | 68 | size: 'small', |
67 | showTotal: (total: number) => `共 ${total} 条数据`, | 69 | showTotal: (total: number) => `共 ${total} 条数据`, |
68 | current: 1, | 70 | current: 1, |
71 | + pageSize: unref(colNumber) * 2, | ||
69 | onChange: (page: number) => { | 72 | onChange: (page: number) => { |
70 | pagination.current = page; | 73 | pagination.current = page; |
71 | getDataSource(); | 74 | getDataSource(); |
@@ -74,8 +77,6 @@ | @@ -74,8 +77,6 @@ | ||
74 | 77 | ||
75 | const dataSource = ref<ProfileRecord[]>([]); | 78 | const dataSource = ref<ProfileRecord[]>([]); |
76 | 79 | ||
77 | - const colNumber = ref(5); | ||
78 | - | ||
79 | const getSelectAllFlag = computed(() => { | 80 | const getSelectAllFlag = computed(() => { |
80 | return unref(dataSource).every((item) => item.checked); | 81 | return unref(dataSource).every((item) => item.checked); |
81 | }); | 82 | }); |
@@ -93,13 +94,14 @@ | @@ -93,13 +94,14 @@ | ||
93 | setFieldsValue(otherParams); | 94 | setFieldsValue(otherParams); |
94 | } | 95 | } |
95 | const params = getFieldsValue(); | 96 | const params = getFieldsValue(); |
97 | + const pageSize = unref(colNumber) * 2; | ||
96 | const { items, total } = await deviceConfigGetQuery({ | 98 | const { items, total } = await deviceConfigGetQuery({ |
97 | page: pagination.current, | 99 | page: pagination.current, |
98 | pageSize: unref(colNumber) * 2, | 100 | pageSize: unref(colNumber) * 2, |
99 | ...params, | 101 | ...params, |
100 | ...otherParams, | 102 | ...otherParams, |
101 | }); | 103 | }); |
102 | - pagination.total = total; | 104 | + Object.assign(pagination, { total, pageSize }); |
103 | dataSource.value = items.map((item) => ({ ...item, checked: false })); | 105 | dataSource.value = items.map((item) => ({ ...item, checked: false })); |
104 | } catch (error) { | 106 | } catch (error) { |
105 | } finally { | 107 | } finally { |
@@ -162,6 +164,12 @@ | @@ -162,6 +164,12 @@ | ||
162 | throw error; | 164 | throw error; |
163 | } | 165 | } |
164 | }; | 166 | }; |
167 | + | ||
168 | + const handleCardLayoutChange = () => { | ||
169 | + pagination.current = 1; | ||
170 | + getDataSource(); | ||
171 | + }; | ||
172 | + | ||
165 | const { query: routeParams } = useRoute(); | 173 | const { query: routeParams } = useRoute(); |
166 | onMounted(() => { | 174 | onMounted(() => { |
167 | getDataSource(routeParams); | 175 | getDataSource(routeParams); |
@@ -204,7 +212,7 @@ | @@ -204,7 +212,7 @@ | ||
204 | </Authority> | 212 | </Authority> |
205 | 213 | ||
206 | <ModeSwitchButton :value="$props.mode" @change="handleModeChange" /> | 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 | <Tooltip title="刷新"> | 217 | <Tooltip title="刷新"> |
210 | <Button type="primary" @click="getDataSource"> | 218 | <Button type="primary" @click="getDataSource"> |