api บรรจุ

This commit is contained in:
Thanit Konmek 2023-07-14 01:00:24 +07:00
parent 79d864bc01
commit d400ba26ed
6 changed files with 146 additions and 152 deletions

View file

@ -28,6 +28,7 @@ import type {
Education, Education,
Family, Family,
Address, Address,
Certificate,
} from "@/modules/05_placement/interface/index/Main"; } from "@/modules/05_placement/interface/index/Main";
import type { Information } from "@/modules/05_placement/components/PersonalDetail/profileType"; import type { Information } from "@/modules/05_placement/components/PersonalDetail/profileType";
@ -92,6 +93,7 @@ const InformationData = ref<Information>(InformationDataDefualt);
const EducationData = ref<Education[]>([]); const EducationData = ref<Education[]>([]);
const FamilyData = ref<Family>(FamilyDataDefualt); const FamilyData = ref<Family>(FamilyDataDefualt);
const AddressData = ref<Address>(AddressDataDefualt); const AddressData = ref<Address>(AddressDataDefualt);
const CertificateData = ref<Certificate[]>([]);
onMounted(async () => { onMounted(async () => {
// await checkProfileData(); // await checkProfileData();
@ -106,7 +108,7 @@ const fetchData = async () => {
.then((res: any) => { .then((res: any) => {
const data = res.data.result; const data = res.data.result;
// data.value = data; // data.value = data;
console.log(data); // console.log(data);
personalData.value.fullName = data.fullName; personalData.value.fullName = data.fullName;
personalData.value.id = data.personalId; personalData.value.id = data.personalId;
@ -190,13 +192,27 @@ const fetchData = async () => {
durationYear: row.durationYear ?? 0, durationYear: row.durationYear ?? 0,
finishDate: row.finishDate ?? new Date(), finishDate: row.finishDate ?? new Date(),
isDate: row.isDate ?? "", isDate: row.isDate ?? "",
startDate: row.startDate ?? 0, startDate: row.startDate ? new Date(row.startDate).getFullYear() : 0,
endDate: row.endDate ?? 0, endDate: row.endDate ? new Date(row.endDate).getFullYear() : 0,
positionPath: row.positionPath ?? "", positionPath: row.positionPath ?? "",
isEducation: row.isEducation ?? "", isEducation: row.isEducation ?? "",
}); });
}); });
EducationData.value = listRow; EducationData.value = listRow;
let listCert: Certificate[] = [];
data.certificates.map((row: any) => {
listCert.push({
id: row.id ?? "",
certificateNo: row.certificateNo ?? "",
issuer: row.issuer ?? "",
issueDate: new Date(row.issueDate) ?? new Date(),
expireDate: new Date(row.expireDate) ?? new Date(),
certificateType: row.certificateType ?? "",
});
});
CertificateData.value = listCert;
}) })
.catch((e: any) => { .catch((e: any) => {
messageError($q, e); messageError($q, e);
@ -252,7 +268,7 @@ const fetchData = async () => {
<Certicate <Certicate
v-model:statusEdit="statusEdit" v-model:statusEdit="statusEdit"
:profileType="profileType" :profileType="profileType"
v-model:data="InformationData" v-model:data="CertificateData"
:fetch="fetchData" :fetch="fetchData"
/> />
</div> </div>

View file

@ -43,8 +43,6 @@ const props = defineProps({
const $q = useQuasar(); const $q = useQuasar();
const store = useProfileDataStore(); const store = useProfileDataStore();
const { profileData, changeProfileColumns } = store; const { profileData, changeProfileColumns } = store;
const dataStore = useDataStore();
const { loaderPage } = dataStore;
const mixin = useCounterMixin(); const mixin = useCounterMixin();
const { success, dateToISO, date2Thai, messageError, showLoader, hideLoader } = const { success, dateToISO, date2Thai, messageError, showLoader, hideLoader } =
mixin; mixin;
@ -94,7 +92,7 @@ const filter = ref<string>(""); //search data table
const visibleColumns = ref<String[]>([]); const visibleColumns = ref<String[]>([]);
profileData.education.columns.length == 0 profileData.education.columns.length == 0
? (visibleColumns.value = [ ? (visibleColumns.value = [
"level", "educationLevel",
"institute", "institute",
"degree", "degree",
"field", "field",
@ -112,11 +110,11 @@ profileData.education.columns.length == 0
: (visibleColumns.value = profileData.education.columns); : (visibleColumns.value = profileData.education.columns);
const columns = ref<QTableProps["columns"]>([ const columns = ref<QTableProps["columns"]>([
{ {
name: "level", name: "educationLevel",
align: "left", align: "left",
label: "ระดับศึกษา", label: "ระดับศึกษา",
sortable: true, sortable: true,
field: "level", field: "educationLevel",
headerStyle: "font-size: 14px", headerStyle: "font-size: 14px",
style: "font-size: 14px", style: "font-size: 14px",
sort: (a: string, b: string) => sort: (a: string, b: string) =>
@ -474,7 +472,8 @@ watch(visibleColumns, async (count: String[], prevCount: String[]) => {
onMounted(async () => { onMounted(async () => {
await fetchLevel(); await fetchLevel();
await fetchPositionPath(); await fetchPositionPath();
// await fetchData(); await props.fetch();
rows.value = props.data;
}); });
const fetchLevel = async () => { const fetchLevel = async () => {
@ -541,45 +540,6 @@ const filterSelector = (val: any, update: Function, refData: string) => {
} }
}; };
const fetchData = async () => {
showLoader();
await http
.get(config.API.profileEduId(profileId.value))
.then((res) => {
let data = res.data.result;
rows.value = [];
data.map((e: ResponseObject) => {
// rows.value.push({
// id: e.id,
// level: e.educationLevel,
// levelId: e.educationLevelId,
// positionPath: e.positionPath,
// positionPathId: e.positionPathId,
// institute: e.institute,
// degree: e.degree,
// field: e.field,
// gpa: e.gpa,
// country: e.country,
// duration: e.duration,
// durationYear: e.durationYear,
// other: e.other,
// fundName: e.fundName,
// finishDate: new Date(e.finishDate),
// startDate: new Date(e.startDate).getFullYear(),
// endDate: new Date(e.endDate).getFullYear(),
// createdFullName: e.createdFullName,
// createdAt: new Date(e.createdAt),
// });
});
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
};
/** /**
* กดดอมลกอนหน * กดดอมลกอนหน
*/ */
@ -604,22 +564,32 @@ const clickNext = async () => {
* กดดอมลตอไป * กดดอมลตอไป
*/ */
const getData = () => { const getData = () => {
// const row = rows.value[rowIndex.value]; const row = rows.value[rowIndex.value];
// levelId.value = row.levelId; const filter = OpsFilter.value.levelOptions.filter(
// positionPathId.value = row.positionPathId; (r: any) => r.name == row.educationLevel
// institute.value = row.institute; );
// degree.value = row.degree; const filterPositionPath = OpsFilter.value.positionPathOptions.filter(
// field.value = row.field; (r: any) => r.name == row.positionPath
// gpa.value = row.gpa; );
// country.value = row.country; const result = filter.length > 0 ? filter[0].id : "";
// duration.value = row.duration; const resultPath =
// durationYear.value = row.durationYear; filterPositionPath.length > 0 ? filterPositionPath[0].id : "";
// other.value = row.other;
// fundName.value = row.fundName; levelId.value = result;
// finishDate.value = row.finishDate; positionPathId.value = resultPath;
// startDate.value = row.startDate; institute.value = row.institute;
// endDate.value = row.endDate; degree.value = row.degree;
// id.value = row.id; field.value = row.field;
gpa.value = row.gpa;
country.value = row.country;
duration.value = row.duration;
durationYear.value = row.durationYear;
other.value = row.other;
fundName.value = row.fundName;
finishDate.value = row.finishDate;
startDate.value = row.startDate;
endDate.value = row.endDate;
id.value = row.id;
}; };
/** /**
@ -673,15 +643,9 @@ const clickSave = async () => {
* นทกเพมขอม * นทกเพมขอม
*/ */
const saveData = async () => { const saveData = async () => {
// const filter = OpsFilter.value.levelOptions.filter(
// (r: any) => r.id == levelId.value
// );
// const filterPositionPath = OpsFilter.value.positionPathOptions.filter(
// (r: any) => r.id == positionPathId.value
// );
showLoader(); showLoader();
await http await http
.post(config.API.profileEduId(profileId.value), { .post(config.API.placementEducationId(route.params.personalId.toString()), {
id: id.value, id: id.value,
// educationLevel: filter[0].name, // educationLevel: filter[0].name,
educationLevelId: levelId.value, educationLevelId: levelId.value,
@ -692,7 +656,7 @@ const saveData = async () => {
gpa: gpa.value, gpa: gpa.value,
country: country.value, country: country.value,
duration: duration.value, duration: duration.value,
durationYear: durationYear.value, durationYear: Number(durationYear.value),
other: other.value, other: other.value,
fundName: fundName.value, fundName: fundName.value,
finishDate: dateToISO(finishDate.value), finishDate: dateToISO(finishDate.value),
@ -707,7 +671,8 @@ const saveData = async () => {
messageError($q, e); messageError($q, e);
}) })
.finally(async () => { .finally(async () => {
await fetchData(); await props.fetch();
rows.value = props.data;
}); });
}; };
@ -723,7 +688,7 @@ const editData = async () => {
// ); // );
showLoader(); showLoader();
await http await http
.put(config.API.profileEduId(id.value), { .put(config.API.placementEducationId(route.params.personalId.toString()), {
id: id.value, id: id.value,
// educationLevel: filter[0].name, // educationLevel: filter[0].name,
educationLevelId: levelId.value, educationLevelId: levelId.value,
@ -734,10 +699,10 @@ const editData = async () => {
gpa: gpa.value, gpa: gpa.value,
country: country.value, country: country.value,
duration: duration.value, duration: duration.value,
durationYear: durationYear.value, durationYear: Number(durationYear.value),
other: other.value, other: other.value,
fundName: fundName.value, fundName: fundName.value,
finishDate: dateToISO(finishDate.value), finishDate: new Date(finishDate.value),
startDate: new Date(`${startDate.value}-01-01`), startDate: new Date(`${startDate.value}-01-01`),
endDate: new Date(`${endDate.value}-01-01`), endDate: new Date(`${endDate.value}-01-01`),
}) })
@ -749,7 +714,8 @@ const editData = async () => {
messageError($q, e); messageError($q, e);
}) })
.finally(async () => { .finally(async () => {
await fetchData(); await props.fetch();
rows.value = props.data;
}); });
}; };
@ -767,7 +733,7 @@ const clickDelete = async () => {
.onOk(async () => { .onOk(async () => {
showLoader(); showLoader();
await http await http
.delete(config.API.profileEduId(id.value)) .delete(config.API.placementEducationId(id.value))
.then((res) => { .then((res) => {
success($q, "ลบข้อมูลสำเร็จ"); success($q, "ลบข้อมูลสำเร็จ");
modal.value = false; modal.value = false;
@ -776,11 +742,13 @@ const clickDelete = async () => {
messageError($q, e); messageError($q, e);
}) })
.finally(async () => { .finally(async () => {
await fetchData(); await props.fetch();
rows.value = props.data;
}); });
}) })
.onCancel(async () => { .onCancel(async () => {
await fetchData(); await props.fetch();
rows.value = props.data;
}); });
}; };
@ -812,13 +780,26 @@ const clickClose = async () => {
* @param _props props ใน row เลอก * @param _props props ใน row เลอก
*/ */
const selectData = async (_props: DataProps) => { const selectData = async (_props: DataProps) => {
const filter = OpsFilter.value.levelOptions.filter(
(r: any) => r.name == _props.row.educationLevel
);
const filterPositionPath = OpsFilter.value.positionPathOptions.filter(
(r: any) => r.name == _props.row.positionPath
);
const result = filter.length > 0 ? filter[0].id : "";
const resultPath =
filterPositionPath.length > 0 ? filterPositionPath[0].id : "";
// console.log(_props.row);
modalEdit.value = true; modalEdit.value = true;
modal.value = true; modal.value = true;
edit.value = false; edit.value = false;
rawItem.value = _props.row; rawItem.value = _props.row;
rowIndex.value = _props.rowIndex; rowIndex.value = _props.rowIndex;
levelId.value = _props.row.levelId; levelId.value = result;
positionPathId.value = _props.row.positionPathId; positionPathId.value = resultPath;
// levelId.value = _props.row.levelId;
// positionPathId.value = _props.row.positionPathId;
institute.value = _props.row.institute; institute.value = _props.row.institute;
degree.value = _props.row.degree; degree.value = _props.row.degree;
field.value = _props.row.field; field.value = _props.row.field;

View file

@ -18,6 +18,8 @@ import HistoryTable from "@/components/TableHistory.vue";
import http from "@/plugins/http"; import http from "@/plugins/http";
import config from "@/app.config"; import config from "@/app.config";
import type { QTableProps } from "quasar"; import type { QTableProps } from "quasar";
import type { PropType } from "vue";
import type { Certificate } from "@/modules/05_placement/interface/index/Main";
const props = defineProps({ const props = defineProps({
statusEdit: { statusEdit: {
@ -32,13 +34,16 @@ const props = defineProps({
type: Function, type: Function,
default: () => console.log("not function"), default: () => console.log("not function"),
}, },
data: {
type: Array as PropType<Certificate[]>,
default: [],
},
}); });
const $q = useQuasar(); const $q = useQuasar();
const store = useProfileDataStore(); const store = useProfileDataStore();
const { profileData, changeProfileColumns } = store; const { profileData, changeProfileColumns } = store;
const dataStore = useDataStore();
const { loaderPage } = dataStore;
const mixin = useCounterMixin(); const mixin = useCounterMixin();
const { date2Thai, success, dateToISO, messageError, showLoader, hideLoader } = const { date2Thai, success, dateToISO, messageError, showLoader, hideLoader } =
mixin; mixin;
@ -68,7 +73,7 @@ const checkValidate = ref<boolean>(false); //validate data ผ่านหรื
// route.params.id ? route.params.id.toString() : "" // route.params.id ? route.params.id.toString() : ""
// ); // );
const profileId = ref<string>(""); const profileId = ref<string>("");
const rows = ref<RequestItemsObject[]>([]); const rows = ref<Certificate[]>([]);
const filter = ref<string>(""); //search data table const filter = ref<string>(""); //search data table
const visibleColumns = ref<String[]>([]); const visibleColumns = ref<String[]>([]);
profileData.certicate.columns.length == 0 profileData.certicate.columns.length == 0
@ -233,40 +238,12 @@ watch(visibleColumns, async (count: String[], prevCount: String[]) => {
onMounted(async () => { onMounted(async () => {
// await fetchData(); // await fetchData();
if (route.params.id) { if (route.params.id) {
profileId.value = route.params.id.toString(); profileId.value = route.params.personalId.toString();
} }
await props.fetch();
rows.value = props.data;
}); });
const fetchData = async () => {
if (profileId.value != "") {
showLoader();
await http
.get(config.API.profileCertId(profileId.value))
.then((res) => {
let data = res.data.result;
rows.value = [];
data.map((e: ResponseObject) => {
rows.value.push({
id: e.id,
certificateNo: e.certificateNo,
issuer: e.issuer,
issueDate: new Date(e.issueDate),
expireDate: new Date(e.expireDate),
certificateType: e.certificateType,
createdFullName: e.createdFullName,
createdAt: new Date(e.createdAt),
});
});
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
};
/** /**
* กดดอมลกอนหน * กดดอมลกอนหน
*/ */
@ -351,42 +328,16 @@ const clickSave = async () => {
* นทกเพมขอม * นทกเพมขอม
*/ */
const saveData = async () => { const saveData = async () => {
if (profileId.value !== "") { // console.log("saveData");
showLoader();
await http
.post(config.API.profileCertId(profileId.value), {
id: id.value,
certificateNo: certificateNo.value,
issuer: issuer.value,
issueDate: dateToISO(issueDate.value),
expireDate: dateToISO(expireDate.value),
certificateType: certificateType.value,
})
.then((res) => {
success($q, "บันทึกข้อมูลสำเร็จ");
modal.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData();
});
}
};
/**
* นทกแกไขขอม
*/
const editData = async () => {
showLoader(); showLoader();
await http await http
.put(config.API.profileCertId(id.value), { .post(config.API.placementCertId(route.params.personalId.toString()), {
id: id.value, id: id.value,
certificateNo: certificateNo.value, certificateNo: certificateNo.value,
issuer: issuer.value, issuer: issuer.value,
issueDate: dateToISO(issueDate.value), issueDate: new Date(issueDate.value),
expireDate: dateToISO(expireDate.value), expireDate: new Date(expireDate.value),
certificateType: certificateType.value, certificateType: certificateType.value,
}) })
.then((res) => { .then((res) => {
@ -397,7 +348,35 @@ const editData = async () => {
messageError($q, e); messageError($q, e);
}) })
.finally(async () => { .finally(async () => {
await fetchData(); await props.fetch();
rows.value = props.data;
});
};
/**
* นทกแกไขขอม
*/
const editData = async () => {
showLoader();
await http
.put(config.API.placementCertId(route.params.personalId.toString()), {
id: id.value,
certificateNo: certificateNo.value,
issuer: issuer.value,
issueDate: new Date(issueDate.value),
expireDate: new Date(expireDate.value),
certificateType: certificateType.value,
})
.then((res) => {
success($q, "บันทึกข้อมูลสำเร็จ");
modal.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await props.fetch();
rows.value = props.data;
}); });
}; };
@ -415,7 +394,12 @@ const clickDelete = async () => {
.onOk(async () => { .onOk(async () => {
showLoader(); showLoader();
await http await http
.delete(config.API.profileCertId(id.value)) .delete(
config.API.placementCertDetailId(
route.params.personalId.toString(),
id.value
)
)
.then((res) => { .then((res) => {
success($q, "ลบข้อมูลสำเร็จ"); success($q, "ลบข้อมูลสำเร็จ");
modal.value = false; modal.value = false;
@ -424,11 +408,13 @@ const clickDelete = async () => {
messageError($q, e); messageError($q, e);
}) })
.finally(async () => { .finally(async () => {
await fetchData(); await props.fetch();
rows.value = props.data;
}); });
}) })
.onCancel(async () => { .onCancel(async () => {
await fetchData(); await props.fetch();
rows.value = props.data;
}); });
}; };

View file

@ -115,7 +115,7 @@ const fetchPerson = async () => {
.then((res) => { .then((res) => {
const data = res.data.result; const data = res.data.result;
let optionbloodGroups: optionData[] = []; let optionbloodGroups: optionData[] = [];
console.log(data); // console.log(data);
data.bloodGroups.map((r: any) => { data.bloodGroups.map((r: any) => {
optionbloodGroups.push({ optionbloodGroups.push({
id: r.id ?? "", id: r.id ?? "",

View file

@ -140,6 +140,15 @@ interface Address {
registSame: string; registSame: string;
} }
interface Certificate {
id: string;
certificateNo: string;
issuer: string;
issueDate: Date;
expireDate: Date;
certificateType: string;
}
const AddressDataDefualt: Address = { const AddressDataDefualt: Address = {
registAddress: "", registAddress: "",
currentAddress: "", currentAddress: "",
@ -195,6 +204,7 @@ export type {
Family, Family,
Address, Address,
optionData, optionData,
Certificate,
}; };
export { AddressDataDefualt, FamilyDataDefualt }; export { AddressDataDefualt, FamilyDataDefualt };

View file

@ -6,6 +6,7 @@ interface DataProps {
//ข้อมูล //ข้อมูล
interface RequestItemsObject { interface RequestItemsObject {
id: string; id: string;
educationLevel: string;
level: string; level: string;
levelId: string; levelId: string;
positionPath: string; positionPath: string;