Skip to content

Commit 433e942

Browse files
author
zhangtao
committed
refactor(ui): add table page shell and reusable descriptions
- add FaTablePage for the standard search/card/header shell and migrate online/workflow as pilots - add FaDescriptions formatter support - reuse FaUploadBase inside FaUpload
1 parent c31ec2f commit 433e942

5 files changed

Lines changed: 357 additions & 300 deletions

File tree

‎frontend/web/src/components/actions/fa-upload/index.vue‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
/>
2828
</FaDialog>
2929

30-
<ElUpload
30+
<FaUploadBase
3131
v-model:file-list="internalFileList"
3232
class="single-upload"
3333
list-type="picture-card"
@@ -76,7 +76,7 @@
7676
</ElIcon>
7777
</template>
7878
</template>
79-
</ElUpload>
79+
</FaUploadBase>
8080
<div v-if="props.showTip" class="mt-1.75 text-xs text-(--el-text-color-regular)">
8181
{{ props.tipText || `支持 ${props.accept} 格式,文件大小不超过 ${props.maxFileSize}MB` }}
8282
</div>

‎frontend/web/src/components/display/fa-descriptions/index.vue‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ export interface DescriptionsItem {
3232
slot?: string;
3333
labelClassName?: string;
3434
className?: string;
35+
/** 普通字段的展示格式化;优先于默认的 String(value) */
36+
formatter?: (value: unknown, data: Record<string, unknown> | null) => string | number;
3537
}
3638
3739
const TAG_TYPES: Set<string> = new Set(["primary", "success", "warning", "danger", "info"]);
@@ -124,6 +126,8 @@ const FaDescriptionsContent = defineComponent({
124126
{ default: () => resolveTagText(value, tag) }
125127
)
126128
);
129+
} else if (item.formatter) {
130+
itemChildren.push(String(item.formatter(value, props.data)));
127131
} else {
128132
const propSlot = slots[item.prop];
129133
if (propSlot) {
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<template>
2+
<div class="fa-full-height">
3+
<slot name="search" />
4+
5+
<ElCard class="fa-table-card" :style="{ marginTop: showSearchBar ? '12px' : '0' }">
6+
<FaTableHeader
7+
v-model:columns="columns"
8+
v-model:show-search-bar="showSearchBar"
9+
:loading="loading"
10+
:layout="layout"
11+
@refresh="emit('refresh')"
12+
>
13+
<template #left>
14+
<slot name="header-left" />
15+
</template>
16+
<template #right>
17+
<slot name="header-right" />
18+
</template>
19+
</FaTableHeader>
20+
21+
<slot />
22+
</ElCard>
23+
24+
<slot name="dialogs" />
25+
</div>
26+
</template>
27+
28+
<script setup lang="ts">
29+
import type { ColumnOption } from "@/types/component";
30+
31+
defineOptions({ name: "FaTablePage" });
32+
33+
withDefaults(
34+
defineProps<{
35+
loading?: boolean;
36+
layout?: string;
37+
}>(),
38+
{
39+
loading: false,
40+
layout: "search,refresh,size,fullscreen,columns,settings",
41+
}
42+
);
43+
44+
const showSearchBar = defineModel<boolean>("showSearchBar", { default: true });
45+
const columns = defineModel<ColumnOption[]>("columns", { default: () => [] });
46+
47+
const emit = defineEmits<{ refresh: [] }>();
48+
49+
defineSlots<{
50+
search?: () => unknown;
51+
"header-left"?: () => unknown;
52+
"header-right"?: () => unknown;
53+
default?: () => unknown;
54+
dialogs?: () => unknown;
55+
}>();
56+
</script>

0 commit comments

Comments
 (0)