109 lines
3.2 KiB
TypeScript
109 lines
3.2 KiB
TypeScript
import { defineStore } from "pinia";
|
|
import { ref, } from "vue";
|
|
import { useCounterMixin } from "@/stores/mixin";
|
|
|
|
const mixin = useCounterMixin();
|
|
const {
|
|
date2Thai,
|
|
dialogConfirm,
|
|
showLoader,
|
|
hideLoader,
|
|
messageError,
|
|
success,
|
|
} = mixin;
|
|
|
|
export const useResultDataStore = defineStore("insigniaResult", () => {
|
|
const insignia = ref<string>('')
|
|
const insigniaOp = ref<any[]>([{ name: "ทั้งหมด", id: "" }])
|
|
const insigniaOp2 = ref<any[]>([])
|
|
const insigniaType = ref<any>()
|
|
const invoiceType = ref<string>('all')
|
|
const invoiceTypeop = ref<any>([{ name: "ทั้งหมด", id: "all" }, { name: "ใบกำกับที่ค้างจ่าย", id: "noDate" }, { name: "ใบกำกับที่จ่ายแล้ว", id: "haveDate" }])
|
|
const rows = ref<any>([])
|
|
const listInsignia = ref<any>([])
|
|
|
|
|
|
const fetchDatainsignia = async (data: any) => {
|
|
insignia.value = ''
|
|
invoiceType.value = 'all'
|
|
data.forEach((e: any) => {
|
|
insigniaOp.value.push({ name: e.name, id: e.id })
|
|
});
|
|
data.forEach((e: any) => {
|
|
insigniaOp2.value.push({ name: e.name, id: e.id })
|
|
});
|
|
}
|
|
const fetchDatainsigniaType = async (data: any) => {
|
|
insigniaType.value = data.map((e: any) => ({ name: e.id, label: e.name }))
|
|
}
|
|
const fetchlistinsignia = async (data: any) => {
|
|
rows.value = [];
|
|
let alllist = await data.map((e: any) => ({
|
|
id: e.id,
|
|
citizenId: e.citizenId,
|
|
prefix: e.prefix,
|
|
position: e.position,
|
|
status: status(e.status),
|
|
dateReceive: date2Thai(e.dateReceive),
|
|
name: e.fullName,
|
|
type: e.requestInsignia,
|
|
employeeType: profileType(e.profileType),
|
|
profileType: e.profileType,
|
|
page: e.page,
|
|
number: e.no,
|
|
vatnumber: e.number,
|
|
datepay: date2Thai(e.datePayment),
|
|
typepay: e.typePayment,
|
|
address: e.address,
|
|
}));
|
|
rows.value = alllist
|
|
listInsignia.value = alllist
|
|
selectInvoice(invoiceType.value)
|
|
|
|
}
|
|
const selectInvoice = (invoice: string) => {
|
|
console.log(invoice);
|
|
if (invoice === "noDate") {
|
|
let list = listInsignia.value.filter((e: any) => e.datepay === null)
|
|
rows.value = list
|
|
} else if (invoice === "haveDate") {
|
|
let list = listInsignia.value.filter((e: any) => e.datepay !== null)
|
|
rows.value = list
|
|
} else rows.value = listInsignia.value
|
|
}
|
|
const status = (val: string) => {
|
|
switch (val) {
|
|
case "PENDING":
|
|
return "รอบันทึกข้อมูล";
|
|
case "REJECT":
|
|
return "ยกเลิก";
|
|
case "DELETE":
|
|
return "ลบ";
|
|
case "DONE":
|
|
return "บันทึกลง ก.พ. 7 แล้ว";
|
|
}
|
|
}
|
|
const profileType = (val: string) => {
|
|
switch (val) {
|
|
case "officer":
|
|
return "ข้าราชการ กทม.สามัญ";
|
|
case "employee":
|
|
return "ลูกจ้างประจำ";
|
|
}
|
|
}
|
|
return {
|
|
rows,
|
|
insignia,
|
|
insigniaOp,
|
|
insigniaOp2,
|
|
insigniaType,
|
|
invoiceType,
|
|
invoiceTypeop,
|
|
fetchDatainsignia,
|
|
fetchDatainsigniaType,
|
|
status,
|
|
profileType,
|
|
fetchlistinsignia,
|
|
selectInvoice,
|
|
};
|
|
});
|