2023-12-19 10:56:51 +07:00
|
|
|
import http from "@/plugins/http";
|
|
|
|
|
import config from "@/app.config";
|
|
|
|
|
import { useQuasar } from "quasar";
|
|
|
|
|
|
|
|
|
|
import { useCounterMixin } from "@/stores/mixin";
|
|
|
|
|
import { useEvaluateStore } from "@/modules/06_evaluate/store";
|
|
|
|
|
|
2023-12-19 17:04:39 +07:00
|
|
|
const store = useEvaluateStore();
|
2023-12-19 10:56:51 +07:00
|
|
|
const mixin = useCounterMixin();
|
|
|
|
|
const $q = useQuasar();
|
|
|
|
|
|
|
|
|
|
const { showLoader, hideLoader, messageError } = mixin;
|
|
|
|
|
|
2023-12-19 17:04:39 +07:00
|
|
|
/** function เช็คการยื่นข้อประเมิน*/
|
2023-12-19 10:56:51 +07:00
|
|
|
async function fetchCheckStatus() {
|
2023-12-19 17:04:39 +07:00
|
|
|
store.showLoadStatus = false;
|
2023-12-21 17:51:13 +07:00
|
|
|
// = 1;
|
2023-12-19 10:56:51 +07:00
|
|
|
showLoader();
|
|
|
|
|
await http
|
|
|
|
|
.get(config.API.evaluationCheckStatus())
|
|
|
|
|
.then((res) => {
|
2023-12-19 17:04:39 +07:00
|
|
|
const data = res.data.result;
|
|
|
|
|
store.tabMenu === "1"
|
|
|
|
|
? (store.evaluateId = data.expertId)
|
|
|
|
|
: (store.evaluateId = data.specialExpertId);
|
2023-12-20 14:23:27 +07:00
|
|
|
fetchCheckStep(store?.evaluateId);
|
2023-12-19 10:56:51 +07:00
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
messageError($q, err);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
hideLoader();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-20 14:23:27 +07:00
|
|
|
async function fetchCheckStep(id: string) {
|
|
|
|
|
if (id) {
|
|
|
|
|
await http
|
|
|
|
|
.get(config.API.evaluationCheckStep(id))
|
|
|
|
|
.then((res) => {
|
|
|
|
|
const data = res.data.result;
|
2023-12-19 17:04:39 +07:00
|
|
|
|
2023-12-20 14:23:27 +07:00
|
|
|
let step =
|
2023-12-21 17:51:13 +07:00
|
|
|
data.step === "CHECK_SPEC"
|
2023-12-20 14:23:27 +07:00
|
|
|
? 1
|
2023-12-21 17:51:13 +07:00
|
|
|
: data.step === "PREPARE_DOC_V1"
|
2023-12-20 14:23:27 +07:00
|
|
|
? 2
|
2023-12-21 17:51:13 +07:00
|
|
|
: data.step === "CHECK_DOC_V1"
|
2023-12-20 14:23:27 +07:00
|
|
|
? 3
|
2023-12-21 17:51:13 +07:00
|
|
|
: data.step === "WAIT_CHECK_DOC_V1"
|
2023-12-20 14:23:27 +07:00
|
|
|
? 4
|
2023-12-21 17:51:13 +07:00
|
|
|
: data.step === "ANNOUNCE_WEB"
|
2023-12-20 14:23:27 +07:00
|
|
|
? 5
|
2023-12-21 17:51:13 +07:00
|
|
|
: data.step === "PREPARE_DOC_V2"
|
2023-12-20 14:23:27 +07:00
|
|
|
? 6
|
2023-12-21 17:51:13 +07:00
|
|
|
: data.step === "CHECK_DOC_V2"
|
2023-12-20 14:23:27 +07:00
|
|
|
? 7
|
2023-12-21 17:51:13 +07:00
|
|
|
: data.step === "WAIT_CHECK_DOC_V2"
|
2023-12-20 14:23:27 +07:00
|
|
|
? 8
|
2023-12-21 17:51:13 +07:00
|
|
|
: data.step === "DONE"
|
2023-12-20 14:23:27 +07:00
|
|
|
? 9
|
|
|
|
|
: 1;
|
2023-12-21 17:51:13 +07:00
|
|
|
|
2023-12-22 16:29:12 +07:00
|
|
|
store.currentStep = step;
|
|
|
|
|
store.step = step;
|
2023-12-20 14:23:27 +07:00
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
messageError($q, err);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
store.showLoadStatus = true;
|
|
|
|
|
});
|
2023-12-21 17:51:13 +07:00
|
|
|
} else
|
|
|
|
|
((store.step = 1), (store.currentStep = 1)), (store.showLoadStatus = true);
|
2023-12-19 17:04:39 +07:00
|
|
|
}
|
|
|
|
|
|
2023-12-21 17:51:13 +07:00
|
|
|
async function saveEvaluation(formSpec: any, detail: any) {
|
2023-12-22 16:00:05 +07:00
|
|
|
const salaries = detail.trainings.map((e: any) => ({
|
|
|
|
|
amount: e.amount,
|
|
|
|
|
date: e.date,
|
|
|
|
|
mouthSalaryAmount: e.mouthSalaryAmount ? e.mouthSalaryAmount : 0,
|
|
|
|
|
posNo: e.posNo,
|
|
|
|
|
position: e.position,
|
|
|
|
|
positionSalaryAmount: e.positionSalaryAmount ? e.positionSalaryAmount : 0,
|
|
|
|
|
refCommandDate: e.refCommandDate,
|
|
|
|
|
refCommandNo: e.refCommandNo ? e.refCommandNo : "",
|
|
|
|
|
salaryClass: e.salaryClass ? e.salaryClass : "",
|
|
|
|
|
salaryRef: e.salaryRef ? e.salaryRef : "",
|
|
|
|
|
salaryStatus: e.salaryStatus ? e.salariesStatus : "",
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
const educations = detail.educations.map((e: any) => ({
|
|
|
|
|
country: e.country,
|
|
|
|
|
degree: e.degree,
|
|
|
|
|
duration: e.duration,
|
|
|
|
|
durationYear: e.durationYear.toString(),
|
|
|
|
|
educationLevel: e.educationLevel,
|
|
|
|
|
endDate: e.endDate,
|
|
|
|
|
field: e.field,
|
|
|
|
|
finishDate: e.finishDate,
|
|
|
|
|
fundName: e.fundName,
|
|
|
|
|
gpa: e.gpa,
|
|
|
|
|
institute: e.institute,
|
|
|
|
|
isDate: e.isDate,
|
|
|
|
|
isEducation: e.isEducation,
|
|
|
|
|
other: e.other,
|
|
|
|
|
startDate: e.startDate,
|
|
|
|
|
}));
|
|
|
|
|
|
2023-12-21 17:51:13 +07:00
|
|
|
const form = {
|
|
|
|
|
userId: detail.id,
|
|
|
|
|
citizenId: detail.citizenId,
|
|
|
|
|
prefix: detail.prefix,
|
|
|
|
|
fullName: `${detail.firstName} ${detail.lastName}.`,
|
|
|
|
|
position: detail.position,
|
|
|
|
|
oc: detail.oc,
|
|
|
|
|
salary: detail.salary.toString(),
|
|
|
|
|
positionLevel: detail.positionLevel,
|
|
|
|
|
posNo: detail.posNo,
|
|
|
|
|
birthDate: detail.birthDate,
|
|
|
|
|
govAge: detail.govAge,
|
2023-12-22 17:03:21 +07:00
|
|
|
type: store.tabMenu === "1" ? "EXPERT" : "SPECIAL_EXPERT",
|
|
|
|
|
step: "PREPARE_DOC_V1",
|
2023-12-21 17:51:13 +07:00
|
|
|
isEducationalQft: formSpec.isEducationalQft,
|
|
|
|
|
isGovermantServiceHtr: formSpec.isGovermantServiceHtr,
|
|
|
|
|
isOperatingExp: formSpec.isOperatingExp,
|
|
|
|
|
isMinPeriodOfTenure: formSpec.isMinPeriodOfTenure,
|
|
|
|
|
isHaveSpecificQft: formSpec.isHaveSpecificQft,
|
|
|
|
|
isHaveProLicense: formSpec.isHaveProLicense,
|
|
|
|
|
isHaveMinPeriodOrHoldPos: formSpec.isHaveMinPeriodOrHoldPos,
|
|
|
|
|
reason: "",
|
2023-12-22 16:00:05 +07:00
|
|
|
educations: [...educations],
|
2023-12-21 17:51:13 +07:00
|
|
|
certificates: [...detail.certificates],
|
2023-12-22 16:00:05 +07:00
|
|
|
salaries: [...salaries],
|
2023-12-21 17:51:13 +07:00
|
|
|
trainings: [...detail.trainings],
|
|
|
|
|
assessments: [...detail.assessments],
|
2023-12-20 15:16:49 +07:00
|
|
|
};
|
|
|
|
|
|
2023-12-19 17:04:39 +07:00
|
|
|
showLoader();
|
|
|
|
|
await http
|
2023-12-21 17:51:13 +07:00
|
|
|
.post(config.API.evaluationCheckspec(), form)
|
2023-12-19 17:04:39 +07:00
|
|
|
.then((res) => {
|
2023-12-23 11:43:02 +07:00
|
|
|
fetchCheckStatus();
|
2023-12-19 17:04:39 +07:00
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
messageError($q, err);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
2023-12-20 14:23:27 +07:00
|
|
|
fetchCheckStep(store?.evaluateId);
|
2023-12-23 11:43:02 +07:00
|
|
|
hideLoader();
|
2023-12-19 17:04:39 +07:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function nextPrapare(type: string, body: any) {
|
|
|
|
|
showLoader();
|
|
|
|
|
await http
|
|
|
|
|
.put(config.API.evaluationPreparedoc(store.evaluateId, type), body)
|
|
|
|
|
.then((res) => {
|
|
|
|
|
console.log(res);
|
|
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
messageError($q, err);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
hideLoader();
|
2023-12-22 17:03:21 +07:00
|
|
|
fetchCheckStatus();
|
2023-12-19 17:04:39 +07:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function nextCheckDoc(type: string) {
|
|
|
|
|
showLoader();
|
|
|
|
|
await http
|
|
|
|
|
.put(config.API.evaluationCheckdoc(store.evaluateId, type))
|
|
|
|
|
.then((res) => {
|
|
|
|
|
console.log(res);
|
|
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
messageError($q, err);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
hideLoader();
|
2023-12-20 14:23:27 +07:00
|
|
|
fetchCheckStep(store?.evaluateId);
|
2023-12-19 17:04:39 +07:00
|
|
|
});
|
|
|
|
|
}
|
2023-12-19 10:56:51 +07:00
|
|
|
|
2023-12-22 16:00:05 +07:00
|
|
|
async function nextCheckDoc2(data: any) {
|
|
|
|
|
const body = {
|
|
|
|
|
commanderAboveFullnameDoc2: data.commanderAboveFullname,
|
|
|
|
|
commanderAbovePositionDoc2: data.commanderAbovePosition,
|
|
|
|
|
commanderFullnameDoc2: data.commanderFullname,
|
|
|
|
|
commanderPositionDoc2: data.commanderPosition,
|
|
|
|
|
};
|
|
|
|
|
showLoader();
|
|
|
|
|
await http
|
|
|
|
|
.put(config.API.evaluationCheckdocV1(store.evaluateId), body)
|
|
|
|
|
.then((res) => {})
|
|
|
|
|
.catch((err) => {})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
hideLoader();
|
|
|
|
|
fetchCheckStatus();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function nextPrepareDoc2() {
|
2023-12-19 17:04:39 +07:00
|
|
|
showLoader();
|
|
|
|
|
await http
|
2023-12-22 16:00:05 +07:00
|
|
|
.put(config.API.evaluationPreparedocV2(store.evaluateId))
|
2023-12-19 17:04:39 +07:00
|
|
|
.then((res) => {})
|
|
|
|
|
.catch((err) => {})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
hideLoader();
|
2023-12-22 16:00:05 +07:00
|
|
|
fetchCheckStatus();
|
2023-12-19 17:04:39 +07:00
|
|
|
});
|
2023-12-19 10:56:51 +07:00
|
|
|
}
|
|
|
|
|
|
2023-12-19 17:04:39 +07:00
|
|
|
export default {
|
|
|
|
|
fetchCheckStatus,
|
|
|
|
|
saveEvaluation,
|
|
|
|
|
nextPrapare,
|
|
|
|
|
nextCheckDoc,
|
|
|
|
|
nextCheckDoc2,
|
2023-12-22 16:00:05 +07:00
|
|
|
nextPrepareDoc2,
|
2023-12-19 17:04:39 +07:00
|
|
|
};
|