@ebiz/designer-components 0.0.18-kzy.1 → 0.0.18-kzy.2
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/dist/designer-components.css +1 -1
- package/dist/index.mjs +371 -266
- package/package.json +1 -1
- package/src/components/EbizRemoteSelect.vue +4 -4
- package/src/components/EbizStatusBadge.vue +182 -0
- package/src/index.js +4 -1
- package/src/router/index.js +6 -0
- package/src/views/Home.vue +2 -1
- package/src/views/StatusBadgeExample.vue +146 -0
package/package.json
CHANGED
@@ -158,8 +158,8 @@ const handleRemoteSearch = async (keyword) => {
|
|
158
158
|
const res = await dataService.fetch(params, props.apiConfig);
|
159
159
|
|
160
160
|
options.value = res.data.map(item => ({
|
161
|
-
label: labelField ? item[labelField] : item.name,
|
162
|
-
value: valueField ? item[valueField] : item.id
|
161
|
+
label: labelField.value ? item[labelField.value] : item.name,
|
162
|
+
value: valueField.value ? item[valueField.value] : item.id
|
163
163
|
}));
|
164
164
|
} catch (error) {
|
165
165
|
console.error('远程搜索失败:', error);
|
@@ -207,8 +207,8 @@ onMounted(async () => {
|
|
207
207
|
|
208
208
|
console.log('res', res)
|
209
209
|
options.value = res.data.map(item => ({
|
210
|
-
label: labelField ? item[labelField] : item.name,
|
211
|
-
value: valueField ? item[valueField] : item.id
|
210
|
+
label: labelField.value ? item[labelField.value] : item.name,
|
211
|
+
value: valueField.value ? item[valueField.value] : item.id
|
212
212
|
}));
|
213
213
|
} catch (error) {
|
214
214
|
console.error('加载默认选项失败:', error);
|
@@ -0,0 +1,182 @@
|
|
1
|
+
<template>
|
2
|
+
<div class="ebiz-status-badge" :style="containerStyle">
|
3
|
+
<div class="status-indicator" :style="indicatorStyle"></div>
|
4
|
+
<div class="status-text" v-if="showText">{{ text }}</div>
|
5
|
+
</div>
|
6
|
+
</template>
|
7
|
+
|
8
|
+
<script>
|
9
|
+
export default {
|
10
|
+
name: "EbizStatusBadge"
|
11
|
+
}
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<script setup>
|
15
|
+
import { computed } from 'vue';
|
16
|
+
|
17
|
+
const props = defineProps({
|
18
|
+
/**
|
19
|
+
* 状态类型
|
20
|
+
*/
|
21
|
+
status: {
|
22
|
+
type: String,
|
23
|
+
default: 'default',
|
24
|
+
validator: (val) => ['default', 'success', 'warning', 'error', 'processing'].includes(val)
|
25
|
+
},
|
26
|
+
/**
|
27
|
+
* 自定义颜色
|
28
|
+
*/
|
29
|
+
color: {
|
30
|
+
type: String,
|
31
|
+
default: ''
|
32
|
+
},
|
33
|
+
/**
|
34
|
+
* 自定义预设颜色映射
|
35
|
+
*/
|
36
|
+
colorMap: {
|
37
|
+
type: Object,
|
38
|
+
default: () => ({})
|
39
|
+
},
|
40
|
+
/**
|
41
|
+
* 指示点大小
|
42
|
+
*/
|
43
|
+
size: {
|
44
|
+
type: [String, Number],
|
45
|
+
default: 'small',
|
46
|
+
validator: (val) => ['small', 'medium', 'large'].includes(val) || typeof val === 'number'
|
47
|
+
},
|
48
|
+
/**
|
49
|
+
* 是否显示文字
|
50
|
+
*/
|
51
|
+
showText: {
|
52
|
+
type: Boolean,
|
53
|
+
default: true
|
54
|
+
},
|
55
|
+
/**
|
56
|
+
* 状态文字
|
57
|
+
*/
|
58
|
+
text: {
|
59
|
+
type: String,
|
60
|
+
default: ''
|
61
|
+
},
|
62
|
+
/**
|
63
|
+
* 状态点位置
|
64
|
+
*/
|
65
|
+
position: {
|
66
|
+
type: String,
|
67
|
+
default: 'left',
|
68
|
+
validator: (val) => ['left', 'right', 'top', 'bottom'].includes(val)
|
69
|
+
},
|
70
|
+
/**
|
71
|
+
* 闪烁效果
|
72
|
+
*/
|
73
|
+
pulse: {
|
74
|
+
type: Boolean,
|
75
|
+
default: false
|
76
|
+
}
|
77
|
+
});
|
78
|
+
|
79
|
+
// 获取预设状态颜色
|
80
|
+
const getStatusColor = (status) => {
|
81
|
+
const defaultColorMap = {
|
82
|
+
default: '#999999',
|
83
|
+
success: '#35c613',
|
84
|
+
warning: '#ed7b2f',
|
85
|
+
error: '#e34d59',
|
86
|
+
processing: '#0052d9'
|
87
|
+
};
|
88
|
+
|
89
|
+
// 优先使用props.color,其次使用用户提供的colorMap,最后使用默认颜色
|
90
|
+
return props.color || props.colorMap[status] || defaultColorMap[status];
|
91
|
+
};
|
92
|
+
|
93
|
+
// 获取点大小
|
94
|
+
const getSize = () => {
|
95
|
+
if (typeof props.size === 'number') {
|
96
|
+
return `${props.size}px`;
|
97
|
+
}
|
98
|
+
|
99
|
+
const sizeMap = {
|
100
|
+
small: '6px',
|
101
|
+
medium: '10px',
|
102
|
+
large: '14px'
|
103
|
+
};
|
104
|
+
|
105
|
+
return sizeMap[props.size];
|
106
|
+
};
|
107
|
+
|
108
|
+
// 计算指示器样式
|
109
|
+
const indicatorStyle = computed(() => {
|
110
|
+
const style = {
|
111
|
+
backgroundColor: getStatusColor(props.status),
|
112
|
+
width: getSize(),
|
113
|
+
height: getSize(),
|
114
|
+
animationName: props.pulse ? 'ebiz-status-pulse' : 'none'
|
115
|
+
};
|
116
|
+
|
117
|
+
return style;
|
118
|
+
});
|
119
|
+
|
120
|
+
// 计算容器样式
|
121
|
+
const containerStyle = computed(() => {
|
122
|
+
const style = {
|
123
|
+
flexDirection: 'row', // 默认水平排列
|
124
|
+
};
|
125
|
+
|
126
|
+
// 根据位置调整排列方向
|
127
|
+
if (props.position === 'top' || props.position === 'bottom') {
|
128
|
+
style.flexDirection = props.position === 'top' ? 'column-reverse' : 'column';
|
129
|
+
} else {
|
130
|
+
style.flexDirection = props.position === 'left' ? 'row' : 'row-reverse';
|
131
|
+
}
|
132
|
+
|
133
|
+
return style;
|
134
|
+
});
|
135
|
+
</script>
|
136
|
+
|
137
|
+
<style scoped>
|
138
|
+
.ebiz-status-badge {
|
139
|
+
display: inline-flex;
|
140
|
+
align-items: center;
|
141
|
+
font-size: 14px;
|
142
|
+
line-height: 1;
|
143
|
+
}
|
144
|
+
|
145
|
+
.status-indicator {
|
146
|
+
border-radius: 50%;
|
147
|
+
flex-shrink: 0;
|
148
|
+
}
|
149
|
+
|
150
|
+
.status-text {
|
151
|
+
margin-left: 8px;
|
152
|
+
}
|
153
|
+
|
154
|
+
.ebiz-status-badge[style*="column"] .status-text {
|
155
|
+
margin-left: 0;
|
156
|
+
margin-top: 4px;
|
157
|
+
}
|
158
|
+
|
159
|
+
.ebiz-status-badge[style*="row-reverse"] .status-text {
|
160
|
+
margin-left: 0;
|
161
|
+
margin-right: 8px;
|
162
|
+
}
|
163
|
+
|
164
|
+
@keyframes ebiz-status-pulse {
|
165
|
+
0% {
|
166
|
+
opacity: 1;
|
167
|
+
transform: scale(1);
|
168
|
+
}
|
169
|
+
50% {
|
170
|
+
opacity: 0.6;
|
171
|
+
transform: scale(1.2);
|
172
|
+
}
|
173
|
+
100% {
|
174
|
+
opacity: 1;
|
175
|
+
transform: scale(1);
|
176
|
+
}
|
177
|
+
}
|
178
|
+
|
179
|
+
.status-indicator[style*="ebiz-status-pulse"] {
|
180
|
+
animation: ebiz-status-pulse 1.5s infinite ease-in-out;
|
181
|
+
}
|
182
|
+
</style>
|
package/src/index.js
CHANGED
@@ -49,6 +49,7 @@ import EbizEmployeeInfo from "./components/EbizEmployeeInfo.vue";
|
|
49
49
|
import EbizAlert from "./components/TdesignAlert.vue";
|
50
50
|
import EbizDialog from "./components/TdesignDialog.vue";
|
51
51
|
import EbizTable from "./components/EbizTable.vue";
|
52
|
+
import EbizStatusBadge from "./components/EbizStatusBadge.vue";
|
52
53
|
import { MessagePlugin as EbizMessage } from 'tdesign-vue-next';
|
53
54
|
|
54
55
|
// 导入简洁数据服务
|
@@ -148,5 +149,7 @@ export {
|
|
148
149
|
// 对话框组件
|
149
150
|
EbizDialog,
|
150
151
|
// 表格组件
|
151
|
-
EbizTable
|
152
|
+
EbizTable,
|
153
|
+
// 状态标记组件
|
154
|
+
EbizStatusBadge
|
152
155
|
};
|
package/src/router/index.js
CHANGED
@@ -240,6 +240,12 @@ const routes = [
|
|
240
240
|
name: 'TableDemo',
|
241
241
|
component: () => import('../views/TableDemo.vue'),
|
242
242
|
meta: { title: 'Ebiz表格组件示例' }
|
243
|
+
},
|
244
|
+
{
|
245
|
+
path: '/status-badge',
|
246
|
+
name: 'StatusBadge',
|
247
|
+
component: () => import('../views/StatusBadgeExample.vue'),
|
248
|
+
meta: { title: 'Ebiz状态标记组件示例' }
|
243
249
|
}
|
244
250
|
]
|
245
251
|
|
package/src/views/Home.vue
CHANGED
@@ -54,7 +54,8 @@ export default {
|
|
54
54
|
{ path: '/ebiz-employee-info', title: 'Ebiz员工信息组件示例' },
|
55
55
|
{ path: '/tdesign-alert', title: 'TDesign提示组件示例' },
|
56
56
|
{ path: '/tdesign-dialog', title: 'TDesign对话框组件示例' },
|
57
|
-
{ path: '/table-demo', title: 'Ebiz表格组件示例' }
|
57
|
+
{ path: '/table-demo', title: 'Ebiz表格组件示例' },
|
58
|
+
{ path: '/status-badge', title: 'Ebiz状态标记组件示例' }
|
58
59
|
]
|
59
60
|
|
60
61
|
return {
|
@@ -0,0 +1,146 @@
|
|
1
|
+
<template>
|
2
|
+
<div class="example-container">
|
3
|
+
<h2>状态标记组件示例</h2>
|
4
|
+
|
5
|
+
<div class="example-section">
|
6
|
+
<h3>不同状态类型</h3>
|
7
|
+
<div class="example-row">
|
8
|
+
<EbizStatusBadge status="default" text="默认状态" />
|
9
|
+
<EbizStatusBadge status="success" text="成功状态" />
|
10
|
+
<EbizStatusBadge status="warning" text="警告状态" />
|
11
|
+
<EbizStatusBadge status="error" text="错误状态" />
|
12
|
+
<EbizStatusBadge status="processing" text="处理中状态" />
|
13
|
+
</div>
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<div class="example-section">
|
17
|
+
<h3>自定义颜色</h3>
|
18
|
+
<div class="example-row">
|
19
|
+
<EbizStatusBadge color="#8B5CF6" text="紫色状态" />
|
20
|
+
<EbizStatusBadge color="#EC4899" text="粉色状态" />
|
21
|
+
<EbizStatusBadge color="#14B8A6" text="青色状态" />
|
22
|
+
<EbizStatusBadge color="#F59E0B" text="橙色状态" />
|
23
|
+
</div>
|
24
|
+
</div>
|
25
|
+
|
26
|
+
<div class="example-section">
|
27
|
+
<h3>预设颜色映射</h3>
|
28
|
+
<div class="example-row">
|
29
|
+
<EbizStatusBadge
|
30
|
+
status="success"
|
31
|
+
text="自定义预设颜色"
|
32
|
+
:colorMap="customColorMap"
|
33
|
+
/>
|
34
|
+
<EbizStatusBadge
|
35
|
+
status="error"
|
36
|
+
text="自定义预设颜色"
|
37
|
+
:colorMap="customColorMap"
|
38
|
+
/>
|
39
|
+
<EbizStatusBadge
|
40
|
+
status="warning"
|
41
|
+
text="自定义预设颜色"
|
42
|
+
:colorMap="customColorMap"
|
43
|
+
/>
|
44
|
+
<EbizStatusBadge
|
45
|
+
status="processing"
|
46
|
+
text="自定义预设颜色"
|
47
|
+
:colorMap="customColorMap"
|
48
|
+
/>
|
49
|
+
</div>
|
50
|
+
</div>
|
51
|
+
|
52
|
+
<div class="example-section">
|
53
|
+
<h3>不同尺寸</h3>
|
54
|
+
<div class="example-row">
|
55
|
+
<EbizStatusBadge size="small" text="小尺寸" />
|
56
|
+
<EbizStatusBadge size="medium" text="中尺寸" />
|
57
|
+
<EbizStatusBadge size="large" text="大尺寸" />
|
58
|
+
<EbizStatusBadge :size="20" text="自定义尺寸(20px)" />
|
59
|
+
</div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div class="example-section">
|
63
|
+
<h3>不同位置</h3>
|
64
|
+
<div class="example-row">
|
65
|
+
<EbizStatusBadge position="left" text="左侧" />
|
66
|
+
<EbizStatusBadge position="right" text="右侧" />
|
67
|
+
<EbizStatusBadge position="top" text="顶部" />
|
68
|
+
<EbizStatusBadge position="bottom" text="底部" />
|
69
|
+
</div>
|
70
|
+
</div>
|
71
|
+
|
72
|
+
<div class="example-section">
|
73
|
+
<h3>脉冲动画</h3>
|
74
|
+
<div class="example-row">
|
75
|
+
<EbizStatusBadge status="processing" :pulse="true" text="处理中" />
|
76
|
+
<EbizStatusBadge status="success" :pulse="true" text="成功" />
|
77
|
+
<EbizStatusBadge status="error" :pulse="true" text="错误" />
|
78
|
+
</div>
|
79
|
+
</div>
|
80
|
+
|
81
|
+
<div class="example-section">
|
82
|
+
<h3>只显示状态点(无文本)</h3>
|
83
|
+
<div class="example-row">
|
84
|
+
<EbizStatusBadge status="default" :showText="false" />
|
85
|
+
<EbizStatusBadge status="success" :showText="false" />
|
86
|
+
<EbizStatusBadge status="warning" :showText="false" />
|
87
|
+
<EbizStatusBadge status="error" :showText="false" />
|
88
|
+
<EbizStatusBadge status="processing" :showText="false" />
|
89
|
+
</div>
|
90
|
+
</div>
|
91
|
+
</div>
|
92
|
+
</template>
|
93
|
+
|
94
|
+
<script>
|
95
|
+
import { EbizStatusBadge } from '../index.js';
|
96
|
+
import { ref } from 'vue';
|
97
|
+
|
98
|
+
export default {
|
99
|
+
name: 'StatusBadgeExample',
|
100
|
+
components: {
|
101
|
+
EbizStatusBadge
|
102
|
+
},
|
103
|
+
setup() {
|
104
|
+
// 自定义预设颜色映射
|
105
|
+
const customColorMap = ref({
|
106
|
+
success: '#6EE7B7', // 浅绿色
|
107
|
+
error: '#F87171', // 浅红色
|
108
|
+
warning: '#FCD34D', // 浅黄色
|
109
|
+
processing: '#60A5FA', // 浅蓝色
|
110
|
+
default: '#A1A1AA' // 浅灰色
|
111
|
+
});
|
112
|
+
|
113
|
+
return {
|
114
|
+
customColorMap
|
115
|
+
};
|
116
|
+
}
|
117
|
+
}
|
118
|
+
</script>
|
119
|
+
|
120
|
+
<style scoped>
|
121
|
+
.example-container {
|
122
|
+
padding: 20px;
|
123
|
+
font-family: Arial, sans-serif;
|
124
|
+
}
|
125
|
+
|
126
|
+
.example-section {
|
127
|
+
margin-bottom: 30px;
|
128
|
+
border: 1px solid #eee;
|
129
|
+
border-radius: 6px;
|
130
|
+
padding: 16px;
|
131
|
+
}
|
132
|
+
|
133
|
+
.example-section h3 {
|
134
|
+
margin-top: 0;
|
135
|
+
margin-bottom: 16px;
|
136
|
+
font-size: 16px;
|
137
|
+
color: #333;
|
138
|
+
}
|
139
|
+
|
140
|
+
.example-row {
|
141
|
+
display: flex;
|
142
|
+
flex-wrap: wrap;
|
143
|
+
gap: 20px;
|
144
|
+
align-items: center;
|
145
|
+
}
|
146
|
+
</style>
|