@vela-studio/ui 1.0.1
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/README.md +152 -0
- package/dist/index.d.ts +696 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +11786 -0
- package/dist/index.mjs.map +1 -0
- package/dist/index.umd.js +10 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/style.css +1 -0
- package/index.ts +150 -0
- package/package.json +73 -0
- package/src/components/advanced/scripting/Scripting.vue +189 -0
- package/src/components/advanced/state/State.vue +231 -0
- package/src/components/advanced/trigger/Trigger.vue +256 -0
- package/src/components/basic/button/Button.vue +120 -0
- package/src/components/basic/container/Container.vue +22 -0
- package/src/components/chart/barChart/barChart.vue +176 -0
- package/src/components/chart/doughnutChart/doughnutChart.vue +128 -0
- package/src/components/chart/funnelChart/funnelChart.vue +128 -0
- package/src/components/chart/gaugeChart/gaugeChart.vue +144 -0
- package/src/components/chart/lineChart/lineChart.vue +188 -0
- package/src/components/chart/pieChart/pieChart.vue +114 -0
- package/src/components/chart/radarChart/radarChart.vue +115 -0
- package/src/components/chart/sankeyChart/sankeyChart.vue +144 -0
- package/src/components/chart/scatterChart/scatterChart.vue +162 -0
- package/src/components/chart/stackedBarChart/stackedBarChart.vue +184 -0
- package/src/components/content/html/Html.vue +104 -0
- package/src/components/content/iframe/Iframe.vue +111 -0
- package/src/components/content/markdown/Markdown.vue +174 -0
- package/src/components/controls/breadcrumb/Breadcrumb.vue +79 -0
- package/src/components/controls/buttonGroup/ButtonGroup.vue +93 -0
- package/src/components/controls/checkboxGroup/CheckboxGroup.vue +147 -0
- package/src/components/controls/dateRange/DateRange.vue +174 -0
- package/src/components/controls/multiSelect/MultiSelect.vue +155 -0
- package/src/components/controls/navButton/NavButton.vue +97 -0
- package/src/components/controls/pagination/Pagination.vue +94 -0
- package/src/components/controls/searchBox/SearchBox.vue +170 -0
- package/src/components/controls/select/Select.vue +134 -0
- package/src/components/controls/slider/Slider.vue +167 -0
- package/src/components/controls/switch/Switch.vue +107 -0
- package/src/components/data/cardGrid/CardGrid.vue +318 -0
- package/src/components/data/list/List.vue +282 -0
- package/src/components/data/pivot/Pivot.vue +270 -0
- package/src/components/data/table/Table.vue +150 -0
- package/src/components/data/timeline/Timeline.vue +315 -0
- package/src/components/group/Group.vue +75 -0
- package/src/components/kpi/box/Box.vue +98 -0
- package/src/components/kpi/countUp/CountUp.vue +193 -0
- package/src/components/kpi/progress/Progress.vue +159 -0
- package/src/components/kpi/stat/Stat.vue +205 -0
- package/src/components/kpi/text/Text.vue +74 -0
- package/src/components/layout/badge/Badge.vue +105 -0
- package/src/components/layout/col/Col.vue +114 -0
- package/src/components/layout/flex/Flex.vue +105 -0
- package/src/components/layout/grid/Grid.vue +89 -0
- package/src/components/layout/modal/Modal.vue +118 -0
- package/src/components/layout/panel/Panel.vue +162 -0
- package/src/components/layout/row/Row.vue +99 -0
- package/src/components/layout/tabs/Tabs.vue +117 -0
- package/src/components/media/image/Image.vue +132 -0
- package/src/components/media/video/Video.vue +115 -0
- package/src/components/v2/basic/BaseButton.vue +179 -0
- package/src/components/v2/kpi/KpiCard.vue +215 -0
- package/src/components/v2/layout/GridBox.vue +55 -0
- package/src/hooks/useDataSource.ts +123 -0
- package/src/types/gis.ts +251 -0
- package/src/utils/chartUtils.ts +349 -0
- package/src/utils/dataUtils.ts +403 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="multi-select-container" :style="containerStyle">
|
|
3
|
+
<el-select
|
|
4
|
+
v-model="internalValue"
|
|
5
|
+
multiple
|
|
6
|
+
:placeholder="placeholder"
|
|
7
|
+
:clearable="clearable"
|
|
8
|
+
:filterable="filterable"
|
|
9
|
+
:disabled="disabled"
|
|
10
|
+
:size="size"
|
|
11
|
+
:collapse-tags="collapseTags"
|
|
12
|
+
:collapse-tags-tooltip="collapseTagsTooltip"
|
|
13
|
+
:max-collapse-tags="maxCollapseTags"
|
|
14
|
+
:multiple-limit="multipleLimit"
|
|
15
|
+
:style="selectStyle"
|
|
16
|
+
@change="handleChange"
|
|
17
|
+
>
|
|
18
|
+
<el-option
|
|
19
|
+
v-for="option in displayOptions"
|
|
20
|
+
:key="option.value"
|
|
21
|
+
:label="option.label"
|
|
22
|
+
:value="option.value"
|
|
23
|
+
:disabled="option.disabled"
|
|
24
|
+
/>
|
|
25
|
+
</el-select>
|
|
26
|
+
</div>
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<script setup lang="ts">
|
|
30
|
+
import { computed, ref, watch } from 'vue'
|
|
31
|
+
import type { CSSProperties } from 'vue'
|
|
32
|
+
import { ElSelect, ElOption } from 'element-plus'
|
|
33
|
+
|
|
34
|
+
// 选项接口
|
|
35
|
+
export interface SelectOption {
|
|
36
|
+
label: string
|
|
37
|
+
value: string | number
|
|
38
|
+
disabled?: boolean
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const props = withDefaults(
|
|
42
|
+
defineProps<{
|
|
43
|
+
modelValue?: (string | number)[]
|
|
44
|
+
options?: SelectOption[]
|
|
45
|
+
placeholder?: string
|
|
46
|
+
clearable?: boolean
|
|
47
|
+
filterable?: boolean
|
|
48
|
+
disabled?: boolean
|
|
49
|
+
size?: 'large' | 'default' | 'small'
|
|
50
|
+
collapseTags?: boolean
|
|
51
|
+
collapseTagsTooltip?: boolean
|
|
52
|
+
maxCollapseTags?: number
|
|
53
|
+
multipleLimit?: number
|
|
54
|
+
padding?: number
|
|
55
|
+
backgroundColor?: string
|
|
56
|
+
borderRadius?: number
|
|
57
|
+
opacity?: number
|
|
58
|
+
selectWidth?: number
|
|
59
|
+
borderColor?: string
|
|
60
|
+
focusBorderColor?: string
|
|
61
|
+
hoverBorderColor?: string
|
|
62
|
+
tagBackgroundColor?: string
|
|
63
|
+
tagTextColor?: string
|
|
64
|
+
}>(),
|
|
65
|
+
{
|
|
66
|
+
modelValue: () => [],
|
|
67
|
+
options: () => [],
|
|
68
|
+
placeholder: '请选择',
|
|
69
|
+
clearable: true,
|
|
70
|
+
filterable: false,
|
|
71
|
+
disabled: false,
|
|
72
|
+
size: 'default',
|
|
73
|
+
collapseTags: true,
|
|
74
|
+
collapseTagsTooltip: true,
|
|
75
|
+
maxCollapseTags: 2,
|
|
76
|
+
multipleLimit: 0,
|
|
77
|
+
padding: 8,
|
|
78
|
+
backgroundColor: 'transparent',
|
|
79
|
+
borderRadius: 4,
|
|
80
|
+
opacity: 100,
|
|
81
|
+
selectWidth: 100,
|
|
82
|
+
borderColor: '#dcdfe6',
|
|
83
|
+
focusBorderColor: '#409eff',
|
|
84
|
+
hoverBorderColor: '#c0c4cc',
|
|
85
|
+
tagBackgroundColor: '#f0f2f5',
|
|
86
|
+
tagTextColor: '#606266',
|
|
87
|
+
},
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
const emit = defineEmits<{
|
|
91
|
+
'update:modelValue': [value: (string | number)[]]
|
|
92
|
+
change: [value: (string | number)[]]
|
|
93
|
+
}>()
|
|
94
|
+
|
|
95
|
+
// 默认选项
|
|
96
|
+
const defaultOptions: SelectOption[] = [
|
|
97
|
+
{ label: '选项 1', value: '1' },
|
|
98
|
+
{ label: '选项 2', value: '2' },
|
|
99
|
+
{ label: '选项 3', value: '3' },
|
|
100
|
+
{ label: '选项 4', value: '4' },
|
|
101
|
+
{ label: '选项 5', value: '5' },
|
|
102
|
+
]
|
|
103
|
+
|
|
104
|
+
// 显示的选项
|
|
105
|
+
const displayOptions = computed(() => {
|
|
106
|
+
return props.options.length > 0 ? props.options : defaultOptions
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
// 内部值
|
|
110
|
+
const internalValue = ref<(string | number)[]>([...props.modelValue])
|
|
111
|
+
|
|
112
|
+
// 监听外部值变化
|
|
113
|
+
watch(
|
|
114
|
+
() => props.modelValue,
|
|
115
|
+
(newVal) => {
|
|
116
|
+
internalValue.value = [...newVal]
|
|
117
|
+
},
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
// 样式
|
|
121
|
+
const containerStyle = computed<CSSProperties>(() => ({
|
|
122
|
+
opacity: props.opacity / 100,
|
|
123
|
+
display: 'flex',
|
|
124
|
+
alignItems: 'center',
|
|
125
|
+
width: '100%',
|
|
126
|
+
height: '100%',
|
|
127
|
+
padding: `${props.padding}px`,
|
|
128
|
+
backgroundColor: props.backgroundColor,
|
|
129
|
+
borderRadius: `${props.borderRadius}px`,
|
|
130
|
+
}))
|
|
131
|
+
|
|
132
|
+
const selectStyle = computed<CSSProperties>(
|
|
133
|
+
() =>
|
|
134
|
+
({
|
|
135
|
+
width: `${props.selectWidth}%`,
|
|
136
|
+
'--el-input-border-color': props.borderColor,
|
|
137
|
+
'--el-input-focus-border-color': props.focusBorderColor,
|
|
138
|
+
'--el-input-hover-border-color': props.hoverBorderColor,
|
|
139
|
+
'--el-tag-bg-color': props.tagBackgroundColor,
|
|
140
|
+
'--el-tag-text-color': props.tagTextColor,
|
|
141
|
+
}) as CSSProperties,
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
// 事件
|
|
145
|
+
function handleChange(value: (string | number)[]) {
|
|
146
|
+
emit('update:modelValue', value)
|
|
147
|
+
emit('change', value)
|
|
148
|
+
}
|
|
149
|
+
</script>
|
|
150
|
+
|
|
151
|
+
<style scoped>
|
|
152
|
+
.multi-select-container {
|
|
153
|
+
box-sizing: border-box;
|
|
154
|
+
}
|
|
155
|
+
</style>
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="nav-button" :style="containerStyle" @click="handleClick">
|
|
3
|
+
<el-icon v-if="icon" class="nav-icon" :size="iconSize">
|
|
4
|
+
<component :is="iconComponent" />
|
|
5
|
+
</el-icon>
|
|
6
|
+
<span v-if="showLabel" class="nav-label">{{ label }}</span>
|
|
7
|
+
</div>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script setup lang="ts">
|
|
11
|
+
import { computed } from 'vue'
|
|
12
|
+
import type { CSSProperties } from 'vue'
|
|
13
|
+
import * as Icons from '@element-plus/icons-vue'
|
|
14
|
+
import { ElIcon } from 'element-plus'
|
|
15
|
+
|
|
16
|
+
export interface NavButtonProps {
|
|
17
|
+
label?: string
|
|
18
|
+
showLabel?: boolean
|
|
19
|
+
icon?: string
|
|
20
|
+
iconSize?: number
|
|
21
|
+
backgroundColor?: string
|
|
22
|
+
color?: string
|
|
23
|
+
borderRadius?: number
|
|
24
|
+
paddingX?: number
|
|
25
|
+
paddingY?: number
|
|
26
|
+
fontSize?: number
|
|
27
|
+
shadow?: boolean
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const props = withDefaults(defineProps<NavButtonProps>(), {
|
|
31
|
+
label: '跳转',
|
|
32
|
+
showLabel: true,
|
|
33
|
+
icon: 'ArrowRight',
|
|
34
|
+
iconSize: 20,
|
|
35
|
+
backgroundColor: '#409eff',
|
|
36
|
+
color: '#ffffff',
|
|
37
|
+
borderRadius: 8,
|
|
38
|
+
paddingX: 24,
|
|
39
|
+
paddingY: 12,
|
|
40
|
+
fontSize: 14,
|
|
41
|
+
shadow: false,
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
const emit = defineEmits<{
|
|
45
|
+
click: []
|
|
46
|
+
}>()
|
|
47
|
+
|
|
48
|
+
// 图标组件
|
|
49
|
+
const iconComponent = computed(() => {
|
|
50
|
+
const name = props.icon
|
|
51
|
+
return (Icons as Record<string, unknown>)[name] || Icons.ArrowRight
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
// 样式
|
|
55
|
+
const containerStyle = computed<CSSProperties>(() => ({
|
|
56
|
+
backgroundColor: props.backgroundColor,
|
|
57
|
+
color: props.color,
|
|
58
|
+
borderRadius: `${props.borderRadius}px`,
|
|
59
|
+
padding: `${props.paddingY}px ${props.paddingX}px`,
|
|
60
|
+
fontSize: `${props.fontSize}px`,
|
|
61
|
+
cursor: 'pointer',
|
|
62
|
+
display: 'inline-flex',
|
|
63
|
+
alignItems: 'center',
|
|
64
|
+
gap: '8px',
|
|
65
|
+
transition: 'all 0.2s ease',
|
|
66
|
+
boxShadow: props.shadow ? '0 2px 8px rgba(0,0,0,0.15)' : 'none',
|
|
67
|
+
}))
|
|
68
|
+
|
|
69
|
+
function handleClick() {
|
|
70
|
+
emit('click')
|
|
71
|
+
}
|
|
72
|
+
</script>
|
|
73
|
+
|
|
74
|
+
<style scoped>
|
|
75
|
+
.nav-button {
|
|
76
|
+
user-select: none;
|
|
77
|
+
font-weight: 500;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.nav-button:hover {
|
|
81
|
+
filter: brightness(1.1);
|
|
82
|
+
transform: translateY(-1px);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.nav-button:active {
|
|
86
|
+
transform: translateY(0);
|
|
87
|
+
filter: brightness(0.95);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.nav-icon {
|
|
91
|
+
flex-shrink: 0;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.nav-label {
|
|
95
|
+
white-space: nowrap;
|
|
96
|
+
}
|
|
97
|
+
</style>
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="pagination-container" :style="containerStyle">
|
|
3
|
+
<el-pagination
|
|
4
|
+
v-model:current-page="internalPage"
|
|
5
|
+
v-model:page-size="internalSize"
|
|
6
|
+
:page-sizes="pageSizes"
|
|
7
|
+
:layout="layout"
|
|
8
|
+
:total="total"
|
|
9
|
+
:background="background"
|
|
10
|
+
:small="small"
|
|
11
|
+
@current-change="handlePageChange"
|
|
12
|
+
@size-change="handleSizeChange"
|
|
13
|
+
/>
|
|
14
|
+
</div>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script setup lang="ts">
|
|
18
|
+
import { computed, ref, watch } from 'vue'
|
|
19
|
+
import type { CSSProperties } from 'vue'
|
|
20
|
+
import { ElPagination } from 'element-plus'
|
|
21
|
+
|
|
22
|
+
export interface PaginationProps {
|
|
23
|
+
currentPage?: number
|
|
24
|
+
pageSize?: number
|
|
25
|
+
total?: number
|
|
26
|
+
pageSizes?: number[]
|
|
27
|
+
layout?: string
|
|
28
|
+
background?: boolean
|
|
29
|
+
small?: boolean
|
|
30
|
+
backgroundColor?: string
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const props = withDefaults(defineProps<PaginationProps>(), {
|
|
34
|
+
currentPage: 1,
|
|
35
|
+
pageSize: 10,
|
|
36
|
+
total: 100,
|
|
37
|
+
pageSizes: () => [10, 20, 50, 100],
|
|
38
|
+
layout: 'prev, pager, next, sizes, total',
|
|
39
|
+
background: true,
|
|
40
|
+
small: false,
|
|
41
|
+
backgroundColor: 'transparent',
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
const emit = defineEmits<{
|
|
45
|
+
'update:currentPage': [page: number]
|
|
46
|
+
'update:pageSize': [size: number]
|
|
47
|
+
pageChange: [page: number]
|
|
48
|
+
sizeChange: [size: number]
|
|
49
|
+
}>()
|
|
50
|
+
|
|
51
|
+
const internalPage = ref(props.currentPage)
|
|
52
|
+
const internalSize = ref(props.pageSize)
|
|
53
|
+
|
|
54
|
+
// 监听外部 props 变化
|
|
55
|
+
watch(
|
|
56
|
+
() => props.currentPage,
|
|
57
|
+
(val) => {
|
|
58
|
+
internalPage.value = val
|
|
59
|
+
},
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
watch(
|
|
63
|
+
() => props.pageSize,
|
|
64
|
+
(val) => {
|
|
65
|
+
internalSize.value = val
|
|
66
|
+
},
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
const containerStyle = computed<CSSProperties>(() => ({
|
|
70
|
+
'--el-pagination-bg-color': props.backgroundColor,
|
|
71
|
+
}))
|
|
72
|
+
|
|
73
|
+
function handlePageChange(page: number) {
|
|
74
|
+
emit('update:currentPage', page)
|
|
75
|
+
emit('pageChange', page)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function handleSizeChange(size: number) {
|
|
79
|
+
emit('update:pageSize', size)
|
|
80
|
+
emit('sizeChange', size)
|
|
81
|
+
}
|
|
82
|
+
</script>
|
|
83
|
+
|
|
84
|
+
<style scoped>
|
|
85
|
+
.pagination-container {
|
|
86
|
+
display: flex;
|
|
87
|
+
justify-content: center;
|
|
88
|
+
padding: 8px;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
:deep(.el-pagination) {
|
|
92
|
+
justify-content: center;
|
|
93
|
+
}
|
|
94
|
+
</style>
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :style="containerStyle">
|
|
3
|
+
<el-input
|
|
4
|
+
v-model="internalValue"
|
|
5
|
+
:placeholder="placeholder"
|
|
6
|
+
:size="size"
|
|
7
|
+
:clearable="clearable"
|
|
8
|
+
:disabled="disabled"
|
|
9
|
+
:prefix-icon="prefixIcon"
|
|
10
|
+
:suffix-icon="suffixIcon"
|
|
11
|
+
:maxlength="maxlength"
|
|
12
|
+
:show-word-limit="showWordLimit"
|
|
13
|
+
:style="inputStyle"
|
|
14
|
+
@input="handleInput"
|
|
15
|
+
@change="handleChange"
|
|
16
|
+
@clear="handleClear"
|
|
17
|
+
@focus="handleFocus"
|
|
18
|
+
@blur="handleBlur"
|
|
19
|
+
>
|
|
20
|
+
<template v-if="showSearchButton" #append>
|
|
21
|
+
<el-button :icon="SearchIcon" :type="buttonType" @click="handleSearch">
|
|
22
|
+
{{ buttonText }}
|
|
23
|
+
</el-button>
|
|
24
|
+
</template>
|
|
25
|
+
</el-input>
|
|
26
|
+
</div>
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<script setup lang="ts">
|
|
30
|
+
import { computed, ref, watch } from 'vue'
|
|
31
|
+
import type { CSSProperties, Component } from 'vue'
|
|
32
|
+
import { Search as SearchIcon } from '@element-plus/icons-vue'
|
|
33
|
+
import { ElInput, ElButton } from 'element-plus'
|
|
34
|
+
|
|
35
|
+
const props = withDefaults(
|
|
36
|
+
defineProps<{
|
|
37
|
+
modelValue?: string
|
|
38
|
+
placeholder?: string
|
|
39
|
+
size?: 'large' | 'default' | 'small'
|
|
40
|
+
clearable?: boolean
|
|
41
|
+
disabled?: boolean
|
|
42
|
+
prefixIcon?: string | Component
|
|
43
|
+
suffixIcon?: string | Component
|
|
44
|
+
maxlength?: number
|
|
45
|
+
showWordLimit?: boolean
|
|
46
|
+
showSearchButton?: boolean
|
|
47
|
+
buttonText?: string
|
|
48
|
+
buttonType?: 'default' | 'primary' | 'success' | 'warning' | 'info' | 'danger'
|
|
49
|
+
padding?: number
|
|
50
|
+
backgroundColor?: string
|
|
51
|
+
borderColor?: string
|
|
52
|
+
borderFocusColor?: string
|
|
53
|
+
borderHoverColor?: string
|
|
54
|
+
textColor?: string
|
|
55
|
+
placeholderColor?: string
|
|
56
|
+
fontSize?: number
|
|
57
|
+
inputWidth?: string
|
|
58
|
+
}>(),
|
|
59
|
+
{
|
|
60
|
+
modelValue: '',
|
|
61
|
+
placeholder: '请输入搜索内容',
|
|
62
|
+
size: 'default',
|
|
63
|
+
clearable: true,
|
|
64
|
+
disabled: false,
|
|
65
|
+
prefixIcon: undefined,
|
|
66
|
+
suffixIcon: undefined,
|
|
67
|
+
maxlength: undefined,
|
|
68
|
+
showWordLimit: false,
|
|
69
|
+
showSearchButton: true,
|
|
70
|
+
buttonText: '搜索',
|
|
71
|
+
buttonType: 'primary',
|
|
72
|
+
padding: 16,
|
|
73
|
+
backgroundColor: 'transparent',
|
|
74
|
+
borderColor: '#dcdfe6',
|
|
75
|
+
borderFocusColor: '#409eff',
|
|
76
|
+
borderHoverColor: '#c0c4cc',
|
|
77
|
+
textColor: '#606266',
|
|
78
|
+
placeholderColor: '#a8abb2',
|
|
79
|
+
fontSize: 14,
|
|
80
|
+
inputWidth: '100%',
|
|
81
|
+
},
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
const emit = defineEmits<{
|
|
85
|
+
'update:modelValue': [value: string]
|
|
86
|
+
input: [value: string]
|
|
87
|
+
change: [value: string]
|
|
88
|
+
clear: []
|
|
89
|
+
search: [value: string]
|
|
90
|
+
focus: []
|
|
91
|
+
blur: []
|
|
92
|
+
}>()
|
|
93
|
+
|
|
94
|
+
// 内部值
|
|
95
|
+
const internalValue = ref(props.modelValue)
|
|
96
|
+
|
|
97
|
+
// 监听外部值变化
|
|
98
|
+
watch(
|
|
99
|
+
() => props.modelValue,
|
|
100
|
+
(newVal) => {
|
|
101
|
+
internalValue.value = newVal
|
|
102
|
+
},
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
// 样式
|
|
106
|
+
const containerStyle = computed<CSSProperties>(() => ({
|
|
107
|
+
padding: `${props.padding}px`,
|
|
108
|
+
backgroundColor: props.backgroundColor,
|
|
109
|
+
}))
|
|
110
|
+
|
|
111
|
+
const inputStyle = computed<CSSProperties>(
|
|
112
|
+
() =>
|
|
113
|
+
({
|
|
114
|
+
width: props.inputWidth,
|
|
115
|
+
fontSize: `${props.fontSize}px`,
|
|
116
|
+
'--el-input-border-color': props.borderColor,
|
|
117
|
+
'--el-input-focus-border-color': props.borderFocusColor,
|
|
118
|
+
'--el-input-hover-border-color': props.borderHoverColor,
|
|
119
|
+
'--el-input-text-color': props.textColor,
|
|
120
|
+
'--el-input-placeholder-color': props.placeholderColor,
|
|
121
|
+
}) as CSSProperties,
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
// 事件处理
|
|
125
|
+
const handleInput = (value: string) => {
|
|
126
|
+
emit('update:modelValue', value)
|
|
127
|
+
emit('input', value)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const handleChange = (value: string) => {
|
|
131
|
+
emit('change', value)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const handleClear = () => {
|
|
135
|
+
emit('clear')
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const handleSearch = () => {
|
|
139
|
+
emit('search', internalValue.value)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const handleFocus = () => {
|
|
143
|
+
emit('focus')
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const handleBlur = () => {
|
|
147
|
+
emit('blur')
|
|
148
|
+
}
|
|
149
|
+
</script>
|
|
150
|
+
|
|
151
|
+
<style scoped>
|
|
152
|
+
.el-input {
|
|
153
|
+
width: v-bind('inputStyle.width');
|
|
154
|
+
font-size: v-bind('inputStyle.fontSize');
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
:deep(.el-input__wrapper) {
|
|
158
|
+
--el-input-border-color: v-bind('inputStyle["--el-input-border-color"]');
|
|
159
|
+
--el-input-focus-border-color: v-bind('inputStyle["--el-input-focus-border-color"]');
|
|
160
|
+
--el-input-hover-border-color: v-bind('inputStyle["--el-input-hover-border-color"]');
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
:deep(.el-input__inner) {
|
|
164
|
+
color: v-bind('inputStyle["--el-input-text-color"]');
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
:deep(.el-input__inner::placeholder) {
|
|
168
|
+
color: v-bind('inputStyle["--el-input-placeholder-color"]');
|
|
169
|
+
}
|
|
170
|
+
</style>
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="select-container" :style="containerStyle">
|
|
3
|
+
<el-select
|
|
4
|
+
v-model="internalValue"
|
|
5
|
+
:placeholder="placeholder"
|
|
6
|
+
:clearable="clearable"
|
|
7
|
+
:filterable="filterable"
|
|
8
|
+
:disabled="disabled"
|
|
9
|
+
:size="size"
|
|
10
|
+
:style="selectStyle"
|
|
11
|
+
@change="handleChange"
|
|
12
|
+
>
|
|
13
|
+
<el-option
|
|
14
|
+
v-for="option in displayOptions"
|
|
15
|
+
:key="option.value"
|
|
16
|
+
:label="option.label"
|
|
17
|
+
:value="option.value"
|
|
18
|
+
:disabled="option.disabled"
|
|
19
|
+
/>
|
|
20
|
+
</el-select>
|
|
21
|
+
</div>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script setup lang="ts">
|
|
25
|
+
import { computed, ref, watch } from 'vue'
|
|
26
|
+
import type { CSSProperties } from 'vue'
|
|
27
|
+
import { ElSelect, ElOption } from 'element-plus'
|
|
28
|
+
|
|
29
|
+
// 选项接口
|
|
30
|
+
export interface SelectOption {
|
|
31
|
+
label: string
|
|
32
|
+
value: string | number
|
|
33
|
+
disabled?: boolean
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const props = withDefaults(
|
|
37
|
+
defineProps<{
|
|
38
|
+
modelValue?: string | number
|
|
39
|
+
options?: SelectOption[]
|
|
40
|
+
placeholder?: string
|
|
41
|
+
clearable?: boolean
|
|
42
|
+
filterable?: boolean
|
|
43
|
+
disabled?: boolean
|
|
44
|
+
size?: 'large' | 'default' | 'small'
|
|
45
|
+
padding?: number
|
|
46
|
+
backgroundColor?: string
|
|
47
|
+
borderRadius?: number
|
|
48
|
+
opacity?: number
|
|
49
|
+
selectWidth?: number
|
|
50
|
+
borderColor?: string
|
|
51
|
+
focusBorderColor?: string
|
|
52
|
+
hoverBorderColor?: string
|
|
53
|
+
}>(),
|
|
54
|
+
{
|
|
55
|
+
modelValue: '',
|
|
56
|
+
options: () => [],
|
|
57
|
+
placeholder: '请选择',
|
|
58
|
+
clearable: true,
|
|
59
|
+
filterable: false,
|
|
60
|
+
disabled: false,
|
|
61
|
+
size: 'default',
|
|
62
|
+
padding: 8,
|
|
63
|
+
backgroundColor: 'transparent',
|
|
64
|
+
borderRadius: 4,
|
|
65
|
+
opacity: 100,
|
|
66
|
+
selectWidth: 100,
|
|
67
|
+
borderColor: '#dcdfe6',
|
|
68
|
+
focusBorderColor: '#409eff',
|
|
69
|
+
hoverBorderColor: '#c0c4cc',
|
|
70
|
+
},
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
const emit = defineEmits<{
|
|
74
|
+
'update:modelValue': [value: string | number]
|
|
75
|
+
change: [value: string | number]
|
|
76
|
+
}>()
|
|
77
|
+
|
|
78
|
+
// 默认选项
|
|
79
|
+
const defaultOptions: SelectOption[] = [
|
|
80
|
+
{ label: '选项 1', value: '1' },
|
|
81
|
+
{ label: '选项 2', value: '2' },
|
|
82
|
+
{ label: '选项 3', value: '3' },
|
|
83
|
+
]
|
|
84
|
+
|
|
85
|
+
// 显示的选项
|
|
86
|
+
const displayOptions = computed(() => {
|
|
87
|
+
return props.options.length > 0 ? props.options : defaultOptions
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
// 内部值
|
|
91
|
+
const internalValue = ref<string | number>(props.modelValue)
|
|
92
|
+
|
|
93
|
+
// 监听外部值变化
|
|
94
|
+
watch(
|
|
95
|
+
() => props.modelValue,
|
|
96
|
+
(newVal) => {
|
|
97
|
+
internalValue.value = newVal
|
|
98
|
+
},
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
// 样式
|
|
102
|
+
const containerStyle = computed<CSSProperties>(() => ({
|
|
103
|
+
opacity: props.opacity / 100,
|
|
104
|
+
display: 'flex',
|
|
105
|
+
alignItems: 'center',
|
|
106
|
+
width: '100%',
|
|
107
|
+
height: '100%',
|
|
108
|
+
padding: `${props.padding}px`,
|
|
109
|
+
backgroundColor: props.backgroundColor,
|
|
110
|
+
borderRadius: `${props.borderRadius}px`,
|
|
111
|
+
}))
|
|
112
|
+
|
|
113
|
+
const selectStyle = computed<CSSProperties>(
|
|
114
|
+
() =>
|
|
115
|
+
({
|
|
116
|
+
width: `${props.selectWidth}%`,
|
|
117
|
+
'--el-input-border-color': props.borderColor,
|
|
118
|
+
'--el-input-focus-border-color': props.focusBorderColor,
|
|
119
|
+
'--el-input-hover-border-color': props.hoverBorderColor,
|
|
120
|
+
}) as CSSProperties,
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
// 事件
|
|
124
|
+
function handleChange(value: string | number) {
|
|
125
|
+
emit('update:modelValue', value)
|
|
126
|
+
emit('change', value)
|
|
127
|
+
}
|
|
128
|
+
</script>
|
|
129
|
+
|
|
130
|
+
<style scoped>
|
|
131
|
+
.select-container {
|
|
132
|
+
box-sizing: border-box;
|
|
133
|
+
}
|
|
134
|
+
</style>
|