Create.vue 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <script setup>
  2. import { useForm } from '@inertiajs/inertia-vue3'
  3. import { useFormErrorReset } from '@/components/useFormErrorReset'
  4. import DashboardLayout from '@/layouts/DashboardLayout.vue'
  5. import AppInputNumber from '@/components/AppInputNumber.vue'
  6. import AppEditor from '@/components/AppEditor.vue'
  7. const form = useForm({
  8. description: null,
  9. amount: null,
  10. })
  11. useFormErrorReset(form)
  12. const onSubmit = () => {
  13. form.post(route('expenses.store'), { onSuccess: () => form.reset() })
  14. }
  15. </script>
  16. <template>
  17. <DashboardLayout>
  18. <div class="grid">
  19. <div class="col-12 md:col-8">
  20. <Card>
  21. <template #title> Tambah Pengeluaran </template>
  22. <template #content>
  23. <AppInputNumber
  24. v-model="form.amount"
  25. class="md:w-16rem"
  26. label="Pengeluaran"
  27. placeholder="contoh: 100000"
  28. :error="form.errors.amount"
  29. />
  30. <AppEditor
  31. label="Keterangan"
  32. v-model="form.description"
  33. editor-style="height: 320px"
  34. placeholder="tulis keterangan disini"
  35. :error="form.errors.description"
  36. >
  37. <template #toolbar>
  38. <span class="q-formats">
  39. <button class="ql-bold" v-tooltip.bottom="'Bold'"></button>
  40. <button class="ql-italic" v-tooltip.bottom="'Italic'"></button>
  41. <button class="ql-underline" v-tooltip.bottom="'Underline'"></button>
  42. </span>
  43. <span class="ql-formats">
  44. <button class="ql-list" value="ordered" v-tooltip.bottom="'Ordered'"></button>
  45. <button class="ql-list" value="bullet" v-tooltip.bottom="'Bullet'"></button>
  46. </span>
  47. </template>
  48. </AppEditor>
  49. </template>
  50. <template #footer>
  51. <div class="flex flex-column md:flex-row justify-content-end">
  52. <Button
  53. label="Simpan"
  54. icon="pi pi-check"
  55. class="p-button-outlined"
  56. :disabled="form.processing"
  57. @click="onSubmit"
  58. />
  59. </div>
  60. </template>
  61. </Card>
  62. </div>
  63. </div>
  64. </DashboardLayout>
  65. </template>