Show.vue 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <script setup>
  2. import { detailTable, filterOptionCategory } from './config'
  3. import AppPagination from '@/components/AppPagination.vue'
  4. import AppDateRangeFilter from '@/components/AppDateRangeFilter.vue'
  5. import AppDropdownFilter from '@/components/AppDropdownFilter.vue'
  6. import AppButtonLink from '@/components/AppButtonLink.vue'
  7. import AppResetFilter from '@/components/AppResetFilter.vue'
  8. import DashboardLayout from '@/layouts/Dashboard/DashboardLayout.vue'
  9. const props = defineProps({
  10. initialFilters: Object,
  11. productId: Number,
  12. productNumber: String,
  13. historyStockProducts: {
  14. type: Object,
  15. default: {
  16. data: [],
  17. links: [],
  18. total: 0,
  19. },
  20. },
  21. })
  22. const exportExcel = () => {
  23. if (location.search.length) {
  24. return (
  25. '/stock-products/history/excel' +
  26. location.search +
  27. `&product_number=${props.productNumber}`
  28. )
  29. } else {
  30. return `/stock-products/history/excel?product_number=${props.productNumber}`
  31. }
  32. }
  33. </script>
  34. <template>
  35. <DashboardLayout title="History Stok Produk">
  36. <DataTable
  37. responsiveLayout="scroll"
  38. :value="historyStockProducts.data"
  39. :rowHover="true"
  40. :stripedRows="true"
  41. >
  42. <template #header>
  43. <h1>History Stok Produk</h1>
  44. <div class="grid">
  45. <div class="col-12 sm:col-6 lg:col-4">
  46. <AppDateRangeFilter
  47. placeholder="filter waktu..."
  48. :name-param="['start_date', 'end_date']"
  49. :initial-date-rage="initialFilters"
  50. />
  51. </div>
  52. <div class="col-12 sm:col-6 lg:col-4">
  53. <AppDropdownFilter
  54. placeholder="category"
  55. name-param="category"
  56. :initial-dropdown="initialFilters"
  57. :options="filterOptionCategory"
  58. />
  59. </div>
  60. <div class="col-12 sm:col-6 lg:col-4">
  61. <AppResetFilter :url="route('stock-products.history', productId)" />
  62. </div>
  63. <div class="col-12 flex flex-column sm:flex-row">
  64. <AppButtonLink
  65. v-if="historyStockProducts.total"
  66. label="Export excel"
  67. class-button="p-button-outlined md:w-16rem"
  68. icon="pi pi-file-excel"
  69. :inertia-link="false"
  70. :href="exportExcel()"
  71. />
  72. </div>
  73. </div>
  74. </template>
  75. <Column
  76. v-for="value in detailTable"
  77. :key="value.field"
  78. :field="value.field"
  79. :header="value.header"
  80. />
  81. <Column>
  82. <template #body="{ data }">
  83. <Badge
  84. v-if="data.category === 'Penambahan'"
  85. :value="data.category"
  86. severity="success"
  87. class="mr-2"
  88. ></Badge>
  89. <Badge
  90. v-if="data.category === 'Pengurangan'"
  91. :value="data.category"
  92. severity="danger"
  93. class="mr-2"
  94. ></Badge>
  95. </template>
  96. </Column>
  97. </DataTable>
  98. <AppPagination :links="historyStockProducts.links" />
  99. </DashboardLayout>
  100. </template>