ปรับ code และ ปุม delete รายการรอบการปฏิบัติงาน

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2023-11-14 09:20:30 +07:00
parent bcb46fa272
commit 01cbfe6245
17 changed files with 1452 additions and 996 deletions

View file

@ -1,63 +1,87 @@
import { defineStore } from "pinia";
import { ref, } from "vue";
import { useCounterMixin } from "@/stores/mixin";
const mixin = useCounterMixin();
const {
date2Thai,
} = mixin;
import { ref } from "vue";
export const useAllocateDataStore = defineStore("insigniaallocate", () => {
const roundId = ref<string>('')
const roundYear = ref<number>()
const insigniaName = ref<string>('')
const insignia = ref<string>('')
const insigniaOp = ref<any[]>([{ name: "ทั้งหมด", id: "", type: "" }])
const insigniaType = ref<any>()
const rows = ref<any>([])
const listInsignia = ref<any>([])
const mainTab = ref<string>("")
const type = ref<any[]>([])
const fetchDatainsignia = async (data: any) => {
// insignia.value = ''
insigniaOp.value = [{ name: "ทั้งหมด", id: "", type: "" }]
const roundId = ref<string>("");
const roundYear = ref<number>();
const insigniaName = ref<string>("");
const insignia = ref<string>("");
const insigniaOp = ref<any[]>([{ name: "ทั้งหมด", id: "", type: "" }]);
const insigniaType = ref<any>();
const rows = ref<any>([]);
const listInsignia = ref<any>([]);
const mainTab = ref<string>("");
const type = ref<any[]>([]);
/**
* function
* @param data
*/
async function fetchDatainsignia(data: any) {
insigniaOp.value = [{ name: "ทั้งหมด", id: "", type: "" }];
data.forEach((e: any) => {
insigniaOp.value.push({ name: `${e.name} (${e.shortName})`, id: e.id, type: e.insigniaType.id })
insigniaOp.value.push({
name: `${e.name} (${e.shortName})`,
id: e.id,
type: e.insigniaType.id,
});
});
data.forEach((e: any) => {
type.value.push({
name:e.name,
shortName:e.shortName,
})})
name: e.name,
shortName: e.shortName,
});
});
}
const fetchDatainsigniaType = async (data: any,) => {
insigniaType.value = data.map((e: any) => ({ name: e.id, label: e.name }))
// mainTab.value = insigniaType.value[0].name
/**
* function
* @param data
*/
async function fetchDatainsigniaType(data: any) {
insigniaType.value = data.map((e: any) => ({ name: e.id, label: e.name }));
}
const listinsignia = async (data: any) => {
/**
* function
* @param data
*/
async function listinsignia(data: any) {
rows.value = [];
let list = await data.map((e: any) => ({
id: e.id,
insignia: `${e.insignia} (${type.value.find(item => item.name === e.insignia)?.shortName || ''})`,
insignia: `${e.insignia} (${
type.value.find((item) => item.name === e.insignia)?.shortName || ""
})`,
insigniaId: e.insigniaId,
total: e.total,
allocate: e.allocate,
remain: e.remain,
year: e.year,
}))
rows.value = list
listInsignia.value = list
selectInsignia(insignia.value)
}));
rows.value = list;
listInsignia.value = list;
selectInsignia(insignia.value);
}
const selectInsignia = (type: string) => {
insignia.value = type
if (insignia.value !== "") {
rows.value = listInsignia.value.filter((e: any) => e.insigniaId === insignia.value)
} else rows.value = listInsignia.value
/**
* function
* @param type
*/
function selectInsignia(type: string) {
insignia.value = type;
if (insignia.value !== "") {
rows.value = listInsignia.value.filter(
(e: any) => e.insigniaId === insignia.value
);
} else rows.value = listInsignia.value;
}
const profileType = (val: string) => {
/**
* function convert
* @param val
*/
function profileType(val: string) {
switch (val) {
case "officer":
return "ข้าราชการ กทม.สามัญ";
@ -78,6 +102,6 @@ export const useAllocateDataStore = defineStore("insigniaallocate", () => {
selectInsignia,
profileType,
insigniaName,
mainTab
mainTab,
};
});