@ysgroup/ui 0.1.15 → 0.1.17
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
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ysgroup/ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@element-plus/icons-vue": "^2.3.1",
|
|
9
|
-
"@ysgroup/contracts": "^0.1.
|
|
9
|
+
"@ysgroup/contracts": "^0.1.3",
|
|
10
10
|
"@ysgroup/theme": "^0.1.0"
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
@@ -7,6 +7,7 @@ import { FIELD_SPECS, ENUM_META } from "@ysgroup/contracts";
|
|
|
7
7
|
import { enumLabel } from "../tokens-runtime";
|
|
8
8
|
import YsFormDialog from "./YsFormDialog.vue";
|
|
9
9
|
import YsRowActionMenu from "./YsRowActionMenu.vue";
|
|
10
|
+
import YsTableToolbar from "./YsTableToolbar.vue";
|
|
10
11
|
|
|
11
12
|
interface FieldSpec {
|
|
12
13
|
key: string;
|
|
@@ -94,13 +95,7 @@ const displayColumns = computed<FieldSpec[]>(() => {
|
|
|
94
95
|
const filtered = computed(() => {
|
|
95
96
|
const kw = keyword.value.trim().toLowerCase();
|
|
96
97
|
if (!kw) return props.rows;
|
|
97
|
-
return props.rows.filter((r) =>
|
|
98
|
-
displayColumns.value.some((c) =>
|
|
99
|
-
String(r[c.key] ?? "")
|
|
100
|
-
.toLowerCase()
|
|
101
|
-
.includes(kw),
|
|
102
|
-
),
|
|
103
|
-
);
|
|
98
|
+
return props.rows.filter((r) => displayColumns.value.some((c) => display(r, c).toLowerCase().includes(kw)));
|
|
104
99
|
});
|
|
105
100
|
|
|
106
101
|
// 搜索词变化时重置到第一页
|
|
@@ -159,11 +154,11 @@ function onSubmit(payload: Record<string, unknown>) {
|
|
|
159
154
|
|
|
160
155
|
<template>
|
|
161
156
|
<div class="ys-crud">
|
|
162
|
-
<
|
|
163
|
-
<
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
</
|
|
157
|
+
<YsTableToolbar v-model:keyword="keyword">
|
|
158
|
+
<template #actions
|
|
159
|
+
><el-button v-if="!readonly" type="primary" @click="onCreate">{{ createLabel || "新建" }}</el-button></template
|
|
160
|
+
>
|
|
161
|
+
</YsTableToolbar>
|
|
167
162
|
|
|
168
163
|
<el-table :data="paged" v-loading="loading" stripe border size="small" table-layout="fixed" row-key="_id">
|
|
169
164
|
<el-table-column v-for="c in displayColumns" :key="c.key" :label="c.title" :width="columnWidth(c)" show-overflow-tooltip>
|
|
@@ -184,23 +179,10 @@ function onSubmit(payload: Record<string, unknown>) {
|
|
|
184
179
|
</el-table-column>
|
|
185
180
|
</el-table>
|
|
186
181
|
|
|
187
|
-
<YsTablePagination
|
|
188
|
-
v-model:current-page="currentPage"
|
|
189
|
-
v-model:page-size="pageSize"
|
|
190
|
-
:total="filtered.length"
|
|
191
|
-
/>
|
|
182
|
+
<YsTablePagination v-model:current-page="currentPage" v-model:page-size="pageSize" :total="filtered.length" />
|
|
192
183
|
|
|
193
184
|
<YsFormDialog v-if="!externalEditor" v-model="dialogOpen" :table="table" :record="editing" :hidden="hiddenInForm" :saving="saving" @submit="onSubmit" />
|
|
194
185
|
</div>
|
|
195
186
|
</template>
|
|
196
187
|
|
|
197
|
-
<style scoped>
|
|
198
|
-
.ys-crud__toolbar {
|
|
199
|
-
display: flex;
|
|
200
|
-
align-items: center;
|
|
201
|
-
margin-bottom: 12px;
|
|
202
|
-
}
|
|
203
|
-
.ys-crud__spacer {
|
|
204
|
-
flex: 1;
|
|
205
|
-
}
|
|
206
|
-
</style>
|
|
188
|
+
<style scoped></style>
|
|
@@ -129,7 +129,7 @@ defineExpose({
|
|
|
129
129
|
</template>
|
|
130
130
|
<el-empty v-else description="Root 登录密码由平台安全配置维护,不允许在设置中心修改" :image-size="72" />
|
|
131
131
|
</el-tab-pane>
|
|
132
|
-
<el-tab-pane v-if="
|
|
132
|
+
<el-tab-pane v-if="['Admin', 'Manager'].includes(role) && $slots.managerActions" label="前端管理" name="manager-actions">
|
|
133
133
|
<slot name="managerActions" />
|
|
134
134
|
</el-tab-pane>
|
|
135
135
|
</el-tabs>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
defineProps<{
|
|
3
|
+
keyword: string;
|
|
4
|
+
placeholder?: string;
|
|
5
|
+
}>();
|
|
6
|
+
|
|
7
|
+
const emit = defineEmits<{
|
|
8
|
+
"update:keyword": [value: string];
|
|
9
|
+
}>();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<template>
|
|
13
|
+
<div class="ys-table-toolbar">
|
|
14
|
+
<el-input :model-value="keyword" :placeholder="placeholder || '搜索'" clearable class="ys-table-toolbar__search" @update:model-value="emit('update:keyword', String($event))" />
|
|
15
|
+
<slot />
|
|
16
|
+
<div class="ys-table-toolbar__spacer" />
|
|
17
|
+
<slot name="actions" />
|
|
18
|
+
</div>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<style scoped>
|
|
22
|
+
.ys-table-toolbar {
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
gap: 10px;
|
|
26
|
+
margin-bottom: 12px;
|
|
27
|
+
flex-wrap: wrap;
|
|
28
|
+
}
|
|
29
|
+
.ys-table-toolbar__search {
|
|
30
|
+
width: 200px;
|
|
31
|
+
}
|
|
32
|
+
.ys-table-toolbar__spacer {
|
|
33
|
+
flex: 1;
|
|
34
|
+
}
|
|
35
|
+
</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 YsTableToolbar } from "./components/YsTableToolbar.vue";
|
|
4
5
|
export { default as YsTablePagination } from "./components/YsTablePagination.vue";
|
|
5
6
|
export { default as YsRowActionMenu } from "./components/YsRowActionMenu.vue";
|
|
6
7
|
export type { YsRowAction } from "./components/YsRowActionMenu.vue";
|