rrj-astra-ui 1.0.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/README.en.md +36 -0
- package/README.md +37 -0
- package/components/AuiBadge.vue +50 -0
- package/components/AuiBlockBox.vue +85 -0
- package/components/AuiButton.vue +210 -0
- package/components/AuiCustomerForm.vue +304 -0
- package/components/AuiDivider.vue +66 -0
- package/components/AuiFold.vue +40 -0
- package/components/AuiFoldItem.vue +173 -0
- package/components/AuiForm.vue +76 -0
- package/components/AuiFormItem.vue +88 -0
- package/components/AuiGrid.vue +26 -0
- package/components/AuiGridItem.vue +20 -0
- package/components/AuiIcon.vue +145 -0
- package/components/AuiImage.vue +152 -0
- package/components/AuiInput.vue +176 -0
- package/components/AuiLamp.vue +254 -0
- package/components/AuiLineProgress.vue +169 -0
- package/components/AuiList.vue +18 -0
- package/components/AuiListItem.vue +142 -0
- package/components/AuiMultiSelect.vue +303 -0
- package/components/AuiNoticeBar.vue +62 -0
- package/components/AuiNumberBox.vue +282 -0
- package/components/AuiPicker.vue +619 -0
- package/components/AuiPopup.vue +57 -0
- package/components/AuiSelectGroup.vue +312 -0
- package/components/AuiTab.vue +173 -0
- package/components/AuiTabItem.vue +43 -0
- package/components/AuiTable.vue +357 -0
- package/components/AuiTag.vue +112 -0
- package/components/AuiText.vue +81 -0
- package/components/AuiTextarea.vue +203 -0
- package/components/AuiToast.vue +96 -0
- package/components/AuiUpdate.vue +271 -0
- package/components/AuiUpload.vue +524 -0
- package/index.js +93 -0
- package/package.json +36 -0
- package/style.scss +30 -0
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view :class="[`aui-table`, `aui-table-theme__${theme}`]">
|
|
3
|
+
<!-- 表头 -->
|
|
4
|
+
<view class="aui-table_head">
|
|
5
|
+
<!-- 新增序号表头 -->
|
|
6
|
+
<view v-if="showSort" class="aui-table-head_item" style="flex-basis: 60px;">序号</view>
|
|
7
|
+
<view
|
|
8
|
+
class="aui-table-head_item"
|
|
9
|
+
v-for="(item, index) in columns"
|
|
10
|
+
:key="index"
|
|
11
|
+
:style="{ flexBasis: item.width || 'auto', flexGrow: item.flexGrow || 1 }"
|
|
12
|
+
>
|
|
13
|
+
{{ item.label }}
|
|
14
|
+
</view>
|
|
15
|
+
<!-- 新增操作列,根据 allowDelete 控制显示 -->
|
|
16
|
+
<view v-if="allowDelete" class="aui-table-head_item" style="flex-basis: 120px;">操作</view>
|
|
17
|
+
</view>
|
|
18
|
+
|
|
19
|
+
<!-- 表格内容 -->
|
|
20
|
+
<view class="aui-table_content" v-if="displayData.length > 0">
|
|
21
|
+
<view
|
|
22
|
+
class="aui-table-content_item"
|
|
23
|
+
v-for="(item, rowIndex) in displayData"
|
|
24
|
+
:key="item.id || rowIndex"
|
|
25
|
+
:draggable="showSort"
|
|
26
|
+
@dragstart="showSort && handleDragStart(rowIndex)"
|
|
27
|
+
@dragover.prevent
|
|
28
|
+
@drop="showSort && handleDrop(rowIndex)"
|
|
29
|
+
:class="{ 'dragging': rowIndex === draggedIndex }"
|
|
30
|
+
>
|
|
31
|
+
<!-- 新增序号列 -->
|
|
32
|
+
<view v-if="showSort" class="aui-table-content-item_item" style="flex-basis: 60px;">
|
|
33
|
+
{{ item.sort }}
|
|
34
|
+
</view>
|
|
35
|
+
<view
|
|
36
|
+
class="aui-table-content-item_item"
|
|
37
|
+
v-for="(col, colIndex) in columns"
|
|
38
|
+
:key="colIndex"
|
|
39
|
+
:style="{ flexBasis: col.width || 'auto', flexGrow: col.flexGrow || 1 }"
|
|
40
|
+
>
|
|
41
|
+
<!-- 可编辑数字列(带步进器) -->
|
|
42
|
+
<template v-if="col.type === 'number' && col.editable">
|
|
43
|
+
<div class="stepper">
|
|
44
|
+
<view class="btn first" @click="decrease(rowIndex, col.prop, col.step, col.min)">
|
|
45
|
+
-
|
|
46
|
+
</view>
|
|
47
|
+
<input
|
|
48
|
+
type="number"
|
|
49
|
+
v-model.number="displayData[rowIndex][col.prop]"
|
|
50
|
+
@change="handleInput($event, rowIndex, col.prop)"
|
|
51
|
+
:min="col.min || 0"
|
|
52
|
+
:max="col.max || Infinity"
|
|
53
|
+
/>
|
|
54
|
+
<view class="btn befor" @click="increase(rowIndex, col.prop, col.step, col.max)">
|
|
55
|
+
+
|
|
56
|
+
</view>
|
|
57
|
+
</div>
|
|
58
|
+
</template>
|
|
59
|
+
|
|
60
|
+
<!-- 格式化内容 -->
|
|
61
|
+
<template v-else-if="col.formatter">
|
|
62
|
+
{{ col.formatter(displayData[rowIndex][col.prop], displayData[rowIndex]) }}
|
|
63
|
+
</template>
|
|
64
|
+
|
|
65
|
+
<!-- 默认文本 -->
|
|
66
|
+
<template v-else>
|
|
67
|
+
{{ displayData[rowIndex][col.prop] || "--" }}
|
|
68
|
+
</template>
|
|
69
|
+
</view>
|
|
70
|
+
<!-- 新增操作列,根据 allowDelete 控制显示 -->
|
|
71
|
+
<view v-if="allowDelete" class="aui-table-content-item_item" style="flex-basis: 120px;">
|
|
72
|
+
<!--<aui-icon name="editprice" @click="handleEdit(rowIndex, item)"/>-->
|
|
73
|
+
<aui-icon name="close" @click="handleDelete(rowIndex, item)"/>
|
|
74
|
+
</view>
|
|
75
|
+
</view>
|
|
76
|
+
</view>
|
|
77
|
+
|
|
78
|
+
<!-- 空状态提示 -->
|
|
79
|
+
<view v-else class="empty-state">
|
|
80
|
+
暂无数据
|
|
81
|
+
</view>
|
|
82
|
+
</view>
|
|
83
|
+
</template>
|
|
84
|
+
|
|
85
|
+
<script setup>
|
|
86
|
+
import { defineProps, defineEmits, computed, ref, watch } from 'vue';
|
|
87
|
+
import AuiIcon from './AuiIcon.vue';
|
|
88
|
+
const __name = 'AuiTable';
|
|
89
|
+
|
|
90
|
+
defineOptions({
|
|
91
|
+
name: __name
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const props = defineProps({
|
|
95
|
+
columns: {
|
|
96
|
+
type: Array,
|
|
97
|
+
default: () => []
|
|
98
|
+
},
|
|
99
|
+
data: {
|
|
100
|
+
type: Array,
|
|
101
|
+
default: () => []
|
|
102
|
+
},
|
|
103
|
+
theme: {
|
|
104
|
+
type: String,
|
|
105
|
+
default: 'default',
|
|
106
|
+
validator: (value) => ['default', 'simple'].includes(value)
|
|
107
|
+
},
|
|
108
|
+
// 新增 showSort 属性
|
|
109
|
+
showSort: {
|
|
110
|
+
type: Boolean,
|
|
111
|
+
default: false
|
|
112
|
+
},
|
|
113
|
+
// 新增 allowDelete 属性
|
|
114
|
+
allowDelete: {
|
|
115
|
+
type: Boolean,
|
|
116
|
+
default: false
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const emits = defineEmits(['update:data', 'cell-change', 'edit', 'delete']); // 新增 edit 和 delete 事件
|
|
121
|
+
|
|
122
|
+
// 增加带 sort 属性的数据处理函数
|
|
123
|
+
const addSortProperty = (data, showSort) => {
|
|
124
|
+
return showSort ? data.map((item, index) => ({ ...item, sort: index + 1 })) : data;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
// 使用计算属性和ref组合确保数据响应式
|
|
128
|
+
const internalData = ref(addSortProperty(props.data, props.showSort));
|
|
129
|
+
|
|
130
|
+
// 统一的显示数据计算属性
|
|
131
|
+
const displayData = computed(() => {
|
|
132
|
+
return internalData.value.length > 0
|
|
133
|
+
? internalData.value
|
|
134
|
+
: addSortProperty(props.data, props.showSort);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
// 监听外部数据变化
|
|
138
|
+
watch(
|
|
139
|
+
() => [props.data, props.showSort],
|
|
140
|
+
([newData, newShowSort]) => {
|
|
141
|
+
if (newData !== internalData.value) {
|
|
142
|
+
internalData.value = addSortProperty(newData, newShowSort);
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
{ deep: true, immediate: true }
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
// 处理输入框变化
|
|
149
|
+
const handleInput = (event, rowIndex, prop) => {
|
|
150
|
+
const newValue = parseFloat(event.target.value);
|
|
151
|
+
if (!isNaN(newValue)) {
|
|
152
|
+
updateValue(rowIndex, prop, newValue);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
// 减少数值
|
|
157
|
+
const decrease = (rowIndex, prop, step, min) => {
|
|
158
|
+
const currentValue = internalData.value[rowIndex][prop];
|
|
159
|
+
if (isNaN(currentValue)) return;
|
|
160
|
+
|
|
161
|
+
const newValue = Math.max(currentValue - (step || 1), min || 0);
|
|
162
|
+
updateValue(rowIndex, prop, newValue);
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// 增加数值
|
|
166
|
+
const increase = (rowIndex, prop, step, max) => {
|
|
167
|
+
const currentValue = internalData.value[rowIndex][prop];
|
|
168
|
+
if (isNaN(currentValue)) return;
|
|
169
|
+
|
|
170
|
+
const newValue = Math.min(currentValue + (step || 1), max || Infinity);
|
|
171
|
+
updateValue(rowIndex, prop, newValue);
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
// 更新数据并触发事件
|
|
175
|
+
const updateValue = (rowIndex, prop, newValue) => {
|
|
176
|
+
const row = internalData.value[rowIndex];
|
|
177
|
+
if (!row || rowIndex < 0 || rowIndex >= internalData.value.length) return;
|
|
178
|
+
if (isNaN(newValue)) return;
|
|
179
|
+
|
|
180
|
+
if (newValue === row[prop]) return;
|
|
181
|
+
|
|
182
|
+
const newRow = { ...row, [prop]: newValue };
|
|
183
|
+
|
|
184
|
+
internalData.value = [
|
|
185
|
+
...internalData.value.slice(0, rowIndex),
|
|
186
|
+
newRow,
|
|
187
|
+
...internalData.value.slice(rowIndex + 1)
|
|
188
|
+
];
|
|
189
|
+
|
|
190
|
+
emits('update:data', [...internalData.value]);
|
|
191
|
+
emits('cell-change', {
|
|
192
|
+
row: newRow,
|
|
193
|
+
rowIndex,
|
|
194
|
+
prop,
|
|
195
|
+
originalValue: row[prop],
|
|
196
|
+
newValue
|
|
197
|
+
});
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
// 触发编辑事件
|
|
201
|
+
const handleEdit = (rowIndex, item) => {
|
|
202
|
+
emits('edit', rowIndex, item);
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
// 触发删除事件
|
|
206
|
+
const handleDelete = (rowIndex, item) => {
|
|
207
|
+
emits('delete', rowIndex, item);
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
// 拖动开始
|
|
211
|
+
let draggedIndex = -1;
|
|
212
|
+
const handleDragStart = (index) => {
|
|
213
|
+
draggedIndex = index;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
// 拖动放下
|
|
217
|
+
const handleDrop = (index) => {
|
|
218
|
+
if (draggedIndex === -1) return;
|
|
219
|
+
|
|
220
|
+
const items = [...internalData.value];
|
|
221
|
+
const [removed] = items.splice(draggedIndex, 1);
|
|
222
|
+
items.splice(index, 0, removed);
|
|
223
|
+
|
|
224
|
+
// 重新计算 sort 属性
|
|
225
|
+
internalData.value = props.showSort ? items.map((item, i) => ({ ...item, sort: i + 1 })) : items;
|
|
226
|
+
emits('update:data', [...internalData.value]);
|
|
227
|
+
draggedIndex = -1;
|
|
228
|
+
};
|
|
229
|
+
</script>
|
|
230
|
+
|
|
231
|
+
<style scoped lang="scss">
|
|
232
|
+
.aui-table {
|
|
233
|
+
display: block;
|
|
234
|
+
overflow: hidden;
|
|
235
|
+
width: 100%;
|
|
236
|
+
border: 1px solid #EEEEEE;
|
|
237
|
+
border-radius: 8px;
|
|
238
|
+
}
|
|
239
|
+
.aui-table-theme__simple.aui-table {
|
|
240
|
+
border: none;
|
|
241
|
+
border-radius: 0;
|
|
242
|
+
}
|
|
243
|
+
.aui-table_head {
|
|
244
|
+
display: flex;
|
|
245
|
+
align-items: center;
|
|
246
|
+
justify-content: space-between;
|
|
247
|
+
background-color: #F5F6F7;
|
|
248
|
+
border-bottom: 1px solid #F3F4F6;
|
|
249
|
+
}
|
|
250
|
+
.aui-table-theme__simple .aui-table_head {
|
|
251
|
+
background-color: #FFFFFF !important;
|
|
252
|
+
border-bottom: 1px solid #F3F4F6;
|
|
253
|
+
}
|
|
254
|
+
.aui-table-head_item {
|
|
255
|
+
text-align: center;
|
|
256
|
+
font-size: 14px;
|
|
257
|
+
padding: 8px 0;
|
|
258
|
+
color: #666666;
|
|
259
|
+
box-sizing: border-box;
|
|
260
|
+
overflow: hidden;
|
|
261
|
+
text-overflow: ellipsis;
|
|
262
|
+
white-space: nowrap;
|
|
263
|
+
}
|
|
264
|
+
.aui-table-content_item {
|
|
265
|
+
display: flex;
|
|
266
|
+
align-items: center;
|
|
267
|
+
justify-content: space-between;
|
|
268
|
+
border-bottom: 1px solid #F3F4F6;
|
|
269
|
+
padding: 8px 0;
|
|
270
|
+
/* 鼠标拖动样式 */
|
|
271
|
+
cursor: move;
|
|
272
|
+
transition: background-color 0.2s;
|
|
273
|
+
}
|
|
274
|
+
.aui-table-content_item.dragging {
|
|
275
|
+
background-color: #f0f0f0;
|
|
276
|
+
opacity: 0.8;
|
|
277
|
+
}
|
|
278
|
+
.aui-table-content-item_item {
|
|
279
|
+
text-align: center;
|
|
280
|
+
font-size: 14px;
|
|
281
|
+
color: #1A1A1A;
|
|
282
|
+
box-sizing: border-box;
|
|
283
|
+
overflow: hidden;
|
|
284
|
+
text-overflow: ellipsis;
|
|
285
|
+
white-space: nowrap;
|
|
286
|
+
}
|
|
287
|
+
.aui-table-content-item_item>.aui-icon{display: inline-block;}
|
|
288
|
+
.empty-state {
|
|
289
|
+
height: 60px;
|
|
290
|
+
line-height: 60px;
|
|
291
|
+
text-align: center;
|
|
292
|
+
color: #999;
|
|
293
|
+
font-size: 14px;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/* 步进器样式 */
|
|
297
|
+
.stepper {
|
|
298
|
+
display: flex;
|
|
299
|
+
justify-content: center;
|
|
300
|
+
align-items: center;
|
|
301
|
+
gap: 0;
|
|
302
|
+
border:1px solid #EEEEEE;
|
|
303
|
+
border-radius: 4px;
|
|
304
|
+
width: 100px;
|
|
305
|
+
margin: 0 auto;
|
|
306
|
+
}
|
|
307
|
+
.stepper .btn {
|
|
308
|
+
width: 32px;
|
|
309
|
+
height: 32px;
|
|
310
|
+
background-color: #f5f5f5;
|
|
311
|
+
cursor: pointer;
|
|
312
|
+
display: flex;
|
|
313
|
+
align-items: center;
|
|
314
|
+
justify-content: center;
|
|
315
|
+
outline: none;
|
|
316
|
+
transition: background-color 0.2s;
|
|
317
|
+
font-size: 20px;
|
|
318
|
+
color:#666666;
|
|
319
|
+
}
|
|
320
|
+
.stepper button:hover {
|
|
321
|
+
background-color: #e0e0e0;
|
|
322
|
+
}
|
|
323
|
+
.stepper input {
|
|
324
|
+
flex:1;
|
|
325
|
+
height: 32px;
|
|
326
|
+
border-left: none;
|
|
327
|
+
border-right: none;
|
|
328
|
+
text-align: center;
|
|
329
|
+
outline: none;
|
|
330
|
+
-moz-appearance: textfield;
|
|
331
|
+
}
|
|
332
|
+
.stepper input::-webkit-outer-spin-button,
|
|
333
|
+
.stepper input::-webkit-inner-spin-button {
|
|
334
|
+
-webkit-appearance: none;
|
|
335
|
+
margin: 0;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/* 新增操作按钮样式 */
|
|
339
|
+
.aui-edit-btn, .aui-delete-btn {
|
|
340
|
+
padding: 4px 8px;
|
|
341
|
+
border: none;
|
|
342
|
+
border-radius: 4px;
|
|
343
|
+
cursor: pointer;
|
|
344
|
+
font-size: 12px;
|
|
345
|
+
margin: 0 2px;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
.aui-edit-btn {
|
|
349
|
+
background-color: #3B82F6;
|
|
350
|
+
color: white;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
.aui-delete-btn {
|
|
354
|
+
background-color: #F5222D;
|
|
355
|
+
color: white;
|
|
356
|
+
}
|
|
357
|
+
</style>
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view :class="['aui-tag', `aui-tag-${type}`]" @click="!disabled && handleClick">
|
|
3
|
+
{{ value }}
|
|
4
|
+
</view>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup>
|
|
8
|
+
import { defineProps, defineEmits } from 'vue';
|
|
9
|
+
const __name = 'AuiTag';
|
|
10
|
+
|
|
11
|
+
defineOptions({
|
|
12
|
+
name: __name
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
const props = defineProps({
|
|
16
|
+
type: {
|
|
17
|
+
type: String,
|
|
18
|
+
default: 'primary',
|
|
19
|
+
validator: (value) => ['primary', 'success', 'warning', 'danger','level-v1','level-v2','level-v3','level-v4','level-v5','level-v6','level-v7','level-v8'].includes(value)
|
|
20
|
+
},
|
|
21
|
+
value: {
|
|
22
|
+
type: String,
|
|
23
|
+
default: ''
|
|
24
|
+
},
|
|
25
|
+
plain: {
|
|
26
|
+
type: Boolean,
|
|
27
|
+
default: false
|
|
28
|
+
},
|
|
29
|
+
closable: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: false
|
|
32
|
+
},
|
|
33
|
+
disabled: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: false
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const emits = defineEmits(['click', 'close']);
|
|
40
|
+
|
|
41
|
+
const handleClick = () => {
|
|
42
|
+
emits('click');
|
|
43
|
+
};
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<style scoped lang="scss">
|
|
47
|
+
@import '../style.scss';
|
|
48
|
+
|
|
49
|
+
.aui-tag {
|
|
50
|
+
display: inline-block;
|
|
51
|
+
padding: 2px 10px;
|
|
52
|
+
font-size: 12px;
|
|
53
|
+
border-radius: 30px;
|
|
54
|
+
cursor: pointer;
|
|
55
|
+
transition: background-color 0.3s;
|
|
56
|
+
}
|
|
57
|
+
.aui-tag-default{
|
|
58
|
+
background-color: #F3F4F6;
|
|
59
|
+
color: $aui-text-color;
|
|
60
|
+
}
|
|
61
|
+
.aui-tag-primary {
|
|
62
|
+
background-color: $aui-primary-bg-color;
|
|
63
|
+
color: $aui-primary-color;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.aui-tag-success {
|
|
67
|
+
background-color: $aui-success-bg-color;
|
|
68
|
+
color: $aui-success-color;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.aui-tag-warning {
|
|
72
|
+
background-color: $aui-warning-bg-color;
|
|
73
|
+
color: $aui-warning-color;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.aui-tag-danger {
|
|
77
|
+
background-color: $aui-danger-bg-color;
|
|
78
|
+
color: $aui-danger-color;
|
|
79
|
+
}
|
|
80
|
+
.aui-tag-level-v1{
|
|
81
|
+
background-color:#F53F3F;
|
|
82
|
+
color:#FFFFFF ;
|
|
83
|
+
}
|
|
84
|
+
.aui-tag-level-v2{
|
|
85
|
+
background-color:#FF7D00;
|
|
86
|
+
color:#FFFFFF ;
|
|
87
|
+
}
|
|
88
|
+
.aui-tag-level-v3{
|
|
89
|
+
background-color:#00B42A;
|
|
90
|
+
color: #FFFFFF;
|
|
91
|
+
}
|
|
92
|
+
.aui-tag-level-v4{
|
|
93
|
+
background-color:#1890FF;
|
|
94
|
+
color: #FFFFFF;
|
|
95
|
+
}
|
|
96
|
+
.aui-tag-level-v5{
|
|
97
|
+
background-color:#86909C;
|
|
98
|
+
color:#FFFFFF ;
|
|
99
|
+
}
|
|
100
|
+
.aui-tag-level-v6{
|
|
101
|
+
background-color:#FFB800;
|
|
102
|
+
color: #FFFFFF;
|
|
103
|
+
}
|
|
104
|
+
.aui-tag-level-v7{
|
|
105
|
+
background-color:#E5E6EB;
|
|
106
|
+
color:#1D2129 ;
|
|
107
|
+
}
|
|
108
|
+
.aui-tag-level-v8{
|
|
109
|
+
background-color:#0FC6C2;
|
|
110
|
+
color: #FFFFFF;
|
|
111
|
+
}
|
|
112
|
+
</style>
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- 绑定新的 props 到 class 和 style -->
|
|
3
|
+
<view :class="['aui-text', `aui-text-${size}`, `aui-text-type-${type}`, { 'aui-text-bold': bold }]" :style="{ color: color, fontSize: customSize }">
|
|
4
|
+
<slot></slot>
|
|
5
|
+
</view>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script setup>
|
|
9
|
+
import { defineProps } from 'vue';
|
|
10
|
+
const __name = 'AuiText';
|
|
11
|
+
|
|
12
|
+
defineOptions({
|
|
13
|
+
name: __name
|
|
14
|
+
})
|
|
15
|
+
const props = defineProps({
|
|
16
|
+
size: {
|
|
17
|
+
type: String,
|
|
18
|
+
default: 'normal',
|
|
19
|
+
validator: (value) => ['normal', 'small', 'large'].includes(value)
|
|
20
|
+
},
|
|
21
|
+
type: {
|
|
22
|
+
type: String,
|
|
23
|
+
default: 'default',
|
|
24
|
+
validator: (value) => ['default', 'primary', 'success', 'warning', 'danger'].includes(value)
|
|
25
|
+
},
|
|
26
|
+
// 新增 color 属性
|
|
27
|
+
color: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: null
|
|
30
|
+
},
|
|
31
|
+
// 新增 customSize 属性
|
|
32
|
+
customSize: {
|
|
33
|
+
type: String,
|
|
34
|
+
default: null
|
|
35
|
+
},
|
|
36
|
+
// 新增 bold 属性
|
|
37
|
+
bold: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: false
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<style scoped lang="scss">
|
|
45
|
+
@import '../style.scss';
|
|
46
|
+
|
|
47
|
+
.aui-text {
|
|
48
|
+
font-size: $aui-font-size;
|
|
49
|
+
color: $aui-text-color;
|
|
50
|
+
display: block;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.aui-text-small {
|
|
54
|
+
font-size: 12px;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.aui-text-large {
|
|
58
|
+
font-size: 18px;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.aui-text-type-primary {
|
|
62
|
+
color: $aui-primary-color;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.aui-text-type-success {
|
|
66
|
+
color: $aui-success-color;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.aui-text-type-warning {
|
|
70
|
+
color: $aui-warning-color;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.aui-text-type-danger {
|
|
74
|
+
color: $aui-danger-color;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/* 新增 bold 样式 */
|
|
78
|
+
.aui-text-bold {
|
|
79
|
+
font-weight: bold;
|
|
80
|
+
}
|
|
81
|
+
</style>
|