Create.vue 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <script setup>
  2. import { watch } from 'vue'
  3. import { Inertia } from '@inertiajs/inertia'
  4. import { useForm } from '@inertiajs/inertia-vue3'
  5. import { useFormErrorReset } from '@/components/useFormErrorReset'
  6. import AppInputText from '@/components/AppInputText.vue'
  7. import AppDropdown from '@/components/AppDropdown.vue'
  8. import DashboardLayout from '@/layouts/DashboardLayout.vue'
  9. import { InTable, OutTable } from './TableHeader'
  10. defineProps({
  11. entryTransactions: Object,
  12. outTransactions: Object,
  13. typeVehicles: Object,
  14. })
  15. const form = useForm({
  16. plat_number: null,
  17. entry_transaction_id: null,
  18. type_vehicle_id: null,
  19. })
  20. useFormErrorReset(form)
  21. watch(
  22. () => form.plat_number,
  23. () => {
  24. Inertia.reload({ only: ['typeVehicles'], data: { plat_number: form.plat_number } })
  25. }
  26. )
  27. const submit = () => {
  28. form.post(route('transactions.store'), { onSuccess: () => form.reset() })
  29. }
  30. </script>
  31. <template>
  32. <DashboardLayout>
  33. <div class="grid">
  34. <div class="col-12 md:col-6">
  35. <Card>
  36. <template #title> Tambah Transaksi Keluar </template>
  37. <template #content>
  38. <div class="grid">
  39. <div class="col-12 md:col-6">
  40. <AppInputText
  41. v-model="form.plat_number"
  42. label="Plat Kendaraan"
  43. placeholder="plat kendaraan"
  44. :error="form.errors.plat_number"
  45. />
  46. </div>
  47. <div class="col-12 md:col-6">
  48. <AppInputText
  49. v-model="form.entry_transaction_id"
  50. label="Nomor Transaksi"
  51. placeholder="nomor transaksi"
  52. :error="form.errors.entry_transaction_id"
  53. />
  54. </div>
  55. <div class="col-12 md:col-6">
  56. <AppDropdown
  57. v-model="form.type_vehicle_id"
  58. label="Jenis Kendaraan"
  59. placeholder="jenis kendaraan"
  60. :options="typeVehicles"
  61. :error="form.errors.type_vehicle_id"
  62. />
  63. </div>
  64. </div>
  65. </template>
  66. <template #footer>
  67. <div class="flex flex-column md:flex-row justify-content-end">
  68. <Button
  69. label="Simpan"
  70. icon="pi pi-check"
  71. class="p-button-outlined"
  72. :disabled="form.processing"
  73. @click="submit"
  74. />
  75. </div>
  76. </template>
  77. </Card>
  78. </div>
  79. <div class="col-12 md:col-6">
  80. <div class="grid">
  81. <div class="col-12">
  82. <Card>
  83. <template #title> Kendaraan Masuk </template>
  84. <template #content>
  85. <DataTable
  86. responsiveLayout="scroll"
  87. columnResizeMode="expand"
  88. :value="entryTransactions"
  89. :rowHover="true"
  90. :stripedRows="true"
  91. >
  92. <template #header>
  93. <span style="color: var(--primary-color)">Maksimal ditampilkan :</span> 10
  94. <br />
  95. <span style="color: var(--primary-color)">Ditampilkan :</span>
  96. {{ Object.keys(entryTransactions).length }}
  97. </template>
  98. <Column
  99. v-for="inTable in InTable"
  100. :field="inTable.field"
  101. :header="inTable.header"
  102. :key="inTable.field"
  103. />
  104. </DataTable>
  105. </template>
  106. </Card>
  107. </div>
  108. <div class="col-12">
  109. <Card>
  110. <template #title> Kendaraan Keluar </template>
  111. <template #content>
  112. <DataTable
  113. responsiveLayout="scroll"
  114. columnResizeMode="expand"
  115. :value="outTransactions"
  116. :rowHover="true"
  117. :stripedRows="true"
  118. >
  119. <template #header>
  120. <span style="color: var(--red-600)">Maksimal ditampilkan :</span> 10
  121. <br />
  122. <span style="color: var(--red-600)">Ditampilkan :</span>
  123. {{ Object.keys(outTransactions).length }}
  124. </template>
  125. <Column
  126. v-for="outTable in OutTable"
  127. :field="outTable.field"
  128. :header="outTable.header"
  129. :key="outTable.field"
  130. />
  131. </DataTable>
  132. </template>
  133. </Card>
  134. </div>
  135. </div>
  136. </div>
  137. </div>
  138. </DashboardLayout>
  139. </template>