mock api รายงาน เครื่องราช
This commit is contained in:
parent
fa316f5643
commit
016970dc9e
10 changed files with 1046 additions and 205 deletions
|
|
@ -1,27 +1,30 @@
|
|||
import { defineStore } from "pinia";
|
||||
import { ref, } from "vue";
|
||||
import { ref } from "vue";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
|
||||
const mixin = useCounterMixin();
|
||||
const {
|
||||
date2Thai
|
||||
} = mixin;
|
||||
|
||||
const { date2Thai } = mixin;
|
||||
|
||||
export const useInsigniaDataStore = defineStore("insignia", () => {
|
||||
let optionsTypeOc = ref<any>([]);
|
||||
let typeOc = ref<string>("")
|
||||
const agency = ref<string>('')
|
||||
let rows = ref<any>([])
|
||||
const listinsignia = ref<any>([])
|
||||
let typeOc = ref<string>("");
|
||||
const agency = ref<string>("");
|
||||
let rows = ref<any>([]);
|
||||
const listinsignia = ref<any>([]);
|
||||
const typeinsignia = ref<number | string>("all");
|
||||
let typeinsigniaOptions = ref<any>([{ id: "all", name: "ทั้งหมด" }]);
|
||||
|
||||
const typeReport = ref<string>("");
|
||||
const titleReport = ref<string>("");
|
||||
|
||||
const setTypeandTitle = (type: string, title: string) => {
|
||||
typeReport.value = type;
|
||||
titleReport.value = title;
|
||||
};
|
||||
|
||||
const fetchData = async (data: any) => {
|
||||
if (data !== null) {
|
||||
rows.value = await data.map((e: any) =>
|
||||
({
|
||||
rows.value = await data.map((e: any) => ({
|
||||
id: e.id,
|
||||
citizenId: e.citizenId,
|
||||
profileId: e.profileId,
|
||||
|
|
@ -34,26 +37,27 @@ export const useInsigniaDataStore = defineStore("insignia", () => {
|
|||
insigniaSend: e.requestInsignia,
|
||||
insigniaLevel: e.level,
|
||||
dateSend: date2Thai(e.requestDate),
|
||||
requestNote: e.requestNote
|
||||
}))
|
||||
listinsignia.value = await rows.value
|
||||
filtertypeInsignia()
|
||||
} else rows.value = []
|
||||
}
|
||||
requestNote: e.requestNote,
|
||||
}));
|
||||
listinsignia.value = await rows.value;
|
||||
filtertypeInsignia();
|
||||
} else rows.value = [];
|
||||
};
|
||||
const fetchOption = (op: any) => {
|
||||
if (agency.value !== null) {
|
||||
typeOc.value = agency.value
|
||||
optionsTypeOc.value = op.filter((e: any) => e.id == agency.value
|
||||
)
|
||||
} else { optionsTypeOc.value = op, typeOc.value = op[2].id }
|
||||
}
|
||||
typeOc.value = agency.value;
|
||||
optionsTypeOc.value = op.filter((e: any) => e.id == agency.value);
|
||||
} else {
|
||||
(optionsTypeOc.value = op), (typeOc.value = op[2].id);
|
||||
}
|
||||
};
|
||||
const filtertypeInsignia = async () => {
|
||||
typeinsignia.value = "all"
|
||||
typeinsignia.value = "all";
|
||||
if (listinsignia.value.length !== 0) {
|
||||
const double_name = [
|
||||
...new Set(listinsignia.value.map((item: any) => item.insigniaSend)),
|
||||
];
|
||||
typeinsigniaOptions.value = [{ id: "all", name: "ทั้งหมด" }]
|
||||
typeinsigniaOptions.value = [{ id: "all", name: "ทั้งหมด" }];
|
||||
for (let i = 1; i <= double_name.length; i++) {
|
||||
const type = double_name[i - 1];
|
||||
const listtype = {
|
||||
|
|
@ -61,9 +65,9 @@ export const useInsigniaDataStore = defineStore("insignia", () => {
|
|||
name: type,
|
||||
};
|
||||
// typeinsigniaOptions.value = [{ id: "all", name: "ทั้งหมด" }]
|
||||
typeinsigniaOptions.value.push(listtype)
|
||||
typeinsigniaOptions.value.push(listtype);
|
||||
}
|
||||
} else typeinsigniaOptions.value = [{ id: "all", name: "ทั้งหมด" }]
|
||||
} else typeinsigniaOptions.value = [{ id: "all", name: "ทั้งหมด" }];
|
||||
};
|
||||
|
||||
const searchFilterTable = async () => {
|
||||
|
|
@ -88,5 +92,8 @@ export const useInsigniaDataStore = defineStore("insignia", () => {
|
|||
fetchData,
|
||||
fetchOption,
|
||||
searchFilterTable,
|
||||
setTypeandTitle,
|
||||
typeReport,
|
||||
titleReport,
|
||||
};
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue