34 lines
996 B
TypeScript
34 lines
996 B
TypeScript
import { defineStore } from "pinia";
|
|
import { ref } from "vue";
|
|
import type {
|
|
DataResponse,
|
|
DataRow,
|
|
} from "../interface/response/position/ListType";
|
|
import { useCounterMixin } from "@/stores/mixin";
|
|
|
|
const { date2Thai } = useCounterMixin();
|
|
|
|
export const usePositionEmployeeDataStore = defineStore(
|
|
"positionEmployeeStore",
|
|
() => {
|
|
const pathLocation = ref<string>("list_position");
|
|
const row = ref<DataRow[]>([]);
|
|
function save(data: DataResponse[], id: string) {
|
|
const list = data.map((e) => ({
|
|
...e,
|
|
posTypes: undefined,
|
|
posTypeId: e.posTypes?.id,
|
|
posTypeName: e.posTypes?.posTypeName,
|
|
posTypeRank: e.posTypes?.posTypeRank,
|
|
createdAt: e.createdAt ? date2Thai(e.createdAt) : "",
|
|
lastUpdatedAt: e.lastUpdatedAt ? date2Thai(e.lastUpdatedAt) : "",
|
|
})) satisfies DataRow[];
|
|
row.value = list.filter((e) => e.posTypeId === id);
|
|
}
|
|
return {
|
|
save,
|
|
row,
|
|
pathLocation,
|
|
};
|
|
}
|
|
);
|