Ppn.vue 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <script setup>
  2. import { ref } from 'vue'
  3. import { useForm } from '@/composables/useForm'
  4. import AppInputText from '@/components/AppInputText.vue'
  5. import DashboardLayout from '@/layouts/Dashboard/DashboardLayout.vue'
  6. const props = defineProps({
  7. ppn: Number,
  8. })
  9. const form = useForm({
  10. ppn: props.ppn,
  11. })
  12. const inputDisable = ref(true)
  13. const buttonLabel = ref('Ubah')
  14. const onSubmit = () => {
  15. if (inputDisable.value) {
  16. buttonLabel.value = 'Simpan'
  17. inputDisable.value = false
  18. } else {
  19. if (!form.ppn) {
  20. form.ppn = 0
  21. }
  22. buttonLabel.value = 'Ubah'
  23. inputDisable.value = true
  24. form.post(route('ppn.store'))
  25. }
  26. }
  27. </script>
  28. <template>
  29. <div class="grid">
  30. <div class="col-12">
  31. <AppInputText
  32. label="PPN"
  33. placeholder="ppn"
  34. type="number"
  35. :disabled="inputDisable"
  36. :error="form.errors.ppn"
  37. v-model="form.ppn"
  38. />
  39. <div class="flex flex-column md:flex-row justify-content-end">
  40. <Button
  41. icon="pi pi-check"
  42. class="p-button-outlined"
  43. :label="buttonLabel"
  44. :disabled="form.processing"
  45. @click="onSubmit"
  46. />
  47. </div>
  48. </div>
  49. </div>
  50. </template>