Pinia Store data positionPath
This commit is contained in:
parent
c1b7b25981
commit
cb52aec394
2 changed files with 137 additions and 32 deletions
|
|
@ -217,7 +217,8 @@ const { loaderPage } = dataStore;
|
||||||
const mixin = useCounterMixin();
|
const mixin = useCounterMixin();
|
||||||
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
|
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
|
||||||
const store = useManageDataStore();
|
const store = useManageDataStore();
|
||||||
const { manageData, changeManageColumns } = store;
|
const { manageData, changeManageColumns, getPositionPath, dataPositionPath } =
|
||||||
|
store;
|
||||||
const rows = ref<RequestItemsHistoryObject[]>([]); //list data table
|
const rows = ref<RequestItemsHistoryObject[]>([]); //list data table
|
||||||
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
|
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
|
||||||
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
|
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
|
||||||
|
|
@ -400,38 +401,43 @@ const $q = useQuasar();
|
||||||
/**
|
/**
|
||||||
* ฟังก์ชัน get data ล่าสุด
|
* ฟังก์ชัน get data ล่าสุด
|
||||||
*/
|
*/
|
||||||
const fetchData = async () => {
|
const fetchData = async (load: boolean = false) => {
|
||||||
await props.fetchDataComponent();
|
await props.fetchDataComponent();
|
||||||
rows.value.splice(0);
|
const result = await getPositionPath(false, load);
|
||||||
showLoader();
|
version.value = result.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่
|
||||||
await http
|
idVersion.value = result.idversion; //เลข id ใน mongodb
|
||||||
.get(config.API.listPositionPathHistory)
|
rows.value = result.data;
|
||||||
.then((res) => {
|
updateData.value = false;
|
||||||
let data = res.data.result;
|
// rows.value.splice(0);
|
||||||
version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่
|
// showLoader();
|
||||||
idVersion.value = data.id; //เลข id ใน mongodb
|
// await http
|
||||||
data.items.map((e: RequestItemsHistoryObject) => {
|
// .get(config.API.listPositionPathHistory)
|
||||||
rows.value.push({
|
// .then((res) => {
|
||||||
id: e.id,
|
// let data = res.data.result;
|
||||||
name: e.name,
|
// version.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่
|
||||||
createdAt: e.createdAt,
|
// idVersion.value = data.id; //เลข id ใน mongodb
|
||||||
lastUpdatedAt: e.lastUpdatedAt,
|
// data.items.map((e: RequestItemsHistoryObject) => {
|
||||||
lastUpdateFullName: e.lastUpdateFullName,
|
// rows.value.push({
|
||||||
isActive: e.isActive,
|
// id: e.id,
|
||||||
createdFullName: e.createdFullName,
|
// name: e.name,
|
||||||
createdUserId: e.createdUserId,
|
// createdAt: e.createdAt,
|
||||||
lastUpdateUserId: e.lastUpdateUserId,
|
// lastUpdatedAt: e.lastUpdatedAt,
|
||||||
note: e.note,
|
// lastUpdateFullName: e.lastUpdateFullName,
|
||||||
});
|
// isActive: e.isActive,
|
||||||
});
|
// createdFullName: e.createdFullName,
|
||||||
})
|
// createdUserId: e.createdUserId,
|
||||||
.catch((e) => {
|
// lastUpdateUserId: e.lastUpdateUserId,
|
||||||
messageError($q, e);
|
// note: e.note,
|
||||||
})
|
// });
|
||||||
.finally(() => {
|
// });
|
||||||
updateData.value = false;
|
// })
|
||||||
hideLoader();
|
// .catch((e) => {
|
||||||
});
|
// messageError($q, e);
|
||||||
|
// })
|
||||||
|
// .finally(() => {
|
||||||
|
// updateData.value = false;
|
||||||
|
// hideLoader();
|
||||||
|
// });
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import type { RequestItemsHistoryObject as positionEmployeeGroupResponse } from
|
||||||
import type { RequestItemsHistoryObject as positionEmployeeLineResponse } from "@/modules/01_metadata/interface/request/positionEmployee/Line";
|
import type { RequestItemsHistoryObject as positionEmployeeLineResponse } from "@/modules/01_metadata/interface/request/positionEmployee/Line";
|
||||||
import type { RequestItemsHistoryObject as positionEmployeeLevelResponse } from "@/modules/01_metadata/interface/request/positionEmployee/Level";
|
import type { RequestItemsHistoryObject as positionEmployeeLevelResponse } from "@/modules/01_metadata/interface/request/positionEmployee/Level";
|
||||||
import type { RequestItemsHistoryObject as positionEmployeeStatusResponse } from "@/modules/01_metadata/interface/request/positionEmployee/Status";
|
import type { RequestItemsHistoryObject as positionEmployeeStatusResponse } from "@/modules/01_metadata/interface/request/positionEmployee/Status";
|
||||||
|
import type { RequestItemsHistoryObject as positionPathResponse } from "@/modules/01_metadata/interface/request/position/Path";
|
||||||
|
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
const mixin = useCounterMixin();
|
const mixin = useCounterMixin();
|
||||||
|
|
@ -37,6 +38,8 @@ export const useManageDataStore = defineStore("manage", () => {
|
||||||
const draftPositionEmployeeLevel = ref<positionEmployeeLevelResponse[]>([]); //list data table
|
const draftPositionEmployeeLevel = ref<positionEmployeeLevelResponse[]>([]); //list data table
|
||||||
const dataPositionEmployeeStatus = ref<positionEmployeeStatusResponse[]>([]); //list data table
|
const dataPositionEmployeeStatus = ref<positionEmployeeStatusResponse[]>([]); //list data table
|
||||||
const draftPositionEmployeeStatus = ref<positionEmployeeStatusResponse[]>([]); //list data table
|
const draftPositionEmployeeStatus = ref<positionEmployeeStatusResponse[]>([]); //list data table
|
||||||
|
const dataPositionPath = ref<positionPathResponse[]>([]); //list data table
|
||||||
|
const draftPositionPath = ref<positionPathResponse[]>([]); //list data table
|
||||||
|
|
||||||
const storeIdVersion = ref<string>(""); //id data ใน mongodb
|
const storeIdVersion = ref<string>(""); //id data ใน mongodb
|
||||||
const storeVersion = ref<string>("published"); //รายการข้อมูลล่าสุดได้เผยแพร่หรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่
|
const storeVersion = ref<string>("published"); //รายการข้อมูลล่าสุดได้เผยแพร่หรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่
|
||||||
|
|
@ -526,6 +529,35 @@ export const useManageDataStore = defineStore("manage", () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getPositionPath = async (
|
||||||
|
selector: boolean = false,
|
||||||
|
newFetch: boolean = false
|
||||||
|
) => {
|
||||||
|
if (dataPositionPath.value.length === 0) {
|
||||||
|
await fetchPositionPath(true, selector);
|
||||||
|
return {
|
||||||
|
data: draftPositionPath.value,
|
||||||
|
version: storeVersion.value,
|
||||||
|
idversion: storeIdVersion.value,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
if (newFetch) {
|
||||||
|
await fetchPositionPath(true, selector);
|
||||||
|
return {
|
||||||
|
data: draftPositionPath.value,
|
||||||
|
version: storeVersion.value,
|
||||||
|
idversion: storeIdVersion.value,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
data: draftPositionPath.value,
|
||||||
|
version: storeVersion.value,
|
||||||
|
idversion: storeIdVersion.value,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const fetchPrefix = async (loader: boolean, selector: boolean) => {
|
const fetchPrefix = async (loader: boolean, selector: boolean) => {
|
||||||
let apiPrefix = "";
|
let apiPrefix = "";
|
||||||
if (loader) {
|
if (loader) {
|
||||||
|
|
@ -1105,6 +1137,71 @@ export const useManageDataStore = defineStore("manage", () => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const fetchPositionPath = async (loader: boolean, selector: boolean) => {
|
||||||
|
let apiPositionPath = "";
|
||||||
|
if (loader) {
|
||||||
|
showLoader();
|
||||||
|
}
|
||||||
|
if (selector) {
|
||||||
|
apiPositionPath = config.API.positionPath;
|
||||||
|
} else {
|
||||||
|
apiPositionPath = config.API.listPositionPathHistory;
|
||||||
|
}
|
||||||
|
await http
|
||||||
|
.get(apiPositionPath)
|
||||||
|
.then((res) => {
|
||||||
|
const data = res.data.result;
|
||||||
|
let rows: positionPathResponse[] = [];
|
||||||
|
if (selector) {
|
||||||
|
data.map((e: positionPathResponse) => {
|
||||||
|
rows.push({
|
||||||
|
id: e.id,
|
||||||
|
name: e.name,
|
||||||
|
createdAt: e.createdAt,
|
||||||
|
lastUpdatedAt: e.lastUpdatedAt,
|
||||||
|
lastUpdateFullName: e.lastUpdateFullName,
|
||||||
|
isActive: e.isActive,
|
||||||
|
createdFullName: e.createdFullName,
|
||||||
|
createdUserId: e.createdUserId,
|
||||||
|
lastUpdateUserId: e.lastUpdateUserId,
|
||||||
|
note: e.note,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
storeVersion.value = data.version; //ตัวแปรที่บอกว่าข้อมูลเผยแพร่ไปหรือยัง published=เผยแพร่แล้ว draft=ยังไม่เผยแพร่
|
||||||
|
storeIdVersion.value = data.id; //เลข id ใน mongodb
|
||||||
|
|
||||||
|
data.items.map((e: positionPathResponse) => {
|
||||||
|
rows.push({
|
||||||
|
id: e.id,
|
||||||
|
name: e.name,
|
||||||
|
createdAt: e.createdAt,
|
||||||
|
lastUpdatedAt: e.lastUpdatedAt,
|
||||||
|
lastUpdateFullName: e.lastUpdateFullName,
|
||||||
|
isActive: e.isActive,
|
||||||
|
createdFullName: e.createdFullName,
|
||||||
|
createdUserId: e.createdUserId,
|
||||||
|
lastUpdateUserId: e.lastUpdateUserId,
|
||||||
|
note: e.note,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
draftPositionPath.value = rows;
|
||||||
|
if (loader) {
|
||||||
|
dataPositionPath.value = rows;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
messageError($q, e);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
if (loader) {
|
||||||
|
hideLoader();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
dataPrefix,
|
dataPrefix,
|
||||||
dataInsignia,
|
dataInsignia,
|
||||||
|
|
@ -1115,6 +1212,7 @@ export const useManageDataStore = defineStore("manage", () => {
|
||||||
dataPositionEmployeeLine,
|
dataPositionEmployeeLine,
|
||||||
dataPositionEmployeeLevel,
|
dataPositionEmployeeLevel,
|
||||||
dataPositionEmployeeStatus,
|
dataPositionEmployeeStatus,
|
||||||
|
dataPositionPath,
|
||||||
storeIdVersion,
|
storeIdVersion,
|
||||||
storeVersion,
|
storeVersion,
|
||||||
manageData,
|
manageData,
|
||||||
|
|
@ -1130,5 +1228,6 @@ export const useManageDataStore = defineStore("manage", () => {
|
||||||
getPositionEmployeeLine,
|
getPositionEmployeeLine,
|
||||||
getPositionEmployeeLevel,
|
getPositionEmployeeLevel,
|
||||||
getPositionEmployeeStatus,
|
getPositionEmployeeStatus,
|
||||||
|
getPositionPath,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue