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