|
|
|
@ -1,91 +1,48 @@
|
|
|
|
|
|
|
|
|
|
import { getUid, getUp3, getPosko, getUlp } from '@/utils/network';
|
|
|
|
|
import { getUid, getUp3, getPosko, getUlp } from '@/utils/network'
|
|
|
|
|
import { ref } from 'vue'
|
|
|
|
|
import { usePostsStore } from '@/stores/posts';
|
|
|
|
|
import { useUp3Store } from '@/stores/up3';
|
|
|
|
|
import { useRegionStore } from '@/stores/region';
|
|
|
|
|
import { useUlpStore } from '@/stores/ulp';
|
|
|
|
|
import { usePostsStore } from '@/stores/posts'
|
|
|
|
|
import { useUp3Store } from '@/stores/up3'
|
|
|
|
|
import { useRegionStore } from '@/stores/region'
|
|
|
|
|
import { useUlpStore } from '@/stores/ulp'
|
|
|
|
|
|
|
|
|
|
interface Item {
|
|
|
|
|
id: any;
|
|
|
|
|
id: number;
|
|
|
|
|
name: any;
|
|
|
|
|
}
|
|
|
|
|
const months = [
|
|
|
|
|
{ id: 1, name: 'Januari' },
|
|
|
|
|
{ id: 2, name: 'Februari' },
|
|
|
|
|
{ id: 3, name: 'Maret' },
|
|
|
|
|
{ id: 4, name: 'April' },
|
|
|
|
|
{ id: 5, name: 'Mei' },
|
|
|
|
|
{ id: 6, name: 'Juni' },
|
|
|
|
|
{ id: 7, name: 'Juli' },
|
|
|
|
|
{ id: 8, name: 'Agustus' },
|
|
|
|
|
{ id: 9, name: 'September' },
|
|
|
|
|
{ id: 10, name: 'Oktober' },
|
|
|
|
|
{ id: 11, name: 'November' },
|
|
|
|
|
{ id: 12, name: 'Desember' },
|
|
|
|
|
const months =[
|
|
|
|
|
{id:1, name: 'Januari'},
|
|
|
|
|
{id:2, name: 'Februari'},
|
|
|
|
|
{id:3, name: 'Maret'},
|
|
|
|
|
{id:4, name: 'April'},
|
|
|
|
|
{id:5, name: 'Mei'},
|
|
|
|
|
{id:6, name: 'Juni'},
|
|
|
|
|
{id:7, name: 'Juli'},
|
|
|
|
|
{id:8, name: 'Agustus'},
|
|
|
|
|
{id:9, name: 'September'},
|
|
|
|
|
{id:10, name: 'Oktober'},
|
|
|
|
|
{id:11, name: 'November'},
|
|
|
|
|
{id:12, name: 'Desember'},
|
|
|
|
|
]
|
|
|
|
|
// create 4 year back array
|
|
|
|
|
const year = new Date().getFullYear();
|
|
|
|
|
const years = ref<Item[]>([]);
|
|
|
|
|
const years =ref<Item[]>([]);
|
|
|
|
|
for (let i = 0; i < 5; i++) {
|
|
|
|
|
years.value.push({ id: year - i, name: year - i })
|
|
|
|
|
years.value.push({id:year-i, name: year-i})
|
|
|
|
|
}
|
|
|
|
|
const itemsUid = ref<Item[]>([]);
|
|
|
|
|
const timeout = ref()
|
|
|
|
|
const items = ref<Item[]>([]);
|
|
|
|
|
const itemsUp3 = ref<Item[]>([]);
|
|
|
|
|
const itemsPosko = ref<Item[]>([]);
|
|
|
|
|
const itemsUlp = ref<Item[]>([]);
|
|
|
|
|
const itemsUlp = ref<Item[]>([]);
|
|
|
|
|
const itemsRegional = ref<Item[]>([]);
|
|
|
|
|
const itemsMedia = ref<Item[]>([]);
|
|
|
|
|
// Fetch data from the API using Axios
|
|
|
|
|
const fetchUid = async () => {
|
|
|
|
|
try {
|
|
|
|
|
const res = await getUid()
|
|
|
|
|
itemsUid.value = res.data.map((item: any) => (
|
|
|
|
|
{
|
|
|
|
|
id: item.id,
|
|
|
|
|
name: item.nama,
|
|
|
|
|
}
|
|
|
|
|
));
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Error fetching data:', error);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const fetchDataUp3 = async (uid: number) => {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const res = await getUp3(uid)
|
|
|
|
|
itemsUp3.value = res.data.map((item: any) => (
|
|
|
|
|
{
|
|
|
|
|
id: item.id,
|
|
|
|
|
name: item.nama,
|
|
|
|
|
}
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Error fetching data:', error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
const fetchDataUlp = async (up3: number) => {
|
|
|
|
|
try {
|
|
|
|
|
const res = await getUlp(up3)
|
|
|
|
|
itemsUlp.value = res.data.map((item: any) => (
|
|
|
|
|
{
|
|
|
|
|
id: item.name,
|
|
|
|
|
name: item.name,
|
|
|
|
|
}
|
|
|
|
|
));
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Error fetching data:', error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const fetchDataPosko = async (up3: number) => {
|
|
|
|
|
const fetchData = async () => {
|
|
|
|
|
try {
|
|
|
|
|
const res = await getPosko(up3)
|
|
|
|
|
itemsPosko.value = res.data.map((item: any) => (
|
|
|
|
|
const res = await getUid()
|
|
|
|
|
items.value = res.data.map((item: any) => (
|
|
|
|
|
{
|
|
|
|
|
id: item.nama,
|
|
|
|
|
id: item.id,
|
|
|
|
|
name: item.nama,
|
|
|
|
|
}
|
|
|
|
|
));
|
|
|
|
@ -93,59 +50,66 @@ const fetchDataPosko = async (up3: number) => {
|
|
|
|
|
console.error('Error fetching data:', error);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
const fetchMedia = () => {
|
|
|
|
|
itemsMedia.value = [
|
|
|
|
|
{ id: "Ulasan Aplikasi PLN Mobile", name: "Ulasan Aplikasi PLN Mobile"},
|
|
|
|
|
{ id: "Twitter", name: "Twitter" },
|
|
|
|
|
{ id: "PLN Mobile", name: "PLN Mobile" },
|
|
|
|
|
{ id: "Media Massa", name: "Media Massa" },
|
|
|
|
|
{ id: "Live Chat Website", name: "Live Chat Website" },
|
|
|
|
|
{ id: "Live Chat PLN Mobile", name: "Live Chat PLN Mobile" },
|
|
|
|
|
{ id: "Instagram", name: "Instagram" },
|
|
|
|
|
{ id: "Facebook", name: "Facebook" },
|
|
|
|
|
{ id: "Email", name: "Email" },
|
|
|
|
|
{ id: "EMS", name: "EMS" },
|
|
|
|
|
{ id: "Datang ke Kantor", name: "Datang ke Kantor" },
|
|
|
|
|
{ id: "Call ke Kantor Unit", name: "Call ke Kantor Unit" },
|
|
|
|
|
{ id: "Call PLN 123", name: "Call PLN 123" },
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
const fetchDataUp3 = async (uid: number) => {
|
|
|
|
|
try {
|
|
|
|
|
const res = await getUp3(uid)
|
|
|
|
|
itemsUp3.value = res.data.map((item: any) => ({
|
|
|
|
|
id: item.id,
|
|
|
|
|
name: item.nama
|
|
|
|
|
}))
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Error fetching data:', error)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const fetchStatus = (data : any) => {
|
|
|
|
|
|
|
|
|
|
const status = [
|
|
|
|
|
{"id": "8", "name": "Selesai"},
|
|
|
|
|
{"id": "7", "name": "Nyala"},
|
|
|
|
|
{"id": "6", "name": "Pengalihan"},
|
|
|
|
|
{"id": "5", "name": "Dialihkan"},
|
|
|
|
|
{"id": "4", "name": "Dalam Pengerjaan"},
|
|
|
|
|
{"id": "3", "name": "Dalam Perjalanan"},
|
|
|
|
|
{"id": "2", "name": "Penugasan Regu"},
|
|
|
|
|
{"id": "1", "name": "lapor"}
|
|
|
|
|
]
|
|
|
|
|
const filteredStatus = status.find(item => item.id == data);
|
|
|
|
|
const name = filteredStatus ? filteredStatus.name : null;
|
|
|
|
|
return name;
|
|
|
|
|
const fetchDataUlp = async (up3: number) => {
|
|
|
|
|
try {
|
|
|
|
|
const res = await getUlp(up3)
|
|
|
|
|
itemsUlp.value = res.data.map((item: any) => (
|
|
|
|
|
{
|
|
|
|
|
id: item.id,
|
|
|
|
|
name: item.nama,
|
|
|
|
|
}
|
|
|
|
|
));
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Error fetching data:', error)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const fetchDataPosko = async (up3: number) => {
|
|
|
|
|
clearTimeout(timeout.value)
|
|
|
|
|
timeout.value = setTimeout(async () => {
|
|
|
|
|
try {
|
|
|
|
|
const res = await getPosko(up3)
|
|
|
|
|
itemsPosko.value = res.data.map((item: any) => (
|
|
|
|
|
{
|
|
|
|
|
id: item.id,
|
|
|
|
|
name: item.nama,
|
|
|
|
|
}
|
|
|
|
|
));
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Error fetching data:', error);
|
|
|
|
|
}
|
|
|
|
|
},300);
|
|
|
|
|
};
|
|
|
|
|
const selectedUid = (value: any) => {
|
|
|
|
|
useRegionStore().setData(value.id);
|
|
|
|
|
fetchDataUp3(value.id);
|
|
|
|
|
useRegionStore().setData(value.id)
|
|
|
|
|
fetchDataUp3(value.id)
|
|
|
|
|
}
|
|
|
|
|
const selectedUp3Posko = (value: any) => {
|
|
|
|
|
useUp3Store().setData(value.id);
|
|
|
|
|
fetchDataPosko(value.id);
|
|
|
|
|
if (value.id != 0) {
|
|
|
|
|
useUp3Store().setData(value.id)
|
|
|
|
|
fetchDataPosko(value.id)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const selectedUp3Ulp = (value: any) => {
|
|
|
|
|
useUp3Store().setData(value.id);
|
|
|
|
|
fetchDataUlp(value.id);
|
|
|
|
|
useUp3Store().setData(value.id)
|
|
|
|
|
fetchDataUlp(value.id)
|
|
|
|
|
}
|
|
|
|
|
const selectedPosko = (value: any) => {
|
|
|
|
|
usePostsStore().setData(value.id);
|
|
|
|
|
usePostsStore().setData(value.id)
|
|
|
|
|
}
|
|
|
|
|
const selectedUlp = (value: any) => {
|
|
|
|
|
useUlpStore().setData(value.id);
|
|
|
|
|
useUlpStore().setData(value.id)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export { selectedUid, selectedUp3Posko, selectedUp3Ulp, selectedPosko, selectedUlp, fetchUid,fetchMedia,fetchStatus, itemsUid, itemsUp3, itemsPosko, itemsRegional, itemsMedia, itemsUlp, months, years };
|
|
|
|
|
export { selectedUid, selectedUp3Posko ,selectedUp3Ulp, selectedPosko,selectedUlp, fetchData, items, itemsUp3, itemsPosko,itemsRegional,itemsMedia,itemsUlp ,months ,years};
|
|
|
|
|