statusBtn.vue
1.22 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
<!-- statusBtn渲染组件 -->
<template>
<view class="status-btn" :class="getStatusClass">
<view class="status-btn-item">
<view class="status-btn-item-text">{{ t(getStatusText) }}</view>
</view>
</view>
</template>
<script setup>
import { computed } from "vue";
import { t } from '@/plugins/index.js'
const props = defineProps({
status: {
type: String,
default: "Pending", // Pending, Confirm, False alarm
},
});
const getStatusClass = computed(() => {
return {
Pending: "status-pending",
Confirm: "status-Confirm",
"False alarm": "status-false-alert",
}[props.status];
});
const getStatusText = computed(() => {
return {
Pending: 'dictionary.pending',
Confirm: 'dictionary.confirmed',
"False alarm": 'TaskNotice.falseAlarm',
}[props.status];
});
</script>
<style lang="scss" scoped>
.status-btn {
display: inline-block;
padding: 6rpx 18rpx;
font-weight: 400;
font-size: 24rpx;
background: #edeef0;
color: #878992;
border-radius: 60rpx 60rpx 60rpx 60rpx;
}
// 动态样式
.status-pending {
background: #edeef0;
color: #878992;
}
.status-Confirm {
background: #def5df;
color: #24bf28;
}
.status-false-alert {
background: #fff2e0;
color: #ff9c14;
}
</style>