<script lang="ts" setup>
import { type PropType, computed } from 'vue'

const props = defineProps({
  status: {
    type: Number,
    required: true,
  },
  trigger: {
    type: Function as PropType<Function>,
    default: () => { },
  },
  id: {
    type: String,
    default: '',
  },
})

const actionConfig = {
  1: [{ label: '查看', key: 'view' }, { label: '重置审批', key: 'reset' }],
  5: [{ label: '通过', key: 'approval' }, { label: '不通过', key: 'reject' }, { label: '重置审批', key: 'reset' }],
}

const actions = computed(() => {
  return actionConfig[props.status]
})
</script>

<template>
  <div :data-id="id">
    <n-button
      v-for="(action, index) in actions" :key="index" class="normal"
      :class="{ gap: index !== 0, reject: index === 1 }" text @click="(trigger(action) as any)"
    >
      {{ action.label }}
    </n-button>
  </div>
</template>

<style scoped>
.normal {
  color: blue
}

.gap {
  margin-left: 15px;
}

.reject {
  color: red;
}
</style>
