api บรรจุ
This commit is contained in:
parent
79d864bc01
commit
d400ba26ed
6 changed files with 146 additions and 152 deletions
|
|
@ -28,6 +28,7 @@ import type {
|
|||
Education,
|
||||
Family,
|
||||
Address,
|
||||
Certificate,
|
||||
} from "@/modules/05_placement/interface/index/Main";
|
||||
|
||||
import type { Information } from "@/modules/05_placement/components/PersonalDetail/profileType";
|
||||
|
|
@ -92,6 +93,7 @@ const InformationData = ref<Information>(InformationDataDefualt);
|
|||
const EducationData = ref<Education[]>([]);
|
||||
const FamilyData = ref<Family>(FamilyDataDefualt);
|
||||
const AddressData = ref<Address>(AddressDataDefualt);
|
||||
const CertificateData = ref<Certificate[]>([]);
|
||||
|
||||
onMounted(async () => {
|
||||
// await checkProfileData();
|
||||
|
|
@ -106,7 +108,7 @@ const fetchData = async () => {
|
|||
.then((res: any) => {
|
||||
const data = res.data.result;
|
||||
// data.value = data;
|
||||
console.log(data);
|
||||
// console.log(data);
|
||||
personalData.value.fullName = data.fullName;
|
||||
personalData.value.id = data.personalId;
|
||||
|
||||
|
|
@ -190,13 +192,27 @@ const fetchData = async () => {
|
|||
durationYear: row.durationYear ?? 0,
|
||||
finishDate: row.finishDate ?? new Date(),
|
||||
isDate: row.isDate ?? "",
|
||||
startDate: row.startDate ?? 0,
|
||||
endDate: row.endDate ?? 0,
|
||||
startDate: row.startDate ? new Date(row.startDate).getFullYear() : 0,
|
||||
endDate: row.endDate ? new Date(row.endDate).getFullYear() : 0,
|
||||
positionPath: row.positionPath ?? "",
|
||||
isEducation: row.isEducation ?? "",
|
||||
});
|
||||
});
|
||||
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) => {
|
||||
messageError($q, e);
|
||||
|
|
@ -252,7 +268,7 @@ const fetchData = async () => {
|
|||
<Certicate
|
||||
v-model:statusEdit="statusEdit"
|
||||
:profileType="profileType"
|
||||
v-model:data="InformationData"
|
||||
v-model:data="CertificateData"
|
||||
:fetch="fetchData"
|
||||
/>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -43,8 +43,6 @@ const props = defineProps({
|
|||
const $q = useQuasar();
|
||||
const store = useProfileDataStore();
|
||||
const { profileData, changeProfileColumns } = store;
|
||||
const dataStore = useDataStore();
|
||||
const { loaderPage } = dataStore;
|
||||
const mixin = useCounterMixin();
|
||||
const { success, dateToISO, date2Thai, messageError, showLoader, hideLoader } =
|
||||
mixin;
|
||||
|
|
@ -94,7 +92,7 @@ const filter = ref<string>(""); //search data table
|
|||
const visibleColumns = ref<String[]>([]);
|
||||
profileData.education.columns.length == 0
|
||||
? (visibleColumns.value = [
|
||||
"level",
|
||||
"educationLevel",
|
||||
"institute",
|
||||
"degree",
|
||||
"field",
|
||||
|
|
@ -112,11 +110,11 @@ profileData.education.columns.length == 0
|
|||
: (visibleColumns.value = profileData.education.columns);
|
||||
const columns = ref<QTableProps["columns"]>([
|
||||
{
|
||||
name: "level",
|
||||
name: "educationLevel",
|
||||
align: "left",
|
||||
label: "ระดับศึกษา",
|
||||
sortable: true,
|
||||
field: "level",
|
||||
field: "educationLevel",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
sort: (a: string, b: string) =>
|
||||
|
|
@ -474,7 +472,8 @@ watch(visibleColumns, async (count: String[], prevCount: String[]) => {
|
|||
onMounted(async () => {
|
||||
await fetchLevel();
|
||||
await fetchPositionPath();
|
||||
// await fetchData();
|
||||
await props.fetch();
|
||||
rows.value = props.data;
|
||||
});
|
||||
|
||||
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 row = rows.value[rowIndex.value];
|
||||
// levelId.value = row.levelId;
|
||||
// positionPathId.value = row.positionPathId;
|
||||
// institute.value = row.institute;
|
||||
// degree.value = row.degree;
|
||||
// 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;
|
||||
const row = rows.value[rowIndex.value];
|
||||
const filter = OpsFilter.value.levelOptions.filter(
|
||||
(r: any) => r.name == row.educationLevel
|
||||
);
|
||||
const filterPositionPath = OpsFilter.value.positionPathOptions.filter(
|
||||
(r: any) => r.name == row.positionPath
|
||||
);
|
||||
const result = filter.length > 0 ? filter[0].id : "";
|
||||
const resultPath =
|
||||
filterPositionPath.length > 0 ? filterPositionPath[0].id : "";
|
||||
|
||||
levelId.value = result;
|
||||
positionPathId.value = resultPath;
|
||||
institute.value = row.institute;
|
||||
degree.value = row.degree;
|
||||
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 filter = OpsFilter.value.levelOptions.filter(
|
||||
// (r: any) => r.id == levelId.value
|
||||
// );
|
||||
// const filterPositionPath = OpsFilter.value.positionPathOptions.filter(
|
||||
// (r: any) => r.id == positionPathId.value
|
||||
// );
|
||||
showLoader();
|
||||
await http
|
||||
.post(config.API.profileEduId(profileId.value), {
|
||||
.post(config.API.placementEducationId(route.params.personalId.toString()), {
|
||||
id: id.value,
|
||||
// educationLevel: filter[0].name,
|
||||
educationLevelId: levelId.value,
|
||||
|
|
@ -692,7 +656,7 @@ const saveData = async () => {
|
|||
gpa: gpa.value,
|
||||
country: country.value,
|
||||
duration: duration.value,
|
||||
durationYear: durationYear.value,
|
||||
durationYear: Number(durationYear.value),
|
||||
other: other.value,
|
||||
fundName: fundName.value,
|
||||
finishDate: dateToISO(finishDate.value),
|
||||
|
|
@ -707,7 +671,8 @@ const saveData = async () => {
|
|||
messageError($q, e);
|
||||
})
|
||||
.finally(async () => {
|
||||
await fetchData();
|
||||
await props.fetch();
|
||||
rows.value = props.data;
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -723,7 +688,7 @@ const editData = async () => {
|
|||
// );
|
||||
showLoader();
|
||||
await http
|
||||
.put(config.API.profileEduId(id.value), {
|
||||
.put(config.API.placementEducationId(route.params.personalId.toString()), {
|
||||
id: id.value,
|
||||
// educationLevel: filter[0].name,
|
||||
educationLevelId: levelId.value,
|
||||
|
|
@ -734,10 +699,10 @@ const editData = async () => {
|
|||
gpa: gpa.value,
|
||||
country: country.value,
|
||||
duration: duration.value,
|
||||
durationYear: durationYear.value,
|
||||
durationYear: Number(durationYear.value),
|
||||
other: other.value,
|
||||
fundName: fundName.value,
|
||||
finishDate: dateToISO(finishDate.value),
|
||||
finishDate: new Date(finishDate.value),
|
||||
startDate: new Date(`${startDate.value}-01-01`),
|
||||
endDate: new Date(`${endDate.value}-01-01`),
|
||||
})
|
||||
|
|
@ -749,7 +714,8 @@ const editData = async () => {
|
|||
messageError($q, e);
|
||||
})
|
||||
.finally(async () => {
|
||||
await fetchData();
|
||||
await props.fetch();
|
||||
rows.value = props.data;
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -767,7 +733,7 @@ const clickDelete = async () => {
|
|||
.onOk(async () => {
|
||||
showLoader();
|
||||
await http
|
||||
.delete(config.API.profileEduId(id.value))
|
||||
.delete(config.API.placementEducationId(id.value))
|
||||
.then((res) => {
|
||||
success($q, "ลบข้อมูลสำเร็จ");
|
||||
modal.value = false;
|
||||
|
|
@ -776,11 +742,13 @@ const clickDelete = async () => {
|
|||
messageError($q, e);
|
||||
})
|
||||
.finally(async () => {
|
||||
await fetchData();
|
||||
await props.fetch();
|
||||
rows.value = props.data;
|
||||
});
|
||||
})
|
||||
.onCancel(async () => {
|
||||
await fetchData();
|
||||
await props.fetch();
|
||||
rows.value = props.data;
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -812,13 +780,26 @@ const clickClose = async () => {
|
|||
* @param _props ค่า props ใน row ที่เลือก
|
||||
*/
|
||||
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;
|
||||
modal.value = true;
|
||||
edit.value = false;
|
||||
rawItem.value = _props.row;
|
||||
rowIndex.value = _props.rowIndex;
|
||||
levelId.value = _props.row.levelId;
|
||||
positionPathId.value = _props.row.positionPathId;
|
||||
levelId.value = result;
|
||||
positionPathId.value = resultPath;
|
||||
// levelId.value = _props.row.levelId;
|
||||
// positionPathId.value = _props.row.positionPathId;
|
||||
institute.value = _props.row.institute;
|
||||
degree.value = _props.row.degree;
|
||||
field.value = _props.row.field;
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ import HistoryTable from "@/components/TableHistory.vue";
|
|||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
import type { QTableProps } from "quasar";
|
||||
import type { PropType } from "vue";
|
||||
import type { Certificate } from "@/modules/05_placement/interface/index/Main";
|
||||
|
||||
const props = defineProps({
|
||||
statusEdit: {
|
||||
|
|
@ -32,13 +34,16 @@ const props = defineProps({
|
|||
type: Function,
|
||||
default: () => console.log("not function"),
|
||||
},
|
||||
data: {
|
||||
type: Array as PropType<Certificate[]>,
|
||||
default: [],
|
||||
},
|
||||
});
|
||||
|
||||
const $q = useQuasar();
|
||||
const store = useProfileDataStore();
|
||||
const { profileData, changeProfileColumns } = store;
|
||||
const dataStore = useDataStore();
|
||||
const { loaderPage } = dataStore;
|
||||
|
||||
const mixin = useCounterMixin();
|
||||
const { date2Thai, success, dateToISO, messageError, showLoader, hideLoader } =
|
||||
mixin;
|
||||
|
|
@ -68,7 +73,7 @@ const checkValidate = ref<boolean>(false); //validate data ผ่านหรื
|
|||
// route.params.id ? route.params.id.toString() : ""
|
||||
// );
|
||||
const profileId = ref<string>("");
|
||||
const rows = ref<RequestItemsObject[]>([]);
|
||||
const rows = ref<Certificate[]>([]);
|
||||
const filter = ref<string>(""); //search data table
|
||||
const visibleColumns = ref<String[]>([]);
|
||||
profileData.certicate.columns.length == 0
|
||||
|
|
@ -233,40 +238,12 @@ watch(visibleColumns, async (count: String[], prevCount: String[]) => {
|
|||
onMounted(async () => {
|
||||
// await fetchData();
|
||||
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 () => {
|
||||
if (profileId.value !== "") {
|
||||
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();
|
||||
});
|
||||
}
|
||||
};
|
||||
// console.log("saveData");
|
||||
|
||||
/**
|
||||
* บันทึกแก้ไขข้อมูล
|
||||
*/
|
||||
const editData = async () => {
|
||||
showLoader();
|
||||
await http
|
||||
.put(config.API.profileCertId(id.value), {
|
||||
.post(config.API.placementCertId(route.params.personalId.toString()), {
|
||||
id: id.value,
|
||||
certificateNo: certificateNo.value,
|
||||
issuer: issuer.value,
|
||||
issueDate: dateToISO(issueDate.value),
|
||||
expireDate: dateToISO(expireDate.value),
|
||||
issueDate: new Date(issueDate.value),
|
||||
expireDate: new Date(expireDate.value),
|
||||
certificateType: certificateType.value,
|
||||
})
|
||||
.then((res) => {
|
||||
|
|
@ -397,7 +348,35 @@ const editData = async () => {
|
|||
messageError($q, e);
|
||||
})
|
||||
.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 () => {
|
||||
showLoader();
|
||||
await http
|
||||
.delete(config.API.profileCertId(id.value))
|
||||
.delete(
|
||||
config.API.placementCertDetailId(
|
||||
route.params.personalId.toString(),
|
||||
id.value
|
||||
)
|
||||
)
|
||||
.then((res) => {
|
||||
success($q, "ลบข้อมูลสำเร็จ");
|
||||
modal.value = false;
|
||||
|
|
@ -424,11 +408,13 @@ const clickDelete = async () => {
|
|||
messageError($q, e);
|
||||
})
|
||||
.finally(async () => {
|
||||
await fetchData();
|
||||
await props.fetch();
|
||||
rows.value = props.data;
|
||||
});
|
||||
})
|
||||
.onCancel(async () => {
|
||||
await fetchData();
|
||||
await props.fetch();
|
||||
rows.value = props.data;
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ const fetchPerson = async () => {
|
|||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
let optionbloodGroups: optionData[] = [];
|
||||
console.log(data);
|
||||
// console.log(data);
|
||||
data.bloodGroups.map((r: any) => {
|
||||
optionbloodGroups.push({
|
||||
id: r.id ?? "",
|
||||
|
|
|
|||
|
|
@ -140,6 +140,15 @@ interface Address {
|
|||
registSame: string;
|
||||
}
|
||||
|
||||
interface Certificate {
|
||||
id: string;
|
||||
certificateNo: string;
|
||||
issuer: string;
|
||||
issueDate: Date;
|
||||
expireDate: Date;
|
||||
certificateType: string;
|
||||
}
|
||||
|
||||
const AddressDataDefualt: Address = {
|
||||
registAddress: "",
|
||||
currentAddress: "",
|
||||
|
|
@ -195,6 +204,7 @@ export type {
|
|||
Family,
|
||||
Address,
|
||||
optionData,
|
||||
Certificate,
|
||||
};
|
||||
|
||||
export { AddressDataDefualt, FamilyDataDefualt };
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ interface DataProps {
|
|||
//ข้อมูล
|
||||
interface RequestItemsObject {
|
||||
id: string;
|
||||
educationLevel: string;
|
||||
level: string;
|
||||
levelId: string;
|
||||
positionPath: string;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue