statusBtn.vue 1.22 KB
<!-- 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>