Create.vue 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <script setup>
  2. import { watch, computed } from 'vue'
  3. import { Head, useForm, usePage } from '@inertiajs/inertia-vue3'
  4. import AppButton from '@/components/AppButton.vue'
  5. import AppDropdown from '@/components/AppDropdown.vue'
  6. import AppInputText from '@/components/AppInputText.vue'
  7. import AppLayout from '@/layouts/AppLayout.vue'
  8. const props = defineProps({
  9. customer_number: String,
  10. genders: Array,
  11. })
  12. const errors = computed(() => usePage().props.value.errors)
  13. watch(errors, () => {
  14. form.clearErrors()
  15. })
  16. const form = useForm({
  17. customer_number: props.customer_number,
  18. name: '',
  19. phone: '',
  20. gender_id: '',
  21. })
  22. const submit = () => {
  23. form.post(route('customers.store'))
  24. }
  25. </script>
  26. <template>
  27. <Head title="Tambah Customer" />
  28. <AppLayout>
  29. <div class="grid">
  30. <div class="col-12 lg:col-8">
  31. <Card>
  32. <template #content>
  33. <div class="grid">
  34. <div class="col-12 md:col-6">
  35. <AppInputText
  36. :disabled="true"
  37. label="Id Customer"
  38. v-model="form.customer_number"
  39. placeholder="id customer"
  40. />
  41. </div>
  42. <div class="col-12 md:col-6">
  43. <AppInputText label="Nama" placeholder="nama" :error="form.errors.name" v-model="form.name" />
  44. </div>
  45. <div class="col-12 md:col-6">
  46. <AppInputText label="Nomor HP" placeholder="nomor hp" :error="form.errors.phone" v-model="form.phone" />
  47. </div>
  48. <div class="col-12 md:col-6">
  49. <AppDropdown
  50. label="Jenis Kelamin"
  51. placeholder="Pilih satu"
  52. v-model="form.gender_id"
  53. :options="genders"
  54. :error="form.errors.gender_id"
  55. />
  56. </div>
  57. </div>
  58. </template>
  59. <template #footer>
  60. <div class="flex justify-content-end">
  61. <AppButton @click="submit" label="Simpan" icon="pi pi-check" class="p-button-text" />
  62. </div>
  63. </template>
  64. </Card>
  65. </div>
  66. </div>
  67. </AppLayout>
  68. </template>