search.vue
2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<script setup lang="ts">
import { AnyObject } from "@/types/global";
import { Layout, LayoutContent, LayoutSider, Form, Space, Grid } from "@arco-design/web-vue";
import IconButton from "@/components/icon-button/index.vue";
type PropType = {
model?: AnyObject;
loading?: boolean;
searchLabel?: string;
searchIcon?: string;
resetLabel?: string;
resetIcon?: string;
hideSearch?: boolean;
hideReset?: boolean;
inline?: boolean;
split?: number;
size?: "mini" | "small" | "medium" | "large";
hideDivider?: boolean;
};
const props = withDefaults(defineProps<PropType>(), {
loading: false,
searchLabel: "搜索",
searchIcon: "search",
resetLabel: "重置",
resetIcon: "refresh",
hideSearch: false,
hideReset: false,
hideDivider: false,
inline: false,
split: 3,
size: "small"
});
defineEmits<{ (e?: "search"): void; (e?: "reset"): void }>();
const layoutStyle = { marginBottom: "12px" };
const layoutRightStyle = props.hideSearch && props.hideReset ? {} : { borderLeft: "1px solid var(--color-neutral-3)" };
if (!props.hideDivider) {
Object.assign(layoutStyle, { paddingBottom: "12px", borderBottom: "1px solid var(--color-neutral-3)" });
}
</script>
<template>
<Layout :style="layoutStyle">
<LayoutContent>
<Form auto-label-width :model="model || {}" label-align="right" :size="size">
<Grid :cols="split as number" :col-gap="12" :row-gap="12">
<slot :size="size" />
</Grid>
</Form>
</LayoutContent>
<LayoutSider class="right" :style="layoutRightStyle">
<Space :size="12" :direction="inline ? 'horizontal' : 'vertical'">
<IconButton
v-if="!hideSearch"
:size="size"
:icon="searchIcon"
:label="searchLabel"
type="primary"
:loading="loading"
@click="$emit('search')"
/>
<IconButton v-if="!hideReset" :size="size" :icon="resetIcon" :label="resetLabel" @click="$emit('reset')" />
<slot name="button" />
</Space>
</LayoutSider>
</Layout>
</template>
<style scoped lang="less">
.right {
border-left: 1px solid var(--color-neutral-3);
margin-left: 12px;
padding-left: 12px;
box-shadow: unset;
width: auto !important;
}
</style>