@ysgroup/ui 0.1.14 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -79,7 +79,6 @@ const dialogOpen = ref(false);
|
|
|
79
79
|
const editing = ref<Record<string, unknown> | null>(null);
|
|
80
80
|
const currentPage = ref(1);
|
|
81
81
|
const pageSize = ref(20);
|
|
82
|
-
const PAGE_SIZES = [20, 50, 100];
|
|
83
82
|
|
|
84
83
|
const allSpecs = computed<FieldSpec[]>(() => (FIELD_SPECS as unknown as Record<string, FieldSpec[]>)[props.table] ?? []);
|
|
85
84
|
|
|
@@ -122,8 +121,6 @@ const paged = computed(() => {
|
|
|
122
121
|
return filtered.value.slice(start, start + pageSize.value);
|
|
123
122
|
});
|
|
124
123
|
|
|
125
|
-
const showPagination = computed(() => filtered.value.length > 20);
|
|
126
|
-
|
|
127
124
|
function display(row: Record<string, unknown>, f: FieldSpec): string {
|
|
128
125
|
const v = props.rowDisplay ? props.rowDisplay(row, f.key, row[f.key]) : row[f.key];
|
|
129
126
|
if (f.widget === "switch") return v ? "是" : "否";
|
|
@@ -187,15 +184,10 @@ function onSubmit(payload: Record<string, unknown>) {
|
|
|
187
184
|
</el-table-column>
|
|
188
185
|
</el-table>
|
|
189
186
|
|
|
190
|
-
<
|
|
191
|
-
v-if="showPagination"
|
|
187
|
+
<YsTablePagination
|
|
192
188
|
v-model:current-page="currentPage"
|
|
193
189
|
v-model:page-size="pageSize"
|
|
194
|
-
:page-sizes="PAGE_SIZES"
|
|
195
190
|
:total="filtered.length"
|
|
196
|
-
layout="total, sizes, prev, pager, next"
|
|
197
|
-
class="ys-crud__pagination"
|
|
198
|
-
@size-change="currentPage = 1"
|
|
199
191
|
/>
|
|
200
192
|
|
|
201
193
|
<YsFormDialog v-if="!externalEditor" v-model="dialogOpen" :table="table" :record="editing" :hidden="hiddenInForm" :saving="saving" @submit="onSubmit" />
|
|
@@ -211,8 +203,4 @@ function onSubmit(payload: Record<string, unknown>) {
|
|
|
211
203
|
.ys-crud__spacer {
|
|
212
204
|
flex: 1;
|
|
213
205
|
}
|
|
214
|
-
.ys-crud__pagination {
|
|
215
|
-
margin-top: 12px;
|
|
216
|
-
justify-content: flex-end;
|
|
217
|
-
}
|
|
218
206
|
</style>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
defineProps<{
|
|
3
|
+
total: number;
|
|
4
|
+
currentPage: number;
|
|
5
|
+
pageSize: number;
|
|
6
|
+
}>();
|
|
7
|
+
|
|
8
|
+
const emit = defineEmits<{
|
|
9
|
+
"update:currentPage": [value: number];
|
|
10
|
+
"update:pageSize": [value: number];
|
|
11
|
+
}>();
|
|
12
|
+
|
|
13
|
+
const PAGE_SIZES = [20, 50, 100];
|
|
14
|
+
|
|
15
|
+
function updatePageSize(value: number): void {
|
|
16
|
+
emit("update:pageSize", value);
|
|
17
|
+
emit("update:currentPage", 1);
|
|
18
|
+
}
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<template>
|
|
22
|
+
<el-pagination
|
|
23
|
+
v-if="total > 20"
|
|
24
|
+
:current-page="currentPage"
|
|
25
|
+
:page-size="pageSize"
|
|
26
|
+
:page-sizes="PAGE_SIZES"
|
|
27
|
+
:total="total"
|
|
28
|
+
layout="total, sizes, prev, pager, next"
|
|
29
|
+
class="ys-table-pagination"
|
|
30
|
+
@update:current-page="emit('update:currentPage', $event)"
|
|
31
|
+
@update:page-size="updatePageSize"
|
|
32
|
+
/>
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<style scoped>
|
|
36
|
+
.ys-table-pagination {
|
|
37
|
+
margin-top: 12px;
|
|
38
|
+
justify-content: flex-end;
|
|
39
|
+
}
|
|
40
|
+
</style>
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* @ysgroup/ui —— 平台组件库(基于 Element Plus 封装,令牌来自 @ysgroup/theme)。 */
|
|
2
2
|
|
|
3
3
|
export { default as YsCrudTable } from "./components/YsCrudTable.vue";
|
|
4
|
+
export { default as YsTablePagination } from "./components/YsTablePagination.vue";
|
|
4
5
|
export { default as YsRowActionMenu } from "./components/YsRowActionMenu.vue";
|
|
5
6
|
export type { YsRowAction } from "./components/YsRowActionMenu.vue";
|
|
6
7
|
export { default as YsFormDialog } from "./components/YsFormDialog.vue";
|