fix กรณีไม่มีประวัติโครงสร้างเลย

This commit is contained in:
Warunee Tamkoo 2025-09-26 23:40:00 +07:00
parent c8d061e43a
commit ce0906314f
2 changed files with 11 additions and 9 deletions

View file

@ -24,7 +24,7 @@ export const useOrganizational = defineStore("organizationalStore", () => {
const activeId = ref<string>(); // id โครงสร้างปัจจุบัน
const draftId = ref<string>(); // id แบบร่างโครงสร้าง
const historyId = ref<string>(); // id ประวัติโครงสร้าง
const historyDnaOrgId = ref<string>(); // id ของโครงสร้างสำหรับใช้ในเมนูสืบทอดตำแหน่ง
const historyDnaOrgId = ref<string>(""); // id ของโครงสร้างสำหรับใช้ในเมนูสืบทอดตำแหน่ง
const isPublic = ref<boolean>(false); // การเผยแพร่
const treeId = ref<string>(); // id โหนด
const level = ref<number>(); // ระดับโหนด

View file

@ -94,16 +94,18 @@ async function fetchHistory() {
(e: OrgRevision) => !e.orgRevisionIsDraft && !e.orgRevisionIsCurrent
);
itemHistory.value = filterData.map((e: OrgRevision) => ({
id: e.orgRevisionId,
name: e.orgRevisionName,
orgRevisionCreatedAt: e.orgRevisionCreatedAt
? date2Thai(e.orgRevisionCreatedAt)
: "",
}));
itemHistory.value =
filterData.map((e: OrgRevision) => ({
id: e.orgRevisionId,
name: e.orgRevisionName,
orgRevisionCreatedAt: e.orgRevisionCreatedAt
? date2Thai(e.orgRevisionCreatedAt)
: "",
})) || [];
// id
store.historyDnaOrgId = itemHistory.value[0].id;
store.historyDnaOrgId =
itemHistory.value.length > 0 ? itemHistory.value[0].id : "";
})
.catch((err) => {
messageError($q, err);