[Fix] filter laporan
This commit is contained in:
parent
758f404b0f
commit
4525444505
@ -89,12 +89,12 @@ class LaporanController extends Controller
|
||||
{
|
||||
try {
|
||||
return $this->laporanService->exportPerNampan($request->validate([
|
||||
'tanggal' => 'nullable|string',
|
||||
'sales_id' => 'nullable|integer|exists:sales,id',
|
||||
'produk_id' => 'nullable|integer|exists:produk,id',
|
||||
'nama_pembeli' => 'nullable|string|max:255',
|
||||
'tanggal' => 'required|string',
|
||||
'format' => 'required|string|in:pdf,xlsx,csv',
|
||||
'page' => 'nullable|integer|min:1',
|
||||
'page' => 'required|integer|min:1',
|
||||
'sales_id' => 'nullable|integer|exists:sales,id',
|
||||
'produk_id' => 'nullable|integer|exists:produks,id',
|
||||
'nama_pembeli' => 'nullable|string|max:255',
|
||||
]));
|
||||
|
||||
} catch (\Exception $e) {
|
||||
@ -107,12 +107,12 @@ class LaporanController extends Controller
|
||||
{
|
||||
try {
|
||||
return $this->laporanService->exportPerProduk($request->validate([
|
||||
'tanggal' => 'nullable|string',
|
||||
'sales_id' => 'nullable|integer|exists:sales,id',
|
||||
'nampan_id' => 'nullable|integer|exists:nampan,id',
|
||||
'nama_pembeli' => 'nullable|string|max:255',
|
||||
'tanggal' => 'required|string',
|
||||
'format' => 'required|string|in:pdf,xlsx,csv',
|
||||
'page' => 'nullable|integer|min:1',
|
||||
'page' => 'required|integer|min:1',
|
||||
'sales_id' => 'nullable|integer|exists:sales,id',
|
||||
'nampan_id' => 'nullable|integer|exists:nampans,id',
|
||||
'nama_pembeli' => 'nullable|string|max:255',
|
||||
]));
|
||||
|
||||
} catch (\Exception $e) {
|
||||
|
@ -175,9 +175,8 @@ const data = ref(null);
|
||||
const loading = ref(false);
|
||||
const loadingExport = ref(false);
|
||||
|
||||
// Sorting state
|
||||
const sortBy = ref(null);
|
||||
const sortOrder = ref('asc'); // 'asc' or 'desc'
|
||||
const sortOrder = ref('asc');
|
||||
|
||||
const pagination = ref({
|
||||
current_page: 1,
|
||||
@ -188,14 +187,14 @@ const pagination = ref({
|
||||
const pendapatanWidth = ref(0);
|
||||
const pendapatanElements = ref([]);
|
||||
|
||||
const salesDipilih = ref(null);
|
||||
const salesDipilih = ref(0);
|
||||
const opsiSales = ref([
|
||||
{ label: 'Semua Sales', value: null, selected: true },
|
||||
{ label: 'Semua Sales', value: 0 },
|
||||
]);
|
||||
|
||||
const produkDipilih = ref(null);
|
||||
const produkDipilih = ref(0);
|
||||
const opsiProduk = ref([
|
||||
{ label: 'Semua Produk', value: null, selected: true },
|
||||
{ label: 'Semua Produk', value: 0 },
|
||||
]);
|
||||
|
||||
const namaPembeli = ref(null);
|
||||
@ -278,10 +277,8 @@ watch(nampan, async (newValue) => {
|
||||
// --- Methods ---
|
||||
const handleSort = (column) => {
|
||||
if (sortBy.value === column) {
|
||||
// If same column, toggle sort order
|
||||
sortOrder.value = sortOrder.value === 'asc' ? 'desc' : 'asc';
|
||||
} else {
|
||||
// If different column, set new column and default to ascending
|
||||
sortBy.value = column;
|
||||
sortOrder.value = 'asc';
|
||||
}
|
||||
@ -308,7 +305,7 @@ const fetchSales = async () => {
|
||||
});
|
||||
const salesData = response.data;
|
||||
opsiSales.value = [
|
||||
{ label: 'Semua Sales', value: null },
|
||||
{ label: 'Semua Sales', value: 0 },
|
||||
...salesData.map(sales => ({
|
||||
label: sales.nama,
|
||||
value: sales.id,
|
||||
@ -328,7 +325,7 @@ const fetchProduk = async () => {
|
||||
});
|
||||
const produkData = response.data;
|
||||
opsiProduk.value = [
|
||||
{ label: 'Semua Produk', value: null },
|
||||
{ label: 'Semua Produk', value: 0 },
|
||||
...produkData.map(produk => ({
|
||||
label: produk.nama,
|
||||
value: produk.id,
|
||||
@ -346,8 +343,8 @@ const fetchData = async (page = 1) => {
|
||||
pendapatanElements.value = [];
|
||||
|
||||
let queryParams = `tanggal=${tanggalDipilih.value}&page=${page}`;
|
||||
if (salesDipilih.value) queryParams += `&sales_id=${salesDipilih.value}`;
|
||||
if (produkDipilih.value) queryParams += `&produk_id=${produkDipilih.value}`;
|
||||
if (salesDipilih.value != 0 ) queryParams += `&sales_id=${salesDipilih.value}`;
|
||||
if (produkDipilih.value != 0) queryParams += `&produk_id=${produkDipilih.value}`;
|
||||
if (namaPembeli.value) queryParams += `&nama_pembeli=${encodeURIComponent(namaPembeli.value)}`;
|
||||
|
||||
try {
|
||||
@ -400,14 +397,14 @@ const selectExport = async (option) => {
|
||||
loadingExport.value = true;
|
||||
|
||||
try {
|
||||
const response = await axios.get('/api/laporan/export/detail-pernampan', {
|
||||
const response = await axios.get(`/api/laporan/export/detail-pernampan`, {
|
||||
params: {
|
||||
tanggal: tanggalDipilih.value,
|
||||
sales_id: salesDipilih.value,
|
||||
produk_id: produkDipilih.value,
|
||||
nama_pembeli: namaPembeli.value,
|
||||
format: exportFormat.value,
|
||||
page: pagination.value.current_page,
|
||||
sales_id: salesDipilih.value != 0 ? salesDipilih.value : null,
|
||||
produk_id: produkDipilih.value != 0 ? produkDipilih.value : null,
|
||||
nama_pembeli: namaPembeli.value || null,
|
||||
},
|
||||
headers: {
|
||||
Authorization: `Bearer ${localStorage.getItem("token")}`,
|
||||
|
@ -183,14 +183,14 @@ const pagination = ref({
|
||||
const pendapatanWidth = ref(0);
|
||||
const pendapatanElements = ref([]);
|
||||
|
||||
const salesDipilih = ref(null);
|
||||
const salesDipilih = ref(0);
|
||||
const opsiSales = ref([
|
||||
{ label: 'Semua Sales', value: null, selected: true },
|
||||
{ label: 'Semua Sales', value: 0, selected: true },
|
||||
]);
|
||||
|
||||
const nampanDipilih = ref(null);
|
||||
const nampanDipilih = ref(0);
|
||||
const opsiNampan = ref([
|
||||
{ label: 'Semua Nampan', value: null, selected: true },
|
||||
{ label: 'Semua Nampan', value: 0, selected: true },
|
||||
]);
|
||||
|
||||
const namaPembeli = ref(null);
|
||||
@ -301,7 +301,7 @@ const fetchSales = async () => {
|
||||
});
|
||||
const salesData = response.data;
|
||||
opsiSales.value = [
|
||||
{ label: 'Semua Sales', value: null },
|
||||
{ label: 'Semua Sales', value: 0 },
|
||||
...salesData.map(sales => ({
|
||||
label: sales.nama,
|
||||
value: sales.id,
|
||||
@ -321,7 +321,7 @@ const fetchNampan = async () => {
|
||||
});
|
||||
const nampanData = response.data;
|
||||
opsiNampan.value = [
|
||||
{ label: 'Semua Nampan', value: null },
|
||||
{ label: 'Semua Nampan', value: 0 },
|
||||
{ label: 'Brankas', value: 0 },
|
||||
...nampanData.map(nampan => ({
|
||||
label: nampan.nama,
|
||||
@ -340,9 +340,9 @@ const fetchData = async (page = 1) => {
|
||||
pendapatanElements.value = [];
|
||||
|
||||
let queryParams = `tanggal=${tanggalDipilih.value}&page=${page}`;
|
||||
if (salesDipilih.value != null) queryParams += `&sales_id=${salesDipilih.value}`;
|
||||
if (nampanDipilih.value != null) queryParams += `&nampan_id=${nampanDipilih.value}`;
|
||||
if (namaPembeli.value != null || namaPembeli.value != '') queryParams += `&nama_pembeli=${encodeURIComponent(namaPembeli.value)}`;
|
||||
if (salesDipilih.value != 0 ) queryParams += `&sales_id=${salesDipilih.value}`;
|
||||
if (nampanDipilih.value != 0) queryParams += `&produk_id=${produkDipilih.value}`;
|
||||
if (namaPembeli.value) queryParams += `&nama_pembeli=${encodeURIComponent(namaPembeli.value)}`;
|
||||
|
||||
try {
|
||||
const response = await axios.get(`/api/laporan/detail-per-produk?${queryParams}`, {
|
||||
@ -395,10 +395,11 @@ const selectExport = async (option) => {
|
||||
const response = await axios.get('/api/laporan/export/detail-perproduk', {
|
||||
params: {
|
||||
tanggal: tanggalDipilih.value,
|
||||
sales_id: salesDipilih.value,
|
||||
nampan_id: nampanDipilih.value,
|
||||
nama_pembeli: namaPembeli.value,
|
||||
format: exportFormat.value,
|
||||
page: pagination.value.current_page,
|
||||
sales_id: salesDipilih.value != 0 ? salesDipilih.value : null,
|
||||
nampan_id: nampanDipilih.value != 0 ? nampanDipilih.value : null,
|
||||
nama_pembeli: namaPembeli.value || null,
|
||||
},
|
||||
headers: {
|
||||
Authorization: `Bearer ${localStorage.getItem("token")}`,
|
||||
|
Loading…
Reference in New Issue
Block a user