use-rate-config.js 486 B

12345678910111213141516171819202122
  1. import { computed, watch } from 'vue'
  2. export const useRateConfig = (formInput) => {
  3. const { proxyValue, securityConfig } = formInput
  4. const max = computed(() => {
  5. return securityConfig.value.max ?? 5
  6. })
  7. const allowHalf = computed(() => {
  8. return securityConfig.value.allowHalf ?? false
  9. })
  10. watch([proxyValue, max], ([val]) => {
  11. if (val && val > max.value) {
  12. proxyValue.value = max.value
  13. }
  14. }, { immediate: true })
  15. return {
  16. max, allowHalf
  17. }
  18. }