2023-06-01 12:54:58 +07:00
|
|
|
import { defineStore } from "pinia";
|
2023-06-08 14:31:25 +07:00
|
|
|
import { ref } from "vue";
|
|
|
|
|
import type { FormPlacementMainData } from "@/modules/05_placement/interface/request/Main"
|
2023-06-01 12:54:58 +07:00
|
|
|
export const useProfileDataStore = defineStore("placement", () => {
|
|
|
|
|
return {};
|
|
|
|
|
});
|
2023-06-07 13:42:11 +07:00
|
|
|
export const usePlacementDataStore = defineStore("placement", () => {
|
|
|
|
|
interface placement {
|
|
|
|
|
mappingPosition: { columns: String[] };
|
|
|
|
|
}
|
|
|
|
|
const placementData = ref<placement>({
|
|
|
|
|
mappingPosition: { columns: [] },
|
|
|
|
|
});
|
|
|
|
|
const changePlacementColumns = (system: String, val: String[]) => {
|
|
|
|
|
if (system == "mappingPosition")
|
|
|
|
|
placementData.value.mappingPosition.columns = val;
|
|
|
|
|
localStorage.setItem(
|
|
|
|
|
"placement",
|
|
|
|
|
JSON.stringify(placementData.value)
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (localStorage.getItem("placement") !== null) {
|
|
|
|
|
placementData.value = JSON.parse(
|
|
|
|
|
localStorage.getItem("placement") || "{}"
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-08 14:31:25 +07:00
|
|
|
let DataMainOrig = ref<FormPlacementMainData[]>([]) // ข้อมูลหลัก
|
|
|
|
|
let DataMainUpdate = ref<FormPlacementMainData[]>([]) // ข้อมูลเปลี่ยนแปลง
|
|
|
|
|
const DataMain = (val: any) => (DataMainOrig.value = val)
|
|
|
|
|
const DataUpdateMain = (val: any) => {
|
|
|
|
|
DataMainUpdate.value = [];
|
|
|
|
|
DataMainUpdate.value = val;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-07 13:42:11 +07:00
|
|
|
return {
|
|
|
|
|
placementData,
|
|
|
|
|
changePlacementColumns,
|
2023-06-08 14:31:25 +07:00
|
|
|
DataMainOrig,
|
|
|
|
|
DataMainUpdate,
|
|
|
|
|
DataMain,
|
|
|
|
|
DataUpdateMain,
|
2023-06-07 13:42:11 +07:00
|
|
|
};
|
|
|
|
|
});
|