Index.vue 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <script setup>
  2. import { ref } from 'vue'
  3. import { useForm } from '@/components/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. <DashboardLayout title="Pengaturan PPN">
  30. <div class="grid">
  31. <div class="col-12 md:col-3">
  32. <Card>
  33. <template #content>
  34. <div class="grid">
  35. <div class="col-12">
  36. <AppInputText
  37. label="PPN"
  38. placeholder="ppn"
  39. type="number"
  40. :disabled="inputDisable"
  41. :error="form.errors.ppn"
  42. v-model="form.ppn"
  43. />
  44. </div>
  45. <div class="col-12">
  46. <div class="flex flex-column md:flex-row justify-content-end">
  47. <Button
  48. icon="pi pi-check"
  49. class="p-button-outlined"
  50. :label="buttonLabel"
  51. :disabled="form.processing"
  52. @click="onSubmit"
  53. />
  54. </div>
  55. </div>
  56. </div>
  57. </template>
  58. </Card>
  59. </div>
  60. </div>
  61. </DashboardLayout>
  62. </template>