API ประเมินบุคคล

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-01-04 13:39:43 +07:00
parent fbcd0b8ec0
commit 0e033bffd3
11 changed files with 835 additions and 631 deletions

View file

@ -5,11 +5,13 @@ import { useQuasar } from "quasar";
import DialogHeader from "@/components/DialogHeader.vue";
import { useCounterMixin } from "@/stores/mixin";
import { useEvaluateStore } from "@/modules/06_evaluate/store";
import { onMounted, ref, watch } from "vue";
const router = useRouter();
const $q = useQuasar();
const mixin = useCounterMixin();
const store = useEvaluateStore();
const { dialogConfirm } = mixin;
@ -40,6 +42,8 @@ function onCklicNext() {
$q,
() => {
const type = props.menu ? props.menu.val?.toLowerCase() : "";
store.step = 1;
store.currentStep = 1;
router.push(`/evaluate/add/${type}`);
},
"ยืนยันการดำเนินการ",

View file

@ -92,13 +92,8 @@ async function onCilckNextStep() {
}
async function validateForm() {
console.log(downloadFileRef.value);
store.checkFileupload = !store.checkFileupload;
console.log(store.checkFileupload);
const emptyValues = downloadFileRef.value.filter((e: any) => e === "");
const hasError = [];
for (const key in formCommandRef) {
if (Object.prototype.hasOwnProperty.call(formCommandRef, key)) {
@ -109,11 +104,22 @@ async function validateForm() {
}
}
}
if (hasError.every((result) => result === true)) {
if (emptyValues.length > 0) {
if (emptyValues.length > 0 && store.statusUpload === true) {
console.log("There are empty values in the array.");
} else if (store.step === 2) {
if (store.statusUpload === false) {
saveStep2();
} else {
nextTostep3();
}
} else {
store.step === 2 ? saveStep2() : saveStep6();
if (store.statusUpload === false) {
saveStep6();
} else {
nextTostep7();
}
}
// store.step === 2 && emptyValues.length > 0 ? saveStep2() : saveStep6();
@ -308,11 +314,15 @@ async function saveStep1() {
}
/** STEP 2*/
const statusUpload = ref<boolean>(false);
const formCommand = reactive<FormCommand>({
commanderFullname: "",
commanderPosition: "",
commanderAboveFullname: "",
commanderAbovePosition: "",
author: "",
subject: "",
assignedPosition: "",
});
const commanderFullnameRef = ref<object | null>(null);
const commanderPositionRef = ref<object | null>(null);
@ -324,6 +334,9 @@ const fileEvaluation3Ref = ref<object | null>(null);
const fileEvaluation4Ref = ref<object | null>(null);
const fileEvaluation5Ref = ref<object | null>(null);
const fileEvaluation6Ref = ref<object | null>(null);
const performanceRef = ref<object | null>(null);
const performanceOwnerRef = ref<object | null>(null);
const assignedPositionRef = ref<object | null>(null);
const formCommandRef: FormCommandRef = {
commanderFullname: commanderFullnameRef,
commanderPosition: commanderPositionRef,
@ -335,6 +348,9 @@ const formCommandRef: FormCommandRef = {
fileEvaluation4: fileEvaluation4Ref,
fileEvaluation5: fileEvaluation5Ref,
fileEvaluation6: fileEvaluation6Ref,
performance: performanceRef,
performanceOwner: performanceOwnerRef,
assignedPosition: assignedPositionRef,
};
const downloadFileRef = ref<any>();
@ -343,6 +359,9 @@ function updateformCommand(val: any, ref: any) {
formCommand.commanderPosition = val.commanderPosition;
formCommand.commanderAboveFullname = val.commanderAboveFullname;
formCommand.commanderAbovePosition = val.commanderAbovePosition;
formCommand.author = val.author;
formCommand.subject = val.subject;
formCommand.assignedPosition = val.assignedPosition;
commanderFullnameRef.value = ref.commanderFullnameRef;
commanderPositionRef.value = ref.commanderPositionRef;
commanderAboveFullnameRef.value = ref.commanderAboveFullnameRef;
@ -354,20 +373,59 @@ function updateformCommand(val: any, ref: any) {
fileEvaluation5Ref.value = ref.fileEvaluation5Ref;
fileEvaluation6Ref.value = ref.fileEvaluation6Ref;
downloadFileRef.value = ref.downloadFile;
performanceRef.value = ref.performance;
performanceOwnerRef.value = ref.performanceOwner;
assignedPositionRef.value = ref.assignedPosition;
statusUpload.value = ref.statusUpload;
}
async function saveStep2() {
const body = {
commanderFullname: formCommand.commanderFullname,
commanderPosition: formCommand.commanderPosition,
commanderAboveFullname: formCommand.commanderAboveFullname,
commanderAbovePosition: formCommand.commanderAbovePosition,
author: formCommand.author,
subject: formCommand.subject,
};
dialogConfirm(
$q,
async () => {
statusUpload.value = true;
store.statusUpload = statusUpload.value;
showLoader();
await http
.put(
config.API.evaluationUpdateAuthor(
route.params.id.toString(),
"director"
),
body
)
.then(() => {
route.params.id && fetchCheckStep(route.params.id.toString());
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
},
"ยืนยันการบันทึกข้อมูล",
"ต้องการยืนยันการบันทึกข้อมูลนี้ใช่หรือไม่?"
);
}
async function nextTostep3() {
dialogConfirm(
$q,
async () => {
showLoader();
await http
.put(
config.API.evaluationPreparedoc(
route.params.id.toString(),
"approve"
),
formCommand
config.API.evaluationPreparedoc(route.params.id.toString(), "approve")
)
.then(() => {
route.params.id && fetchCheckStep(route.params.id.toString());
@ -384,6 +442,7 @@ async function saveStep2() {
);
}
/** STEP3*/
async function saveStep3() {
showLoader();
await http
@ -404,19 +463,54 @@ async function saveStep4() {
async function saveStep5() {
console.log("Save 5");
}
/** STEP 6*/
async function saveStep6() {
const body = {
commanderAboveFullnameDoc2: formCommand.commanderAboveFullname,
commanderAbovePositionDoc2: formCommand.commanderAbovePosition,
commanderFullnameDoc2: formCommand.commanderFullname,
commanderPositionDoc2: formCommand.commanderPosition,
authorDoc2: formCommand.author,
subjectDoc2: formCommand.subject,
assignedPosition: formCommand.assignedPosition,
};
dialogConfirm(
$q,
async () => {
statusUpload.value = true;
store.statusUpload = statusUpload.value;
showLoader();
await http
.put(
config.API.evaluationUpdateAuthor(
route.params.id.toString(),
"director2"
),
body
)
.then(() => {
route.params.id && fetchCheckStep(route.params.id.toString());
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
},
"ยืนยันการบันทึกข้อมูล",
"ต้องการยืนยันการบันทึกข้อมูลนี้ใช่หรือไม่?"
);
}
async function nextTostep7() {
dialogConfirm(
$q,
async () => {
showLoader();
await http
.put(config.API.evaluationCheckdocV2(route.params.id.toString()), body)
.put(config.API.evaluationCheckdocV2(route.params.id.toString()))
.then(() => {
route.params.id && fetchCheckStep(route.params.id.toString());
})
@ -431,6 +525,7 @@ async function saveStep6() {
"ต้องการยืนยันการดำเนินการต่อใช่หรือไม่?"
);
}
async function saveStep7() {
showLoader();
await http
@ -576,7 +671,6 @@ onMounted(async () => {
class="col-xs-12 col-sm-7 row"
v-if="store.step === 1 || store.step === 3 || store.step === 7"
>
<!-- <q-card flat bordered class="col-12"> -->
<div class="col-12">
<ViewStep1
v-if="store.step === 1"
@ -594,14 +688,13 @@ onMounted(async () => {
:urlDownloadFile="urlDownloadFile"
/>
</div>
<!-- </q-card> -->
</div>
</div>
<div class="q-mt-md q-gutter-md" align="right">
<q-btn
v-if="
store.step >= store.currentStep &&
store.statusUpload === false &&
store.step !== 3 &&
store.step !== 4 &&
store.step !== 5 &&
@ -610,10 +703,15 @@ onMounted(async () => {
store.step !== 9
"
unelevated
label="ดำเนินการต่อ"
:label="
store.step === 2 || store.step === 6
? 'บันทึกข้อมูล'
: 'ดำเนินการต่อ'
"
color="public"
@click="onCilckNextStep()"
/>
<q-btn
v-else-if="
store.step >= store.currentStep &&
@ -624,6 +722,29 @@ onMounted(async () => {
color="public"
@click="onCilckNextStep()"
/>
<q-btn
v-if="
store.step >= store.currentStep &&
store.step == 2 &&
store.statusUpload
"
unelevated
label="ดำเนินการต่อ"
color="public"
@click="onCilckNextStep()"
/>
<q-btn
v-if="
store.step >= store.currentStep &&
store.step == 6 &&
store.statusUpload
"
unelevated
label="ดำเนินการต่อ"
color="public"
@click="onCilckNextStep()"
/>
</div>
</div>
</q-card>

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref, onMounted } from "vue";
import { ref, onMounted, watch } from "vue";
import type { QTableProps } from "quasar";
import { useRouter } from "vue-router";
@ -8,6 +8,23 @@ import { useEvaluateStore } from "@/modules/06_evaluate/store";
const store = useEvaluateStore();
const router = useRouter();
const props = defineProps({
page: {
type: Number,
require: true,
},
pageSize: {
type: Number,
require: true,
},
maxPage: {
type: Number,
require: true,
},
});
const emit = defineEmits(["update:pagination"]);
/** ค้นหาคอลัม */
const visibleColumns = ref<string[]>(["no", "type", "dateSend", "status"]);
const columns = ref<QTableProps["columns"]>([
@ -51,10 +68,25 @@ const columns = ref<QTableProps["columns"]>([
const pagination = ref({
sortBy: "",
descending: true,
page: 1,
rowsPerPage: 10,
page: props.page,
rowsPerPage: props.pageSize,
});
const currentPage = ref<number>(1);
function updateProp(newPagination: any, page: number) {
emit("update:pagination", newPagination, page);
}
/**
* function updatePageSize
* @param newPagination PageSize
*/
function updateRowsPerPagen(newPagination: any) {
pagination.value.rowsPerPage = newPagination.rowsPerPage;
currentPage.value = 1;
}
function redirectToDetail(data: any) {
router.push(`/evaluate/detail/${data.typeparam.toLowerCase()}/${data.id}`);
}
@ -63,6 +95,11 @@ onMounted(() => {
store.columns = columns.value;
store.visibleColumns = visibleColumns.value;
});
/** function Callblck ทำงานเมื่อ pagination มีการเปลี่ยนแปลง */
watch([() => currentPage.value, () => pagination.value.rowsPerPage], () => {
updateProp(pagination.value, currentPage.value);
});
</script>
<template>
<q-table
@ -77,6 +114,7 @@ onMounted(() => {
:visible-columns="store.visibleColumns"
:filter="store.filterKeyword"
v-model:pagination="pagination"
@update:pagination="updateRowsPerPagen"
>
<template v-slot:header="props">
<q-tr :props="props">
@ -104,13 +142,13 @@ onMounted(() => {
</template>
<template v-slot:pagination="scope">
<q-pagination
v-model="pagination.page"
v-model="currentPage"
active-color="primary"
color="dark"
size="sm"
boundary-links
direction-links
:max="scope.pagesNumber"
:max="Number(props.maxPage)"
></q-pagination>
</template>
</q-table>

File diff suppressed because it is too large Load diff

View file

@ -123,7 +123,7 @@ onMounted(async () => {
icon="mdi-clipboard-outline"
@click="onClickfetchDocument(item.fileName, 'COPPY')"
>
<q-tooltip>ดลอกล</q-tooltip>
<q-tooltip>ดลอกล</q-tooltip>
</q-btn>
</q-item-section>
</q-item>
@ -160,7 +160,7 @@ onMounted(async () => {
)
"
>
<q-tooltip>ดลอกล</q-tooltip>
<q-tooltip>ดลอกล</q-tooltip>
</q-btn>
</q-item-section>
</q-item>

View file

@ -31,15 +31,14 @@ const performance = ref<string>("");
const performanceOwner = ref<string>("");
const position = ref<string>("");
const performanceRef = ref<object | null>(null);
const performanceOwnerRef = ref<object | null>(null);
const positionRef = ref<object | null>(null);
const formCommand = reactive<FormCommand>({
commanderFullname: "",
commanderPosition: "",
commanderAboveFullname: "",
commanderAbovePosition: "",
author: "",
subject: "",
assignedPosition: "",
});
const commanderFullnameRef = ref<object | null>(null);
@ -47,6 +46,9 @@ const commanderPositionRef = ref<object | null>(null);
const commanderAboveFullnameRef = ref<object | null>(null);
const commanderAbovePositionRef = ref<object | null>(null);
const fileEvaluation1Ref = ref<object | null>(null);
const performanceRef = ref<object | null>(null);
const performanceOwnerRef = ref<object | null>(null);
const assignedPositionRef = ref<object | null>(null);
const modalView = ref<boolean>(false);
function onClickViewPDF(file: any) {
@ -62,6 +64,9 @@ const updateInput = (value: any) => {
commanderAbovePositionRef: commanderAbovePositionRef.value,
fileEvaluation1Ref: fileEvaluation1Ref.value,
downloadFile: [downloadUrl.value],
performance: performanceRef.value,
performanceOwner: performanceOwnerRef.value,
assignedPosition: assignedPositionRef.value,
};
emit("update:form", value, ref);
};
@ -78,7 +83,7 @@ async function fetchPathUpload(
metadata: {
subject: performance.value,
author: performanceOwner.value,
position: position.value
position: position.value,
},
},
};
@ -104,7 +109,6 @@ async function fetchPathUpload(
}
async function uploadfile(uploadUrl: string, file: any) {
console.log(uploadUrl);
await axios
.put(uploadUrl, file, {
headers: {
@ -130,10 +134,15 @@ async function fetcheSigner(id: string) {
formCommand.commanderPosition = data.commanderPositionDoc2;
formCommand.commanderAboveFullname = data.commanderAboveFullnameDoc2;
formCommand.commanderAbovePosition = data.commanderAbovePositionDoc2;
formCommand.author = data.authorDoc2;
formCommand.subject = data.subjectDoc2;
formCommand.assignedPosition = data.assignedPosition;
store.statusUpload = true;
})
.catch(() => {
store.statusUpload = false;
})
// .catch((err) => {
// messageError($q, err);
// })
.finally(() => {
hideLoader();
});
@ -159,19 +168,6 @@ async function fetchCheckDate() {
.catch((err) => {}));
}
onMounted(async () => {
if (keycloak.tokenParsed != null) {
performanceOwner.value = keycloak.tokenParsed.name;
}
checkDoc();
if (store.currentStep > 2) {
fetcheSigner(evaluateId.value);
}
await fetchCheckDate();
// props.evaluateId && (await fetchPathUpload(" 2", props.evaluateId));
});
const downloadUrl = ref<string>("");
function checkDoc() {
showLoader();
@ -194,12 +190,28 @@ function checkDoc() {
commanderAbovePositionRef: commanderAbovePositionRef.value,
fileEvaluation1Ref: fileEvaluation1Ref.value,
downloadFile: [downloadUrl.value],
performance: performanceRef.value,
performanceOwner: performanceOwnerRef.value,
assignedPosition: assignedPositionRef.value,
};
emit("update:form", formCommand, ref);
});
}
onMounted(async () => {
if (keycloak.tokenParsed != null) {
formCommand.author = keycloak.tokenParsed.name;
}
checkDoc();
if (store.currentStep > 2) {
fetcheSigner(evaluateId.value);
}
await fetchCheckDate();
// props.evaluateId && (await fetchPathUpload(" 2", props.evaluateId));
});
watch(
() => store.checkFileupload,
() => {
@ -208,8 +220,14 @@ watch(
: fileEvaluation1.value;
}
);
// onMounted(() => {});
watch(
() => store.statusUpload,
() => {
setTimeout(() => {
store.statusUpload && updateInput(formCommand);
}, 200);
}
);
</script>
<template>
@ -242,7 +260,7 @@ watch(
class="col-xs-12 col-sm-6"
outlined
label="ชื่อผลงาน"
v-model="performance"
v-model="formCommand.subject"
@update:model-value="updateInput(formCommand)"
:rules="[(val) => !!val || `${'กรุณากรอกชื่อผลงาน'}`]"
lazy-rules
@ -253,7 +271,7 @@ watch(
class="col-xs-12 col-sm-6"
dense
outlined
v-model="performanceOwner"
v-model="formCommand.author"
@update:model-value="updateInput(formCommand)"
label="เจ้าของผลงาน"
:rules="[(val) => !!val || `${'กรุณากรอกเจ้าของผลงาน'}`]"
@ -261,11 +279,11 @@ watch(
/>
<q-input
:readonly="store.currentStep != 6"
ref="positionRef"
ref="assignedPositionRef"
class="col-xs-12 col-sm-6"
dense
outlined
v-model="position"
v-model="formCommand.assignedPosition"
@update:model-value="updateInput(formCommand)"
label="ตำแหน่งที่ได้รับ"
:rules="[
@ -281,7 +299,7 @@ watch(
</q-card>
</div>
<div class="col-6" v-if="store.currentStep === 6">
<div class="col-6" v-if="store.statusUpload && store.currentStep === 6">
<q-card bordered style="border: 1px solid #d6dee1">
<div class="text-weight-medium bg-grey-1 q-py-sm q-px-md">
เอกสารเล 2

View file

@ -41,11 +41,11 @@ function copyLink() {
class="q-mt-md"
outline
icon="mdi-clipboard-outline"
label="คัดลอกลิง์"
label="คัดลอกลิง์"
color="primary"
@click="copyLink"
>
<q-tooltip> ดลอกล </q-tooltip></q-btn
<q-tooltip> ดลอกล </q-tooltip></q-btn
>
</div>
</div>

View file

@ -13,6 +13,9 @@ interface FormCommand {
commanderPosition: string;
commanderAboveFullname: string;
commanderAbovePosition: string;
author: string;
subject: string;
assignedPosition: string;
}
interface FormCommandRef {
@ -26,6 +29,8 @@ interface FormCommandRef {
fileEvaluation4: object | null;
fileEvaluation5: object | null;
fileEvaluation6: object | null;
performance: object | null;
performanceOwner: object | null;
[key: string]: any;
}

View file

@ -29,6 +29,7 @@ export const useEvaluateStore = defineStore("evaluateStore", () => {
const showLoadStatus = ref<boolean>(false);
const step = ref<number>(1);
const currentStep = ref<number>(1);
const statusUpload = ref<boolean>(false);
const title = ref<string[]>([
"ตรวจสอบคุณสมบัติ",
"จัดเตรียมเอกสารเล่ม 1",
@ -65,7 +66,6 @@ export const useEvaluateStore = defineStore("evaluateStore", () => {
}
const tabPanels = ref<string>("1");
const evaluateId = ref<string>("");
return {
@ -79,6 +79,7 @@ export const useEvaluateStore = defineStore("evaluateStore", () => {
checkFileupload,
step,
currentStep,
statusUpload,
title,
tabPanels,
evaluateId,

View file

@ -36,12 +36,19 @@ function onclickAddEvaluate(data: ListMenu) {
modal.value = !modal.value;
menu.value = data;
}
const page = ref<number>(1);
const pageSize = ref<number>(25);
const maxPage = ref<number>(10);
async function fetchEvaluteList() {
showLoader();
await http
.get(config.API.evaluationList())
.get(
config.API.evaluationList() +
`?page=${page.value}&pageSize=${pageSize.value}`
)
.then((res) => {
maxPage.value = Math.ceil(res.data.result.total / pageSize.value);
store.fetchEvaluateList(res.data.result.data);
})
.catch((err) => {
@ -52,6 +59,13 @@ async function fetchEvaluteList() {
});
}
async function updatePaging(newPagination: any, currentPage: number) {
page.value = currentPage;
pageSize.value = newPagination.rowsPerPage;
await fetchEvaluteList();
}
onMounted(() => {
fetchEvaluteList();
});
@ -128,7 +142,12 @@ onMounted(() => {
</div>
</div>
<div class="col-12">
<TableListEvaluate />
<TableListEvaluate
:page="page"
:pageSize="pageSize"
:maxPage="maxPage"
@update:pagination="updatePaging"
/>
</div>
</q-card>
</div>